aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie2010-03-03 02:07:03 +0000
committerMelanie2010-03-03 02:07:03 +0000
commit028a87fe37002e7a0611f66babf1deee46c83804 (patch)
tree387aec499fd60c2012bed8148e6a2ddc847c3d95 /OpenSim/Region
parentRevert "test" (diff)
parentFixes Region.Framework tests. Although these tests don't fail, they need to b... (diff)
downloadopensim-SC_OLD-028a87fe37002e7a0611f66babf1deee46c83804.zip
opensim-SC_OLD-028a87fe37002e7a0611f66babf1deee46c83804.tar.gz
opensim-SC_OLD-028a87fe37002e7a0611f66babf1deee46c83804.tar.bz2
opensim-SC_OLD-028a87fe37002e7a0611f66babf1deee46c83804.tar.xz
Merge branch 'master' into careminster-presence-refactor
This brings careminster on the level of master. To be tested
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Application/Application.cs1
-rw-r--r--OpenSim/Region/Application/ConfigurationLoader.cs14
-rw-r--r--OpenSim/Region/Application/HGCommands.cs60
-rwxr-xr-xOpenSim/Region/Application/OpenSim.cs150
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs43
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs1
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs4960
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs4
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs10
-rw-r--r--OpenSim/Region/ClientStack/RegionApplicationBase.cs9
-rw-r--r--OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs60
-rw-r--r--OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs68
-rw-r--r--OpenSim/Region/Communications/Hypergrid/HGUserServices.cs337
-rw-r--r--OpenSim/Region/Communications/Local/CommunicationsLocal.cs59
-rw-r--r--OpenSim/Region/Communications/Local/LocalUserServices.cs100
-rw-r--r--OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs65
-rw-r--r--OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs54
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs774
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1UserServices.cs176
-rw-r--r--OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs65
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs2
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs4
-rw-r--r--OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs2
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs46
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs16
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs11
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs1373
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs293
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs60
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs117
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs70
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs81
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs398
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs20
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs20
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs125
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs958
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs58
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs64
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs168
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs1602
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs273
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs200
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs (renamed from OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs)129
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs (renamed from OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs)3
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs655
-rw-r--r--OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs52
-rw-r--r--OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs6
-rw-r--r--OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs311
-rw-r--r--OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs19
-rw-r--r--OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs42
-rw-r--r--OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml33
-rw-r--r--OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs5
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs119
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs119
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs (renamed from OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs)23
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs128
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs28
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs20
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs2
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs164
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs (renamed from OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserServiceConnector.cs)47
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs6
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs168
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs (renamed from OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserServiceConnector.cs)18
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs303
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs811
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs16
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs19
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs6
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs842
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs11
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs307
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs5
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs26
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs200
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs100
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs164
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs104
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs (renamed from OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs)180
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs300
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs189
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs148
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs (renamed from OpenSim/Region/Communications/Hypergrid/HGUserDataPlugin.cs)73
-rw-r--r--OpenSim/Region/CoreModules/World/Access/AccessModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs50
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs14
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs28
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs33
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs15
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs52
-rw-r--r--OpenSim/Region/CoreModules/World/Sound/SoundModule.cs14
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs41
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs25
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs3
-rw-r--r--OpenSim/Region/DataSnapshot/DataSnapshotManager.cs18
-rw-r--r--OpenSim/Region/DataSnapshot/EstateSnapshot.cs15
-rw-r--r--OpenSim/Region/DataSnapshot/LandSnapshot.cs7
-rw-r--r--OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs16
-rw-r--r--OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs (renamed from OpenSim/Region/Framework/Interfaces/ITeleportModule.cs)27
-rw-r--r--OpenSim/Region/Framework/Interfaces/IFriendsModule.cs16
-rw-r--r--OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs20
-rw-r--r--OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs4
-rw-r--r--OpenSim/Region/Framework/Interfaces/IPresenceModule.cs10
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISoundModule.cs4
-rw-r--r--OpenSim/Region/Framework/Interfaces/ITerrainModule.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/IWorldComm.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs199
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs265
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs77
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs391
-rw-r--r--OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs590
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs73
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs661
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs1229
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs43
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneManager.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs183
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs342
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs186
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneViewer.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs21
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs14
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/UndoState.cs79
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs16
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs6
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs4
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs125
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs44
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs3
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs6
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs5
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs4
-rw-r--r--OpenSim/Region/OptionalModules/SvnSerialiser/SvnBackupModule.cs10
-rw-r--r--OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs24
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs15
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs12
-rw-r--r--OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs4
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs5
-rw-r--r--OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs5
-rw-r--r--OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs5
-rw-r--r--OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs19
-rw-r--r--OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs4
-rw-r--r--OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs8
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs6
-rw-r--r--OpenSim/Region/Physics/Manager/VehicleConstants.cs12
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs5
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs451
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs5
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSCharacter.cs2
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSPrim.cs2
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXCharacter.cs361
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs861
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXPrim.cs347
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs183
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs271
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs36
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs8
181 files changed, 10223 insertions, 16408 deletions
diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs
index 555baa4..7721cdf 100644
--- a/OpenSim/Region/Application/Application.cs
+++ b/OpenSim/Region/Application/Application.cs
@@ -129,7 +129,6 @@ namespace OpenSim
129 configSource.AddSwitch("Startup", "inifile"); 129 configSource.AddSwitch("Startup", "inifile");
130 configSource.AddSwitch("Startup", "inimaster"); 130 configSource.AddSwitch("Startup", "inimaster");
131 configSource.AddSwitch("Startup", "inidirectory"); 131 configSource.AddSwitch("Startup", "inidirectory");
132 configSource.AddSwitch("Startup", "gridmode");
133 configSource.AddSwitch("Startup", "physics"); 132 configSource.AddSwitch("Startup", "physics");
134 configSource.AddSwitch("Startup", "gui"); 133 configSource.AddSwitch("Startup", "gui");
135 configSource.AddSwitch("Startup", "console"); 134 configSource.AddSwitch("Startup", "console");
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs
index 21edcc5..655c5ca 100644
--- a/OpenSim/Region/Application/ConfigurationLoader.cs
+++ b/OpenSim/Region/Application/ConfigurationLoader.cs
@@ -304,7 +304,6 @@ namespace OpenSim
304 304
305 config.Set("region_info_source", "filesystem"); 305 config.Set("region_info_source", "filesystem");
306 306
307 config.Set("gridmode", false);
308 config.Set("physics", "OpenDynamicsEngine"); 307 config.Set("physics", "OpenDynamicsEngine");
309 config.Set("meshing", "Meshmerizer"); 308 config.Set("meshing", "Meshmerizer");
310 config.Set("physical_prim", true); 309 config.Set("physical_prim", true);
@@ -342,19 +341,7 @@ namespace OpenSim
342 if (null == config) 341 if (null == config)
343 config = defaultConfig.AddConfig("Network"); 342 config = defaultConfig.AddConfig("Network");
344 343
345 config.Set("default_location_x", 1000);
346 config.Set("default_location_y", 1000);
347 config.Set("http_listener_port", ConfigSettings.DefaultRegionHttpPort); 344 config.Set("http_listener_port", ConfigSettings.DefaultRegionHttpPort);
348 config.Set("remoting_listener_port", ConfigSettings.DefaultRegionRemotingPort);
349 config.Set("grid_server_url", "http://127.0.0.1:" + ConfigSettings.DefaultGridServerHttpPort.ToString());
350 config.Set("grid_send_key", "null");
351 config.Set("grid_recv_key", "null");
352 config.Set("user_server_url", "http://127.0.0.1:" + ConfigSettings.DefaultUserServerHttpPort.ToString());
353 config.Set("user_send_key", "null");
354 config.Set("user_recv_key", "null");
355 config.Set("asset_server_url", "http://127.0.0.1:" + ConfigSettings.DefaultAssetServerHttpPort.ToString());
356 config.Set("inventory_server_url", "http://127.0.0.1:" + ConfigSettings.DefaultInventoryServerHttpPort.ToString());
357 config.Set("secure_inventory_server", "true");
358 } 345 }
359 346
360 return defaultConfig; 347 return defaultConfig;
@@ -368,7 +355,6 @@ namespace OpenSim
368 IConfig startupConfig = m_config.Source.Configs["Startup"]; 355 IConfig startupConfig = m_config.Source.Configs["Startup"];
369 if (startupConfig != null) 356 if (startupConfig != null)
370 { 357 {
371 m_configSettings.Standalone = !startupConfig.GetBoolean("gridmode", false);
372 m_configSettings.PhysicsEngine = startupConfig.GetString("physics"); 358 m_configSettings.PhysicsEngine = startupConfig.GetString("physics");
373 m_configSettings.MeshEngineName = startupConfig.GetString("meshing"); 359 m_configSettings.MeshEngineName = startupConfig.GetString("meshing");
374 m_configSettings.PhysicalPrim = startupConfig.GetBoolean("physical_prim", true); 360 m_configSettings.PhysicalPrim = startupConfig.GetBoolean("physical_prim", true);
diff --git a/OpenSim/Region/Application/HGCommands.cs b/OpenSim/Region/Application/HGCommands.cs
deleted file mode 100644
index 7ae161d..0000000
--- a/OpenSim/Region/Application/HGCommands.cs
+++ /dev/null
@@ -1,60 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Xml;
32using log4net;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Console;
37using OpenSim.Region.Framework;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.Framework.Scenes.Hypergrid;
40
41namespace OpenSim
42{
43 public class HGCommands
44 {
45// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
47 public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager,
48 StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version)
49 {
50 HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager);
51
52 return
53 new HGScene(
54 regionInfo, circuitManager, m_commsManager, sceneGridService, storageManager,
55 m_moduleLoader, false, m_configSettings.PhysicalPrim,
56 m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version);
57 }
58
59 }
60}
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index a86a831..7e81650 100755
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -122,8 +122,7 @@ namespace OpenSim
122 m_log.Info("===================================================================="); 122 m_log.Info("====================================================================");
123 m_log.Info("========================= STARTING OPENSIM ========================="); 123 m_log.Info("========================= STARTING OPENSIM =========================");
124 m_log.Info("===================================================================="); 124 m_log.Info("====================================================================");
125 m_log.InfoFormat("[OPENSIM MAIN]: Running in {0} mode", 125 m_log.InfoFormat("[OPENSIM MAIN]: Running ");
126 (ConfigurationSettings.Standalone ? "sandbox" : "grid"));
127 //m_log.InfoFormat("[OPENSIM MAIN]: GC Is Server GC: {0}", GCSettings.IsServerGC.ToString()); 126 //m_log.InfoFormat("[OPENSIM MAIN]: GC Is Server GC: {0}", GCSettings.IsServerGC.ToString());
128 // http://msdn.microsoft.com/en-us/library/bb384202.aspx 127 // http://msdn.microsoft.com/en-us/library/bb384202.aspx
129 //GCSettings.LatencyMode = GCLatencyMode.Batch; 128 //GCSettings.LatencyMode = GCLatencyMode.Batch;
@@ -153,6 +152,11 @@ namespace OpenSim
153 RegisterConsoleCommands(); 152 RegisterConsoleCommands();
154 153
155 base.StartupSpecific(); 154 base.StartupSpecific();
155
156 MainServer.Instance.AddStreamHandler(new OpenSim.SimStatusHandler());
157 MainServer.Instance.AddStreamHandler(new OpenSim.XSimStatusHandler(this));
158 if (userStatsURI != String.Empty)
159 MainServer.Instance.AddStreamHandler(new OpenSim.UXSimStatusHandler(this));
156 160
157 if (m_console is RemoteConsole) 161 if (m_console is RemoteConsole)
158 { 162 {
@@ -190,6 +194,8 @@ namespace OpenSim
190 194
191 PrintFileToConsole("startuplogo.txt"); 195 PrintFileToConsole("startuplogo.txt");
192 196
197 m_log.InfoFormat("[NETWORK]: Using {0} as SYSTEMIP", Util.GetLocalHost().ToString());
198
193 // For now, start at the 'root' level by default 199 // For now, start at the 'root' level by default
194 if (m_sceneManager.Scenes.Count == 1) // If there is only one region, select it 200 if (m_sceneManager.Scenes.Count == 1) // If there is only one region, select it
195 ChangeSelectedRegion("region", 201 ChangeSelectedRegion("region",
@@ -348,26 +354,6 @@ namespace OpenSim
348 "kill uuid <UUID>", 354 "kill uuid <UUID>",
349 "Kill an object by UUID", KillUUID); 355 "Kill an object by UUID", KillUUID);
350 356
351 if (ConfigurationSettings.Standalone)
352 {
353 m_console.Commands.AddCommand("region", false, "create user",
354 "create user [<first> [<last> [<pass> [<x> <y> [<email>]]]]]",
355 "Create a new user", HandleCreateUser);
356
357 m_console.Commands.AddCommand("region", false, "reset user password",
358 "reset user password [<first> [<last> [<password>]]]",
359 "Reset a user password", HandleResetUserPassword);
360 }
361
362 m_console.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
363 "Set local coordinate to map HG regions to", RunCommand);
364 m_console.Commands.AddCommand("hypergrid", false, "link-region",
365 "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
366 "Link a hypergrid region", RunCommand);
367 m_console.Commands.AddCommand("hypergrid", false, "unlink-region",
368 "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
369 "Unlink a hypergrid region", RunCommand);
370
371 } 357 }
372 358
373 public override void ShutdownSpecific() 359 public override void ShutdownSpecific()
@@ -420,7 +406,7 @@ namespace OpenSim
420 406
421 foreach (ScenePresence presence in agents) 407 foreach (ScenePresence presence in agents)
422 { 408 {
423 RegionInfo regionInfo = m_sceneManager.GetRegionInfo(presence.RegionHandle); 409 RegionInfo regionInfo = presence.Scene.RegionInfo;
424 410
425 if (presence.Firstname.ToLower().Contains(cmdparams[2].ToLower()) && 411 if (presence.Firstname.ToLower().Contains(cmdparams[2].ToLower()) &&
426 presence.Lastname.ToLower().Contains(cmdparams[3].ToLower())) 412 presence.Lastname.ToLower().Contains(cmdparams[3].ToLower()))
@@ -433,7 +419,7 @@ namespace OpenSim
433 // kick client... 419 // kick client...
434 if (alert != null) 420 if (alert != null)
435 presence.ControllingClient.Kick(alert); 421 presence.ControllingClient.Kick(alert);
436 else 422 else
437 presence.ControllingClient.Kick("\nThe OpenSim manager kicked you out.\n"); 423 presence.ControllingClient.Kick("\nThe OpenSim manager kicked you out.\n");
438 424
439 // ...and close on our side 425 // ...and close on our side
@@ -640,7 +626,6 @@ namespace OpenSim
640 } 626 }
641 } 627 }
642 628
643
644 /// <summary> 629 /// <summary>
645 /// Load, Unload, and list Region modules in use 630 /// Load, Unload, and list Region modules in use
646 /// </summary> 631 /// </summary>
@@ -777,38 +762,6 @@ namespace OpenSim
777 } 762 }
778 763
779 /// <summary> 764 /// <summary>
780 /// Execute switch for some of the create commands
781 /// </summary>
782 /// <param name="args"></param>
783 private void HandleCreateUser(string module, string[] cmd)
784 {
785 if (ConfigurationSettings.Standalone)
786 {
787 CreateUser(cmd);
788 }
789 else
790 {
791 MainConsole.Instance.Output("Create user is not available in grid mode, use the user server.");
792 }
793 }
794
795 /// <summary>
796 /// Execute switch for some of the reset commands
797 /// </summary>
798 /// <param name="args"></param>
799 protected void HandleResetUserPassword(string module, string[] cmd)
800 {
801 if (ConfigurationSettings.Standalone)
802 {
803 ResetUserPassword(cmd);
804 }
805 else
806 {
807 MainConsole.Instance.Output("Reset user password is not available in grid mode, use the user-server.");
808 }
809 }
810
811 /// <summary>
812 /// Turn on some debugging values for OpenSim. 765 /// Turn on some debugging values for OpenSim.
813 /// </summary> 766 /// </summary>
814 /// <param name="args"></param> 767 /// <param name="args"></param>
@@ -908,7 +861,7 @@ namespace OpenSim
908 861
909 foreach (ScenePresence presence in agents) 862 foreach (ScenePresence presence in agents)
910 { 863 {
911 RegionInfo regionInfo = m_sceneManager.GetRegionInfo(presence.RegionHandle); 864 RegionInfo regionInfo = presence.Scene.RegionInfo;
912 string regionName; 865 string regionName;
913 866
914 if (regionInfo == null) 867 if (regionInfo == null)
@@ -972,7 +925,6 @@ namespace OpenSim
972 scene.RegionInfo.RegionLocX, 925 scene.RegionInfo.RegionLocX,
973 scene.RegionInfo.RegionLocY, 926 scene.RegionInfo.RegionLocY,
974 scene.RegionInfo.InternalEndPoint.Port)); 927 scene.RegionInfo.InternalEndPoint.Port));
975
976 }); 928 });
977 break; 929 break;
978 930
@@ -1047,86 +999,6 @@ namespace OpenSim
1047 } 999 }
1048 1000
1049 /// <summary> 1001 /// <summary>
1050 /// Create a new user
1051 /// </summary>
1052 /// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
1053 protected void CreateUser(string[] cmdparams)
1054 {
1055 string firstName;
1056 string lastName;
1057 string password;
1058 string email;
1059 uint regX = 1000;
1060 uint regY = 1000;
1061
1062 IConfig standalone;
1063 if ((standalone = m_config.Source.Configs["StandAlone"]) != null)
1064 {
1065 regX = (uint)standalone.GetInt("default_location_x", (int)regX);
1066 regY = (uint)standalone.GetInt("default_location_y", (int)regY);
1067 }
1068
1069
1070 if (cmdparams.Length < 3)
1071 firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
1072 else firstName = cmdparams[2];
1073
1074 if (cmdparams.Length < 4)
1075 lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
1076 else lastName = cmdparams[3];
1077
1078 if (cmdparams.Length < 5)
1079 password = MainConsole.Instance.PasswdPrompt("Password");
1080 else password = cmdparams[4];
1081
1082 if (cmdparams.Length < 6)
1083 regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString()));
1084 else regX = Convert.ToUInt32(cmdparams[5]);
1085
1086 if (cmdparams.Length < 7)
1087 regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString()));
1088 else regY = Convert.ToUInt32(cmdparams[6]);
1089
1090 if (cmdparams.Length < 8)
1091 email = MainConsole.Instance.CmdPrompt("Email", "");
1092 else email = cmdparams[7];
1093
1094 if (null == m_commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName))
1095 {
1096 m_commsManager.UserAdminService.AddUser(firstName, lastName, password, email, regX, regY);
1097 }
1098 else
1099 {
1100 MainConsole.Instance.Output(string.Format("A user with the name {0} {1} already exists!", firstName, lastName));
1101 }
1102 }
1103
1104 /// <summary>
1105 /// Reset a user password.
1106 /// </summary>
1107 /// <param name="cmdparams"></param>
1108 private void ResetUserPassword(string[] cmdparams)
1109 {
1110 string firstName;
1111 string lastName;
1112 string newPassword;
1113
1114 if (cmdparams.Length < 4)
1115 firstName = MainConsole.Instance.CmdPrompt("First name");
1116 else firstName = cmdparams[3];
1117
1118 if (cmdparams.Length < 5)
1119 lastName = MainConsole.Instance.CmdPrompt("Last name");
1120 else lastName = cmdparams[4];
1121
1122 if (cmdparams.Length < 6)
1123 newPassword = MainConsole.Instance.PasswdPrompt("New password");
1124 else newPassword = cmdparams[5];
1125
1126 m_commsManager.UserAdminService.ResetUserPassword(firstName, lastName, newPassword);
1127 }
1128
1129 /// <summary>
1130 /// Use XML2 format to serialize data to a file 1002 /// Use XML2 format to serialize data to a file
1131 /// </summary> 1003 /// </summary>
1132 /// <param name="module"></param> 1004 /// <param name="module"></param>
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index cf2ab65..06ffa91 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -36,8 +36,7 @@ using Nini.Config;
36using OpenMetaverse; 36using OpenMetaverse;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Services; 39
40using OpenSim.Framework.Communications.Cache;
41using OpenSim.Framework.Console; 40using OpenSim.Framework.Console;
42using OpenSim.Framework.Servers; 41using OpenSim.Framework.Servers;
43using OpenSim.Framework.Servers.HttpServer; 42using OpenSim.Framework.Servers.HttpServer;
@@ -85,8 +84,6 @@ namespace OpenSim
85 84
86 protected ConfigurationLoader m_configLoader; 85 protected ConfigurationLoader m_configLoader;
87 86
88 protected GridInfoService m_gridInfoService;
89
90 public ConsoleCommand CreateAccount = null; 87 public ConsoleCommand CreateAccount = null;
91 88
92 protected List<IApplicationPlugin> m_plugins = new List<IApplicationPlugin>(); 89 protected List<IApplicationPlugin> m_plugins = new List<IApplicationPlugin>();
@@ -555,35 +552,6 @@ namespace OpenSim
555 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); 552 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
556 scene.PhysicsScene.SetWaterLevel((float) regionInfo.RegionSettings.WaterHeight); 553 scene.PhysicsScene.SetWaterLevel((float) regionInfo.RegionSettings.WaterHeight);
557 554
558 // TODO: Remove this cruft once MasterAvatar is fully deprecated
559 //Master Avatar Setup
560 UserProfileData masterAvatar;
561 if (scene.RegionInfo.MasterAvatarAssignedUUID == UUID.Zero)
562 {
563 masterAvatar =
564 m_commsManager.UserService.SetupMasterUser(scene.RegionInfo.MasterAvatarFirstName,
565 scene.RegionInfo.MasterAvatarLastName,
566 scene.RegionInfo.MasterAvatarSandboxPassword);
567 }
568 else
569 {
570 masterAvatar = m_commsManager.UserService.SetupMasterUser(scene.RegionInfo.MasterAvatarAssignedUUID);
571 scene.RegionInfo.MasterAvatarFirstName = masterAvatar.FirstName;
572 scene.RegionInfo.MasterAvatarLastName = masterAvatar.SurName;
573 }
574
575 if (masterAvatar == null)
576 {
577 m_log.Info("[PARCEL]: No master avatar found, using null.");
578 scene.RegionInfo.MasterAvatarAssignedUUID = UUID.Zero;
579 }
580 else
581 {
582 m_log.InfoFormat("[PARCEL]: Found master avatar {0} {1} [" + masterAvatar.ID.ToString() + "]",
583 scene.RegionInfo.MasterAvatarFirstName, scene.RegionInfo.MasterAvatarLastName);
584 scene.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.ID;
585 }
586
587 return scene; 555 return scene;
588 } 556 }
589 557
@@ -606,15 +574,10 @@ namespace OpenSim
606 protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, 574 protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager,
607 AgentCircuitManager circuitManager) 575 AgentCircuitManager circuitManager)
608 { 576 {
609 bool hgrid = ConfigSource.Source.Configs["Startup"].GetBoolean("hypergrid", false); 577 SceneCommunicationService sceneGridService = new SceneCommunicationService();
610 if (hgrid)
611 return HGCommands.CreateScene(regionInfo, circuitManager, m_commsManager,
612 storageManager, m_moduleLoader, m_configSettings, m_config, m_version);
613
614 SceneCommunicationService sceneGridService = new SceneCommunicationService(m_commsManager);
615 578
616 return new Scene( 579 return new Scene(
617 regionInfo, circuitManager, m_commsManager, sceneGridService, 580 regionInfo, circuitManager, sceneGridService,
618 storageManager, m_moduleLoader, false, m_configSettings.PhysicalPrim, 581 storageManager, m_moduleLoader, false, m_configSettings.PhysicalPrim,
619 m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); 582 m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version);
620 } 583 }
diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
index b53a2fb..9869a99 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
@@ -31,7 +31,6 @@ using OpenMetaverse;
31using OpenMetaverse.Imaging; 31using OpenMetaverse.Imaging;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes.Hypergrid;
35using OpenSim.Services.Interfaces; 34using OpenSim.Services.Interfaces;
36using log4net; 35using log4net;
37using System.Reflection; 36using System.Reflection;
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index f98e741..1696037 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -40,11 +40,10 @@ using OpenMetaverse.Packets;
40using OpenMetaverse.StructuredData; 40using OpenMetaverse.StructuredData;
41using OpenSim.Framework; 41using OpenSim.Framework;
42using OpenSim.Framework.Client; 42using OpenSim.Framework.Client;
43using OpenSim.Framework.Communications.Cache; 43
44using OpenSim.Framework.Statistics; 44using OpenSim.Framework.Statistics;
45using OpenSim.Region.Framework.Interfaces; 45using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Region.Framework.Scenes; 46using OpenSim.Region.Framework.Scenes;
47using OpenSim.Region.Framework.Scenes.Hypergrid;
48using OpenSim.Services.Interfaces; 47using OpenSim.Services.Interfaces;
49using Timer = System.Timers.Timer; 48using Timer = System.Timers.Timer;
50using AssetLandmark = OpenSim.Framework.AssetLandmark; 49using AssetLandmark = OpenSim.Framework.AssetLandmark;
@@ -122,7 +121,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
122 public event ObjectAttach OnObjectAttach; 121 public event ObjectAttach OnObjectAttach;
123 public event ObjectDeselect OnObjectDetach; 122 public event ObjectDeselect OnObjectDetach;
124 public event ObjectDrop OnObjectDrop; 123 public event ObjectDrop OnObjectDrop;
125 public event GenericCall2 OnCompleteMovementToRegion; 124 public event GenericCall1 OnCompleteMovementToRegion;
126 public event UpdateAgent OnAgentUpdate; 125 public event UpdateAgent OnAgentUpdate;
127 public event AgentRequestSit OnAgentRequestSit; 126 public event AgentRequestSit OnAgentRequestSit;
128 public event AgentSit OnAgentSit; 127 public event AgentSit OnAgentSit;
@@ -233,6 +232,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
233 public event ObjectBuy OnObjectBuy; 232 public event ObjectBuy OnObjectBuy;
234 public event BuyObjectInventory OnBuyObjectInventory; 233 public event BuyObjectInventory OnBuyObjectInventory;
235 public event AgentSit OnUndo; 234 public event AgentSit OnUndo;
235 public event AgentSit OnRedo;
236 public event LandUndo OnLandUndo;
236 public event ForceReleaseControls OnForceReleaseControls; 237 public event ForceReleaseControls OnForceReleaseControls;
237 public event GodLandStatRequest OnLandStatRequest; 238 public event GodLandStatRequest OnLandStatRequest;
238 public event RequestObjectPropertiesFamily OnObjectGroupRequest; 239 public event RequestObjectPropertiesFamily OnObjectGroupRequest;
@@ -351,6 +352,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
351 private bool m_SendLogoutPacketWhenClosing = true; 352 private bool m_SendLogoutPacketWhenClosing = true;
352 private AgentUpdateArgs lastarg; 353 private AgentUpdateArgs lastarg;
353 private bool m_IsActive = true; 354 private bool m_IsActive = true;
355 private bool m_IsLoggingOut = false;
354 356
355 protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>(); 357 protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
356 protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers 358 protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
@@ -414,6 +416,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
414 get { return m_IsActive; } 416 get { return m_IsActive; }
415 set { m_IsActive = value; } 417 set { m_IsActive = value; }
416 } 418 }
419 public bool IsLoggingOut
420 {
421 get { return m_IsLoggingOut; }
422 set { m_IsLoggingOut = value; }
423 }
424
417 public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } } 425 public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } }
418 426
419 #endregion Properties 427 #endregion Properties
@@ -2510,6 +2518,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
2510 2518
2511 public void SendAsset(AssetRequestToClient req) 2519 public void SendAsset(AssetRequestToClient req)
2512 { 2520 {
2521 if (req.AssetInf.Data == null)
2522 {
2523 m_log.ErrorFormat("Cannot send asset {0} ({1}), asset data is null",
2524 req.AssetInf.ID, req.AssetInf.Metadata.ContentType);
2525 return;
2526 }
2527
2513 //m_log.Debug("sending asset " + req.RequestAssetID); 2528 //m_log.Debug("sending asset " + req.RequestAssetID);
2514 TransferInfoPacket Transfer = new TransferInfoPacket(); 2529 TransferInfoPacket Transfer = new TransferInfoPacket();
2515 Transfer.TransferInfo.ChannelType = 2; 2530 Transfer.TransferInfo.ChannelType = 2;
@@ -4049,10 +4064,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4049 EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock(); 4064 EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock();
4050 edata.CovenantID = covenant; 4065 edata.CovenantID = covenant;
4051 edata.CovenantTimestamp = 0; 4066 edata.CovenantTimestamp = 0;
4052 if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) 4067 edata.EstateOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
4053 edata.EstateOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
4054 else
4055 edata.EstateOwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID;
4056 edata.EstateName = Utils.StringToBytes(m_scene.RegionInfo.EstateSettings.EstateName); 4068 edata.EstateName = Utils.StringToBytes(m_scene.RegionInfo.EstateSettings.EstateName);
4057 einfopack.Data = edata; 4069 einfopack.Data = edata;
4058 OutPacket(einfopack, ThrottleOutPacketType.Task); 4070 OutPacket(einfopack, ThrottleOutPacketType.Task);
@@ -4073,8 +4085,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4073 4085
4074 //Sending Estate Settings 4086 //Sending Estate Settings
4075 returnblock[0].Parameter = Utils.StringToBytes(estateName); 4087 returnblock[0].Parameter = Utils.StringToBytes(estateName);
4076 // TODO: remove this cruft once MasterAvatar is fully deprecated
4077 //
4078 returnblock[1].Parameter = Utils.StringToBytes(estateOwner.ToString()); 4088 returnblock[1].Parameter = Utils.StringToBytes(estateOwner.ToString());
4079 returnblock[2].Parameter = Utils.StringToBytes(estateID.ToString()); 4089 returnblock[2].Parameter = Utils.StringToBytes(estateID.ToString());
4080 4090
@@ -4653,6 +4663,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4653 AddLocalPacketHandler(PacketType.ObjectName, HandleObjectName, false); 4663 AddLocalPacketHandler(PacketType.ObjectName, HandleObjectName, false);
4654 AddLocalPacketHandler(PacketType.ObjectPermissions, HandleObjectPermissions, false); 4664 AddLocalPacketHandler(PacketType.ObjectPermissions, HandleObjectPermissions, false);
4655 AddLocalPacketHandler(PacketType.Undo, HandleUndo, false); 4665 AddLocalPacketHandler(PacketType.Undo, HandleUndo, false);
4666 AddLocalPacketHandler(PacketType.UndoLand, HandleLandUndo, false);
4667 AddLocalPacketHandler(PacketType.Redo, HandleRedo, false);
4656 AddLocalPacketHandler(PacketType.ObjectDuplicateOnRay, HandleObjectDuplicateOnRay); 4668 AddLocalPacketHandler(PacketType.ObjectDuplicateOnRay, HandleObjectDuplicateOnRay);
4657 AddLocalPacketHandler(PacketType.RequestObjectPropertiesFamily, HandleRequestObjectPropertiesFamily, false); 4669 AddLocalPacketHandler(PacketType.RequestObjectPropertiesFamily, HandleRequestObjectPropertiesFamily, false);
4658 AddLocalPacketHandler(PacketType.ObjectIncludeInSearch, HandleObjectIncludeInSearch); 4670 AddLocalPacketHandler(PacketType.ObjectIncludeInSearch, HandleObjectIncludeInSearch);
@@ -5199,7 +5211,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5199 args.Type = ChatTypeEnum.Shout; 5211 args.Type = ChatTypeEnum.Shout;
5200 args.Position = new Vector3(); 5212 args.Position = new Vector3();
5201 args.Scene = Scene; 5213 args.Scene = Scene;
5202 args.Sender = this; 5214 args.Sender = this;
5203 ChatMessage handlerChatFromClient2 = OnChatFromClient; 5215 ChatMessage handlerChatFromClient2 = OnChatFromClient;
5204 if (handlerChatFromClient2 != null) 5216 if (handlerChatFromClient2 != null)
5205 handlerChatFromClient2(this, args); 5217 handlerChatFromClient2(this, args);
@@ -5501,6 +5513,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5501 // for the client session anyway, in order to protect ourselves against bad code in plugins 5513 // for the client session anyway, in order to protect ourselves against bad code in plugins
5502 try 5514 try
5503 { 5515 {
5516
5504 byte[] visualparams = new byte[appear.VisualParam.Length]; 5517 byte[] visualparams = new byte[appear.VisualParam.Length];
5505 for (int i = 0; i < appear.VisualParam.Length; i++) 5518 for (int i = 0; i < appear.VisualParam.Length; i++)
5506 visualparams[i] = appear.VisualParam[i].ParamValue; 5519 visualparams[i] = appear.VisualParam[i].ParamValue;
@@ -5711,10 +5724,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5711 5724
5712 private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack) 5725 private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack)
5713 { 5726 {
5714 GenericCall2 handlerCompleteMovementToRegion = OnCompleteMovementToRegion; 5727 GenericCall1 handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
5715 if (handlerCompleteMovementToRegion != null) 5728 if (handlerCompleteMovementToRegion != null)
5716 { 5729 {
5717 handlerCompleteMovementToRegion(); 5730 handlerCompleteMovementToRegion(sender);
5718 } 5731 }
5719 handlerCompleteMovementToRegion = null; 5732 handlerCompleteMovementToRegion = null;
5720 5733
@@ -5823,7 +5836,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5823 handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, soundTriggerPacket.SoundData.OwnerID, 5836 handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, soundTriggerPacket.SoundData.OwnerID,
5824 soundTriggerPacket.SoundData.ObjectID, soundTriggerPacket.SoundData.ParentID, 5837 soundTriggerPacket.SoundData.ObjectID, soundTriggerPacket.SoundData.ParentID,
5825 soundTriggerPacket.SoundData.Gain, soundTriggerPacket.SoundData.Position, 5838 soundTriggerPacket.SoundData.Gain, soundTriggerPacket.SoundData.Position,
5826 soundTriggerPacket.SoundData.Handle); 5839 soundTriggerPacket.SoundData.Handle, 0);
5827 5840
5828 } 5841 }
5829 return true; 5842 return true;
@@ -6721,6 +6734,56 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6721 return true; 6734 return true;
6722 } 6735 }
6723 6736
6737 private bool HandleLandUndo(IClientAPI sender, Packet Pack)
6738 {
6739 UndoLandPacket undolanditem = (UndoLandPacket)Pack;
6740
6741 #region Packet Session and User Check
6742 if (m_checkPackets)
6743 {
6744 if (undolanditem.AgentData.SessionID != SessionId ||
6745 undolanditem.AgentData.AgentID != AgentId)
6746 return true;
6747 }
6748 #endregion
6749
6750 LandUndo handlerOnUndo = OnLandUndo;
6751 if (handlerOnUndo != null)
6752 {
6753 handlerOnUndo(this);
6754 }
6755 return true;
6756 }
6757
6758 private bool HandleRedo(IClientAPI sender, Packet Pack)
6759 {
6760 RedoPacket redoitem = (RedoPacket)Pack;
6761
6762 #region Packet Session and User Check
6763 if (m_checkPackets)
6764 {
6765 if (redoitem.AgentData.SessionID != SessionId ||
6766 redoitem.AgentData.AgentID != AgentId)
6767 return true;
6768 }
6769 #endregion
6770
6771 if (redoitem.ObjectData.Length > 0)
6772 {
6773 for (int i = 0; i < redoitem.ObjectData.Length; i++)
6774 {
6775 UUID objiD = redoitem.ObjectData[i].ObjectID;
6776 AgentSit handlerOnRedo = OnRedo;
6777 if (handlerOnRedo != null)
6778 {
6779 handlerOnRedo(this, objiD);
6780 }
6781
6782 }
6783 }
6784 return true;
6785 }
6786
6724 private bool HandleObjectDuplicateOnRay(IClientAPI sender, Packet Pack) 6787 private bool HandleObjectDuplicateOnRay(IClientAPI sender, Packet Pack)
6725 { 6788 {
6726 ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack; 6789 ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack;
@@ -6984,7 +7047,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6984 assetRequestItem = invService.GetItem(assetRequestItem); 7047 assetRequestItem = invService.GetItem(assetRequestItem);
6985 if (assetRequestItem == null) 7048 if (assetRequestItem == null)
6986 { 7049 {
6987 assetRequestItem = ((Scene)m_scene).CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); 7050 ILibraryService lib = m_scene.RequestModuleInterface<ILibraryService>();
7051 if (lib != null)
7052 assetRequestItem = lib.LibraryRootFolder.FindItem(itemID);
6988 if (assetRequestItem == null) 7053 if (assetRequestItem == null)
6989 return true; 7054 return true;
6990 } 7055 }
@@ -10958,4855 +11023,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
10958 /// <param name="Pack">OpenMetaverse.packet</param> 11023 /// <param name="Pack">OpenMetaverse.packet</param>
10959 public void ProcessInPacket(Packet Pack) 11024 public void ProcessInPacket(Packet Pack)
10960 { 11025 {
10961 11026// m_log.DebugFormat("[CLIENT]: Packet IN {0}", Pack);
10962 if (ProcessPacketMethod(Pack))
10963 {
10964 PacketPool.Instance.ReturnPacket(Pack);
10965 return;
10966 }
10967
10968 // Main packet processing conditional
10969 switch (Pack.Type)
10970 {
10971 #region CommentedOut
10972 /*
10973 #region Scene/Avatar
10974
10975
10976 case PacketType.AvatarPropertiesRequest:
10977 AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack;
10978
10979 #region Packet Session and User Check
10980 if (m_checkPackets)
10981 {
10982 if (avatarProperties.AgentData.SessionID != SessionId ||
10983 avatarProperties.AgentData.AgentID != AgentId)
10984 break;
10985 }
10986 #endregion
10987
10988 RequestAvatarProperties handlerRequestAvatarProperties = OnRequestAvatarProperties;
10989 if (handlerRequestAvatarProperties != null)
10990 {
10991 handlerRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID);
10992 }
10993
10994 break;
10995
10996 case PacketType.ChatFromViewer:
10997 ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
10998
10999 #region Packet Session and User Check
11000 if (m_checkPackets)
11001 {
11002 if (inchatpack.AgentData.SessionID != SessionId ||
11003 inchatpack.AgentData.AgentID != AgentId)
11004 break;
11005 }
11006 #endregion
11007
11008 string fromName = String.Empty; //ClientAvatar.firstname + " " + ClientAvatar.lastname;
11009 byte[] message = inchatpack.ChatData.Message;
11010 byte type = inchatpack.ChatData.Type;
11011 Vector3 fromPos = new Vector3(); // ClientAvatar.Pos;
11012 // UUID fromAgentID = AgentId;
11013
11014 int channel = inchatpack.ChatData.Channel;
11015
11016 if (OnChatFromClient != null)
11017 {
11018 OSChatMessage args = new OSChatMessage();
11019 args.Channel = channel;
11020 args.From = fromName;
11021 args.Message = Utils.BytesToString(message);
11022 args.Type = (ChatTypeEnum)type;
11023 args.Position = fromPos;
11024
11025 args.Scene = Scene;
11026 args.Sender = this;
11027 args.SenderUUID = this.AgentId;
11028
11029 ChatMessage handlerChatFromClient = OnChatFromClient;
11030 if (handlerChatFromClient != null)
11031 handlerChatFromClient(this, args);
11032 }
11033 break;
11034
11035 case PacketType.AvatarPropertiesUpdate:
11036 AvatarPropertiesUpdatePacket avatarProps = (AvatarPropertiesUpdatePacket)Pack;
11037
11038 #region Packet Session and User Check
11039 if (m_checkPackets)
11040 {
11041 if (avatarProps.AgentData.SessionID != SessionId ||
11042 avatarProps.AgentData.AgentID != AgentId)
11043 break;
11044 }
11045 #endregion
11046
11047 UpdateAvatarProperties handlerUpdateAvatarProperties = OnUpdateAvatarProperties;
11048 if (handlerUpdateAvatarProperties != null)
11049 {
11050 AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = avatarProps.PropertiesData;
11051 UserProfileData UserProfile = new UserProfileData();
11052 UserProfile.ID = AgentId;
11053 UserProfile.AboutText = Utils.BytesToString(Properties.AboutText);
11054 UserProfile.FirstLifeAboutText = Utils.BytesToString(Properties.FLAboutText);
11055 UserProfile.FirstLifeImage = Properties.FLImageID;
11056 UserProfile.Image = Properties.ImageID;
11057 UserProfile.ProfileUrl = Utils.BytesToString(Properties.ProfileURL);
11058
11059 handlerUpdateAvatarProperties(this, UserProfile);
11060 }
11061 break;
11062
11063 case PacketType.ScriptDialogReply:
11064 ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack;
11065
11066 #region Packet Session and User Check
11067 if (m_checkPackets)
11068 {
11069 if (rdialog.AgentData.SessionID != SessionId ||
11070 rdialog.AgentData.AgentID != AgentId)
11071 break;
11072 }
11073 #endregion
11074
11075 int ch = rdialog.Data.ChatChannel;
11076 byte[] msg = rdialog.Data.ButtonLabel;
11077 if (OnChatFromClient != null)
11078 {
11079 OSChatMessage args = new OSChatMessage();
11080 args.Channel = ch;
11081 args.From = String.Empty;
11082 args.Message = Utils.BytesToString(msg);
11083 args.Type = ChatTypeEnum.Shout;
11084 args.Position = new Vector3();
11085 args.Scene = Scene;
11086 args.Sender = this;
11087 ChatMessage handlerChatFromClient2 = OnChatFromClient;
11088 if (handlerChatFromClient2 != null)
11089 handlerChatFromClient2(this, args);
11090 }
11091
11092 break;
11093
11094 case PacketType.ImprovedInstantMessage:
11095 ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack;
11096
11097 #region Packet Session and User Check
11098 if (m_checkPackets)
11099 {
11100 if (msgpack.AgentData.SessionID != SessionId ||
11101 msgpack.AgentData.AgentID != AgentId)
11102 break;
11103 }
11104 #endregion
11105
11106 string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName);
11107 string IMmessage = Utils.BytesToString(msgpack.MessageBlock.Message);
11108 ImprovedInstantMessage handlerInstantMessage = OnInstantMessage;
11109
11110 if (handlerInstantMessage != null)
11111 {
11112 GridInstantMessage im = new GridInstantMessage(Scene,
11113 msgpack.AgentData.AgentID,
11114 IMfromName,
11115 msgpack.MessageBlock.ToAgentID,
11116 msgpack.MessageBlock.Dialog,
11117 msgpack.MessageBlock.FromGroup,
11118 IMmessage,
11119 msgpack.MessageBlock.ID,
11120 msgpack.MessageBlock.Offline != 0 ? true : false,
11121 msgpack.MessageBlock.Position,
11122 msgpack.MessageBlock.BinaryBucket);
11123
11124 handlerInstantMessage(this, im);
11125 }
11126 break;
11127
11128 case PacketType.AcceptFriendship:
11129 AcceptFriendshipPacket afriendpack = (AcceptFriendshipPacket)Pack;
11130
11131 #region Packet Session and User Check
11132 if (m_checkPackets)
11133 {
11134 if (afriendpack.AgentData.SessionID != SessionId ||
11135 afriendpack.AgentData.AgentID != AgentId)
11136 break;
11137 }
11138 #endregion
11139
11140 // My guess is this is the folder to stick the calling card into
11141 List<UUID> callingCardFolders = new List<UUID>();
11142
11143 UUID agentID = afriendpack.AgentData.AgentID;
11144 UUID transactionID = afriendpack.TransactionBlock.TransactionID;
11145
11146 for (int fi = 0; fi < afriendpack.FolderData.Length; fi++)
11147 {
11148 callingCardFolders.Add(afriendpack.FolderData[fi].FolderID);
11149 }
11150
11151 FriendActionDelegate handlerApproveFriendRequest = OnApproveFriendRequest;
11152 if (handlerApproveFriendRequest != null)
11153 {
11154 handlerApproveFriendRequest(this, agentID, transactionID, callingCardFolders);
11155 }
11156 break;
11157
11158 case PacketType.DeclineFriendship:
11159 DeclineFriendshipPacket dfriendpack = (DeclineFriendshipPacket)Pack;
11160
11161 #region Packet Session and User Check
11162 if (m_checkPackets)
11163 {
11164 if (dfriendpack.AgentData.SessionID != SessionId ||
11165 dfriendpack.AgentData.AgentID != AgentId)
11166 break;
11167 }
11168 #endregion
11169
11170 if (OnDenyFriendRequest != null)
11171 {
11172 OnDenyFriendRequest(this,
11173 dfriendpack.AgentData.AgentID,
11174 dfriendpack.TransactionBlock.TransactionID,
11175 null);
11176 }
11177 break;
11178
11179 case PacketType.TerminateFriendship:
11180 TerminateFriendshipPacket tfriendpack = (TerminateFriendshipPacket)Pack;
11181
11182 #region Packet Session and User Check
11183 if (m_checkPackets)
11184 {
11185 if (tfriendpack.AgentData.SessionID != SessionId ||
11186 tfriendpack.AgentData.AgentID != AgentId)
11187 break;
11188 }
11189 #endregion
11190
11191 UUID listOwnerAgentID = tfriendpack.AgentData.AgentID;
11192 UUID exFriendID = tfriendpack.ExBlock.OtherID;
11193
11194 FriendshipTermination handlerTerminateFriendship = OnTerminateFriendship;
11195 if (handlerTerminateFriendship != null)
11196 {
11197 handlerTerminateFriendship(this, listOwnerAgentID, exFriendID);
11198 }
11199 break;
11200
11201 case PacketType.RezObject:
11202 RezObjectPacket rezPacket = (RezObjectPacket)Pack;
11203
11204 #region Packet Session and User Check
11205 if (m_checkPackets)
11206 {
11207 if (rezPacket.AgentData.SessionID != SessionId ||
11208 rezPacket.AgentData.AgentID != AgentId)
11209 break;
11210 }
11211 #endregion
11212
11213 RezObject handlerRezObject = OnRezObject;
11214 if (handlerRezObject != null)
11215 {
11216 handlerRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd,
11217 rezPacket.RezData.RayStart, rezPacket.RezData.RayTargetID,
11218 rezPacket.RezData.BypassRaycast, rezPacket.RezData.RayEndIsIntersection,
11219 rezPacket.RezData.RezSelected, rezPacket.RezData.RemoveItem,
11220 rezPacket.RezData.FromTaskID);
11221 }
11222 break;
11223
11224 case PacketType.DeRezObject:
11225 DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)Pack;
11226
11227 #region Packet Session and User Check
11228 if (m_checkPackets)
11229 {
11230 if (DeRezPacket.AgentData.SessionID != SessionId ||
11231 DeRezPacket.AgentData.AgentID != AgentId)
11232 break;
11233 }
11234 #endregion
11235
11236 DeRezObject handlerDeRezObject = OnDeRezObject;
11237 if (handlerDeRezObject != null)
11238 {
11239 List<uint> deRezIDs = new List<uint>();
11240
11241 foreach (DeRezObjectPacket.ObjectDataBlock data in
11242 DeRezPacket.ObjectData)
11243 {
11244 deRezIDs.Add(data.ObjectLocalID);
11245 }
11246 // It just so happens that the values on the DeRezAction enumerator match the Destination
11247 // values given by a Second Life client
11248 handlerDeRezObject(this, deRezIDs,
11249 DeRezPacket.AgentBlock.GroupID,
11250 (DeRezAction)DeRezPacket.AgentBlock.Destination,
11251 DeRezPacket.AgentBlock.DestinationID);
11252
11253 }
11254 break;
11255
11256 case PacketType.ModifyLand:
11257 ModifyLandPacket modify = (ModifyLandPacket)Pack;
11258
11259 #region Packet Session and User Check
11260 if (m_checkPackets)
11261 {
11262 if (modify.AgentData.SessionID != SessionId ||
11263 modify.AgentData.AgentID != AgentId)
11264 break;
11265 }
11266
11267 #endregion
11268 //m_log.Info("[LAND]: LAND:" + modify.ToString());
11269 if (modify.ParcelData.Length > 0)
11270 {
11271 if (OnModifyTerrain != null)
11272 {
11273 for (int i = 0; i < modify.ParcelData.Length; i++)
11274 {
11275 ModifyTerrain handlerModifyTerrain = OnModifyTerrain;
11276 if (handlerModifyTerrain != null)
11277 {
11278 handlerModifyTerrain(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds,
11279 modify.ModifyBlock.BrushSize,
11280 modify.ModifyBlock.Action, modify.ParcelData[i].North,
11281 modify.ParcelData[i].West, modify.ParcelData[i].South,
11282 modify.ParcelData[i].East, AgentId);
11283 }
11284 }
11285 }
11286 }
11287
11288 break;
11289
11290 case PacketType.RegionHandshakeReply:
11291
11292 Action<IClientAPI> handlerRegionHandShakeReply = OnRegionHandShakeReply;
11293 if (handlerRegionHandShakeReply != null)
11294 {
11295 handlerRegionHandShakeReply(this);
11296 }
11297
11298 break;
11299
11300 case PacketType.AgentWearablesRequest:
11301 GenericCall2 handlerRequestWearables = OnRequestWearables;
11302
11303 if (handlerRequestWearables != null)
11304 {
11305 handlerRequestWearables();
11306 }
11307
11308 Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData;
11309
11310 if (handlerRequestAvatarsData != null)
11311 {
11312 handlerRequestAvatarsData(this);
11313 }
11314
11315 break;
11316
11317 case PacketType.AgentSetAppearance:
11318 AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
11319
11320 #region Packet Session and User Check
11321 if (m_checkPackets)
11322 {
11323 if (appear.AgentData.SessionID != SessionId ||
11324 appear.AgentData.AgentID != AgentId)
11325 break;
11326 }
11327 #endregion
11328
11329 SetAppearance handlerSetAppearance = OnSetAppearance;
11330 if (handlerSetAppearance != null)
11331 {
11332 // Temporarily protect ourselves from the mantis #951 failure.
11333 // However, we could do this for several other handlers where a failure isn't terminal
11334 // for the client session anyway, in order to protect ourselves against bad code in plugins
11335 try
11336 {
11337 byte[] visualparams = new byte[appear.VisualParam.Length];
11338 for (int i = 0; i < appear.VisualParam.Length; i++)
11339 visualparams[i] = appear.VisualParam[i].ParamValue;
11340
11341 Primitive.TextureEntry te = null;
11342 if (appear.ObjectData.TextureEntry.Length > 1)
11343 te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
11344
11345 handlerSetAppearance(te, visualparams);
11346 }
11347 catch (Exception e)
11348 {
11349 m_log.ErrorFormat(
11350 "[CLIENT VIEW]: AgentSetApperance packet handler threw an exception, {0}",
11351 e);
11352 }
11353 }
11354
11355 break;
11356
11357 case PacketType.AgentIsNowWearing:
11358 if (OnAvatarNowWearing != null)
11359 {
11360 AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket)Pack;
11361
11362 #region Packet Session and User Check
11363 if (m_checkPackets)
11364 {
11365 if (nowWearing.AgentData.SessionID != SessionId ||
11366 nowWearing.AgentData.AgentID != AgentId)
11367 break;
11368 }
11369 #endregion
11370
11371 AvatarWearingArgs wearingArgs = new AvatarWearingArgs();
11372 for (int i = 0; i < nowWearing.WearableData.Length; i++)
11373 {
11374 AvatarWearingArgs.Wearable wearable =
11375 new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID,
11376 nowWearing.WearableData[i].WearableType);
11377 wearingArgs.NowWearing.Add(wearable);
11378 }
11379
11380 AvatarNowWearing handlerAvatarNowWearing = OnAvatarNowWearing;
11381 if (handlerAvatarNowWearing != null)
11382 {
11383 handlerAvatarNowWearing(this, wearingArgs);
11384 }
11385 }
11386 break;
11387
11388 case PacketType.RezSingleAttachmentFromInv:
11389 RezSingleAttachmentFromInv handlerRezSingleAttachment = OnRezSingleAttachmentFromInv;
11390 if (handlerRezSingleAttachment != null)
11391 {
11392 RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack;
11393
11394 #region Packet Session and User Check
11395 if (m_checkPackets)
11396 {
11397 if (rez.AgentData.SessionID != SessionId ||
11398 rez.AgentData.AgentID != AgentId)
11399 break;
11400 }
11401 #endregion
11402
11403 handlerRezSingleAttachment(this, rez.ObjectData.ItemID,
11404 rez.ObjectData.AttachmentPt);
11405 }
11406
11407 break;
11408
11409 case PacketType.RezMultipleAttachmentsFromInv:
11410 RezMultipleAttachmentsFromInv handlerRezMultipleAttachments = OnRezMultipleAttachmentsFromInv;
11411 if (handlerRezMultipleAttachments != null)
11412 {
11413 RezMultipleAttachmentsFromInvPacket rez = (RezMultipleAttachmentsFromInvPacket)Pack;
11414 handlerRezMultipleAttachments(this, rez.HeaderData,
11415 rez.ObjectData);
11416 }
11417
11418 break;
11419
11420 case PacketType.DetachAttachmentIntoInv:
11421 UUIDNameRequest handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv;
11422 if (handlerDetachAttachmentIntoInv != null)
11423 {
11424 DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack;
11425
11426 #region Packet Session and User Check
11427 // UNSUPPORTED ON THIS PACKET
11428 #endregion
11429
11430 UUID itemID = detachtoInv.ObjectData.ItemID;
11431 // UUID ATTACH_agentID = detachtoInv.ObjectData.AgentID;
11432
11433 handlerDetachAttachmentIntoInv(itemID, this);
11434 }
11435 break;
11436
11437 case PacketType.ObjectAttach:
11438 if (OnObjectAttach != null)
11439 {
11440 ObjectAttachPacket att = (ObjectAttachPacket)Pack;
11441
11442 #region Packet Session and User Check
11443 if (m_checkPackets)
11444 {
11445 if (att.AgentData.SessionID != SessionId ||
11446 att.AgentData.AgentID != AgentId)
11447 break;
11448 }
11449 #endregion
11450
11451 ObjectAttach handlerObjectAttach = OnObjectAttach;
11452
11453 if (handlerObjectAttach != null)
11454 {
11455 if (att.ObjectData.Length > 0)
11456 {
11457 handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, att.ObjectData[0].Rotation, false);
11458 }
11459 }
11460 }
11461 break;
11462
11463 case PacketType.ObjectDetach:
11464 ObjectDetachPacket dett = (ObjectDetachPacket)Pack;
11465
11466 #region Packet Session and User Check
11467 if (m_checkPackets)
11468 {
11469 if (dett.AgentData.SessionID != SessionId ||
11470 dett.AgentData.AgentID != AgentId)
11471 break;
11472 }
11473 #endregion
11474
11475 for (int j = 0; j < dett.ObjectData.Length; j++)
11476 {
11477 uint obj = dett.ObjectData[j].ObjectLocalID;
11478 ObjectDeselect handlerObjectDetach = OnObjectDetach;
11479 if (handlerObjectDetach != null)
11480 {
11481 handlerObjectDetach(obj, this);
11482 }
11483
11484 }
11485 break;
11486
11487 case PacketType.ObjectDrop:
11488 ObjectDropPacket dropp = (ObjectDropPacket)Pack;
11489
11490 #region Packet Session and User Check
11491 if (m_checkPackets)
11492 {
11493 if (dropp.AgentData.SessionID != SessionId ||
11494 dropp.AgentData.AgentID != AgentId)
11495 break;
11496 }
11497 #endregion
11498
11499 for (int j = 0; j < dropp.ObjectData.Length; j++)
11500 {
11501 uint obj = dropp.ObjectData[j].ObjectLocalID;
11502 ObjectDrop handlerObjectDrop = OnObjectDrop;
11503 if (handlerObjectDrop != null)
11504 {
11505 handlerObjectDrop(obj, this);
11506 }
11507 }
11508 break;
11509
11510 case PacketType.SetAlwaysRun:
11511 SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack;
11512
11513 #region Packet Session and User Check
11514 if (m_checkPackets)
11515 {
11516 if (run.AgentData.SessionID != SessionId ||
11517 run.AgentData.AgentID != AgentId)
11518 break;
11519 }
11520 #endregion
11521
11522 SetAlwaysRun handlerSetAlwaysRun = OnSetAlwaysRun;
11523 if (handlerSetAlwaysRun != null)
11524 handlerSetAlwaysRun(this, run.AgentData.AlwaysRun);
11525
11526 break;
11527
11528 case PacketType.CompleteAgentMovement:
11529 GenericCall2 handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
11530 if (handlerCompleteMovementToRegion != null)
11531 {
11532 handlerCompleteMovementToRegion();
11533 }
11534 handlerCompleteMovementToRegion = null;
11535
11536 break;
11537
11538 case PacketType.AgentAnimation:
11539 AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
11540
11541 #region Packet Session and User Check
11542 if (m_checkPackets)
11543 {
11544 if (AgentAni.AgentData.SessionID != SessionId ||
11545 AgentAni.AgentData.AgentID != AgentId)
11546 break;
11547 }
11548 #endregion
11549
11550 StartAnim handlerStartAnim = null;
11551 StopAnim handlerStopAnim = null;
11552
11553 for (int i = 0; i < AgentAni.AnimationList.Length; i++)
11554 {
11555 if (AgentAni.AnimationList[i].StartAnim)
11556 {
11557 handlerStartAnim = OnStartAnim;
11558 if (handlerStartAnim != null)
11559 {
11560 handlerStartAnim(this, AgentAni.AnimationList[i].AnimID);
11561 }
11562 }
11563 else
11564 {
11565 handlerStopAnim = OnStopAnim;
11566 if (handlerStopAnim != null)
11567 {
11568 handlerStopAnim(this, AgentAni.AnimationList[i].AnimID);
11569 }
11570 }
11571 }
11572 break;
11573
11574 case PacketType.AgentRequestSit:
11575 if (OnAgentRequestSit != null)
11576 {
11577 AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack;
11578
11579 #region Packet Session and User Check
11580 if (m_checkPackets)
11581 {
11582 if (agentRequestSit.AgentData.SessionID != SessionId ||
11583 agentRequestSit.AgentData.AgentID != AgentId)
11584 break;
11585 }
11586 #endregion
11587
11588 AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit;
11589 if (handlerAgentRequestSit != null)
11590 handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID,
11591 agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset);
11592 }
11593 break;
11594
11595 case PacketType.AgentSit:
11596 if (OnAgentSit != null)
11597 {
11598 AgentSitPacket agentSit = (AgentSitPacket)Pack;
11599
11600 #region Packet Session and User Check
11601 if (m_checkPackets)
11602 {
11603 if (agentSit.AgentData.SessionID != SessionId ||
11604 agentSit.AgentData.AgentID != AgentId)
11605 break;
11606 }
11607 #endregion
11608
11609 AgentSit handlerAgentSit = OnAgentSit;
11610 if (handlerAgentSit != null)
11611 {
11612 OnAgentSit(this, agentSit.AgentData.AgentID);
11613 }
11614 }
11615 break;
11616
11617 case PacketType.SoundTrigger:
11618 SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack;
11619
11620 #region Packet Session and User Check
11621 if (m_checkPackets)
11622 {
11623 // UNSUPPORTED ON THIS PACKET
11624 }
11625 #endregion
11626
11627 SoundTrigger handlerSoundTrigger = OnSoundTrigger;
11628 if (handlerSoundTrigger != null)
11629 {
11630 handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, soundTriggerPacket.SoundData.OwnerID,
11631 soundTriggerPacket.SoundData.ObjectID, soundTriggerPacket.SoundData.ParentID,
11632 soundTriggerPacket.SoundData.Gain, soundTriggerPacket.SoundData.Position,
11633 soundTriggerPacket.SoundData.Handle);
11634
11635 }
11636 break;
11637
11638 case PacketType.AvatarPickerRequest:
11639 AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack;
11640
11641 #region Packet Session and User Check
11642 if (m_checkPackets)
11643 {
11644 if (avRequestQuery.AgentData.SessionID != SessionId ||
11645 avRequestQuery.AgentData.AgentID != AgentId)
11646 break;
11647 }
11648 #endregion
11649
11650 AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData;
11651 AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data;
11652 //m_log.Debug("Agent Sends:" + Utils.BytesToString(querydata.Name));
11653
11654 AvatarPickerRequest handlerAvatarPickerRequest = OnAvatarPickerRequest;
11655 if (handlerAvatarPickerRequest != null)
11656 {
11657 handlerAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID,
11658 Utils.BytesToString(querydata.Name));
11659 }
11660 break;
11661
11662 case PacketType.AgentDataUpdateRequest:
11663 AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack;
11664
11665 #region Packet Session and User Check
11666 if (m_checkPackets)
11667 {
11668 if (avRequestDataUpdatePacket.AgentData.SessionID != SessionId ||
11669 avRequestDataUpdatePacket.AgentData.AgentID != AgentId)
11670 break;
11671 }
11672 #endregion
11673
11674 FetchInventory handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest;
11675
11676 if (handlerAgentDataUpdateRequest != null)
11677 {
11678 handlerAgentDataUpdateRequest(this, avRequestDataUpdatePacket.AgentData.AgentID, avRequestDataUpdatePacket.AgentData.SessionID);
11679 }
11680
11681 break;
11682
11683 case PacketType.UserInfoRequest:
11684 UserInfoRequest handlerUserInfoRequest = OnUserInfoRequest;
11685 if (handlerUserInfoRequest != null)
11686 {
11687 handlerUserInfoRequest(this);
11688 }
11689 else
11690 {
11691 SendUserInfoReply(false, true, "");
11692 }
11693 break;
11694
11695 case PacketType.UpdateUserInfo:
11696 UpdateUserInfoPacket updateUserInfo = (UpdateUserInfoPacket)Pack;
11697
11698 #region Packet Session and User Check
11699 if (m_checkPackets)
11700 {
11701 if (updateUserInfo.AgentData.SessionID != SessionId ||
11702 updateUserInfo.AgentData.AgentID != AgentId)
11703 break;
11704 }
11705 #endregion
11706
11707 UpdateUserInfo handlerUpdateUserInfo = OnUpdateUserInfo;
11708 if (handlerUpdateUserInfo != null)
11709 {
11710 bool visible = true;
11711 string DirectoryVisibility =
11712 Utils.BytesToString(updateUserInfo.UserData.DirectoryVisibility);
11713 if (DirectoryVisibility == "hidden")
11714 visible = false;
11715
11716 handlerUpdateUserInfo(
11717 updateUserInfo.UserData.IMViaEMail,
11718 visible, this);
11719 }
11720 break;
11721
11722 case PacketType.SetStartLocationRequest:
11723 SetStartLocationRequestPacket avSetStartLocationRequestPacket = (SetStartLocationRequestPacket)Pack;
11724
11725 #region Packet Session and User Check
11726 if (m_checkPackets)
11727 {
11728 if (avSetStartLocationRequestPacket.AgentData.SessionID != SessionId ||
11729 avSetStartLocationRequestPacket.AgentData.AgentID != AgentId)
11730 break;
11731 }
11732 #endregion
11733
11734 if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId)
11735 {
11736 TeleportLocationRequest handlerSetStartLocationRequest = OnSetStartLocationRequest;
11737 if (handlerSetStartLocationRequest != null)
11738 {
11739 handlerSetStartLocationRequest(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos,
11740 avSetStartLocationRequestPacket.StartLocationData.LocationLookAt,
11741 avSetStartLocationRequestPacket.StartLocationData.LocationID);
11742 }
11743 }
11744 break;
11745
11746 case PacketType.AgentThrottle:
11747 AgentThrottlePacket atpack = (AgentThrottlePacket)Pack;
11748
11749 #region Packet Session and User Check
11750 if (m_checkPackets)
11751 {
11752 if (atpack.AgentData.SessionID != SessionId ||
11753 atpack.AgentData.AgentID != AgentId)
11754 break;
11755 }
11756 #endregion
11757
11758 m_udpClient.SetThrottles(atpack.Throttle.Throttles);
11759 break;
11760
11761 case PacketType.AgentPause:
11762 m_udpClient.IsPaused = true;
11763 break;
11764
11765 case PacketType.AgentResume:
11766 m_udpClient.IsPaused = false;
11767 SendStartPingCheck(m_udpClient.CurrentPingSequence++);
11768
11769 break;
11770
11771 case PacketType.ForceScriptControlRelease:
11772 ForceReleaseControls handlerForceReleaseControls = OnForceReleaseControls;
11773 if (handlerForceReleaseControls != null)
11774 {
11775 handlerForceReleaseControls(this, AgentId);
11776 }
11777 break;
11778
11779 #endregion
11780
11781
11782 //#region Objects/m_sceneObjects
11783
11784 case PacketType.ObjectLink:
11785 ObjectLinkPacket link = (ObjectLinkPacket)Pack;
11786
11787 #region Packet Session and User Check
11788 if (m_checkPackets)
11789 {
11790 if (link.AgentData.SessionID != SessionId ||
11791 link.AgentData.AgentID != AgentId)
11792 break;
11793 }
11794 #endregion
11795
11796 uint parentprimid = 0;
11797 List<uint> childrenprims = new List<uint>();
11798 if (link.ObjectData.Length > 1)
11799 {
11800 parentprimid = link.ObjectData[0].ObjectLocalID;
11801
11802 for (int i = 1; i < link.ObjectData.Length; i++)
11803 {
11804 childrenprims.Add(link.ObjectData[i].ObjectLocalID);
11805 }
11806 }
11807 LinkObjects handlerLinkObjects = OnLinkObjects;
11808 if (handlerLinkObjects != null)
11809 {
11810 handlerLinkObjects(this, parentprimid, childrenprims);
11811 }
11812 break;
11813
11814 case PacketType.ObjectDelink:
11815 ObjectDelinkPacket delink = (ObjectDelinkPacket)Pack;
11816
11817 #region Packet Session and User Check
11818 if (m_checkPackets)
11819 {
11820 if (delink.AgentData.SessionID != SessionId ||
11821 delink.AgentData.AgentID != AgentId)
11822 break;
11823 }
11824 #endregion
11825
11826 // It appears the prim at index 0 is not always the root prim (for
11827 // instance, when one prim of a link set has been edited independently
11828 // of the others). Therefore, we'll pass all the ids onto the delink
11829 // method for it to decide which is the root.
11830 List<uint> prims = new List<uint>();
11831 for (int i = 0; i < delink.ObjectData.Length; i++)
11832 {
11833 prims.Add(delink.ObjectData[i].ObjectLocalID);
11834 }
11835 DelinkObjects handlerDelinkObjects = OnDelinkObjects;
11836 if (handlerDelinkObjects != null)
11837 {
11838 handlerDelinkObjects(prims);
11839 }
11840
11841 break;
11842
11843 case PacketType.ObjectAdd:
11844 if (OnAddPrim != null)
11845 {
11846 ObjectAddPacket addPacket = (ObjectAddPacket)Pack;
11847
11848 #region Packet Session and User Check
11849 if (m_checkPackets)
11850 {
11851 if (addPacket.AgentData.SessionID != SessionId ||
11852 addPacket.AgentData.AgentID != AgentId)
11853 break;
11854 }
11855 #endregion
11856
11857 PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket);
11858 // m_log.Info("[REZData]: " + addPacket.ToString());
11859 //BypassRaycast: 1
11860 //RayStart: <69.79469, 158.2652, 98.40343>
11861 //RayEnd: <61.97724, 141.995, 92.58341>
11862 //RayTargetID: 00000000-0000-0000-0000-000000000000
11863
11864 //Check to see if adding the prim is allowed; useful for any module wanting to restrict the
11865 //object from rezing initially
11866
11867 AddNewPrim handlerAddPrim = OnAddPrim;
11868 if (handlerAddPrim != null)
11869 handlerAddPrim(AgentId, ActiveGroupId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection);
11870 }
11871 break;
11872
11873 case PacketType.ObjectShape:
11874 ObjectShapePacket shapePacket = (ObjectShapePacket)Pack;
11875
11876 #region Packet Session and User Check
11877 if (m_checkPackets)
11878 {
11879 if (shapePacket.AgentData.SessionID != SessionId ||
11880 shapePacket.AgentData.AgentID != AgentId)
11881 break;
11882 }
11883 #endregion
11884
11885 UpdateShape handlerUpdatePrimShape = null;
11886 for (int i = 0; i < shapePacket.ObjectData.Length; i++)
11887 {
11888 handlerUpdatePrimShape = OnUpdatePrimShape;
11889 if (handlerUpdatePrimShape != null)
11890 {
11891 UpdateShapeArgs shapeData = new UpdateShapeArgs();
11892 shapeData.ObjectLocalID = shapePacket.ObjectData[i].ObjectLocalID;
11893 shapeData.PathBegin = shapePacket.ObjectData[i].PathBegin;
11894 shapeData.PathCurve = shapePacket.ObjectData[i].PathCurve;
11895 shapeData.PathEnd = shapePacket.ObjectData[i].PathEnd;
11896 shapeData.PathRadiusOffset = shapePacket.ObjectData[i].PathRadiusOffset;
11897 shapeData.PathRevolutions = shapePacket.ObjectData[i].PathRevolutions;
11898 shapeData.PathScaleX = shapePacket.ObjectData[i].PathScaleX;
11899 shapeData.PathScaleY = shapePacket.ObjectData[i].PathScaleY;
11900 shapeData.PathShearX = shapePacket.ObjectData[i].PathShearX;
11901 shapeData.PathShearY = shapePacket.ObjectData[i].PathShearY;
11902 shapeData.PathSkew = shapePacket.ObjectData[i].PathSkew;
11903 shapeData.PathTaperX = shapePacket.ObjectData[i].PathTaperX;
11904 shapeData.PathTaperY = shapePacket.ObjectData[i].PathTaperY;
11905 shapeData.PathTwist = shapePacket.ObjectData[i].PathTwist;
11906 shapeData.PathTwistBegin = shapePacket.ObjectData[i].PathTwistBegin;
11907 shapeData.ProfileBegin = shapePacket.ObjectData[i].ProfileBegin;
11908 shapeData.ProfileCurve = shapePacket.ObjectData[i].ProfileCurve;
11909 shapeData.ProfileEnd = shapePacket.ObjectData[i].ProfileEnd;
11910 shapeData.ProfileHollow = shapePacket.ObjectData[i].ProfileHollow;
11911
11912 handlerUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID,
11913 shapeData);
11914 }
11915 }
11916 break;
11917
11918 case PacketType.ObjectExtraParams:
11919 ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket)Pack;
11920
11921 #region Packet Session and User Check
11922 if (m_checkPackets)
11923 {
11924 if (extraPar.AgentData.SessionID != SessionId ||
11925 extraPar.AgentData.AgentID != AgentId)
11926 break;
11927 }
11928 #endregion
11929
11930 ObjectExtraParams handlerUpdateExtraParams = OnUpdateExtraParams;
11931 if (handlerUpdateExtraParams != null)
11932 {
11933 for (int i = 0; i < extraPar.ObjectData.Length; i++)
11934 {
11935 handlerUpdateExtraParams(m_agentId, extraPar.ObjectData[i].ObjectLocalID,
11936 extraPar.ObjectData[i].ParamType,
11937 extraPar.ObjectData[i].ParamInUse, extraPar.ObjectData[i].ParamData);
11938 }
11939 }
11940 break;
11941
11942 case PacketType.ObjectDuplicate:
11943 ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack;
11944
11945 #region Packet Session and User Check
11946 if (m_checkPackets)
11947 {
11948 if (dupe.AgentData.SessionID != SessionId ||
11949 dupe.AgentData.AgentID != AgentId)
11950 break;
11951 }
11952 #endregion
11953
11954 ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData;
11955
11956 ObjectDuplicate handlerObjectDuplicate = null;
11957
11958 for (int i = 0; i < dupe.ObjectData.Length; i++)
11959 {
11960 handlerObjectDuplicate = OnObjectDuplicate;
11961 if (handlerObjectDuplicate != null)
11962 {
11963 handlerObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset,
11964 dupe.SharedData.DuplicateFlags, AgentandGroupData.AgentID,
11965 AgentandGroupData.GroupID);
11966 }
11967 }
11968
11969 break;
11970
11971 case PacketType.RequestMultipleObjects:
11972 RequestMultipleObjectsPacket incomingRequest = (RequestMultipleObjectsPacket)Pack;
11973
11974 #region Packet Session and User Check
11975 if (m_checkPackets)
11976 {
11977 if (incomingRequest.AgentData.SessionID != SessionId ||
11978 incomingRequest.AgentData.AgentID != AgentId)
11979 break;
11980 }
11981 #endregion
11982
11983 ObjectRequest handlerObjectRequest = null;
11984
11985 for (int i = 0; i < incomingRequest.ObjectData.Length; i++)
11986 {
11987 handlerObjectRequest = OnObjectRequest;
11988 if (handlerObjectRequest != null)
11989 {
11990 handlerObjectRequest(incomingRequest.ObjectData[i].ID, this);
11991 }
11992 }
11993 break;
11994
11995 case PacketType.ObjectSelect:
11996 ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
11997
11998 #region Packet Session and User Check
11999 if (m_checkPackets)
12000 {
12001 if (incomingselect.AgentData.SessionID != SessionId ||
12002 incomingselect.AgentData.AgentID != AgentId)
12003 break;
12004 }
12005 #endregion
12006
12007 ObjectSelect handlerObjectSelect = null;
12008
12009 for (int i = 0; i < incomingselect.ObjectData.Length; i++)
12010 {
12011 handlerObjectSelect = OnObjectSelect;
12012 if (handlerObjectSelect != null)
12013 {
12014 handlerObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this);
12015 }
12016 }
12017 break;
12018
12019 case PacketType.ObjectDeselect:
12020 ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack;
12021
12022 #region Packet Session and User Check
12023 if (m_checkPackets)
12024 {
12025 if (incomingdeselect.AgentData.SessionID != SessionId ||
12026 incomingdeselect.AgentData.AgentID != AgentId)
12027 break;
12028 }
12029 #endregion
12030
12031 ObjectDeselect handlerObjectDeselect = null;
12032
12033 for (int i = 0; i < incomingdeselect.ObjectData.Length; i++)
12034 {
12035 handlerObjectDeselect = OnObjectDeselect;
12036 if (handlerObjectDeselect != null)
12037 {
12038 OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this);
12039 }
12040 }
12041 break;
12042
12043 case PacketType.ObjectPosition:
12044 // DEPRECATED: but till libsecondlife removes it, people will use it
12045 ObjectPositionPacket position = (ObjectPositionPacket)Pack;
12046
12047 #region Packet Session and User Check
12048 if (m_checkPackets)
12049 {
12050 if (position.AgentData.SessionID != SessionId ||
12051 position.AgentData.AgentID != AgentId)
12052 break;
12053 }
12054 #endregion
12055
12056
12057 for (int i = 0; i < position.ObjectData.Length; i++)
12058 {
12059 UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
12060 if (handlerUpdateVector != null)
12061 handlerUpdateVector(position.ObjectData[i].ObjectLocalID, position.ObjectData[i].Position, this);
12062 }
12063
12064 break;
12065
12066 case PacketType.ObjectScale:
12067 // DEPRECATED: but till libsecondlife removes it, people will use it
12068 ObjectScalePacket scale = (ObjectScalePacket)Pack;
12069
12070 #region Packet Session and User Check
12071 if (m_checkPackets)
12072 {
12073 if (scale.AgentData.SessionID != SessionId ||
12074 scale.AgentData.AgentID != AgentId)
12075 break;
12076 }
12077 #endregion
12078
12079 for (int i = 0; i < scale.ObjectData.Length; i++)
12080 {
12081 UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
12082 if (handlerUpdatePrimGroupScale != null)
12083 handlerUpdatePrimGroupScale(scale.ObjectData[i].ObjectLocalID, scale.ObjectData[i].Scale, this);
12084 }
12085
12086 break;
12087
12088 case PacketType.ObjectRotation:
12089 // DEPRECATED: but till libsecondlife removes it, people will use it
12090 ObjectRotationPacket rotation = (ObjectRotationPacket)Pack;
12091
12092 #region Packet Session and User Check
12093 if (m_checkPackets)
12094 {
12095 if (rotation.AgentData.SessionID != SessionId ||
12096 rotation.AgentData.AgentID != AgentId)
12097 break;
12098 }
12099 #endregion
12100
12101 for (int i = 0; i < rotation.ObjectData.Length; i++)
12102 {
12103 UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
12104 if (handlerUpdatePrimRotation != null)
12105 handlerUpdatePrimRotation(rotation.ObjectData[i].ObjectLocalID, rotation.ObjectData[i].Rotation, this);
12106 }
12107
12108 break;
12109
12110 case PacketType.ObjectFlagUpdate:
12111 ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
12112
12113 #region Packet Session and User Check
12114 if (m_checkPackets)
12115 {
12116 if (flags.AgentData.SessionID != SessionId ||
12117 flags.AgentData.AgentID != AgentId)
12118 break;
12119 }
12120 #endregion
12121
12122 UpdatePrimFlags handlerUpdatePrimFlags = OnUpdatePrimFlags;
12123
12124 if (handlerUpdatePrimFlags != null)
12125 {
12126 byte[] data = Pack.ToBytes();
12127 // 46,47,48 are special positions within the packet
12128 // This may change so perhaps we need a better way
12129 // of storing this (OMV.FlagUpdatePacket.UsePhysics,etc?)
12130 bool UsePhysics = (data[46] != 0) ? true : false;
12131 bool IsTemporary = (data[47] != 0) ? true : false;
12132 bool IsPhantom = (data[48] != 0) ? true : false;
12133 handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this);
12134 }
12135 break;
12136 case PacketType.ObjectImage:
12137 ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
12138
12139 UpdatePrimTexture handlerUpdatePrimTexture = null;
12140 for (int i = 0; i < imagePack.ObjectData.Length; i++)
12141 {
12142 handlerUpdatePrimTexture = OnUpdatePrimTexture;
12143 if (handlerUpdatePrimTexture != null)
12144 {
12145 handlerUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID,
12146 imagePack.ObjectData[i].TextureEntry, this);
12147 }
12148 }
12149 break;
12150
12151 case PacketType.ObjectGrab:
12152 ObjectGrabPacket grab = (ObjectGrabPacket)Pack;
12153
12154 #region Packet Session and User Check
12155 if (m_checkPackets)
12156 {
12157 if (grab.AgentData.SessionID != SessionId ||
12158 grab.AgentData.AgentID != AgentId)
12159 break;
12160 }
12161 #endregion
12162
12163 GrabObject handlerGrabObject = OnGrabObject;
12164
12165 if (handlerGrabObject != null)
12166 {
12167 List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
12168 if ((grab.SurfaceInfo != null) && (grab.SurfaceInfo.Length > 0))
12169 {
12170 foreach (ObjectGrabPacket.SurfaceInfoBlock surfaceInfo in grab.SurfaceInfo)
12171 {
12172 SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
12173 arg.Binormal = surfaceInfo.Binormal;
12174 arg.FaceIndex = surfaceInfo.FaceIndex;
12175 arg.Normal = surfaceInfo.Normal;
12176 arg.Position = surfaceInfo.Position;
12177 arg.STCoord = surfaceInfo.STCoord;
12178 arg.UVCoord = surfaceInfo.UVCoord;
12179 touchArgs.Add(arg);
12180 }
12181 }
12182 handlerGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this, touchArgs);
12183 }
12184 break;
12185
12186 case PacketType.ObjectGrabUpdate:
12187 ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack;
12188
12189 #region Packet Session and User Check
12190 if (m_checkPackets)
12191 {
12192 if (grabUpdate.AgentData.SessionID != SessionId ||
12193 grabUpdate.AgentData.AgentID != AgentId)
12194 break;
12195 }
12196 #endregion
12197
12198 MoveObject handlerGrabUpdate = OnGrabUpdate;
12199
12200 if (handlerGrabUpdate != null)
12201 {
12202 List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
12203 if ((grabUpdate.SurfaceInfo != null) && (grabUpdate.SurfaceInfo.Length > 0))
12204 {
12205 foreach (ObjectGrabUpdatePacket.SurfaceInfoBlock surfaceInfo in grabUpdate.SurfaceInfo)
12206 {
12207 SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
12208 arg.Binormal = surfaceInfo.Binormal;
12209 arg.FaceIndex = surfaceInfo.FaceIndex;
12210 arg.Normal = surfaceInfo.Normal;
12211 arg.Position = surfaceInfo.Position;
12212 arg.STCoord = surfaceInfo.STCoord;
12213 arg.UVCoord = surfaceInfo.UVCoord;
12214 touchArgs.Add(arg);
12215 }
12216 }
12217 handlerGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial,
12218 grabUpdate.ObjectData.GrabPosition, this, touchArgs);
12219 }
12220 break;
12221
12222 case PacketType.ObjectDeGrab:
12223 ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack;
12224
12225 #region Packet Session and User Check
12226 if (m_checkPackets)
12227 {
12228 if (deGrab.AgentData.SessionID != SessionId ||
12229 deGrab.AgentData.AgentID != AgentId)
12230 break;
12231 }
12232 #endregion
12233
12234 DeGrabObject handlerDeGrabObject = OnDeGrabObject;
12235 if (handlerDeGrabObject != null)
12236 {
12237 List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
12238 if ((deGrab.SurfaceInfo != null) && (deGrab.SurfaceInfo.Length > 0))
12239 {
12240 foreach (ObjectDeGrabPacket.SurfaceInfoBlock surfaceInfo in deGrab.SurfaceInfo)
12241 {
12242 SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
12243 arg.Binormal = surfaceInfo.Binormal;
12244 arg.FaceIndex = surfaceInfo.FaceIndex;
12245 arg.Normal = surfaceInfo.Normal;
12246 arg.Position = surfaceInfo.Position;
12247 arg.STCoord = surfaceInfo.STCoord;
12248 arg.UVCoord = surfaceInfo.UVCoord;
12249 touchArgs.Add(arg);
12250 }
12251 }
12252 handlerDeGrabObject(deGrab.ObjectData.LocalID, this, touchArgs);
12253 }
12254 break;
12255
12256 case PacketType.ObjectSpinStart:
12257 //m_log.Warn("[CLIENT]: unhandled ObjectSpinStart packet");
12258 ObjectSpinStartPacket spinStart = (ObjectSpinStartPacket)Pack;
12259
12260 #region Packet Session and User Check
12261 if (m_checkPackets)
12262 {
12263 if (spinStart.AgentData.SessionID != SessionId ||
12264 spinStart.AgentData.AgentID != AgentId)
12265 break;
12266 }
12267 #endregion
12268
12269 SpinStart handlerSpinStart = OnSpinStart;
12270 if (handlerSpinStart != null)
12271 {
12272 handlerSpinStart(spinStart.ObjectData.ObjectID, this);
12273 }
12274 break;
12275 case PacketType.ObjectSpinUpdate:
12276 //m_log.Warn("[CLIENT]: unhandled ObjectSpinUpdate packet");
12277 ObjectSpinUpdatePacket spinUpdate = (ObjectSpinUpdatePacket)Pack;
12278
12279 #region Packet Session and User Check
12280 if (m_checkPackets)
12281 {
12282 if (spinUpdate.AgentData.SessionID != SessionId ||
12283 spinUpdate.AgentData.AgentID != AgentId)
12284 break;
12285 }
12286 #endregion
12287
12288 Vector3 axis;
12289 float angle;
12290 spinUpdate.ObjectData.Rotation.GetAxisAngle(out axis, out angle);
12291 //m_log.Warn("[CLIENT]: ObjectSpinUpdate packet rot axis:" + axis + " angle:" + angle);
12292
12293 SpinObject handlerSpinUpdate = OnSpinUpdate;
12294 if (handlerSpinUpdate != null)
12295 {
12296 handlerSpinUpdate(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, this);
12297 }
12298 break;
12299
12300
12301 case PacketType.ObjectSpinStop:
12302 //m_log.Warn("[CLIENT]: unhandled ObjectSpinStop packet");
12303 ObjectSpinStopPacket spinStop = (ObjectSpinStopPacket)Pack;
12304
12305 #region Packet Session and User Check
12306 if (m_checkPackets)
12307 {
12308 if (spinStop.AgentData.SessionID != SessionId ||
12309 spinStop.AgentData.AgentID != AgentId)
12310 break;
12311 }
12312 #endregion
12313
12314 SpinStop handlerSpinStop = OnSpinStop;
12315 if (handlerSpinStop != null)
12316 {
12317 handlerSpinStop(spinStop.ObjectData.ObjectID, this);
12318 }
12319 break;
12320
12321 case PacketType.ObjectDescription:
12322 ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack;
12323
12324 #region Packet Session and User Check
12325 if (m_checkPackets)
12326 {
12327 if (objDes.AgentData.SessionID != SessionId ||
12328 objDes.AgentData.AgentID != AgentId)
12329 break;
12330 }
12331 #endregion
12332
12333 GenericCall7 handlerObjectDescription = null;
12334
12335 for (int i = 0; i < objDes.ObjectData.Length; i++)
12336 {
12337 handlerObjectDescription = OnObjectDescription;
12338 if (handlerObjectDescription != null)
12339 {
12340 handlerObjectDescription(this, objDes.ObjectData[i].LocalID,
12341 Util.FieldToString(objDes.ObjectData[i].Description));
12342 }
12343 }
12344 break;
12345
12346 case PacketType.ObjectName:
12347 ObjectNamePacket objName = (ObjectNamePacket)Pack;
12348
12349 #region Packet Session and User Check
12350 if (m_checkPackets)
12351 {
12352 if (objName.AgentData.SessionID != SessionId ||
12353 objName.AgentData.AgentID != AgentId)
12354 break;
12355 }
12356 #endregion
12357
12358 GenericCall7 handlerObjectName = null;
12359 for (int i = 0; i < objName.ObjectData.Length; i++)
12360 {
12361 handlerObjectName = OnObjectName;
12362 if (handlerObjectName != null)
12363 {
12364 handlerObjectName(this, objName.ObjectData[i].LocalID,
12365 Util.FieldToString(objName.ObjectData[i].Name));
12366 }
12367 }
12368 break;
12369
12370 case PacketType.ObjectPermissions:
12371 if (OnObjectPermissions != null)
12372 {
12373 ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack;
12374
12375 #region Packet Session and User Check
12376 if (m_checkPackets)
12377 {
12378 if (newobjPerms.AgentData.SessionID != SessionId ||
12379 newobjPerms.AgentData.AgentID != AgentId)
12380 break;
12381 }
12382 #endregion
12383
12384 UUID AgentID = newobjPerms.AgentData.AgentID;
12385 UUID SessionID = newobjPerms.AgentData.SessionID;
12386
12387 ObjectPermissions handlerObjectPermissions = null;
12388
12389 for (int i = 0; i < newobjPerms.ObjectData.Length; i++)
12390 {
12391 ObjectPermissionsPacket.ObjectDataBlock permChanges = newobjPerms.ObjectData[i];
12392
12393 byte field = permChanges.Field;
12394 uint localID = permChanges.ObjectLocalID;
12395 uint mask = permChanges.Mask;
12396 byte set = permChanges.Set;
12397
12398 handlerObjectPermissions = OnObjectPermissions;
12399
12400 if (handlerObjectPermissions != null)
12401 handlerObjectPermissions(this, AgentID, SessionID, field, localID, mask, set);
12402 }
12403 }
12404
12405 // Here's our data,
12406 // PermField contains the field the info goes into
12407 // PermField determines which mask we're changing
12408 //
12409 // chmask is the mask of the change
12410 // setTF is whether we're adding it or taking it away
12411 //
12412 // objLocalID is the localID of the object.
12413
12414 // Unfortunately, we have to pass the event the packet because objData is an array
12415 // That means multiple object perms may be updated in a single packet.
12416
12417 break;
12418
12419 case PacketType.Undo:
12420 UndoPacket undoitem = (UndoPacket)Pack;
12421
12422 #region Packet Session and User Check
12423 if (m_checkPackets)
12424 {
12425 if (undoitem.AgentData.SessionID != SessionId ||
12426 undoitem.AgentData.AgentID != AgentId)
12427 break;
12428 }
12429 #endregion
12430
12431 if (undoitem.ObjectData.Length > 0)
12432 {
12433 for (int i = 0; i < undoitem.ObjectData.Length; i++)
12434 {
12435 UUID objiD = undoitem.ObjectData[i].ObjectID;
12436 AgentSit handlerOnUndo = OnUndo;
12437 if (handlerOnUndo != null)
12438 {
12439 handlerOnUndo(this, objiD);
12440 }
12441
12442 }
12443 }
12444 break;
12445
12446 case PacketType.ObjectDuplicateOnRay:
12447 ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack;
12448
12449 #region Packet Session and User Check
12450 if (m_checkPackets)
12451 {
12452 if (dupeOnRay.AgentData.SessionID != SessionId ||
12453 dupeOnRay.AgentData.AgentID != AgentId)
12454 break;
12455 }
12456 #endregion
12457
12458 ObjectDuplicateOnRay handlerObjectDuplicateOnRay = null;
12459
12460 for (int i = 0; i < dupeOnRay.ObjectData.Length; i++)
12461 {
12462 handlerObjectDuplicateOnRay = OnObjectDuplicateOnRay;
12463 if (handlerObjectDuplicateOnRay != null)
12464 {
12465 handlerObjectDuplicateOnRay(dupeOnRay.ObjectData[i].ObjectLocalID, dupeOnRay.AgentData.DuplicateFlags,
12466 dupeOnRay.AgentData.AgentID, dupeOnRay.AgentData.GroupID, dupeOnRay.AgentData.RayTargetID, dupeOnRay.AgentData.RayEnd,
12467 dupeOnRay.AgentData.RayStart, dupeOnRay.AgentData.BypassRaycast, dupeOnRay.AgentData.RayEndIsIntersection,
12468 dupeOnRay.AgentData.CopyCenters, dupeOnRay.AgentData.CopyRotates);
12469 }
12470 }
12471
12472 break;
12473
12474 case PacketType.RequestObjectPropertiesFamily:
12475 //This powers the little tooltip that appears when you move your mouse over an object
12476 RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack;
12477
12478 #region Packet Session and User Check
12479 if (m_checkPackets)
12480 {
12481 if (packToolTip.AgentData.SessionID != SessionId ||
12482 packToolTip.AgentData.AgentID != AgentId)
12483 break;
12484 }
12485 #endregion
12486
12487 RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData;
12488
12489 RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily;
12490
12491 if (handlerRequestObjectPropertiesFamily != null)
12492 {
12493 handlerRequestObjectPropertiesFamily(this, m_agentId, packObjBlock.RequestFlags,
12494 packObjBlock.ObjectID);
12495 }
12496
12497 break;
12498
12499 case PacketType.ObjectIncludeInSearch:
12500 //This lets us set objects to appear in search (stuff like DataSnapshot, etc)
12501 ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack;
12502 ObjectIncludeInSearch handlerObjectIncludeInSearch = null;
12503
12504 #region Packet Session and User Check
12505 if (m_checkPackets)
12506 {
12507 if (packInSearch.AgentData.SessionID != SessionId ||
12508 packInSearch.AgentData.AgentID != AgentId)
12509 break;
12510 }
12511 #endregion
12512
12513 foreach (ObjectIncludeInSearchPacket.ObjectDataBlock objData in packInSearch.ObjectData)
12514 {
12515 bool inSearch = objData.IncludeInSearch;
12516 uint localID = objData.ObjectLocalID;
12517
12518 handlerObjectIncludeInSearch = OnObjectIncludeInSearch;
12519
12520 if (handlerObjectIncludeInSearch != null)
12521 {
12522 handlerObjectIncludeInSearch(this, inSearch, localID);
12523 }
12524 }
12525 break;
12526
12527 case PacketType.ScriptAnswerYes:
12528 ScriptAnswerYesPacket scriptAnswer = (ScriptAnswerYesPacket)Pack;
12529
12530 #region Packet Session and User Check
12531 if (m_checkPackets)
12532 {
12533 if (scriptAnswer.AgentData.SessionID != SessionId ||
12534 scriptAnswer.AgentData.AgentID != AgentId)
12535 break;
12536 }
12537 #endregion
12538
12539 ScriptAnswer handlerScriptAnswer = OnScriptAnswer;
12540 if (handlerScriptAnswer != null)
12541 {
12542 handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions);
12543 }
12544 break;
12545
12546 case PacketType.ObjectClickAction:
12547 ObjectClickActionPacket ocpacket = (ObjectClickActionPacket)Pack;
12548
12549 #region Packet Session and User Check
12550 if (m_checkPackets)
12551 {
12552 if (ocpacket.AgentData.SessionID != SessionId ||
12553 ocpacket.AgentData.AgentID != AgentId)
12554 break;
12555 }
12556 #endregion
12557
12558 GenericCall7 handlerObjectClickAction = OnObjectClickAction;
12559 if (handlerObjectClickAction != null)
12560 {
12561 foreach (ObjectClickActionPacket.ObjectDataBlock odata in ocpacket.ObjectData)
12562 {
12563 byte action = odata.ClickAction;
12564 uint localID = odata.ObjectLocalID;
12565 handlerObjectClickAction(this, localID, action.ToString());
12566 }
12567 }
12568 break;
12569
12570 case PacketType.ObjectMaterial:
12571 ObjectMaterialPacket ompacket = (ObjectMaterialPacket)Pack;
12572
12573 #region Packet Session and User Check
12574 if (m_checkPackets)
12575 {
12576 if (ompacket.AgentData.SessionID != SessionId ||
12577 ompacket.AgentData.AgentID != AgentId)
12578 break;
12579 }
12580 #endregion
12581
12582 GenericCall7 handlerObjectMaterial = OnObjectMaterial;
12583 if (handlerObjectMaterial != null)
12584 {
12585 foreach (ObjectMaterialPacket.ObjectDataBlock odata in ompacket.ObjectData)
12586 {
12587 byte material = odata.Material;
12588 uint localID = odata.ObjectLocalID;
12589 handlerObjectMaterial(this, localID, material.ToString());
12590 }
12591 }
12592 break;
12593
12594 //#endregion
12595
12596 //#region Inventory/Asset/Other related packets
12597
12598 case PacketType.RequestImage:
12599 RequestImagePacket imageRequest = (RequestImagePacket)Pack;
12600 //m_log.Debug("image request: " + Pack.ToString());
12601
12602 #region Packet Session and User Check
12603 if (m_checkPackets)
12604 {
12605 if (imageRequest.AgentData.SessionID != SessionId ||
12606 imageRequest.AgentData.AgentID != AgentId)
12607 break;
12608 }
12609 #endregion
12610
12611 //handlerTextureRequest = null;
12612 for (int i = 0; i < imageRequest.RequestImage.Length; i++)
12613 {
12614 if (OnRequestTexture != null)
12615 {
12616 TextureRequestArgs args = new TextureRequestArgs();
12617
12618 RequestImagePacket.RequestImageBlock block = imageRequest.RequestImage[i];
12619
12620 args.RequestedAssetID = block.Image;
12621 args.DiscardLevel = block.DiscardLevel;
12622 args.PacketNumber = block.Packet;
12623 args.Priority = block.DownloadPriority;
12624 args.requestSequence = imageRequest.Header.Sequence;
12625
12626 // NOTE: This is not a built in part of the LLUDP protocol, but we double the
12627 // priority of avatar textures to get avatars rezzing in faster than the
12628 // surrounding scene
12629 if ((ImageType)block.Type == ImageType.Baked)
12630 args.Priority *= 2.0f;
12631
12632 //handlerTextureRequest = OnRequestTexture;
12633
12634 //if (handlerTextureRequest != null)
12635 //OnRequestTexture(this, args);
12636
12637 // in the end, we null this, so we have to check if it's null
12638 if (m_imageManager != null)
12639 {
12640 m_imageManager.EnqueueReq(args);
12641 }
12642 }
12643 }
12644 break;
12645
12646 case PacketType.TransferRequest:
12647 //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request");
12648
12649 TransferRequestPacket transfer = (TransferRequestPacket)Pack;
12650 //m_log.Debug("Transfer Request: " + transfer.ToString());
12651 // Validate inventory transfers
12652 // Has to be done here, because AssetCache can't do it
12653 //
12654 UUID taskID = UUID.Zero;
12655 if (transfer.TransferInfo.SourceType == 3)
12656 {
12657 taskID = new UUID(transfer.TransferInfo.Params, 48);
12658 UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
12659 UUID requestID = new UUID(transfer.TransferInfo.Params, 80);
12660 if (!(((Scene)m_scene).Permissions.BypassPermissions()))
12661 {
12662 if (taskID != UUID.Zero) // Prim
12663 {
12664 SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID);
12665 if (part == null)
12666 break;
12667
12668 if (part.OwnerID != AgentId)
12669 break;
12670
12671 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
12672 break;
12673
12674 TaskInventoryItem ti = part.Inventory.GetInventoryItem(itemID);
12675 if (ti == null)
12676 break;
12677
12678 if (ti.OwnerID != AgentId)
12679 break;
12680
12681 if ((ti.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
12682 break;
12683
12684 if (ti.AssetID != requestID)
12685 break;
12686 }
12687 else // Agent
12688 {
12689 IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>();
12690 InventoryItemBase assetRequestItem = new InventoryItemBase(itemID, AgentId);
12691 assetRequestItem = invService.GetItem(assetRequestItem);
12692 if (assetRequestItem == null)
12693 {
12694 assetRequestItem = ((Scene)m_scene).CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID);
12695 if (assetRequestItem == null)
12696 return;
12697 }
12698
12699 // At this point, we need to apply perms
12700 // only to notecards and scripts. All
12701 // other asset types are always available
12702 //
12703 if (assetRequestItem.AssetType == 10)
12704 {
12705 if (!((Scene)m_scene).Permissions.CanViewScript(itemID, UUID.Zero, AgentId))
12706 {
12707 SendAgentAlertMessage("Insufficient permissions to view script", false);
12708 break;
12709 }
12710 }
12711 else if (assetRequestItem.AssetType == 7)
12712 {
12713 if (!((Scene)m_scene).Permissions.CanViewNotecard(itemID, UUID.Zero, AgentId))
12714 {
12715 SendAgentAlertMessage("Insufficient permissions to view notecard", false);
12716 break;
12717 }
12718 }
12719
12720 if (assetRequestItem.AssetID != requestID)
12721 break;
12722 }
12723 }
12724 }
12725
12726 //m_assetCache.AddAssetRequest(this, transfer);
12727
12728 MakeAssetRequest(transfer, taskID);
12729
12730 // RequestAsset = OnRequestAsset;
12731 // if (RequestAsset != null)
12732 // {
12733 // RequestAsset(this, transfer);
12734 // }
12735
12736 break;
12737
12738 case PacketType.AssetUploadRequest:
12739 AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
12740
12741
12742 // m_log.Debug("upload request " + request.ToString());
12743 // m_log.Debug("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString());
12744 UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId);
12745
12746 UDPAssetUploadRequest handlerAssetUploadRequest = OnAssetUploadRequest;
12747
12748 if (handlerAssetUploadRequest != null)
12749 {
12750 handlerAssetUploadRequest(this, temp,
12751 request.AssetBlock.TransactionID, request.AssetBlock.Type,
12752 request.AssetBlock.AssetData, request.AssetBlock.StoreLocal,
12753 request.AssetBlock.Tempfile);
12754 }
12755 break;
12756
12757 case PacketType.RequestXfer:
12758 RequestXferPacket xferReq = (RequestXferPacket)Pack;
12759
12760 RequestXfer handlerRequestXfer = OnRequestXfer;
12761
12762 if (handlerRequestXfer != null)
12763 {
12764 handlerRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename));
12765 }
12766 break;
12767
12768 case PacketType.SendXferPacket:
12769 SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack;
12770
12771 XferReceive handlerXferReceive = OnXferReceive;
12772 if (handlerXferReceive != null)
12773 {
12774 handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data);
12775 }
12776 break;
12777
12778 case PacketType.ConfirmXferPacket:
12779 ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack;
12780
12781 ConfirmXfer handlerConfirmXfer = OnConfirmXfer;
12782 if (handlerConfirmXfer != null)
12783 {
12784 handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet);
12785 }
12786 break;
12787
12788 case PacketType.AbortXfer:
12789 AbortXferPacket abortXfer = (AbortXferPacket)Pack;
12790 AbortXfer handlerAbortXfer = OnAbortXfer;
12791 if (handlerAbortXfer != null)
12792 {
12793 handlerAbortXfer(this, abortXfer.XferID.ID);
12794 }
12795
12796 break;
12797
12798 case PacketType.CreateInventoryFolder:
12799 CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
12800
12801 #region Packet Session and User Check
12802 if (m_checkPackets)
12803 {
12804 if (invFolder.AgentData.SessionID != SessionId ||
12805 invFolder.AgentData.AgentID != AgentId)
12806 break;
12807 }
12808 #endregion
12809
12810 CreateInventoryFolder handlerCreateInventoryFolder = OnCreateNewInventoryFolder;
12811 if (handlerCreateInventoryFolder != null)
12812 {
12813 handlerCreateInventoryFolder(this, invFolder.FolderData.FolderID,
12814 (ushort)invFolder.FolderData.Type,
12815 Util.FieldToString(invFolder.FolderData.Name),
12816 invFolder.FolderData.ParentID);
12817 }
12818 break;
12819
12820 case PacketType.UpdateInventoryFolder:
12821 if (OnUpdateInventoryFolder != null)
12822 {
12823 UpdateInventoryFolderPacket invFolderx = (UpdateInventoryFolderPacket)Pack;
12824
12825 #region Packet Session and User Check
12826 if (m_checkPackets)
12827 {
12828 if (invFolderx.AgentData.SessionID != SessionId ||
12829 invFolderx.AgentData.AgentID != AgentId)
12830 break;
12831 }
12832 #endregion
12833
12834 UpdateInventoryFolder handlerUpdateInventoryFolder = null;
12835
12836 for (int i = 0; i < invFolderx.FolderData.Length; i++)
12837 {
12838 handlerUpdateInventoryFolder = OnUpdateInventoryFolder;
12839 if (handlerUpdateInventoryFolder != null)
12840 {
12841 OnUpdateInventoryFolder(this, invFolderx.FolderData[i].FolderID,
12842 (ushort)invFolderx.FolderData[i].Type,
12843 Util.FieldToString(invFolderx.FolderData[i].Name),
12844 invFolderx.FolderData[i].ParentID);
12845 }
12846 }
12847 }
12848 break;
12849
12850 case PacketType.MoveInventoryFolder:
12851 if (OnMoveInventoryFolder != null)
12852 {
12853 MoveInventoryFolderPacket invFoldery = (MoveInventoryFolderPacket)Pack;
12854
12855 #region Packet Session and User Check
12856 if (m_checkPackets)
12857 {
12858 if (invFoldery.AgentData.SessionID != SessionId ||
12859 invFoldery.AgentData.AgentID != AgentId)
12860 break;
12861 }
12862 #endregion
12863
12864 MoveInventoryFolder handlerMoveInventoryFolder = null;
12865
12866 for (int i = 0; i < invFoldery.InventoryData.Length; i++)
12867 {
12868 handlerMoveInventoryFolder = OnMoveInventoryFolder;
12869 if (handlerMoveInventoryFolder != null)
12870 {
12871 OnMoveInventoryFolder(this, invFoldery.InventoryData[i].FolderID,
12872 invFoldery.InventoryData[i].ParentID);
12873 }
12874 }
12875 }
12876 break;
12877
12878 case PacketType.CreateInventoryItem:
12879 CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
12880
12881 #region Packet Session and User Check
12882 if (m_checkPackets)
12883 {
12884 if (createItem.AgentData.SessionID != SessionId ||
12885 createItem.AgentData.AgentID != AgentId)
12886 break;
12887 }
12888 #endregion
12889
12890 CreateNewInventoryItem handlerCreateNewInventoryItem = OnCreateNewInventoryItem;
12891 if (handlerCreateNewInventoryItem != null)
12892 {
12893 handlerCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID,
12894 createItem.InventoryBlock.FolderID,
12895 createItem.InventoryBlock.CallbackID,
12896 Util.FieldToString(createItem.InventoryBlock.Description),
12897 Util.FieldToString(createItem.InventoryBlock.Name),
12898 createItem.InventoryBlock.InvType,
12899 createItem.InventoryBlock.Type,
12900 createItem.InventoryBlock.WearableType,
12901 createItem.InventoryBlock.NextOwnerMask,
12902 Util.UnixTimeSinceEpoch());
12903 }
12904 break;
12905
12906 case PacketType.FetchInventory:
12907 if (OnFetchInventory != null)
12908 {
12909 FetchInventoryPacket FetchInventoryx = (FetchInventoryPacket)Pack;
12910
12911 #region Packet Session and User Check
12912 if (m_checkPackets)
12913 {
12914 if (FetchInventoryx.AgentData.SessionID != SessionId ||
12915 FetchInventoryx.AgentData.AgentID != AgentId)
12916 break;
12917 }
12918 #endregion
12919
12920 FetchInventory handlerFetchInventory = null;
12921
12922 for (int i = 0; i < FetchInventoryx.InventoryData.Length; i++)
12923 {
12924 handlerFetchInventory = OnFetchInventory;
12925
12926 if (handlerFetchInventory != null)
12927 {
12928 OnFetchInventory(this, FetchInventoryx.InventoryData[i].ItemID,
12929 FetchInventoryx.InventoryData[i].OwnerID);
12930 }
12931 }
12932 }
12933 break;
12934
12935 case PacketType.FetchInventoryDescendents:
12936 FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
12937
12938 #region Packet Session and User Check
12939 if (m_checkPackets)
12940 {
12941 if (Fetch.AgentData.SessionID != SessionId ||
12942 Fetch.AgentData.AgentID != AgentId)
12943 break;
12944 }
12945 #endregion
12946
12947 FetchInventoryDescendents handlerFetchInventoryDescendents = OnFetchInventoryDescendents;
12948 if (handlerFetchInventoryDescendents != null)
12949 {
12950 handlerFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID,
12951 Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems,
12952 Fetch.InventoryData.SortOrder);
12953 }
12954 break;
12955
12956 case PacketType.PurgeInventoryDescendents:
12957 PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack;
12958
12959 #region Packet Session and User Check
12960 if (m_checkPackets)
12961 {
12962 if (Purge.AgentData.SessionID != SessionId ||
12963 Purge.AgentData.AgentID != AgentId)
12964 break;
12965 }
12966 #endregion
12967
12968 PurgeInventoryDescendents handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents;
12969 if (handlerPurgeInventoryDescendents != null)
12970 {
12971 handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID);
12972 }
12973 break;
12974
12975 case PacketType.UpdateInventoryItem:
12976 UpdateInventoryItemPacket inventoryItemUpdate = (UpdateInventoryItemPacket)Pack;
12977
12978 #region Packet Session and User Check
12979 if (m_checkPackets)
12980 {
12981 if (inventoryItemUpdate.AgentData.SessionID != SessionId ||
12982 inventoryItemUpdate.AgentData.AgentID != AgentId)
12983 break;
12984 }
12985 #endregion
12986
12987 if (OnUpdateInventoryItem != null)
12988 {
12989 UpdateInventoryItem handlerUpdateInventoryItem = null;
12990 for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++)
12991 {
12992 handlerUpdateInventoryItem = OnUpdateInventoryItem;
12993
12994 if (handlerUpdateInventoryItem != null)
12995 {
12996 InventoryItemBase itemUpd = new InventoryItemBase();
12997 itemUpd.ID = inventoryItemUpdate.InventoryData[i].ItemID;
12998 itemUpd.Name = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Name);
12999 itemUpd.Description = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Description);
13000 itemUpd.GroupID = inventoryItemUpdate.InventoryData[i].GroupID;
13001 itemUpd.GroupOwned = inventoryItemUpdate.InventoryData[i].GroupOwned;
13002 itemUpd.GroupPermissions = inventoryItemUpdate.InventoryData[i].GroupMask;
13003 itemUpd.NextPermissions = inventoryItemUpdate.InventoryData[i].NextOwnerMask;
13004 itemUpd.EveryOnePermissions = inventoryItemUpdate.InventoryData[i].EveryoneMask;
13005 itemUpd.CreationDate = inventoryItemUpdate.InventoryData[i].CreationDate;
13006 itemUpd.Folder = inventoryItemUpdate.InventoryData[i].FolderID;
13007 itemUpd.InvType = inventoryItemUpdate.InventoryData[i].InvType;
13008 itemUpd.SalePrice = inventoryItemUpdate.InventoryData[i].SalePrice;
13009 itemUpd.SaleType = inventoryItemUpdate.InventoryData[i].SaleType;
13010 itemUpd.Flags = inventoryItemUpdate.InventoryData[i].Flags;
13011
13012 OnUpdateInventoryItem(this, inventoryItemUpdate.InventoryData[i].TransactionID,
13013 inventoryItemUpdate.InventoryData[i].ItemID,
13014 itemUpd);
13015 }
13016 }
13017 }
13018 break;
13019
13020 case PacketType.CopyInventoryItem:
13021 CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack;
13022
13023 #region Packet Session and User Check
13024 if (m_checkPackets)
13025 {
13026 if (copyitem.AgentData.SessionID != SessionId ||
13027 copyitem.AgentData.AgentID != AgentId)
13028 break;
13029 }
13030 #endregion
13031
13032 CopyInventoryItem handlerCopyInventoryItem = null;
13033 if (OnCopyInventoryItem != null)
13034 {
13035 foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData)
13036 {
13037 handlerCopyInventoryItem = OnCopyInventoryItem;
13038 if (handlerCopyInventoryItem != null)
13039 {
13040 handlerCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID,
13041 datablock.OldItemID, datablock.NewFolderID,
13042 Util.FieldToString(datablock.NewName));
13043 }
13044 }
13045 }
13046 break;
13047
13048 case PacketType.MoveInventoryItem:
13049 MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack;
13050
13051 #region Packet Session and User Check
13052 if (m_checkPackets)
13053 {
13054 if (moveitem.AgentData.SessionID != SessionId ||
13055 moveitem.AgentData.AgentID != AgentId)
13056 break;
13057 }
13058 #endregion
13059
13060 if (OnMoveInventoryItem != null)
13061 {
13062 MoveInventoryItem handlerMoveInventoryItem = null;
13063 InventoryItemBase itm = null;
13064 List<InventoryItemBase> items = new List<InventoryItemBase>();
13065 foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData)
13066 {
13067 itm = new InventoryItemBase(datablock.ItemID, AgentId);
13068 itm.Folder = datablock.FolderID;
13069 itm.Name = Util.FieldToString(datablock.NewName);
13070 // weird, comes out as empty string
13071 //m_log.DebugFormat("[XXX] new name: {0}", itm.Name);
13072 items.Add(itm);
13073 }
13074 handlerMoveInventoryItem = OnMoveInventoryItem;
13075 if (handlerMoveInventoryItem != null)
13076 {
13077 handlerMoveInventoryItem(this, items);
13078 }
13079 }
13080 break;
13081
13082 case PacketType.RemoveInventoryItem:
13083 RemoveInventoryItemPacket removeItem = (RemoveInventoryItemPacket)Pack;
13084
13085 #region Packet Session and User Check
13086 if (m_checkPackets)
13087 {
13088 if (removeItem.AgentData.SessionID != SessionId ||
13089 removeItem.AgentData.AgentID != AgentId)
13090 break;
13091 }
13092 #endregion
13093
13094 if (OnRemoveInventoryItem != null)
13095 {
13096 RemoveInventoryItem handlerRemoveInventoryItem = null;
13097 List<UUID> uuids = new List<UUID>();
13098 foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData)
13099 {
13100 uuids.Add(datablock.ItemID);
13101 }
13102 handlerRemoveInventoryItem = OnRemoveInventoryItem;
13103 if (handlerRemoveInventoryItem != null)
13104 {
13105 handlerRemoveInventoryItem(this, uuids);
13106 }
13107
13108 }
13109 break;
13110
13111 case PacketType.RemoveInventoryFolder:
13112 RemoveInventoryFolderPacket removeFolder = (RemoveInventoryFolderPacket)Pack;
13113
13114 #region Packet Session and User Check
13115 if (m_checkPackets)
13116 {
13117 if (removeFolder.AgentData.SessionID != SessionId ||
13118 removeFolder.AgentData.AgentID != AgentId)
13119 break;
13120 }
13121 #endregion
13122
13123 if (OnRemoveInventoryFolder != null)
13124 {
13125 RemoveInventoryFolder handlerRemoveInventoryFolder = null;
13126 List<UUID> uuids = new List<UUID>();
13127 foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData)
13128 {
13129 uuids.Add(datablock.FolderID);
13130 }
13131 handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
13132 if (handlerRemoveInventoryFolder != null)
13133 {
13134 handlerRemoveInventoryFolder(this, uuids);
13135 }
13136 }
13137 break;
13138
13139 case PacketType.RemoveInventoryObjects:
13140 RemoveInventoryObjectsPacket removeObject = (RemoveInventoryObjectsPacket)Pack;
13141 #region Packet Session and User Check
13142 if (m_checkPackets)
13143 {
13144 if (removeObject.AgentData.SessionID != SessionId ||
13145 removeObject.AgentData.AgentID != AgentId)
13146 break;
13147 }
13148 #endregion
13149 if (OnRemoveInventoryFolder != null)
13150 {
13151 RemoveInventoryFolder handlerRemoveInventoryFolder = null;
13152 List<UUID> uuids = new List<UUID>();
13153 foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData)
13154 {
13155 uuids.Add(datablock.FolderID);
13156 }
13157 handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
13158 if (handlerRemoveInventoryFolder != null)
13159 {
13160 handlerRemoveInventoryFolder(this, uuids);
13161 }
13162 }
13163
13164 if (OnRemoveInventoryItem != null)
13165 {
13166 RemoveInventoryItem handlerRemoveInventoryItem = null;
13167 List<UUID> uuids = new List<UUID>();
13168 foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData)
13169 {
13170 uuids.Add(datablock.ItemID);
13171 }
13172 handlerRemoveInventoryItem = OnRemoveInventoryItem;
13173 if (handlerRemoveInventoryItem != null)
13174 {
13175 handlerRemoveInventoryItem(this, uuids);
13176 }
13177 }
13178 break;
13179
13180 case PacketType.RequestTaskInventory:
13181 RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
13182
13183 #region Packet Session and User Check
13184 if (m_checkPackets)
13185 {
13186 if (requesttask.AgentData.SessionID != SessionId ||
13187 requesttask.AgentData.AgentID != AgentId)
13188 break;
13189 }
13190 #endregion
13191
13192 RequestTaskInventory handlerRequestTaskInventory = OnRequestTaskInventory;
13193 if (handlerRequestTaskInventory != null)
13194 {
13195 handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID);
13196 }
13197 break;
13198
13199 case PacketType.UpdateTaskInventory:
13200 UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
13201
13202 #region Packet Session and User Check
13203 if (m_checkPackets)
13204 {
13205 if (updatetask.AgentData.SessionID != SessionId ||
13206 updatetask.AgentData.AgentID != AgentId)
13207 break;
13208 }
13209 #endregion
13210
13211 if (OnUpdateTaskInventory != null)
13212 {
13213 if (updatetask.UpdateData.Key == 0)
13214 {
13215 UpdateTaskInventory handlerUpdateTaskInventory = OnUpdateTaskInventory;
13216 if (handlerUpdateTaskInventory != null)
13217 {
13218 TaskInventoryItem newTaskItem = new TaskInventoryItem();
13219 newTaskItem.ItemID = updatetask.InventoryData.ItemID;
13220 newTaskItem.ParentID = updatetask.InventoryData.FolderID;
13221 newTaskItem.CreatorID = updatetask.InventoryData.CreatorID;
13222 newTaskItem.OwnerID = updatetask.InventoryData.OwnerID;
13223 newTaskItem.GroupID = updatetask.InventoryData.GroupID;
13224 newTaskItem.BasePermissions = updatetask.InventoryData.BaseMask;
13225 newTaskItem.CurrentPermissions = updatetask.InventoryData.OwnerMask;
13226 newTaskItem.GroupPermissions = updatetask.InventoryData.GroupMask;
13227 newTaskItem.EveryonePermissions = updatetask.InventoryData.EveryoneMask;
13228 newTaskItem.NextPermissions = updatetask.InventoryData.NextOwnerMask;
13229 //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned;
13230 newTaskItem.Type = updatetask.InventoryData.Type;
13231 newTaskItem.InvType = updatetask.InventoryData.InvType;
13232 newTaskItem.Flags = updatetask.InventoryData.Flags;
13233 //newTaskItem.SaleType=updatetask.InventoryData.SaleType;
13234 //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;;
13235 newTaskItem.Name = Util.FieldToString(updatetask.InventoryData.Name);
13236 newTaskItem.Description = Util.FieldToString(updatetask.InventoryData.Description);
13237 newTaskItem.CreationDate = (uint)updatetask.InventoryData.CreationDate;
13238 handlerUpdateTaskInventory(this, updatetask.InventoryData.TransactionID,
13239 newTaskItem, updatetask.UpdateData.LocalID);
13240 }
13241 }
13242 }
13243
13244 break;
13245
13246 case PacketType.RemoveTaskInventory:
13247
13248 RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack;
13249
13250 #region Packet Session and User Check
13251 if (m_checkPackets)
13252 {
13253 if (removeTask.AgentData.SessionID != SessionId ||
13254 removeTask.AgentData.AgentID != AgentId)
13255 break;
13256 }
13257 #endregion
13258
13259 RemoveTaskInventory handlerRemoveTaskItem = OnRemoveTaskItem;
13260
13261 if (handlerRemoveTaskItem != null)
13262 {
13263 handlerRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID);
13264 }
13265
13266 break;
13267
13268 case PacketType.MoveTaskInventory:
13269
13270 MoveTaskInventoryPacket moveTaskInventoryPacket = (MoveTaskInventoryPacket)Pack;
13271
13272 #region Packet Session and User Check
13273 if (m_checkPackets)
13274 {
13275 if (moveTaskInventoryPacket.AgentData.SessionID != SessionId ||
13276 moveTaskInventoryPacket.AgentData.AgentID != AgentId)
13277 break;
13278 }
13279 #endregion
13280
13281 MoveTaskInventory handlerMoveTaskItem = OnMoveTaskItem;
13282
13283 if (handlerMoveTaskItem != null)
13284 {
13285 handlerMoveTaskItem(
13286 this, moveTaskInventoryPacket.AgentData.FolderID,
13287 moveTaskInventoryPacket.InventoryData.LocalID,
13288 moveTaskInventoryPacket.InventoryData.ItemID);
13289 }
13290
13291 break;
13292
13293 case PacketType.RezScript:
13294 //m_log.Debug(Pack.ToString());
13295 RezScriptPacket rezScriptx = (RezScriptPacket)Pack;
13296
13297 #region Packet Session and User Check
13298 if (m_checkPackets)
13299 {
13300 if (rezScriptx.AgentData.SessionID != SessionId ||
13301 rezScriptx.AgentData.AgentID != AgentId)
13302 break;
13303 }
13304 #endregion
13305
13306 RezScript handlerRezScript = OnRezScript;
13307 InventoryItemBase item = new InventoryItemBase();
13308 item.ID = rezScriptx.InventoryBlock.ItemID;
13309 item.Folder = rezScriptx.InventoryBlock.FolderID;
13310 item.CreatorId = rezScriptx.InventoryBlock.CreatorID.ToString();
13311 item.Owner = rezScriptx.InventoryBlock.OwnerID;
13312 item.BasePermissions = rezScriptx.InventoryBlock.BaseMask;
13313 item.CurrentPermissions = rezScriptx.InventoryBlock.OwnerMask;
13314 item.EveryOnePermissions = rezScriptx.InventoryBlock.EveryoneMask;
13315 item.NextPermissions = rezScriptx.InventoryBlock.NextOwnerMask;
13316 item.GroupPermissions = rezScriptx.InventoryBlock.GroupMask;
13317 item.GroupOwned = rezScriptx.InventoryBlock.GroupOwned;
13318 item.GroupID = rezScriptx.InventoryBlock.GroupID;
13319 item.AssetType = rezScriptx.InventoryBlock.Type;
13320 item.InvType = rezScriptx.InventoryBlock.InvType;
13321 item.Flags = rezScriptx.InventoryBlock.Flags;
13322 item.SaleType = rezScriptx.InventoryBlock.SaleType;
13323 item.SalePrice = rezScriptx.InventoryBlock.SalePrice;
13324 item.Name = Util.FieldToString(rezScriptx.InventoryBlock.Name);
13325 item.Description = Util.FieldToString(rezScriptx.InventoryBlock.Description);
13326 item.CreationDate = rezScriptx.InventoryBlock.CreationDate;
13327
13328 if (handlerRezScript != null)
13329 {
13330 handlerRezScript(this, item, rezScriptx.InventoryBlock.TransactionID, rezScriptx.UpdateBlock.ObjectLocalID);
13331 }
13332 break;
13333
13334 case PacketType.MapLayerRequest:
13335 RequestMapLayer();
13336 break;
13337 case PacketType.MapBlockRequest:
13338 MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack;
13339
13340 #region Packet Session and User Check
13341 if (m_checkPackets)
13342 {
13343 if (MapRequest.AgentData.SessionID != SessionId ||
13344 MapRequest.AgentData.AgentID != AgentId)
13345 break;
13346 }
13347 #endregion
13348
13349 RequestMapBlocks handlerRequestMapBlocks = OnRequestMapBlocks;
13350 if (handlerRequestMapBlocks != null)
13351 {
13352 handlerRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY,
13353 MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY, MapRequest.AgentData.Flags);
13354 }
13355 break;
13356 case PacketType.MapNameRequest:
13357 MapNameRequestPacket map = (MapNameRequestPacket)Pack;
13358
13359 #region Packet Session and User Check
13360 if (m_checkPackets)
13361 {
13362 if (map.AgentData.SessionID != SessionId ||
13363 map.AgentData.AgentID != AgentId)
13364 break;
13365 }
13366 #endregion
13367
13368 string mapName = Util.UTF8.GetString(map.NameData.Name, 0,
13369 map.NameData.Name.Length - 1);
13370 RequestMapName handlerMapNameRequest = OnMapNameRequest;
13371 if (handlerMapNameRequest != null)
13372 {
13373 handlerMapNameRequest(this, mapName);
13374 }
13375 break;
13376
13377 case PacketType.TeleportLandmarkRequest:
13378 TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
13379
13380 #region Packet Session and User Check
13381 if (m_checkPackets)
13382 {
13383 if (tpReq.Info.SessionID != SessionId ||
13384 tpReq.Info.AgentID != AgentId)
13385 break;
13386 }
13387 #endregion
13388
13389 UUID lmid = tpReq.Info.LandmarkID;
13390 AssetLandmark lm;
13391 if (lmid != UUID.Zero)
13392 {
13393 //AssetBase lma = m_assetCache.GetAsset(lmid, false);
13394 AssetBase lma = m_assetService.Get(lmid.ToString());
13395
13396 if (lma == null)
13397 {
13398 // Failed to find landmark
13399 TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
13400 tpCancel.Info.SessionID = tpReq.Info.SessionID;
13401 tpCancel.Info.AgentID = tpReq.Info.AgentID;
13402 OutPacket(tpCancel, ThrottleOutPacketType.Task);
13403 }
13404
13405 try
13406 {
13407 lm = new AssetLandmark(lma);
13408 }
13409 catch (NullReferenceException)
13410 {
13411 // asset not found generates null ref inside the assetlandmark constructor.
13412 TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
13413 tpCancel.Info.SessionID = tpReq.Info.SessionID;
13414 tpCancel.Info.AgentID = tpReq.Info.AgentID;
13415 OutPacket(tpCancel, ThrottleOutPacketType.Task);
13416 break;
13417 }
13418 }
13419 else
13420 {
13421 // Teleport home request
13422 UUIDNameRequest handlerTeleportHomeRequest = OnTeleportHomeRequest;
13423 if (handlerTeleportHomeRequest != null)
13424 {
13425 handlerTeleportHomeRequest(AgentId, this);
13426 }
13427 break;
13428 }
13429
13430 TeleportLandmarkRequest handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest;
13431 if (handlerTeleportLandmarkRequest != null)
13432 {
13433 handlerTeleportLandmarkRequest(this, lm.RegionID, lm.Position);
13434 }
13435 else
13436 {
13437 //no event handler so cancel request
13438
13439
13440 TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
13441 tpCancel.Info.AgentID = tpReq.Info.AgentID;
13442 tpCancel.Info.SessionID = tpReq.Info.SessionID;
13443 OutPacket(tpCancel, ThrottleOutPacketType.Task);
13444
13445 }
13446 break;
13447
13448 case PacketType.TeleportLocationRequest:
13449 TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
13450 // m_log.Debug(tpLocReq.ToString());
13451
13452 #region Packet Session and User Check
13453 if (m_checkPackets)
13454 {
13455 if (tpLocReq.AgentData.SessionID != SessionId ||
13456 tpLocReq.AgentData.AgentID != AgentId)
13457 break;
13458 }
13459 #endregion
13460
13461 TeleportLocationRequest handlerTeleportLocationRequest = OnTeleportLocationRequest;
13462 if (handlerTeleportLocationRequest != null)
13463 {
13464 handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position,
13465 tpLocReq.Info.LookAt, 16);
13466 }
13467 else
13468 {
13469 //no event handler so cancel request
13470 TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
13471 tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
13472 tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
13473 OutPacket(tpCancel, ThrottleOutPacketType.Task);
13474 }
13475 break;
13476
13477 //#endregion
13478
13479 case PacketType.UUIDNameRequest:
13480 UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack;
13481
13482 foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock)
13483 {
13484 UUIDNameRequest handlerNameRequest = OnNameFromUUIDRequest;
13485 if (handlerNameRequest != null)
13486 {
13487 handlerNameRequest(UUIDBlock.ID, this);
13488 }
13489 }
13490 break;
13491
13492 //#region Parcel related packets
13493
13494
13495 case PacketType.RegionHandleRequest:
13496 RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack;
13497
13498 RegionHandleRequest handlerRegionHandleRequest = OnRegionHandleRequest;
13499 if (handlerRegionHandleRequest != null)
13500 {
13501 handlerRegionHandleRequest(this, rhrPack.RequestBlock.RegionID);
13502 }
13503 break;
13504
13505 case PacketType.ParcelInfoRequest:
13506 ParcelInfoRequestPacket pirPack = (ParcelInfoRequestPacket)Pack;
13507
13508 #region Packet Session and User Check
13509 if (m_checkPackets)
13510 {
13511 if (pirPack.AgentData.SessionID != SessionId ||
13512 pirPack.AgentData.AgentID != AgentId)
13513 break;
13514 }
13515 #endregion
13516
13517 ParcelInfoRequest handlerParcelInfoRequest = OnParcelInfoRequest;
13518 if (handlerParcelInfoRequest != null)
13519 {
13520 handlerParcelInfoRequest(this, pirPack.Data.ParcelID);
13521 }
13522 break;
13523
13524 case PacketType.ParcelAccessListRequest:
13525 ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack;
13526
13527 #region Packet Session and User Check
13528 if (m_checkPackets)
13529 {
13530 if (requestPacket.AgentData.SessionID != SessionId ||
13531 requestPacket.AgentData.AgentID != AgentId)
13532 break;
13533 }
13534 #endregion
13535
13536 ParcelAccessListRequest handlerParcelAccessListRequest = OnParcelAccessListRequest;
13537
13538 if (handlerParcelAccessListRequest != null)
13539 {
13540 handlerParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID,
13541 requestPacket.Data.Flags, requestPacket.Data.SequenceID,
13542 requestPacket.Data.LocalID, this);
13543 }
13544 break;
13545
13546 case PacketType.ParcelAccessListUpdate:
13547 ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack;
13548
13549 #region Packet Session and User Check
13550 if (m_checkPackets)
13551 {
13552 if (updatePacket.AgentData.SessionID != SessionId ||
13553 updatePacket.AgentData.AgentID != AgentId)
13554 break;
13555 }
13556 #endregion
13557
13558 List<ParcelManager.ParcelAccessEntry> entries = new List<ParcelManager.ParcelAccessEntry>();
13559 foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List)
13560 {
13561 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
13562 entry.AgentID = block.ID;
13563 entry.Flags = (AccessList)block.Flags;
13564 entry.Time = new DateTime();
13565 entries.Add(entry);
13566 }
13567
13568 ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest;
13569 if (handlerParcelAccessListUpdateRequest != null)
13570 {
13571 handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID,
13572 updatePacket.AgentData.SessionID, updatePacket.Data.Flags,
13573 updatePacket.Data.LocalID, entries, this);
13574 }
13575 break;
13576
13577 case PacketType.ParcelPropertiesRequest:
13578
13579 ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack;
13580
13581 #region Packet Session and User Check
13582 if (m_checkPackets)
13583 {
13584 if (propertiesRequest.AgentData.SessionID != SessionId ||
13585 propertiesRequest.AgentData.AgentID != AgentId)
13586 break;
13587 }
13588 #endregion
13589
13590 ParcelPropertiesRequest handlerParcelPropertiesRequest = OnParcelPropertiesRequest;
13591 if (handlerParcelPropertiesRequest != null)
13592 {
13593 handlerParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West),
13594 (int)Math.Round(propertiesRequest.ParcelData.South),
13595 (int)Math.Round(propertiesRequest.ParcelData.East),
13596 (int)Math.Round(propertiesRequest.ParcelData.North),
13597 propertiesRequest.ParcelData.SequenceID,
13598 propertiesRequest.ParcelData.SnapSelection, this);
13599 }
13600 break;
13601
13602 case PacketType.ParcelDivide:
13603 ParcelDividePacket landDivide = (ParcelDividePacket)Pack;
13604
13605 #region Packet Session and User Check
13606 if (m_checkPackets)
13607 {
13608 if (landDivide.AgentData.SessionID != SessionId ||
13609 landDivide.AgentData.AgentID != AgentId)
13610 break;
13611 }
13612 #endregion
13613
13614 ParcelDivideRequest handlerParcelDivideRequest = OnParcelDivideRequest;
13615 if (handlerParcelDivideRequest != null)
13616 {
13617 handlerParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West),
13618 (int)Math.Round(landDivide.ParcelData.South),
13619 (int)Math.Round(landDivide.ParcelData.East),
13620 (int)Math.Round(landDivide.ParcelData.North), this);
13621 }
13622 break;
13623
13624 case PacketType.ParcelJoin:
13625 ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack;
13626
13627 #region Packet Session and User Check
13628 if (m_checkPackets)
13629 {
13630 if (landJoin.AgentData.SessionID != SessionId ||
13631 landJoin.AgentData.AgentID != AgentId)
13632 break;
13633 }
13634 #endregion
13635
13636 ParcelJoinRequest handlerParcelJoinRequest = OnParcelJoinRequest;
13637
13638 if (handlerParcelJoinRequest != null)
13639 {
13640 handlerParcelJoinRequest((int)Math.Round(landJoin.ParcelData.West),
13641 (int)Math.Round(landJoin.ParcelData.South),
13642 (int)Math.Round(landJoin.ParcelData.East),
13643 (int)Math.Round(landJoin.ParcelData.North), this);
13644 }
13645 break;
13646
13647 case PacketType.ParcelPropertiesUpdate:
13648 ParcelPropertiesUpdatePacket parcelPropertiesPacket = (ParcelPropertiesUpdatePacket)Pack;
13649
13650 #region Packet Session and User Check
13651 if (m_checkPackets)
13652 {
13653 if (parcelPropertiesPacket.AgentData.SessionID != SessionId ||
13654 parcelPropertiesPacket.AgentData.AgentID != AgentId)
13655 break;
13656 }
13657 #endregion
13658
13659 ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest;
13660
13661 if (handlerParcelPropertiesUpdateRequest != null)
13662 {
13663 LandUpdateArgs args = new LandUpdateArgs();
13664
13665 args.AuthBuyerID = parcelPropertiesPacket.ParcelData.AuthBuyerID;
13666 args.Category = (ParcelCategory)parcelPropertiesPacket.ParcelData.Category;
13667 args.Desc = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Desc);
13668 args.GroupID = parcelPropertiesPacket.ParcelData.GroupID;
13669 args.LandingType = parcelPropertiesPacket.ParcelData.LandingType;
13670 args.MediaAutoScale = parcelPropertiesPacket.ParcelData.MediaAutoScale;
13671 args.MediaID = parcelPropertiesPacket.ParcelData.MediaID;
13672 args.MediaURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MediaURL);
13673 args.MusicURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MusicURL);
13674 args.Name = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Name);
13675 args.ParcelFlags = parcelPropertiesPacket.ParcelData.ParcelFlags;
13676 args.PassHours = parcelPropertiesPacket.ParcelData.PassHours;
13677 args.PassPrice = parcelPropertiesPacket.ParcelData.PassPrice;
13678 args.SalePrice = parcelPropertiesPacket.ParcelData.SalePrice;
13679 args.SnapshotID = parcelPropertiesPacket.ParcelData.SnapshotID;
13680 args.UserLocation = parcelPropertiesPacket.ParcelData.UserLocation;
13681 args.UserLookAt = parcelPropertiesPacket.ParcelData.UserLookAt;
13682 handlerParcelPropertiesUpdateRequest(args, parcelPropertiesPacket.ParcelData.LocalID, this);
13683 }
13684 break;
13685
13686 case PacketType.ParcelSelectObjects:
13687 ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack;
13688
13689 #region Packet Session and User Check
13690 if (m_checkPackets)
13691 {
13692 if (selectPacket.AgentData.SessionID != SessionId ||
13693 selectPacket.AgentData.AgentID != AgentId)
13694 break;
13695 }
13696 #endregion
13697
13698 List<UUID> returnIDs = new List<UUID>();
13699
13700 foreach (ParcelSelectObjectsPacket.ReturnIDsBlock rb in
13701 selectPacket.ReturnIDs)
13702 {
13703 returnIDs.Add(rb.ReturnID);
13704 }
13705
13706 ParcelSelectObjects handlerParcelSelectObjects = OnParcelSelectObjects;
13707
13708 if (handlerParcelSelectObjects != null)
13709 {
13710 handlerParcelSelectObjects(selectPacket.ParcelData.LocalID,
13711 Convert.ToInt32(selectPacket.ParcelData.ReturnType), returnIDs, this);
13712 }
13713 break;
13714
13715 case PacketType.ParcelObjectOwnersRequest:
13716 //m_log.Debug(Pack.ToString());
13717 ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack;
13718
13719 #region Packet Session and User Check
13720 if (m_checkPackets)
13721 {
13722 if (reqPacket.AgentData.SessionID != SessionId ||
13723 reqPacket.AgentData.AgentID != AgentId)
13724 break;
13725 }
13726 #endregion
13727
13728 ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest;
13729
13730 if (handlerParcelObjectOwnerRequest != null)
13731 {
13732 handlerParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this);
13733 }
13734 break;
13735
13736 case PacketType.ParcelGodForceOwner:
13737 ParcelGodForceOwnerPacket godForceOwnerPacket = (ParcelGodForceOwnerPacket)Pack;
13738
13739 #region Packet Session and User Check
13740 if (m_checkPackets)
13741 {
13742 if (godForceOwnerPacket.AgentData.SessionID != SessionId ||
13743 godForceOwnerPacket.AgentData.AgentID != AgentId)
13744 break;
13745 }
13746 #endregion
13747
13748 ParcelGodForceOwner handlerParcelGodForceOwner = OnParcelGodForceOwner;
13749 if (handlerParcelGodForceOwner != null)
13750 {
13751 handlerParcelGodForceOwner(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, this);
13752 }
13753 break;
13754
13755 case PacketType.ParcelRelease:
13756 ParcelReleasePacket releasePacket = (ParcelReleasePacket)Pack;
13757
13758 #region Packet Session and User Check
13759 if (m_checkPackets)
13760 {
13761 if (releasePacket.AgentData.SessionID != SessionId ||
13762 releasePacket.AgentData.AgentID != AgentId)
13763 break;
13764 }
13765 #endregion
13766
13767 ParcelAbandonRequest handlerParcelAbandonRequest = OnParcelAbandonRequest;
13768 if (handlerParcelAbandonRequest != null)
13769 {
13770 handlerParcelAbandonRequest(releasePacket.Data.LocalID, this);
13771 }
13772 break;
13773
13774 case PacketType.ParcelReclaim:
13775 ParcelReclaimPacket reclaimPacket = (ParcelReclaimPacket)Pack;
13776
13777 #region Packet Session and User Check
13778 if (m_checkPackets)
13779 {
13780 if (reclaimPacket.AgentData.SessionID != SessionId ||
13781 reclaimPacket.AgentData.AgentID != AgentId)
13782 break;
13783 }
13784 #endregion
13785
13786 ParcelReclaim handlerParcelReclaim = OnParcelReclaim;
13787 if (handlerParcelReclaim != null)
13788 {
13789 handlerParcelReclaim(reclaimPacket.Data.LocalID, this);
13790 }
13791 break;
13792
13793 case PacketType.ParcelReturnObjects:
13794
13795
13796 ParcelReturnObjectsPacket parcelReturnObjects = (ParcelReturnObjectsPacket)Pack;
13797
13798 #region Packet Session and User Check
13799 if (m_checkPackets)
13800 {
13801 if (parcelReturnObjects.AgentData.SessionID != SessionId ||
13802 parcelReturnObjects.AgentData.AgentID != AgentId)
13803 break;
13804 }
13805 #endregion
13806
13807 UUID[] puserselectedOwnerIDs = new UUID[parcelReturnObjects.OwnerIDs.Length];
13808 for (int parceliterator = 0; parceliterator < parcelReturnObjects.OwnerIDs.Length; parceliterator++)
13809 puserselectedOwnerIDs[parceliterator] = parcelReturnObjects.OwnerIDs[parceliterator].OwnerID;
13810
13811 UUID[] puserselectedTaskIDs = new UUID[parcelReturnObjects.TaskIDs.Length];
13812
13813 for (int parceliterator = 0; parceliterator < parcelReturnObjects.TaskIDs.Length; parceliterator++)
13814 puserselectedTaskIDs[parceliterator] = parcelReturnObjects.TaskIDs[parceliterator].TaskID;
13815
13816 ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest = OnParcelReturnObjectsRequest;
13817 if (handlerParcelReturnObjectsRequest != null)
13818 {
13819 handlerParcelReturnObjectsRequest(parcelReturnObjects.ParcelData.LocalID, parcelReturnObjects.ParcelData.ReturnType, puserselectedOwnerIDs, puserselectedTaskIDs, this);
13820
13821 }
13822 break;
13823
13824 case PacketType.ParcelSetOtherCleanTime:
13825 ParcelSetOtherCleanTimePacket parcelSetOtherCleanTimePacket = (ParcelSetOtherCleanTimePacket)Pack;
13826
13827 #region Packet Session and User Check
13828 if (m_checkPackets)
13829 {
13830 if (parcelSetOtherCleanTimePacket.AgentData.SessionID != SessionId ||
13831 parcelSetOtherCleanTimePacket.AgentData.AgentID != AgentId)
13832 break;
13833 }
13834 #endregion
13835
13836 ParcelSetOtherCleanTime handlerParcelSetOtherCleanTime = OnParcelSetOtherCleanTime;
13837 if (handlerParcelSetOtherCleanTime != null)
13838 {
13839 handlerParcelSetOtherCleanTime(this,
13840 parcelSetOtherCleanTimePacket.ParcelData.LocalID,
13841 parcelSetOtherCleanTimePacket.ParcelData.OtherCleanTime);
13842 }
13843 break;
13844
13845 case PacketType.LandStatRequest:
13846 LandStatRequestPacket lsrp = (LandStatRequestPacket)Pack;
13847
13848 #region Packet Session and User Check
13849 if (m_checkPackets)
13850 {
13851 if (lsrp.AgentData.SessionID != SessionId ||
13852 lsrp.AgentData.AgentID != AgentId)
13853 break;
13854 }
13855 #endregion
13856
13857 GodLandStatRequest handlerLandStatRequest = OnLandStatRequest;
13858 if (handlerLandStatRequest != null)
13859 {
13860 handlerLandStatRequest(lsrp.RequestData.ParcelLocalID, lsrp.RequestData.ReportType, lsrp.RequestData.RequestFlags, Utils.BytesToString(lsrp.RequestData.Filter), this);
13861 }
13862 break;
13863
13864 case PacketType.ParcelDwellRequest:
13865 ParcelDwellRequestPacket dwellrq =
13866 (ParcelDwellRequestPacket)Pack;
13867
13868 #region Packet Session and User Check
13869 if (m_checkPackets)
13870 {
13871 if (dwellrq.AgentData.SessionID != SessionId ||
13872 dwellrq.AgentData.AgentID != AgentId)
13873 break;
13874 }
13875 #endregion
13876
13877 ParcelDwellRequest handlerParcelDwellRequest = OnParcelDwellRequest;
13878 if (handlerParcelDwellRequest != null)
13879 {
13880 handlerParcelDwellRequest(dwellrq.Data.LocalID, this);
13881 }
13882 break;
13883
13884 //#endregion
13885
13886 //#region Estate Packets
13887
13888 case PacketType.EstateOwnerMessage:
13889 EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack;
13890 //m_log.Debug(messagePacket.ToString());
13891
13892 #region Packet Session and User Check
13893 if (m_checkPackets)
13894 {
13895 if (messagePacket.AgentData.SessionID != SessionId ||
13896 messagePacket.AgentData.AgentID != AgentId)
13897 break;
13898 }
13899 #endregion
13900
13901 switch (Utils.BytesToString(messagePacket.MethodData.Method))
13902 {
13903 case "getinfo":
13904 if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
13905 {
13906 OnDetailedEstateDataRequest(this, messagePacket.MethodData.Invoice);
13907 }
13908 break;
13909 case "setregioninfo":
13910 if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
13911 {
13912 OnSetEstateFlagsRequest(convertParamStringToBool(messagePacket.ParamList[0].Parameter), convertParamStringToBool(messagePacket.ParamList[1].Parameter),
13913 convertParamStringToBool(messagePacket.ParamList[2].Parameter), !convertParamStringToBool(messagePacket.ParamList[3].Parameter),
13914 Convert.ToInt16(Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[4].Parameter), Culture.NumberFormatInfo)),
13915 (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo),
13916 Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[6].Parameter)),
13917 convertParamStringToBool(messagePacket.ParamList[7].Parameter), convertParamStringToBool(messagePacket.ParamList[8].Parameter));
13918 }
13919 break;
13920 // case "texturebase":
13921 // if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
13922 // {
13923 // foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
13924 // {
13925 // string s = Utils.BytesToString(block.Parameter);
13926 // string[] splitField = s.Split(' ');
13927 // if (splitField.Length == 2)
13928 // {
13929 // UUID tempUUID = new UUID(splitField[1]);
13930 // OnSetEstateTerrainBaseTexture(this, Convert.ToInt16(splitField[0]), tempUUID);
13931 // }
13932 // }
13933 // }
13934 // break;
13935 case "texturedetail":
13936 if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
13937 {
13938 foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
13939 {
13940 string s = Utils.BytesToString(block.Parameter);
13941 string[] splitField = s.Split(' ');
13942 if (splitField.Length == 2)
13943 {
13944 Int16 corner = Convert.ToInt16(splitField[0]);
13945 UUID textureUUID = new UUID(splitField[1]);
13946
13947 OnSetEstateTerrainDetailTexture(this, corner, textureUUID);
13948 }
13949 }
13950 }
13951
13952 break;
13953 case "textureheights":
13954 if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
13955 {
13956 foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
13957 {
13958 string s = Utils.BytesToString(block.Parameter);
13959 string[] splitField = s.Split(' ');
13960 if (splitField.Length == 3)
13961 {
13962 Int16 corner = Convert.ToInt16(splitField[0]);
13963 float lowValue = (float)Convert.ToDecimal(splitField[1], Culture.NumberFormatInfo);
13964 float highValue = (float)Convert.ToDecimal(splitField[2], Culture.NumberFormatInfo);
13965
13966 OnSetEstateTerrainTextureHeights(this, corner, lowValue, highValue);
13967 }
13968 }
13969 }
13970 break;
13971 case "texturecommit":
13972 OnCommitEstateTerrainTextureRequest(this);
13973 break;
13974 case "setregionterrain":
13975 if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
13976 {
13977 if (messagePacket.ParamList.Length != 9)
13978 {
13979 m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
13980 }
13981 else
13982 {
13983 try
13984 {
13985 string tmp = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
13986 if (!tmp.Contains(".")) tmp += ".00";
13987 float WaterHeight = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
13988 tmp = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
13989 if (!tmp.Contains(".")) tmp += ".00";
13990 float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
13991 tmp = Utils.BytesToString(messagePacket.ParamList[2].Parameter);
13992 if (!tmp.Contains(".")) tmp += ".00";
13993 float TerrainLowerLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
13994 bool UseEstateSun = convertParamStringToBool(messagePacket.ParamList[3].Parameter);
13995 bool UseFixedSun = convertParamStringToBool(messagePacket.ParamList[4].Parameter);
13996 float SunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo);
13997 bool UseGlobal = convertParamStringToBool(messagePacket.ParamList[6].Parameter);
13998 bool EstateFixedSun = convertParamStringToBool(messagePacket.ParamList[7].Parameter);
13999 float EstateSunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[8].Parameter), Culture.NumberFormatInfo);
14000
14001 OnSetRegionTerrainSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseEstateSun, UseFixedSun, SunHour, UseGlobal, EstateFixedSun, EstateSunHour);
14002
14003 }
14004 catch (Exception ex)
14005 {
14006 m_log.Error("EstateOwnerMessage: Exception while setting terrain settings: \n" + messagePacket + "\n" + ex);
14007 }
14008 }
14009 }
14010
14011 break;
14012 case "restart":
14013 if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
14014 {
14015 // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart.
14016 foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
14017 {
14018 float timeSeconds;
14019 Utils.TryParseSingle(Utils.BytesToString(block.Parameter), out timeSeconds);
14020 timeSeconds = (int)timeSeconds;
14021 OnEstateRestartSimRequest(this, (int)timeSeconds);
14022
14023 }
14024 }
14025 break;
14026 case "estatechangecovenantid":
14027 if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
14028 {
14029 foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
14030 {
14031 UUID newCovenantID = new UUID(Utils.BytesToString(block.Parameter));
14032 OnEstateChangeCovenantRequest(this, newCovenantID);
14033 }
14034 }
14035 break;
14036 case "estateaccessdelta": // Estate access delta manages the banlist and allow list too.
14037 if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
14038 {
14039 int estateAccessType = Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
14040 OnUpdateEstateAccessDeltaRequest(this, messagePacket.MethodData.Invoice, estateAccessType, new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)));
14041
14042 }
14043 break;
14044 case "simulatormessage":
14045 if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
14046 {
14047 UUID invoice = messagePacket.MethodData.Invoice;
14048 UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
14049 string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
14050 string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
14051 UUID sessionID = messagePacket.AgentData.SessionID;
14052 OnSimulatorBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
14053 }
14054 break;
14055 case "instantmessage":
14056 if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
14057 {
14058 if (messagePacket.ParamList.Length < 5)
14059 break;
14060 UUID invoice = messagePacket.MethodData.Invoice;
14061 UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
14062 string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
14063 string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
14064 UUID sessionID = messagePacket.AgentData.SessionID;
14065 OnEstateBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
14066 }
14067 break;
14068 case "setregiondebug":
14069 if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
14070 {
14071 UUID invoice = messagePacket.MethodData.Invoice;
14072 UUID SenderID = messagePacket.AgentData.AgentID;
14073 bool scripted = convertParamStringToBool(messagePacket.ParamList[0].Parameter);
14074 bool collisionEvents = convertParamStringToBool(messagePacket.ParamList[1].Parameter);
14075 bool physics = convertParamStringToBool(messagePacket.ParamList[2].Parameter);
14076
14077 OnEstateDebugRegionRequest(this, invoice, SenderID, scripted, collisionEvents, physics);
14078 }
14079 break;
14080 case "teleporthomeuser":
14081 if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
14082 {
14083 UUID invoice = messagePacket.MethodData.Invoice;
14084 UUID SenderID = messagePacket.AgentData.AgentID;
14085 UUID Prey;
14086
14087 UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[1].Parameter), out Prey);
14088
14089 OnEstateTeleportOneUserHomeRequest(this, invoice, SenderID, Prey);
14090 }
14091 break;
14092 case "teleporthomeallusers":
14093 if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
14094 {
14095 UUID invoice = messagePacket.MethodData.Invoice;
14096 UUID SenderID = messagePacket.AgentData.AgentID;
14097 OnEstateTeleportAllUsersHomeRequest(this, invoice, SenderID);
14098 }
14099 break;
14100 case "colliders":
14101 handlerLandStatRequest = OnLandStatRequest;
14102 if (handlerLandStatRequest != null)
14103 {
14104 handlerLandStatRequest(0, 1, 0, "", this);
14105 }
14106 break;
14107 case "scripts":
14108 handlerLandStatRequest = OnLandStatRequest;
14109 if (handlerLandStatRequest != null)
14110 {
14111 handlerLandStatRequest(0, 0, 0, "", this);
14112 }
14113 break;
14114 case "terrain":
14115 if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
14116 {
14117 if (messagePacket.ParamList.Length > 0)
14118 {
14119 if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "bake")
14120 {
14121 BakeTerrain handlerBakeTerrain = OnBakeTerrain;
14122 if (handlerBakeTerrain != null)
14123 {
14124 handlerBakeTerrain(this);
14125 }
14126 }
14127 if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "download filename")
14128 {
14129 if (messagePacket.ParamList.Length > 1)
14130 {
14131 RequestTerrain handlerRequestTerrain = OnRequestTerrain;
14132 if (handlerRequestTerrain != null)
14133 {
14134 handlerRequestTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
14135 }
14136 }
14137 }
14138 if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "upload filename")
14139 {
14140 if (messagePacket.ParamList.Length > 1)
14141 {
14142 RequestTerrain handlerUploadTerrain = OnUploadTerrain;
14143 if (handlerUploadTerrain != null)
14144 {
14145 handlerUploadTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
14146 }
14147 }
14148 }
14149
14150 }
14151
14152
14153 }
14154 break;
14155
14156 case "estatechangeinfo":
14157 if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
14158 {
14159 UUID invoice = messagePacket.MethodData.Invoice;
14160 UUID SenderID = messagePacket.AgentData.AgentID;
14161 UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
14162 UInt32 param2 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
14163
14164 EstateChangeInfo handlerEstateChangeInfo = OnEstateChangeInfo;
14165 if (handlerEstateChangeInfo != null)
14166 {
14167 handlerEstateChangeInfo(this, invoice, SenderID, param1, param2);
14168 }
14169 }
14170 break;
14171
14172 default:
14173 m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket);
14174 break;
14175 }
14176
14177 //int parcelID, uint reportType, uint requestflags, string filter
14178
14179 //lsrp.RequestData.ParcelLocalID;
14180 //lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts
14181 //lsrp.RequestData.RequestFlags;
14182 //lsrp.RequestData.Filter;
14183
14184 break;
14185
14186 case PacketType.RequestRegionInfo:
14187 RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData;
14188
14189 #region Packet Session and User Check
14190 if (m_checkPackets)
14191 {
14192 if (mPacket.SessionID != SessionId ||
14193 mPacket.AgentID != AgentId)
14194 break;
14195 }
14196 #endregion
14197
14198 RegionInfoRequest handlerRegionInfoRequest = OnRegionInfoRequest;
14199 if (handlerRegionInfoRequest != null)
14200 {
14201 handlerRegionInfoRequest(this);
14202 }
14203 break;
14204
14205 case PacketType.EstateCovenantRequest:
14206
14207 //EstateCovenantRequestPacket.AgentDataBlock epack =
14208 // ((EstateCovenantRequestPacket)Pack).AgentData;
14209
14210 EstateCovenantRequest handlerEstateCovenantRequest = OnEstateCovenantRequest;
14211 if (handlerEstateCovenantRequest != null)
14212 {
14213 handlerEstateCovenantRequest(this);
14214 }
14215 break;
14216
14217 //#endregion
14218
14219 //#region GodPackets
14220
14221 case PacketType.RequestGodlikePowers:
14222 RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack;
14223 RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock;
14224 UUID token = rblock.Token;
14225
14226 RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData;
14227
14228 RequestGodlikePowers handlerReqGodlikePowers = OnRequestGodlikePowers;
14229
14230 if (handlerReqGodlikePowers != null)
14231 {
14232 handlerReqGodlikePowers(ablock.AgentID, ablock.SessionID, token, rblock.Godlike, this);
14233 }
14234
14235 break;
14236
14237 case PacketType.GodKickUser:
14238 GodKickUserPacket gkupack = (GodKickUserPacket)Pack;
14239
14240 if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID)
14241 {
14242 GodKickUser handlerGodKickUser = OnGodKickUser;
14243 if (handlerGodKickUser != null)
14244 {
14245 handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID,
14246 gkupack.UserInfo.AgentID, gkupack.UserInfo.KickFlags, gkupack.UserInfo.Reason,gkupack.UserInfo);
14247 }
14248 }
14249 else
14250 {
14251 SendAgentAlertMessage("Kick request denied", false);
14252 }
14253 //KickUserPacket kupack = new KickUserPacket();
14254 //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo;
14255
14256 //kupack.UserInfo.AgentID = gkupack.UserInfo.AgentID;
14257 //kupack.UserInfo.SessionID = gkupack.UserInfo.GodSessionID;
14258
14259 //kupack.TargetBlock.TargetIP = (uint)0;
14260 //kupack.TargetBlock.TargetPort = (ushort)0;
14261 //kupack.UserInfo.Reason = gkupack.UserInfo.Reason;
14262
14263 //OutPacket(kupack, ThrottleOutPacketType.Task);
14264 break;
14265
14266 //#endregion
14267
14268 //#region Economy/Transaction Packets
14269
14270 case PacketType.MoneyBalanceRequest:
14271 MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack;
14272
14273 #region Packet Session and User Check
14274 if (m_checkPackets)
14275 {
14276 if (moneybalancerequestpacket.AgentData.SessionID != SessionId ||
14277 moneybalancerequestpacket.AgentData.AgentID != AgentId)
14278 break;
14279 }
14280 #endregion
14281
14282 MoneyBalanceRequest handlerMoneyBalanceRequest = OnMoneyBalanceRequest;
14283
14284 if (handlerMoneyBalanceRequest != null)
14285 {
14286 handlerMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID);
14287 }
14288
14289 break;
14290
14291 case PacketType.EconomyDataRequest:
14292
14293
14294 EconomyDataRequest handlerEconomoyDataRequest = OnEconomyDataRequest;
14295 if (handlerEconomoyDataRequest != null)
14296 {
14297 handlerEconomoyDataRequest(AgentId);
14298 }
14299 break;
14300
14301 case PacketType.RequestPayPrice:
14302 RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack;
14303
14304 RequestPayPrice handlerRequestPayPrice = OnRequestPayPrice;
14305 if (handlerRequestPayPrice != null)
14306 {
14307 handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID);
14308 }
14309 break;
14310
14311 case PacketType.ObjectSaleInfo:
14312 ObjectSaleInfoPacket objectSaleInfoPacket = (ObjectSaleInfoPacket)Pack;
14313
14314 #region Packet Session and User Check
14315 if (m_checkPackets)
14316 {
14317 if (objectSaleInfoPacket.AgentData.SessionID != SessionId ||
14318 objectSaleInfoPacket.AgentData.AgentID != AgentId)
14319 break;
14320 }
14321 #endregion
14322
14323 ObjectSaleInfo handlerObjectSaleInfo = OnObjectSaleInfo;
14324 if (handlerObjectSaleInfo != null)
14325 {
14326 foreach (ObjectSaleInfoPacket.ObjectDataBlock d
14327 in objectSaleInfoPacket.ObjectData)
14328 {
14329 handlerObjectSaleInfo(this,
14330 objectSaleInfoPacket.AgentData.AgentID,
14331 objectSaleInfoPacket.AgentData.SessionID,
14332 d.LocalID,
14333 d.SaleType,
14334 d.SalePrice);
14335 }
14336 }
14337 break;
14338
14339 case PacketType.ObjectBuy:
14340 ObjectBuyPacket objectBuyPacket = (ObjectBuyPacket)Pack;
14341
14342 #region Packet Session and User Check
14343 if (m_checkPackets)
14344 {
14345 if (objectBuyPacket.AgentData.SessionID != SessionId ||
14346 objectBuyPacket.AgentData.AgentID != AgentId)
14347 break;
14348 }
14349 #endregion
14350
14351 ObjectBuy handlerObjectBuy = OnObjectBuy;
14352
14353 if (handlerObjectBuy != null)
14354 {
14355 foreach (ObjectBuyPacket.ObjectDataBlock d
14356 in objectBuyPacket.ObjectData)
14357 {
14358 handlerObjectBuy(this,
14359 objectBuyPacket.AgentData.AgentID,
14360 objectBuyPacket.AgentData.SessionID,
14361 objectBuyPacket.AgentData.GroupID,
14362 objectBuyPacket.AgentData.CategoryID,
14363 d.ObjectLocalID,
14364 d.SaleType,
14365 d.SalePrice);
14366 }
14367 }
14368 break;
14369
14370 //#endregion
14371
14372 //#region Script Packets
14373
14374 case PacketType.GetScriptRunning:
14375 GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack;
14376
14377 GetScriptRunning handlerGetScriptRunning = OnGetScriptRunning;
14378 if (handlerGetScriptRunning != null)
14379 {
14380 handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID);
14381 }
14382 break;
14383
14384 case PacketType.SetScriptRunning:
14385 SetScriptRunningPacket setScriptRunning = (SetScriptRunningPacket)Pack;
14386
14387 #region Packet Session and User Check
14388 if (m_checkPackets)
14389 {
14390 if (setScriptRunning.AgentData.SessionID != SessionId ||
14391 setScriptRunning.AgentData.AgentID != AgentId)
14392 break;
14393 }
14394 #endregion
14395
14396 SetScriptRunning handlerSetScriptRunning = OnSetScriptRunning;
14397 if (handlerSetScriptRunning != null)
14398 {
14399 handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running);
14400 }
14401 break;
14402
14403 case PacketType.ScriptReset:
14404 ScriptResetPacket scriptResetPacket = (ScriptResetPacket)Pack;
14405
14406 #region Packet Session and User Check
14407 if (m_checkPackets)
14408 {
14409 if (scriptResetPacket.AgentData.SessionID != SessionId ||
14410 scriptResetPacket.AgentData.AgentID != AgentId)
14411 break;
14412 }
14413 #endregion
14414
14415 ScriptReset handlerScriptReset = OnScriptReset;
14416 if (handlerScriptReset != null)
14417 {
14418 handlerScriptReset(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID);
14419 }
14420 break;
14421
14422 //#endregion
14423
14424 //#region Gesture Managment
14425
14426 case PacketType.ActivateGestures:
14427 ActivateGesturesPacket activateGesturePacket = (ActivateGesturesPacket)Pack;
14428
14429 #region Packet Session and User Check
14430 if (m_checkPackets)
14431 {
14432 if (activateGesturePacket.AgentData.SessionID != SessionId ||
14433 activateGesturePacket.AgentData.AgentID != AgentId)
14434 break;
14435 }
14436 #endregion
14437
14438 ActivateGesture handlerActivateGesture = OnActivateGesture;
14439 if (handlerActivateGesture != null)
14440 {
14441 handlerActivateGesture(this,
14442 activateGesturePacket.Data[0].AssetID,
14443 activateGesturePacket.Data[0].ItemID);
14444 }
14445 else m_log.Error("Null pointer for activateGesture");
14446
14447 break;
14448
14449 case PacketType.DeactivateGestures:
14450 DeactivateGesturesPacket deactivateGesturePacket = (DeactivateGesturesPacket)Pack;
14451
14452 #region Packet Session and User Check
14453 if (m_checkPackets)
14454 {
14455 if (deactivateGesturePacket.AgentData.SessionID != SessionId ||
14456 deactivateGesturePacket.AgentData.AgentID != AgentId)
14457 break;
14458 }
14459 #endregion
14460
14461 DeactivateGesture handlerDeactivateGesture = OnDeactivateGesture;
14462 if (handlerDeactivateGesture != null)
14463 {
14464 handlerDeactivateGesture(this, deactivateGesturePacket.Data[0].ItemID);
14465 }
14466 break;
14467 case PacketType.ObjectOwner:
14468 ObjectOwnerPacket objectOwnerPacket = (ObjectOwnerPacket)Pack;
14469
14470 #region Packet Session and User Check
14471 if (m_checkPackets)
14472 {
14473 if (objectOwnerPacket.AgentData.SessionID != SessionId ||
14474 objectOwnerPacket.AgentData.AgentID != AgentId)
14475 break;
14476 }
14477 #endregion
14478
14479 List<uint> localIDs = new List<uint>();
14480
14481 foreach (ObjectOwnerPacket.ObjectDataBlock d in objectOwnerPacket.ObjectData)
14482 localIDs.Add(d.ObjectLocalID);
14483
14484 ObjectOwner handlerObjectOwner = OnObjectOwner;
14485 if (handlerObjectOwner != null)
14486 {
14487 handlerObjectOwner(this, objectOwnerPacket.HeaderData.OwnerID, objectOwnerPacket.HeaderData.GroupID, localIDs);
14488 }
14489 break;
14490
14491 //#endregion
14492
14493 case PacketType.AgentFOV:
14494 AgentFOVPacket fovPacket = (AgentFOVPacket)Pack;
14495
14496 if (fovPacket.FOVBlock.GenCounter > m_agentFOVCounter)
14497 {
14498 m_agentFOVCounter = fovPacket.FOVBlock.GenCounter;
14499 AgentFOV handlerAgentFOV = OnAgentFOV;
14500 if (handlerAgentFOV != null)
14501 {
14502 handlerAgentFOV(this, fovPacket.FOVBlock.VerticalAngle);
14503 }
14504 }
14505 break;
14506
14507 //#region unimplemented handlers
14508
14509 case PacketType.ViewerStats:
14510 // TODO: handle this packet
14511 //m_log.Warn("[CLIENT]: unhandled ViewerStats packet");
14512 break;
14513
14514 case PacketType.MapItemRequest:
14515 MapItemRequestPacket mirpk = (MapItemRequestPacket)Pack;
14516
14517 #region Packet Session and User Check
14518 if (m_checkPackets)
14519 {
14520 if (mirpk.AgentData.SessionID != SessionId ||
14521 mirpk.AgentData.AgentID != AgentId)
14522 break;
14523 }
14524 #endregion
14525
14526 //m_log.Debug(mirpk.ToString());
14527 MapItemRequest handlerMapItemRequest = OnMapItemRequest;
14528 if (handlerMapItemRequest != null)
14529 {
14530 handlerMapItemRequest(this, mirpk.AgentData.Flags, mirpk.AgentData.EstateID,
14531 mirpk.AgentData.Godlike, mirpk.RequestData.ItemType,
14532 mirpk.RequestData.RegionHandle);
14533
14534 }
14535 break;
14536
14537 case PacketType.TransferAbort:
14538 // TODO: handle this packet
14539 //m_log.Warn("[CLIENT]: unhandled TransferAbort packet");
14540 break;
14541
14542 case PacketType.MuteListRequest:
14543 MuteListRequestPacket muteListRequest =
14544 (MuteListRequestPacket)Pack;
14545
14546 #region Packet Session and User Check
14547 if (m_checkPackets)
14548 {
14549 if (muteListRequest.AgentData.SessionID != SessionId ||
14550 muteListRequest.AgentData.AgentID != AgentId)
14551 break;
14552 }
14553 #endregion
14554
14555 MuteListRequest handlerMuteListRequest = OnMuteListRequest;
14556 if (handlerMuteListRequest != null)
14557 {
14558 handlerMuteListRequest(this, muteListRequest.MuteData.MuteCRC);
14559 }
14560 else
14561 {
14562 SendUseCachedMuteList();
14563 }
14564 break;
14565
14566 case PacketType.UseCircuitCode:
14567 // Don't display this one, we handle it at a lower level
14568 break;
14569
14570 case PacketType.AgentHeightWidth:
14571 // TODO: handle this packet
14572 //m_log.Warn("[CLIENT]: unhandled AgentHeightWidth packet");
14573 break;
14574
14575 case PacketType.InventoryDescendents:
14576 // TODO: handle this packet
14577 //m_log.Warn("[CLIENT]: unhandled InventoryDescent packet");
14578
14579 break;
14580
14581 case PacketType.DirPlacesQuery:
14582 DirPlacesQueryPacket dirPlacesQueryPacket = (DirPlacesQueryPacket)Pack;
14583 //m_log.Debug(dirPlacesQueryPacket.ToString());
14584
14585 #region Packet Session and User Check
14586 if (m_checkPackets)
14587 {
14588 if (dirPlacesQueryPacket.AgentData.SessionID != SessionId ||
14589 dirPlacesQueryPacket.AgentData.AgentID != AgentId)
14590 break;
14591 }
14592 #endregion
14593
14594 DirPlacesQuery handlerDirPlacesQuery = OnDirPlacesQuery;
14595 if (handlerDirPlacesQuery != null)
14596 {
14597 handlerDirPlacesQuery(this,
14598 dirPlacesQueryPacket.QueryData.QueryID,
14599 Utils.BytesToString(
14600 dirPlacesQueryPacket.QueryData.QueryText),
14601 (int)dirPlacesQueryPacket.QueryData.QueryFlags,
14602 (int)dirPlacesQueryPacket.QueryData.Category,
14603 Utils.BytesToString(
14604 dirPlacesQueryPacket.QueryData.SimName),
14605 dirPlacesQueryPacket.QueryData.QueryStart);
14606 }
14607 break;
14608
14609 case PacketType.DirFindQuery:
14610 DirFindQueryPacket dirFindQueryPacket = (DirFindQueryPacket)Pack;
14611
14612 #region Packet Session and User Check
14613 if (m_checkPackets)
14614 {
14615 if (dirFindQueryPacket.AgentData.SessionID != SessionId ||
14616 dirFindQueryPacket.AgentData.AgentID != AgentId)
14617 break;
14618 }
14619 #endregion
14620
14621 DirFindQuery handlerDirFindQuery = OnDirFindQuery;
14622 if (handlerDirFindQuery != null)
14623 {
14624 handlerDirFindQuery(this,
14625 dirFindQueryPacket.QueryData.QueryID,
14626 Utils.BytesToString(
14627 dirFindQueryPacket.QueryData.QueryText),
14628 dirFindQueryPacket.QueryData.QueryFlags,
14629 dirFindQueryPacket.QueryData.QueryStart);
14630 }
14631 break;
14632
14633 case PacketType.DirLandQuery:
14634 DirLandQueryPacket dirLandQueryPacket = (DirLandQueryPacket)Pack;
14635
14636 #region Packet Session and User Check
14637 if (m_checkPackets)
14638 {
14639 if (dirLandQueryPacket.AgentData.SessionID != SessionId ||
14640 dirLandQueryPacket.AgentData.AgentID != AgentId)
14641 break;
14642 }
14643 #endregion
14644
14645 DirLandQuery handlerDirLandQuery = OnDirLandQuery;
14646 if (handlerDirLandQuery != null)
14647 {
14648 handlerDirLandQuery(this,
14649 dirLandQueryPacket.QueryData.QueryID,
14650 dirLandQueryPacket.QueryData.QueryFlags,
14651 dirLandQueryPacket.QueryData.SearchType,
14652 dirLandQueryPacket.QueryData.Price,
14653 dirLandQueryPacket.QueryData.Area,
14654 dirLandQueryPacket.QueryData.QueryStart);
14655 }
14656 break;
14657
14658 case PacketType.DirPopularQuery:
14659 DirPopularQueryPacket dirPopularQueryPacket = (DirPopularQueryPacket)Pack;
14660
14661 #region Packet Session and User Check
14662 if (m_checkPackets)
14663 {
14664 if (dirPopularQueryPacket.AgentData.SessionID != SessionId ||
14665 dirPopularQueryPacket.AgentData.AgentID != AgentId)
14666 break;
14667 }
14668 #endregion
14669
14670 DirPopularQuery handlerDirPopularQuery = OnDirPopularQuery;
14671 if (handlerDirPopularQuery != null)
14672 {
14673 handlerDirPopularQuery(this,
14674 dirPopularQueryPacket.QueryData.QueryID,
14675 dirPopularQueryPacket.QueryData.QueryFlags);
14676 }
14677 break;
14678
14679 case PacketType.DirClassifiedQuery:
14680 DirClassifiedQueryPacket dirClassifiedQueryPacket = (DirClassifiedQueryPacket)Pack;
14681
14682 #region Packet Session and User Check
14683 if (m_checkPackets)
14684 {
14685 if (dirClassifiedQueryPacket.AgentData.SessionID != SessionId ||
14686 dirClassifiedQueryPacket.AgentData.AgentID != AgentId)
14687 break;
14688 }
14689 #endregion
14690
14691 DirClassifiedQuery handlerDirClassifiedQuery = OnDirClassifiedQuery;
14692 if (handlerDirClassifiedQuery != null)
14693 {
14694 handlerDirClassifiedQuery(this,
14695 dirClassifiedQueryPacket.QueryData.QueryID,
14696 Utils.BytesToString(
14697 dirClassifiedQueryPacket.QueryData.QueryText),
14698 dirClassifiedQueryPacket.QueryData.QueryFlags,
14699 dirClassifiedQueryPacket.QueryData.Category,
14700 dirClassifiedQueryPacket.QueryData.QueryStart);
14701 }
14702 break;
14703
14704 case PacketType.EventInfoRequest:
14705 EventInfoRequestPacket eventInfoRequestPacket = (EventInfoRequestPacket)Pack;
14706
14707 #region Packet Session and User Check
14708 if (m_checkPackets)
14709 {
14710 if (eventInfoRequestPacket.AgentData.SessionID != SessionId ||
14711 eventInfoRequestPacket.AgentData.AgentID != AgentId)
14712 break;
14713 }
14714 #endregion
14715
14716 if (OnEventInfoRequest != null)
14717 {
14718 OnEventInfoRequest(this, eventInfoRequestPacket.EventData.EventID);
14719 }
14720 break;
14721
14722 //#region Calling Card
14723
14724 case PacketType.OfferCallingCard:
14725 OfferCallingCardPacket offerCallingCardPacket = (OfferCallingCardPacket)Pack;
14726
14727 #region Packet Session and User Check
14728 if (m_checkPackets)
14729 {
14730 if (offerCallingCardPacket.AgentData.SessionID != SessionId ||
14731 offerCallingCardPacket.AgentData.AgentID != AgentId)
14732 break;
14733 }
14734 #endregion
14735
14736 if (OnOfferCallingCard != null)
14737 {
14738 OnOfferCallingCard(this,
14739 offerCallingCardPacket.AgentBlock.DestID,
14740 offerCallingCardPacket.AgentBlock.TransactionID);
14741 }
14742 break;
14743
14744 case PacketType.AcceptCallingCard:
14745 AcceptCallingCardPacket acceptCallingCardPacket = (AcceptCallingCardPacket)Pack;
14746
14747 #region Packet Session and User Check
14748 if (m_checkPackets)
14749 {
14750 if (acceptCallingCardPacket.AgentData.SessionID != SessionId ||
14751 acceptCallingCardPacket.AgentData.AgentID != AgentId)
14752 break;
14753 }
14754 #endregion
14755
14756 // according to http://wiki.secondlife.com/wiki/AcceptCallingCard FolderData should
14757 // contain exactly one entry
14758 if (OnAcceptCallingCard != null && acceptCallingCardPacket.FolderData.Length > 0)
14759 {
14760 OnAcceptCallingCard(this,
14761 acceptCallingCardPacket.TransactionBlock.TransactionID,
14762 acceptCallingCardPacket.FolderData[0].FolderID);
14763 }
14764 break;
14765
14766 case PacketType.DeclineCallingCard:
14767 DeclineCallingCardPacket declineCallingCardPacket = (DeclineCallingCardPacket)Pack;
14768
14769 #region Packet Session and User Check
14770 if (m_checkPackets)
14771 {
14772 if (declineCallingCardPacket.AgentData.SessionID != SessionId ||
14773 declineCallingCardPacket.AgentData.AgentID != AgentId)
14774 break;
14775 }
14776 #endregion
14777
14778 if (OnDeclineCallingCard != null)
14779 {
14780 OnDeclineCallingCard(this,
14781 declineCallingCardPacket.TransactionBlock.TransactionID);
14782 }
14783 break;
14784 //#endregion
14785
14786 //#region Groups
14787 case PacketType.ActivateGroup:
14788 ActivateGroupPacket activateGroupPacket = (ActivateGroupPacket)Pack;
14789
14790 #region Packet Session and User Check
14791 if (m_checkPackets)
14792 {
14793 if (activateGroupPacket.AgentData.SessionID != SessionId ||
14794 activateGroupPacket.AgentData.AgentID != AgentId)
14795 break;
14796 }
14797 #endregion
14798
14799 if (m_GroupsModule != null)
14800 {
14801 m_GroupsModule.ActivateGroup(this, activateGroupPacket.AgentData.GroupID);
14802 m_GroupsModule.SendAgentGroupDataUpdate(this);
14803 }
14804 break;
14805
14806
14807 case PacketType.GroupTitlesRequest:
14808 GroupTitlesRequestPacket groupTitlesRequest =
14809 (GroupTitlesRequestPacket)Pack;
14810
14811 #region Packet Session and User Check
14812 if (m_checkPackets)
14813 {
14814 if (groupTitlesRequest.AgentData.SessionID != SessionId ||
14815 groupTitlesRequest.AgentData.AgentID != AgentId)
14816 break;
14817 }
14818 #endregion
14819
14820 if (m_GroupsModule != null)
14821 {
14822 GroupTitlesReplyPacket groupTitlesReply = (GroupTitlesReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupTitlesReply);
14823
14824 groupTitlesReply.AgentData =
14825 new GroupTitlesReplyPacket.AgentDataBlock();
14826
14827 groupTitlesReply.AgentData.AgentID = AgentId;
14828 groupTitlesReply.AgentData.GroupID =
14829 groupTitlesRequest.AgentData.GroupID;
14830
14831 groupTitlesReply.AgentData.RequestID =
14832 groupTitlesRequest.AgentData.RequestID;
14833
14834 List<GroupTitlesData> titles =
14835 m_GroupsModule.GroupTitlesRequest(this,
14836 groupTitlesRequest.AgentData.GroupID);
14837
14838 groupTitlesReply.GroupData =
14839 new GroupTitlesReplyPacket.GroupDataBlock[titles.Count];
14840
14841 int i = 0;
14842 foreach (GroupTitlesData d in titles)
14843 {
14844 groupTitlesReply.GroupData[i] =
14845 new GroupTitlesReplyPacket.GroupDataBlock();
14846
14847 groupTitlesReply.GroupData[i].Title =
14848 Util.StringToBytes256(d.Name);
14849 groupTitlesReply.GroupData[i].RoleID =
14850 d.UUID;
14851 groupTitlesReply.GroupData[i].Selected =
14852 d.Selected;
14853 i++;
14854 }
14855
14856 OutPacket(groupTitlesReply, ThrottleOutPacketType.Task);
14857 }
14858 break;
14859
14860 case PacketType.GroupProfileRequest:
14861 GroupProfileRequestPacket groupProfileRequest =
14862 (GroupProfileRequestPacket)Pack;
14863
14864 #region Packet Session and User Check
14865 if (m_checkPackets)
14866 {
14867 if (groupProfileRequest.AgentData.SessionID != SessionId ||
14868 groupProfileRequest.AgentData.AgentID != AgentId)
14869 break;
14870 }
14871 #endregion
14872
14873 if (m_GroupsModule != null)
14874 {
14875 GroupProfileReplyPacket groupProfileReply = (GroupProfileReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupProfileReply);
14876
14877 groupProfileReply.AgentData = new GroupProfileReplyPacket.AgentDataBlock();
14878 groupProfileReply.GroupData = new GroupProfileReplyPacket.GroupDataBlock();
14879 groupProfileReply.AgentData.AgentID = AgentId;
14880
14881 GroupProfileData d = m_GroupsModule.GroupProfileRequest(this,
14882 groupProfileRequest.GroupData.GroupID);
14883
14884 groupProfileReply.GroupData.GroupID = d.GroupID;
14885 groupProfileReply.GroupData.Name = Util.StringToBytes256(d.Name);
14886 groupProfileReply.GroupData.Charter = Util.StringToBytes1024(d.Charter);
14887 groupProfileReply.GroupData.ShowInList = d.ShowInList;
14888 groupProfileReply.GroupData.MemberTitle = Util.StringToBytes256(d.MemberTitle);
14889 groupProfileReply.GroupData.PowersMask = d.PowersMask;
14890 groupProfileReply.GroupData.InsigniaID = d.InsigniaID;
14891 groupProfileReply.GroupData.FounderID = d.FounderID;
14892 groupProfileReply.GroupData.MembershipFee = d.MembershipFee;
14893 groupProfileReply.GroupData.OpenEnrollment = d.OpenEnrollment;
14894 groupProfileReply.GroupData.Money = d.Money;
14895 groupProfileReply.GroupData.GroupMembershipCount = d.GroupMembershipCount;
14896 groupProfileReply.GroupData.GroupRolesCount = d.GroupRolesCount;
14897 groupProfileReply.GroupData.AllowPublish = d.AllowPublish;
14898 groupProfileReply.GroupData.MaturePublish = d.MaturePublish;
14899 groupProfileReply.GroupData.OwnerRole = d.OwnerRole;
14900
14901 OutPacket(groupProfileReply, ThrottleOutPacketType.Task);
14902 }
14903 break;
14904
14905 case PacketType.GroupMembersRequest:
14906 GroupMembersRequestPacket groupMembersRequestPacket =
14907 (GroupMembersRequestPacket)Pack;
14908
14909 #region Packet Session and User Check
14910 if (m_checkPackets)
14911 {
14912 if (groupMembersRequestPacket.AgentData.SessionID != SessionId ||
14913 groupMembersRequestPacket.AgentData.AgentID != AgentId)
14914 break;
14915 }
14916 #endregion
14917
14918 if (m_GroupsModule != null)
14919 {
14920 List<GroupMembersData> members =
14921 m_GroupsModule.GroupMembersRequest(this, groupMembersRequestPacket.GroupData.GroupID);
14922
14923 int memberCount = members.Count;
14924
14925 while (true)
14926 {
14927 int blockCount = members.Count;
14928 if (blockCount > 40)
14929 blockCount = 40;
14930
14931 GroupMembersReplyPacket groupMembersReply = (GroupMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupMembersReply);
14932
14933 groupMembersReply.AgentData =
14934 new GroupMembersReplyPacket.AgentDataBlock();
14935 groupMembersReply.GroupData =
14936 new GroupMembersReplyPacket.GroupDataBlock();
14937 groupMembersReply.MemberData =
14938 new GroupMembersReplyPacket.MemberDataBlock[
14939 blockCount];
14940
14941 groupMembersReply.AgentData.AgentID = AgentId;
14942 groupMembersReply.GroupData.GroupID =
14943 groupMembersRequestPacket.GroupData.GroupID;
14944 groupMembersReply.GroupData.RequestID =
14945 groupMembersRequestPacket.GroupData.RequestID;
14946 groupMembersReply.GroupData.MemberCount = memberCount;
14947
14948 for (int i = 0; i < blockCount; i++)
14949 {
14950 GroupMembersData m = members[0];
14951 members.RemoveAt(0);
14952
14953 groupMembersReply.MemberData[i] =
14954 new GroupMembersReplyPacket.MemberDataBlock();
14955 groupMembersReply.MemberData[i].AgentID =
14956 m.AgentID;
14957 groupMembersReply.MemberData[i].Contribution =
14958 m.Contribution;
14959 groupMembersReply.MemberData[i].OnlineStatus =
14960 Util.StringToBytes256(m.OnlineStatus);
14961 groupMembersReply.MemberData[i].AgentPowers =
14962 m.AgentPowers;
14963 groupMembersReply.MemberData[i].Title =
14964 Util.StringToBytes256(m.Title);
14965 groupMembersReply.MemberData[i].IsOwner =
14966 m.IsOwner;
14967 }
14968 OutPacket(groupMembersReply, ThrottleOutPacketType.Task);
14969 if (members.Count == 0)
14970 break;
14971 }
14972 }
14973 break;
14974
14975 case PacketType.GroupRoleDataRequest:
14976 GroupRoleDataRequestPacket groupRolesRequest =
14977 (GroupRoleDataRequestPacket)Pack;
14978
14979 #region Packet Session and User Check
14980 if (m_checkPackets)
14981 {
14982 if (groupRolesRequest.AgentData.SessionID != SessionId ||
14983 groupRolesRequest.AgentData.AgentID != AgentId)
14984 break;
14985 }
14986 #endregion
14987
14988 if (m_GroupsModule != null)
14989 {
14990 GroupRoleDataReplyPacket groupRolesReply = (GroupRoleDataReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleDataReply);
14991
14992 groupRolesReply.AgentData =
14993 new GroupRoleDataReplyPacket.AgentDataBlock();
14994
14995 groupRolesReply.AgentData.AgentID = AgentId;
14996
14997 groupRolesReply.GroupData =
14998 new GroupRoleDataReplyPacket.GroupDataBlock();
14999
15000 groupRolesReply.GroupData.GroupID =
15001 groupRolesRequest.GroupData.GroupID;
15002
15003 groupRolesReply.GroupData.RequestID =
15004 groupRolesRequest.GroupData.RequestID;
15005
15006 List<GroupRolesData> titles =
15007 m_GroupsModule.GroupRoleDataRequest(this,
15008 groupRolesRequest.GroupData.GroupID);
15009
15010 groupRolesReply.GroupData.RoleCount =
15011 titles.Count;
15012
15013 groupRolesReply.RoleData =
15014 new GroupRoleDataReplyPacket.RoleDataBlock[titles.Count];
15015
15016 int i = 0;
15017 foreach (GroupRolesData d in titles)
15018 {
15019 groupRolesReply.RoleData[i] =
15020 new GroupRoleDataReplyPacket.RoleDataBlock();
15021
15022 groupRolesReply.RoleData[i].RoleID =
15023 d.RoleID;
15024 groupRolesReply.RoleData[i].Name =
15025 Util.StringToBytes256(d.Name);
15026 groupRolesReply.RoleData[i].Title =
15027 Util.StringToBytes256(d.Title);
15028 groupRolesReply.RoleData[i].Description =
15029 Util.StringToBytes1024(d.Description);
15030 groupRolesReply.RoleData[i].Powers =
15031 d.Powers;
15032 groupRolesReply.RoleData[i].Members =
15033 (uint)d.Members;
15034
15035 i++;
15036 }
15037
15038 OutPacket(groupRolesReply, ThrottleOutPacketType.Task);
15039 }
15040 break;
15041
15042 case PacketType.GroupRoleMembersRequest:
15043 GroupRoleMembersRequestPacket groupRoleMembersRequest =
15044 (GroupRoleMembersRequestPacket)Pack;
15045
15046 #region Packet Session and User Check
15047 if (m_checkPackets)
15048 {
15049 if (groupRoleMembersRequest.AgentData.SessionID != SessionId ||
15050 groupRoleMembersRequest.AgentData.AgentID != AgentId)
15051 break;
15052 }
15053 #endregion
15054
15055 if (m_GroupsModule != null)
15056 {
15057 List<GroupRoleMembersData> mappings =
15058 m_GroupsModule.GroupRoleMembersRequest(this,
15059 groupRoleMembersRequest.GroupData.GroupID);
15060
15061 int mappingsCount = mappings.Count;
15062
15063 while (mappings.Count > 0)
15064 {
15065 int pairs = mappings.Count;
15066 if (pairs > 32)
15067 pairs = 32;
15068
15069 GroupRoleMembersReplyPacket groupRoleMembersReply = (GroupRoleMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleMembersReply);
15070 groupRoleMembersReply.AgentData =
15071 new GroupRoleMembersReplyPacket.AgentDataBlock();
15072 groupRoleMembersReply.AgentData.AgentID =
15073 AgentId;
15074 groupRoleMembersReply.AgentData.GroupID =
15075 groupRoleMembersRequest.GroupData.GroupID;
15076 groupRoleMembersReply.AgentData.RequestID =
15077 groupRoleMembersRequest.GroupData.RequestID;
15078
15079 groupRoleMembersReply.AgentData.TotalPairs =
15080 (uint)mappingsCount;
15081
15082 groupRoleMembersReply.MemberData =
15083 new GroupRoleMembersReplyPacket.MemberDataBlock[pairs];
15084
15085 for (int i = 0; i < pairs; i++)
15086 {
15087 GroupRoleMembersData d = mappings[0];
15088 mappings.RemoveAt(0);
15089
15090 groupRoleMembersReply.MemberData[i] =
15091 new GroupRoleMembersReplyPacket.MemberDataBlock();
15092
15093 groupRoleMembersReply.MemberData[i].RoleID =
15094 d.RoleID;
15095 groupRoleMembersReply.MemberData[i].MemberID =
15096 d.MemberID;
15097 }
15098
15099 OutPacket(groupRoleMembersReply, ThrottleOutPacketType.Task);
15100 }
15101 }
15102 break;
15103
15104 case PacketType.CreateGroupRequest:
15105 CreateGroupRequestPacket createGroupRequest =
15106 (CreateGroupRequestPacket)Pack;
15107
15108 #region Packet Session and User Check
15109 if (m_checkPackets)
15110 {
15111 if (createGroupRequest.AgentData.SessionID != SessionId ||
15112 createGroupRequest.AgentData.AgentID != AgentId)
15113 break;
15114 }
15115 #endregion
15116
15117 if (m_GroupsModule != null)
15118 {
15119 m_GroupsModule.CreateGroup(this,
15120 Utils.BytesToString(createGroupRequest.GroupData.Name),
15121 Utils.BytesToString(createGroupRequest.GroupData.Charter),
15122 createGroupRequest.GroupData.ShowInList,
15123 createGroupRequest.GroupData.InsigniaID,
15124 createGroupRequest.GroupData.MembershipFee,
15125 createGroupRequest.GroupData.OpenEnrollment,
15126 createGroupRequest.GroupData.AllowPublish,
15127 createGroupRequest.GroupData.MaturePublish);
15128 }
15129 break;
15130
15131 case PacketType.UpdateGroupInfo:
15132 UpdateGroupInfoPacket updateGroupInfo =
15133 (UpdateGroupInfoPacket)Pack;
15134
15135 #region Packet Session and User Check
15136 if (m_checkPackets)
15137 {
15138 if (updateGroupInfo.AgentData.SessionID != SessionId ||
15139 updateGroupInfo.AgentData.AgentID != AgentId)
15140 break;
15141 }
15142 #endregion
15143
15144 if (m_GroupsModule != null)
15145 {
15146 m_GroupsModule.UpdateGroupInfo(this,
15147 updateGroupInfo.GroupData.GroupID,
15148 Utils.BytesToString(updateGroupInfo.GroupData.Charter),
15149 updateGroupInfo.GroupData.ShowInList,
15150 updateGroupInfo.GroupData.InsigniaID,
15151 updateGroupInfo.GroupData.MembershipFee,
15152 updateGroupInfo.GroupData.OpenEnrollment,
15153 updateGroupInfo.GroupData.AllowPublish,
15154 updateGroupInfo.GroupData.MaturePublish);
15155 }
15156
15157 break;
15158
15159 case PacketType.SetGroupAcceptNotices:
15160 SetGroupAcceptNoticesPacket setGroupAcceptNotices =
15161 (SetGroupAcceptNoticesPacket)Pack;
15162
15163 #region Packet Session and User Check
15164 if (m_checkPackets)
15165 {
15166 if (setGroupAcceptNotices.AgentData.SessionID != SessionId ||
15167 setGroupAcceptNotices.AgentData.AgentID != AgentId)
15168 break;
15169 }
15170 #endregion
15171
15172 if (m_GroupsModule != null)
15173 {
15174 m_GroupsModule.SetGroupAcceptNotices(this,
15175 setGroupAcceptNotices.Data.GroupID,
15176 setGroupAcceptNotices.Data.AcceptNotices,
15177 setGroupAcceptNotices.NewData.ListInProfile);
15178 }
15179
15180 break;
15181
15182 case PacketType.GroupTitleUpdate:
15183 GroupTitleUpdatePacket groupTitleUpdate =
15184 (GroupTitleUpdatePacket)Pack;
15185
15186 #region Packet Session and User Check
15187 if (m_checkPackets)
15188 {
15189 if (groupTitleUpdate.AgentData.SessionID != SessionId ||
15190 groupTitleUpdate.AgentData.AgentID != AgentId)
15191 break;
15192 }
15193 #endregion
15194
15195 if (m_GroupsModule != null)
15196 {
15197 m_GroupsModule.GroupTitleUpdate(this,
15198 groupTitleUpdate.AgentData.GroupID,
15199 groupTitleUpdate.AgentData.TitleRoleID);
15200 }
15201
15202 break;
15203
15204
15205 case PacketType.ParcelDeedToGroup:
15206 ParcelDeedToGroupPacket parcelDeedToGroup = (ParcelDeedToGroupPacket)Pack;
15207 if (m_GroupsModule != null)
15208 {
15209 ParcelDeedToGroup handlerParcelDeedToGroup = OnParcelDeedToGroup;
15210 if (handlerParcelDeedToGroup != null)
15211 {
15212 handlerParcelDeedToGroup(parcelDeedToGroup.Data.LocalID, parcelDeedToGroup.Data.GroupID, this);
15213
15214 }
15215 }
15216
15217 break;
15218
15219
15220 case PacketType.GroupNoticesListRequest:
15221 GroupNoticesListRequestPacket groupNoticesListRequest =
15222 (GroupNoticesListRequestPacket)Pack;
15223
15224 #region Packet Session and User Check
15225 if (m_checkPackets)
15226 {
15227 if (groupNoticesListRequest.AgentData.SessionID != SessionId ||
15228 groupNoticesListRequest.AgentData.AgentID != AgentId)
15229 break;
15230 }
15231 #endregion
15232
15233 if (m_GroupsModule != null)
15234 {
15235 GroupNoticeData[] gn =
15236 m_GroupsModule.GroupNoticesListRequest(this,
15237 groupNoticesListRequest.Data.GroupID);
15238
15239 GroupNoticesListReplyPacket groupNoticesListReply = (GroupNoticesListReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupNoticesListReply);
15240 groupNoticesListReply.AgentData =
15241 new GroupNoticesListReplyPacket.AgentDataBlock();
15242 groupNoticesListReply.AgentData.AgentID = AgentId;
15243 groupNoticesListReply.AgentData.GroupID = groupNoticesListRequest.Data.GroupID;
15244
15245 groupNoticesListReply.Data = new GroupNoticesListReplyPacket.DataBlock[gn.Length];
15246
15247 int i = 0;
15248 foreach (GroupNoticeData g in gn)
15249 {
15250 groupNoticesListReply.Data[i] = new GroupNoticesListReplyPacket.DataBlock();
15251 groupNoticesListReply.Data[i].NoticeID =
15252 g.NoticeID;
15253 groupNoticesListReply.Data[i].Timestamp =
15254 g.Timestamp;
15255 groupNoticesListReply.Data[i].FromName =
15256 Util.StringToBytes256(g.FromName);
15257 groupNoticesListReply.Data[i].Subject =
15258 Util.StringToBytes256(g.Subject);
15259 groupNoticesListReply.Data[i].HasAttachment =
15260 g.HasAttachment;
15261 groupNoticesListReply.Data[i].AssetType =
15262 g.AssetType;
15263 i++;
15264 }
15265
15266 OutPacket(groupNoticesListReply, ThrottleOutPacketType.Task);
15267 }
15268
15269 break;
15270
15271 case PacketType.GroupNoticeRequest:
15272 GroupNoticeRequestPacket groupNoticeRequest =
15273 (GroupNoticeRequestPacket)Pack;
15274
15275 #region Packet Session and User Check
15276 if (m_checkPackets)
15277 {
15278 if (groupNoticeRequest.AgentData.SessionID != SessionId ||
15279 groupNoticeRequest.AgentData.AgentID != AgentId)
15280 break;
15281 }
15282 #endregion
15283
15284 if (m_GroupsModule != null)
15285 {
15286 m_GroupsModule.GroupNoticeRequest(this,
15287 groupNoticeRequest.Data.GroupNoticeID);
15288 }
15289 break;
15290
15291 case PacketType.GroupRoleUpdate:
15292 GroupRoleUpdatePacket groupRoleUpdate =
15293 (GroupRoleUpdatePacket)Pack;
15294
15295 #region Packet Session and User Check
15296 if (m_checkPackets)
15297 {
15298 if (groupRoleUpdate.AgentData.SessionID != SessionId ||
15299 groupRoleUpdate.AgentData.AgentID != AgentId)
15300 break;
15301 }
15302 #endregion
15303
15304 if (m_GroupsModule != null)
15305 {
15306 foreach (GroupRoleUpdatePacket.RoleDataBlock d in
15307 groupRoleUpdate.RoleData)
15308 {
15309 m_GroupsModule.GroupRoleUpdate(this,
15310 groupRoleUpdate.AgentData.GroupID,
15311 d.RoleID,
15312 Utils.BytesToString(d.Name),
15313 Utils.BytesToString(d.Description),
15314 Utils.BytesToString(d.Title),
15315 d.Powers,
15316 d.UpdateType);
15317 }
15318 m_GroupsModule.NotifyChange(groupRoleUpdate.AgentData.GroupID);
15319 }
15320 break;
15321
15322 case PacketType.GroupRoleChanges:
15323 GroupRoleChangesPacket groupRoleChanges =
15324 (GroupRoleChangesPacket)Pack;
15325
15326 #region Packet Session and User Check
15327 if (m_checkPackets)
15328 {
15329 if (groupRoleChanges.AgentData.SessionID != SessionId ||
15330 groupRoleChanges.AgentData.AgentID != AgentId)
15331 break;
15332 }
15333 #endregion
15334
15335 if (m_GroupsModule != null)
15336 {
15337 foreach (GroupRoleChangesPacket.RoleChangeBlock d in
15338 groupRoleChanges.RoleChange)
15339 {
15340 m_GroupsModule.GroupRoleChanges(this,
15341 groupRoleChanges.AgentData.GroupID,
15342 d.RoleID,
15343 d.MemberID,
15344 d.Change);
15345 }
15346 m_GroupsModule.NotifyChange(groupRoleChanges.AgentData.GroupID);
15347 }
15348 break;
15349
15350 case PacketType.JoinGroupRequest:
15351 JoinGroupRequestPacket joinGroupRequest =
15352 (JoinGroupRequestPacket)Pack;
15353
15354 #region Packet Session and User Check
15355 if (m_checkPackets)
15356 {
15357 if (joinGroupRequest.AgentData.SessionID != SessionId ||
15358 joinGroupRequest.AgentData.AgentID != AgentId)
15359 break;
15360 }
15361 #endregion
15362
15363 if (m_GroupsModule != null)
15364 {
15365 m_GroupsModule.JoinGroupRequest(this,
15366 joinGroupRequest.GroupData.GroupID);
15367 }
15368 break;
15369
15370 case PacketType.LeaveGroupRequest:
15371 LeaveGroupRequestPacket leaveGroupRequest =
15372 (LeaveGroupRequestPacket)Pack;
15373
15374 #region Packet Session and User Check
15375 if (m_checkPackets)
15376 {
15377 if (leaveGroupRequest.AgentData.SessionID != SessionId ||
15378 leaveGroupRequest.AgentData.AgentID != AgentId)
15379 break;
15380 }
15381 #endregion
15382
15383 if (m_GroupsModule != null)
15384 {
15385 m_GroupsModule.LeaveGroupRequest(this,
15386 leaveGroupRequest.GroupData.GroupID);
15387 }
15388 break;
15389
15390 case PacketType.EjectGroupMemberRequest:
15391 EjectGroupMemberRequestPacket ejectGroupMemberRequest =
15392 (EjectGroupMemberRequestPacket)Pack;
15393
15394 #region Packet Session and User Check
15395 if (m_checkPackets)
15396 {
15397 if (ejectGroupMemberRequest.AgentData.SessionID != SessionId ||
15398 ejectGroupMemberRequest.AgentData.AgentID != AgentId)
15399 break;
15400 }
15401 #endregion
15402
15403 if (m_GroupsModule != null)
15404 {
15405 foreach (EjectGroupMemberRequestPacket.EjectDataBlock e
15406 in ejectGroupMemberRequest.EjectData)
15407 {
15408 m_GroupsModule.EjectGroupMemberRequest(this,
15409 ejectGroupMemberRequest.GroupData.GroupID,
15410 e.EjecteeID);
15411 }
15412 }
15413 break;
15414
15415 case PacketType.InviteGroupRequest:
15416 InviteGroupRequestPacket inviteGroupRequest =
15417 (InviteGroupRequestPacket)Pack;
15418
15419 #region Packet Session and User Check
15420 if (m_checkPackets)
15421 {
15422 if (inviteGroupRequest.AgentData.SessionID != SessionId ||
15423 inviteGroupRequest.AgentData.AgentID != AgentId)
15424 break;
15425 }
15426 #endregion
15427
15428 if (m_GroupsModule != null)
15429 {
15430 foreach (InviteGroupRequestPacket.InviteDataBlock b in
15431 inviteGroupRequest.InviteData)
15432 {
15433 m_GroupsModule.InviteGroupRequest(this,
15434 inviteGroupRequest.GroupData.GroupID,
15435 b.InviteeID,
15436 b.RoleID);
15437 }
15438 }
15439 break;
15440
15441 //#endregion
15442
15443 case PacketType.StartLure:
15444 StartLurePacket startLureRequest = (StartLurePacket)Pack;
15445
15446 #region Packet Session and User Check
15447 if (m_checkPackets)
15448 {
15449 if (startLureRequest.AgentData.SessionID != SessionId ||
15450 startLureRequest.AgentData.AgentID != AgentId)
15451 break;
15452 }
15453 #endregion
15454
15455 StartLure handlerStartLure = OnStartLure;
15456 if (handlerStartLure != null)
15457 handlerStartLure(startLureRequest.Info.LureType,
15458 Utils.BytesToString(
15459 startLureRequest.Info.Message),
15460 startLureRequest.TargetData[0].TargetID,
15461 this);
15462 break;
15463
15464 case PacketType.TeleportLureRequest:
15465 TeleportLureRequestPacket teleportLureRequest =
15466 (TeleportLureRequestPacket)Pack;
15467
15468 #region Packet Session and User Check
15469 if (m_checkPackets)
15470 {
15471 if (teleportLureRequest.Info.SessionID != SessionId ||
15472 teleportLureRequest.Info.AgentID != AgentId)
15473 break;
15474 }
15475 #endregion
15476
15477 TeleportLureRequest handlerTeleportLureRequest = OnTeleportLureRequest;
15478 if (handlerTeleportLureRequest != null)
15479 handlerTeleportLureRequest(
15480 teleportLureRequest.Info.LureID,
15481 teleportLureRequest.Info.TeleportFlags,
15482 this);
15483 break;
15484
15485 case PacketType.ClassifiedInfoRequest:
15486 ClassifiedInfoRequestPacket classifiedInfoRequest =
15487 (ClassifiedInfoRequestPacket)Pack;
15488
15489 #region Packet Session and User Check
15490 if (m_checkPackets)
15491 {
15492 if (classifiedInfoRequest.AgentData.SessionID != SessionId ||
15493 classifiedInfoRequest.AgentData.AgentID != AgentId)
15494 break;
15495 }
15496 #endregion
15497
15498 ClassifiedInfoRequest handlerClassifiedInfoRequest = OnClassifiedInfoRequest;
15499 if (handlerClassifiedInfoRequest != null)
15500 handlerClassifiedInfoRequest(
15501 classifiedInfoRequest.Data.ClassifiedID,
15502 this);
15503 break;
15504
15505 case PacketType.ClassifiedInfoUpdate:
15506 ClassifiedInfoUpdatePacket classifiedInfoUpdate =
15507 (ClassifiedInfoUpdatePacket)Pack;
15508
15509 #region Packet Session and User Check
15510 if (m_checkPackets)
15511 {
15512 if (classifiedInfoUpdate.AgentData.SessionID != SessionId ||
15513 classifiedInfoUpdate.AgentData.AgentID != AgentId)
15514 break;
15515 }
15516 #endregion
15517
15518 ClassifiedInfoUpdate handlerClassifiedInfoUpdate = OnClassifiedInfoUpdate;
15519 if (handlerClassifiedInfoUpdate != null)
15520 handlerClassifiedInfoUpdate(
15521 classifiedInfoUpdate.Data.ClassifiedID,
15522 classifiedInfoUpdate.Data.Category,
15523 Utils.BytesToString(
15524 classifiedInfoUpdate.Data.Name),
15525 Utils.BytesToString(
15526 classifiedInfoUpdate.Data.Desc),
15527 classifiedInfoUpdate.Data.ParcelID,
15528 classifiedInfoUpdate.Data.ParentEstate,
15529 classifiedInfoUpdate.Data.SnapshotID,
15530 new Vector3(
15531 classifiedInfoUpdate.Data.PosGlobal),
15532 classifiedInfoUpdate.Data.ClassifiedFlags,
15533 classifiedInfoUpdate.Data.PriceForListing,
15534 this);
15535 break;
15536
15537 case PacketType.ClassifiedDelete:
15538 ClassifiedDeletePacket classifiedDelete =
15539 (ClassifiedDeletePacket)Pack;
15540
15541 #region Packet Session and User Check
15542 if (m_checkPackets)
15543 {
15544 if (classifiedDelete.AgentData.SessionID != SessionId ||
15545 classifiedDelete.AgentData.AgentID != AgentId)
15546 break;
15547 }
15548 #endregion
15549
15550 ClassifiedDelete handlerClassifiedDelete = OnClassifiedDelete;
15551 if (handlerClassifiedDelete != null)
15552 handlerClassifiedDelete(
15553 classifiedDelete.Data.ClassifiedID,
15554 this);
15555 break;
15556
15557 case PacketType.ClassifiedGodDelete:
15558 ClassifiedGodDeletePacket classifiedGodDelete =
15559 (ClassifiedGodDeletePacket)Pack;
15560
15561 #region Packet Session and User Check
15562 if (m_checkPackets)
15563 {
15564 if (classifiedGodDelete.AgentData.SessionID != SessionId ||
15565 classifiedGodDelete.AgentData.AgentID != AgentId)
15566 break;
15567 }
15568 #endregion
15569
15570 ClassifiedDelete handlerClassifiedGodDelete = OnClassifiedGodDelete;
15571 if (handlerClassifiedGodDelete != null)
15572 handlerClassifiedGodDelete(
15573 classifiedGodDelete.Data.ClassifiedID,
15574 this);
15575 break;
15576
15577 case PacketType.EventGodDelete:
15578 EventGodDeletePacket eventGodDelete =
15579 (EventGodDeletePacket)Pack;
15580
15581 #region Packet Session and User Check
15582 if (m_checkPackets)
15583 {
15584 if (eventGodDelete.AgentData.SessionID != SessionId ||
15585 eventGodDelete.AgentData.AgentID != AgentId)
15586 break;
15587 }
15588 #endregion
15589
15590 EventGodDelete handlerEventGodDelete = OnEventGodDelete;
15591 if (handlerEventGodDelete != null)
15592 handlerEventGodDelete(
15593 eventGodDelete.EventData.EventID,
15594 eventGodDelete.QueryData.QueryID,
15595 Utils.BytesToString(
15596 eventGodDelete.QueryData.QueryText),
15597 eventGodDelete.QueryData.QueryFlags,
15598 eventGodDelete.QueryData.QueryStart,
15599 this);
15600 break;
15601
15602 case PacketType.EventNotificationAddRequest:
15603 EventNotificationAddRequestPacket eventNotificationAdd =
15604 (EventNotificationAddRequestPacket)Pack;
15605
15606 #region Packet Session and User Check
15607 if (m_checkPackets)
15608 {
15609 if (eventNotificationAdd.AgentData.SessionID != SessionId ||
15610 eventNotificationAdd.AgentData.AgentID != AgentId)
15611 break;
15612 }
15613 #endregion
15614
15615 EventNotificationAddRequest handlerEventNotificationAddRequest = OnEventNotificationAddRequest;
15616 if (handlerEventNotificationAddRequest != null)
15617 handlerEventNotificationAddRequest(
15618 eventNotificationAdd.EventData.EventID, this);
15619 break;
15620
15621 case PacketType.EventNotificationRemoveRequest:
15622 EventNotificationRemoveRequestPacket eventNotificationRemove =
15623 (EventNotificationRemoveRequestPacket)Pack;
15624
15625 #region Packet Session and User Check
15626 if (m_checkPackets)
15627 {
15628 if (eventNotificationRemove.AgentData.SessionID != SessionId ||
15629 eventNotificationRemove.AgentData.AgentID != AgentId)
15630 break;
15631 }
15632 #endregion
15633
15634 EventNotificationRemoveRequest handlerEventNotificationRemoveRequest = OnEventNotificationRemoveRequest;
15635 if (handlerEventNotificationRemoveRequest != null)
15636 handlerEventNotificationRemoveRequest(
15637 eventNotificationRemove.EventData.EventID, this);
15638 break;
15639
15640 case PacketType.RetrieveInstantMessages:
15641 RetrieveInstantMessagesPacket rimpInstantMessagePack = (RetrieveInstantMessagesPacket)Pack;
15642
15643 #region Packet Session and User Check
15644 if (m_checkPackets)
15645 {
15646 if (rimpInstantMessagePack.AgentData.SessionID != SessionId ||
15647 rimpInstantMessagePack.AgentData.AgentID != AgentId)
15648 break;
15649 }
15650 #endregion
15651
15652 RetrieveInstantMessages handlerRetrieveInstantMessages = OnRetrieveInstantMessages;
15653 if (handlerRetrieveInstantMessages != null)
15654 handlerRetrieveInstantMessages(this);
15655 break;
15656
15657 case PacketType.PickDelete:
15658 PickDeletePacket pickDelete =
15659 (PickDeletePacket)Pack;
15660
15661 #region Packet Session and User Check
15662 if (m_checkPackets)
15663 {
15664 if (pickDelete.AgentData.SessionID != SessionId ||
15665 pickDelete.AgentData.AgentID != AgentId)
15666 break;
15667 }
15668 #endregion
15669
15670 PickDelete handlerPickDelete = OnPickDelete;
15671 if (handlerPickDelete != null)
15672 handlerPickDelete(this, pickDelete.Data.PickID);
15673 break;
15674
15675 case PacketType.PickGodDelete:
15676 PickGodDeletePacket pickGodDelete =
15677 (PickGodDeletePacket)Pack;
15678
15679 #region Packet Session and User Check
15680 if (m_checkPackets)
15681 {
15682 if (pickGodDelete.AgentData.SessionID != SessionId ||
15683 pickGodDelete.AgentData.AgentID != AgentId)
15684 break;
15685 }
15686 #endregion
15687
15688 PickGodDelete handlerPickGodDelete = OnPickGodDelete;
15689 if (handlerPickGodDelete != null)
15690 handlerPickGodDelete(this,
15691 pickGodDelete.AgentData.AgentID,
15692 pickGodDelete.Data.PickID,
15693 pickGodDelete.Data.QueryID);
15694 break;
15695
15696 case PacketType.PickInfoUpdate:
15697 PickInfoUpdatePacket pickInfoUpdate =
15698 (PickInfoUpdatePacket)Pack;
15699
15700 #region Packet Session and User Check
15701 if (m_checkPackets)
15702 {
15703 if (pickInfoUpdate.AgentData.SessionID != SessionId ||
15704 pickInfoUpdate.AgentData.AgentID != AgentId)
15705 break;
15706 }
15707 #endregion
15708
15709 PickInfoUpdate handlerPickInfoUpdate = OnPickInfoUpdate;
15710 if (handlerPickInfoUpdate != null)
15711 handlerPickInfoUpdate(this,
15712 pickInfoUpdate.Data.PickID,
15713 pickInfoUpdate.Data.CreatorID,
15714 pickInfoUpdate.Data.TopPick,
15715 Utils.BytesToString(pickInfoUpdate.Data.Name),
15716 Utils.BytesToString(pickInfoUpdate.Data.Desc),
15717 pickInfoUpdate.Data.SnapshotID,
15718 pickInfoUpdate.Data.SortOrder,
15719 pickInfoUpdate.Data.Enabled);
15720 break;
15721
15722 case PacketType.AvatarNotesUpdate:
15723 AvatarNotesUpdatePacket avatarNotesUpdate =
15724 (AvatarNotesUpdatePacket)Pack;
15725
15726 #region Packet Session and User Check
15727 if (m_checkPackets)
15728 {
15729 if (avatarNotesUpdate.AgentData.SessionID != SessionId ||
15730 avatarNotesUpdate.AgentData.AgentID != AgentId)
15731 break;
15732 }
15733 #endregion
15734
15735 AvatarNotesUpdate handlerAvatarNotesUpdate = OnAvatarNotesUpdate;
15736 if (handlerAvatarNotesUpdate != null)
15737 handlerAvatarNotesUpdate(this,
15738 avatarNotesUpdate.Data.TargetID,
15739 Utils.BytesToString(avatarNotesUpdate.Data.Notes));
15740 break;
15741
15742 case PacketType.AvatarInterestsUpdate:
15743 AvatarInterestsUpdatePacket avatarInterestUpdate =
15744 (AvatarInterestsUpdatePacket)Pack;
15745
15746 #region Packet Session and User Check
15747 if (m_checkPackets)
15748 {
15749 if (avatarInterestUpdate.AgentData.SessionID != SessionId ||
15750 avatarInterestUpdate.AgentData.AgentID != AgentId)
15751 break;
15752 }
15753 #endregion
15754 11027
15755 AvatarInterestUpdate handlerAvatarInterestUpdate = OnAvatarInterestUpdate; 11028 if (!ProcessPacketMethod(Pack))
15756 if (handlerAvatarInterestUpdate != null) 11029 m_log.Warn("[CLIENT]: unhandled packet " + Pack);
15757 handlerAvatarInterestUpdate(this,
15758 avatarInterestUpdate.PropertiesData.WantToMask,
15759 Utils.BytesToString(avatarInterestUpdate.PropertiesData.WantToText),
15760 avatarInterestUpdate.PropertiesData.SkillsMask,
15761 Utils.BytesToString(avatarInterestUpdate.PropertiesData.SkillsText),
15762 Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText));
15763 break;
15764
15765 case PacketType.GrantUserRights:
15766 GrantUserRightsPacket GrantUserRights =
15767 (GrantUserRightsPacket)Pack;
15768 #region Packet Session and User Check
15769 if (m_checkPackets)
15770 {
15771 if (GrantUserRights.AgentData.SessionID != SessionId ||
15772 GrantUserRights.AgentData.AgentID != AgentId)
15773 break;
15774 }
15775 #endregion
15776 GrantUserFriendRights GrantUserRightsHandler = OnGrantUserRights;
15777 if (GrantUserRightsHandler != null)
15778 GrantUserRightsHandler(this,
15779 GrantUserRights.AgentData.AgentID,
15780 GrantUserRights.Rights[0].AgentRelated,
15781 GrantUserRights.Rights[0].RelatedRights);
15782 break;
15783
15784 case PacketType.PlacesQuery:
15785 PlacesQueryPacket placesQueryPacket =
15786 (PlacesQueryPacket)Pack;
15787
15788 PlacesQuery handlerPlacesQuery = OnPlacesQuery;
15789
15790 if (handlerPlacesQuery != null)
15791 handlerPlacesQuery(placesQueryPacket.AgentData.QueryID,
15792 placesQueryPacket.TransactionData.TransactionID,
15793 Utils.BytesToString(
15794 placesQueryPacket.QueryData.QueryText),
15795 placesQueryPacket.QueryData.QueryFlags,
15796 (byte)placesQueryPacket.QueryData.Category,
15797 Utils.BytesToString(
15798 placesQueryPacket.QueryData.SimName),
15799 this);
15800 break;
15801 */
15802 #endregion
15803 default:
15804 m_log.Warn("[CLIENT]: unhandled packet " + Pack);
15805 break;
15806 }
15807 11030
15808 PacketPool.Instance.ReturnPacket(Pack); 11031 PacketPool.Instance.ReturnPacket(Pack);
15809
15810 } 11032 }
15811 11033
15812 private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket) 11034 private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket)
@@ -16122,6 +11344,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
16122 const uint m_maxPacketSize = 600; 11344 const uint m_maxPacketSize = 600;
16123 int numPackets = 1; 11345 int numPackets = 1;
16124 11346
11347 if (data == null)
11348 return 0;
11349
16125 if (data.LongLength > m_maxPacketSize) 11350 if (data.LongLength > m_maxPacketSize)
16126 { 11351 {
16127 // over max number of bytes so split up file 11352 // over max number of bytes so split up file
@@ -16367,5 +11592,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
16367 packet.PropertiesData.LanguagesText = Utils.StringToBytes(languages); 11592 packet.PropertiesData.LanguagesText = Utils.StringToBytes(languages);
16368 OutPacket(packet, ThrottleOutPacketType.Task); 11593 OutPacket(packet, ThrottleOutPacketType.Task);
16369 } 11594 }
11595
11596 public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
11597 {
11598 ChangeUserRightsPacket packet = (ChangeUserRightsPacket)PacketPool.Instance.GetPacket(PacketType.ChangeUserRights);
11599
11600 packet.AgentData = new ChangeUserRightsPacket.AgentDataBlock();
11601 packet.AgentData.AgentID = agentID;
11602
11603 packet.Rights = new ChangeUserRightsPacket.RightsBlock[1];
11604 packet.Rights[0] = new ChangeUserRightsPacket.RightsBlock();
11605 packet.Rights[0].AgentRelated = friendID;
11606 packet.Rights[0].RelatedRights = rights;
11607
11608 OutPacket(packet, ThrottleOutPacketType.Task);
11609 }
16370 } 11610 }
16371} 11611}
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs
index adf171e..10e5a95 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs
@@ -197,7 +197,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
197 197
198 private void Initialise(UUID fileID, string fileName) 198 private void Initialise(UUID fileID, string fileName)
199 { 199 {
200 m_asset = new AssetBase(fileID, fileName, type); 200 m_asset = new AssetBase(fileID, fileName, type, UUID.Zero.ToString());
201 m_asset.Data = new byte[0]; 201 m_asset.Data = new byte[0];
202 m_asset.Description = "empty"; 202 m_asset.Description = "empty";
203 m_asset.Local = true; 203 m_asset.Local = true;
@@ -212,6 +212,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
212 212
213 public void RequestStartXfer(IClientAPI pRemoteClient) 213 public void RequestStartXfer(IClientAPI pRemoteClient)
214 { 214 {
215 m_asset.Metadata.CreatorID = pRemoteClient.AgentId.ToString();
216
215 if (!String.IsNullOrEmpty(m_asset.Name)) 217 if (!String.IsNullOrEmpty(m_asset.Name))
216 { 218 {
217 pRemoteClient.SendXferRequest(mXferID, m_asset.Type, m_asset.FullID, 0, Utils.StringToBytes(m_asset.Name)); 219 pRemoteClient.SendXferRequest(mXferID, m_asset.Type, m_asset.FullID, 0, Utils.StringToBytes(m_asset.Name));
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 3c4fa72..36d24e8 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -596,15 +596,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
596 } 596 }
597 catch (MalformedDataException) 597 catch (MalformedDataException)
598 { 598 {
599 m_log.ErrorFormat("[LLUDPSERVER]: Malformed data, cannot parse packet from {0}:\n{1}",
600 buffer.RemoteEndPoint, Utils.BytesToHexString(buffer.Data, buffer.DataLength, null));
601 } 599 }
602 600
603 // Fail-safe check 601 // Fail-safe check
604 if (packet == null) 602 if (packet == null)
605 { 603 {
606 m_log.Warn("[LLUDPSERVER]: Couldn't build a message from incoming data " + buffer.DataLength + 604 m_log.ErrorFormat("[LLUDPSERVER]: Malformed data, cannot parse {0} byte packet from {1}:",
607 " bytes long from " + buffer.RemoteEndPoint); 605 buffer.DataLength, buffer.RemoteEndPoint);
606 m_log.Error(Utils.BytesToHexString(buffer.Data, buffer.DataLength, null));
608 return; 607 return;
609 } 608 }
610 609
@@ -919,7 +918,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
919 // Remove this client from the scene 918 // Remove this client from the scene
920 IClientAPI client; 919 IClientAPI client;
921 if (m_scene.TryGetClient(udpClient.AgentID, out client)) 920 if (m_scene.TryGetClient(udpClient.AgentID, out client))
921 {
922 client.IsLoggingOut = true;
922 client.Close(); 923 client.Close();
924 }
923 } 925 }
924 926
925 private void IncomingPacketHandler() 927 private void IncomingPacketHandler()
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
index c7aeca14..0ec87e5 100644
--- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs
+++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
@@ -56,13 +56,6 @@ namespace OpenSim.Region.ClientStack
56 56
57 protected uint m_httpServerPort; 57 protected uint m_httpServerPort;
58 58
59 public CommunicationsManager CommunicationsManager
60 {
61 get { return m_commsManager; }
62 set { m_commsManager = value; }
63 }
64 protected CommunicationsManager m_commsManager;
65
66 protected StorageManager m_storageManager; 59 protected StorageManager m_storageManager;
67 60
68 protected ClientStackManager m_clientStackManager; 61 protected ClientStackManager m_clientStackManager;
@@ -111,6 +104,8 @@ namespace OpenSim.Region.ClientStack
111 m_log.Info("[REGION]: Starting HTTP server"); 104 m_log.Info("[REGION]: Starting HTTP server");
112 m_httpServer.Start(); 105 m_httpServer.Start();
113 106
107 MainServer.Instance = m_httpServer;
108
114 base.StartupSpecific(); 109 base.StartupSpecific();
115 } 110 }
116 111
diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs
deleted file mode 100644
index e80f6ab..0000000
--- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs
+++ /dev/null
@@ -1,60 +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.Reflection;
29using log4net;
30using OpenSim.Data;
31using OpenSim.Framework;
32using OpenSim.Framework.Communications;
33using OpenSim.Framework.Communications.Cache;
34using OpenSim.Framework.Servers;
35using OpenSim.Framework.Servers.HttpServer;
36using OpenSim.Region.Communications.OGS1;
37using OpenSim.Region.Framework.Scenes;
38
39namespace OpenSim.Region.Communications.Hypergrid
40{
41 public class HGCommunicationsGridMode : CommunicationsManager // CommunicationsOGS1
42 {
43
44 public HGCommunicationsGridMode(
45 NetworkServersInfo serversInfo,
46 SceneManager sman, LibraryRootFolder libraryRootFolder)
47 : base(serversInfo, libraryRootFolder)
48 {
49
50 HGUserServices userServices = new HGUserServices(this);
51 // This plugin arrangement could eventually be configurable rather than hardcoded here.
52 userServices.AddPlugin(new TemporaryUserProfilePlugin());
53 userServices.AddPlugin(new HGUserDataPlugin(this, userServices));
54
55 m_userService = userServices;
56 m_messageService = userServices;
57 m_avatarService = userServices;
58 }
59 }
60}
diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs
deleted file mode 100644
index 4e3f5a1..0000000
--- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs
+++ /dev/null
@@ -1,68 +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.Data;
30using OpenSim.Framework;
31using OpenSim.Framework.Communications;
32using OpenSim.Framework.Communications.Cache;
33using OpenSim.Framework.Communications.Osp;
34using OpenSim.Framework.Servers;
35using OpenSim.Framework.Servers.HttpServer;
36using OpenSim.Region.Communications.Local;
37using OpenSim.Region.Communications.OGS1;
38
39namespace OpenSim.Region.Communications.Hypergrid
40{
41 public class HGCommunicationsStandalone : CommunicationsManager
42 {
43 public HGCommunicationsStandalone(
44 ConfigSettings configSettings,
45 NetworkServersInfo serversInfo,
46 BaseHttpServer httpServer,
47 LibraryRootFolder libraryRootFolder,
48 bool dumpAssetsToFile)
49 : base(serversInfo, libraryRootFolder)
50 {
51 LocalUserServices localUserService =
52 new LocalUserServices(
53 serversInfo.DefaultHomeLocX, serversInfo.DefaultHomeLocY, this);
54 localUserService.AddPlugin(configSettings.StandaloneUserPlugin, configSettings.StandaloneUserSource);
55
56 HGUserServices hgUserService = new HGUserServices(this, localUserService);
57 // This plugin arrangement could eventually be configurable rather than hardcoded here.
58 hgUserService.AddPlugin(new TemporaryUserProfilePlugin());
59 hgUserService.AddPlugin(new HGUserDataPlugin(this, hgUserService));
60
61 m_userService = hgUserService;
62 m_userAdminService = hgUserService;
63 m_avatarService = hgUserService;
64 m_messageService = hgUserService;
65
66 }
67 }
68}
diff --git a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs b/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs
deleted file mode 100644
index 09d8285..0000000
--- a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs
+++ /dev/null
@@ -1,337 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Framework.Communications;
34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Framework.Communications.Clients;
36using OpenSim.Region.Communications.OGS1;
37using OpenSim.Region.Communications.Local;
38using OpenSim.Services.Interfaces;
39
40namespace OpenSim.Region.Communications.Hypergrid
41{
42 /// <summary>
43 /// For the time being, this class is just an identity wrapper around OGS1UserServices,
44 /// so it always fails for foreign users.
45 /// Later it needs to talk with the foreign users' user servers.
46 /// </summary>
47 public class HGUserServices : OGS1UserServices
48 {
49 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 //private OGS1UserServices m_remoteUserServices;
52 private LocalUserServices m_localUserServices;
53
54 // Constructor called when running in grid mode
55 public HGUserServices(CommunicationsManager commsManager)
56 : base(commsManager)
57 {
58 }
59
60 // Constructor called when running in standalone
61 public HGUserServices(CommunicationsManager commsManager, LocalUserServices local)
62 : base(commsManager)
63 {
64 m_localUserServices = local;
65 }
66
67 public override void SetInventoryService(IInventoryService invService)
68 {
69 base.SetInventoryService(invService);
70 if (m_localUserServices != null)
71 m_localUserServices.SetInventoryService(invService);
72 }
73
74 public override UUID AddUser(
75 string firstName, string lastName, string password, string email, uint regX, uint regY, UUID uuid)
76 {
77 // Only valid to create users locally
78 if (m_localUserServices != null)
79 return m_localUserServices.AddUser(firstName, lastName, password, email, regX, regY, uuid);
80
81 return UUID.Zero;
82 }
83
84 public override bool AddUserAgent(UserAgentData agentdata)
85 {
86 if (m_localUserServices != null)
87 return m_localUserServices.AddUserAgent(agentdata);
88
89 return base.AddUserAgent(agentdata);
90 }
91
92 public override UserAgentData GetAgentByUUID(UUID userId)
93 {
94 string url = string.Empty;
95 if ((m_localUserServices != null) && !IsForeignUser(userId, out url))
96 return m_localUserServices.GetAgentByUUID(userId);
97
98 return base.GetAgentByUUID(userId);
99 }
100
101 public override void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
102 {
103 string url = string.Empty;
104 if ((m_localUserServices != null) && !IsForeignUser(userid, out url))
105 m_localUserServices.LogOffUser(userid, regionid, regionhandle, position, lookat);
106 else
107 base.LogOffUser(userid, regionid, regionhandle, position, lookat);
108 }
109
110 public override UserProfileData GetUserProfile(string firstName, string lastName)
111 {
112 if (m_localUserServices != null)
113 return m_localUserServices.GetUserProfile(firstName, lastName);
114
115 return base.GetUserProfile(firstName, lastName);
116 }
117
118 public override List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
119 {
120 if (m_localUserServices != null)
121 return m_localUserServices.GenerateAgentPickerRequestResponse(queryID, query);
122
123 return base.GenerateAgentPickerRequestResponse(queryID, query);
124 }
125
126 /// <summary>
127 /// Get a user profile from the user server
128 /// </summary>
129 /// <param name="avatarID"></param>
130 /// <returns>null if the request fails</returns>
131 public override UserProfileData GetUserProfile(UUID avatarID)
132 {
133 //string url = string.Empty;
134 // Unfortunately we can't query for foreigners here,
135 // because we'll end up in an infinite loop...
136 //if ((m_localUserServices != null) && (!IsForeignUser(avatarID, out url)))
137 if (m_localUserServices != null)
138 return m_localUserServices.GetUserProfile(avatarID);
139
140 return base.GetUserProfile(avatarID);
141 }
142
143 public override void ClearUserAgent(UUID avatarID)
144 {
145 if (m_localUserServices != null)
146 m_localUserServices.ClearUserAgent(avatarID);
147 else
148 base.ClearUserAgent(avatarID);
149 }
150
151 /// <summary>
152 /// Retrieve the user information for the given master uuid.
153 /// </summary>
154 /// <param name="uuid"></param>
155 /// <returns></returns>
156 public override UserProfileData SetupMasterUser(string firstName, string lastName)
157 {
158 if (m_localUserServices != null)
159 return m_localUserServices.SetupMasterUser(firstName, lastName);
160
161 return base.SetupMasterUser(firstName, lastName);
162 }
163
164 /// <summary>
165 /// Retrieve the user information for the given master uuid.
166 /// </summary>
167 /// <param name="uuid"></param>
168 /// <returns></returns>
169 public override UserProfileData SetupMasterUser(string firstName, string lastName, string password)
170 {
171 if (m_localUserServices != null)
172 return m_localUserServices.SetupMasterUser(firstName, lastName, password);
173
174 return base.SetupMasterUser(firstName, lastName, password);
175 }
176
177 /// <summary>
178 /// Retrieve the user information for the given master uuid.
179 /// </summary>
180 /// <param name="uuid"></param>
181 /// <returns></returns>
182 public override UserProfileData SetupMasterUser(UUID uuid)
183 {
184 if (m_localUserServices != null)
185 return m_localUserServices.SetupMasterUser(uuid);
186
187 return base.SetupMasterUser(uuid);
188 }
189
190 public override bool ResetUserPassword(string firstName, string lastName, string newPassword)
191 {
192 if (m_localUserServices != null)
193 return m_localUserServices.ResetUserPassword(firstName, lastName, newPassword);
194 else
195 return base.ResetUserPassword(firstName, lastName, newPassword);
196 }
197
198 public override bool UpdateUserProfile(UserProfileData userProfile)
199 {
200 string url = string.Empty;
201 if ((m_localUserServices != null) && (!IsForeignUser(userProfile.ID, out url)))
202 return m_localUserServices.UpdateUserProfile(userProfile);
203
204 return base.UpdateUserProfile(userProfile);
205 }
206
207 public override bool AuthenticateUserByPassword(UUID userID, string password)
208 {
209 if (m_localUserServices != null)
210 return m_localUserServices.AuthenticateUserByPassword(userID, password);
211 else
212 return base.AuthenticateUserByPassword(userID, password);
213 }
214
215 #region IUserServices Friend Methods
216
217 // NOTE: We're still not dealing with foreign user friends
218
219 /// <summary>
220 /// Adds a new friend to the database for XUser
221 /// </summary>
222 /// <param name="friendlistowner">The agent that who's friends list is being added to</param>
223 /// <param name="friend">The agent that being added to the friends list of the friends list owner</param>
224 /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param>
225 public override void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
226 {
227 if (m_localUserServices != null)
228 m_localUserServices.AddNewUserFriend(friendlistowner, friend, perms);
229 else
230 base.AddNewUserFriend(friendlistowner, friend, perms);
231 }
232
233 /// <summary>
234 /// Delete friend on friendlistowner's friendlist.
235 /// </summary>
236 /// <param name="friendlistowner">The agent that who's friends list is being updated</param>
237 /// <param name="friend">The Ex-friend agent</param>
238 public override void RemoveUserFriend(UUID friendlistowner, UUID friend)
239 {
240 if (m_localUserServices != null)
241 m_localUserServices.RemoveUserFriend(friendlistowner, friend);
242 else
243 base.RemoveUserFriend(friend, friend);
244 }
245
246 /// <summary>
247 /// Update permissions for friend on friendlistowner's friendlist.
248 /// </summary>
249 /// <param name="friendlistowner">The agent that who's friends list is being updated</param>
250 /// <param name="friend">The agent that is getting or loosing permissions</param>
251 /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param>
252 public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
253 {
254 if (m_localUserServices != null)
255 m_localUserServices.UpdateUserFriendPerms(friendlistowner, friend, perms);
256 else
257 base.UpdateUserFriendPerms(friendlistowner, friend, perms);
258 }
259 /// <summary>
260 /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner
261 /// </summary>
262 /// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param>
263 public override List<FriendListItem> GetUserFriendList(UUID friendlistowner)
264 {
265 if (m_localUserServices != null)
266 return m_localUserServices.GetUserFriendList(friendlistowner);
267
268 return base.GetUserFriendList(friendlistowner);
269 }
270
271 #endregion
272
273 /// Appearance
274 public override AvatarAppearance GetUserAppearance(UUID user)
275 {
276 string url = string.Empty;
277 if ((m_localUserServices != null) && (!IsForeignUser(user, out url)))
278 return m_localUserServices.GetUserAppearance(user);
279 else
280 return base.GetUserAppearance(user);
281 }
282
283 public override void UpdateUserAppearance(UUID user, AvatarAppearance appearance)
284 {
285 string url = string.Empty;
286 if ((m_localUserServices != null) && (!IsForeignUser(user, out url)))
287 m_localUserServices.UpdateUserAppearance(user, appearance);
288 else
289 base.UpdateUserAppearance(user, appearance);
290 }
291
292 #region IMessagingService
293
294 public override Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids)
295 {
296 if (m_localUserServices != null)
297 return m_localUserServices.GetFriendRegionInfos(uuids);
298
299 return base.GetFriendRegionInfos(uuids);
300 }
301 #endregion
302
303 public override bool VerifySession(UUID userID, UUID sessionID)
304 {
305 string url = string.Empty;
306 if ((m_localUserServices != null) && (!IsForeignUser(userID, out url)))
307 return m_localUserServices.VerifySession(userID, sessionID);
308 else
309 return base.VerifySession(userID, sessionID);
310 }
311
312
313 protected override string GetUserServerURL(UUID userID)
314 {
315 string serverURL = string.Empty;
316 if (IsForeignUser(userID, out serverURL))
317 return serverURL;
318
319 return m_commsManager.NetworkServersInfo.UserURL;
320 }
321
322 public bool IsForeignUser(UUID userID, out string userServerURL)
323 {
324 userServerURL = m_commsManager.NetworkServersInfo.UserURL;
325 CachedUserInfo uinfo = m_commsManager.UserProfileCacheService.GetUserDetails(userID);
326 if (uinfo != null)
327 {
328 if (!HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile))
329 {
330 userServerURL = ((ForeignUserProfileData)(uinfo.UserProfile)).UserServerURI;
331 return true;
332 }
333 }
334 return false;
335 }
336 }
337}
diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
deleted file mode 100644
index eaf996d..0000000
--- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
+++ /dev/null
@@ -1,59 +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.Data;
30using OpenSim.Framework;
31using OpenSim.Framework.Communications;
32using OpenSim.Framework.Communications.Cache;
33using OpenSim.Framework.Communications.Osp;
34
35namespace OpenSim.Region.Communications.Local
36{
37 public class CommunicationsLocal : CommunicationsManager
38 {
39 public CommunicationsLocal(
40 ConfigSettings configSettings,
41 NetworkServersInfo serversInfo,
42 LibraryRootFolder libraryRootFolder)
43 : base(serversInfo, libraryRootFolder)
44 {
45
46 LocalUserServices lus
47 = new LocalUserServices(
48 serversInfo.DefaultHomeLocX, serversInfo.DefaultHomeLocY, this);
49 lus.AddPlugin(new TemporaryUserProfilePlugin());
50 lus.AddPlugin(configSettings.StandaloneUserPlugin, configSettings.StandaloneUserSource);
51 m_userService = lus;
52 m_userAdminService = lus;
53 m_avatarService = lus;
54 m_messageService = lus;
55
56 //LocalLoginService loginService = CreateLoginService(libraryRootFolder, inventoryService, userService, backendService);
57 }
58 }
59}
diff --git a/OpenSim/Region/Communications/Local/LocalUserServices.cs b/OpenSim/Region/Communications/Local/LocalUserServices.cs
deleted file mode 100644
index 89b55c4..0000000
--- a/OpenSim/Region/Communications/Local/LocalUserServices.cs
+++ /dev/null
@@ -1,100 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using OpenMetaverse;
30using OpenSim.Framework;
31using OpenSim.Framework.Communications;
32using log4net;
33using System.Reflection;
34
35namespace OpenSim.Region.Communications.Local
36{
37 public class LocalUserServices : UserManagerBase
38 {
39 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40 private readonly uint m_defaultHomeX;
41 private readonly uint m_defaultHomeY;
42
43 /// <summary>
44 /// User services used when OpenSim is running in standalone mode.
45 /// </summary>
46 /// <param name="defaultHomeLocX"></param>
47 /// <param name="defaultHomeLocY"></param>
48 /// <param name="commsManager"></param>
49 public LocalUserServices(
50 uint defaultHomeLocX, uint defaultHomeLocY, CommunicationsManager commsManager)
51 : base(commsManager)
52 {
53 m_defaultHomeX = defaultHomeLocX;
54 m_defaultHomeY = defaultHomeLocY;
55 }
56
57 public override UserProfileData SetupMasterUser(string firstName, string lastName)
58 {
59 return SetupMasterUser(firstName, lastName, String.Empty);
60 }
61
62 public override UserProfileData SetupMasterUser(string firstName, string lastName, string password)
63 {
64 UserProfileData profile = GetUserProfile(firstName, lastName);
65 if (profile != null)
66 {
67 return profile;
68 }
69
70 m_log.Debug("Unknown Master User. Sandbox Mode: Creating Account");
71 AddUser(firstName, lastName, password, "", m_defaultHomeX, m_defaultHomeY);
72 return GetUserProfile(firstName, lastName);
73 }
74
75 public override UserProfileData SetupMasterUser(UUID uuid)
76 {
77 UserProfileData data = GetUserProfile(uuid);
78 if (data == null)
79 {
80 throw new Exception("[LOCAL USER SERVICES]: Unknown master user UUID. Possible reason: UserServer is not running.");
81 }
82 return data;
83 }
84
85 public override bool AuthenticateUserByPassword(UUID userID, string password)
86 {
87 UserProfileData userProfile = GetUserProfile(userID);
88
89 if (null == userProfile)
90 return false;
91
92 string md5PasswordHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + userProfile.PasswordSalt);
93
94 if (md5PasswordHash == userProfile.PasswordHash)
95 return true;
96 else
97 return false;
98 }
99 }
100} \ No newline at end of file
diff --git a/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs b/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs
deleted file mode 100644
index c631bf7..0000000
--- a/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,65 +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.Reflection;
29using System.Runtime.InteropServices;
30
31// General information about an assembly is controlled through the following
32// set of attributes. Change these attribute values to modify the information
33// associated with an assembly.
34
35[assembly : AssemblyTitle("OpenSim.Region.Communications.Local")]
36[assembly : AssemblyDescription("")]
37[assembly : AssemblyConfiguration("")]
38[assembly : AssemblyCompany("http://opensimulator.org")]
39[assembly : AssemblyProduct("OpenSim.Region.Communications.Local")]
40[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")]
41[assembly : AssemblyTrademark("")]
42[assembly : AssemblyCulture("")]
43
44// Setting ComVisible to false makes the types in this assembly not visible
45// to COM components. If you need to access a type in this assembly from
46// COM, set the ComVisible attribute to true on that type.
47
48[assembly : ComVisible(false)]
49
50// The following GUID is for the ID of the typelib if this project is exposed to COM
51
52[assembly : Guid("fb173926-bd0a-4cd0-bb45-185b2f72ddfb")]
53
54// Version information for an assembly consists of the following four values:
55//
56// Major Version
57// Minor Version
58// Build Number
59// Revision
60//
61// You can specify all the values or you can default the Revision and Build Numbers
62// by using the '*' as shown below:
63
64[assembly : AssemblyVersion("0.6.5.*")]
65[assembly : AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs
deleted file mode 100644
index 94e4ed2..0000000
--- a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs
+++ /dev/null
@@ -1,54 +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 OpenSim.Framework;
29using OpenSim.Framework.Communications;
30using OpenSim.Framework.Communications.Cache;
31using OpenSim.Framework.Servers.HttpServer;
32
33namespace OpenSim.Region.Communications.OGS1
34{
35 public class CommunicationsOGS1 : CommunicationsManager
36 {
37 public CommunicationsOGS1(
38 NetworkServersInfo serversInfo,
39 LibraryRootFolder libraryRootFolder)
40 : base(serversInfo, libraryRootFolder)
41 {
42
43 // This plugin arrangement could eventually be configurable rather than hardcoded here.
44 OGS1UserServices userServices = new OGS1UserServices(this);
45 userServices.AddPlugin(new TemporaryUserProfilePlugin());
46 userServices.AddPlugin(new OGS1UserDataPlugin(this));
47
48 m_userService = userServices;
49 m_messageService = userServices;
50 m_avatarService = (IAvatarService)m_userService;
51 }
52
53 }
54}
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs b/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs
deleted file mode 100644
index cb1766a..0000000
--- a/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs
+++ /dev/null
@@ -1,774 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using System.Text.RegularExpressions;
34using System.Xml.Serialization;
35using log4net;
36using Nwc.XmlRpc;
37using OpenMetaverse;
38using OpenSim.Data;
39using OpenSim.Framework;
40using OpenSim.Framework.Communications;
41using OpenSim.Framework.Communications.Clients;
42
43namespace OpenSim.Region.Communications.OGS1
44{
45 public class OGS1UserDataPlugin : IUserDataPlugin
46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48
49 protected CommunicationsManager m_commsManager;
50
51 public OGS1UserDataPlugin()
52 {
53 }
54
55 public OGS1UserDataPlugin(CommunicationsManager commsManager)
56 {
57 m_log.DebugFormat("[OGS1 USER SERVICES]: {0} initialized", Name);
58 m_commsManager = commsManager;
59 }
60
61 public string Version { get { return "0.1"; } }
62 public string Name { get { return "Open Grid Services 1 (OGS1) User Data Plugin"; } }
63 public void Initialise() {}
64
65 public void Initialise(string connect) {}
66
67 public void Dispose() {}
68
69 // Arguably the presence of these means that IUserDataPlugin could be fissioned
70 public UserAgentData GetUserAgent(string name) { return null; }
71 public UserAgentData GetAgentByName(string name) { return null; }
72 public UserAgentData GetAgentByName(string fname, string lname) { return null; }
73 public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) {}
74 public void AddNewUserProfile(UserProfileData user) {}
75 public void AddNewUserAgent(UserAgentData agent) {}
76 public bool MoneyTransferRequest(UUID from, UUID to, uint amount) { return false; }
77 public bool InventoryTransferRequest(UUID from, UUID to, UUID inventory) { return false; }
78 public void ResetAttachments(UUID userID) {}
79 public void LogoutUsers(UUID regionID) {}
80
81 public virtual void AddTemporaryUserProfile(UserProfileData userProfile)
82 {
83 // Not interested
84 }
85
86 public UserProfileData GetUserByUri(Uri uri)
87 {
88 WebRequest request = WebRequest.Create(uri);
89
90 WebResponse webResponse = request.GetResponse();
91
92 XmlSerializer deserializer = new XmlSerializer(typeof(XmlRpcResponse));
93 XmlRpcResponse xmlRpcResponse = (XmlRpcResponse)deserializer.Deserialize(webResponse.GetResponseStream());
94
95 Hashtable respData = (Hashtable)xmlRpcResponse.Value;
96
97 return ConvertXMLRPCDataToUserProfile(respData);
98 }
99
100// public Uri GetUserUri(UserProfileData userProfile)
101// {
102// throw new NotImplementedException();
103// }
104
105 public virtual UserAgentData GetAgentByUUID(UUID userId)
106 {
107 try
108 {
109 Hashtable param = new Hashtable();
110 param["avatar_uuid"] = userId.ToString();
111 IList parameters = new ArrayList();
112 parameters.Add(param);
113 XmlRpcRequest req = new XmlRpcRequest("get_agent_by_uuid", parameters);
114
115 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 6000);
116 Hashtable respData = (Hashtable)resp.Value;
117 if (respData.Contains("error_type"))
118 {
119 //m_log.Warn("[GRID]: " +
120 // "Error sent by user server when trying to get agent: (" +
121 // (string) respData["error_type"] +
122 // "): " + (string)respData["error_desc"]);
123 return null;
124 }
125 UUID sessionid = UUID.Zero;
126
127 UserAgentData userAgent = new UserAgentData();
128 userAgent.Handle = Convert.ToUInt64((string)respData["handle"]);
129 UUID.TryParse((string)respData["sessionid"], out sessionid);
130 userAgent.SessionID = sessionid;
131
132 if ((string)respData["agent_online"] == "TRUE")
133 {
134 userAgent.AgentOnline = true;
135 }
136 else
137 {
138 userAgent.AgentOnline = false;
139 }
140
141 return userAgent;
142 }
143 catch (Exception e)
144 {
145 m_log.ErrorFormat(
146 "[OGS1 USER SERVICES]: Error when trying to fetch agent data by uuid from remote user server: {0}",
147 e);
148 }
149
150 return null;
151 }
152
153 public virtual UserProfileData GetUserByName(string firstName, string lastName)
154 {
155 return GetUserProfile(firstName + " " + lastName);
156 }
157
158 public virtual List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query)
159 {
160 List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>();
161 Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9 ]");
162 try
163 {
164 Hashtable param = new Hashtable();
165 param["queryid"] = (string)queryID.ToString();
166 param["avquery"] = objAlphaNumericPattern.Replace(query, String.Empty);
167 IList parameters = new ArrayList();
168 parameters.Add(param);
169 XmlRpcRequest req = new XmlRpcRequest("get_avatar_picker_avatar", parameters);
170 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000);
171 Hashtable respData = (Hashtable)resp.Value;
172 pickerlist = ConvertXMLRPCDataToAvatarPickerList(queryID, respData);
173 }
174 catch (WebException e)
175 {
176 m_log.Warn("[OGS1 USER SERVICES]: Error when trying to fetch Avatar Picker Response: " +
177 e.Message);
178 // Return Empty picker list (no results)
179 }
180 return pickerlist;
181 }
182
183 /// <summary>
184 /// Get a user profile from the user server
185 /// </summary>
186 /// <param name="avatarID"></param>
187 /// <returns>null if the request fails</returns>
188 protected virtual UserProfileData GetUserProfile(string name)
189 {
190 try
191 {
192 Hashtable param = new Hashtable();
193 param["avatar_name"] = name;
194 IList parameters = new ArrayList();
195 parameters.Add(param);
196 XmlRpcRequest req = new XmlRpcRequest("get_user_by_name", parameters);
197 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000);
198 Hashtable respData = (Hashtable)resp.Value;
199
200 return ConvertXMLRPCDataToUserProfile(respData);
201 }
202 catch (WebException e)
203 {
204 m_log.ErrorFormat(
205 "[OGS1 USER SERVICES]: Error when trying to fetch profile data by name from remote user server: {0}",
206 e);
207 }
208
209 return null;
210 }
211
212 /// <summary>
213 /// Get a user profile from the user server
214 /// </summary>
215 /// <param name="avatarID"></param>
216 /// <returns>null if the request fails</returns>
217 public virtual UserProfileData GetUserByUUID(UUID avatarID)
218 {
219 try
220 {
221 Hashtable param = new Hashtable();
222 param["avatar_uuid"] = avatarID.ToString();
223 IList parameters = new ArrayList();
224 parameters.Add(param);
225 XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", parameters);
226 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000);
227 Hashtable respData = (Hashtable)resp.Value;
228
229 return ConvertXMLRPCDataToUserProfile(respData);
230 }
231 catch (Exception e)
232 {
233 m_log.ErrorFormat(
234 "[OGS1 USER SERVICES]: Error when trying to fetch profile data by uuid from remote user server: {0}",
235 e);
236 }
237
238 return null;
239 }
240
241 public virtual bool UpdateUserProfile(UserProfileData userProfile)
242 {
243 m_log.Debug("[OGS1 USER SERVICES]: Asking UserServer to update profile.");
244
245 Hashtable param = new Hashtable();
246 param["avatar_uuid"] = userProfile.ID.ToString();
247 //param["AllowPublish"] = userProfile.ToString();
248 param["FLImageID"] = userProfile.FirstLifeImage.ToString();
249 param["ImageID"] = userProfile.Image.ToString();
250 //param["MaturePublish"] = MaturePublish.ToString();
251 param["AboutText"] = userProfile.AboutText;
252 param["FLAboutText"] = userProfile.FirstLifeAboutText;
253 //param["ProfileURL"] = userProfile.ProfileURL.ToString();
254
255 param["home_region"] = userProfile.HomeRegion.ToString();
256 param["home_region_id"] = userProfile.HomeRegionID.ToString();
257
258 param["home_pos_x"] = userProfile.HomeLocationX.ToString();
259 param["home_pos_y"] = userProfile.HomeLocationY.ToString();
260 param["home_pos_z"] = userProfile.HomeLocationZ.ToString();
261 param["home_look_x"] = userProfile.HomeLookAtX.ToString();
262 param["home_look_y"] = userProfile.HomeLookAtY.ToString();
263 param["home_look_z"] = userProfile.HomeLookAtZ.ToString();
264 param["user_flags"] = userProfile.UserFlags.ToString();
265 param["god_level"] = userProfile.GodLevel.ToString();
266 param["custom_type"] = userProfile.CustomType.ToString();
267 param["partner"] = userProfile.Partner.ToString();
268
269 IList parameters = new ArrayList();
270 parameters.Add(param);
271
272 XmlRpcRequest req = new XmlRpcRequest("update_user_profile", parameters);
273 XmlRpcResponse resp = req.Send(GetUserServerURL(userProfile.ID), 3000);
274 Hashtable respData = (Hashtable)resp.Value;
275 if (respData != null)
276 {
277 if (respData.Contains("returnString"))
278 {
279 if (((string)respData["returnString"]).ToUpper() != "TRUE")
280 {
281 m_log.Warn("[GRID]: Unable to update user profile, User Server Reported an issue");
282 return false;
283 }
284 }
285 else
286 {
287 m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!");
288 return false;
289 }
290 }
291 else
292 {
293 m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!");
294 return false;
295 }
296
297 return true;
298 }
299
300 /// <summary>
301 /// Adds a new friend to the database for XUser
302 /// </summary>
303 /// <param name="friendlistowner">The agent that who's friends list is being added to</param>
304 /// <param name="friend">The agent that being added to the friends list of the friends list owner</param>
305 /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param>
306 public virtual void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
307 {
308 try
309 {
310 Hashtable param = new Hashtable();
311 param["ownerID"] = friendlistowner.Guid.ToString();
312 param["friendID"] = friend.Guid.ToString();
313 param["friendPerms"] = perms.ToString();
314 IList parameters = new ArrayList();
315 parameters.Add(param);
316
317 XmlRpcRequest req = new XmlRpcRequest("add_new_user_friend", parameters);
318 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000);
319 Hashtable respData = (Hashtable)resp.Value;
320 if (respData != null)
321 {
322 if (respData.Contains("returnString"))
323 {
324 if ((string)respData["returnString"] == "TRUE")
325 {
326
327 }
328 else
329 {
330 m_log.Warn("[GRID]: Unable to add new friend, User Server Reported an issue");
331 }
332 }
333 else
334 {
335 m_log.Warn("[GRID]: Unable to add new friend, UserServer didn't understand me!");
336 }
337 }
338 else
339 {
340 m_log.Warn("[GRID]: Unable to add new friend, UserServer didn't understand me!");
341
342 }
343 }
344 catch (WebException e)
345 {
346 m_log.Warn("[GRID]: Error when trying to AddNewUserFriend: " +
347 e.Message);
348
349 }
350 }
351
352 /// <summary>
353 /// Delete friend on friendlistowner's friendlist.
354 /// </summary>
355 /// <param name="friendlistowner">The agent that who's friends list is being updated</param>
356 /// <param name="friend">The Ex-friend agent</param>
357 public virtual void RemoveUserFriend(UUID friendlistowner, UUID friend)
358 {
359 try
360 {
361 Hashtable param = new Hashtable();
362 param["ownerID"] = friendlistowner.Guid.ToString();
363 param["friendID"] = friend.Guid.ToString();
364
365 IList parameters = new ArrayList();
366 parameters.Add(param);
367
368 XmlRpcRequest req = new XmlRpcRequest("remove_user_friend", parameters);
369 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000);
370 Hashtable respData = (Hashtable)resp.Value;
371 if (respData != null)
372 {
373 if (respData.Contains("returnString"))
374 {
375 if ((string)respData["returnString"] == "TRUE")
376 {
377
378 }
379 else
380 {
381 m_log.Warn("[GRID]: Unable to remove friend, User Server Reported an issue");
382 }
383 }
384 else
385 {
386 m_log.Warn("[GRID]: Unable to remove friend, UserServer didn't understand me!");
387 }
388 }
389 else
390 {
391 m_log.Warn("[GRID]: Unable to remove friend, UserServer didn't understand me!");
392
393 }
394 }
395 catch (WebException e)
396 {
397 m_log.Warn("[GRID]: Error when trying to RemoveUserFriend: " +
398 e.Message);
399
400 }
401 }
402
403 /// <summary>
404 /// Update permissions for friend on friendlistowner's friendlist.
405 /// </summary>
406 /// <param name="friendlistowner">The agent that who's friends list is being updated</param>
407 /// <param name="friend">The agent that is getting or loosing permissions</param>
408 /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param>
409 public virtual void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
410 {
411 try
412 {
413 Hashtable param = new Hashtable();
414 param["ownerID"] = friendlistowner.Guid.ToString();
415 param["friendID"] = friend.Guid.ToString();
416 param["friendPerms"] = perms.ToString();
417 IList parameters = new ArrayList();
418 parameters.Add(param);
419
420 XmlRpcRequest req = new XmlRpcRequest("update_user_friend_perms", parameters);
421 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000);
422 Hashtable respData = (Hashtable)resp.Value;
423 if (respData != null)
424 {
425 if (respData.Contains("returnString"))
426 {
427 if ((string)respData["returnString"] == "TRUE")
428 {
429
430 }
431 else
432 {
433 m_log.Warn("[GRID]: Unable to update_user_friend_perms, User Server Reported an issue");
434 }
435 }
436 else
437 {
438 m_log.Warn("[GRID]: Unable to update_user_friend_perms, UserServer didn't understand me!");
439 }
440 }
441 else
442 {
443 m_log.Warn("[GRID]: Unable to update_user_friend_perms, UserServer didn't understand me!");
444
445 }
446 }
447 catch (WebException e)
448 {
449 m_log.Warn("[GRID]: Error when trying to update_user_friend_perms: " +
450 e.Message);
451 }
452 }
453 /// <summary>
454 /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner
455 /// </summary>
456 /// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param>
457 public virtual List<FriendListItem> GetUserFriendList(UUID friendlistowner)
458 {
459 List<FriendListItem> buddylist = new List<FriendListItem>();
460
461 try
462 {
463 Hashtable param = new Hashtable();
464 param["ownerID"] = friendlistowner.Guid.ToString();
465
466 IList parameters = new ArrayList();
467 parameters.Add(param);
468 XmlRpcRequest req = new XmlRpcRequest("get_user_friend_list", parameters);
469 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 8000);
470 Hashtable respData = (Hashtable)resp.Value;
471
472 if (respData != null && respData.Contains("avcount"))
473 {
474 buddylist = ConvertXMLRPCDataToFriendListItemList(respData);
475 }
476
477 }
478 catch (WebException e)
479 {
480 m_log.Warn("[OGS1 USER SERVICES]: Error when trying to fetch Avatar's friends list: " +
481 e.Message);
482 // Return Empty list (no friends)
483 }
484 return buddylist;
485 }
486
487 public virtual Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids)
488 {
489 Dictionary<UUID, FriendRegionInfo> result = new Dictionary<UUID, FriendRegionInfo>();
490
491 // ask MessageServer about the current on-/offline status and regions the friends are in
492 ArrayList parameters = new ArrayList();
493 Hashtable map = new Hashtable();
494
495 ArrayList list = new ArrayList();
496 foreach (UUID uuid in uuids)
497 {
498 list.Add(uuid.ToString());
499 list.Add(uuid.ToString());
500 }
501 map["uuids"] = list;
502
503 map["recv_key"] = m_commsManager.NetworkServersInfo.UserRecvKey;
504 map["send_key"] = m_commsManager.NetworkServersInfo.UserSendKey;
505
506 parameters.Add(map);
507
508 try
509 {
510 XmlRpcRequest req = new XmlRpcRequest("get_presence_info_bulk", parameters);
511 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.MessagingURL, 8000);
512 Hashtable respData = resp != null ? (Hashtable)resp.Value : null;
513
514 if (respData == null || respData.ContainsKey("faultMessage"))
515 {
516 m_log.WarnFormat("[OGS1 USER SERVICES]: Contacting MessagingServer about user-regions resulted in error: {0}",
517 respData == null ? "<unknown error>" : respData["faultMessage"]);
518 }
519 else if (!respData.ContainsKey("count"))
520 {
521 m_log.WarnFormat("[OGS1 USER SERVICES]: Wrong format in response for MessagingServer request get_presence_info_bulk: missing 'count' field");
522 }
523 else
524 {
525 int count = (int)respData["count"];
526 m_log.DebugFormat("[OGS1 USER SERVICES]: Request returned {0} results.", count);
527 for (int i = 0; i < count; ++i)
528 {
529 if (respData.ContainsKey("uuid_" + i) && respData.ContainsKey("isOnline_" + i) && respData.ContainsKey("regionHandle_" + i))
530 {
531 UUID uuid;
532 if (UUID.TryParse((string)respData["uuid_" + i], out uuid))
533 {
534 FriendRegionInfo info = new FriendRegionInfo();
535 info.isOnline = (bool)respData["isOnline_" + i];
536 if (info.isOnline)
537 {
538 // TODO remove this after the next protocol update (say, r7800?)
539 info.regionHandle = Convert.ToUInt64(respData["regionHandle_" + i]);
540
541 // accept missing id
542 if (respData.ContainsKey("regionID_" + i))
543 UUID.TryParse((string)respData["regionID_" + i], out info.regionID);
544 }
545
546 result.Add(uuid, info);
547 }
548 }
549 else
550 {
551 m_log.WarnFormat("[OGS1 USER SERVICES]: Response to get_presence_info_bulk contained an error in entry {0}", i);
552 }
553 }
554 }
555 }
556 catch (WebException e)
557 {
558 m_log.ErrorFormat("[OGS1 USER SERVICES]: Network problems when trying to fetch friend infos: {0}", e.Message);
559 }
560
561 m_log.DebugFormat("[OGS1 USER SERVICES]: Returning {0} entries", result.Count);
562
563 return result;
564 }
565
566 public virtual AvatarAppearance GetUserAppearance(UUID user)
567 {
568 AvatarAppearance appearance = null;
569
570 try
571 {
572 Hashtable param = new Hashtable();
573 param["owner"] = user.ToString();
574
575 IList parameters = new ArrayList();
576 parameters.Add(param);
577 XmlRpcRequest req = new XmlRpcRequest("get_avatar_appearance", parameters);
578 XmlRpcResponse resp = req.Send(GetUserServerURL(user), 8000);
579 Hashtable respData = (Hashtable)resp.Value;
580
581 return ConvertXMLRPCDataToAvatarAppearance(respData);
582 }
583 catch (WebException e)
584 {
585 m_log.ErrorFormat("[OGS1 USER SERVICES]: Network problems when trying to fetch appearance for avatar {0}, {1}", user, e.Message);
586 }
587
588 return appearance;
589 }
590
591 public virtual void UpdateUserAppearance(UUID user, AvatarAppearance appearance)
592 {
593 try
594 {
595 Hashtable param = appearance.ToHashTable();
596 param["owner"] = user.ToString();
597
598 IList parameters = new ArrayList();
599 parameters.Add(param);
600 XmlRpcRequest req = new XmlRpcRequest("update_avatar_appearance", parameters);
601 XmlRpcResponse resp = req.Send(GetUserServerURL(user), 8000);
602 Hashtable respData = (Hashtable)resp.Value;
603
604 if (respData != null)
605 {
606 if (respData.Contains("returnString"))
607 {
608 if ((string)respData["returnString"] == "TRUE")
609 {
610 m_log.DebugFormat("[OGS1 USER SERVICES]: Updated user appearance in {0}", GetUserServerURL(user));
611 }
612 else
613 {
614 m_log.Warn("[GRID]: Unable to update_user_appearance, User Server Reported an issue");
615 }
616 }
617 else
618 {
619 m_log.Warn("[GRID]: Unable to update_user_appearance, UserServer didn't understand me!");
620 }
621 }
622 else
623 {
624 m_log.Warn("[GRID]: Unable to update_user_appearance, UserServer didn't understand me!");
625 }
626 }
627 catch (WebException e)
628 {
629 m_log.WarnFormat("[OGS1 USER SERVICES]: Error when trying to update Avatar's appearance in {0}: {1}",
630 GetUserServerURL(user), e.Message);
631 // Return Empty list (no friends)
632 }
633 }
634
635 protected virtual string GetUserServerURL(UUID userID)
636 {
637 return m_commsManager.NetworkServersInfo.UserURL;
638 }
639
640 protected UserProfileData ConvertXMLRPCDataToUserProfile(Hashtable data)
641 {
642 if (data.Contains("error_type"))
643 {
644 //m_log.Warn("[GRID]: " +
645 // "Error sent by user server when trying to get user profile: (" +
646 // data["error_type"] +
647 // "): " + data["error_desc"]);
648 return null;
649 }
650
651 UserProfileData userData = new UserProfileData();
652 userData.FirstName = (string)data["firstname"];
653 userData.SurName = (string)data["lastname"];
654 if (data["email"] != null)
655 userData.Email = (string)data["email"];
656 userData.ID = new UUID((string)data["uuid"]);
657 userData.Created = Convert.ToInt32(data["profile_created"]);
658 if (data.Contains("server_inventory") && data["server_inventory"] != null)
659 userData.UserInventoryURI = (string)data["server_inventory"];
660 if (data.Contains("server_asset") && data["server_asset"] != null)
661 userData.UserAssetURI = (string)data["server_asset"];
662 if (data.Contains("profile_firstlife_about") && data["profile_firstlife_about"] != null)
663 userData.FirstLifeAboutText = (string)data["profile_firstlife_about"];
664 userData.FirstLifeImage = new UUID((string)data["profile_firstlife_image"]);
665 userData.CanDoMask = Convert.ToUInt32((string)data["profile_can_do"]);
666 userData.WantDoMask = Convert.ToUInt32(data["profile_want_do"]);
667 userData.AboutText = (string)data["profile_about"];
668 userData.Image = new UUID((string)data["profile_image"]);
669 userData.LastLogin = Convert.ToInt32((string)data["profile_lastlogin"]);
670 userData.HomeRegion = Convert.ToUInt64((string)data["home_region"]);
671 if (data.Contains("home_region_id"))
672 userData.HomeRegionID = new UUID((string)data["home_region_id"]);
673 else
674 userData.HomeRegionID = UUID.Zero;
675 userData.HomeLocation =
676 new Vector3((float)Convert.ToDecimal((string)data["home_coordinates_x"], Culture.NumberFormatInfo),
677 (float)Convert.ToDecimal((string)data["home_coordinates_y"], Culture.NumberFormatInfo),
678 (float)Convert.ToDecimal((string)data["home_coordinates_z"], Culture.NumberFormatInfo));
679 userData.HomeLookAt =
680 new Vector3((float)Convert.ToDecimal((string)data["home_look_x"], Culture.NumberFormatInfo),
681 (float)Convert.ToDecimal((string)data["home_look_y"], Culture.NumberFormatInfo),
682 (float)Convert.ToDecimal((string)data["home_look_z"], Culture.NumberFormatInfo));
683 if (data.Contains("user_flags"))
684 userData.UserFlags = Convert.ToInt32((string)data["user_flags"]);
685 if (data.Contains("god_level"))
686 userData.GodLevel = Convert.ToInt32((string)data["god_level"]);
687
688 if (data.Contains("custom_type"))
689 userData.CustomType = (string)data["custom_type"];
690 else
691 userData.CustomType = "";
692 if (userData.CustomType == null)
693 userData.CustomType = "";
694
695 if (data.Contains("partner"))
696 userData.Partner = new UUID((string)data["partner"]);
697 else
698 userData.Partner = UUID.Zero;
699
700 return userData;
701 }
702
703 protected AvatarAppearance ConvertXMLRPCDataToAvatarAppearance(Hashtable data)
704 {
705 if (data != null)
706 {
707 if (data.Contains("error_type"))
708 {
709 m_log.Warn("[GRID]: " +
710 "Error sent by user server when trying to get user appearance: (" +
711 data["error_type"] +
712 "): " + data["error_desc"]);
713 return null;
714 }
715 else
716 {
717 return new AvatarAppearance(data);
718 }
719 }
720 else
721 {
722 m_log.Error("[GRID]: The avatar appearance is null, something bad happenend");
723 return null;
724 }
725 }
726
727 protected List<AvatarPickerAvatar> ConvertXMLRPCDataToAvatarPickerList(UUID queryID, Hashtable data)
728 {
729 List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>();
730 int pickercount = Convert.ToInt32((string)data["avcount"]);
731 UUID respqueryID = new UUID((string)data["queryid"]);
732 if (queryID == respqueryID)
733 {
734 for (int i = 0; i < pickercount; i++)
735 {
736 AvatarPickerAvatar apicker = new AvatarPickerAvatar();
737 UUID avatarID = new UUID((string)data["avatarid" + i.ToString()]);
738 string firstname = (string)data["firstname" + i.ToString()];
739 string lastname = (string)data["lastname" + i.ToString()];
740 apicker.AvatarID = avatarID;
741 apicker.firstName = firstname;
742 apicker.lastName = lastname;
743 pickerlist.Add(apicker);
744 }
745 }
746 else
747 {
748 m_log.Warn("[OGS1 USER SERVICES]: Got invalid queryID from userServer");
749 }
750 return pickerlist;
751 }
752
753 protected List<FriendListItem> ConvertXMLRPCDataToFriendListItemList(Hashtable data)
754 {
755 List<FriendListItem> buddylist = new List<FriendListItem>();
756 int buddycount = Convert.ToInt32((string)data["avcount"]);
757
758
759 for (int i = 0; i < buddycount; i++)
760 {
761 FriendListItem buddylistitem = new FriendListItem();
762
763 buddylistitem.FriendListOwner = new UUID((string)data["ownerID" + i.ToString()]);
764 buddylistitem.Friend = new UUID((string)data["friendID" + i.ToString()]);
765 buddylistitem.FriendListOwnerPerms = (uint)Convert.ToInt32((string)data["ownerPerms" + i.ToString()]);
766 buddylistitem.FriendPerms = (uint)Convert.ToInt32((string)data["friendPerms" + i.ToString()]);
767
768 buddylist.Add(buddylistitem);
769 }
770
771 return buddylist;
772 }
773 }
774}
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
deleted file mode 100644
index ed3526d..0000000
--- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
+++ /dev/null
@@ -1,176 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using System.Text.RegularExpressions;
34using System.Xml.Serialization;
35using log4net;
36using Nwc.XmlRpc;
37using OpenMetaverse;
38using OpenSim.Data;
39using OpenSim.Framework;
40using OpenSim.Framework.Communications;
41using OpenSim.Framework.Communications.Clients;
42
43namespace OpenSim.Region.Communications.OGS1
44{
45 public class OGS1UserServices : UserManagerBase
46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48
49 public OGS1UserServices(CommunicationsManager commsManager)
50 : base(commsManager)
51 {
52 }
53
54 public override void ClearUserAgent(UUID avatarID)
55 {
56 // TODO: implement
57 // It may be possible to use the UserManagerBase implementation.
58 }
59
60 protected virtual string GetUserServerURL(UUID userID)
61 {
62 return m_commsManager.NetworkServersInfo.UserURL;
63 }
64
65 /// <summary>
66 /// Logs off a user on the user server
67 /// </summary>
68 /// <param name="UserID">UUID of the user</param>
69 /// <param name="regionID">UUID of the Region</param>
70 /// <param name="regionhandle">regionhandle</param>
71 /// <param name="position">final position</param>
72 /// <param name="lookat">final lookat</param>
73 public override void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
74 {
75 Hashtable param = new Hashtable();
76 param["avatar_uuid"] = userid.Guid.ToString();
77 param["region_uuid"] = regionid.Guid.ToString();
78 param["region_handle"] = regionhandle.ToString();
79 param["region_pos_x"] = position.X.ToString();
80 param["region_pos_y"] = position.Y.ToString();
81 param["region_pos_z"] = position.Z.ToString();
82 param["lookat_x"] = lookat.X.ToString();
83 param["lookat_y"] = lookat.Y.ToString();
84 param["lookat_z"] = lookat.Z.ToString();
85
86 IList parameters = new ArrayList();
87 parameters.Add(param);
88 XmlRpcRequest req = new XmlRpcRequest("logout_of_simulator", parameters);
89
90 try
91 {
92 req.Send(GetUserServerURL(userid), 3000);
93 }
94 catch (WebException)
95 {
96 m_log.Warn("[LOGOFF]: Unable to notify grid server of user logoff");
97 }
98 }
99
100 /// <summary>
101 /// Retrieve the user information for the given master uuid.
102 /// </summary>
103 /// <param name="uuid"></param>
104 /// <returns></returns>
105 public override UserProfileData SetupMasterUser(string firstName, string lastName)
106 {
107 return SetupMasterUser(firstName, lastName, String.Empty);
108 }
109
110 /// <summary>
111 /// Retrieve the user information for the given master uuid.
112 /// </summary>
113 /// <param name="uuid"></param>
114 /// <returns></returns>
115 public override UserProfileData SetupMasterUser(string firstName, string lastName, string password)
116 {
117 UserProfileData profile = GetUserProfile(firstName, lastName);
118 return profile;
119 }
120
121 /// <summary>
122 /// Retrieve the user information for the given master uuid.
123 /// </summary>
124 /// <param name="uuid"></param>
125 /// <returns></returns>
126 public override UserProfileData SetupMasterUser(UUID uuid)
127 {
128 UserProfileData data = GetUserProfile(uuid);
129
130 if (data == null)
131 {
132 throw new Exception(
133 "Could not retrieve profile for master user " + uuid + ". User server did not respond to the request.");
134 }
135
136 return data;
137 }
138
139 public override bool VerifySession(UUID userID, UUID sessionID)
140 {
141 m_log.DebugFormat("[OGS1 USER SERVICES]: Verifying user session for " + userID);
142 return AuthClient.VerifySession(GetUserServerURL(userID), userID, sessionID);
143 }
144
145 public override bool AuthenticateUserByPassword(UUID userID, string password)
146 {
147 Hashtable param = new Hashtable();
148 param["user_uuid"] = userID.ToString();
149 param["password"] = password;
150 IList parameters = new ArrayList();
151 parameters.Add(param);
152 XmlRpcRequest req = new XmlRpcRequest("authenticate_user_by_password", parameters);
153 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000);
154
155 // Temporary measure to deal with older services
156 if (resp.IsFault && resp.FaultCode == XmlRpcErrorCodes.SERVER_ERROR_METHOD)
157 {
158 throw new Exception(
159 String.Format(
160 "XMLRPC method 'authenticate_user_by_password' not yet implemented by user service at {0}",
161 m_commsManager.NetworkServersInfo.UserURL));
162 }
163
164 Hashtable respData = (Hashtable)resp.Value;
165
166 if ((string)respData["auth_user"] == "TRUE")
167 {
168 return true;
169 }
170 else
171 {
172 return false;
173 }
174 }
175 }
176} \ No newline at end of file
diff --git a/OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs b/OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs
deleted file mode 100644
index 2b54f2e..0000000
--- a/OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,65 +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.Reflection;
29using System.Runtime.InteropServices;
30
31// General information about an assembly is controlled through the following
32// set of attributes. Change these attribute values to modify the information
33// associated with an assembly.
34
35[assembly : AssemblyTitle("OpenGrid.Framework.Communications.OGS1")]
36[assembly : AssemblyDescription("")]
37[assembly : AssemblyConfiguration("")]
38[assembly : AssemblyCompany("http://opensimulator.org")]
39[assembly : AssemblyProduct("OpenGrid.Framework.Communications.OGS1")]
40[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")]
41[assembly : AssemblyTrademark("")]
42[assembly : AssemblyCulture("")]
43
44// Setting ComVisible to false makes the types in this assembly not visible
45// to COM components. If you need to access a type in this assembly from
46// COM, set the ComVisible attribute to true on that type.
47
48[assembly : ComVisible(false)]
49
50// The following GUID is for the ID of the typelib if this project is exposed to COM
51
52[assembly : Guid("a8b2b39b-c83b-41e2-b0b5-7ccfc1fddae7")]
53
54// Version information for an assembly consists of the following four values:
55//
56// Major Version
57// Minor Version
58// Build Number
59// Revision
60//
61// You can specify all the values or you can default the Revision and Build Numbers
62// by using the '*' as shown below:
63
64[assembly : AssemblyVersion("0.6.5.*")]
65[assembly : AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
index c9ee54f..012d581 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
@@ -30,7 +30,7 @@ using System.Reflection;
30using log4net; 30using log4net;
31using OpenMetaverse; 31using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Communications.Cache; 33
34using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
36 36
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
index fa92fe8..c791cb4 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
@@ -31,7 +31,7 @@ using System.Reflection;
31using log4net; 31using log4net;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications.Cache; 34
35using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
36 36
37namespace OpenSim.Region.CoreModules.Agent.AssetTransaction 37namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
@@ -112,7 +112,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
112 bool storeLocal, bool tempFile) 112 bool storeLocal, bool tempFile)
113 { 113 {
114 ourClient = remoteClient; 114 ourClient = remoteClient;
115 m_asset = new AssetBase(assetID, "blank", type); 115 m_asset = new AssetBase(assetID, "blank", type, remoteClient.AgentId.ToString());
116 m_asset.Data = data; 116 m_asset.Data = data;
117 m_asset.Description = "empty"; 117 m_asset.Description = "empty";
118 m_asset.Local = storeLocal; 118 m_asset.Local = storeLocal;
diff --git a/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs b/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs
index 71ff28c..c7bf6c8 100644
--- a/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs
@@ -33,7 +33,7 @@ using log4net;
33using Nini.Config; 33using Nini.Config;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Communications.Cache; 36
37using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using BlockingQueue = OpenSim.Framework.BlockingQueue<OpenSim.Region.Framework.Interfaces.ITextureSender>; 39using BlockingQueue = OpenSim.Framework.BlockingQueue<OpenSim.Region.Framework.Interfaces.ITextureSender>;
@@ -214,8 +214,8 @@ namespace OpenSim.Region.CoreModules.Agent.TextureDownload
214 { 214 {
215 Scene scene = (Scene)client.Scene; 215 Scene scene = (Scene)client.Scene;
216 216
217 CachedUserInfo profile = scene.CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId); 217 ScenePresence sp = scene.GetScenePresence(client.AgentId);
218 if (profile == null) // Deny unknown user 218 if (sp == null) // Deny unknown user
219 return; 219 return;
220 220
221 IInventoryService invService = scene.InventoryService; 221 IInventoryService invService = scene.InventoryService;
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
index 7ac8bed..50c83b5 100644
--- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
@@ -240,7 +240,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
240 { 240 {
241 string assetID = "j2kCache_" + AssetId.ToString(); 241 string assetID = "j2kCache_" + AssetId.ToString();
242 242
243 AssetBase layerDecodeAsset = new AssetBase(assetID, assetID, (sbyte)AssetType.Notecard); 243 AssetBase layerDecodeAsset = new AssetBase(assetID, assetID, (sbyte)AssetType.Notecard, m_scene.RegionInfo.RegionID.ToString());
244 layerDecodeAsset.Local = true; 244 layerDecodeAsset.Local = true;
245 layerDecodeAsset.Temporary = true; 245 layerDecodeAsset.Temporary = true;
246 246
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
index 1903eb9..b1b7b27 100644
--- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
@@ -330,7 +330,7 @@ namespace OpenSim.Region.CoreModules.Asset
330 //m_log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name); 330 //m_log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name);
331 331
332 if (name != Name) 332 if (name != Name)
333 return; 333 return;
334 334
335 long maxSize = DefaultMaxSize; 335 long maxSize = DefaultMaxSize;
336 int maxCount = DefaultMaxCount; 336 int maxCount = DefaultMaxCount;
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index 9216e0b..967c0a1 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -69,7 +69,7 @@ namespace Flotsam.RegionModules.AssetCache
69 69
70 private readonly List<char> m_InvalidChars = new List<char>(); 70 private readonly List<char> m_InvalidChars = new List<char>();
71 71
72 private int m_LogLevel = 1; 72 private int m_LogLevel = 0;
73 private ulong m_HitRateDisplay = 1; // How often to display hit statistics, given in requests 73 private ulong m_HitRateDisplay = 1; // How often to display hit statistics, given in requests
74 74
75 private static ulong m_Requests; 75 private static ulong m_Requests;
@@ -156,7 +156,7 @@ namespace Flotsam.RegionModules.AssetCache
156 m_WaitOnInprogressTimeout = assetConfig.GetInt("WaitOnInprogressTimeout", 3000); 156 m_WaitOnInprogressTimeout = assetConfig.GetInt("WaitOnInprogressTimeout", 3000);
157#endif 157#endif
158 158
159 m_LogLevel = assetConfig.GetInt("LogLevel", 1); 159 m_LogLevel = assetConfig.GetInt("LogLevel", 0);
160 m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1000); 160 m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1000);
161 161
162 m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration)); 162 m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration));
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 144c8d1..22c8937 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -31,7 +31,7 @@ using log4net;
31using Nini.Config; 31using Nini.Config;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications.Cache; 34
35using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
@@ -46,21 +46,16 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
46 46
47 public bool TryGetAvatarAppearance(UUID avatarId, out AvatarAppearance appearance) 47 public bool TryGetAvatarAppearance(UUID avatarId, out AvatarAppearance appearance)
48 { 48 {
49 CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(avatarId); 49 AvatarData avatar = m_scene.AvatarService.GetAvatar(avatarId);
50 //if ((profile != null) && (profile.RootFolder != null)) 50 //if ((profile != null) && (profile.RootFolder != null))
51 if (profile != null) 51 if (avatar != null)
52 { 52 {
53 appearance = m_scene.CommsManager.AvatarService.GetUserAppearance(avatarId); 53 appearance = avatar.ToAvatarAppearance(avatarId);
54 if (appearance != null) 54 return true;
55 {
56 //SetAppearanceAssets(profile, ref appearance);
57 //m_log.DebugFormat("[APPEARANCE]: Found : {0}", appearance.ToString());
58 return true;
59 }
60 } 55 }
61 56
62 appearance = CreateDefault(avatarId);
63 m_log.ErrorFormat("[APPEARANCE]: Appearance not found for {0}, creating default", avatarId); 57 m_log.ErrorFormat("[APPEARANCE]: Appearance not found for {0}, creating default", avatarId);
58 appearance = CreateDefault(avatarId);
64 return false; 59 return false;
65 } 60 }
66 61
@@ -160,21 +155,23 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
160 /// <param name="e"></param> 155 /// <param name="e"></param>
161 public void AvatarIsWearing(Object sender, AvatarWearingArgs e) 156 public void AvatarIsWearing(Object sender, AvatarWearingArgs e)
162 { 157 {
158 m_log.DebugFormat("[APPEARANCE]: AvatarIsWearing");
159
163 IClientAPI clientView = (IClientAPI)sender; 160 IClientAPI clientView = (IClientAPI)sender;
164 ScenePresence avatar = m_scene.GetScenePresence(clientView.AgentId); 161 ScenePresence sp = m_scene.GetScenePresence(clientView.AgentId);
165 162
166 if (avatar == null) 163 if (sp == null)
167 { 164 {
168 m_log.Error("[APPEARANCE]: Avatar is child agent, ignoring AvatarIsWearing event"); 165 m_log.Error("[APPEARANCE]: Avatar is child agent, ignoring AvatarIsWearing event");
169 return; 166 return;
170 } 167 }
171 168
172 AvatarAppearance avatAppearance = null; 169 AvatarAppearance avatAppearance = sp.Appearance;
173 if (!TryGetAvatarAppearance(clientView.AgentId, out avatAppearance)) 170 //if (!TryGetAvatarAppearance(clientView.AgentId, out avatAppearance))
174 { 171 //{
175 m_log.Warn("[APPEARANCE]: We didn't seem to find the appearance, falling back to ScenePresence"); 172 // m_log.Warn("[APPEARANCE]: We didn't seem to find the appearance, falling back to ScenePresence");
176 avatAppearance = avatar.Appearance; 173 // avatAppearance = sp.Appearance;
177 } 174 //}
178 175
179 //m_log.DebugFormat("[APPEARANCE]: Received wearables for {0}", clientView.Name); 176 //m_log.DebugFormat("[APPEARANCE]: Received wearables for {0}", clientView.Name);
180 177
@@ -186,10 +183,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
186 } 183 }
187 } 184 }
188 185
189 SetAppearanceAssets(avatar.UUID, ref avatAppearance); 186 SetAppearanceAssets(sp.UUID, ref avatAppearance);
187 AvatarData adata = new AvatarData(avatAppearance);
188 m_scene.AvatarService.SetAvatar(clientView.AgentId, adata);
190 189
191 m_scene.CommsManager.AvatarService.UpdateUserAppearance(clientView.AgentId, avatAppearance); 190 sp.Appearance = avatAppearance;
192 avatar.Appearance = avatAppearance;
193 } 191 }
194 192
195 public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams) 193 public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams)
@@ -200,7 +198,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
200 198
201 public void UpdateDatabase(UUID user, AvatarAppearance appearance) 199 public void UpdateDatabase(UUID user, AvatarAppearance appearance)
202 { 200 {
203 m_scene.CommsManager.AvatarService.UpdateUserAppearance(user, appearance); 201 //m_log.DebugFormat("[APPEARANCE]: UpdateDatabase");
202 AvatarData adata = new AvatarData(appearance);
203 m_scene.AvatarService.SetAvatar(user, adata);
204 } 204 }
205 205
206 private static byte[] GetDefaultVisualParams() 206 private static byte[] GetDefaultVisualParams()
diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
index 61b6d65..3614915 100644
--- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
@@ -130,7 +130,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule
130 } 130 }
131 else 131 else
132 { 132 {
133 string killer = DeadAvatar.Scene.CommsManager.UUIDNameRequestString(part.OwnerID); 133 string killer = DeadAvatar.Scene.GetUserName(part.OwnerID);
134 DeadAvatar.ControllingClient.SendAgentAlertMessage("You impaled yourself on " + part.Name + " owned by " + killer +"!", true); 134 DeadAvatar.ControllingClient.SendAgentAlertMessage("You impaled yourself on " + part.Name + " owned by " + killer +"!", true);
135 } 135 }
136 //DeadAvatar.Scene. part.ObjectOwner 136 //DeadAvatar.Scene. part.ObjectOwner
@@ -148,13 +148,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule
148 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID) 148 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID)
149 { 149 {
150 ILandObject obj = avatar.Scene.LandChannel.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 150 ILandObject obj = avatar.Scene.LandChannel.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
151 if ((obj.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0) 151 try
152 { 152 {
153 avatar.Invulnerable = false; 153 if ((obj.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0)
154 {
155 avatar.Invulnerable = false;
156 }
157 else
158 {
159 avatar.Invulnerable = true;
160 }
154 } 161 }
155 else 162 catch (Exception)
156 { 163 {
157 avatar.Invulnerable = true;
158 } 164 }
159 } 165 }
160 } 166 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index 72ec869..fac052a 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -31,9 +31,10 @@ using log4net;
31using Nini.Config; 31using Nini.Config;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications.Cache; 34
35using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Services.Interfaces;
37 38
38namespace OpenSim.Region.CoreModules.Avatar.Dialog 39namespace OpenSim.Region.CoreModules.Avatar.Dialog
39{ 40{
@@ -116,12 +117,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
116 UUID avatarID, string objectName, UUID objectID, UUID ownerID, 117 UUID avatarID, string objectName, UUID objectID, UUID ownerID,
117 string message, UUID textureID, int ch, string[] buttonlabels) 118 string message, UUID textureID, int ch, string[] buttonlabels)
118 { 119 {
119 CachedUserInfo info = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(ownerID); 120 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerID);
120 string ownerFirstName, ownerLastName; 121 string ownerFirstName, ownerLastName;
121 if (info != null) 122 if (account != null)
122 { 123 {
123 ownerFirstName = info.UserProfile.FirstName; 124 ownerFirstName = account.FirstName;
124 ownerLastName = info.UserProfile.SurName; 125 ownerLastName = account.LastName;
125 } 126 }
126 else 127 else
127 { 128 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 086d4fe..de324c0 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -28,7 +28,6 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Net;
32using System.Reflection; 31using System.Reflection;
33using log4net; 32using log4net;
34using Nini.Config; 33using Nini.Config;
@@ -36,1119 +35,721 @@ using Nwc.XmlRpc;
36using OpenMetaverse; 35using OpenMetaverse;
37using OpenSim.Framework; 36using OpenSim.Framework;
38using OpenSim.Framework.Communications; 37using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
42using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
41using OpenSim.Services.Connectors.Friends;
42using OpenSim.Server.Base;
43using OpenSim.Framework.Servers.HttpServer;
44using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
45using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
43using GridRegion = OpenSim.Services.Interfaces.GridRegion; 46using GridRegion = OpenSim.Services.Interfaces.GridRegion;
44 47
45namespace OpenSim.Region.CoreModules.Avatar.Friends 48namespace OpenSim.Region.CoreModules.Avatar.Friends
46{ 49{
47 /* 50 public class FriendsModule : ISharedRegionModule, IFriendsModule
48 This module handles adding/removing friends, and the the presence
49 notification process for login/logoff of friends.
50
51 The presence notification works as follows:
52 - After the user initially connects to a region (so we now have a UDP
53 connection to work with), this module fetches the friends of user
54 (those are cached), their on-/offline status, and info about the
55 region they are in from the MessageServer.
56 - (*) It then informs the user about the on-/offline status of her friends.
57 - It then informs all online friends currently on this region-server about
58 user's new online status (this will save some network traffic, as local
59 messages don't have to be transferred inter-region, and it will be all
60 that has to be done in Standalone Mode).
61 - For the rest of the online friends (those not on this region-server),
62 this module uses the provided region-information to map users to
63 regions, and sends one notification to every region containing the
64 friends to inform on that server.
65 - The region-server will handle that in the following way:
66 - If it finds the friend, it informs her about the user being online.
67 - If it doesn't find the friend (maybe she TPed away in the meantime),
68 it stores that information.
69 - After it processed all friends, it returns the list of friends it
70 couldn't find.
71 - If this list isn't empty, the FriendsModule re-requests information
72 about those online friends that have been missed and starts at (*)
73 again until all friends have been found, or until it tried 3 times
74 (to prevent endless loops due to some uncaught error).
75
76 NOTE: Online/Offline notifications don't need to be sent on region change.
77
78 We implement two XMLRpc handlers here, handling all the inter-region things
79 we have to handle:
80 - On-/Offline-Notifications (bulk)
81 - Terminate Friendship messages (single)
82 */
83
84 public class FriendsModule : IRegionModule, IFriendsModule
85 { 51 {
86 private class Transaction 52 protected class UserFriendData
87 { 53 {
88 public UUID agentID; 54 public UUID PrincipalID;
89 public string agentName; 55 public FriendInfo[] Friends;
90 public uint count; 56 public int Refcount;
57 public UUID RegionID;
91 58
92 public Transaction(UUID agentID, string agentName) 59 public bool IsFriend(string friend)
93 { 60 {
94 this.agentID = agentID; 61 foreach (FriendInfo fi in Friends)
95 this.agentName = agentName; 62 {
96 this.count = 1; 63 if (fi.Friend == friend)
64 return true;
65 }
66
67 return false;
97 } 68 }
98 } 69 }
99 70
100 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 71 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
101 72
102 private Cache m_friendLists = new Cache(CacheFlags.AllowUpdate); 73 protected List<Scene> m_Scenes = new List<Scene>();
103 74
104 private Dictionary<UUID, ulong> m_rootAgents = new Dictionary<UUID, ulong>(); 75 protected IPresenceService m_PresenceService = null;
76 protected IFriendsService m_FriendsService = null;
77 protected FriendsSimConnector m_FriendsSimConnector;
105 78
106 private Dictionary<UUID, UUID> m_pendingCallingcardRequests = new Dictionary<UUID,UUID>(); 79 protected Dictionary<UUID, UserFriendData> m_Friends =
80 new Dictionary<UUID, UserFriendData>();
107 81
108 private Scene m_initialScene; // saves a lookup if we don't have a specific scene 82 protected List<UUID> m_NeedsListOfFriends = new List<UUID>();
109 private Dictionary<ulong, Scene> m_scenes = new Dictionary<ulong,Scene>();
110 private IMessageTransferModule m_TransferModule = null;
111 83
112 private IGridService m_gridServices = null; 84 protected IPresenceService PresenceService
113
114 #region IRegionModule Members
115
116 public void Initialise(Scene scene, IConfigSource config)
117 { 85 {
118 lock (m_scenes) 86 get
119 { 87 {
120 if (m_scenes.Count == 0) 88 if (m_PresenceService == null)
121 { 89 {
122 MainServer.Instance.AddXmlRPCHandler("presence_update_bulk", processPresenceUpdateBulk); 90 if (m_Scenes.Count > 0)
123 MainServer.Instance.AddXmlRPCHandler("terminate_friend", processTerminateFriend); 91 m_PresenceService = m_Scenes[0].RequestModuleInterface<IPresenceService>();
124 m_friendLists.DefaultTTL = new TimeSpan(1, 0, 0); // store entries for one hour max
125 m_initialScene = scene;
126 } 92 }
127 93
128 if (!m_scenes.ContainsKey(scene.RegionInfo.RegionHandle)) 94 return m_PresenceService;
129 m_scenes[scene.RegionInfo.RegionHandle] = scene;
130 } 95 }
131
132 scene.RegisterModuleInterface<IFriendsModule>(this);
133
134 scene.EventManager.OnNewClient += OnNewClient;
135 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
136 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
137 scene.EventManager.OnMakeChildAgent += MakeChildAgent;
138 scene.EventManager.OnClientClosed += ClientClosed;
139 } 96 }
140 97
141 public void PostInitialise() 98 protected IFriendsService FriendsService
142 { 99 {
143 if (m_scenes.Count > 0) 100 get
144 { 101 {
145 m_TransferModule = m_initialScene.RequestModuleInterface<IMessageTransferModule>(); 102 if (m_FriendsService == null)
146 m_gridServices = m_initialScene.GridService; 103 {
147 } 104 if (m_Scenes.Count > 0)
148 if (m_TransferModule == null) 105 m_FriendsService = m_Scenes[0].RequestModuleInterface<IFriendsService>();
149 m_log.Error("[FRIENDS]: Unable to find a message transfer module, friendship offers will not work"); 106 }
150 }
151
152 public void Close()
153 {
154 }
155 107
156 public string Name 108 return m_FriendsService;
157 { 109 }
158 get { return "FriendsModule"; }
159 } 110 }
160 111
161 public bool IsSharedModule 112 protected IGridService GridService
162 { 113 {
163 get { return true; } 114 get
115 {
116 return m_Scenes[0].GridService;
117 }
164 } 118 }
165 119
166 #endregion 120 public IScene Scene
167
168 #region IInterregionFriendsComms
169
170 public List<UUID> InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List<UUID> friends, bool online)
171 { 121 {
172 List<UUID> tpdAway = new List<UUID>(); 122 get
173
174 // destRegionHandle is a region on another server
175 uint x = 0, y = 0;
176 Utils.LongToUInts(destRegionHandle, out x, out y);
177 GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y);
178 if (info != null)
179 { 123 {
180 string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk"; 124 if (m_Scenes.Count > 0)
181 125 return m_Scenes[0];
182 Hashtable reqParams = new Hashtable(); 126 else
183 reqParams["agentID"] = agentId.ToString(); 127 return null;
184 reqParams["agentOnline"] = online;
185 int count = 0;
186 foreach (UUID uuid in friends)
187 {
188 reqParams["friendID_" + count++] = uuid.ToString();
189 }
190 reqParams["friendCount"] = count;
191
192 IList parameters = new ArrayList();
193 parameters.Add(reqParams);
194 try
195 {
196 XmlRpcRequest request = new XmlRpcRequest("presence_update_bulk", parameters);
197 XmlRpcResponse response = request.Send(httpServer, 5000);
198 Hashtable respData = (Hashtable)response.Value;
199
200 count = (int)respData["friendCount"];
201 for (int i = 0; i < count; ++i)
202 {
203 UUID uuid;
204 if (UUID.TryParse((string)respData["friendID_" + i], out uuid)) tpdAway.Add(uuid);
205 }
206 }
207 catch (WebException e)
208 {
209 // Ignore connect failures, simulators come and go
210 //
211 if (!e.Message.Contains("ConnectFailure"))
212 {
213 m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e);
214 }
215 }
216 catch (Exception e)
217 {
218 m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e);
219 }
220 } 128 }
221 else m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}???", destRegionHandle);
222
223 return tpdAway;
224 } 129 }
225 130
226 public bool TriggerTerminateFriend(ulong destRegionHandle, UUID agentID, UUID exFriendID) 131 public void Initialise(IConfigSource config)
227 { 132 {
228 // destRegionHandle is a region on another server 133 IConfig friendsConfig = config.Configs["Friends"];
229 uint x = 0, y = 0; 134 if (friendsConfig != null)
230 Utils.LongToUInts(destRegionHandle, out x, out y);
231 GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y);
232 if (info == null)
233 { 135 {
234 m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}", destRegionHandle); 136 int mPort = friendsConfig.GetInt("Port", 0);
235 return false; // region not found???
236 }
237 137
238 string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk"; 138 string connector = friendsConfig.GetString("Connector", String.Empty);
139 Object[] args = new Object[] { config };
239 140
240 Hashtable reqParams = new Hashtable(); 141 m_FriendsService = ServerUtils.LoadPlugin<IFriendsService>(connector, args);
241 reqParams["agentID"] = agentID.ToString(); 142 m_FriendsSimConnector = new FriendsSimConnector();
242 reqParams["friendID"] = exFriendID.ToString();
243 143
244 IList parameters = new ArrayList(); 144 // Instantiate the request handler
245 parameters.Add(reqParams); 145 IHttpServer server = MainServer.GetHttpServer((uint)mPort);
246 try 146 server.AddStreamHandler(new FriendsRequestHandler(this));
247 {
248 XmlRpcRequest request = new XmlRpcRequest("terminate_friend", parameters);
249 XmlRpcResponse response = request.Send(httpServer, 5000);
250 Hashtable respData = (Hashtable)response.Value;
251 147
252 return (bool)respData["success"];
253 } 148 }
254 catch (Exception e) 149
150 if (m_FriendsService == null)
255 { 151 {
256 m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e); 152 m_log.Error("[FRIENDS]: No Connector defined in section Friends, or filed to load, cannot continue");
257 return false; 153 throw new Exception("Connector load error");
258 } 154 }
155
259 } 156 }
260 157
261 #endregion 158 public void PostInitialise()
159 {
160 }
262 161
263 #region Incoming XMLRPC messages 162 public void Close()
264 /// <summary>
265 /// Receive presence information changes about clients in other regions.
266 /// </summary>
267 /// <param name="req"></param>
268 /// <returns></returns>
269 public XmlRpcResponse processPresenceUpdateBulk(XmlRpcRequest req, IPEndPoint remoteClient)
270 { 163 {
271 Hashtable requestData = (Hashtable)req.Params[0]; 164 }
272 165
273 List<UUID> friendsNotHere = new List<UUID>(); 166 public void AddRegion(Scene scene)
167 {
168 m_Scenes.Add(scene);
169 scene.RegisterModuleInterface<IFriendsModule>(this);
274 170
275 // this is called with the expectation that all the friends in the request are on this region-server. 171 scene.EventManager.OnNewClient += OnNewClient;
276 // But as some time passed since we checked (on the other region-server, via the MessagingServer), 172 scene.EventManager.OnClientClosed += OnClientClosed;
277 // some of the friends might have teleported away. 173 scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
278 // Actually, even now, between this line and the sending below, some people could TP away. So, 174 scene.EventManager.OnMakeChildAgent += OnMakeChildAgent;
279 // we'll have to lock the m_rootAgents list for the duration to prevent/delay that. 175 scene.EventManager.OnClientLogin += OnClientLogin;
280 lock (m_rootAgents) 176 }
281 {
282 List<ScenePresence> friendsHere = new List<ScenePresence>();
283
284 try
285 {
286 UUID agentID = new UUID((string)requestData["agentID"]);
287 bool agentOnline = (bool)requestData["agentOnline"];
288 int count = (int)requestData["friendCount"];
289 for (int i = 0; i < count; ++i)
290 {
291 UUID uuid;
292 if (UUID.TryParse((string)requestData["friendID_" + i], out uuid))
293 {
294 if (m_rootAgents.ContainsKey(uuid)) friendsHere.Add(GetRootPresenceFromAgentID(uuid));
295 else friendsNotHere.Add(uuid);
296 }
297 }
298 177
299 // now send, as long as they are still here... 178 public void RegionLoaded(Scene scene)
300 UUID[] agentUUID = new UUID[] { agentID }; 179 {
301 if (agentOnline) 180 }
302 {
303 foreach (ScenePresence agent in friendsHere)
304 {
305 agent.ControllingClient.SendAgentOnline(agentUUID);
306 }
307 }
308 else
309 {
310 foreach (ScenePresence agent in friendsHere)
311 {
312 agent.ControllingClient.SendAgentOffline(agentUUID);
313 }
314 }
315 }
316 catch(Exception e)
317 {
318 m_log.Warn("[FRIENDS]: Got exception while parsing presence_update_bulk request:", e);
319 }
320 }
321 181
322 // no need to lock anymore; if TPs happen now, worst case is that we have an additional agent in this region, 182 public void RemoveRegion(Scene scene)
323 // which should be caught on the next iteration... 183 {
324 Hashtable result = new Hashtable(); 184 m_Scenes.Remove(scene);
325 int idx = 0; 185 }
326 foreach (UUID uuid in friendsNotHere)
327 {
328 result["friendID_" + idx++] = uuid.ToString();
329 }
330 result["friendCount"] = idx;
331 186
332 XmlRpcResponse response = new XmlRpcResponse(); 187 public string Name
333 response.Value = result; 188 {
189 get { return "FriendsModule"; }
190 }
334 191
335 return response; 192 public Type ReplaceableInterface
193 {
194 get { return null; }
336 } 195 }
337 196
338 public XmlRpcResponse processTerminateFriend(XmlRpcRequest req, IPEndPoint remoteClient) 197 public uint GetFriendPerms(UUID principalID, UUID friendID)
339 { 198 {
340 Hashtable requestData = (Hashtable)req.Params[0]; 199 if (!m_Friends.ContainsKey(principalID))
200 return 0;
341 201
342 bool success = false; 202 UserFriendData data = m_Friends[principalID];
343 203
344 UUID agentID; 204 foreach (FriendInfo fi in data.Friends)
345 UUID friendID;
346 if (requestData.ContainsKey("agentID") && UUID.TryParse((string)requestData["agentID"], out agentID) &&
347 requestData.ContainsKey("friendID") && UUID.TryParse((string)requestData["friendID"], out friendID))
348 { 205 {
349 // try to find it and if it is there, prevent it to vanish before we sent the message 206 if (fi.Friend == friendID.ToString())
350 lock (m_rootAgents) 207 return (uint)fi.TheirFlags;
351 {
352 if (m_rootAgents.ContainsKey(agentID))
353 {
354 m_log.DebugFormat("[FRIEND]: Sending terminate friend {0} to agent {1}", friendID, agentID);
355 GetRootPresenceFromAgentID(agentID).ControllingClient.SendTerminateFriend(friendID);
356 success = true;
357 }
358 }
359 } 208 }
360 209 return 0;
361 // return whether we were successful
362 Hashtable result = new Hashtable();
363 result["success"] = success;
364
365 XmlRpcResponse response = new XmlRpcResponse();
366 response.Value = result;
367 return response;
368 } 210 }
369 211
370 #endregion
371
372 #region Scene events
373
374 private void OnNewClient(IClientAPI client) 212 private void OnNewClient(IClientAPI client)
375 { 213 {
376 // All friends establishment protocol goes over instant message
377 // There's no way to send a message from the sim
378 // to a user to 'add a friend' without causing dialog box spam
379
380 // Subscribe to instant messages
381 client.OnInstantMessage += OnInstantMessage; 214 client.OnInstantMessage += OnInstantMessage;
382
383 // Friend list management
384 client.OnApproveFriendRequest += OnApproveFriendRequest; 215 client.OnApproveFriendRequest += OnApproveFriendRequest;
385 client.OnDenyFriendRequest += OnDenyFriendRequest; 216 client.OnDenyFriendRequest += OnDenyFriendRequest;
386 client.OnTerminateFriendship += OnTerminateFriendship; 217 client.OnTerminateFriendship += OnTerminateFriendship;
387 218
388 // ... calling card handling... 219 client.OnGrantUserRights += OnGrantUserRights;
389 client.OnOfferCallingCard += OnOfferCallingCard;
390 client.OnAcceptCallingCard += OnAcceptCallingCard;
391 client.OnDeclineCallingCard += OnDeclineCallingCard;
392 220
393 // we need this one exactly once per agent session (see comments in the handler below)
394 client.OnEconomyDataRequest += OnEconomyDataRequest;
395
396 // if it leaves, we want to know, too
397 client.OnLogout += OnLogout; 221 client.OnLogout += OnLogout;
398
399 client.OnGrantUserRights += GrantUserFriendRights;
400 client.OnTrackAgent += FindAgent;
401 client.OnFindAgent += FindAgent;
402 222
223 if (m_Friends.ContainsKey(client.AgentId))
224 {
225 m_Friends[client.AgentId].Refcount++;
226 return;
227 }
228
229 UserFriendData newFriends = new UserFriendData();
230
231 newFriends.PrincipalID = client.AgentId;
232 newFriends.Friends = m_FriendsService.GetFriends(client.AgentId);
233 newFriends.Refcount = 1;
234 newFriends.RegionID = UUID.Zero;
235
236 m_Friends.Add(client.AgentId, newFriends);
237
238 //StatusChange(client.AgentId, true);
403 } 239 }
404 240
405 private void ClientClosed(UUID AgentId, Scene scene) 241 private void OnClientClosed(UUID agentID, Scene scene)
406 { 242 {
407 // agent's client was closed. As we handle logout in OnLogout, this here has only to handle 243 if (m_Friends.ContainsKey(agentID))
408 // TPing away (root agent is closed) or TPing/crossing in a region far enough away (client
409 // agent is closed).
410 // NOTE: In general, this doesn't mean that the agent logged out, just that it isn't around
411 // in one of the regions here anymore.
412 lock (m_rootAgents)
413 { 244 {
414 if (m_rootAgents.ContainsKey(AgentId)) 245 if (m_Friends[agentID].Refcount == 1)
415 { 246 m_Friends.Remove(agentID);
416 m_rootAgents.Remove(AgentId); 247 else
417 } 248 m_Friends[agentID].Refcount--;
418 } 249 }
419 } 250 }
420 251
421 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID) 252 private void OnLogout(IClientAPI client)
422 { 253 {
423 lock (m_rootAgents) 254 StatusChange(client.AgentId, false);
424 { 255 m_Friends.Remove(client.AgentId);
425 m_rootAgents[avatar.UUID] = avatar.RegionHandle;
426 // Claim User! my user! Mine mine mine!
427 }
428 } 256 }
429 257
430 private void MakeChildAgent(ScenePresence avatar) 258 private void OnMakeRootAgent(ScenePresence sp)
431 { 259 {
432 lock (m_rootAgents) 260 UUID agentID = sp.ControllingClient.AgentId;
261
262 if (m_Friends.ContainsKey(agentID))
433 { 263 {
434 if (m_rootAgents.ContainsKey(avatar.UUID)) 264 if (m_Friends[agentID].RegionID == UUID.Zero && m_Friends[agentID].Friends == null)
435 { 265 {
436 // only delete if the region matches. As this is a shared module, the avatar could be 266 m_Friends[agentID].Friends =
437 // root agent in another region on this server. 267 m_FriendsService.GetFriends(agentID);
438 if (m_rootAgents[avatar.UUID] == avatar.RegionHandle)
439 {
440 m_rootAgents.Remove(avatar.UUID);
441// m_log.Debug("[FRIEND]: Removing " + avatar.Firstname + " " + avatar.Lastname + " as a root agent");
442 }
443 } 268 }
269 m_Friends[agentID].RegionID =
270 sp.ControllingClient.Scene.RegionInfo.RegionID;
444 } 271 }
445 } 272 }
446 #endregion
447 273
448 private ScenePresence GetRootPresenceFromAgentID(UUID AgentID) 274
275 private void OnMakeChildAgent(ScenePresence sp)
449 { 276 {
450 ScenePresence returnAgent = null; 277 UUID agentID = sp.ControllingClient.AgentId;
451 lock (m_scenes) 278
279 if (m_Friends.ContainsKey(agentID))
452 { 280 {
453 ScenePresence queryagent = null; 281 if (m_Friends[agentID].RegionID == sp.ControllingClient.Scene.RegionInfo.RegionID)
454 foreach (Scene scene in m_scenes.Values) 282 m_Friends[agentID].RegionID = UUID.Zero;
455 {
456 queryagent = scene.GetScenePresence(AgentID);
457 if (queryagent != null)
458 {
459 if (!queryagent.IsChildAgent)
460 {
461 returnAgent = queryagent;
462 break;
463 }
464 }
465 }
466 } 283 }
467 return returnAgent;
468 } 284 }
469 285
470 private ScenePresence GetAnyPresenceFromAgentID(UUID AgentID) 286 private void OnClientLogin(IClientAPI client)
471 { 287 {
472 ScenePresence returnAgent = null; 288 UUID agentID = client.AgentId;
473 lock (m_scenes) 289
474 { 290 // Inform the friends that this user is online
475 ScenePresence queryagent = null; 291 StatusChange(agentID, true);
476 foreach (Scene scene in m_scenes.Values) 292
293 // Register that we need to send the list of online friends to this user
294 lock (m_NeedsListOfFriends)
295 if (!m_NeedsListOfFriends.Contains(agentID))
477 { 296 {
478 queryagent = scene.GetScenePresence(AgentID); 297 m_NeedsListOfFriends.Add(agentID);
479 if (queryagent != null)
480 {
481 returnAgent = queryagent;
482 break;
483 }
484 } 298 }
485 }
486 return returnAgent;
487 } 299 }
488 300
489 public void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage) 301 public void SendFriendsOnlineIfNeeded(IClientAPI client)
490 { 302 {
491 CachedUserInfo userInfo = m_initialScene.CommsManager.UserProfileCacheService.GetUserDetails(fromUserId); 303 UUID agentID = client.AgentId;
492 304 if (m_NeedsListOfFriends.Contains(agentID))
493 if (userInfo != null)
494 { 305 {
495 GridInstantMessage msg = new GridInstantMessage( 306 if (!m_Friends.ContainsKey(agentID))
496 toUserClient.Scene, fromUserId, userInfo.UserProfile.Name, toUserClient.AgentId, 307 {
497 (byte)InstantMessageDialog.FriendshipOffered, offerMessage, false, Vector3.Zero); 308 m_log.DebugFormat("[FRIENDS MODULE]: agent {0} not found in local cache", agentID);
498 309 return;
499 FriendshipOffered(msg); 310 }
500 }
501 else
502 {
503 m_log.ErrorFormat("[FRIENDS]: No user found for id {0} in OfferFriendship()", fromUserId);
504 }
505 }
506 311
507 #region FriendRequestHandling 312 //
313 // Send the friends online
314 //
315 List<UUID> online = GetOnlineFriends(agentID);
316 if (online.Count > 0)
317 {
318 m_log.DebugFormat("[FRIENDS MODULE]: User {0} in region {1} has {2} friends online", client.AgentId, client.Scene.RegionInfo.RegionName, online.Count);
319 client.SendAgentOnline(online.ToArray());
320 }
508 321
509 private void OnInstantMessage(IClientAPI client, GridInstantMessage im) 322 //
510 { 323 // Send outstanding friendship offers
511 // Friend Requests go by Instant Message.. using the dialog param 324 //
512 // https://wiki.secondlife.com/wiki/ImprovedInstantMessage 325 if (m_Friends.ContainsKey(agentID))
326 {
327 List<string> outstanding = new List<string>();
513 328
514 if (im.dialog == (byte)InstantMessageDialog.FriendshipOffered) // 38 329 foreach (FriendInfo fi in m_Friends[agentID].Friends)
515 { 330 if (fi.TheirFlags == -1)
516 // fromAgentName is the *destination* name (the friend we offer friendship to) 331 outstanding.Add(fi.Friend);
517 ScenePresence initiator = GetAnyPresenceFromAgentID(new UUID(im.fromAgentID)); 332
518 im.fromAgentName = initiator != null ? initiator.Name : "(hippo)"; 333 GridInstantMessage im = new GridInstantMessage(client.Scene, UUID.Zero, "", agentID, (byte)InstantMessageDialog.FriendshipOffered, "Will you be my friend?", true, Vector3.Zero);
519 334 foreach (string fid in outstanding)
520 FriendshipOffered(im); 335 {
521 } 336 try
522 else if (im.dialog == (byte)InstantMessageDialog.FriendshipAccepted) // 39 337 {
523 { 338 im.fromAgentID = new Guid(fid);
524 FriendshipAccepted(client, im); 339 }
525 } 340 catch
526 else if (im.dialog == (byte)InstantMessageDialog.FriendshipDeclined) // 40 341 {
527 { 342 continue;
528 FriendshipDeclined(client, im); 343 }
529 }
530 }
531
532 /// <summary>
533 /// Invoked when a user offers a friendship.
534 /// </summary>
535 ///
536 /// <param name="im"></param>
537 /// <param name="client"></param>
538 private void FriendshipOffered(GridInstantMessage im)
539 {
540 // this is triggered by the initiating agent:
541 // A local agent offers friendship to some possibly remote friend.
542 // A IM is triggered, processed here and sent to the friend (possibly in a remote region).
543 344
544 m_log.DebugFormat("[FRIEND]: Offer(38) - From: {0}, FromName: {1} To: {2}, Session: {3}, Message: {4}, Offline {5}", 345 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, new UUID(im.fromAgentID));
545 im.fromAgentID, im.fromAgentName, im.toAgentID, im.imSessionID, im.message, im.offline); 346 im.fromAgentName = account.FirstName + " " + account.LastName;
546 347
547 // 1.20 protocol sends an UUID in the message field, instead of the friendship offer text. 348 PresenceInfo[] presences = PresenceService.GetAgents(new string[] { fid });
548 // For interoperability, we have to clear that 349 PresenceInfo presence = PresenceInfo.GetOnlinePresence(presences);
549 if (Util.isUUID(im.message)) im.message = ""; 350 if (presence != null)
351 im.offline = 0;
550 352
551 // be sneeky and use the initiator-UUID as transactionID. This means we can be stateless. 353 im.imSessionID = im.fromAgentID;
552 // we have to look up the agent name on friendship-approval, though.
553 im.imSessionID = im.fromAgentID;
554 354
555 if (m_TransferModule != null) 355 // Finally
556 { 356 LocalFriendshipOffered(agentID, im);
557 // Send it to whoever is the destination.
558 // If new friend is local, it will send an IM to the viewer.
559 // If new friend is remote, it will cause a OnGridInstantMessage on the remote server
560 m_TransferModule.SendInstantMessage(
561 im,
562 delegate(bool success)
563 {
564 m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
565 } 357 }
566 );
567 }
568 }
569
570 /// <summary>
571 /// Invoked when a user accepts a friendship offer.
572 /// </summary>
573 /// <param name="im"></param>
574 /// <param name="client"></param>
575 private void FriendshipAccepted(IClientAPI client, GridInstantMessage im)
576 {
577 m_log.DebugFormat("[FRIEND]: 39 - from client {0}, agent {2} {3}, imsession {4} to {5}: {6} (dialog {7})",
578 client.AgentId, im.fromAgentID, im.fromAgentName, im.imSessionID, im.toAgentID, im.message, im.dialog);
579 }
580
581 /// <summary>
582 /// Invoked when a user declines a friendship offer.
583 /// </summary>
584 /// May not currently be used - see OnDenyFriendRequest() instead
585 /// <param name="im"></param>
586 /// <param name="client"></param>
587 private void FriendshipDeclined(IClientAPI client, GridInstantMessage im)
588 {
589 UUID fromAgentID = new UUID(im.fromAgentID);
590 UUID toAgentID = new UUID(im.toAgentID);
591
592 // declining the friendship offer causes a type 40 IM being sent to the (possibly remote) initiator
593 // toAgentID is initiator, fromAgentID declined friendship
594 m_log.DebugFormat("[FRIEND]: 40 - from client {0}, agent {1} {2}, imsession {3} to {4}: {5} (dialog {6})",
595 client != null ? client.AgentId.ToString() : "<null>",
596 fromAgentID, im.fromAgentName, im.imSessionID, im.toAgentID, im.message, im.dialog);
597
598 // Send the decline to whoever is the destination.
599 GridInstantMessage msg
600 = new GridInstantMessage(
601 client.Scene, fromAgentID, client.Name, toAgentID,
602 im.dialog, im.message, im.offline != 0, im.Position);
603
604 // If new friend is local, it will send an IM to the viewer.
605 // If new friend is remote, it will cause a OnGridInstantMessage on the remote server
606 m_TransferModule.SendInstantMessage(msg,
607 delegate(bool success) {
608 m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
609 } 358 }
610 );
611 }
612
613 private void OnGridInstantMessage(GridInstantMessage msg)
614 {
615 // This event won't be raised unless we have that agent,
616 // so we can depend on the above not trying to send
617 // via grid again
618 //m_log.DebugFormat("[FRIEND]: Got GridIM from {0}, to {1}, imSession {2}, message {3}, dialog {4}",
619 // msg.fromAgentID, msg.toAgentID, msg.imSessionID, msg.message, msg.dialog);
620
621 if (msg.dialog == (byte)InstantMessageDialog.FriendshipOffered ||
622 msg.dialog == (byte)InstantMessageDialog.FriendshipAccepted ||
623 msg.dialog == (byte)InstantMessageDialog.FriendshipDeclined)
624 {
625 // this should succeed as we *know* the root agent is here.
626 m_TransferModule.SendInstantMessage(msg,
627 delegate(bool success) {
628 //m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
629 }
630 );
631 }
632 359
633 if (msg.dialog == (byte)InstantMessageDialog.FriendshipAccepted) 360 lock (m_NeedsListOfFriends)
634 { 361 m_NeedsListOfFriends.Remove(agentID);
635 // for accept friendship, we have to do a bit more
636 ApproveFriendship(new UUID(msg.fromAgentID), new UUID(msg.toAgentID), msg.fromAgentName);
637 } 362 }
638 } 363 }
639 364
640 private void ApproveFriendship(UUID fromAgentID, UUID toAgentID, string fromName) 365 List<UUID> GetOnlineFriends(UUID userID)
641 { 366 {
642 m_log.DebugFormat("[FRIEND]: Approve friendship from {0} (ID: {1}) to {2}", 367 List<string> friendList = new List<string>();
643 fromAgentID, fromName, toAgentID);
644 368
645 // a new friend was added in the initiator's and friend's data, so the cache entries are wrong now. 369 foreach (FriendInfo fi in m_Friends[userID].Friends)
646 lock (m_friendLists)
647 { 370 {
648 m_friendLists.Invalidate(fromAgentID.ToString()); 371 if (((fi.TheirFlags & 1) != 0) && (fi.TheirFlags != -1))
649 m_friendLists.Invalidate(toAgentID.ToString()); 372 friendList.Add(fi.Friend);
650 } 373 }
651 374
652 // now send presence update and add a calling card for the new friend 375 PresenceInfo[] presence = PresenceService.GetAgents(friendList.ToArray());
653 376
654 ScenePresence initiator = GetAnyPresenceFromAgentID(toAgentID); 377 List<UUID> online = new List<UUID>();
655 if (initiator == null)
656 {
657 // quite wrong. Shouldn't happen.
658 m_log.WarnFormat("[FRIEND]: Coudn't find initiator of friend request {0}", toAgentID);
659 return;
660 }
661 378
662 m_log.DebugFormat("[FRIEND]: Tell {0} that {1} is online", 379 foreach (PresenceInfo pi in presence)
663 initiator.Name, fromName);
664 // tell initiator that friend is online
665 initiator.ControllingClient.SendAgentOnline(new UUID[] { fromAgentID });
666
667 // find the folder for the friend...
668 //InventoryFolderImpl folder =
669 // initiator.Scene.CommsManager.UserProfileCacheService.GetUserDetails(toAgentID).FindFolderForType((int)InventoryType.CallingCard);
670 IInventoryService invService = initiator.Scene.InventoryService;
671 InventoryFolderBase folder = invService.GetFolderForType(toAgentID, AssetType.CallingCard);
672 if (folder != null)
673 { 380 {
674 // ... and add the calling card 381 if (pi.Online)
675 CreateCallingCard(initiator.ControllingClient, fromAgentID, folder.ID, fromName); 382 {
383 online.Add(new UUID(pi.UserID));
384 //m_log.DebugFormat("[XXX] {0} friend online {1}", userID, pi.UserID);
385 }
676 } 386 }
387
388 return online;
677 } 389 }
678 390
679 private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders) 391 //
392 // Find the client for a ID
393 //
394 public IClientAPI LocateClientObject(UUID agentID)
680 { 395 {
681 m_log.DebugFormat("[FRIEND]: Got approve friendship from {0} {1}, agentID {2}, tid {3}", 396 Scene scene = GetClientScene(agentID);
682 client.Name, client.AgentId, agentID, friendID); 397 if(scene == null)
683 398 return null;
684 // store the new friend persistently for both avatars
685 m_initialScene.StoreAddFriendship(friendID, agentID, (uint) FriendRights.CanSeeOnline);
686 399
687 // The cache entries aren't valid anymore either, as we just added a friend to both sides. 400 ScenePresence presence = scene.GetScenePresence(agentID);
688 lock (m_friendLists) 401 if(presence == null)
689 { 402 return null;
690 m_friendLists.Invalidate(agentID.ToString());
691 m_friendLists.Invalidate(friendID.ToString());
692 }
693 403
694 // if it's a local friend, we don't have to do the lookup 404 return presence.ControllingClient;
695 ScenePresence friendPresence = GetAnyPresenceFromAgentID(friendID); 405 }
696 406
697 if (friendPresence != null) 407 //
408 // Find the scene for an agent
409 //
410 private Scene GetClientScene(UUID agentId)
411 {
412 lock (m_Scenes)
698 { 413 {
699 m_log.Debug("[FRIEND]: Local agent detected."); 414 foreach (Scene scene in m_Scenes)
700 415 {
701 // create calling card 416 ScenePresence presence = scene.GetScenePresence(agentId);
702 CreateCallingCard(client, friendID, callingCardFolders[0], friendPresence.Name); 417 if (presence != null)
703 418 {
704 // local message means OnGridInstantMessage won't be triggered, so do the work here. 419 if (!presence.IsChildAgent)
705 friendPresence.ControllingClient.SendInstantMessage( 420 return scene;
706 new GridInstantMessage(client.Scene, agentID, 421 }
707 client.Name, friendID, 422 }
708 (byte)InstantMessageDialog.FriendshipAccepted,
709 agentID.ToString(), false, Vector3.Zero));
710 ApproveFriendship(agentID, friendID, client.Name);
711 } 423 }
712 else 424 return null;
713 { 425 }
714 m_log.Debug("[FRIEND]: Remote agent detected.");
715
716 // fetch the friend's name for the calling card.
717 CachedUserInfo info = m_initialScene.CommsManager.UserProfileCacheService.GetUserDetails(friendID);
718
719 // create calling card
720 CreateCallingCard(client, friendID, callingCardFolders[0],
721 info.UserProfile.FirstName + " " + info.UserProfile.SurName);
722 426
723 // Compose (remote) response to friend. 427 /// <summary>
724 GridInstantMessage msg = new GridInstantMessage(client.Scene, agentID, client.Name, friendID, 428 /// Caller beware! Call this only for root agents.
725 (byte)InstantMessageDialog.FriendshipAccepted, 429 /// </summary>
726 agentID.ToString(), false, Vector3.Zero); 430 /// <param name="agentID"></param>
727 if (m_TransferModule != null) 431 /// <param name="online"></param>
432 private void StatusChange(UUID agentID, bool online)
433 {
434 if (m_Friends.ContainsKey(agentID))
435 {
436 List<FriendInfo> friendList = new List<FriendInfo>();
437 foreach (FriendInfo fi in m_Friends[agentID].Friends)
728 { 438 {
729 m_TransferModule.SendInstantMessage(msg, 439 if (((fi.MyFlags & 1) != 0) && (fi.TheirFlags != -1))
730 delegate(bool success) { 440 friendList.Add(fi);
731 m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); 441 }
732 } 442 foreach (FriendInfo fi in friendList)
733 ); 443 {
444 // Notify about this user status
445 StatusNotify(fi, agentID, online);
734 } 446 }
735 } 447 }
736
737 // tell client that new friend is online
738 client.SendAgentOnline(new UUID[] { friendID });
739 } 448 }
740 449
741 private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders) 450 private void StatusNotify(FriendInfo friend, UUID userID, bool online)
742 { 451 {
743 m_log.DebugFormat("[FRIEND]: Got deny friendship from {0} {1}, agentID {2}, tid {3}", 452 UUID friendID = UUID.Zero;
744 client.Name, client.AgentId, agentID, friendID); 453
745 454 if (UUID.TryParse(friend.Friend, out friendID))
746 // Compose response to other agent.
747 GridInstantMessage msg = new GridInstantMessage(client.Scene, agentID, client.Name, friendID,
748 (byte)InstantMessageDialog.FriendshipDeclined,
749 agentID.ToString(), false, Vector3.Zero);
750 // send decline to initiator
751 if (m_TransferModule != null)
752 { 455 {
753 m_TransferModule.SendInstantMessage(msg, 456 // Try local
754 delegate(bool success) { 457 if (LocalStatusNotification(userID, friendID, online))
755 m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); 458 return;
756 } 459
757 ); 460 // The friend is not here [as root]. Let's forward.
461 PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() });
462 PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions);
463 if (friendSession != null)
464 {
465 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
466 m_FriendsSimConnector.StatusNotify(region, userID, friendID, online);
467 }
468
469 // Friend is not online. Ignore.
758 } 470 }
759 } 471 }
760 472
761 private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID) 473 private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
762 { 474 {
763 // client.AgentId == agentID! 475 if (im.dialog == (byte)OpenMetaverse.InstantMessageDialog.FriendshipOffered)
476 {
477 // we got a friendship offer
478 UUID principalID = new UUID(im.fromAgentID);
479 UUID friendID = new UUID(im.toAgentID);
764 480
765 // this removes the friends from the stored friendlists. After the next login, they will be gone... 481 m_log.DebugFormat("[FRIENDS]: {0} offered friendship to {1}", principalID, friendID);
766 m_initialScene.StoreRemoveFriendship(agentID, exfriendID);
767 482
768 // ... now tell the two involved clients that they aren't friends anymore. 483 // This user wants to be friends with the other user.
484 // Let's add both relations to the DB, but one of them is inactive (-1)
485 FriendsService.StoreFriend(friendID, principalID.ToString(), 0);
769 486
770 // I don't know why we have to tell <agent>, as this was caused by her, but that's how it works in SL... 487 // Now let's ask the other user to be friends with this user
771 client.SendTerminateFriend(exfriendID); 488 ForwardFriendshipOffer(principalID, friendID, im);
772
773 // now send the friend, if online
774 ScenePresence presence = GetAnyPresenceFromAgentID(exfriendID);
775 if (presence != null)
776 {
777 m_log.DebugFormat("[FRIEND]: Sending terminate friend {0} to agent {1}", agentID, exfriendID);
778 presence.ControllingClient.SendTerminateFriend(agentID);
779 } 489 }
780 else 490 }
781 {
782 // retry 3 times, in case the agent TPed from the last known region...
783 for (int retry = 0; retry < 3; ++retry)
784 {
785 // wasn't sent, so ex-friend wasn't around on this region-server. Fetch info and try to send
786 UserAgentData data = m_initialScene.CommsManager.UserService.GetAgentByUUID(exfriendID);
787
788 if (null == data)
789 break;
790
791 if (!data.AgentOnline)
792 {
793 m_log.DebugFormat("[FRIEND]: {0} is offline, so not sending TerminateFriend", exfriendID);
794 break; // if ex-friend isn't online, we don't need to send
795 }
796 491
797 m_log.DebugFormat("[FRIEND]: Sending remote terminate friend {0} to agent {1}@{2}", 492 private void ForwardFriendshipOffer(UUID agentID, UUID friendID, GridInstantMessage im)
798 agentID, exfriendID, data.Handle); 493 {
494 // !!!!!!!! This is a hack so that we don't have to keep state (transactionID/imSessionID)
495 // We stick this agent's ID as imSession, so that it's directly available on the receiving end
496 im.imSessionID = im.fromAgentID;
799 497
800 // try to send to foreign region, retry if it fails (friend TPed away, for example) 498 // Try the local sim
801 if (TriggerTerminateFriend(data.Handle, exfriendID, agentID)) break; 499 if (LocalFriendshipOffered(friendID, im))
802 } 500 return;
803 }
804 501
805 // clean up cache: FriendList is wrong now... 502 // The prospective friend is not here [as root]. Let's forward.
806 lock (m_friendLists) 503 PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() });
504 PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions);
505 if (friendSession != null)
807 { 506 {
808 m_friendLists.Invalidate(agentID.ToString()); 507 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
809 m_friendLists.Invalidate(exfriendID.ToString()); 508 m_FriendsSimConnector.FriendshipOffered(region, agentID, friendID, im.message);
810 } 509 }
510
511 // If the prospective friend is not online, he'll get the message upon login.
811 } 512 }
812 513
813 #endregion 514 private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders)
515 {
516 FriendsService.StoreFriend(agentID, friendID.ToString(), 1);
517 FriendsService.StoreFriend(friendID, agentID.ToString(), 1);
518 // update the local cache
519 m_Friends[agentID].Friends = FriendsService.GetFriends(agentID);
814 520
815 #region CallingCards 521 m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", agentID, friendID);
816 522
817 private void OnOfferCallingCard(IClientAPI client, UUID destID, UUID transactionID) 523 //
818 { 524 // Notify the friend
819 m_log.DebugFormat("[CALLING CARD]: got offer from {0} for {1}, transaction {2}", 525 //
820 client.AgentId, destID, transactionID); 526
821 // This might be slightly wrong. On a multi-region server, we might get the child-agent instead of the root-agent 527 // Try Local
822 // (or the root instead of the child) 528 if (LocalFriendshipApproved(agentID, client.Name, friendID))
823 ScenePresence destAgent = GetAnyPresenceFromAgentID(destID);
824 if (destAgent == null)
825 { 529 {
826 client.SendAlertMessage("The person you have offered a card to can't be found anymore."); 530 client.SendAgentOnline(new UUID[] { friendID });
827 return; 531 return;
828 } 532 }
829 533
830 lock (m_pendingCallingcardRequests) 534 // The friend is not here
535 PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() });
536 PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions);
537 if (friendSession != null)
831 { 538 {
832 m_pendingCallingcardRequests[transactionID] = client.AgentId; 539 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
540 m_FriendsSimConnector.FriendshipApproved(region, agentID, client.Name, friendID);
541 client.SendAgentOnline(new UUID[] { friendID });
833 } 542 }
834 // inform the destination agent about the offer
835 destAgent.ControllingClient.SendOfferCallingCard(client.AgentId, transactionID);
836 }
837 543
838 private void CreateCallingCard(IClientAPI client, UUID creator, UUID folder, string name)
839 {
840 InventoryItemBase item = new InventoryItemBase();
841 item.AssetID = UUID.Zero;
842 item.AssetType = (int)AssetType.CallingCard;
843 item.BasePermissions = (uint)PermissionMask.Copy;
844 item.CreationDate = Util.UnixTimeSinceEpoch();
845 item.CreatorId = creator.ToString();
846 item.CurrentPermissions = item.BasePermissions;
847 item.Description = "";
848 item.EveryOnePermissions = (uint)PermissionMask.None;
849 item.Flags = 0;
850 item.Folder = folder;
851 item.GroupID = UUID.Zero;
852 item.GroupOwned = false;
853 item.ID = UUID.Random();
854 item.InvType = (int)InventoryType.CallingCard;
855 item.Name = name;
856 item.NextPermissions = item.EveryOnePermissions;
857 item.Owner = client.AgentId;
858 item.SalePrice = 10;
859 item.SaleType = (byte)SaleType.Not;
860 ((Scene)client.Scene).AddInventoryItem(client, item);
861 } 544 }
862 545
863 private void OnAcceptCallingCard(IClientAPI client, UUID transactionID, UUID folderID) 546 private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders)
864 { 547 {
865 m_log.DebugFormat("[CALLING CARD]: User {0} ({1} {2}) accepted tid {3}, folder {4}", 548 m_log.DebugFormat("[FRIENDS]: {0} denied friendship to {1}", agentID, friendID);
866 client.AgentId,
867 client.FirstName, client.LastName,
868 transactionID, folderID);
869 UUID destID;
870 lock (m_pendingCallingcardRequests)
871 {
872 if (!m_pendingCallingcardRequests.TryGetValue(transactionID, out destID))
873 {
874 m_log.WarnFormat("[CALLING CARD]: Got a AcceptCallingCard from {0} without an offer before.",
875 client.Name);
876 return;
877 }
878 // else found pending calling card request with that transaction.
879 m_pendingCallingcardRequests.Remove(transactionID);
880 }
881 549
550 FriendsService.Delete(agentID, friendID.ToString());
551 FriendsService.Delete(friendID, agentID.ToString());
882 552
883 ScenePresence destAgent = GetAnyPresenceFromAgentID(destID); 553 //
884 // inform sender of the card that destination declined the offer 554 // Notify the friend
885 if (destAgent != null) destAgent.ControllingClient.SendAcceptCallingCard(transactionID); 555 //
886 556
887 // put a calling card into the inventory of receiver 557 // Try local
888 CreateCallingCard(client, destID, folderID, destAgent.Name); 558 if (LocalFriendshipDenied(agentID, client.Name, friendID))
889 } 559 return;
890 560
891 private void OnDeclineCallingCard(IClientAPI client, UUID transactionID) 561 PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() });
892 { 562 PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions);
893 m_log.DebugFormat("[CALLING CARD]: User {0} (ID:{1}) declined card, tid {2}", 563 if (friendSession != null)
894 client.Name, client.AgentId, transactionID);
895 UUID destID;
896 lock (m_pendingCallingcardRequests)
897 { 564 {
898 if (!m_pendingCallingcardRequests.TryGetValue(transactionID, out destID)) 565 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
899 { 566 m_FriendsSimConnector.FriendshipDenied(region, agentID, client.Name, friendID);
900 m_log.WarnFormat("[CALLING CARD]: Got a AcceptCallingCard from {0} without an offer before.",
901 client.Name);
902 return;
903 }
904 // else found pending calling card request with that transaction.
905 m_pendingCallingcardRequests.Remove(transactionID);
906 } 567 }
907
908 ScenePresence destAgent = GetAnyPresenceFromAgentID(destID);
909 // inform sender of the card that destination declined the offer
910 if (destAgent != null) destAgent.ControllingClient.SendDeclineCallingCard(transactionID);
911 } 568 }
912 569
913 /// <summary> 570 private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID)
914 /// Send presence information about a client to other clients in both this region and others.
915 /// </summary>
916 /// <param name="client"></param>
917 /// <param name="friendList"></param>
918 /// <param name="iAmOnline"></param>
919 private void SendPresenceState(IClientAPI client, List<FriendListItem> friendList, bool iAmOnline)
920 { 571 {
921 //m_log.DebugFormat("[FRIEND]: {0} logged {1}; sending presence updates", client.Name, iAmOnline ? "in" : "out"); 572 FriendsService.Delete(agentID, exfriendID.ToString());
573 FriendsService.Delete(exfriendID, agentID.ToString());
922 574
923 if (friendList == null || friendList.Count == 0) 575 // Update local cache
924 { 576 m_Friends[agentID].Friends = FriendsService.GetFriends(agentID);
925 //m_log.DebugFormat("[FRIEND]: {0} doesn't have friends.", client.Name);
926 return; // nothing we can do if she doesn't have friends...
927 }
928 577
929 // collect sets of friendIDs; to send to (online and offline), and to receive from 578 client.SendTerminateFriend(exfriendID);
930 // TODO: If we ever switch to .NET >= 3, replace those Lists with HashSets.
931 // I can't believe that we have Dictionaries, but no Sets, considering Java introduced them years ago...
932 List<UUID> friendIDsToSendTo = new List<UUID>();
933 List<UUID> candidateFriendIDsToReceive = new List<UUID>();
934
935 foreach (FriendListItem item in friendList)
936 {
937 if (((item.FriendListOwnerPerms | item.FriendPerms) & (uint)FriendRights.CanSeeOnline) != 0)
938 {
939 // friend is allowed to see my presence => add
940 if ((item.FriendListOwnerPerms & (uint)FriendRights.CanSeeOnline) != 0)
941 friendIDsToSendTo.Add(item.Friend);
942 579
943 if ((item.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0) 580 //
944 candidateFriendIDsToReceive.Add(item.Friend); 581 // Notify the friend
945 } 582 //
946 }
947 583
948 // we now have a list of "interesting" friends (which we have to find out on-/offline state for), 584 // Try local
949 // friends we want to send our online state to (if *they* are online, too), and 585 if (LocalFriendshipTerminated(exfriendID))
950 // friends we want to receive online state for (currently unknown whether online or not) 586 return;
951 587
952 // as this processing might take some time and friends might TP away, we try up to three times to 588 PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { exfriendID.ToString() });
953 // reach them. Most of the time, we *will* reach them, and this loop won't loop 589 PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions);
954 int retry = 0; 590 if (friendSession != null)
955 do
956 { 591 {
957 // build a list of friends to look up region-information and on-/offline-state for 592 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
958 List<UUID> friendIDsToLookup = new List<UUID>(friendIDsToSendTo); 593 m_FriendsSimConnector.FriendshipTerminated(region, agentID, exfriendID);
959 foreach (UUID uuid in candidateFriendIDsToReceive) 594 }
960 { 595 }
961 if (!friendIDsToLookup.Contains(uuid)) friendIDsToLookup.Add(uuid);
962 }
963
964 m_log.DebugFormat(
965 "[FRIEND]: {0} to lookup, {1} to send to, {2} candidates to receive from for agent {3}",
966 friendIDsToLookup.Count, friendIDsToSendTo.Count, candidateFriendIDsToReceive.Count, client.Name);
967
968 // we have to fetch FriendRegionInfos, as the (cached) FriendListItems don't
969 // necessarily contain the correct online state...
970 Dictionary<UUID, FriendRegionInfo> friendRegions = m_initialScene.GetFriendRegionInfos(friendIDsToLookup);
971 m_log.DebugFormat(
972 "[FRIEND]: Found {0} regionInfos for {1} friends of {2}",
973 friendRegions.Count, friendIDsToLookup.Count, client.Name);
974 596
975 // argument for SendAgentOn/Offline; we shouldn't generate that repeatedly within loops. 597 private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights)
976 UUID[] agentArr = new UUID[] { client.AgentId }; 598 {
599 if (!m_Friends.ContainsKey(remoteClient.AgentId))
600 return;
977 601
978 // first, send to friend presence state to me, if I'm online... 602 m_log.DebugFormat("[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", requester, rights, target);
979 if (iAmOnline) 603 // Let's find the friend in this user's friend list
980 { 604 UserFriendData fd = m_Friends[remoteClient.AgentId];
981 List<UUID> friendIDsToReceive = new List<UUID>(); 605 FriendInfo friend = null;
982 606 foreach (FriendInfo fi in fd.Friends)
983 for (int i = candidateFriendIDsToReceive.Count - 1; i >= 0; --i) 607 if (fi.Friend == target.ToString())
984 { 608 friend = fi;
985 UUID uuid = candidateFriendIDsToReceive[i];
986 FriendRegionInfo info;
987 if (friendRegions.TryGetValue(uuid, out info) && info != null && info.isOnline)
988 {
989 friendIDsToReceive.Add(uuid);
990 }
991 }
992
993 m_log.DebugFormat(
994 "[FRIEND]: Sending {0} online friends to {1}", friendIDsToReceive.Count, client.Name);
995
996 if (friendIDsToReceive.Count > 0)
997 client.SendAgentOnline(friendIDsToReceive.ToArray());
998
999 // clear them for a possible second iteration; we don't have to repeat this
1000 candidateFriendIDsToReceive.Clear();
1001 }
1002 609
1003 // now, send my presence state to my friends 610 if (friend != null) // Found it
1004 for (int i = friendIDsToSendTo.Count - 1; i >= 0; --i) 611 {
1005 { 612 // Store it on the DB
1006 UUID uuid = friendIDsToSendTo[i]; 613 FriendsService.StoreFriend(requester, target.ToString(), rights);
1007 FriendRegionInfo info;
1008 if (friendRegions.TryGetValue(uuid, out info) && info != null && info.isOnline)
1009 {
1010 // any client is good enough, root or child...
1011 ScenePresence agent = GetAnyPresenceFromAgentID(uuid);
1012 if (agent != null)
1013 {
1014 //m_log.DebugFormat("[FRIEND]: Found local agent {0}", agent.Name);
1015 614
1016 // friend is online and on this server... 615 // Store it in the local cache
1017 if (iAmOnline) agent.ControllingClient.SendAgentOnline(agentArr); 616 int myFlags = friend.MyFlags;
1018 else agent.ControllingClient.SendAgentOffline(agentArr); 617 friend.MyFlags = rights;
1019 618
1020 // done, remove it 619 // Always send this back to the original client
1021 friendIDsToSendTo.RemoveAt(i); 620 remoteClient.SendChangeUserRights(requester, target, rights);
1022 }
1023 }
1024 else
1025 {
1026 //m_log.DebugFormat("[FRIEND]: Friend {0} ({1}) is offline; not sending.", uuid, i);
1027 621
1028 // friend is offline => no need to try sending 622 //
1029 friendIDsToSendTo.RemoveAt(i); 623 // Notify the friend
1030 } 624 //
1031 }
1032 625
1033 m_log.DebugFormat("[FRIEND]: Have {0} friends to contact via inter-region comms.", friendIDsToSendTo.Count); 626 // Try local
627 if (LocalGrantRights(requester, target, myFlags, rights))
628 return;
1034 629
1035 // we now have all the friends left that are online (we think), but not on this region-server 630 PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() });
1036 if (friendIDsToSendTo.Count > 0) 631 PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions);
632 if (friendSession != null)
1037 { 633 {
1038 // sort them into regions 634 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
1039 Dictionary<ulong, List<UUID>> friendsInRegion = new Dictionary<ulong,List<UUID>>(); 635 // TODO: You might want to send the delta to save the lookup
1040 foreach (UUID uuid in friendIDsToSendTo) 636 // on the other end!!
1041 { 637 m_FriendsSimConnector.GrantRights(region, requester, target, myFlags, rights);
1042 ulong handle = friendRegions[uuid].regionHandle; // this can't fail as we filtered above already
1043 List<UUID> friends;
1044 if (!friendsInRegion.TryGetValue(handle, out friends))
1045 {
1046 friends = new List<UUID>();
1047 friendsInRegion[handle] = friends;
1048 }
1049 friends.Add(uuid);
1050 }
1051 m_log.DebugFormat("[FRIEND]: Found {0} regions to send to.", friendRegions.Count);
1052
1053 // clear uuids list and collect missed friends in it for the next retry
1054 friendIDsToSendTo.Clear();
1055
1056 // send bulk updates to the region
1057 foreach (KeyValuePair<ulong, List<UUID>> pair in friendsInRegion)
1058 {
1059 //m_log.DebugFormat("[FRIEND]: Inform {0} friends in region {1} that user {2} is {3}line",
1060 // pair.Value.Count, pair.Key, client.Name, iAmOnline ? "on" : "off");
1061
1062 friendIDsToSendTo.AddRange(InformFriendsInOtherRegion(client.AgentId, pair.Key, pair.Value, iAmOnline));
1063 }
1064 } 638 }
1065 // now we have in friendIDsToSendTo only the agents left that TPed away while we tried to contact them.
1066 // In most cases, it will be empty, and it won't loop here. But sometimes, we have to work harder and try again...
1067 } 639 }
1068 while (++retry < 3 && friendIDsToSendTo.Count > 0);
1069 } 640 }
1070 641
1071 private void OnEconomyDataRequest(UUID agentID) 642 #region Local
643
644 public bool LocalFriendshipOffered(UUID toID, GridInstantMessage im)
1072 { 645 {
1073 // KLUDGE: This is the only way I found to get a message (only) after login was completed and the 646 IClientAPI friendClient = LocateClientObject(toID);
1074 // client is connected enough to receive UDP packets). 647 if (friendClient != null)
1075 // This packet seems to be sent only once, just after connection was established to the first
1076 // region after login.
1077 // We use it here to trigger a presence update; the old update-on-login was never be heard by
1078 // the freshly logged in viewer, as it wasn't connected to the region at that time.
1079 // TODO: Feel free to replace this by a better solution if you find one.
1080
1081 // get the agent. This should work every time, as we just got a packet from it
1082 //ScenePresence agent = GetRootPresenceFromAgentID(agentID);
1083 // KLUDGE 2: As this is sent quite early, the avatar isn't here as root agent yet. So, we have to cheat a bit
1084 ScenePresence agent = GetAnyPresenceFromAgentID(agentID);
1085
1086 // just to be paranoid...
1087 if (agent == null)
1088 { 648 {
1089 m_log.ErrorFormat("[FRIEND]: Got a packet from agent {0} who can't be found anymore!?", agentID); 649 // the prospective friend in this sim as root agent
1090 return; 650 friendClient.SendInstantMessage(im);
651 // we're done
652 return true;
1091 } 653 }
654 return false;
655 }
1092 656
1093 List<FriendListItem> fl; 657 public bool LocalFriendshipApproved(UUID userID, string userName, UUID friendID)
1094 lock (m_friendLists) 658 {
659 IClientAPI friendClient = LocateClientObject(friendID);
660 if (friendClient != null)
1095 { 661 {
1096 fl = (List<FriendListItem>)m_friendLists.Get(agent.ControllingClient.AgentId.ToString(), 662 // the prospective friend in this sim as root agent
1097 m_initialScene.GetFriendList); 663 GridInstantMessage im = new GridInstantMessage(Scene, userID, userName, friendID,
664 (byte)OpenMetaverse.InstantMessageDialog.FriendshipAccepted, userID.ToString(), false, Vector3.Zero);
665 friendClient.SendInstantMessage(im);
666 // update the local cache
667 m_Friends[friendID].Friends = FriendsService.GetFriends(friendID);
668 // we're done
669 return true;
1098 } 670 }
1099 671
1100 // tell everyone that we are online 672 return false;
1101 SendPresenceState(agent.ControllingClient, fl, true);
1102 } 673 }
1103 674
1104 private void OnLogout(IClientAPI remoteClient) 675 public bool LocalFriendshipDenied(UUID userID, string userName, UUID friendID)
1105 { 676 {
1106 List<FriendListItem> fl; 677 IClientAPI friendClient = LocateClientObject(friendID);
1107 lock (m_friendLists) 678 if (friendClient != null)
1108 { 679 {
1109 fl = (List<FriendListItem>)m_friendLists.Get(remoteClient.AgentId.ToString(), 680 // the prospective friend in this sim as root agent
1110 m_initialScene.GetFriendList);
1111 }
1112 681
1113 // tell everyone that we are offline 682 GridInstantMessage im = new GridInstantMessage(Scene, userID, userName, friendID,
1114 SendPresenceState(remoteClient, fl, false); 683 (byte)OpenMetaverse.InstantMessageDialog.FriendshipDeclined, userID.ToString(), false, Vector3.Zero);
684 friendClient.SendInstantMessage(im);
685 // we're done
686 return true;
687 }
688
689 return false;
1115 } 690 }
1116 private void GrantUserFriendRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) 691
692 public bool LocalFriendshipTerminated(UUID exfriendID)
1117 { 693 {
1118 ((Scene)remoteClient.Scene).CommsManager.UpdateUserFriendPerms(requester, target, (uint)rights); 694 IClientAPI friendClient = LocateClientObject(exfriendID);
695 if (friendClient != null)
696 {
697 // the friend in this sim as root agent
698 friendClient.SendTerminateFriend(exfriendID);
699 // update local cache
700 m_Friends[exfriendID].Friends = FriendsService.GetFriends(exfriendID);
701 // we're done
702 return true;
703 }
704
705 return false;
1119 } 706 }
1120 public void FindAgent(IClientAPI remoteClient, UUID hunter, UUID target) 707
708 public bool LocalGrantRights(UUID userID, UUID friendID, int userFlags, int rights)
1121 { 709 {
1122 List<FriendListItem> friendList = GetUserFriends(hunter); 710 IClientAPI friendClient = LocateClientObject(friendID);
1123 foreach (FriendListItem item in friendList) 711 if (friendClient != null)
1124 { 712 {
1125 if (item.onlinestatus == true) 713 bool onlineBitChanged = ((rights ^ userFlags) & (int)FriendRights.CanSeeOnline) != 0;
714 if (onlineBitChanged)
1126 { 715 {
1127 if (item.Friend == target && (item.FriendPerms & (uint)FriendRights.CanSeeOnMap) != 0) 716 if ((rights & (int)FriendRights.CanSeeOnline) == 1)
1128 { 717 friendClient.SendAgentOnline(new UUID[] { new UUID(userID) });
1129 ScenePresence SPTarget = ((Scene)remoteClient.Scene).GetScenePresence(target); 718 else
1130 string regionname = SPTarget.Scene.RegionInfo.RegionName; 719 friendClient.SendAgentOffline(new UUID[] { new UUID(userID) });
1131 remoteClient.SendScriptTeleportRequest("FindAgent", regionname,new Vector3(SPTarget.AbsolutePosition),new Vector3(SPTarget.Lookat));
1132 }
1133 } 720 }
1134 else 721 else
1135 { 722 {
1136 remoteClient.SendAgentAlertMessage("The agent you are looking for is not online.", false); 723 bool canEditObjectsChanged = ((rights ^ userFlags) & (int)FriendRights.CanModifyObjects) != 0;
724 if (canEditObjectsChanged)
725 friendClient.SendChangeUserRights(userID, friendID, rights);
1137 } 726 }
727
728 return true;
1138 } 729 }
730
731 return false;
732
1139 } 733 }
1140 734
1141 public List<FriendListItem> GetUserFriends(UUID agentID) 735 public bool LocalStatusNotification(UUID userID, UUID friendID, bool online)
1142 { 736 {
1143 List<FriendListItem> fl; 737 IClientAPI friendClient = LocateClientObject(friendID);
1144 lock (m_friendLists) 738 if (friendClient != null)
1145 { 739 {
1146 fl = (List<FriendListItem>)m_friendLists.Get(agentID.ToString(), 740 //m_log.DebugFormat("[FRIENDS]: Notify {0} that user {1} is {2}", friend.Friend, userID, online);
1147 m_initialScene.GetFriendList); 741 // the friend in this sim as root agent
742 if (online)
743 friendClient.SendAgentOnline(new UUID[] { userID });
744 else
745 friendClient.SendAgentOffline(new UUID[] { userID });
746 // we're done
747 return true;
1148 } 748 }
1149 749
1150 return fl; 750 return false;
1151 } 751 }
752 #endregion
753
1152 } 754 }
1153 #endregion
1154} 755}
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs
new file mode 100644
index 0000000..0883c5b
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs
@@ -0,0 +1,293 @@
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.Xml;
33
34using OpenSim.Framework;
35using OpenSim.Server.Base;
36using OpenSim.Framework.Servers.HttpServer;
37using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
38
39using OpenMetaverse;
40using log4net;
41
42namespace OpenSim.Region.CoreModules.Avatar.Friends
43{
44 public class FriendsRequestHandler : BaseStreamHandler
45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 private FriendsModule m_FriendsModule;
49
50 public FriendsRequestHandler(FriendsModule fmodule)
51 : base("POST", "/friends")
52 {
53 m_FriendsModule = fmodule;
54 }
55
56 public override byte[] Handle(string path, Stream requestData,
57 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
58 {
59 StreamReader sr = new StreamReader(requestData);
60 string body = sr.ReadToEnd();
61 sr.Close();
62 body = body.Trim();
63
64 m_log.DebugFormat("[XXX]: query String: {0}", body);
65
66 try
67 {
68 Dictionary<string, object> request =
69 ServerUtils.ParseQueryString(body);
70
71 if (!request.ContainsKey("METHOD"))
72 return FailureResult();
73
74 string method = request["METHOD"].ToString();
75 request.Remove("METHOD");
76
77 switch (method)
78 {
79 case "friendship_offered":
80 return FriendshipOffered(request);
81 case "friendship_approved":
82 return FriendshipApproved(request);
83 case "friendship_denied":
84 return FriendshipDenied(request);
85 case "friendship_terminated":
86 return FriendshipTerminated(request);
87 case "grant_rights":
88 return GrantRights(request);
89 case "status":
90 return StatusNotification(request);
91 }
92 }
93 catch (Exception e)
94 {
95 m_log.Debug("[FRIENDS]: Exception {0}" + e.ToString());
96 }
97
98 return FailureResult();
99 }
100
101 byte[] FriendshipOffered(Dictionary<string, object> request)
102 {
103 UUID fromID = UUID.Zero;
104 UUID toID = UUID.Zero;
105 string message = string.Empty;
106
107 if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID"))
108 return FailureResult();
109
110 message = request["Message"].ToString();
111
112 if (!UUID.TryParse(request["FromID"].ToString(), out fromID))
113 return FailureResult();
114
115 if (!UUID.TryParse(request["ToID"].ToString(), out toID))
116 return FailureResult();
117
118 GridInstantMessage im = new GridInstantMessage(m_FriendsModule.Scene, fromID, "", toID,
119 (byte)InstantMessageDialog.FriendshipOffered, message, false, Vector3.Zero);
120
121 if (m_FriendsModule.LocalFriendshipOffered(toID, im))
122 return SuccessResult();
123
124 return FailureResult();
125 }
126
127 byte[] FriendshipApproved(Dictionary<string, object> request)
128 {
129 UUID fromID = UUID.Zero;
130 UUID toID = UUID.Zero;
131 string fromName = string.Empty;
132
133 if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID"))
134 return FailureResult();
135
136 if (!UUID.TryParse(request["FromID"].ToString(), out fromID))
137 return FailureResult();
138
139 if (!UUID.TryParse(request["ToID"].ToString(), out toID))
140 return FailureResult();
141
142 if (request.ContainsKey("FromName"))
143 fromName = request["FromName"].ToString();
144
145 if (m_FriendsModule.LocalFriendshipApproved(fromID, fromName, toID))
146 return SuccessResult();
147
148 return FailureResult();
149 }
150
151 byte[] FriendshipDenied(Dictionary<string, object> request)
152 {
153 UUID fromID = UUID.Zero;
154 UUID toID = UUID.Zero;
155 string fromName = string.Empty;
156
157 if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID"))
158 return FailureResult();
159
160 if (!UUID.TryParse(request["FromID"].ToString(), out fromID))
161 return FailureResult();
162
163 if (!UUID.TryParse(request["ToID"].ToString(), out toID))
164 return FailureResult();
165
166 if (request.ContainsKey("FromName"))
167 fromName = request["FromName"].ToString();
168
169 if (m_FriendsModule.LocalFriendshipDenied(fromID, fromName, toID))
170 return SuccessResult();
171
172 return FailureResult();
173 }
174
175 byte[] FriendshipTerminated(Dictionary<string, object> request)
176 {
177 UUID fromID = UUID.Zero;
178 UUID toID = UUID.Zero;
179
180 if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID"))
181 return FailureResult();
182
183 if (!UUID.TryParse(request["FromID"].ToString(), out fromID))
184 return FailureResult();
185
186 if (!UUID.TryParse(request["ToID"].ToString(), out toID))
187 return FailureResult();
188
189 if (m_FriendsModule.LocalFriendshipTerminated(toID))
190 return SuccessResult();
191
192 return FailureResult();
193 }
194
195 byte[] GrantRights(Dictionary<string, object> request)
196 {
197 UUID fromID = UUID.Zero;
198 UUID toID = UUID.Zero;
199 int rights = 0, userFlags = 0;
200
201 if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID"))
202 return FailureResult();
203
204 if (!UUID.TryParse(request["FromID"].ToString(), out fromID))
205 return FailureResult();
206
207 if (!UUID.TryParse(request["ToID"].ToString(), out toID))
208 return FailureResult();
209
210 if (!Int32.TryParse(request["UserFlags"].ToString(), out userFlags))
211 return FailureResult();
212
213 if (!Int32.TryParse(request["Rights"].ToString(), out rights))
214 return FailureResult();
215
216 if (m_FriendsModule.LocalGrantRights(UUID.Zero, UUID.Zero, userFlags, rights))
217 return SuccessResult();
218
219 return FailureResult();
220 }
221
222 byte[] StatusNotification(Dictionary<string, object> request)
223 {
224 UUID fromID = UUID.Zero;
225 UUID toID = UUID.Zero;
226 bool online = false;
227
228 if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID") || !request.ContainsKey("Online"))
229 return FailureResult();
230
231 if (!UUID.TryParse(request["FromID"].ToString(), out fromID))
232 return FailureResult();
233
234 if (!UUID.TryParse(request["ToID"].ToString(), out toID))
235 return FailureResult();
236
237 if (!Boolean.TryParse(request["Online"].ToString(), out online))
238 return FailureResult();
239
240 if (m_FriendsModule.LocalStatusNotification(fromID, toID, online))
241 return SuccessResult();
242
243 return FailureResult();
244 }
245
246 #region Misc
247
248 private byte[] FailureResult()
249 {
250 return BoolResult(false);
251 }
252
253 private byte[] SuccessResult()
254 {
255 return BoolResult(true);
256 }
257
258 private byte[] BoolResult(bool value)
259 {
260 XmlDocument doc = new XmlDocument();
261
262 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
263 "", "");
264
265 doc.AppendChild(xmlnode);
266
267 XmlElement rootElement = doc.CreateElement("", "ServerResponse",
268 "");
269
270 doc.AppendChild(rootElement);
271
272 XmlElement result = doc.CreateElement("", "RESULT", "");
273 result.AppendChild(doc.CreateTextNode(value.ToString()));
274
275 rootElement.AppendChild(result);
276
277 return DocToBytes(doc);
278 }
279
280 private byte[] DocToBytes(XmlDocument doc)
281 {
282 MemoryStream ms = new MemoryStream();
283 XmlTextWriter xw = new XmlTextWriter(ms, null);
284 xw.Formatting = Formatting.Indented;
285 doc.WriteTo(xw);
286 xw.Flush();
287
288 return ms.ToArray();
289 }
290
291 #endregion
292 }
293}
diff --git a/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs b/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs
index 8ce5092..7303fe7 100644
--- a/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs
@@ -30,7 +30,7 @@ using log4net;
30using Nini.Config; 30using Nini.Config;
31using OpenMetaverse; 31using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Communications.Cache; 33
34using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
index 9a68749..ab141eb 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.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 */
27using System;
27using System.Collections.Generic; 28using System.Collections.Generic;
28using System.Reflection; 29using System.Reflection;
29using log4net; 30using log4net;
@@ -36,9 +37,10 @@ using OpenSim.Region.Framework.Scenes;
36 37
37namespace OpenSim.Region.CoreModules.Avatar.InstantMessage 38namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
38{ 39{
39 public class InstantMessageModule : IRegionModule 40 public class InstantMessageModule : ISharedRegionModule
40 { 41 {
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(
43 MethodBase.GetCurrentMethod().DeclaringType);
42 44
43 /// <value> 45 /// <value>
44 /// Is this module enabled? 46 /// Is this module enabled?
@@ -51,7 +53,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
51 53
52 private IMessageTransferModule m_TransferModule = null; 54 private IMessageTransferModule m_TransferModule = null;
53 55
54 public void Initialise(Scene scene, IConfigSource config) 56 public void Initialise(IConfigSource config)
55 { 57 {
56 if (config.Configs["Messaging"] != null) 58 if (config.Configs["Messaging"] != null)
57 { 59 {
@@ -62,6 +64,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
62 } 64 }
63 65
64 m_enabled = true; 66 m_enabled = true;
67 }
68
69 public void AddRegion(Scene scene)
70 {
71 if (!m_enabled)
72 return;
65 73
66 lock (m_scenes) 74 lock (m_scenes)
67 { 75 {
@@ -74,6 +82,39 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
74 } 82 }
75 } 83 }
76 84
85 public void RegionLoaded(Scene scene)
86 {
87 if (!m_enabled)
88 return;
89
90 if (m_TransferModule == null)
91 {
92 m_TransferModule =
93 scene.RequestModuleInterface<IMessageTransferModule>();
94
95 if (m_TransferModule == null)
96 {
97 m_log.Error("[INSTANT MESSAGE]: No message transfer module, IM will not work!");
98 scene.EventManager.OnClientConnect -= OnClientConnect;
99 scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
100
101 m_scenes.Clear();
102 m_enabled = false;
103 }
104 }
105 }
106
107 public void RemoveRegion(Scene scene)
108 {
109 if (!m_enabled)
110 return;
111
112 lock (m_scenes)
113 {
114 m_scenes.Remove(scene);
115 }
116 }
117
77 void OnClientConnect(IClientCore client) 118 void OnClientConnect(IClientCore client)
78 { 119 {
79 IClientIM clientIM; 120 IClientIM clientIM;
@@ -85,15 +126,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
85 126
86 public void PostInitialise() 127 public void PostInitialise()
87 { 128 {
88 if (!m_enabled)
89 return;
90
91 m_TransferModule =
92 m_scenes[0].RequestModuleInterface<IMessageTransferModule>();
93
94 if (m_TransferModule == null)
95 m_log.Error("[INSTANT MESSAGE]: No message transfer module, "+
96 "IM will not work!");
97 } 129 }
98 130
99 public void Close() 131 public void Close()
@@ -105,9 +137,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
105 get { return "InstantMessageModule"; } 137 get { return "InstantMessageModule"; }
106 } 138 }
107 139
108 public bool IsSharedModule 140 public Type ReplaceableInterface
109 { 141 {
110 get { return true; } 142 get { return null; }
111 } 143 }
112 144
113 #endregion 145 #endregion
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index e5159b3..c0d3f31 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -37,21 +37,33 @@ using OpenSim.Framework;
37using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion; 39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
41using OpenSim.Services.Interfaces;
40 42
41namespace OpenSim.Region.CoreModules.Avatar.InstantMessage 43namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
42{ 44{
43 public class MessageTransferModule : IRegionModule, IMessageTransferModule 45 public class MessageTransferModule : ISharedRegionModule, IMessageTransferModule
44 { 46 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 48
47 // private bool m_Enabled = false; 49 private bool m_Enabled = false;
48 protected bool m_Gridmode = false;
49 protected List<Scene> m_Scenes = new List<Scene>(); 50 protected List<Scene> m_Scenes = new List<Scene>();
50 protected Dictionary<UUID, ulong> m_UserRegionMap = new Dictionary<UUID, ulong>(); 51 protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>();
51 52
52 public event UndeliveredMessage OnUndeliveredMessage; 53 public event UndeliveredMessage OnUndeliveredMessage;
53 54
54 public virtual void Initialise(Scene scene, IConfigSource config) 55 private IPresenceService m_PresenceService;
56 protected IPresenceService PresenceService
57 {
58 get
59 {
60 if (m_PresenceService == null)
61 m_PresenceService = m_Scenes[0].RequestModuleInterface<IPresenceService>();
62 return m_PresenceService;
63 }
64 }
65
66 public virtual void Initialise(IConfigSource config)
55 { 67 {
56 IConfig cnf = config.Configs["Messaging"]; 68 IConfig cnf = config.Configs["Messaging"];
57 if (cnf != null && cnf.GetString( 69 if (cnf != null && cnf.GetString(
@@ -62,20 +74,16 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
62 return; 74 return;
63 } 75 }
64 76
65 cnf = config.Configs["Startup"]; 77 m_Enabled = true;
66 if (cnf != null) 78 }
67 m_Gridmode = cnf.GetBoolean("gridmode", false);
68 79
69 // m_Enabled = true; 80 public virtual void AddRegion(Scene scene)
81 {
82 if (!m_Enabled)
83 return;
70 84
71 lock (m_Scenes) 85 lock (m_Scenes)
72 { 86 {
73 if (m_Scenes.Count == 0)
74 {
75 MainServer.Instance.AddXmlRPCHandler(
76 "grid_instant_message", processXMLRPCGridInstantMessage);
77 }
78
79 m_log.Debug("[MESSAGE TRANSFER]: Message transfer module active"); 87 m_log.Debug("[MESSAGE TRANSFER]: Message transfer module active");
80 scene.RegisterModuleInterface<IMessageTransferModule>(this); 88 scene.RegisterModuleInterface<IMessageTransferModule>(this);
81 m_Scenes.Add(scene); 89 m_Scenes.Add(scene);
@@ -84,6 +92,26 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
84 92
85 public virtual void PostInitialise() 93 public virtual void PostInitialise()
86 { 94 {
95 if (!m_Enabled)
96 return;
97
98 MainServer.Instance.AddXmlRPCHandler(
99 "grid_instant_message", processXMLRPCGridInstantMessage);
100 }
101
102 public virtual void RegionLoaded(Scene scene)
103 {
104 }
105
106 public virtual void RemoveRegion(Scene scene)
107 {
108 if (!m_Enabled)
109 return;
110
111 lock(m_Scenes)
112 {
113 m_Scenes.Remove(scene);
114 }
87 } 115 }
88 116
89 public virtual void Close() 117 public virtual void Close()
@@ -95,9 +123,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
95 get { return "MessageTransferModule"; } 123 get { return "MessageTransferModule"; }
96 } 124 }
97 125
98 public virtual bool IsSharedModule 126 public virtual Type ReplaceableInterface
99 { 127 {
100 get { return true; } 128 get { return null; }
101 } 129 }
102 130
103 public virtual void SendInstantMessage(GridInstantMessage im, MessageResultNotification result) 131 public virtual void SendInstantMessage(GridInstantMessage im, MessageResultNotification result)
@@ -148,15 +176,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
148 } 176 }
149 } 177 }
150 178
151 if (m_Gridmode) 179 SendGridInstantMessageViaXMLRPC(im, result);
152 {
153 //m_log.DebugFormat("[INSTANT MESSAGE]: Delivering via grid");
154 // Still here, try send via Grid
155 SendGridInstantMessageViaXMLRPC(im, result);
156 return;
157 }
158
159 HandleUndeliveredMessage(im, result);
160 180
161 return; 181 return;
162 } 182 }
@@ -409,7 +429,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
409 /// <summary> 429 /// <summary>
410 /// delegate for sending a grid instant message asynchronously 430 /// delegate for sending a grid instant message asynchronously
411 /// </summary> 431 /// </summary>
412 public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, ulong prevRegionHandle); 432 public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID);
413 433
414 protected virtual void GridInstantMessageCompleted(IAsyncResult iar) 434 protected virtual void GridInstantMessageCompleted(IAsyncResult iar)
415 { 435 {
@@ -423,7 +443,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
423 { 443 {
424 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; 444 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync;
425 445
426 d.BeginInvoke(im, result, 0, GridInstantMessageCompleted, d); 446 d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d);
427 } 447 }
428 448
429 /// <summary> 449 /// <summary>
@@ -438,11 +458,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
438 /// Pass in 0 the first time this method is called. It will be called recursively with the last 458 /// Pass in 0 the first time this method is called. It will be called recursively with the last
439 /// regionhandle tried 459 /// regionhandle tried
440 /// </param> 460 /// </param>
441 protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, ulong prevRegionHandle) 461 protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID)
442 { 462 {
443 UUID toAgentID = new UUID(im.toAgentID); 463 UUID toAgentID = new UUID(im.toAgentID);
444 464
445 UserAgentData upd = null; 465 PresenceInfo upd = null;
446 466
447 bool lookupAgent = false; 467 bool lookupAgent = false;
448 468
@@ -450,13 +470,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
450 { 470 {
451 if (m_UserRegionMap.ContainsKey(toAgentID)) 471 if (m_UserRegionMap.ContainsKey(toAgentID))
452 { 472 {
453 upd = new UserAgentData(); 473 upd = new PresenceInfo();
454 upd.AgentOnline = true; 474 upd.Online = true;
455 upd.Handle = m_UserRegionMap[toAgentID]; 475 upd.RegionID = m_UserRegionMap[toAgentID];
456 476
457 // We need to compare the current regionhandle with the previous region handle 477 // We need to compare the current regionhandle with the previous region handle
458 // or the recursive loop will never end because it will never try to lookup the agent again 478 // or the recursive loop will never end because it will never try to lookup the agent again
459 if (prevRegionHandle == upd.Handle) 479 if (prevRegionID == upd.RegionID)
460 { 480 {
461 lookupAgent = true; 481 lookupAgent = true;
462 } 482 }
@@ -472,14 +492,23 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
472 if (lookupAgent) 492 if (lookupAgent)
473 { 493 {
474 // Non-cached user agent lookup. 494 // Non-cached user agent lookup.
475 upd = m_Scenes[0].CommsManager.UserService.GetAgentByUUID(toAgentID); 495 PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() });
496 if (presences != null)
497 {
498 foreach (PresenceInfo p in presences)
499 if (p.Online)
500 {
501 upd = presences[0];
502 break;
503 }
504 }
476 505
477 if (upd != null) 506 if (upd != null)
478 { 507 {
479 // check if we've tried this before.. 508 // check if we've tried this before..
480 // This is one way to end the recursive loop 509 // This is one way to end the recursive loop
481 // 510 //
482 if (upd.Handle == prevRegionHandle) 511 if (upd.RegionID == prevRegionID)
483 { 512 {
484 m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); 513 m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message");
485 HandleUndeliveredMessage(im, result); 514 HandleUndeliveredMessage(im, result);
@@ -496,12 +525,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
496 525
497 if (upd != null) 526 if (upd != null)
498 { 527 {
499 if (upd.AgentOnline) 528 if (upd.Online)
500 { 529 {
501 uint x = 0, y = 0; 530 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID,
502 Utils.LongToUInts(upd.Handle, out x, out y); 531 upd.RegionID);
503 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByPosition(m_Scenes[0].RegionInfo.ScopeID,
504 (int)x, (int)y);
505 if (reginfo != null) 532 if (reginfo != null)
506 { 533 {
507 Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); 534 Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im);
@@ -517,11 +544,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
517 { 544 {
518 if (m_UserRegionMap.ContainsKey(toAgentID)) 545 if (m_UserRegionMap.ContainsKey(toAgentID))
519 { 546 {
520 m_UserRegionMap[toAgentID] = upd.Handle; 547 m_UserRegionMap[toAgentID] = upd.RegionID;
521 } 548 }
522 else 549 else
523 { 550 {
524 m_UserRegionMap.Add(toAgentID, upd.Handle); 551 m_UserRegionMap.Add(toAgentID, upd.RegionID);
525 } 552 }
526 } 553 }
527 result(true); 554 result(true);
@@ -536,12 +563,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
536 563
537 // This is recursive!!!!! 564 // This is recursive!!!!!
538 SendGridInstantMessageViaXMLRPCAsync(im, result, 565 SendGridInstantMessageViaXMLRPCAsync(im, result,
539 upd.Handle); 566 upd.RegionID);
540 } 567 }
541 } 568 }
542 else 569 else
543 { 570 {
544 m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.Handle); 571 m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.RegionID);
545 HandleUndeliveredMessage(im, result); 572 HandleUndeliveredMessage(im, result);
546 } 573 }
547 } 574 }
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs
index 2d4a635..24cbaeb 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs
@@ -37,9 +37,9 @@ using OpenSim.Framework.Client;
37using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39 39
40namespace OpenSim.Region.CoreModules.Avatar.MuteList 40namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
41{ 41{
42 public class MuteListModule : IRegionModule 42 public class MuteListModule : ISharedRegionModule
43 { 43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45
@@ -47,11 +47,8 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList
47 private List<Scene> m_SceneList = new List<Scene>(); 47 private List<Scene> m_SceneList = new List<Scene>();
48 private string m_RestURL = String.Empty; 48 private string m_RestURL = String.Empty;
49 49
50 public void Initialise(Scene scene, IConfigSource config) 50 public void Initialise(IConfigSource config)
51 { 51 {
52 if (!enabled)
53 return;
54
55 IConfig cnf = config.Configs["Messaging"]; 52 IConfig cnf = config.Configs["Messaging"];
56 if (cnf == null) 53 if (cnf == null)
57 { 54 {
@@ -59,39 +56,53 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList
59 return; 56 return;
60 } 57 }
61 58
62 if (cnf != null && cnf.GetString( 59 if (cnf != null && cnf.GetString("MuteListModule", "None") !=
63 "MuteListModule", "None") !=
64 "MuteListModule") 60 "MuteListModule")
65 { 61 {
66 enabled = false; 62 enabled = false;
67 return; 63 return;
68 } 64 }
69 65
66 m_RestURL = cnf.GetString("MuteListURL", "");
67 if (m_RestURL == "")
68 {
69 m_log.Error("[MUTE LIST] Module was enabled, but no URL is given, disabling");
70 enabled = false;
71 return;
72 }
73 }
74
75 public void AddRegion(Scene scene)
76 {
77 if (!enabled)
78 return;
79
70 lock (m_SceneList) 80 lock (m_SceneList)
71 { 81 {
72 if (m_SceneList.Count == 0) 82 m_SceneList.Add(scene);
73 {
74 m_RestURL = cnf.GetString("MuteListURL", "");
75 if (m_RestURL == "")
76 {
77 m_log.Error("[MUTE LIST] Module was enabled, but no URL is given, disabling");
78 enabled = false;
79 return;
80 }
81 }
82 if (!m_SceneList.Contains(scene))
83 m_SceneList.Add(scene);
84 83
85 scene.EventManager.OnNewClient += OnNewClient; 84 scene.EventManager.OnNewClient += OnNewClient;
86 } 85 }
87 } 86 }
88 87
89 public void PostInitialise() 88 public void RegionLoaded(Scene scene)
89 {
90 }
91
92 public void RemoveRegion(Scene scene)
90 { 93 {
91 if (!enabled) 94 if (!enabled)
92 return; 95 return;
93 96
94 if (m_SceneList.Count == 0) 97 lock (m_SceneList)
98 {
99 m_SceneList.Remove(scene);
100 }
101 }
102
103 public void PostInitialise()
104 {
105 if (!enabled)
95 return; 106 return;
96 107
97 m_log.Debug("[MUTE LIST] Mute list enabled"); 108 m_log.Debug("[MUTE LIST] Mute list enabled");
@@ -102,26 +113,15 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList
102 get { return "MuteListModule"; } 113 get { return "MuteListModule"; }
103 } 114 }
104 115
105 public bool IsSharedModule 116 public Type ReplaceableInterface
106 { 117 {
107 get { return true; } 118 get { return null; }
108 } 119 }
109 120
110 public void Close() 121 public void Close()
111 { 122 {
112 } 123 }
113 124
114// private IClientAPI FindClient(UUID agentID)
115// {
116// foreach (Scene s in m_SceneList)
117// {
118// ScenePresence presence = s.GetScenePresence(agentID);
119// if (presence != null && !presence.IsChildAgent)
120// return presence.ControllingClient;
121// }
122// return null;
123// }
124
125 private void OnNewClient(IClientAPI client) 125 private void OnNewClient(IClientAPI client)
126 { 126 {
127 client.OnMuteListRequest += OnMuteListRequest; 127 client.OnMuteListRequest += OnMuteListRequest;
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index 0727fa9..9412735 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -40,82 +40,91 @@ using OpenSim.Region.Framework.Scenes;
40 40
41namespace OpenSim.Region.CoreModules.Avatar.InstantMessage 41namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
42{ 42{
43 public class OfflineMessageModule : IRegionModule 43 public class OfflineMessageModule : ISharedRegionModule
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 private bool enabled = true; 47 private bool enabled = true;
48 private List<Scene> m_SceneList = new List<Scene>(); 48 private List<Scene> m_SceneList = new List<Scene>();
49 private string m_RestURL = String.Empty; 49 private string m_RestURL = String.Empty;
50 IMessageTransferModule m_TransferModule = null;
50 private bool m_ForwardOfflineGroupMessages = true; 51 private bool m_ForwardOfflineGroupMessages = true;
51 52
52 public void Initialise(Scene scene, IConfigSource config) 53 public void Initialise(IConfigSource config)
53 { 54 {
54 if (!enabled)
55 return;
56
57 IConfig cnf = config.Configs["Messaging"]; 55 IConfig cnf = config.Configs["Messaging"];
58 if (cnf == null) 56 if (cnf == null)
59 { 57 {
60 enabled = false; 58 enabled = false;
61 return; 59 return;
62 } 60 }
63 if (cnf != null && cnf.GetString( 61 if (cnf != null && cnf.GetString("OfflineMessageModule", "None") !=
64 "OfflineMessageModule", "None") !=
65 "OfflineMessageModule") 62 "OfflineMessageModule")
66 { 63 {
67 enabled = false; 64 enabled = false;
68 return; 65 return;
69 } 66 }
70 67
71 if (cnf != null) 68 m_RestURL = cnf.GetString("OfflineMessageURL", "");
72 m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", m_ForwardOfflineGroupMessages); 69 if (m_RestURL == "")
70 {
71 m_log.Error("[OFFLINE MESSAGING] Module was enabled, but no URL is given, disabling");
72 enabled = false;
73 return;
74 }
75
76 m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", m_ForwardOfflineGroupMessages);
77 }
78
79 public void AddRegion(Scene scene)
80 {
81 if (!enabled)
82 return;
73 83
74 lock (m_SceneList) 84 lock (m_SceneList)
75 { 85 {
76 if (m_SceneList.Count == 0) 86 m_SceneList.Add(scene);
77 {
78 m_RestURL = cnf.GetString("OfflineMessageURL", "");
79 if (m_RestURL == "")
80 {
81 m_log.Error("[OFFLINE MESSAGING] Module was enabled, but no URL is given, disabling");
82 enabled = false;
83 return;
84 }
85 }
86 if (!m_SceneList.Contains(scene))
87 m_SceneList.Add(scene);
88 87
89 scene.EventManager.OnNewClient += OnNewClient; 88 scene.EventManager.OnNewClient += OnNewClient;
90 } 89 }
91 } 90 }
92 91
93 public void PostInitialise() 92 public void RegionLoaded(Scene scene)
94 { 93 {
95 if (!enabled) 94 if (!enabled)
96 return; 95 return;
97 96
98 if (m_SceneList.Count == 0) 97 if (m_TransferModule == null)
99 return;
100
101 IMessageTransferModule trans = m_SceneList[0].RequestModuleInterface<IMessageTransferModule>();
102 if (trans == null)
103 { 98 {
104 enabled = false; 99 m_TransferModule = scene.RequestModuleInterface<IMessageTransferModule>();
105 100 if (m_TransferModule == null)
106 lock (m_SceneList)
107 { 101 {
108 foreach (Scene s in m_SceneList) 102 scene.EventManager.OnNewClient -= OnNewClient;
109 s.EventManager.OnNewClient -= OnNewClient;
110 103
104 enabled = false;
111 m_SceneList.Clear(); 105 m_SceneList.Clear();
106
107 m_log.Error("[OFFLINE MESSAGING] No message transfer module is enabled. Diabling offline messages");
112 } 108 }
109 m_TransferModule.OnUndeliveredMessage += UndeliveredMessage;
110 }
111 }
113 112
114 m_log.Error("[OFFLINE MESSAGING] No message transfer module is enabled. Diabling offline messages"); 113 public void RemoveRegion(Scene scene)
114 {
115 if (!enabled)
115 return; 116 return;
117
118 lock (m_SceneList)
119 {
120 m_SceneList.Remove(scene);
116 } 121 }
122 }
117 123
118 trans.OnUndeliveredMessage += UndeliveredMessage; 124 public void PostInitialise()
125 {
126 if (!enabled)
127 return;
119 128
120 m_log.Debug("[OFFLINE MESSAGING] Offline messages enabled"); 129 m_log.Debug("[OFFLINE MESSAGING] Offline messages enabled");
121 } 130 }
@@ -125,9 +134,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
125 get { return "OfflineMessageModule"; } 134 get { return "OfflineMessageModule"; }
126 } 135 }
127 136
128 public bool IsSharedModule 137 public Type ReplaceableInterface
129 { 138 {
130 get { return true; } 139 get { return null; }
131 } 140 }
132 141
133 public void Close() 142 public void Close()
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
index f5ab454..bafad82 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.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 */
27using System;
27using System.Collections; 28using System.Collections;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using System.Net; 30using System.Net;
@@ -35,408 +36,123 @@ using OpenMetaverse;
35using OpenSim.Framework; 36using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion; 40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
39 42
40namespace OpenSim.Region.CoreModules.Avatar.InstantMessage 43namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
41{ 44{
42 public class PresenceModule : IRegionModule, IPresenceModule 45 public class PresenceModule : ISharedRegionModule, IPresenceModule
43 { 46 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(
45 48 MethodBase.GetCurrentMethod().DeclaringType);
46 private bool m_Enabled = false;
47 private bool m_Gridmode = false;
48
49 // some default scene for doing things that aren't connected to a specific scene. Avoids locking.
50 private Scene m_initialScene;
51
52 private List<Scene> m_Scenes = new List<Scene>();
53
54 // we currently are only interested in root-agents. If the root isn't here, we don't know the region the
55 // user is in, so we have to ask the messaging server anyway.
56 private Dictionary<UUID, Scene> m_RootAgents =
57 new Dictionary<UUID, Scene>();
58 49
59 public event PresenceChange OnPresenceChange; 50 public event PresenceChange OnPresenceChange;
60 public event BulkPresenceData OnBulkPresenceData; 51 public event BulkPresenceData OnBulkPresenceData;
61 52
62 public void Initialise(Scene scene, IConfigSource config) 53 protected List<Scene> m_Scenes = new List<Scene>();
63 {
64 lock (m_Scenes)
65 {
66 // This is a shared module; Initialise will be called for every region on this server.
67 // Only check config once for the first region.
68 if (m_Scenes.Count == 0)
69 {
70 IConfig cnf = config.Configs["Messaging"];
71 if (cnf != null && cnf.GetString(
72 "PresenceModule", "PresenceModule") !=
73 "PresenceModule")
74 return;
75
76 cnf = config.Configs["Startup"];
77 if (cnf != null)
78 m_Gridmode = cnf.GetBoolean("gridmode", false);
79 54
80 m_Enabled = true; 55 protected IPresenceService m_PresenceService = null;
81 56
82 m_initialScene = scene; 57 protected IPresenceService PresenceService
83 }
84
85 if (m_Gridmode)
86 NotifyMessageServerOfStartup(scene);
87
88 m_Scenes.Add(scene);
89 }
90
91 scene.RegisterModuleInterface<IPresenceModule>(this);
92
93 scene.EventManager.OnNewClient += OnNewClient;
94 scene.EventManager.OnSetRootAgentScene += OnSetRootAgentScene;
95 scene.EventManager.OnMakeChildAgent += OnMakeChildAgent;
96 }
97
98 public void PostInitialise()
99 {
100 }
101
102 public void Close()
103 { 58 {
104 if (!m_Gridmode || !m_Enabled) 59 get
105 return;
106
107 if (OnPresenceChange != null)
108 { 60 {
109 lock (m_RootAgents) 61 if (m_PresenceService == null)
110 { 62 {
111 // on shutdown, users are kicked, too 63 if (m_Scenes.Count > 0)
112 foreach (KeyValuePair<UUID, Scene> pair in m_RootAgents) 64 m_PresenceService = m_Scenes[0].RequestModuleInterface<IPresenceService>();
113 {
114 OnPresenceChange(new PresenceInfo(pair.Key, UUID.Zero));
115 }
116 } 65 }
117 }
118 66
119 lock (m_Scenes) 67 return m_PresenceService;
120 {
121 foreach (Scene scene in m_Scenes)
122 NotifyMessageServerOfShutdown(scene);
123 } 68 }
124 } 69 }
125 70
126 public string Name 71 public void Initialise(IConfigSource config)
127 {
128 get { return "PresenceModule"; }
129 }
130
131 public bool IsSharedModule
132 { 72 {
133 get { return true; }
134 } 73 }
135 74
136 public void RequestBulkPresenceData(UUID[] users) 75 public void AddRegion(Scene scene)
137 { 76 {
138 if (OnBulkPresenceData != null) 77 m_Scenes.Add(scene);
139 {
140 PresenceInfo[] result = new PresenceInfo[users.Length];
141 if (m_Gridmode)
142 {
143 // first check the local information
144 List<UUID> uuids = new List<UUID>(); // the uuids to check remotely
145 List<int> indices = new List<int>(); // just for performance.
146 lock (m_RootAgents)
147 {
148 for (int i = 0; i < uuids.Count; ++i)
149 {
150 Scene scene;
151 if (m_RootAgents.TryGetValue(users[i], out scene))
152 {
153 result[i] = new PresenceInfo(users[i], scene.RegionInfo.RegionID);
154 }
155 else
156 {
157 uuids.Add(users[i]);
158 indices.Add(i);
159 }
160 }
161 }
162 78
163 // now we have filtered out all the local root agents. The rest we have to request info about 79 scene.EventManager.OnNewClient += OnNewClient;
164 Dictionary<UUID, FriendRegionInfo> infos = m_initialScene.GetFriendRegionInfos(uuids);
165 for (int i = 0; i < uuids.Count; ++i)
166 {
167 FriendRegionInfo info;
168 if (infos.TryGetValue(uuids[i], out info) && info.isOnline)
169 {
170 UUID regionID = info.regionID;
171 if (regionID == UUID.Zero)
172 {
173 // TODO this is the old messaging-server protocol; only the regionHandle is available.
174 // Fetch region-info to get the id
175 uint x = 0, y = 0;
176 Utils.LongToUInts(info.regionHandle, out x, out y);
177 GridRegion regionInfo = m_initialScene.GridService.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID,
178 (int)x, (int)y);
179 regionID = regionInfo.RegionID;
180 }
181 result[indices[i]] = new PresenceInfo(uuids[i], regionID);
182 }
183 else result[indices[i]] = new PresenceInfo(uuids[i], UUID.Zero);
184 }
185 }
186 else
187 {
188 // in standalone mode, we have all the info locally available.
189 lock (m_RootAgents)
190 {
191 for (int i = 0; i < users.Length; ++i)
192 {
193 Scene scene;
194 if (m_RootAgents.TryGetValue(users[i], out scene))
195 {
196 result[i] = new PresenceInfo(users[i], scene.RegionInfo.RegionID);
197 }
198 else
199 {
200 result[i] = new PresenceInfo(users[i], UUID.Zero);
201 }
202 }
203 }
204 }
205 80
206 // tell everyone 81 scene.RegisterModuleInterface<IPresenceModule>(this);
207 OnBulkPresenceData(result);
208 }
209 } 82 }
210 83
211 // new client doesn't mean necessarily that user logged in, it just means it entered one of the 84 public void RegionLoaded(Scene scene)
212 // the regions on this server
213 public void OnNewClient(IClientAPI client)
214 { 85 {
215 client.OnConnectionClosed += OnConnectionClosed;
216 client.OnLogout += OnLogout;
217
218 // KLUDGE: See handler for details.
219 client.OnEconomyDataRequest += OnEconomyDataRequest;
220 } 86 }
221 87
222 // connection closed just means *one* client connection has been closed. It doesn't mean that the 88 public void RemoveRegion(Scene scene)
223 // user has logged off; it might have just TPed away.
224 public void OnConnectionClosed(IClientAPI client)
225 { 89 {
226 // TODO: Have to think what we have to do here... 90 m_Scenes.Remove(scene);
227 // Should we just remove the root from the list (if scene matches)?
228 if (!(client.Scene is Scene))
229 return;
230 Scene scene = (Scene)client.Scene;
231
232 lock (m_RootAgents)
233 {
234 Scene rootScene;
235 if (!(m_RootAgents.TryGetValue(client.AgentId, out rootScene)) || scene != rootScene)
236 return;
237
238 m_RootAgents.Remove(client.AgentId);
239 }
240
241 // Should it have logged off, we'll do the logout part in OnLogout, even if no root is stored
242 // anymore. It logged off, after all...
243 } 91 }
244 92
245 // Triggered when the user logs off. 93 public void PostInitialise()
246 public void OnLogout(IClientAPI client)
247 { 94 {
248 if (!(client.Scene is Scene))
249 return;
250 Scene scene = (Scene)client.Scene;
251
252 // On logout, we really remove the client from rootAgents, even if the scene doesn't match
253 lock (m_RootAgents)
254 {
255 if (m_RootAgents.ContainsKey(client.AgentId)) m_RootAgents.Remove(client.AgentId);
256 }
257
258 // now inform the messaging server and anyone who is interested
259 NotifyMessageServerOfAgentLeaving(client.AgentId, scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle);
260 if (OnPresenceChange != null) OnPresenceChange(new PresenceInfo(client.AgentId, UUID.Zero));
261 } 95 }
262 96
263 public void OnSetRootAgentScene(UUID agentID, Scene scene) 97 public void Close()
264 { 98 {
265 // OnSetRootAgentScene can be called from several threads at once (with different agentID).
266 // Concurrent access to m_RootAgents is prone to failure on multi-core/-processor systems without
267 // correct locking).
268 lock (m_RootAgents)
269 {
270 Scene rootScene;
271 if (m_RootAgents.TryGetValue(agentID, out rootScene) && scene == rootScene)
272 {
273 return;
274 }
275 m_RootAgents[agentID] = scene;
276 }
277
278 // inform messaging server that agent changed the region
279 Util.FireAndForget(
280 delegate(object o)
281 {
282 NotifyMessageServerOfAgentLocation(agentID, scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle);
283 }
284 );
285 } 99 }
286 100
287 private void OnEconomyDataRequest(UUID agentID) 101 public string Name
288 { 102 {
289 // KLUDGE: This is the only way I found to get a message (only) after login was completed and the 103 get { return "PresenceModule"; }
290 // client is connected enough to receive UDP packets.
291 // This packet seems to be sent only once, just after connection was established to the first
292 // region after login.
293 // We use it here to trigger a presence update; the old update-on-login was never be heard by
294 // the freshly logged in viewer, as it wasn't connected to the region at that time.
295 // TODO: Feel free to replace this by a better solution if you find one.
296
297 // get the agent. This should work every time, as we just got a packet from it
298 ScenePresence agent = null;
299 lock (m_Scenes)
300 {
301 foreach (Scene scene in m_Scenes)
302 {
303 agent = scene.GetScenePresence(agentID);
304 if (agent != null) break;
305 }
306 }
307
308 // just to be paranoid...
309 if (agent == null)
310 {
311 m_log.ErrorFormat("[PRESENCE]: Got a packet from agent {0} who can't be found anymore!?", agentID);
312 return;
313 }
314
315 // we are a bit premature here, but the next packet will switch this child agent to root.
316 if (OnPresenceChange != null) OnPresenceChange(new PresenceInfo(agentID, agent.Scene.RegionInfo.RegionID));
317 } 104 }
318 105
319 public void OnMakeChildAgent(ScenePresence agent) 106 public Type ReplaceableInterface
320 { 107 {
321 // OnMakeChildAgent can be called from several threads at once (with different agent). 108 get { return null; }
322 // Concurrent access to m_RootAgents is prone to failure on multi-core/-processor systems without
323 // correct locking).
324 lock (m_RootAgents)
325 {
326 Scene rootScene;
327 if (m_RootAgents.TryGetValue(agent.UUID, out rootScene) && agent.Scene == rootScene)
328 {
329 m_RootAgents.Remove(agent.UUID);
330 }
331 }
332 // don't notify the messaging-server; either this agent just had been downgraded and another one will be upgraded
333 // to root momentarily (which will notify the messaging-server), or possibly it will be closed in a moment,
334 // which will update the messaging-server, too.
335 } 109 }
336 110
337 private void NotifyMessageServerOfStartup(Scene scene) 111 public void RequestBulkPresenceData(UUID[] users)
338 { 112 {
339 Hashtable xmlrpcdata = new Hashtable();
340 xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString();
341 ArrayList SendParams = new ArrayList();
342 SendParams.Add(xmlrpcdata);
343 try
344 {
345 XmlRpcRequest UpRequest = new XmlRpcRequest("region_startup", SendParams);
346 XmlRpcResponse resp = UpRequest.Send(scene.CommsManager.NetworkServersInfo.MessagingURL, 5000);
347
348 Hashtable responseData = (Hashtable)resp.Value;
349 if (responseData == null || (!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE")
350 {
351 m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region startup for region {0}", scene.RegionInfo.RegionName);
352 }
353 }
354 catch (WebException)
355 {
356 m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region startup for region {0}", scene.RegionInfo.RegionName);
357 }
358 } 113 }
359 114
360 private void NotifyMessageServerOfShutdown(Scene scene) 115 public void OnNewClient(IClientAPI client)
361 { 116 {
362 if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty) 117 client.AddGenericPacketHandler("requestonlinenotification", OnRequestOnlineNotification);
363 return;
364
365 Hashtable xmlrpcdata = new Hashtable();
366 xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString();
367 ArrayList SendParams = new ArrayList();
368 SendParams.Add(xmlrpcdata);
369 try
370 {
371 XmlRpcRequest DownRequest = new XmlRpcRequest("region_shutdown", SendParams);
372 XmlRpcResponse resp = DownRequest.Send(scene.CommsManager.NetworkServersInfo.MessagingURL, 5000);
373
374 Hashtable responseData = (Hashtable)resp.Value;
375 if ((!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE")
376 {
377 m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region shutdown for region {0}", scene.RegionInfo.RegionName);
378 }
379 }
380 catch (WebException)
381 {
382 m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region shutdown for region {0}", scene.RegionInfo.RegionName);
383 }
384 } 118 }
385 119
386 private void NotifyMessageServerOfAgentLocation(UUID agentID, UUID region, ulong regionHandle) 120 public void OnRequestOnlineNotification(Object sender, string method, List<String> args)
387 { 121 {
388 if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty) 122 if (!(sender is IClientAPI))
389 return; 123 return;
390 124
391 Hashtable xmlrpcdata = new Hashtable(); 125 IClientAPI client = (IClientAPI)sender;
392 xmlrpcdata["AgentID"] = agentID.ToString(); 126 m_log.DebugFormat("[PRESENCE MODULE]: OnlineNotification requested by {0}", client.Name);
393 xmlrpcdata["RegionUUID"] = region.ToString();
394 xmlrpcdata["RegionHandle"] = regionHandle.ToString();
395 ArrayList SendParams = new ArrayList();
396 SendParams.Add(xmlrpcdata);
397 try
398 {
399 XmlRpcRequest LocationRequest = new XmlRpcRequest("agent_location", SendParams);
400 XmlRpcResponse resp = LocationRequest.Send(m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL, 5000);
401 127
402 Hashtable responseData = (Hashtable)resp.Value; 128 PresenceInfo[] status = PresenceService.GetAgents(args.ToArray());
403 if ((!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE")
404 {
405 m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent location for {0}", agentID.ToString());
406 }
407 }
408 catch (WebException)
409 {
410 m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent location for {0}", agentID.ToString());
411 }
412 }
413 129
414 private void NotifyMessageServerOfAgentLeaving(UUID agentID, UUID region, ulong regionHandle) 130 List<UUID> online = new List<UUID>();
415 { 131 List<UUID> offline = new List<UUID>();
416 if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty)
417 return;
418 132
419 Hashtable xmlrpcdata = new Hashtable(); 133 foreach (PresenceInfo pi in status)
420 xmlrpcdata["AgentID"] = agentID.ToString();
421 xmlrpcdata["RegionUUID"] = region.ToString();
422 xmlrpcdata["RegionHandle"] = regionHandle.ToString();
423 ArrayList SendParams = new ArrayList();
424 SendParams.Add(xmlrpcdata);
425 try
426 { 134 {
427 XmlRpcRequest LeavingRequest = new XmlRpcRequest("agent_leaving", SendParams); 135 UUID uuid = new UUID(pi.UserID);
428 XmlRpcResponse resp = LeavingRequest.Send(m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL, 5000); 136 if (pi.Online)
429
430 Hashtable responseData = (Hashtable)resp.Value;
431 if ((!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE")
432 { 137 {
433 m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent leaving for {0}", agentID.ToString()); 138 if (!online.Contains(uuid))
139 {
140 online.Add(uuid);
141 if (offline.Contains(uuid))
142 offline.Remove(uuid);
143 }
144 }
145 else
146 {
147 if (!online.Contains(uuid) && !offline.Contains(uuid))
148 offline.Add(uuid);
434 } 149 }
435 } 150 }
436 catch (WebException) 151
437 { 152 if (online.Count > 0)
438 m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent leaving for {0}", agentID.ToString()); 153 client.SendAgentOnline(online.ToArray());
439 } 154 if (offline.Count > 0)
155 client.SendAgentOffline(offline.ToArray());
440 } 156 }
441 } 157 }
442} 158}
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 160a9bd..dc7439c 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -37,7 +37,7 @@ using log4net;
37using OpenMetaverse; 37using OpenMetaverse;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Communications; 39using OpenSim.Framework.Communications;
40using OpenSim.Framework.Communications.Cache; 40
41using OpenSim.Framework.Communications.Osp; 41using OpenSim.Framework.Communications.Osp;
42using OpenSim.Framework.Serialization; 42using OpenSim.Framework.Serialization;
43using OpenSim.Framework.Serialization.External; 43using OpenSim.Framework.Serialization.External;
@@ -53,7 +53,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
53 53
54 protected TarArchiveReader archive; 54 protected TarArchiveReader archive;
55 55
56 private CachedUserInfo m_userInfo; 56 private UserAccount m_userInfo;
57 private string m_invPath; 57 private string m_invPath;
58 58
59 /// <value> 59 /// <value>
@@ -67,7 +67,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
67 private Stream m_loadStream; 67 private Stream m_loadStream;
68 68
69 public InventoryArchiveReadRequest( 69 public InventoryArchiveReadRequest(
70 Scene scene, CachedUserInfo userInfo, string invPath, string loadPath) 70 Scene scene, UserAccount userInfo, string invPath, string loadPath)
71 : this( 71 : this(
72 scene, 72 scene,
73 userInfo, 73 userInfo,
@@ -77,7 +77,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
77 } 77 }
78 78
79 public InventoryArchiveReadRequest( 79 public InventoryArchiveReadRequest(
80 Scene scene, CachedUserInfo userInfo, string invPath, Stream loadStream) 80 Scene scene, UserAccount userInfo, string invPath, Stream loadStream)
81 { 81 {
82 m_scene = scene; 82 m_scene = scene;
83 m_userInfo = userInfo; 83 m_userInfo = userInfo;
@@ -103,7 +103,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
103 //InventoryFolderImpl rootDestinationFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); 103 //InventoryFolderImpl rootDestinationFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath);
104 InventoryFolderBase rootDestinationFolder 104 InventoryFolderBase rootDestinationFolder
105 = InventoryArchiveUtils.FindFolderByPath( 105 = InventoryArchiveUtils.FindFolderByPath(
106 m_scene.InventoryService, m_userInfo.UserProfile.ID, m_invPath); 106 m_scene.InventoryService, m_userInfo.PrincipalID, m_invPath);
107 107
108 if (null == rootDestinationFolder) 108 if (null == rootDestinationFolder)
109 { 109 {
@@ -280,7 +280,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
280 // even though there is a AssetType.RootCategory 280 // even though there is a AssetType.RootCategory
281 destFolder 281 destFolder
282 = new InventoryFolderBase( 282 = new InventoryFolderBase(
283 newFolderId, newFolderName, m_userInfo.UserProfile.ID, 283 newFolderId, newFolderName, m_userInfo.PrincipalID,
284 (short)AssetType.Unknown, destFolder.ID, 1); 284 (short)AssetType.Unknown, destFolder.ID, 1);
285 m_scene.InventoryService.AddFolder(destFolder); 285 m_scene.InventoryService.AddFolder(destFolder);
286 286
@@ -357,7 +357,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
357 // Don't use the item ID that's in the file 357 // Don't use the item ID that's in the file
358 item.ID = UUID.Random(); 358 item.ID = UUID.Random();
359 359
360 UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager); 360 UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService);
361 if (UUID.Zero != ospResolvedId) 361 if (UUID.Zero != ospResolvedId)
362 { 362 {
363 item.CreatorIdAsUuid = ospResolvedId; 363 item.CreatorIdAsUuid = ospResolvedId;
@@ -368,10 +368,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
368 } 368 }
369 else 369 else
370 { 370 {
371 item.CreatorIdAsUuid = m_userInfo.UserProfile.ID; 371 item.CreatorIdAsUuid = m_userInfo.PrincipalID;
372 } 372 }
373 373
374 item.Owner = m_userInfo.UserProfile.ID; 374 item.Owner = m_userInfo.PrincipalID;
375 375
376 // Reset folder ID to the one in which we want to load it 376 // Reset folder ID to the one in which we want to load it
377 item.Folder = loadFolder.ID; 377 item.Folder = loadFolder.ID;
@@ -416,7 +416,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
416 416
417 //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); 417 //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
418 418
419 AssetBase asset = new AssetBase(new UUID(uuid), "RandomName", assetType); 419 AssetBase asset = new AssetBase(new UUID(uuid), "RandomName", assetType, UUID.Zero.ToString());
420 asset.Data = data; 420 asset.Data = data;
421 421
422 m_scene.AssetService.Store(asset); 422 m_scene.AssetService.Store(asset);
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index 98b686e..ef10104 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -37,10 +37,11 @@ using OpenSim.Framework;
37using OpenSim.Framework.Serialization; 37using OpenSim.Framework.Serialization;
38using OpenSim.Framework.Serialization.External; 38using OpenSim.Framework.Serialization.External;
39using OpenSim.Framework.Communications; 39using OpenSim.Framework.Communications;
40using OpenSim.Framework.Communications.Cache; 40
41using OpenSim.Framework.Communications.Osp; 41using OpenSim.Framework.Communications.Osp;
42using OpenSim.Region.CoreModules.World.Archiver; 42using OpenSim.Region.CoreModules.World.Archiver;
43using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Services.Interfaces;
44 45
45namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver 46namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
46{ 47{
@@ -54,7 +55,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
54 private const string STAR_WILDCARD = "*"; 55 private const string STAR_WILDCARD = "*";
55 56
56 private InventoryArchiverModule m_module; 57 private InventoryArchiverModule m_module;
57 private CachedUserInfo m_userInfo; 58 private UserAccount m_userInfo;
58 private string m_invPath; 59 private string m_invPath;
59 protected TarArchiveWriter m_archiveWriter; 60 protected TarArchiveWriter m_archiveWriter;
60 protected UuidGatherer m_assetGatherer; 61 protected UuidGatherer m_assetGatherer;
@@ -89,7 +90,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
89 /// </summary> 90 /// </summary>
90 public InventoryArchiveWriteRequest( 91 public InventoryArchiveWriteRequest(
91 Guid id, InventoryArchiverModule module, Scene scene, 92 Guid id, InventoryArchiverModule module, Scene scene,
92 CachedUserInfo userInfo, string invPath, string savePath) 93 UserAccount userInfo, string invPath, string savePath)
93 : this( 94 : this(
94 id, 95 id,
95 module, 96 module,
@@ -105,7 +106,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
105 /// </summary> 106 /// </summary>
106 public InventoryArchiveWriteRequest( 107 public InventoryArchiveWriteRequest(
107 Guid id, InventoryArchiverModule module, Scene scene, 108 Guid id, InventoryArchiverModule module, Scene scene,
108 CachedUserInfo userInfo, string invPath, Stream saveStream) 109 UserAccount userInfo, string invPath, Stream saveStream)
109 { 110 {
110 m_id = id; 111 m_id = id;
111 m_module = module; 112 m_module = module;
@@ -148,7 +149,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
148 m_userUuids[inventoryItem.CreatorIdAsUuid] = 1; 149 m_userUuids[inventoryItem.CreatorIdAsUuid] = 1;
149 150
150 InventoryItemBase saveItem = (InventoryItemBase)inventoryItem.Clone(); 151 InventoryItemBase saveItem = (InventoryItemBase)inventoryItem.Clone();
151 saveItem.CreatorId = OspResolver.MakeOspa(saveItem.CreatorIdAsUuid, m_scene.CommsManager); 152 saveItem.CreatorId = OspResolver.MakeOspa(saveItem.CreatorIdAsUuid, m_scene.UserAccountService);
152 153
153 string serialization = UserInventoryItemSerializer.Serialize(saveItem); 154 string serialization = UserInventoryItemSerializer.Serialize(saveItem);
154 m_archiveWriter.WriteFile(filename, serialization); 155 m_archiveWriter.WriteFile(filename, serialization);
@@ -215,7 +216,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
215 { 216 {
216 InventoryFolderBase inventoryFolder = null; 217 InventoryFolderBase inventoryFolder = null;
217 InventoryItemBase inventoryItem = null; 218 InventoryItemBase inventoryItem = null;
218 InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.UserProfile.ID); 219 InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.PrincipalID);
219 220
220 bool foundStar = false; 221 bool foundStar = false;
221 222
@@ -318,14 +319,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
318 foreach (UUID creatorId in m_userUuids.Keys) 319 foreach (UUID creatorId in m_userUuids.Keys)
319 { 320 {
320 // Record the creator of this item 321 // Record the creator of this item
321 CachedUserInfo creator 322 UserAccount creator = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, creatorId);
322 = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(creatorId);
323 323
324 if (creator != null) 324 if (creator != null)
325 { 325 {
326 m_archiveWriter.WriteFile( 326 m_archiveWriter.WriteFile(
327 ArchiveConstants.USERS_PATH + creator.UserProfile.Name + ".xml", 327 ArchiveConstants.USERS_PATH + creator.FirstName + " " + creator.LastName + ".xml",
328 UserProfileSerializer.Serialize(creator.UserProfile)); 328 UserProfileSerializer.Serialize(creator.PrincipalID, creator.FirstName, creator.LastName));
329 } 329 }
330 else 330 else
331 { 331 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index ecd60bd..71b3062 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -34,7 +34,7 @@ using Nini.Config;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Communications; 36using OpenSim.Framework.Communications;
37using OpenSim.Framework.Communications.Cache; 37
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
@@ -113,7 +113,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
113 /// Trigger the inventory archive saved event. 113 /// Trigger the inventory archive saved event.
114 /// </summary> 114 /// </summary>
115 protected internal void TriggerInventoryArchiveSaved( 115 protected internal void TriggerInventoryArchiveSaved(
116 Guid id, bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, 116 Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
117 Exception reportedException) 117 Exception reportedException)
118 { 118 {
119 InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved; 119 InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved;
@@ -125,20 +125,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
125 { 125 {
126 if (m_scenes.Count > 0) 126 if (m_scenes.Count > 0)
127 { 127 {
128 CachedUserInfo userInfo = GetUserInfo(firstName, lastName, pass); 128 UserAccount userInfo = GetUserInfo(firstName, lastName, pass);
129 129
130 if (userInfo != null) 130 if (userInfo != null)
131 { 131 {
132 if (CheckPresence(userInfo.UserProfile.ID)) 132 if (CheckPresence(userInfo.PrincipalID))
133 { 133 {
134 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); 134 try
135 {
136 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute();
137 }
138 catch (EntryPointNotFoundException e)
139 {
140 m_log.ErrorFormat(
141 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
142 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
143 m_log.Error(e);
144
145 return false;
146 }
147
135 return true; 148 return true;
136 } 149 }
137 else 150 else
138 { 151 {
139 m_log.ErrorFormat( 152 m_log.ErrorFormat(
140 "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", 153 "[INVENTORY ARCHIVER]: User {0} {1} {2} not logged in to this region simulator",
141 userInfo.UserProfile.Name, userInfo.UserProfile.ID); 154 userInfo.FirstName, userInfo.LastName, userInfo.PrincipalID);
142 } 155 }
143 } 156 }
144 } 157 }
@@ -150,20 +163,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
150 { 163 {
151 if (m_scenes.Count > 0) 164 if (m_scenes.Count > 0)
152 { 165 {
153 CachedUserInfo userInfo = GetUserInfo(firstName, lastName, pass); 166 UserAccount userInfo = GetUserInfo(firstName, lastName, pass);
154 167
155 if (userInfo != null) 168 if (userInfo != null)
156 { 169 {
157 if (CheckPresence(userInfo.UserProfile.ID)) 170 if (CheckPresence(userInfo.PrincipalID))
158 { 171 {
159 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); 172 try
173 {
174 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute();
175 }
176 catch (EntryPointNotFoundException e)
177 {
178 m_log.ErrorFormat(
179 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
180 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
181 m_log.Error(e);
182
183 return false;
184 }
185
160 return true; 186 return true;
161 } 187 }
162 else 188 else
163 { 189 {
164 m_log.ErrorFormat( 190 m_log.ErrorFormat(
165 "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", 191 "[INVENTORY ARCHIVER]: User {0} {1} {2} not logged in to this region simulator",
166 userInfo.UserProfile.Name, userInfo.UserProfile.ID); 192 userInfo.FirstName, userInfo.LastName, userInfo.PrincipalID);
167 } 193 }
168 } 194 }
169 } 195 }
@@ -175,14 +201,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
175 { 201 {
176 if (m_scenes.Count > 0) 202 if (m_scenes.Count > 0)
177 { 203 {
178 CachedUserInfo userInfo = GetUserInfo(firstName, lastName, pass); 204 UserAccount userInfo = GetUserInfo(firstName, lastName, pass);
179 205
180 if (userInfo != null) 206 if (userInfo != null)
181 { 207 {
182 if (CheckPresence(userInfo.UserProfile.ID)) 208 if (CheckPresence(userInfo.PrincipalID))
183 { 209 {
184 InventoryArchiveReadRequest request = 210 InventoryArchiveReadRequest request;
185 new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); 211
212 try
213 {
214 request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream);
215 }
216 catch (EntryPointNotFoundException e)
217 {
218 m_log.ErrorFormat(
219 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
220 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
221 m_log.Error(e);
222
223 return false;
224 }
225
186 UpdateClientWithLoadedNodes(userInfo, request.Execute()); 226 UpdateClientWithLoadedNodes(userInfo, request.Execute());
187 227
188 return true; 228 return true;
@@ -190,8 +230,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
190 else 230 else
191 { 231 {
192 m_log.ErrorFormat( 232 m_log.ErrorFormat(
193 "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", 233 "[INVENTORY ARCHIVER]: User {0} {1} {2} not logged in to this region simulator",
194 userInfo.UserProfile.Name, userInfo.UserProfile.ID); 234 userInfo.FirstName, userInfo.LastName, userInfo.PrincipalID);
195 } 235 }
196 } 236 }
197 } 237 }
@@ -203,14 +243,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
203 { 243 {
204 if (m_scenes.Count > 0) 244 if (m_scenes.Count > 0)
205 { 245 {
206 CachedUserInfo userInfo = GetUserInfo(firstName, lastName, pass); 246 UserAccount userInfo = GetUserInfo(firstName, lastName, pass);
207 247
208 if (userInfo != null) 248 if (userInfo != null)
209 { 249 {
210 if (CheckPresence(userInfo.UserProfile.ID)) 250 if (CheckPresence(userInfo.PrincipalID))
211 { 251 {
212 InventoryArchiveReadRequest request = 252 InventoryArchiveReadRequest request;
213 new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); 253
254 try
255 {
256 request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath);
257 }
258 catch (EntryPointNotFoundException e)
259 {
260 m_log.ErrorFormat(
261 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
262 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
263 m_log.Error(e);
264
265 return false;
266 }
267
214 UpdateClientWithLoadedNodes(userInfo, request.Execute()); 268 UpdateClientWithLoadedNodes(userInfo, request.Execute());
215 269
216 return true; 270 return true;
@@ -218,8 +272,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
218 else 272 else
219 { 273 {
220 m_log.ErrorFormat( 274 m_log.ErrorFormat(
221 "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", 275 "[INVENTORY ARCHIVER]: User {0} {1} {2} not logged in to this region simulator",
222 userInfo.UserProfile.Name, userInfo.UserProfile.ID); 276 userInfo.FirstName, userInfo.LastName, userInfo.PrincipalID);
223 } 277 }
224 } 278 }
225 } 279 }
@@ -291,7 +345,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
291 } 345 }
292 346
293 private void SaveInvConsoleCommandCompleted( 347 private void SaveInvConsoleCommandCompleted(
294 Guid id, bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, 348 Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
295 Exception reportedException) 349 Exception reportedException)
296 { 350 {
297 lock (m_pendingConsoleSaves) 351 lock (m_pendingConsoleSaves)
@@ -304,13 +358,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
304 358
305 if (succeeded) 359 if (succeeded)
306 { 360 {
307 m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive for {0}", userInfo.UserProfile.Name); 361 m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive for {0} {1}", userInfo.FirstName, userInfo.LastName);
308 } 362 }
309 else 363 else
310 { 364 {
311 m_log.ErrorFormat( 365 m_log.ErrorFormat(
312 "[INVENTORY ARCHIVER]: Archive save for {0} failed - {1}", 366 "[INVENTORY ARCHIVER]: Archive save for {0} {1} failed - {2}",
313 userInfo.UserProfile.Name, reportedException.Message); 367 userInfo.FirstName, userInfo.LastName, reportedException.Message);
314 } 368 }
315 } 369 }
316 370
@@ -321,11 +375,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
321 /// <param name="lastName"></param> 375 /// <param name="lastName"></param>
322 /// <param name="pass">User password</param> 376 /// <param name="pass">User password</param>
323 /// <returns></returns> 377 /// <returns></returns>
324 protected CachedUserInfo GetUserInfo(string firstName, string lastName, string pass) 378 protected UserAccount GetUserInfo(string firstName, string lastName, string pass)
325 { 379 {
326 CachedUserInfo userInfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); 380 UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, firstName, lastName);
327 //m_aScene.CommsManager.UserService.GetUserProfile(firstName, lastName); 381 if (null == account)
328 if (null == userInfo)
329 { 382 {
330 m_log.ErrorFormat( 383 m_log.ErrorFormat(
331 "[INVENTORY ARCHIVER]: Failed to find user info for {0} {1}", 384 "[INVENTORY ARCHIVER]: Failed to find user info for {0} {1}",
@@ -335,9 +388,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
335 388
336 try 389 try
337 { 390 {
338 if (m_aScene.CommsManager.UserService.AuthenticateUserByPassword(userInfo.UserProfile.ID, pass)) 391 if (m_aScene.AuthenticationService.Authenticate(account.PrincipalID, pass, 1) != string.Empty)
339 { 392 {
340 return userInfo; 393 return account;
341 } 394 }
342 else 395 else
343 { 396 {
@@ -358,14 +411,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
358 /// Notify the client of loaded nodes if they are logged in 411 /// Notify the client of loaded nodes if they are logged in
359 /// </summary> 412 /// </summary>
360 /// <param name="loadedNodes">Can be empty. In which case, nothing happens</param> 413 /// <param name="loadedNodes">Can be empty. In which case, nothing happens</param>
361 private void UpdateClientWithLoadedNodes(CachedUserInfo userInfo, List<InventoryNodeBase> loadedNodes) 414 private void UpdateClientWithLoadedNodes(UserAccount userInfo, List<InventoryNodeBase> loadedNodes)
362 { 415 {
363 if (loadedNodes.Count == 0) 416 if (loadedNodes.Count == 0)
364 return; 417 return;
365 418
366 foreach (Scene scene in m_scenes.Values) 419 foreach (Scene scene in m_scenes.Values)
367 { 420 {
368 ScenePresence user = scene.GetScenePresence(userInfo.UserProfile.ID); 421 ScenePresence user = scene.GetScenePresence(userInfo.PrincipalID);
369 422
370 if (user != null && !user.IsChildAgent) 423 if (user != null && !user.IsChildAgent)
371 { 424 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index e4dad18..9c95e78 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -38,7 +38,7 @@ using OpenSim.Framework;
38using OpenSim.Framework.Serialization; 38using OpenSim.Framework.Serialization;
39using OpenSim.Framework.Serialization.External; 39using OpenSim.Framework.Serialization.External;
40using OpenSim.Framework.Communications; 40using OpenSim.Framework.Communications;
41using OpenSim.Framework.Communications.Cache; 41
42using OpenSim.Framework.Communications.Osp; 42using OpenSim.Framework.Communications.Osp;
43using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; 43using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
44using OpenSim.Region.CoreModules.World.Serialiser; 44using OpenSim.Region.CoreModules.World.Serialiser;
@@ -65,7 +65,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
65 } 65 }
66 66
67 private void SaveCompleted( 67 private void SaveCompleted(
68 Guid id, bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, 68 Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
69 Exception reportedException) 69 Exception reportedException)
70 { 70 {
71 mre.Set(); 71 mre.Set();
@@ -76,124 +76,126 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
76 /// </summary> 76 /// </summary>
77 // Commenting for now! The mock inventory service needs more beef, at least for 77 // Commenting for now! The mock inventory service needs more beef, at least for
78 // GetFolderForType 78 // GetFolderForType
79 [Test] 79 // REFACTORING PROBLEM. This needs to be rewritten.
80 public void TestSaveIarV0_1() 80
81 { 81// [Test]
82 TestHelper.InMethod(); 82// public void TestSaveIarV0_1()
83 //log4net.Config.XmlConfigurator.Configure(); 83// {
84 84// TestHelper.InMethod();
85 InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); 85// //log4net.Config.XmlConfigurator.Configure();
86 86
87 Scene scene = SceneSetupHelpers.SetupScene("Inventory"); 87// InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
88 SceneSetupHelpers.SetupSceneModules(scene, archiverModule); 88
89 CommunicationsManager cm = scene.CommsManager; 89// Scene scene = SceneSetupHelpers.SetupScene("Inventory");
90 90// SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
91 // Create user 91// CommunicationsManager cm = scene.CommsManager;
92 string userFirstName = "Jock"; 92
93 string userLastName = "Stirrup"; 93// // Create user
94 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); 94// string userFirstName = "Jock";
95 95// string userLastName = "Stirrup";
96 lock (this) 96// UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
97 { 97
98 UserProfileTestUtils.CreateUserWithInventory( 98// lock (this)
99 cm, userFirstName, userLastName, userId, InventoryReceived); 99// {
100 Monitor.Wait(this, 60000); 100// UserProfileTestUtils.CreateUserWithInventory(
101 } 101// cm, userFirstName, userLastName, userId, InventoryReceived);
102 102// Monitor.Wait(this, 60000);
103 // Create asset 103// }
104 SceneObjectGroup object1; 104
105 SceneObjectPart part1; 105// // Create asset
106 { 106// SceneObjectGroup object1;
107 string partName = "My Little Dog Object"; 107// SceneObjectPart part1;
108 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); 108// {
109 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); 109// string partName = "My Little Dog Object";
110 Vector3 groupPosition = new Vector3(10, 20, 30); 110// UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
111 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); 111// PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
112 Vector3 offsetPosition = new Vector3(5, 10, 15); 112// Vector3 groupPosition = new Vector3(10, 20, 30);
113 113// Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
114 part1 114// Vector3 offsetPosition = new Vector3(5, 10, 15);
115 = new SceneObjectPart( 115
116 ownerId, shape, groupPosition, rotationOffset, offsetPosition); 116// part1
117 part1.Name = partName; 117// = new SceneObjectPart(
118 118// ownerId, shape, groupPosition, rotationOffset, offsetPosition);
119 object1 = new SceneObjectGroup(part1); 119// part1.Name = partName;
120 scene.AddNewSceneObject(object1, false); 120
121 } 121// object1 = new SceneObjectGroup(part1);
122 122// scene.AddNewSceneObject(object1, false);
123 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); 123// }
124 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); 124
125 scene.AssetService.Store(asset1); 125// UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
126 126// AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
127 // Create item 127// scene.AssetService.Store(asset1);
128 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); 128
129 InventoryItemBase item1 = new InventoryItemBase(); 129// // Create item
130 item1.Name = "My Little Dog"; 130// UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
131 item1.AssetID = asset1.FullID; 131// InventoryItemBase item1 = new InventoryItemBase();
132 item1.ID = item1Id; 132// item1.Name = "My Little Dog";
133 InventoryFolderBase objsFolder 133// item1.AssetID = asset1.FullID;
134 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); 134// item1.ID = item1Id;
135 item1.Folder = objsFolder.ID; 135// InventoryFolderBase objsFolder
136 scene.AddInventoryItem(userId, item1); 136// = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects");
137 137// item1.Folder = objsFolder.ID;
138 MemoryStream archiveWriteStream = new MemoryStream(); 138// scene.AddInventoryItem(userId, item1);
139 archiverModule.OnInventoryArchiveSaved += SaveCompleted; 139
140 140// MemoryStream archiveWriteStream = new MemoryStream();
141 mre.Reset(); 141// archiverModule.OnInventoryArchiveSaved += SaveCompleted;
142 archiverModule.ArchiveInventory( 142
143 Guid.NewGuid(), userFirstName, userLastName, "Objects", "troll", archiveWriteStream); 143// mre.Reset();
144 mre.WaitOne(60000, false); 144// archiverModule.ArchiveInventory(
145 145// Guid.NewGuid(), userFirstName, userLastName, "Objects", "troll", archiveWriteStream);
146 byte[] archive = archiveWriteStream.ToArray(); 146// mre.WaitOne(60000, false);
147 MemoryStream archiveReadStream = new MemoryStream(archive); 147
148 TarArchiveReader tar = new TarArchiveReader(archiveReadStream); 148// byte[] archive = archiveWriteStream.ToArray();
149 149// MemoryStream archiveReadStream = new MemoryStream(archive);
150 //bool gotControlFile = false; 150// TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
151 bool gotObject1File = false; 151
152 //bool gotObject2File = false; 152// //bool gotControlFile = false;
153 string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1); 153// bool gotObject1File = false;
154 string expectedObject1FilePath = string.Format( 154// //bool gotObject2File = false;
155 "{0}{1}{2}", 155// string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1);
156 ArchiveConstants.INVENTORY_PATH, 156// string expectedObject1FilePath = string.Format(
157 InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder), 157// "{0}{1}{2}",
158 expectedObject1FileName); 158// ArchiveConstants.INVENTORY_PATH,
159 159// InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder),
160 string filePath; 160// expectedObject1FileName);
161 TarArchiveReader.TarEntryType tarEntryType; 161
162 162// string filePath;
163 Console.WriteLine("Reading archive"); 163// TarArchiveReader.TarEntryType tarEntryType;
164 164
165 while (tar.ReadEntry(out filePath, out tarEntryType) != null) 165// Console.WriteLine("Reading archive");
166 { 166
167 Console.WriteLine("Got {0}", filePath); 167// while (tar.ReadEntry(out filePath, out tarEntryType) != null)
168 168// {
169// if (ArchiveConstants.CONTROL_FILE_PATH == filePath) 169// Console.WriteLine("Got {0}", filePath);
170
171//// if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
172//// {
173//// gotControlFile = true;
174//// }
175
176// if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
170// { 177// {
171// gotControlFile = true; 178//// string fileName = filePath.Remove(0, "Objects/".Length);
179////
180//// if (fileName.StartsWith(part1.Name))
181//// {
182// Assert.That(expectedObject1FilePath, Is.EqualTo(filePath));
183// gotObject1File = true;
184//// }
185//// else if (fileName.StartsWith(part2.Name))
186//// {
187//// Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
188//// gotObject2File = true;
189//// }
172// } 190// }
173 191// }
174 if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
175 {
176// string fileName = filePath.Remove(0, "Objects/".Length);
177//
178// if (fileName.StartsWith(part1.Name))
179// {
180 Assert.That(expectedObject1FilePath, Is.EqualTo(filePath));
181 gotObject1File = true;
182// }
183// else if (fileName.StartsWith(part2.Name))
184// {
185// Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
186// gotObject2File = true;
187// }
188 }
189 }
190 192
191// Assert.That(gotControlFile, Is.True, "No control file in archive"); 193//// Assert.That(gotControlFile, Is.True, "No control file in archive");
192 Assert.That(gotObject1File, Is.True, "No item1 file in archive"); 194// Assert.That(gotObject1File, Is.True, "No item1 file in archive");
193// Assert.That(gotObject2File, Is.True, "No object2 file in archive"); 195//// Assert.That(gotObject2File, Is.True, "No object2 file in archive");
194 196
195 // TODO: Test presence of more files and contents of files. 197// // TODO: Test presence of more files and contents of files.
196 } 198// }
197 199
198 /// <summary> 200 /// <summary>
199 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where 201 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
@@ -201,187 +203,189 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
201 /// </summary> 203 /// </summary>
202 /// 204 ///
203 /// This test also does some deeper probing of loading into nested inventory structures 205 /// This test also does some deeper probing of loading into nested inventory structures
204 [Test] 206 /// REFACTORING PROBLEM. This needs to be rewritten.
205 public void TestLoadIarV0_1ExistingUsers() 207// [Test]
206 { 208// public void TestLoadIarV0_1ExistingUsers()
207 TestHelper.InMethod(); 209// {
208 210// TestHelper.InMethod();
209 //log4net.Config.XmlConfigurator.Configure(); 211
210 212// //log4net.Config.XmlConfigurator.Configure();
211 string userFirstName = "Mr"; 213
212 string userLastName = "Tiddles"; 214// string userFirstName = "Mr";
213 UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000555"); 215// string userLastName = "Tiddles";
214 string userItemCreatorFirstName = "Lord"; 216// UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000555");
215 string userItemCreatorLastName = "Lucan"; 217// string userItemCreatorFirstName = "Lord";
216 UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); 218// string userItemCreatorLastName = "Lucan";
217 219// UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
218 string item1Name = "b.lsl"; 220
219 string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1Name, UUID.Random()); 221// string item1Name = "b.lsl";
220 222// string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1Name, UUID.Random());
221 MemoryStream archiveWriteStream = new MemoryStream(); 223
222 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); 224// MemoryStream archiveWriteStream = new MemoryStream();
223 225// TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
224 InventoryItemBase item1 = new InventoryItemBase(); 226
225 item1.Name = item1Name; 227// InventoryItemBase item1 = new InventoryItemBase();
226 item1.AssetID = UUID.Random(); 228// item1.Name = item1Name;
227 item1.GroupID = UUID.Random(); 229// item1.AssetID = UUID.Random();
228 item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName); 230// item1.GroupID = UUID.Random();
229 //item1.CreatorId = userUuid.ToString(); 231// item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName);
230 //item1.CreatorId = "00000000-0000-0000-0000-000000000444"; 232// //item1.CreatorId = userUuid.ToString();
231 item1.Owner = UUID.Zero; 233// //item1.CreatorId = "00000000-0000-0000-0000-000000000444";
232 234// item1.Owner = UUID.Zero;
233 string item1FileName 235
234 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); 236// string item1FileName
235 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); 237// = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
236 tar.Close(); 238// tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
237 239// tar.Close();
238 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); 240
239 SerialiserModule serialiserModule = new SerialiserModule(); 241// MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
240 InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); 242// SerialiserModule serialiserModule = new SerialiserModule();
241 243// InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
242 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene 244
243 Scene scene = SceneSetupHelpers.SetupScene("inventory"); 245// // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
244 IUserAdminService userAdminService = scene.CommsManager.UserAdminService; 246// Scene scene = SceneSetupHelpers.SetupScene("inventory");
245 247// IUserAdminService userAdminService = scene.CommsManager.UserAdminService;
246 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); 248
247 userAdminService.AddUser( 249// SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
248 userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid); 250// userAdminService.AddUser(
249 userAdminService.AddUser( 251// userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid);
250 userItemCreatorFirstName, userItemCreatorLastName, "hampshire", 252// userAdminService.AddUser(
251 String.Empty, 1000, 1000, userItemCreatorUuid); 253// userItemCreatorFirstName, userItemCreatorLastName, "hampshire",
252 254// String.Empty, 1000, 1000, userItemCreatorUuid);
253 archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream); 255
254 256// archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream);
255 CachedUserInfo userInfo 257
256 = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); 258// CachedUserInfo userInfo
257 259// = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
258 InventoryItemBase foundItem1 260
259 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, item1Name); 261// InventoryItemBase foundItem1
260 262// = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, item1Name);
261 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); 263
262 264// Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
263// We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the 265
264// UUID, not the OSPA itself. 266//// We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the
267//// UUID, not the OSPA itself.
268//// Assert.That(
269//// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId),
270//// "Loaded item non-uuid creator doesn't match original");
265// Assert.That( 271// Assert.That(
266// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId), 272// foundItem1.CreatorId, Is.EqualTo(userItemCreatorUuid.ToString()),
267// "Loaded item non-uuid creator doesn't match original"); 273// "Loaded item non-uuid creator doesn't match original");
268 Assert.That(
269 foundItem1.CreatorId, Is.EqualTo(userItemCreatorUuid.ToString()),
270 "Loaded item non-uuid creator doesn't match original");
271
272 Assert.That(
273 foundItem1.CreatorIdAsUuid, Is.EqualTo(userItemCreatorUuid),
274 "Loaded item uuid creator doesn't match original");
275 Assert.That(foundItem1.Owner, Is.EqualTo(userUuid),
276 "Loaded item owner doesn't match inventory reciever");
277
278 // Now try loading to a root child folder
279 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xA");
280 archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
281 archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", "meowfood", archiveReadStream);
282
283 InventoryItemBase foundItem2
284 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xA/" + item1Name);
285 Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");
286
287 // Now try loading to a more deeply nested folder
288 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC");
289 archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
290 archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", "meowfood", archiveReadStream);
291
292 InventoryItemBase foundItem3
293 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC/" + item1Name);
294 Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
295 }
296
297 [Test]
298 public void TestIarV0_1WithEscapedChars()
299 {
300 TestHelper.InMethod();
301// log4net.Config.XmlConfigurator.Configure();
302
303 string itemName = "You & you are a mean/man/";
304 string humanEscapedItemName = @"You & you are a mean\/man\/";
305 string userPassword = "meowfood";
306
307 InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
308
309 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
310 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
311 CommunicationsManager cm = scene.CommsManager;
312
313 // Create user
314 string userFirstName = "Jock";
315 string userLastName = "Stirrup";
316 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
317
318 lock (this)
319 {
320 UserProfileTestUtils.CreateUserWithInventory(
321 cm, userFirstName, userLastName, userPassword, userId, InventoryReceived);
322 Monitor.Wait(this, 60000);
323 }
324
325 // Create asset
326 SceneObjectGroup object1;
327 SceneObjectPart part1;
328 {
329 string partName = "part name";
330 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
331 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
332 Vector3 groupPosition = new Vector3(10, 20, 30);
333 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
334 Vector3 offsetPosition = new Vector3(5, 10, 15);
335
336 part1
337 = new SceneObjectPart(
338 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
339 part1.Name = partName;
340
341 object1 = new SceneObjectGroup(part1);
342 scene.AddNewSceneObject(object1, false);
343 }
344
345 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
346 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
347 scene.AssetService.Store(asset1);
348
349 // Create item
350 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
351 InventoryItemBase item1 = new InventoryItemBase();
352 item1.Name = itemName;
353 item1.AssetID = asset1.FullID;
354 item1.ID = item1Id;
355 InventoryFolderBase objsFolder
356 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects");
357 item1.Folder = objsFolder.ID;
358 scene.AddInventoryItem(userId, item1);
359
360 MemoryStream archiveWriteStream = new MemoryStream();
361 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
362
363 mre.Reset();
364 archiverModule.ArchiveInventory(
365 Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
366 mre.WaitOne(60000, false);
367
368 // LOAD ITEM
369 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
370
371 archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream);
372
373 InventoryItemBase foundItem1
374 = InventoryArchiveUtils.FindItemByPath(
375 scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName);
376 274
377 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
378// Assert.That( 275// Assert.That(
379// foundItem1.CreatorId, Is.EqualTo(userUuid), 276// foundItem1.CreatorIdAsUuid, Is.EqualTo(userItemCreatorUuid),
380// "Loaded item non-uuid creator doesn't match that of the loading user"); 277// "Loaded item uuid creator doesn't match original");
381 Assert.That( 278// Assert.That(foundItem1.Owner, Is.EqualTo(userUuid),
382 foundItem1.Name, Is.EqualTo(itemName), 279// "Loaded item owner doesn't match inventory reciever");
383 "Loaded item name doesn't match saved name"); 280
384 } 281// // Now try loading to a root child folder
282// UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xA");
283// archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
284// archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", "meowfood", archiveReadStream);
285
286// InventoryItemBase foundItem2
287// = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xA/" + item1Name);
288// Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");
289
290// // Now try loading to a more deeply nested folder
291// UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC");
292// archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
293// archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", "meowfood", archiveReadStream);
294
295// InventoryItemBase foundItem3
296// = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC/" + item1Name);
297// Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
298 //}
299
300 // REFACTORING PROBLEM. Needs rewrite.
301// [Test]
302// public void TestIarV0_1WithEscapedChars()
303// {
304// TestHelper.InMethod();
305//// log4net.Config.XmlConfigurator.Configure();
306
307// string itemName = "You & you are a mean/man/";
308// string humanEscapedItemName = @"You & you are a mean\/man\/";
309// string userPassword = "meowfood";
310
311// InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
312
313// Scene scene = SceneSetupHelpers.SetupScene("Inventory");
314// SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
315// CommunicationsManager cm = scene.CommsManager;
316
317// // Create user
318// string userFirstName = "Jock";
319// string userLastName = "Stirrup";
320// UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
321
322// lock (this)
323// {
324// UserProfileTestUtils.CreateUserWithInventory(
325// cm, userFirstName, userLastName, userPassword, userId, InventoryReceived);
326// Monitor.Wait(this, 60000);
327// }
328
329// // Create asset
330// SceneObjectGroup object1;
331// SceneObjectPart part1;
332// {
333// string partName = "part name";
334// UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
335// PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
336// Vector3 groupPosition = new Vector3(10, 20, 30);
337// Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
338// Vector3 offsetPosition = new Vector3(5, 10, 15);
339
340// part1
341// = new SceneObjectPart(
342// ownerId, shape, groupPosition, rotationOffset, offsetPosition);
343// part1.Name = partName;
344
345// object1 = new SceneObjectGroup(part1);
346// scene.AddNewSceneObject(object1, false);
347// }
348
349// UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
350// AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
351// scene.AssetService.Store(asset1);
352
353// // Create item
354// UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
355// InventoryItemBase item1 = new InventoryItemBase();
356// item1.Name = itemName;
357// item1.AssetID = asset1.FullID;
358// item1.ID = item1Id;
359// InventoryFolderBase objsFolder
360// = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects");
361// item1.Folder = objsFolder.ID;
362// scene.AddInventoryItem(userId, item1);
363
364// MemoryStream archiveWriteStream = new MemoryStream();
365// archiverModule.OnInventoryArchiveSaved += SaveCompleted;
366
367// mre.Reset();
368// archiverModule.ArchiveInventory(
369// Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
370// mre.WaitOne(60000, false);
371
372// // LOAD ITEM
373// MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
374
375// archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream);
376
377// InventoryItemBase foundItem1
378// = InventoryArchiveUtils.FindItemByPath(
379// scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName);
380
381// Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
382//// Assert.That(
383//// foundItem1.CreatorId, Is.EqualTo(userUuid),
384//// "Loaded item non-uuid creator doesn't match that of the loading user");
385// Assert.That(
386// foundItem1.Name, Is.EqualTo(itemName),
387// "Loaded item name doesn't match saved name");
388// }
385 389
386 /// <summary> 390 /// <summary>
387 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where 391 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
@@ -390,199 +394,203 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
390 /// 394 ///
391 /// This may possibly one day get overtaken by the as yet incomplete temporary profiles feature 395 /// This may possibly one day get overtaken by the as yet incomplete temporary profiles feature
392 /// (as tested in the a later commented out test) 396 /// (as tested in the a later commented out test)
393 [Test] 397 /// REFACTORING PROBLEM. Needs rewrite.
394 public void TestLoadIarV0_1AbsentUsers() 398// [Test]
395 { 399// public void TestLoadIarV0_1AbsentUsers()
396 TestHelper.InMethod(); 400// {
397 401// TestHelper.InMethod();
398 //log4net.Config.XmlConfigurator.Configure(); 402
399 403// //log4net.Config.XmlConfigurator.Configure();
400 string userFirstName = "Charlie"; 404
401 string userLastName = "Chan"; 405// string userFirstName = "Charlie";
402 UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000999"); 406// string userLastName = "Chan";
403 string userItemCreatorFirstName = "Bat"; 407// UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000999");
404 string userItemCreatorLastName = "Man"; 408// string userItemCreatorFirstName = "Bat";
405 //UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000008888"); 409// string userItemCreatorLastName = "Man";
406 410// //UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000008888");
407 string itemName = "b.lsl"; 411
408 string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); 412// string itemName = "b.lsl";
409 413// string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
410 MemoryStream archiveWriteStream = new MemoryStream(); 414
411 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); 415// MemoryStream archiveWriteStream = new MemoryStream();
412 416// TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
413 InventoryItemBase item1 = new InventoryItemBase(); 417
414 item1.Name = itemName; 418// InventoryItemBase item1 = new InventoryItemBase();
415 item1.AssetID = UUID.Random(); 419// item1.Name = itemName;
416 item1.GroupID = UUID.Random(); 420// item1.AssetID = UUID.Random();
417 item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName); 421// item1.GroupID = UUID.Random();
418 //item1.CreatorId = userUuid.ToString(); 422// item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName);
419 //item1.CreatorId = "00000000-0000-0000-0000-000000000444"; 423// //item1.CreatorId = userUuid.ToString();
420 item1.Owner = UUID.Zero; 424// //item1.CreatorId = "00000000-0000-0000-0000-000000000444";
421 425// item1.Owner = UUID.Zero;
422 string item1FileName 426
423 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); 427// string item1FileName
424 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); 428// = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
425 tar.Close(); 429// tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
426 430// tar.Close();
427 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); 431
428 SerialiserModule serialiserModule = new SerialiserModule(); 432// MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
429 InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); 433// SerialiserModule serialiserModule = new SerialiserModule();
430 434// InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
431 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene 435
432 Scene scene = SceneSetupHelpers.SetupScene("inventory"); 436// // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
433 IUserAdminService userAdminService = scene.CommsManager.UserAdminService; 437// Scene scene = SceneSetupHelpers.SetupScene("inventory");
434 438// IUserAdminService userAdminService = scene.CommsManager.UserAdminService;
435 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); 439
436 userAdminService.AddUser( 440// SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
437 userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid); 441// userAdminService.AddUser(
438 442// userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid);
439 archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream); 443
440 444// archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream);
441 CachedUserInfo userInfo 445
442 = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); 446// CachedUserInfo userInfo
443 447// = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
444 InventoryItemBase foundItem1 448
445 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, itemName); 449// InventoryItemBase foundItem1
446 450// = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, itemName);
447 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); 451
452// Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
453//// Assert.That(
454//// foundItem1.CreatorId, Is.EqualTo(userUuid),
455//// "Loaded item non-uuid creator doesn't match that of the loading user");
448// Assert.That( 456// Assert.That(
449// foundItem1.CreatorId, Is.EqualTo(userUuid), 457// foundItem1.CreatorIdAsUuid, Is.EqualTo(userUuid),
450// "Loaded item non-uuid creator doesn't match that of the loading user"); 458// "Loaded item uuid creator doesn't match that of the loading user");
451 Assert.That( 459// }
452 foundItem1.CreatorIdAsUuid, Is.EqualTo(userUuid),
453 "Loaded item uuid creator doesn't match that of the loading user");
454 }
455 460
456 /// <summary> 461 /// <summary>
457 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where 462 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
458 /// no account exists with the creator name 463 /// no account exists with the creator name
459 /// </summary> 464 /// </summary>
460 /// Disabled since temporary profiles have not yet been implemented. 465 /// Disabled since temporary profiles have not yet been implemented.
466 /// REFACTORING PROBLEM. Needs rewrite.
467 ///
461 //[Test] 468 //[Test]
462 public void TestLoadIarV0_1TempProfiles() 469 //public void TestLoadIarV0_1TempProfiles()
463 { 470 //{
464 TestHelper.InMethod(); 471 // TestHelper.InMethod();
465 472
466 //log4net.Config.XmlConfigurator.Configure(); 473 // //log4net.Config.XmlConfigurator.Configure();
467 474
468 string userFirstName = "Dennis"; 475 // string userFirstName = "Dennis";
469 string userLastName = "Menace"; 476 // string userLastName = "Menace";
470 UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000aaa"); 477 // UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000aaa");
471 string user2FirstName = "Walter"; 478 // string user2FirstName = "Walter";
472 string user2LastName = "Mitty"; 479 // string user2LastName = "Mitty";
473 480
474 string itemName = "b.lsl"; 481 // string itemName = "b.lsl";
475 string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); 482 // string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
476 483
477 MemoryStream archiveWriteStream = new MemoryStream(); 484 // MemoryStream archiveWriteStream = new MemoryStream();
478 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); 485 // TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
479 486
480 InventoryItemBase item1 = new InventoryItemBase(); 487 // InventoryItemBase item1 = new InventoryItemBase();
481 item1.Name = itemName; 488 // item1.Name = itemName;
482 item1.AssetID = UUID.Random(); 489 // item1.AssetID = UUID.Random();
483 item1.GroupID = UUID.Random(); 490 // item1.GroupID = UUID.Random();
484 item1.CreatorId = OspResolver.MakeOspa(user2FirstName, user2LastName); 491 // item1.CreatorId = OspResolver.MakeOspa(user2FirstName, user2LastName);
485 item1.Owner = UUID.Zero; 492 // item1.Owner = UUID.Zero;
486 493
487 string item1FileName 494 // string item1FileName
488 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); 495 // = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
489 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); 496 // tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
490 tar.Close(); 497 // tar.Close();
491 498
492 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); 499 // MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
493 SerialiserModule serialiserModule = new SerialiserModule(); 500 // SerialiserModule serialiserModule = new SerialiserModule();
494 InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); 501 // InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
495 502
496 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene 503 // // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
497 Scene scene = SceneSetupHelpers.SetupScene(); 504 // Scene scene = SceneSetupHelpers.SetupScene();
498 IUserAdminService userAdminService = scene.CommsManager.UserAdminService; 505 // IUserAdminService userAdminService = scene.CommsManager.UserAdminService;
499 506
500 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); 507 // SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
501 userAdminService.AddUser( 508 // userAdminService.AddUser(
502 userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid); 509 // userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid);
503 510
504 archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "troll", archiveReadStream); 511 // archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "troll", archiveReadStream);
505 512
506 // Check that a suitable temporary user profile has been created. 513 // // Check that a suitable temporary user profile has been created.
507 UserProfileData user2Profile 514 // UserProfileData user2Profile
508 = scene.CommsManager.UserService.GetUserProfile( 515 // = scene.CommsManager.UserService.GetUserProfile(
509 OspResolver.HashName(user2FirstName + " " + user2LastName)); 516 // OspResolver.HashName(user2FirstName + " " + user2LastName));
510 Assert.That(user2Profile, Is.Not.Null); 517 // Assert.That(user2Profile, Is.Not.Null);
511 Assert.That(user2Profile.FirstName == user2FirstName); 518 // Assert.That(user2Profile.FirstName == user2FirstName);
512 Assert.That(user2Profile.SurName == user2LastName); 519 // Assert.That(user2Profile.SurName == user2LastName);
513 520
514 CachedUserInfo userInfo 521 // CachedUserInfo userInfo
515 = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); 522 // = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
516 userInfo.OnInventoryReceived += InventoryReceived; 523 // userInfo.OnInventoryReceived += InventoryReceived;
517 524
518 lock (this) 525 // lock (this)
519 { 526 // {
520 userInfo.FetchInventory(); 527 // userInfo.FetchInventory();
521 Monitor.Wait(this, 60000); 528 // Monitor.Wait(this, 60000);
522 } 529 // }
523 530
524 InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); 531 // InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName);
525 532
526 Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId)); 533 // Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId));
527 Assert.That( 534 // Assert.That(
528 foundItem.CreatorIdAsUuid, Is.EqualTo(OspResolver.HashName(user2FirstName + " " + user2LastName))); 535 // foundItem.CreatorIdAsUuid, Is.EqualTo(OspResolver.HashName(user2FirstName + " " + user2LastName)));
529 Assert.That(foundItem.Owner, Is.EqualTo(userUuid)); 536 // Assert.That(foundItem.Owner, Is.EqualTo(userUuid));
530 537
531 Console.WriteLine("### Successfully completed {0} ###", MethodBase.GetCurrentMethod()); 538 // Console.WriteLine("### Successfully completed {0} ###", MethodBase.GetCurrentMethod());
532 } 539 //}
533 540
534 /// <summary> 541 /// <summary>
535 /// Test replication of an archive path to the user's inventory. 542 /// Test replication of an archive path to the user's inventory.
536 /// </summary> 543 /// </summary>
537 [Test] 544 //[Test]
538 public void TestReplicateArchivePathToUserInventory() 545 //public void TestReplicateArchivePathToUserInventory()
539 { 546 //{
540 TestHelper.InMethod(); 547 // TestHelper.InMethod();
541 548
542 //log4net.Config.XmlConfigurator.Configure(); 549 // //log4net.Config.XmlConfigurator.Configure();
543 550
544 Scene scene = SceneSetupHelpers.SetupScene("inventory"); 551 // Scene scene = SceneSetupHelpers.SetupScene("inventory");
545 CommunicationsManager commsManager = scene.CommsManager; 552 // CommunicationsManager commsManager = scene.CommsManager;
546 CachedUserInfo userInfo; 553 // CachedUserInfo userInfo;
547 554
548 lock (this) 555 // lock (this)
549 { 556 // {
550 userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived); 557 // // !!! REFACTORING PROBLEM. This needs to be rewritten
551 Monitor.Wait(this, 60000); 558 // userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived);
552 } 559 // Monitor.Wait(this, 60000);
553 560 // }
554 //Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder); 561
555 562 // //Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder);
556 Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); 563
557 List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); 564 // Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
558 565 // List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>();
559 string folder1Name = "a"; 566
560 string folder2Name = "b"; 567 // string folder1Name = "a";
561 string itemName = "c.lsl"; 568 // string folder2Name = "b";
562 569 // string itemName = "c.lsl";
563 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random()); 570
564 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); 571 // string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random());
565 string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); 572 // string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
566 573 // string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
567 string itemArchivePath 574
568 = string.Format( 575 // string itemArchivePath
569 "{0}{1}{2}{3}", 576 // = string.Format(
570 ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName); 577 // "{0}{1}{2}{3}",
571 578 // ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName);
572 //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); 579
573 580 // //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder);
574 new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null) 581
575 .ReplicateArchivePathToUserInventory( 582 // new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null)
576 itemArchivePath, false, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID), 583 // .ReplicateArchivePathToUserInventory(
577 foldersCreated, nodesLoaded); 584 // itemArchivePath, false, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID),
578 585 // foldersCreated, nodesLoaded);
579 //Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder); 586
580 //InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a"); 587 // //Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder);
581 InventoryFolderBase folder1 588 // //InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a");
582 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userInfo.UserProfile.ID, "a"); 589 // InventoryFolderBase folder1
583 Assert.That(folder1, Is.Not.Null, "Could not find folder a"); 590 // = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userInfo.UserProfile.ID, "a");
584 InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b"); 591 // Assert.That(folder1, Is.Not.Null, "Could not find folder a");
585 Assert.That(folder2, Is.Not.Null, "Could not find folder b"); 592 // InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b");
586 } 593 // Assert.That(folder2, Is.Not.Null, "Could not find folder b");
594 //}
587 } 595 }
588} 596}
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index b60b32b..09552a8 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -32,14 +32,14 @@ using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache; 35
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
39 39
40namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer 40namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
41{ 41{
42 public class InventoryTransferModule : IInventoryTransferModule, IRegionModule 42 public class InventoryTransferModule : IInventoryTransferModule, ISharedRegionModule
43 { 43 {
44 private static readonly ILog m_log 44 private static readonly ILog m_log
45 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -50,10 +50,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
50 new Dictionary<UUID, Scene>(); 50 new Dictionary<UUID, Scene>();
51 51
52 private IMessageTransferModule m_TransferModule = null; 52 private IMessageTransferModule m_TransferModule = null;
53 private bool m_Enabled = true;
53 54
54 #region IRegionModule Members 55 #region IRegionModule Members
55 56
56 public void Initialise(Scene scene, IConfigSource config) 57 public void Initialise(IConfigSource config)
57 { 58 {
58 if (config.Configs["Messaging"] != null) 59 if (config.Configs["Messaging"] != null)
59 { 60 {
@@ -62,29 +63,56 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
62 if (config.Configs["Messaging"].GetString( 63 if (config.Configs["Messaging"].GetString(
63 "InventoryTransferModule", "InventoryTransferModule") != 64 "InventoryTransferModule", "InventoryTransferModule") !=
64 "InventoryTransferModule") 65 "InventoryTransferModule")
66 {
67 m_Enabled = false;
65 return; 68 return;
69 }
66 } 70 }
71 }
67 72
68 if (!m_Scenelist.Contains(scene)) 73 public void AddRegion(Scene scene)
69 { 74 {
70 m_Scenelist.Add(scene); 75 if (!m_Enabled)
76 return;
71 77
72 scene.RegisterModuleInterface<IInventoryTransferModule>(this); 78 m_Scenelist.Add(scene);
73 79
74 scene.EventManager.OnNewClient += OnNewClient; 80 scene.RegisterModuleInterface<IInventoryTransferModule>(this);
75 scene.EventManager.OnClientClosed += ClientLoggedOut; 81
76 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; 82 scene.EventManager.OnNewClient += OnNewClient;
77 } 83 scene.EventManager.OnClientClosed += ClientLoggedOut;
84 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
78 } 85 }
79 86
80 public void PostInitialise() 87 public void RegionLoaded(Scene scene)
81 { 88 {
82 if (m_Scenelist.Count > 0) 89 if (m_TransferModule == null)
83 { 90 {
84 m_TransferModule = m_Scenelist[0].RequestModuleInterface<IMessageTransferModule>(); 91 m_TransferModule = m_Scenelist[0].RequestModuleInterface<IMessageTransferModule>();
85 if (m_TransferModule == null) 92 if (m_TransferModule == null)
93 {
86 m_log.Error("[INVENTORY TRANSFER] No Message transfer module found, transfers will be local only"); 94 m_log.Error("[INVENTORY TRANSFER] No Message transfer module found, transfers will be local only");
95 m_Enabled = false;
96
97 m_Scenelist.Clear();
98 scene.EventManager.OnNewClient -= OnNewClient;
99 scene.EventManager.OnClientClosed -= ClientLoggedOut;
100 scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
101 }
87 } 102 }
103
104 }
105
106 public void RemoveRegion(Scene scene)
107 {
108 scene.EventManager.OnNewClient -= OnNewClient;
109 scene.EventManager.OnClientClosed -= ClientLoggedOut;
110 scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
111 m_Scenelist.Remove(scene);
112 }
113
114 public void PostInitialise()
115 {
88 } 116 }
89 117
90 public void Close() 118 public void Close()
@@ -96,9 +124,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
96 get { return "InventoryModule"; } 124 get { return "InventoryModule"; }
97 } 125 }
98 126
99 public bool IsSharedModule 127 public Type ReplaceableInterface
100 { 128 {
101 get { return true; } 129 get { return null; }
102 } 130 }
103 131
104 #endregion 132 #endregion
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
index 261bd6c..d1d7df2 100644
--- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
@@ -37,34 +37,72 @@ using OpenSim.Region.Framework.Scenes;
37 37
38namespace OpenSim.Region.CoreModules.Avatar.Lure 38namespace OpenSim.Region.CoreModules.Avatar.Lure
39{ 39{
40 public class LureModule : IRegionModule 40 public class LureModule : ISharedRegionModule
41 { 41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(
43 MethodBase.GetCurrentMethod().DeclaringType);
43 44
44 private readonly List<Scene> m_scenes = new List<Scene>(); 45 private readonly List<Scene> m_scenes = new List<Scene>();
45 46
46 private IMessageTransferModule m_TransferModule = null; 47 private IMessageTransferModule m_TransferModule = null;
48 private bool m_Enabled = true;
47 49
48 public void Initialise(Scene scene, IConfigSource config) 50 public void Initialise(IConfigSource config)
49 { 51 {
50 if (config.Configs["Messaging"] != null) 52 if (config.Configs["Messaging"] != null)
51 { 53 {
52 if (config.Configs["Messaging"].GetString( 54 if (config.Configs["Messaging"].GetString(
53 "LureModule", "LureModule") != 55 "LureModule", "LureModule") !=
54 "LureModule") 56 "LureModule")
55 return; 57 m_Enabled = false;
56 } 58 }
59 }
60
61 public void AddRegion(Scene scene)
62 {
63 if (!m_Enabled)
64 return;
57 65
58 lock (m_scenes) 66 lock (m_scenes)
59 { 67 {
60 if (!m_scenes.Contains(scene)) 68 m_scenes.Add(scene);
69 scene.EventManager.OnNewClient += OnNewClient;
70 scene.EventManager.OnIncomingInstantMessage +=
71 OnGridInstantMessage;
72 }
73 }
74
75 public void RegionLoaded(Scene scene)
76 {
77 if (m_TransferModule == null)
78 {
79 m_TransferModule =
80 scene.RequestModuleInterface<IMessageTransferModule>();
81
82 if (m_TransferModule == null)
61 { 83 {
62 m_scenes.Add(scene); 84 m_log.Error("[INSTANT MESSAGE]: No message transfer module, "+
63 scene.EventManager.OnNewClient += OnNewClient; 85 "lures will not work!");
64 scene.EventManager.OnIncomingInstantMessage += 86
87 m_Enabled = false;
88 m_scenes.Clear();
89 scene.EventManager.OnNewClient -= OnNewClient;
90 scene.EventManager.OnIncomingInstantMessage -=
65 OnGridInstantMessage; 91 OnGridInstantMessage;
66 } 92 }
67 } 93 }
94
95 }
96
97 public void RemoveRegion(Scene scene)
98 {
99 lock (m_scenes)
100 {
101 m_scenes.Remove(scene);
102 scene.EventManager.OnNewClient -= OnNewClient;
103 scene.EventManager.OnIncomingInstantMessage -=
104 OnGridInstantMessage;
105 }
68 } 106 }
69 107
70 void OnNewClient(IClientAPI client) 108 void OnNewClient(IClientAPI client)
@@ -76,12 +114,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
76 114
77 public void PostInitialise() 115 public void PostInitialise()
78 { 116 {
79 m_TransferModule =
80 m_scenes[0].RequestModuleInterface<IMessageTransferModule>();
81
82 if (m_TransferModule == null)
83 m_log.Error("[INSTANT MESSAGE]: No message transfer module, "+
84 "lures will not work!");
85 } 117 }
86 118
87 public void Close() 119 public void Close()
@@ -93,9 +125,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
93 get { return "LureModule"; } 125 get { return "LureModule"; }
94 } 126 }
95 127
96 public bool IsSharedModule 128 public Type ReplaceableInterface
97 { 129 {
98 get { return true; } 130 get { return null; }
99 } 131 }
100 132
101 public void OnInstantMessage(IClientAPI client, GridInstantMessage im) 133 public void OnInstantMessage(IClientAPI client, GridInstantMessage im)
diff --git a/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs b/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs
deleted file mode 100644
index 8cf58c6..0000000
--- a/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs
+++ /dev/null
@@ -1,168 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Globalization;
31using System.Reflection;
32using log4net;
33using Nini.Config;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38
39namespace OpenSim.Region.CoreModules.Avatar.Profiles
40{
41 public class AvatarProfilesModule : IRegionModule
42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 private Scene m_scene;
45 private IProfileModule m_profileModule = null;
46 private bool m_enabled = true;
47
48 public AvatarProfilesModule()
49 {
50 }
51
52 #region IRegionModule Members
53
54 public void Initialise(Scene scene, IConfigSource config)
55 {
56 IConfig profileConfig = config.Configs["Profile"];
57 if (profileConfig != null)
58 {
59 if (profileConfig.GetString("Module", Name) != Name)
60 {
61 m_enabled = false;
62 return;
63 }
64 }
65
66 m_scene = scene;
67 m_scene.EventManager.OnNewClient += NewClient;
68 }
69
70 public void PostInitialise()
71 {
72 if (!m_enabled)
73 return;
74 m_profileModule = m_scene.RequestModuleInterface<IProfileModule>();
75 }
76
77 public void Close()
78 {
79 }
80
81 public string Name
82 {
83 get { return "AvatarProfilesModule"; }
84 }
85
86 public bool IsSharedModule
87 {
88 get { return false; }
89 }
90
91 #endregion
92
93 public void NewClient(IClientAPI client)
94 {
95 client.OnRequestAvatarProperties += RequestAvatarProperty;
96 client.OnUpdateAvatarProperties += UpdateAvatarProperties;
97 }
98
99 public void RemoveClient(IClientAPI client)
100 {
101 client.OnRequestAvatarProperties -= RequestAvatarProperty;
102 client.OnUpdateAvatarProperties -= UpdateAvatarProperties;
103 }
104
105 /// <summary>
106 ///
107 /// </summary>
108 /// <param name="remoteClient"></param>
109 /// <param name="avatarID"></param>
110 public void RequestAvatarProperty(IClientAPI remoteClient, UUID avatarID)
111 {
112 // FIXME: finish adding fields such as url, masking, etc.
113 UserProfileData profile = m_scene.CommsManager.UserService.GetUserProfile(avatarID);
114 if (null != profile)
115 {
116 Byte[] charterMember;
117 if (profile.CustomType == "")
118 {
119 charterMember = new Byte[1];
120 charterMember[0] = (Byte)((profile.UserFlags & 0xf00) >> 8);
121 }
122 else
123 {
124 charterMember = Utils.StringToBytes(profile.CustomType);
125 }
126
127 if (m_profileModule != null)
128 {
129 Hashtable profileData = m_profileModule.GetProfileData(remoteClient.AgentId);
130 if (profileData["ProfileUrl"] != null)
131 profile.ProfileUrl = profileData["ProfileUrl"].ToString();
132 }
133 remoteClient.SendAvatarProperties(profile.ID, profile.AboutText,
134 Util.ToDateTime(profile.Created).ToString("M/d/yyyy", CultureInfo.InvariantCulture),
135 charterMember, profile.FirstLifeAboutText, (uint)(profile.UserFlags & 0xff),
136 profile.FirstLifeImage, profile.Image, profile.ProfileUrl, profile.Partner);
137 }
138 else
139 {
140 m_log.Debug("[AvatarProfilesModule]: Got null for profile for " + avatarID.ToString());
141 }
142 }
143
144 public void UpdateAvatarProperties(IClientAPI remoteClient, UserProfileData newProfile)
145 {
146 UserProfileData Profile = m_scene.CommsManager.UserService.GetUserProfile(newProfile.ID);
147
148 // if it's the profile of the user requesting the update, then we change only a few things.
149 if (remoteClient.AgentId.CompareTo(Profile.ID) == 0)
150 {
151 Profile.Image = newProfile.Image;
152 Profile.FirstLifeImage = newProfile.FirstLifeImage;
153 Profile.AboutText = newProfile.AboutText;
154 Profile.FirstLifeAboutText = newProfile.FirstLifeAboutText;
155 Profile.ProfileUrl = newProfile.ProfileUrl;
156 }
157 else
158 {
159 return;
160 }
161
162 if (m_scene.CommsManager.UserService.UpdateUserProfile(Profile))
163 {
164 RequestAvatarProperty(remoteClient, newProfile.ID);
165 }
166 }
167 }
168}
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
new file mode 100644
index 0000000..80c0af8
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -0,0 +1,1602 @@
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.Net;
31using System.Reflection;
32using System.Threading;
33
34using OpenSim.Framework;
35using OpenSim.Framework.Capabilities;
36using OpenSim.Framework.Client;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Services.Interfaces;
40
41using GridRegion = OpenSim.Services.Interfaces.GridRegion;
42
43using OpenMetaverse;
44using log4net;
45using Nini.Config;
46
47namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
48{
49 public class EntityTransferModule : ISharedRegionModule, IEntityTransferModule
50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
53 protected bool m_Enabled = false;
54 protected Scene m_aScene;
55 protected List<UUID> m_agentsInTransit;
56
57 #region ISharedRegionModule
58
59 public Type ReplaceableInterface
60 {
61 get { return null; }
62 }
63
64 public virtual string Name
65 {
66 get { return "BasicEntityTransferModule"; }
67 }
68
69 public virtual void Initialise(IConfigSource source)
70 {
71 IConfig moduleConfig = source.Configs["Modules"];
72 if (moduleConfig != null)
73 {
74 string name = moduleConfig.GetString("EntityTransferModule", "");
75 if (name == Name)
76 {
77 m_agentsInTransit = new List<UUID>();
78 m_Enabled = true;
79 m_log.InfoFormat("[ENTITY TRANSFER MODULE]: {0} enabled.", Name);
80 }
81 }
82 }
83
84 public virtual void PostInitialise()
85 {
86 }
87
88 public virtual void AddRegion(Scene scene)
89 {
90 if (!m_Enabled)
91 return;
92
93 if (m_aScene == null)
94 m_aScene = scene;
95
96 scene.RegisterModuleInterface<IEntityTransferModule>(this);
97 scene.EventManager.OnNewClient += OnNewClient;
98 }
99
100 protected virtual void OnNewClient(IClientAPI client)
101 {
102 client.OnTeleportHomeRequest += TeleportHome;
103 }
104
105 public virtual void Close()
106 {
107 if (!m_Enabled)
108 return;
109 }
110
111
112 public virtual void RemoveRegion(Scene scene)
113 {
114 if (!m_Enabled)
115 return;
116 if (scene == m_aScene)
117 m_aScene = null;
118 }
119
120 public virtual void RegionLoaded(Scene scene)
121 {
122 if (!m_Enabled)
123 return;
124
125 }
126
127
128 #endregion
129
130 #region Agent Teleports
131
132 public void Teleport(ScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags)
133 {
134 if (!sp.Scene.Permissions.CanTeleport(sp.UUID))
135 return;
136
137 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
138
139 // Reset animations; the viewer does that in teleports.
140 sp.Animator.ResetAnimations();
141
142 try
143 {
144 if (regionHandle == sp.Scene.RegionInfo.RegionHandle)
145 {
146 m_log.DebugFormat(
147 "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}",
148 position, sp.Scene.RegionInfo.RegionName);
149
150 // Teleport within the same region
151 if (IsOutsideRegion(sp.Scene, position) || position.Z < 0)
152 {
153 Vector3 emergencyPos = new Vector3(128, 128, 128);
154
155 m_log.WarnFormat(
156 "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
157 position, sp.Name, sp.UUID, emergencyPos);
158 position = emergencyPos;
159 }
160
161 // TODO: Get proper AVG Height
162 float localAVHeight = 1.56f;
163 float posZLimit = 22;
164
165 // TODO: Check other Scene HeightField
166 if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize)
167 {
168 posZLimit = (float)sp.Scene.Heightmap[(int)position.X, (int)position.Y];
169 }
170
171 float newPosZ = posZLimit + localAVHeight;
172 if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
173 {
174 position.Z = newPosZ;
175 }
176
177 // Only send this if the event queue is null
178 if (eq == null)
179 sp.ControllingClient.SendTeleportLocationStart();
180
181 sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
182 sp.Teleport(position);
183 }
184 else // Another region possibly in another simulator
185 {
186 uint x = 0, y = 0;
187 Utils.LongToUInts(regionHandle, out x, out y);
188 GridRegion reg = m_aScene.GridService.GetRegionByPosition(sp.Scene.RegionInfo.ScopeID, (int)x, (int)y);
189
190 if (reg != null)
191 {
192 GridRegion finalDestination = GetFinalDestination(reg);
193 if (finalDestination == null)
194 {
195 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final destination is having problems. Unable to teleport agent.");
196 sp.ControllingClient.SendTeleportFailed("Problem at destination");
197 return;
198 }
199 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final destination is x={0} y={1} uuid={2}",
200 finalDestination.RegionLocX / Constants.RegionSize, finalDestination.RegionLocY / Constants.RegionSize, finalDestination.RegionID);
201
202 //
203 // This is it
204 //
205 DoTeleport(sp, reg, finalDestination, position, lookAt, teleportFlags, eq);
206 //
207 //
208 //
209 }
210 else
211 {
212 // TP to a place that doesn't exist (anymore)
213 // Inform the viewer about that
214 sp.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
215
216 // and set the map-tile to '(Offline)'
217 uint regX, regY;
218 Utils.LongToUInts(regionHandle, out regX, out regY);
219
220 MapBlockData block = new MapBlockData();
221 block.X = (ushort)(regX / Constants.RegionSize);
222 block.Y = (ushort)(regY / Constants.RegionSize);
223 block.Access = 254; // == not there
224
225 List<MapBlockData> blocks = new List<MapBlockData>();
226 blocks.Add(block);
227 sp.ControllingClient.SendMapBlock(blocks, 0);
228 }
229 }
230 }
231 catch (Exception e)
232 {
233 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Exception on teleport: {0}\n{1}", e.Message, e.StackTrace);
234 sp.ControllingClient.SendTeleportFailed("Internal error");
235 }
236 }
237
238 protected void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq)
239 {
240 if (reg == null || finalDestination == null)
241 {
242 sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
243 return;
244 }
245
246 m_log.DebugFormat(
247 "[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}:{2}/{3}",
248 reg.ExternalHostName, reg.HttpPort, finalDestination.RegionName, position);
249
250 uint newRegionX = (uint)(reg.RegionHandle >> 40);
251 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
252 uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40);
253 uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8);
254
255 ulong destinationHandle = finalDestination.RegionHandle;
256
257 if (eq == null)
258 sp.ControllingClient.SendTeleportLocationStart();
259
260 // Let's do DNS resolution only once in this process, please!
261 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
262 // it's actually doing a lot of work.
263 IPEndPoint endPoint = finalDestination.ExternalEndPoint;
264 if (endPoint.Address != null)
265 {
266 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
267 // both regions
268 if (sp.ParentID != (uint)0)
269 sp.StandUp();
270
271 if (!sp.ValidateAttachments())
272 {
273 sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
274 return;
275 }
276
277 // the avatar.Close below will clear the child region list. We need this below for (possibly)
278 // closing the child agents, so save it here (we need a copy as it is Clear()-ed).
279 //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList());
280 // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
281 // failure at this point (unlike a border crossing failure). So perhaps this can never fail
282 // once we reach here...
283 //avatar.Scene.RemoveCapsHandler(avatar.UUID);
284
285 string capsPath = String.Empty;
286
287 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
288 AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo();
289 agentCircuit.startpos = position;
290 agentCircuit.child = true;
291 agentCircuit.Appearance = sp.Appearance;
292 if (currentAgentCircuit != null)
293 agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs;
294
295 if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY))
296 {
297 // brand new agent, let's create a new caps seed
298 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
299 }
300
301 string reason = String.Empty;
302
303 // Let's create an agent there if one doesn't exist yet.
304 if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason))
305 {
306 sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}",
307 reason));
308 return;
309 }
310
311 // OK, it got this agent. Let's close some child agents
312 sp.CloseChildAgents(newRegionX, newRegionY);
313
314 if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY))
315 {
316 #region IP Translation for NAT
317 IClientIPEndpoint ipepClient;
318 if (sp.ClientView.TryGet(out ipepClient))
319 {
320 capsPath
321 = "http://"
322 + NetworkUtil.GetHostFor(ipepClient.EndPoint, finalDestination.ExternalHostName)
323 + ":"
324 + finalDestination.HttpPort
325 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
326 }
327 else
328 {
329 capsPath
330 = "http://"
331 + finalDestination.ExternalHostName
332 + ":"
333 + finalDestination.HttpPort
334 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
335 }
336 #endregion
337
338 if (eq != null)
339 {
340 #region IP Translation for NAT
341 // Uses ipepClient above
342 if (sp.ClientView.TryGet(out ipepClient))
343 {
344 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
345 }
346 #endregion
347
348 eq.EnableSimulator(destinationHandle, endPoint, sp.UUID);
349
350 // ES makes the client send a UseCircuitCode message to the destination,
351 // which triggers a bunch of things there.
352 // So let's wait
353 Thread.Sleep(200);
354
355 eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath);
356
357 }
358 else
359 {
360 sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint);
361 }
362 }
363 else
364 {
365 agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle);
366 capsPath = "http://" + finalDestination.ExternalHostName + ":" + finalDestination.HttpPort
367 + "/CAPS/" + agentCircuit.CapsPath + "0000/";
368 }
369
370 // Expect avatar crossing is a heavy-duty function at the destination.
371 // That is where MakeRoot is called, which fetches appearance and inventory.
372 // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates.
373 //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
374 // position, false);
375
376 //{
377 // avatar.ControllingClient.SendTeleportFailed("Problem with destination.");
378 // // We should close that agent we just created over at destination...
379 // List<ulong> lst = new List<ulong>();
380 // lst.Add(reg.RegionHandle);
381 // SendCloseChildAgentAsync(avatar.UUID, lst);
382 // return;
383 //}
384
385 SetInTransit(sp.UUID);
386
387 // Let's send a full update of the agent. This is a synchronous call.
388 AgentData agent = new AgentData();
389 sp.CopyTo(agent);
390 agent.Position = position;
391 SetCallbackURL(agent, sp.Scene.RegionInfo);
392
393 UpdateAgent(reg, finalDestination, agent);
394
395 m_log.DebugFormat(
396 "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, sp.UUID);
397
398
399 if (eq != null)
400 {
401 eq.TeleportFinishEvent(destinationHandle, 13, endPoint,
402 0, teleportFlags, capsPath, sp.UUID);
403 }
404 else
405 {
406 sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4,
407 teleportFlags, capsPath);
408 }
409
410 // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
411 // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
412 // that the client contacted the destination before we send the attachments and close things here.
413 if (!WaitForCallback(sp.UUID))
414 {
415 // Client never contacted destination. Let's restore everything back
416 sp.ControllingClient.SendTeleportFailed("Problems connecting to destination.");
417
418 ResetFromTransit(sp.UUID);
419
420 // Yikes! We should just have a ref to scene here.
421 //sp.Scene.InformClientOfNeighbours(sp);
422 EnableChildAgents(sp);
423
424 // Finally, kill the agent we just created at the destination.
425 m_aScene.SimulationService.CloseAgent(finalDestination, sp.UUID);
426
427 return;
428 }
429
430
431 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
432 CrossAttachmentsIntoNewRegion(finalDestination, sp, true);
433
434 KillEntity(sp.Scene, sp.LocalId);
435
436 sp.MakeChildAgent();
437 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
438
439 if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
440 {
441 Thread.Sleep(5000);
442 sp.Close();
443 sp.Scene.IncomingCloseAgent(sp.UUID);
444 }
445 else
446 // now we have a child agent in this region.
447 sp.Reset();
448
449
450 // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE!
451 if (sp.Scene.NeedSceneCacheClear(sp.UUID))
452 {
453 m_log.DebugFormat(
454 "[ENTITY TRANSFER MODULE]: User {0} is going to another region, profile cache removed",
455 sp.UUID);
456 }
457 }
458 else
459 {
460 sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
461 }
462 }
463
464
465 protected virtual bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason)
466 {
467 return m_aScene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason);
468 }
469
470 protected virtual bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agent)
471 {
472 return m_aScene.SimulationService.UpdateAgent(finalDestination, agent);
473 }
474
475 protected virtual void SetCallbackURL(AgentData agent, RegionInfo region)
476 {
477 agent.CallbackURI = "http://" + region.ExternalHostName + ":" + region.HttpPort +
478 "/agent/" + agent.AgentID.ToString() + "/" + region.RegionID.ToString() + "/release/";
479
480 }
481
482 protected void KillEntity(Scene scene, uint localID)
483 {
484 scene.SendKillObject(localID);
485 }
486
487 protected virtual GridRegion GetFinalDestination(GridRegion region)
488 {
489 return region;
490 }
491
492 protected virtual bool NeedsNewAgent(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY)
493 {
494 return Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY);
495 }
496
497 protected virtual bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg)
498 {
499 return Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY);
500 }
501
502 protected virtual bool IsOutsideRegion(Scene s, Vector3 pos)
503 {
504
505 if (s.TestBorderCross(pos, Cardinals.N))
506 return true;
507 if (s.TestBorderCross(pos, Cardinals.S))
508 return true;
509 if (s.TestBorderCross(pos, Cardinals.E))
510 return true;
511 if (s.TestBorderCross(pos, Cardinals.W))
512 return true;
513
514 return false;
515 }
516
517
518 #endregion
519
520 #region Teleport Home
521
522 public virtual void TeleportHome(UUID id, IClientAPI client)
523 {
524 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName);
525
526 OpenSim.Services.Interfaces.PresenceInfo pinfo = m_aScene.PresenceService.GetAgent(client.SessionId);
527
528 if (pinfo != null)
529 {
530 GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, pinfo.HomeRegionID);
531 if (regionInfo == null)
532 {
533 // can't find the Home region: Tell viewer and abort
534 client.SendTeleportFailed("Your home region could not be found.");
535 return;
536 }
537 // a little eekie that this goes back to Scene and with a forced cast, will fix that at some point...
538 ((Scene)(client.Scene)).RequestTeleportLocation(
539 client, regionInfo.RegionHandle, pinfo.HomePosition, pinfo.HomeLookAt,
540 (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
541 }
542 }
543
544 #endregion
545
546
547 #region Agent Crossings
548
549 public void Cross(ScenePresence agent, bool isFlying)
550 {
551 Scene scene = agent.Scene;
552 Vector3 pos = agent.AbsolutePosition;
553 Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z);
554 uint neighbourx = scene.RegionInfo.RegionLocX;
555 uint neighboury = scene.RegionInfo.RegionLocY;
556 const float boundaryDistance = 1.7f;
557 Vector3 northCross = new Vector3(0, boundaryDistance, 0);
558 Vector3 southCross = new Vector3(0, -1 * boundaryDistance, 0);
559 Vector3 eastCross = new Vector3(boundaryDistance, 0, 0);
560 Vector3 westCross = new Vector3(-1 * boundaryDistance, 0, 0);
561
562 // distance to edge that will trigger crossing
563
564
565 // distance into new region to place avatar
566 const float enterDistance = 0.5f;
567
568 if (scene.TestBorderCross(pos + westCross, Cardinals.W))
569 {
570 if (scene.TestBorderCross(pos + northCross, Cardinals.N))
571 {
572 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
573 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
574 }
575 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
576 {
577 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
578 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0)
579 {
580 neighboury--;
581 newpos.Y = Constants.RegionSize - enterDistance;
582 }
583 else
584 {
585 neighboury = b.TriggerRegionY;
586 neighbourx = b.TriggerRegionX;
587
588 Vector3 newposition = pos;
589 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
590 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
591 agent.ControllingClient.SendAgentAlertMessage(
592 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
593 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
594 return;
595 }
596 }
597
598 Border ba = scene.GetCrossedBorder(pos + westCross, Cardinals.W);
599 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
600 {
601 neighbourx--;
602 newpos.X = Constants.RegionSize - enterDistance;
603 }
604 else
605 {
606 neighboury = ba.TriggerRegionY;
607 neighbourx = ba.TriggerRegionX;
608
609
610 Vector3 newposition = pos;
611 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
612 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
613 agent.ControllingClient.SendAgentAlertMessage(
614 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
615 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
616
617
618 return;
619 }
620
621 }
622 else if (scene.TestBorderCross(pos + eastCross, Cardinals.E))
623 {
624 Border b = scene.GetCrossedBorder(pos + eastCross, Cardinals.E);
625 neighbourx += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
626 newpos.X = enterDistance;
627
628 if (scene.TestBorderCross(pos + southCross, Cardinals.S))
629 {
630 Border ba = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
631 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
632 {
633 neighboury--;
634 newpos.Y = Constants.RegionSize - enterDistance;
635 }
636 else
637 {
638 neighboury = ba.TriggerRegionY;
639 neighbourx = ba.TriggerRegionX;
640 Vector3 newposition = pos;
641 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
642 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
643 agent.ControllingClient.SendAgentAlertMessage(
644 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
645 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
646 return;
647 }
648 }
649 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
650 {
651 Border c = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
652 neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize);
653 newpos.Y = enterDistance;
654 }
655
656
657 }
658 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
659 {
660 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
661 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0)
662 {
663 neighboury--;
664 newpos.Y = Constants.RegionSize - enterDistance;
665 }
666 else
667 {
668 neighboury = b.TriggerRegionY;
669 neighbourx = b.TriggerRegionX;
670 Vector3 newposition = pos;
671 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
672 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
673 agent.ControllingClient.SendAgentAlertMessage(
674 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
675 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
676 return;
677 }
678 }
679 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
680 {
681
682 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
683 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
684 newpos.Y = enterDistance;
685 }
686
687 /*
688
689 if (pos.X < boundaryDistance) //West
690 {
691 neighbourx--;
692 newpos.X = Constants.RegionSize - enterDistance;
693 }
694 else if (pos.X > Constants.RegionSize - boundaryDistance) // East
695 {
696 neighbourx++;
697 newpos.X = enterDistance;
698 }
699
700 if (pos.Y < boundaryDistance) // South
701 {
702 neighboury--;
703 newpos.Y = Constants.RegionSize - enterDistance;
704 }
705 else if (pos.Y > Constants.RegionSize - boundaryDistance) // North
706 {
707 neighboury++;
708 newpos.Y = enterDistance;
709 }
710 */
711
712 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync;
713 d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d);
714
715 }
716
717
718 public delegate void InformClientToInitateTeleportToLocationDelegate(ScenePresence agent, uint regionX, uint regionY,
719 Vector3 position,
720 Scene initiatingScene);
721
722 private void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position, Scene initiatingScene)
723 {
724
725 // This assumes that we know what our neighbors are.
726
727 InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync;
728 d.BeginInvoke(agent, regionX, regionY, position, initiatingScene,
729 InformClientToInitiateTeleportToLocationCompleted,
730 d);
731 }
732
733 public void InformClientToInitiateTeleportToLocationAsync(ScenePresence agent, uint regionX, uint regionY, Vector3 position,
734 Scene initiatingScene)
735 {
736 Thread.Sleep(10000);
737 IMessageTransferModule im = initiatingScene.RequestModuleInterface<IMessageTransferModule>();
738 if (im != null)
739 {
740 UUID gotoLocation = Util.BuildFakeParcelID(
741 Util.UIntsToLong(
742 (regionX *
743 (uint)Constants.RegionSize),
744 (regionY *
745 (uint)Constants.RegionSize)),
746 (uint)(int)position.X,
747 (uint)(int)position.Y,
748 (uint)(int)position.Z);
749 GridInstantMessage m = new GridInstantMessage(initiatingScene, UUID.Zero,
750 "Region", agent.UUID,
751 (byte)InstantMessageDialog.GodLikeRequestTeleport, false,
752 "", gotoLocation, false, new Vector3(127, 0, 0),
753 new Byte[0]);
754 im.SendInstantMessage(m, delegate(bool success)
755 {
756 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Client Initiating Teleport sending IM success = {0}", success);
757 });
758
759 }
760 }
761
762 private void InformClientToInitiateTeleportToLocationCompleted(IAsyncResult iar)
763 {
764 InformClientToInitateTeleportToLocationDelegate icon =
765 (InformClientToInitateTeleportToLocationDelegate)iar.AsyncState;
766 icon.EndInvoke(iar);
767 }
768
769 public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying);
770
771 /// <summary>
772 /// This Closes child agents on neighboring regions
773 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
774 /// </summary>
775 protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying)
776 {
777 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury);
778
779 Scene m_scene = agent.Scene;
780 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
781
782 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
783 GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
784
785 if (neighbourRegion != null && agent.ValidateAttachments())
786 {
787 pos = pos + (agent.Velocity);
788
789 SetInTransit(agent.UUID);
790 AgentData cAgent = new AgentData();
791 agent.CopyTo(cAgent);
792 cAgent.Position = pos;
793 if (isFlying)
794 cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
795 cAgent.CallbackURI = "http://" + m_scene.RegionInfo.ExternalHostName + ":" + m_scene.RegionInfo.HttpPort +
796 "/agent/" + agent.UUID.ToString() + "/" + m_scene.RegionInfo.RegionID.ToString() + "/release/";
797
798 m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent);
799
800 // Next, let's close the child agent connections that are too far away.
801 agent.CloseChildAgents(neighbourx, neighboury);
802
803 //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo();
804 agent.ControllingClient.RequestClientInfo();
805
806 //m_log.Debug("BEFORE CROSS");
807 //Scene.DumpChildrenSeeds(UUID);
808 //DumpKnownRegions();
809 string agentcaps;
810 if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps))
811 {
812 m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.",
813 neighbourRegion.RegionHandle);
814 return agent;
815 }
816 // TODO Should construct this behind a method
817 string capsPath =
818 "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort
819 + "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/";
820
821 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
822
823 IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>();
824 if (eq != null)
825 {
826 eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
827 capsPath, agent.UUID, agent.ControllingClient.SessionId);
828 }
829 else
830 {
831 agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
832 capsPath);
833 }
834
835 if (!WaitForCallback(agent.UUID))
836 {
837 m_log.Debug("[ENTITY TRANSFER MODULE]: Callback never came in crossing agent");
838 ResetFromTransit(agent.UUID);
839
840 // Yikes! We should just have a ref to scene here.
841 //agent.Scene.InformClientOfNeighbours(agent);
842 EnableChildAgents(agent);
843
844 return agent;
845 }
846
847 agent.MakeChildAgent();
848 // now we have a child agent in this region. Request all interesting data about other (root) agents
849 agent.SendInitialFullUpdateToAllClients();
850
851 CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true);
852
853 // m_scene.SendKillObject(m_localId);
854
855 agent.Scene.NotifyMyCoarseLocationChange();
856 // the user may change their profile information in other region,
857 // so the userinfo in UserProfileCache is not reliable any more, delete it
858 // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE!
859 if (agent.Scene.NeedSceneCacheClear(agent.UUID))
860 {
861 m_log.DebugFormat(
862 "[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID);
863 }
864 }
865
866 //m_log.Debug("AFTER CROSS");
867 //Scene.DumpChildrenSeeds(UUID);
868 //DumpKnownRegions();
869 return agent;
870 }
871
872 private void CrossAgentToNewRegionCompleted(IAsyncResult iar)
873 {
874 CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState;
875 ScenePresence agent = icon.EndInvoke(iar);
876
877 // If the cross was successful, this agent is a child agent
878 if (agent.IsChildAgent)
879 agent.Reset();
880 else // Not successful
881 agent.RestoreInCurrentScene();
882
883 // In any case
884 agent.NotInTransit();
885
886 //m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname);
887 }
888
889 #endregion
890
891 #region Enable Child Agent
892 /// <summary>
893 /// This informs a single neighboring region about agent "avatar".
894 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
895 /// </summary>
896 public void EnableChildAgent(ScenePresence sp, GridRegion region)
897 {
898 AgentCircuitData agent = sp.ControllingClient.RequestClientInfo();
899 agent.BaseFolder = UUID.Zero;
900 agent.InventoryFolder = UUID.Zero;
901 agent.startpos = new Vector3(128, 128, 70);
902 agent.child = true;
903 agent.Appearance = sp.Appearance;
904
905 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
906 d.BeginInvoke(sp, agent, region, region.ExternalEndPoint, true,
907 InformClientOfNeighbourCompleted,
908 d);
909 }
910 #endregion
911
912 #region Enable Child Agents
913
914 private delegate void InformClientOfNeighbourDelegate(
915 ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
916
917 /// <summary>
918 /// This informs all neighboring regions about agent "avatar".
919 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
920 /// </summary>
921 public void EnableChildAgents(ScenePresence sp)
922 {
923 List<GridRegion> neighbours = new List<GridRegion>();
924 RegionInfo m_regionInfo = sp.Scene.RegionInfo;
925
926 if (m_regionInfo != null)
927 {
928 neighbours = RequestNeighbours(sp.Scene, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
929 }
930 else
931 {
932 m_log.Debug("[ENTITY TRANSFER MODULE]: m_regionInfo was null in EnableChildAgents, is this a NPC?");
933 }
934
935 /// We need to find the difference between the new regions where there are no child agents
936 /// and the regions where there are already child agents. We only send notification to the former.
937 List<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region
938 neighbourHandles.Add(sp.Scene.RegionInfo.RegionHandle); // add this region too
939 List<ulong> previousRegionNeighbourHandles;
940
941 if (sp.Scene.CapsModule != null)
942 {
943 previousRegionNeighbourHandles =
944 new List<ulong>(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID).Keys);
945 }
946 else
947 {
948 previousRegionNeighbourHandles = new List<ulong>();
949 }
950
951 List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles);
952 List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles);
953
954 //Dump("Current Neighbors", neighbourHandles);
955 //Dump("Previous Neighbours", previousRegionNeighbourHandles);
956 //Dump("New Neighbours", newRegions);
957 //Dump("Old Neighbours", oldRegions);
958
959 /// Update the scene presence's known regions here on this region
960 sp.DropOldNeighbours(oldRegions);
961
962 /// Collect as many seeds as possible
963 Dictionary<ulong, string> seeds;
964 if (sp.Scene.CapsModule != null)
965 seeds
966 = new Dictionary<ulong, string>(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID));
967 else
968 seeds = new Dictionary<ulong, string>();
969
970 //m_log.Debug(" !!! No. of seeds: " + seeds.Count);
971 if (!seeds.ContainsKey(sp.Scene.RegionInfo.RegionHandle))
972 seeds.Add(sp.Scene.RegionInfo.RegionHandle, sp.ControllingClient.RequestClientInfo().CapsPath);
973
974 /// Create the necessary child agents
975 List<AgentCircuitData> cagents = new List<AgentCircuitData>();
976 foreach (GridRegion neighbour in neighbours)
977 {
978 if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle)
979 {
980
981 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
982 AgentCircuitData agent = sp.ControllingClient.RequestClientInfo();
983 agent.BaseFolder = UUID.Zero;
984 agent.InventoryFolder = UUID.Zero;
985 agent.startpos = new Vector3(128, 128, 70);
986 agent.child = true;
987 agent.Appearance = sp.Appearance;
988 if (currentAgentCircuit != null)
989 agent.ServiceURLs = currentAgentCircuit.ServiceURLs;
990
991 if (newRegions.Contains(neighbour.RegionHandle))
992 {
993 agent.CapsPath = CapsUtil.GetRandomCapsObjectPath();
994 sp.AddNeighbourRegion(neighbour.RegionHandle, agent.CapsPath);
995 seeds.Add(neighbour.RegionHandle, agent.CapsPath);
996 }
997 else
998 agent.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, neighbour.RegionHandle);
999
1000 cagents.Add(agent);
1001 }
1002 }
1003
1004 /// Update all child agent with everyone's seeds
1005 foreach (AgentCircuitData a in cagents)
1006 {
1007 a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
1008 }
1009
1010 if (sp.Scene.CapsModule != null)
1011 {
1012 sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds);
1013 }
1014 sp.KnownRegions = seeds;
1015 //avatar.Scene.DumpChildrenSeeds(avatar.UUID);
1016 //avatar.DumpKnownRegions();
1017
1018 bool newAgent = false;
1019 int count = 0;
1020 foreach (GridRegion neighbour in neighbours)
1021 {
1022 //m_log.WarnFormat("--> Going to send child agent to {0}", neighbour.RegionName);
1023 // Don't do it if there's already an agent in that region
1024 if (newRegions.Contains(neighbour.RegionHandle))
1025 newAgent = true;
1026 else
1027 newAgent = false;
1028
1029 if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle)
1030 {
1031 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
1032 try
1033 {
1034 d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent,
1035 InformClientOfNeighbourCompleted,
1036 d);
1037 }
1038
1039 catch (ArgumentOutOfRangeException)
1040 {
1041 m_log.ErrorFormat(
1042 "[ENTITY TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbor list. The following region will not display to the client: {0} for region {1} ({2}, {3}).",
1043 neighbour.ExternalHostName,
1044 neighbour.RegionHandle,
1045 neighbour.RegionLocX,
1046 neighbour.RegionLocY);
1047 }
1048 catch (Exception e)
1049 {
1050 m_log.ErrorFormat(
1051 "[ENTITY TRANSFER MODULE]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}",
1052 neighbour.ExternalHostName,
1053 neighbour.RegionHandle,
1054 neighbour.RegionLocX,
1055 neighbour.RegionLocY,
1056 e);
1057
1058 // FIXME: Okay, even though we've failed, we're still going to throw the exception on,
1059 // since I don't know what will happen if we just let the client continue
1060
1061 // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes.
1062 // throw e;
1063
1064 }
1065 }
1066 count++;
1067 }
1068 }
1069
1070 private void InformClientOfNeighbourCompleted(IAsyncResult iar)
1071 {
1072 InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate)iar.AsyncState;
1073 icon.EndInvoke(iar);
1074 //m_log.WarnFormat(" --> InformClientOfNeighbourCompleted");
1075 }
1076
1077 /// <summary>
1078 /// Async component for informing client of which neighbours exist
1079 /// </summary>
1080 /// <remarks>
1081 /// This needs to run asynchronously, as a network timeout may block the thread for a long while
1082 /// </remarks>
1083 /// <param name="remoteClient"></param>
1084 /// <param name="a"></param>
1085 /// <param name="regionHandle"></param>
1086 /// <param name="endPoint"></param>
1087 private void InformClientOfNeighbourAsync(ScenePresence sp, AgentCircuitData a, GridRegion reg,
1088 IPEndPoint endPoint, bool newAgent)
1089 {
1090 // Let's wait just a little to give time to originating regions to catch up with closing child agents
1091 // after a cross here
1092 Thread.Sleep(500);
1093
1094 Scene m_scene = sp.Scene;
1095
1096 uint x, y;
1097 Utils.LongToUInts(reg.RegionHandle, out x, out y);
1098 x = x / Constants.RegionSize;
1099 y = y / Constants.RegionSize;
1100 m_log.Info("[ENTITY TRANSFER MODULE]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")");
1101
1102 string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
1103 + "/CAPS/" + a.CapsPath + "0000/";
1104
1105 string reason = String.Empty;
1106
1107
1108 bool regionAccepted = m_scene.SimulationService.CreateAgent(reg, a, 0, out reason); // m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, 0, out reason);
1109
1110 if (regionAccepted && newAgent)
1111 {
1112 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
1113 if (eq != null)
1114 {
1115 #region IP Translation for NAT
1116 IClientIPEndpoint ipepClient;
1117 if (sp.ClientView.TryGet(out ipepClient))
1118 {
1119 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
1120 }
1121 #endregion
1122
1123 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: {0} is sending {1} EnableSimulator for neighbor region {2} @ {3} " +
1124 "and EstablishAgentCommunication with seed cap {4}",
1125 m_scene.RegionInfo.RegionName, sp.Name, reg.RegionName, reg.RegionHandle, capsPath);
1126
1127 eq.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID);
1128 eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath);
1129 }
1130 else
1131 {
1132 sp.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
1133 // TODO: make Event Queue disablable!
1134 }
1135
1136 m_log.Info("[ENTITY TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString());
1137
1138 }
1139
1140 }
1141
1142 protected List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY)
1143 {
1144 RegionInfo m_regionInfo = pScene.RegionInfo;
1145
1146 Border[] northBorders = pScene.NorthBorders.ToArray();
1147 Border[] southBorders = pScene.SouthBorders.ToArray();
1148 Border[] eastBorders = pScene.EastBorders.ToArray();
1149 Border[] westBorders = pScene.WestBorders.ToArray();
1150
1151 // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement.
1152 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1)
1153 {
1154 return pScene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
1155 }
1156 else
1157 {
1158 Vector2 extent = Vector2.Zero;
1159 for (int i = 0; i < eastBorders.Length; i++)
1160 {
1161 extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X;
1162 }
1163 for (int i = 0; i < northBorders.Length; i++)
1164 {
1165 extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
1166 }
1167
1168 // Loss of fraction on purpose
1169 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
1170 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
1171
1172 int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize;
1173 int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize;
1174
1175 int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize;
1176 int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize;
1177
1178 List<GridRegion> neighbours = pScene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
1179 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
1180
1181 return neighbours;
1182 }
1183 }
1184
1185 private List<ulong> NewNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1186 {
1187 return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); });
1188 }
1189
1190 // private List<ulong> CommonNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1191 // {
1192 // return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); });
1193 // }
1194
1195 private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1196 {
1197 return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); });
1198 }
1199
1200 private List<ulong> NeighbourHandles(List<GridRegion> neighbours)
1201 {
1202 List<ulong> handles = new List<ulong>();
1203 foreach (GridRegion reg in neighbours)
1204 {
1205 handles.Add(reg.RegionHandle);
1206 }
1207 return handles;
1208 }
1209
1210 private void Dump(string msg, List<ulong> handles)
1211 {
1212 m_log.InfoFormat("-------------- HANDLE DUMP ({0}) ---------", msg);
1213 foreach (ulong handle in handles)
1214 {
1215 uint x, y;
1216 Utils.LongToUInts(handle, out x, out y);
1217 x = x / Constants.RegionSize;
1218 y = y / Constants.RegionSize;
1219 m_log.InfoFormat("({0}, {1})", x, y);
1220 }
1221 }
1222
1223 #endregion
1224
1225
1226 #region Agent Arrived
1227 public void AgentArrivedAtDestination(UUID id)
1228 {
1229 //m_log.Debug(" >>> ReleaseAgent called <<< ");
1230 ResetFromTransit(id);
1231 }
1232
1233 #endregion
1234
1235 #region Object Transfers
1236 /// <summary>
1237 /// Move the given scene object into a new region depending on which region its absolute position has moved
1238 /// into.
1239 ///
1240 /// This method locates the new region handle and offsets the prim position for the new region
1241 /// </summary>
1242 /// <param name="attemptedPosition">the attempted out of region position of the scene object</param>
1243 /// <param name="grp">the scene object that we're crossing</param>
1244 public void Cross(SceneObjectGroup grp, Vector3 attemptedPosition, bool silent)
1245 {
1246 if (grp == null)
1247 return;
1248 if (grp.IsDeleted)
1249 return;
1250
1251 Scene scene = grp.Scene;
1252 if (scene == null)
1253 return;
1254
1255 if (grp.RootPart.DIE_AT_EDGE)
1256 {
1257 // We remove the object here
1258 try
1259 {
1260 scene.DeleteSceneObject(grp, false);
1261 }
1262 catch (Exception)
1263 {
1264 m_log.Warn("[DATABASE]: exception when trying to remove the prim that crossed the border.");
1265 }
1266 return;
1267 }
1268
1269 int thisx = (int)scene.RegionInfo.RegionLocX;
1270 int thisy = (int)scene.RegionInfo.RegionLocY;
1271 Vector3 EastCross = new Vector3(0.1f, 0, 0);
1272 Vector3 WestCross = new Vector3(-0.1f, 0, 0);
1273 Vector3 NorthCross = new Vector3(0, 0.1f, 0);
1274 Vector3 SouthCross = new Vector3(0, -0.1f, 0);
1275
1276
1277 // use this if no borders were crossed!
1278 ulong newRegionHandle
1279 = Util.UIntsToLong((uint)((thisx) * Constants.RegionSize),
1280 (uint)((thisy) * Constants.RegionSize));
1281
1282 Vector3 pos = attemptedPosition;
1283
1284 int changeX = 1;
1285 int changeY = 1;
1286
1287 if (scene.TestBorderCross(attemptedPosition + WestCross, Cardinals.W))
1288 {
1289 if (scene.TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
1290 {
1291
1292 Border crossedBorderx = scene.GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
1293
1294 if (crossedBorderx.BorderLine.Z > 0)
1295 {
1296 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
1297 changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize);
1298 }
1299 else
1300 pos.X = ((pos.X + Constants.RegionSize));
1301
1302 Border crossedBordery = scene.GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
1303 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
1304
1305 if (crossedBordery.BorderLine.Z > 0)
1306 {
1307 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
1308 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
1309 }
1310 else
1311 pos.Y = ((pos.Y + Constants.RegionSize));
1312
1313
1314
1315 newRegionHandle
1316 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
1317 (uint)((thisy - changeY) * Constants.RegionSize));
1318 // x - 1
1319 // y - 1
1320 }
1321 else if (scene.TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
1322 {
1323 Border crossedBorderx = scene.GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
1324
1325 if (crossedBorderx.BorderLine.Z > 0)
1326 {
1327 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
1328 changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize);
1329 }
1330 else
1331 pos.X = ((pos.X + Constants.RegionSize));
1332
1333
1334 Border crossedBordery = scene.GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
1335 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
1336
1337 if (crossedBordery.BorderLine.Z > 0)
1338 {
1339 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
1340 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
1341 }
1342 else
1343 pos.Y = ((pos.Y + Constants.RegionSize));
1344
1345 newRegionHandle
1346 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
1347 (uint)((thisy + changeY) * Constants.RegionSize));
1348 // x - 1
1349 // y + 1
1350 }
1351 else
1352 {
1353 Border crossedBorderx = scene.GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
1354
1355 if (crossedBorderx.BorderLine.Z > 0)
1356 {
1357 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
1358 changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize);
1359 }
1360 else
1361 pos.X = ((pos.X + Constants.RegionSize));
1362
1363 newRegionHandle
1364 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
1365 (uint)(thisy * Constants.RegionSize));
1366 // x - 1
1367 }
1368 }
1369 else if (scene.TestBorderCross(attemptedPosition + EastCross, Cardinals.E))
1370 {
1371 if (scene.TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
1372 {
1373
1374 pos.X = ((pos.X - Constants.RegionSize));
1375 Border crossedBordery = scene.GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
1376 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
1377
1378 if (crossedBordery.BorderLine.Z > 0)
1379 {
1380 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
1381 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
1382 }
1383 else
1384 pos.Y = ((pos.Y + Constants.RegionSize));
1385
1386
1387 newRegionHandle
1388 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
1389 (uint)((thisy - changeY) * Constants.RegionSize));
1390 // x + 1
1391 // y - 1
1392 }
1393 else if (scene.TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
1394 {
1395 pos.X = ((pos.X - Constants.RegionSize));
1396 pos.Y = ((pos.Y - Constants.RegionSize));
1397 newRegionHandle
1398 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
1399 (uint)((thisy + changeY) * Constants.RegionSize));
1400 // x + 1
1401 // y + 1
1402 }
1403 else
1404 {
1405 pos.X = ((pos.X - Constants.RegionSize));
1406 newRegionHandle
1407 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
1408 (uint)(thisy * Constants.RegionSize));
1409 // x + 1
1410 }
1411 }
1412 else if (scene.TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
1413 {
1414 Border crossedBordery = scene.GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
1415 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
1416
1417 if (crossedBordery.BorderLine.Z > 0)
1418 {
1419 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
1420 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
1421 }
1422 else
1423 pos.Y = ((pos.Y + Constants.RegionSize));
1424
1425 newRegionHandle
1426 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - changeY) * Constants.RegionSize));
1427 // y - 1
1428 }
1429 else if (scene.TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
1430 {
1431
1432 pos.Y = ((pos.Y - Constants.RegionSize));
1433 newRegionHandle
1434 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + changeY) * Constants.RegionSize));
1435 // y + 1
1436 }
1437
1438 // Offset the positions for the new region across the border
1439 Vector3 oldGroupPosition = grp.RootPart.GroupPosition;
1440 grp.OffsetForNewRegion(pos);
1441
1442 // If we fail to cross the border, then reset the position of the scene object on that border.
1443 uint x = 0, y = 0;
1444 Utils.LongToUInts(newRegionHandle, out x, out y);
1445 GridRegion destination = scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
1446 if (destination != null && !CrossPrimGroupIntoNewRegion(destination, grp, silent))
1447 {
1448 grp.OffsetForNewRegion(oldGroupPosition);
1449 grp.ScheduleGroupForFullUpdate();
1450 }
1451 }
1452
1453
1454 /// <summary>
1455 /// Move the given scene object into a new region
1456 /// </summary>
1457 /// <param name="newRegionHandle"></param>
1458 /// <param name="grp">Scene Object Group that we're crossing</param>
1459 /// <returns>
1460 /// true if the crossing itself was successful, false on failure
1461 /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region
1462 /// </returns>
1463 protected bool CrossPrimGroupIntoNewRegion(GridRegion destination, SceneObjectGroup grp, bool silent)
1464 {
1465 //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<");
1466
1467 bool successYN = false;
1468 grp.RootPart.UpdateFlag = 0;
1469 //int primcrossingXMLmethod = 0;
1470
1471 if (destination != null)
1472 {
1473 //string objectState = grp.GetStateSnapshot();
1474
1475 //successYN
1476 // = m_sceneGridService.PrimCrossToNeighboringRegion(
1477 // newRegionHandle, grp.UUID, m_serialiser.SaveGroupToXml2(grp), primcrossingXMLmethod);
1478 //if (successYN && (objectState != "") && m_allowScriptCrossings)
1479 //{
1480 // successYN = m_sceneGridService.PrimCrossToNeighboringRegion(
1481 // newRegionHandle, grp.UUID, objectState, 100);
1482 //}
1483
1484 //// And the new channel...
1485 //if (m_interregionCommsOut != null)
1486 // successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp, true);
1487 if (m_aScene.SimulationService != null)
1488 successYN = m_aScene.SimulationService.CreateObject(destination, grp, true);
1489
1490 if (successYN)
1491 {
1492 // We remove the object here
1493 try
1494 {
1495 grp.Scene.DeleteSceneObject(grp, silent);
1496 }
1497 catch (Exception e)
1498 {
1499 m_log.ErrorFormat(
1500 "[ENTITY TRANSFER MODULE]: Exception deleting the old object left behind on a border crossing for {0}, {1}",
1501 grp, e);
1502 }
1503 }
1504 else
1505 {
1506 if (!grp.IsDeleted)
1507 {
1508 if (grp.RootPart.PhysActor != null)
1509 {
1510 grp.RootPart.PhysActor.CrossingFailure();
1511 }
1512 }
1513
1514 m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: Prim crossing failed for {0}", grp);
1515 }
1516 }
1517 else
1518 {
1519 m_log.Error("[ENTITY TRANSFER MODULE]: destination was unexpectedly null in Scene.CrossPrimGroupIntoNewRegion()");
1520 }
1521
1522 return successYN;
1523 }
1524
1525 protected bool CrossAttachmentsIntoNewRegion(GridRegion destination, ScenePresence sp, bool silent)
1526 {
1527 List<SceneObjectGroup> m_attachments = sp.Attachments;
1528 lock (m_attachments)
1529 {
1530 // Validate
1531 foreach (SceneObjectGroup gobj in m_attachments)
1532 {
1533 if (gobj == null || gobj.IsDeleted)
1534 return false;
1535 }
1536
1537 foreach (SceneObjectGroup gobj in m_attachments)
1538 {
1539 // If the prim group is null then something must have happened to it!
1540 if (gobj != null && gobj.RootPart != null)
1541 {
1542 // Set the parent localID to 0 so it transfers over properly.
1543 gobj.RootPart.SetParentLocalId(0);
1544 gobj.AbsolutePosition = gobj.RootPart.AttachedPos;
1545 gobj.RootPart.IsAttachment = false;
1546 //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
1547 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}", gobj.UUID, destination.RegionName);
1548 CrossPrimGroupIntoNewRegion(destination, gobj, silent);
1549 }
1550 }
1551 m_attachments.Clear();
1552
1553 return true;
1554 }
1555 }
1556
1557 #endregion
1558
1559 #region Misc
1560
1561 protected bool WaitForCallback(UUID id)
1562 {
1563 int count = 200;
1564 while (m_agentsInTransit.Contains(id) && count-- > 0)
1565 {
1566 //m_log.Debug(" >>> Waiting... " + count);
1567 Thread.Sleep(100);
1568 }
1569
1570 if (count > 0)
1571 return true;
1572 else
1573 return false;
1574 }
1575
1576 protected void SetInTransit(UUID id)
1577 {
1578 lock (m_agentsInTransit)
1579 {
1580 if (!m_agentsInTransit.Contains(id))
1581 m_agentsInTransit.Add(id);
1582 }
1583 }
1584
1585 protected bool ResetFromTransit(UUID id)
1586 {
1587 lock (m_agentsInTransit)
1588 {
1589 if (m_agentsInTransit.Contains(id))
1590 {
1591 m_agentsInTransit.Remove(id);
1592 return true;
1593 }
1594 }
1595 return false;
1596 }
1597
1598
1599 #endregion
1600
1601 }
1602}
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
new file mode 100644
index 0000000..28593fc
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -0,0 +1,273 @@
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;
31
32using OpenSim.Framework;
33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Services.Connectors.Hypergrid;
36using OpenSim.Services.Interfaces;
37using OpenSim.Server.Base;
38
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40
41using OpenMetaverse;
42using log4net;
43using Nini.Config;
44
45namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
46{
47 public class HGEntityTransferModule : EntityTransferModule, ISharedRegionModule, IEntityTransferModule, IUserAgentVerificationModule
48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 private bool m_Initialized = false;
52
53 private GatekeeperServiceConnector m_GatekeeperConnector;
54
55 #region ISharedRegionModule
56
57 public override string Name
58 {
59 get { return "HGEntityTransferModule"; }
60 }
61
62 public override void Initialise(IConfigSource source)
63 {
64 IConfig moduleConfig = source.Configs["Modules"];
65 if (moduleConfig != null)
66 {
67 string name = moduleConfig.GetString("EntityTransferModule", "");
68 if (name == Name)
69 {
70 m_agentsInTransit = new List<UUID>();
71
72 m_Enabled = true;
73 m_log.InfoFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name);
74 }
75 }
76 }
77
78 public override void AddRegion(Scene scene)
79 {
80 base.AddRegion(scene);
81 if (m_Enabled)
82 {
83 scene.RegisterModuleInterface<IUserAgentVerificationModule>(this);
84 }
85 }
86
87 protected override void OnNewClient(IClientAPI client)
88 {
89 client.OnTeleportHomeRequest += TeleportHome;
90 client.OnConnectionClosed += new Action<IClientAPI>(OnConnectionClosed);
91 }
92
93
94 public override void RegionLoaded(Scene scene)
95 {
96 base.RegionLoaded(scene);
97 if (m_Enabled)
98 if (!m_Initialized)
99 {
100 m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService);
101 m_Initialized = true;
102 }
103
104 }
105 public override void RemoveRegion(Scene scene)
106 {
107 base.AddRegion(scene);
108 if (m_Enabled)
109 {
110 scene.UnregisterModuleInterface<IUserAgentVerificationModule>(this);
111 }
112 }
113
114
115 #endregion
116
117 #region HG overrides of IEntiryTransferModule
118
119 protected override GridRegion GetFinalDestination(GridRegion region)
120 {
121 int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, region.RegionID);
122 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: region {0} flags: {1}", region.RegionID, flags);
123 if ((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0)
124 {
125 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Destination region {0} is hyperlink", region.RegionID);
126 return m_GatekeeperConnector.GetHyperlinkRegion(region, region.RegionID);
127 }
128 return region;
129 }
130
131 protected override bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg)
132 {
133 if (base.NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
134 return true;
135
136 int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID);
137 if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0)
138 return true;
139
140 return false;
141 }
142
143 protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason)
144 {
145 reason = string.Empty;
146 int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID);
147 if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0)
148 {
149 // this user is going to another grid
150 if (agentCircuit.ServiceURLs.ContainsKey("HomeURI"))
151 {
152 string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString();
153 IUserAgentService connector = new UserAgentServiceConnector(userAgentDriver);
154 bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, out reason);
155 if (success)
156 // Log them out of this grid
157 m_aScene.PresenceService.LogoutAgent(agentCircuit.SessionID, sp.AbsolutePosition, sp.Lookat);
158
159 return success;
160 }
161 else
162 {
163 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent does not have a HomeURI address");
164 return false;
165 }
166 }
167
168 return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason);
169 }
170
171 public override void TeleportHome(UUID id, IClientAPI client)
172 {
173 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName);
174
175 // Let's find out if this is a foreign user or a local user
176 UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, id);
177 if (account != null)
178 {
179 // local grid user
180 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local");
181 base.TeleportHome(id, client);
182 return;
183 }
184
185 // Foreign user wants to go home
186 //
187 AgentCircuitData aCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode);
188 if (aCircuit == null || (aCircuit != null && !aCircuit.ServiceURLs.ContainsKey("HomeURI")))
189 {
190 client.SendTeleportFailed("Your information has been lost");
191 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information");
192 return;
193 }
194
195 IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString());
196 Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY;
197 GridRegion finalDestination = userAgentService.GetHomeRegion(aCircuit.AgentID, out position, out lookAt);
198 if (finalDestination == null)
199 {
200 client.SendTeleportFailed("Your home region could not be found");
201 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found");
202 return;
203 }
204
205 ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(client.AgentId);
206 if (sp == null)
207 {
208 client.SendTeleportFailed("Internal error");
209 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene where it is supposed to be");
210 return;
211 }
212
213 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
214 GridRegion homeGatekeeper = MakeRegion(aCircuit);
215
216 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}:{5}",
217 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ExternalHostName, homeGatekeeper.HttpPort, homeGatekeeper.RegionName);
218
219 DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq);
220 }
221 #endregion
222
223 #region IUserAgentVerificationModule
224
225 public bool VerifyClient(AgentCircuitData aCircuit, string token)
226 {
227 if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
228 {
229 string url = aCircuit.ServiceURLs["HomeURI"].ToString();
230 IUserAgentService security = new UserAgentServiceConnector(url);
231 return security.VerifyClient(aCircuit.SessionID, token);
232 }
233
234 return false;
235 }
236
237 void OnConnectionClosed(IClientAPI obj)
238 {
239 if (obj.IsLoggingOut)
240 {
241 AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode);
242
243 if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
244 {
245 string url = aCircuit.ServiceURLs["HomeURI"].ToString();
246 IUserAgentService security = new UserAgentServiceConnector(url);
247 security.LogoutAgent(obj.AgentId, obj.SessionId);
248 //m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Sent logout call to UserAgentService @ {0}", url);
249 }
250 else
251 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: HomeURI not found for agent {0} logout", obj.AgentId);
252 }
253 }
254
255 #endregion
256
257 private GridRegion MakeRegion(AgentCircuitData aCircuit)
258 {
259 GridRegion region = new GridRegion();
260
261 Uri uri = null;
262 if (!aCircuit.ServiceURLs.ContainsKey("HomeURI") ||
263 (aCircuit.ServiceURLs.ContainsKey("HomeURI") && !Uri.TryCreate(aCircuit.ServiceURLs["HomeURI"].ToString(), UriKind.Absolute, out uri)))
264 return null;
265
266 region.ExternalHostName = uri.Host;
267 region.HttpPort = (uint)uri.Port;
268 region.RegionName = string.Empty;
269 region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0);
270 return region;
271 }
272 }
273}
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs
new file mode 100644
index 0000000..664f38d
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs
@@ -0,0 +1,200 @@
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.Threading;
32using log4net;
33using OpenMetaverse;
34using OpenSim.Framework;
35
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Region.Framework.Scenes.Serialization;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Services.Interfaces;
40
41//using HyperGrid.Framework;
42//using OpenSim.Region.Communications.Hypergrid;
43
44namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
45{
46 public class HGAssetMapper
47 {
48 #region Fields
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 // This maps between inventory server urls and inventory server clients
52// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
53
54 private Scene m_scene;
55
56 #endregion
57
58 #region Constructor
59
60 public HGAssetMapper(Scene scene)
61 {
62 m_scene = scene;
63 }
64
65 #endregion
66
67 #region Internal functions
68
69 public AssetBase FetchAsset(string url, UUID assetID)
70 {
71 AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString());
72
73 if (asset != null)
74 {
75 m_log.DebugFormat("[HG ASSET MAPPER]: Copied asset {0} from {1} to local asset server. ", asset.ID, url);
76 return asset;
77 }
78 return null;
79 }
80
81 public bool PostAsset(string url, AssetBase asset)
82 {
83 if (asset != null)
84 {
85 // See long comment in AssetCache.AddAsset
86 if (!asset.Temporary || asset.Local)
87 {
88 // We need to copy the asset into a new asset, because
89 // we need to set its ID to be URL+UUID, so that the
90 // HGAssetService dispatches it to the remote grid.
91 // It's not pretty, but the best that can be done while
92 // not having a global naming infrastructure
93 AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type, asset.Metadata.CreatorID);
94 Copy(asset, asset1);
95 try
96 {
97 asset1.ID = url + "/" + asset.ID;
98 }
99 catch
100 {
101 m_log.Warn("[HG ASSET MAPPER]: Oops.");
102 }
103
104 m_scene.AssetService.Store(asset1);
105 m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url);
106 }
107 return true;
108 }
109 else
110 m_log.Warn("[HG ASSET MAPPER]: Tried to post asset to remote server, but asset not in local cache.");
111
112 return false;
113 }
114
115 private void Copy(AssetBase from, AssetBase to)
116 {
117 to.Data = from.Data;
118 to.Description = from.Description;
119 to.FullID = from.FullID;
120 to.ID = from.ID;
121 to.Local = from.Local;
122 to.Name = from.Name;
123 to.Temporary = from.Temporary;
124 to.Type = from.Type;
125
126 }
127
128 // TODO: unused
129 // private void Dump(Dictionary<UUID, bool> lst)
130 // {
131 // m_log.Debug("XXX -------- UUID DUMP ------- XXX");
132 // foreach (KeyValuePair<UUID, bool> kvp in lst)
133 // m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")");
134 // m_log.Debug("XXX -------- UUID DUMP ------- XXX");
135 // }
136
137 #endregion
138
139
140 #region Public interface
141
142 public void Get(UUID assetID, UUID ownerID, string userAssetURL)
143 {
144 // Get the item from the remote asset server onto the local AssetCache
145 // and place an entry in m_assetMap
146
147 m_log.Debug("[HG ASSET MAPPER]: Fetching object " + assetID + " from asset server " + userAssetURL);
148 AssetBase asset = FetchAsset(userAssetURL, assetID);
149
150 if (asset != null)
151 {
152 // OK, now fetch the inside.
153 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
154 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
155 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
156 foreach (UUID uuid in ids.Keys)
157 FetchAsset(userAssetURL, uuid);
158
159 m_log.DebugFormat("[HG ASSET MAPPER]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL);
160
161 }
162 else
163 m_log.Warn("[HG ASSET MAPPER]: Could not fetch asset from remote asset server " + userAssetURL);
164 }
165
166
167 public void Post(UUID assetID, UUID ownerID, string userAssetURL)
168 {
169 // Post the item from the local AssetCache onto the remote asset server
170 // and place an entry in m_assetMap
171
172 m_log.Debug("[HG ASSET MAPPER]: Posting object " + assetID + " to asset server " + userAssetURL);
173 AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
174 if (asset != null)
175 {
176 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
177 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty);
178 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
179 foreach (UUID uuid in ids.Keys)
180 {
181 asset = m_scene.AssetService.Get(uuid.ToString());
182 if (asset == null)
183 m_log.DebugFormat("[HG ASSET MAPPER]: Could not find asset {0}", uuid);
184 else
185 PostAsset(userAssetURL, asset);
186 }
187
188 // maybe all pieces got there...
189 m_log.DebugFormat("[HG ASSET MAPPER]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL);
190
191 }
192 else
193 m_log.DebugFormat("[HG ASSET MAPPER]: Something wrong with asset {0}, it could not be found", assetID);
194
195 }
196
197 #endregion
198
199 }
200}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
index 6f7f34f..25f5154 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -25,55 +25,67 @@
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
28using System;
29using System.Collections.Generic;
28using System.Reflection; 30using System.Reflection;
29using log4net; 31
30using Nini.Config;
31using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Communications;
34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Services.Connectors.Hypergrid;
36using OpenSim.Services.Interfaces;
37using OpenSim.Server.Base;
36 38
37namespace OpenSim.Region.Framework.Scenes.Hypergrid 39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40
41using OpenMetaverse;
42using log4net;
43using Nini.Config;
44
45namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
38{ 46{
39 public partial class HGScene : Scene 47 public class HGInventoryAccessModule : BasicInventoryAccessModule, INonSharedRegionModule, IInventoryAccessModule
40 { 48 {
41 #region Fields
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 50
44 private HGAssetMapper m_assMapper; 51 private static HGAssetMapper m_assMapper;
45 public HGAssetMapper AssetMapper 52 public static HGAssetMapper AssetMapper
46 { 53 {
47 get { return m_assMapper; } 54 get { return m_assMapper; }
48 } 55 }
49 56
50 private IHyperAssetService m_hyper; 57 private bool m_Initialized = false;
51 private IHyperAssetService HyperAssets 58
59 #region INonSharedRegionModule
60
61 public override string Name
62 {
63 get { return "HGInventoryAccessModule"; }
64 }
65
66 public override void Initialise(IConfigSource source)
52 { 67 {
53 get 68 IConfig moduleConfig = source.Configs["Modules"];
69 if (moduleConfig != null)
54 { 70 {
55 if (m_hyper == null) 71 string name = moduleConfig.GetString("InventoryAccessModule", "");
56 m_hyper = RequestModuleInterface<IHyperAssetService>(); 72 if (name == Name)
57 return m_hyper; 73 {
74 m_Enabled = true;
75 m_log.InfoFormat("[HG INVENTORY ACCESS MODULE]: {0} enabled.", Name);
76 }
58 } 77 }
59 } 78 }
60 79
61 #endregion 80 public override void AddRegion(Scene scene)
62
63 #region Constructors
64
65 public HGScene(RegionInfo regInfo, AgentCircuitManager authen,
66 CommunicationsManager commsMan, SceneCommunicationService sceneGridService,
67 StorageManager storeManager,
68 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim,
69 bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion)
70 : base(regInfo, authen, commsMan, sceneGridService, storeManager, moduleLoader,
71 dumpAssetsToFile, physicalPrim, SeeIntoRegionFromNeighbor, config, simulatorVersion)
72 { 81 {
73 m_log.Info("[HGScene]: Starting HGScene."); 82 if (!m_Enabled)
74 m_assMapper = new HGAssetMapper(this); 83 return;
84
85 base.AddRegion(scene);
86 m_assMapper = new HGAssetMapper(scene);
87 scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem;
75 88
76 EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem;
77 } 89 }
78 90
79 #endregion 91 #endregion
@@ -82,17 +94,16 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
82 94
83 public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) 95 public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel)
84 { 96 {
85 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(avatarID); 97 string userAssetServer = string.Empty;
86 if (userInfo != null) 98 if (IsForeignUser(avatarID, out userAssetServer))
87 { 99 {
88 m_assMapper.Post(assetID, avatarID); 100 m_assMapper.Post(assetID, avatarID, userAssetServer);
89 } 101 }
90 } 102 }
91 103
92 #endregion 104 #endregion
93 105
94 #region Overrides of Scene.Inventory methods 106 #region Overrides of Basic Inventory Access methods
95
96 /// 107 ///
97 /// CapsUpdateInventoryItemAsset 108 /// CapsUpdateInventoryItemAsset
98 /// 109 ///
@@ -135,7 +146,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
135 //{ 146 //{
136 InventoryItemBase item = new InventoryItemBase(itemID); 147 InventoryItemBase item = new InventoryItemBase(itemID);
137 item.Owner = remoteClient.AgentId; 148 item.Owner = remoteClient.AgentId;
138 item = InventoryService.GetItem(item); 149 item = m_Scene.InventoryService.GetItem(item);
139 //if (item == null) 150 //if (item == null)
140 //{ // Fetch the item 151 //{ // Fetch the item
141 // item = new InventoryItemBase(); 152 // item = new InventoryItemBase();
@@ -143,32 +154,54 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
143 // item.ID = itemID; 154 // item.ID = itemID;
144 // item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo); 155 // item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo);
145 //} 156 //}
146 if (item != null) 157 string userAssetServer = string.Empty;
158 if (item != null && IsForeignUser(remoteClient.AgentId, out userAssetServer))
147 { 159 {
148 m_assMapper.Get(item.AssetID, remoteClient.AgentId); 160 m_assMapper.Get(item.AssetID, remoteClient.AgentId, userAssetServer);
149 161
150 } 162 }
151 //} 163 //}
152 164
153 // OK, we're done fetching. Pass it up to the default RezObject 165 // OK, we're done fetching. Pass it up to the default RezObject
154 return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, 166 return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
155 RezSelected, RemoveItem, fromTaskID, attachment); 167 RezSelected, RemoveItem, fromTaskID, attachment);
156 168
157 } 169 }
158 170
159 protected override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) 171 public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
160 { 172 {
161 string userAssetServer = HyperAssets.GetUserAssetServer(sender); 173 string userAssetServer = string.Empty;
162 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer())) 174 if (IsForeignUser(sender, out userAssetServer))
163 m_assMapper.Get(item.AssetID, sender); 175 m_assMapper.Get(item.AssetID, sender, userAssetServer);
164 176
165 userAssetServer = HyperAssets.GetUserAssetServer(receiver); 177 if (IsForeignUser(receiver, out userAssetServer))
166 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer())) 178 m_assMapper.Post(item.AssetID, receiver, userAssetServer);
167 m_assMapper.Post(item.AssetID, receiver);
168 } 179 }
169 180
170 #endregion 181 #endregion
171 182
172 } 183 public bool IsForeignUser(UUID userID, out string assetServerURL)
184 {
185 assetServerURL = string.Empty;
186 UserAccount account = null;
187 if (m_Scene.UserAccountService != null)
188 account = m_Scene.UserAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, userID);
189
190 if (account == null) // foreign
191 {
192 ScenePresence sp = null;
193 if (m_Scene.TryGetAvatar(userID, out sp))
194 {
195 AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
196 if (aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
197 {
198 assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString();
199 assetServerURL = assetServerURL.Trim(new char[] { '/' }); return true;
200 }
201 }
202 }
173 203
204 return false;
205 }
206 }
174} 207}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs
index 5d4e7ac..fcb544f 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs
@@ -29,10 +29,11 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30 30
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes;
32using OpenSim.Services.Interfaces; 33using OpenSim.Services.Interfaces;
33using OpenMetaverse; 34using OpenMetaverse;
34 35
35namespace OpenSim.Region.Framework.Scenes.Hypergrid 36namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
36{ 37{
37 public class HGUuidGatherer : UuidGatherer 38 public class HGUuidGatherer : UuidGatherer
38 { 39 {
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
new file mode 100644
index 0000000..e0df288
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -0,0 +1,655 @@
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.Net;
31using System.Reflection;
32using System.Threading;
33
34using OpenSim.Framework;
35using OpenSim.Framework.Capabilities;
36using OpenSim.Framework.Client;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.Framework.Scenes.Serialization;
40using OpenSim.Services.Interfaces;
41
42using GridRegion = OpenSim.Services.Interfaces.GridRegion;
43
44using OpenMetaverse;
45using log4net;
46using Nini.Config;
47
48namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
49{
50 public class BasicInventoryAccessModule : INonSharedRegionModule, IInventoryAccessModule
51 {
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53
54 protected bool m_Enabled = false;
55 protected Scene m_Scene;
56
57 #region INonSharedRegionModule
58
59 public Type ReplaceableInterface
60 {
61 get { return null; }
62 }
63
64 public virtual string Name
65 {
66 get { return "BasicInventoryAccessModule"; }
67 }
68
69 public virtual void Initialise(IConfigSource source)
70 {
71 IConfig moduleConfig = source.Configs["Modules"];
72 if (moduleConfig != null)
73 {
74 string name = moduleConfig.GetString("InventoryAccessModule", "");
75 if (name == Name)
76 {
77 m_Enabled = true;
78 m_log.InfoFormat("[INVENTORY ACCESS MODULE]: {0} enabled.", Name);
79 }
80 }
81 }
82
83 public virtual void PostInitialise()
84 {
85 }
86
87 public virtual void AddRegion(Scene scene)
88 {
89 if (!m_Enabled)
90 return;
91
92 m_Scene = scene;
93
94 scene.RegisterModuleInterface<IInventoryAccessModule>(this);
95 scene.EventManager.OnNewClient += OnNewClient;
96 }
97
98 protected virtual void OnNewClient(IClientAPI client)
99 {
100
101 }
102
103 public virtual void Close()
104 {
105 if (!m_Enabled)
106 return;
107 }
108
109
110 public virtual void RemoveRegion(Scene scene)
111 {
112 if (!m_Enabled)
113 return;
114 m_Scene = null;
115 }
116
117 public virtual void RegionLoaded(Scene scene)
118 {
119 if (!m_Enabled)
120 return;
121
122 }
123
124 #endregion
125
126 #region Inventory Access
127
128 /// <summary>
129 /// Capability originating call to update the asset of an item in an agent's inventory
130 /// </summary>
131 /// <param name="remoteClient"></param>
132 /// <param name="itemID"></param>
133 /// <param name="data"></param>
134 /// <returns></returns>
135 public virtual UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data)
136 {
137 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
138 item = m_Scene.InventoryService.GetItem(item);
139
140 if (item != null)
141 {
142 if ((InventoryType)item.InvType == InventoryType.Notecard)
143 {
144 if (!m_Scene.Permissions.CanEditNotecard(itemID, UUID.Zero, remoteClient.AgentId))
145 {
146 remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false);
147 return UUID.Zero;
148 }
149
150 remoteClient.SendAgentAlertMessage("Notecard saved", false);
151 }
152 else if ((InventoryType)item.InvType == InventoryType.LSL)
153 {
154 if (!m_Scene.Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId))
155 {
156 remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false);
157 return UUID.Zero;
158 }
159
160 remoteClient.SendAgentAlertMessage("Script saved", false);
161 }
162
163 AssetBase asset =
164 CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data, remoteClient.AgentId.ToString());
165 item.AssetID = asset.FullID;
166 m_Scene.AssetService.Store(asset);
167
168 m_Scene.InventoryService.UpdateItem(item);
169
170 // remoteClient.SendInventoryItemCreateUpdate(item);
171 return (asset.FullID);
172 }
173 else
174 {
175 m_log.ErrorFormat(
176 "[AGENT INVENTORY]: Could not find item {0} for caps inventory update",
177 itemID);
178 }
179
180 return UUID.Zero;
181 }
182
183 /// <summary>
184 /// Delete a scene object from a scene and place in the given avatar's inventory.
185 /// Returns the UUID of the newly created asset.
186 /// </summary>
187 /// <param name="action"></param>
188 /// <param name="folderID"></param>
189 /// <param name="objectGroup"></param>
190 /// <param name="remoteClient"> </param>
191 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
192 SceneObjectGroup objectGroup, IClientAPI remoteClient)
193 {
194 UUID assetID = UUID.Zero;
195
196 Vector3 inventoryStoredPosition = new Vector3
197 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
198 ? 250
199 : objectGroup.AbsolutePosition.X)
200 ,
201 (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
202 ? 250
203 : objectGroup.AbsolutePosition.X,
204 objectGroup.AbsolutePosition.Z);
205
206 Vector3 originalPosition = objectGroup.AbsolutePosition;
207
208 objectGroup.AbsolutePosition = inventoryStoredPosition;
209
210 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
211
212 objectGroup.AbsolutePosition = originalPosition;
213
214 // Get the user info of the item destination
215 //
216 UUID userID = UUID.Zero;
217
218 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
219 action == DeRezAction.SaveToExistingUserInventoryItem)
220 {
221 // Take or take copy require a taker
222 // Saving changes requires a local user
223 //
224 if (remoteClient == null)
225 return UUID.Zero;
226
227 userID = remoteClient.AgentId;
228 }
229 else
230 {
231 // All returns / deletes go to the object owner
232 //
233
234 userID = objectGroup.RootPart.OwnerID;
235 }
236
237 if (userID == UUID.Zero) // Can't proceed
238 {
239 return UUID.Zero;
240 }
241
242 // If we're returning someone's item, it goes back to the
243 // owner's Lost And Found folder.
244 // Delete is treated like return in this case
245 // Deleting your own items makes them go to trash
246 //
247
248 InventoryFolderBase folder = null;
249 InventoryItemBase item = null;
250
251 if (DeRezAction.SaveToExistingUserInventoryItem == action)
252 {
253 item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID);
254 item = m_Scene.InventoryService.GetItem(item);
255
256 //item = userInfo.RootFolder.FindItem(
257 // objectGroup.RootPart.FromUserInventoryItemID);
258
259 if (null == item)
260 {
261 m_log.DebugFormat(
262 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
263 objectGroup.Name, objectGroup.UUID);
264 return UUID.Zero;
265 }
266 }
267 else
268 {
269 // Folder magic
270 //
271 if (action == DeRezAction.Delete)
272 {
273 // Deleting someone else's item
274 //
275
276
277 if (remoteClient == null ||
278 objectGroup.OwnerID != remoteClient.AgentId)
279 {
280 // Folder skeleton may not be loaded and we
281 // have to wait for the inventory to find
282 // the destination folder
283 //
284 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
285 }
286 else
287 {
288 // Assume inventory skeleton was loaded during login
289 // and all folders can be found
290 //
291 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
292 }
293 }
294 else if (action == DeRezAction.Return)
295 {
296
297 // Dump to lost + found unconditionally
298 //
299 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
300 }
301
302 if (folderID == UUID.Zero && folder == null)
303 {
304 if (action == DeRezAction.Delete)
305 {
306 // Deletes go to trash by default
307 //
308 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
309 }
310 else
311 {
312 // Catch all. Use lost & found
313 //
314
315 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
316 }
317 }
318
319 if (folder == null) // None of the above
320 {
321 //folder = userInfo.RootFolder.FindFolder(folderID);
322 folder = new InventoryFolderBase(folderID);
323
324 if (folder == null) // Nowhere to put it
325 {
326 return UUID.Zero;
327 }
328 }
329
330 item = new InventoryItemBase();
331 item.CreatorId = objectGroup.RootPart.CreatorID.ToString();
332 item.ID = UUID.Random();
333 item.InvType = (int)InventoryType.Object;
334 item.Folder = folder.ID;
335 item.Owner = userID;
336 }
337
338 AssetBase asset = CreateAsset(
339 objectGroup.GetPartName(objectGroup.RootPart.LocalId),
340 objectGroup.GetPartDescription(objectGroup.RootPart.LocalId),
341 (sbyte)AssetType.Object,
342 Utils.StringToBytes(sceneObjectXml),
343 objectGroup.OwnerID.ToString());
344 m_Scene.AssetService.Store(asset);
345 assetID = asset.FullID;
346
347 if (DeRezAction.SaveToExistingUserInventoryItem == action)
348 {
349 item.AssetID = asset.FullID;
350 m_Scene.InventoryService.UpdateItem(item);
351 }
352 else
353 {
354 item.AssetID = asset.FullID;
355
356 if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
357 {
358 uint perms = objectGroup.GetEffectivePermissions();
359 uint nextPerms = (perms & 7) << 13;
360 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
361 perms &= ~(uint)PermissionMask.Copy;
362 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
363 perms &= ~(uint)PermissionMask.Transfer;
364 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
365 perms &= ~(uint)PermissionMask.Modify;
366
367 item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask;
368 item.CurrentPermissions = item.BasePermissions;
369 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
370 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
371 item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask;
372 item.CurrentPermissions |= 8; // Slam!
373 }
374 else
375 {
376 item.BasePermissions = objectGroup.GetEffectivePermissions();
377 item.CurrentPermissions = objectGroup.GetEffectivePermissions();
378 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
379 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
380 item.GroupPermissions = objectGroup.RootPart.GroupMask;
381
382 item.CurrentPermissions |= 8; // Slam!
383 }
384
385 // TODO: add the new fields (Flags, Sale info, etc)
386 item.CreationDate = Util.UnixTimeSinceEpoch();
387 item.Description = asset.Description;
388 item.Name = asset.Name;
389 item.AssetType = asset.Type;
390
391 m_Scene.InventoryService.AddItem(item);
392
393 if (remoteClient != null && item.Owner == remoteClient.AgentId)
394 {
395 remoteClient.SendInventoryItemCreateUpdate(item, 0);
396 }
397 else
398 {
399 ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner);
400 if (notifyUser != null)
401 {
402 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
403 }
404 }
405 }
406
407 return assetID;
408 }
409
410
411 /// <summary>
412 /// Rez an object into the scene from the user's inventory
413 /// </summary>
414 /// <param name="remoteClient"></param>
415 /// <param name="itemID"></param>
416 /// <param name="RayEnd"></param>
417 /// <param name="RayStart"></param>
418 /// <param name="RayTargetID"></param>
419 /// <param name="BypassRayCast"></param>
420 /// <param name="RayEndIsIntersection"></param>
421 /// <param name="RezSelected"></param>
422 /// <param name="RemoveItem"></param>
423 /// <param name="fromTaskID"></param>
424 /// <param name="attachment"></param>
425 /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful.</returns>
426 public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart,
427 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
428 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
429 {
430 // Work out position details
431 byte bRayEndIsIntersection = (byte)0;
432
433 if (RayEndIsIntersection)
434 {
435 bRayEndIsIntersection = (byte)1;
436 }
437 else
438 {
439 bRayEndIsIntersection = (byte)0;
440 }
441
442 Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f);
443
444
445 Vector3 pos = m_Scene.GetNewRezLocation(
446 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
447 BypassRayCast, bRayEndIsIntersection, true, scale, false);
448
449 // Rez object
450 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
451 item = m_Scene.InventoryService.GetItem(item);
452
453 if (item != null)
454 {
455 AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString());
456
457 if (rezAsset != null)
458 {
459 UUID itemId = UUID.Zero;
460
461 // If we have permission to copy then link the rezzed object back to the user inventory
462 // item that it came from. This allows us to enable 'save object to inventory'
463 if (!m_Scene.Permissions.BypassPermissions())
464 {
465 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy)
466 {
467 itemId = item.ID;
468 }
469 }
470 else
471 {
472 // Brave new fullperm world
473 //
474 itemId = item.ID;
475 }
476
477 string xmlData = Utils.BytesToString(rezAsset.Data);
478 SceneObjectGroup group
479 = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData);
480
481 if (!m_Scene.Permissions.CanRezObject(
482 group.Children.Count, remoteClient.AgentId, pos)
483 && !attachment)
484 {
485 // The client operates in no fail mode. It will
486 // have already removed the item from the folder
487 // if it's no copy.
488 // Put it back if it's not an attachment
489 //
490 if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment))
491 remoteClient.SendBulkUpdateInventory(item);
492 return null;
493 }
494
495 group.ResetIDs();
496
497 if (attachment)
498 {
499 group.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom;
500 group.RootPart.IsAttachment = true;
501 }
502
503 m_Scene.AddNewSceneObject(group, true);
504
505 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z);
506 // if attachment we set it's asset id so object updates can reflect that
507 // if not, we set it's position in world.
508 if (!attachment)
509 {
510 float offsetHeight = 0;
511 pos = m_Scene.GetNewRezLocation(
512 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
513 BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false);
514 pos.Z += offsetHeight;
515 group.AbsolutePosition = pos;
516 // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight);
517
518 }
519 else
520 {
521 group.SetFromItemID(itemID);
522 }
523
524 SceneObjectPart rootPart = null;
525 try
526 {
527 rootPart = group.GetChildPart(group.UUID);
528 }
529 catch (NullReferenceException)
530 {
531 string isAttachment = "";
532
533 if (attachment)
534 isAttachment = " Object was an attachment";
535
536 m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment);
537 }
538
539 // Since renaming the item in the inventory does not affect the name stored
540 // in the serialization, transfer the correct name from the inventory to the
541 // object itself before we rez.
542 rootPart.Name = item.Name;
543 rootPart.Description = item.Description;
544
545 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values);
546
547 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
548 if (rootPart.OwnerID != item.Owner)
549 {
550 //Need to kill the for sale here
551 rootPart.ObjectSaleType = 0;
552 rootPart.SalePrice = 10;
553
554 if (m_Scene.Permissions.PropagatePermissions())
555 {
556 if ((item.CurrentPermissions & 8) != 0)
557 {
558 foreach (SceneObjectPart part in partList)
559 {
560 part.EveryoneMask = item.EveryOnePermissions;
561 part.NextOwnerMask = item.NextPermissions;
562 part.GroupMask = 0; // DO NOT propagate here
563 }
564 }
565 group.ApplyNextOwnerPermissions();
566 }
567 }
568
569 foreach (SceneObjectPart part in partList)
570 {
571 if (part.OwnerID != item.Owner)
572 {
573 part.LastOwnerID = part.OwnerID;
574 part.OwnerID = item.Owner;
575 part.Inventory.ChangeInventoryOwner(item.Owner);
576 }
577 else if (((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam!
578 {
579 part.EveryoneMask = item.EveryOnePermissions;
580 part.NextOwnerMask = item.NextPermissions;
581
582 part.GroupMask = 0; // DO NOT propagate here
583 }
584 }
585
586 rootPart.TrimPermissions();
587
588 if (!attachment)
589 {
590 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
591 {
592 group.ClearPartAttachmentData();
593 }
594 }
595
596 if (!attachment)
597 {
598 // Fire on_rez
599 group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 0);
600
601 rootPart.ScheduleFullUpdate();
602 }
603
604 if (!m_Scene.Permissions.BypassPermissions())
605 {
606 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
607 {
608 // If this is done on attachments, no
609 // copy ones will be lost, so avoid it
610 //
611 if (!attachment)
612 {
613 List<UUID> uuids = new List<UUID>();
614 uuids.Add(item.ID);
615 m_Scene.InventoryService.DeleteItems(item.Owner, uuids);
616 }
617 }
618 }
619
620 return rootPart.ParentGroup;
621 }
622 }
623
624 return null;
625 }
626
627 public virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
628 {
629 }
630
631 #endregion
632
633 #region Misc
634
635 /// <summary>
636 /// Create a new asset data structure.
637 /// </summary>
638 /// <param name="name"></param>
639 /// <param name="description"></param>
640 /// <param name="invType"></param>
641 /// <param name="assetType"></param>
642 /// <param name="data"></param>
643 /// <returns></returns>
644 private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data, string creatorID)
645 {
646 AssetBase asset = new AssetBase(UUID.Random(), name, assetType, creatorID);
647 asset.Description = description;
648 asset.Data = (data == null) ? new byte[1] : data;
649
650 return asset;
651 }
652
653 #endregion
654 }
655}
diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs
index 13f58bd..e37da9f 100644
--- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs
@@ -31,12 +31,13 @@ using System.Reflection;
31 31
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Communications; 33using OpenSim.Framework.Communications;
34using OpenSim.Framework.Communications.Cache; 34
35using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; 35using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
36using OpenSim.Region.Framework; 36using OpenSim.Region.Framework;
37using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Services.Interfaces; 39using OpenSim.Services.Interfaces;
40using OpenSim.Server.Base;
40 41
41using OpenMetaverse; 42using OpenMetaverse;
42using log4net; 43using log4net;
@@ -53,6 +54,8 @@ namespace OpenSim.Region.CoreModules.Framework.Library
53 private string m_LibraryName = "OpenSim Library"; 54 private string m_LibraryName = "OpenSim Library";
54 private Scene m_Scene; 55 private Scene m_Scene;
55 56
57 private ILibraryService m_Library;
58
56 #region ISharedRegionModule 59 #region ISharedRegionModule
57 60
58 public void Initialise(IConfigSource config) 61 public void Initialise(IConfigSource config)
@@ -60,9 +63,22 @@ namespace OpenSim.Region.CoreModules.Framework.Library
60 m_Enabled = config.Configs["Modules"].GetBoolean("LibraryModule", m_Enabled); 63 m_Enabled = config.Configs["Modules"].GetBoolean("LibraryModule", m_Enabled);
61 if (m_Enabled) 64 if (m_Enabled)
62 { 65 {
63 IConfig libConfig = config.Configs["LibraryModule"]; 66 IConfig libConfig = config.Configs["LibraryService"];
64 if (libConfig != null) 67 if (libConfig != null)
65 m_LibraryName = libConfig.GetString("LibraryName", m_LibraryName); 68 {
69 string dllName = libConfig.GetString("LocalServiceModule", string.Empty);
70 m_log.Debug("[LIBRARY MODULE]: Library service dll is " + dllName);
71 if (dllName != string.Empty)
72 {
73 Object[] args = new Object[] { config };
74 m_Library = ServerUtils.LoadPlugin<ILibraryService>(dllName, args);
75 }
76 }
77 }
78 if (m_Library == null)
79 {
80 m_log.Warn("[LIBRARY MODULE]: No local library service. Module will be disabled.");
81 m_Enabled = false;
66 } 82 }
67 } 83 }
68 84
@@ -91,10 +107,15 @@ namespace OpenSim.Region.CoreModules.Framework.Library
91 { 107 {
92 m_Scene = scene; 108 m_Scene = scene;
93 } 109 }
110 scene.RegisterModuleInterface<ILibraryService>(m_Library);
94 } 111 }
95 112
96 public void RemoveRegion(Scene scene) 113 public void RemoveRegion(Scene scene)
97 { 114 {
115 if (!m_Enabled)
116 return;
117
118 scene.UnregisterModuleInterface<ILibraryService>(m_Library);
98 } 119 }
99 120
100 public void RegionLoaded(Scene scene) 121 public void RegionLoaded(Scene scene)
@@ -127,27 +148,23 @@ namespace OpenSim.Region.CoreModules.Framework.Library
127 148
128 protected void LoadLibrariesFromArchives() 149 protected void LoadLibrariesFromArchives()
129 { 150 {
130 InventoryFolderImpl lib = m_Scene.CommsManager.UserProfileCacheService.LibraryRoot; 151 InventoryFolderImpl lib = m_Library.LibraryRootFolder;
131 if (lib == null) 152 if (lib == null)
132 { 153 {
133 m_log.Debug("[LIBRARY MODULE]: No library. Ignoring Library Module"); 154 m_log.Debug("[LIBRARY MODULE]: No library. Ignoring Library Module");
134 return; 155 return;
135 } 156 }
136 157
137 lib.Name = m_LibraryName;
138
139 RegionInfo regInfo = new RegionInfo(); 158 RegionInfo regInfo = new RegionInfo();
140 Scene m_MockScene = new Scene(regInfo); 159 Scene m_MockScene = new Scene(regInfo);
141 m_MockScene.CommsManager = m_Scene.CommsManager; 160 LocalInventoryService invService = new LocalInventoryService(lib);
142 LocalInventoryService invService = new LocalInventoryService((LibraryRootFolder)lib);
143 m_MockScene.RegisterModuleInterface<IInventoryService>(invService); 161 m_MockScene.RegisterModuleInterface<IInventoryService>(invService);
144 m_MockScene.RegisterModuleInterface<IAssetService>(m_Scene.AssetService); 162 m_MockScene.RegisterModuleInterface<IAssetService>(m_Scene.AssetService);
145 163
146 UserProfileData profile = new UserProfileData(); 164 UserAccount uinfo = new UserAccount(lib.Owner);
147 profile.FirstName = "OpenSim"; 165 uinfo.FirstName = "OpenSim";
148 profile.ID = lib.Owner; 166 uinfo.LastName = "Library";
149 profile.SurName = "Library"; 167 uinfo.ServiceURLs = new Dictionary<string, object>();
150 CachedUserInfo uinfo = new CachedUserInfo(invService, profile);
151 168
152 foreach (string iarFileName in Directory.GetFiles(pathToLibraries, "*.iar")) 169 foreach (string iarFileName in Directory.GetFiles(pathToLibraries, "*.iar"))
153 { 170 {
@@ -175,6 +192,15 @@ namespace OpenSim.Region.CoreModules.Framework.Library
175 m_log.DebugFormat("[LIBRARY MODULE]: Exception when processing archive {0}: {1}", iarFileName, e.Message); 192 m_log.DebugFormat("[LIBRARY MODULE]: Exception when processing archive {0}: {1}", iarFileName, e.Message);
176 } 193 }
177 } 194 }
195
196 }
197
198 private void DumpLibrary()
199 {
200 InventoryFolderImpl lib = m_Library.LibraryRootFolder;
201
202 m_log.DebugFormat(" - folder {0}", lib.Name);
203 DumpFolder(lib);
178 } 204 }
179// 205//
180// private void DumpLibrary() 206// private void DumpLibrary()
diff --git a/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs b/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs
index 2c95b5a..49589fd 100644
--- a/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs
+++ b/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs
@@ -29,7 +29,7 @@ using System.Collections.Generic;
29using System.Reflection; 29using System.Reflection;
30 30
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Framework.Communications.Cache; 32
33using OpenSim.Services.Interfaces; 33using OpenSim.Services.Interfaces;
34 34
35using OpenMetaverse; 35using OpenMetaverse;
@@ -41,9 +41,9 @@ namespace OpenSim.Region.CoreModules.Framework.Library
41 { 41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 43
44 private LibraryRootFolder m_Library; 44 private InventoryFolderImpl m_Library;
45 45
46 public LocalInventoryService(LibraryRootFolder lib) 46 public LocalInventoryService(InventoryFolderImpl lib)
47 { 47 {
48 m_Library = lib; 48 m_Library = lib;
49 } 49 }
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs
deleted file mode 100644
index 0b54746..0000000
--- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs
+++ /dev/null
@@ -1,311 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using System.Text.RegularExpressions;
34using log4net;
35using Nini.Config;
36using OpenMetaverse;
37using Nwc.XmlRpc;
38using OpenSim.Framework;
39using OpenSim.Framework.Communications;
40using OpenSim.Framework.Communications.Services;
41using OpenSim.Framework.Communications.Cache;
42using OpenSim.Framework.Capabilities;
43using OpenSim.Framework.Servers.HttpServer;
44using OpenSim.Region.Framework.Scenes;
45using OpenSim.Region.Framework.Interfaces;
46
47namespace OpenSim.Region.CoreModules.Hypergrid
48{
49 public class HGStandaloneLoginModule : IRegionModule, ILoginServiceToRegionsConnector
50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
53 protected List<Scene> m_scenes = new List<Scene>();
54 protected Scene m_firstScene;
55
56 protected bool m_enabled = false; // Module is only enabled if running in standalone mode
57
58 protected HGLoginAuthService m_loginService;
59
60 #region IRegionModule Members
61
62 public void Initialise(Scene scene, IConfigSource source)
63 {
64 if (m_firstScene == null)
65 {
66 m_firstScene = scene;
67
68 IConfig startupConfig = source.Configs["Startup"];
69 if (startupConfig != null)
70 {
71 m_enabled = !startupConfig.GetBoolean("gridmode", false);
72 }
73
74 if (m_enabled)
75 {
76 m_log.Debug("[HGLogin]: HGlogin module enabled");
77 bool authenticate = true;
78 string welcomeMessage = "Welcome to OpenSim";
79 IConfig standaloneConfig = source.Configs["StandAlone"];
80 if (standaloneConfig != null)
81 {
82 authenticate = standaloneConfig.GetBoolean("accounts_authenticate", true);
83 welcomeMessage = standaloneConfig.GetString("welcome_message");
84 }
85
86 //TODO: fix casting.
87 LibraryRootFolder rootFolder = m_firstScene.CommsManager.UserProfileCacheService.LibraryRoot as LibraryRootFolder;
88
89 IHttpServer httpServer = MainServer.Instance;
90
91 //TODO: fix the casting of the user service, maybe by registering the userManagerBase with scenes, or refactoring so we just need a IUserService reference
92 m_loginService
93 = new HGLoginAuthService(
94 (UserManagerBase)m_firstScene.CommsManager.UserAdminService,
95 welcomeMessage,
96 m_firstScene.CommsManager.InterServiceInventoryService,
97 m_firstScene.CommsManager.NetworkServersInfo,
98 authenticate,
99 rootFolder,
100 this);
101
102 httpServer.AddXmlRPCHandler("hg_login", m_loginService.XmlRpcLoginMethod);
103 httpServer.AddXmlRPCHandler("check_auth_session", m_loginService.XmlRPCCheckAuthSession, false);
104 httpServer.AddXmlRPCHandler("get_avatar_appearance", XmlRPCGetAvatarAppearance);
105 httpServer.AddXmlRPCHandler("update_avatar_appearance", XmlRPCUpdateAvatarAppearance);
106
107 }
108 }
109
110 if (m_enabled)
111 {
112 AddScene(scene);
113 }
114 }
115
116 public void PostInitialise()
117 {
118
119 }
120
121 public void Close()
122 {
123
124 }
125
126 public string Name
127 {
128 get { return "HGStandaloneLoginModule"; }
129 }
130
131 public bool IsSharedModule
132 {
133 get { return true; }
134 }
135
136 #endregion
137
138 protected void AddScene(Scene scene)
139 {
140 lock (m_scenes)
141 {
142 if (!m_scenes.Contains(scene))
143 {
144 m_scenes.Add(scene);
145 }
146 }
147 }
148
149 public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent, out string reason)
150 {
151 reason = String.Empty;
152 return true;
153 }
154
155 public void LogOffUserFromGrid(ulong regionHandle, UUID AvatarID, UUID RegionSecret, string message)
156 {
157 Scene scene;
158 if (TryGetRegion(regionHandle, out scene))
159 {
160 scene.HandleLogOffUserFromGrid(AvatarID, RegionSecret, message);
161 }
162 }
163
164 public RegionInfo RequestNeighbourInfo(ulong regionhandle)
165 {
166 Scene scene;
167 if (TryGetRegion(regionhandle, out scene))
168 {
169 return scene.RegionInfo;
170 }
171 return null;
172 }
173
174 public RegionInfo RequestClosestRegion(string region)
175 {
176 Scene scene;
177 if (TryGetRegion(region, out scene))
178 {
179 return scene.RegionInfo;
180 }
181 else if (m_scenes.Count > 0)
182 {
183 return m_scenes[0].RegionInfo;
184 }
185 return null;
186 }
187
188 public RegionInfo RequestNeighbourInfo(UUID regionID)
189 {
190 Scene scene;
191 if (TryGetRegion(regionID, out scene))
192 {
193 return scene.RegionInfo;
194 }
195 return null;
196 }
197
198 protected bool TryGetRegion(ulong regionHandle, out Scene scene)
199 {
200 lock (m_scenes)
201 {
202 foreach (Scene nextScene in m_scenes)
203 {
204 if (nextScene.RegionInfo.RegionHandle == regionHandle)
205 {
206 scene = nextScene;
207 return true;
208 }
209 }
210 }
211
212 scene = null;
213 return false;
214 }
215
216 protected bool TryGetRegion(UUID regionID, out Scene scene)
217 {
218 lock (m_scenes)
219 {
220 foreach (Scene nextScene in m_scenes)
221 {
222 if (nextScene.RegionInfo.RegionID == regionID)
223 {
224 scene = nextScene;
225 return true;
226 }
227 }
228 }
229
230 scene = null;
231 return false;
232 }
233
234 protected bool TryGetRegion(string regionName, out Scene scene)
235 {
236 lock (m_scenes)
237 {
238 foreach (Scene nextScene in m_scenes)
239 {
240 if (nextScene.RegionInfo.RegionName.Equals(regionName, StringComparison.InvariantCultureIgnoreCase))
241 {
242 scene = nextScene;
243 return true;
244 }
245 }
246 }
247
248 scene = null;
249 return false;
250 }
251
252 public XmlRpcResponse XmlRPCGetAvatarAppearance(XmlRpcRequest request, IPEndPoint remoteClient)
253 {
254 XmlRpcResponse response = new XmlRpcResponse();
255 Hashtable requestData = (Hashtable)request.Params[0];
256 AvatarAppearance appearance;
257 Hashtable responseData;
258 if (requestData.Contains("owner"))
259 {
260 appearance = m_firstScene.CommsManager.AvatarService.GetUserAppearance(new UUID((string)requestData["owner"]));
261 if (appearance == null)
262 {
263 responseData = new Hashtable();
264 responseData["error_type"] = "no appearance";
265 responseData["error_desc"] = "There was no appearance found for this avatar";
266 }
267 else
268 {
269 responseData = appearance.ToHashTable();
270 }
271 }
272 else
273 {
274 responseData = new Hashtable();
275 responseData["error_type"] = "unknown_avatar";
276 responseData["error_desc"] = "The avatar appearance requested is not in the database";
277 }
278
279 response.Value = responseData;
280 return response;
281 }
282
283 public XmlRpcResponse XmlRPCUpdateAvatarAppearance(XmlRpcRequest request, IPEndPoint remoteClient)
284 {
285 XmlRpcResponse response = new XmlRpcResponse();
286 Hashtable requestData = (Hashtable)request.Params[0];
287 Hashtable responseData;
288 if (requestData.Contains("owner"))
289 {
290 AvatarAppearance appearance = new AvatarAppearance(requestData);
291
292 // TODO: Sometime in the future we may have a database layer that is capable of updating appearance when
293 // the TextureEntry is null. When that happens, this check can be removed
294 if (appearance.Texture != null)
295 m_firstScene.CommsManager.AvatarService.UpdateUserAppearance(new UUID((string)requestData["owner"]), appearance);
296
297 responseData = new Hashtable();
298 responseData["returnString"] = "TRUE";
299 }
300 else
301 {
302 responseData = new Hashtable();
303 responseData["error_type"] = "unknown_avatar";
304 responseData["error_desc"] = "The avatar appearance requested is not in the database";
305 }
306 response.Value = responseData;
307 return response;
308 }
309 }
310
311}
diff --git a/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs b/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs
index 0f2ba32..b7d3904 100644
--- a/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs
+++ b/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs
@@ -46,7 +46,6 @@ namespace OpenSim.Region.CoreModules.InterGrid
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 private readonly List<Scene> m_scenes = new List<Scene>(); 48 private readonly List<Scene> m_scenes = new List<Scene>();
49 private CommunicationsManager m_com;
50 private IConfigSource m_settings; 49 private IConfigSource m_settings;
51 50
52 #region Implementation of IRegionModuleBase 51 #region Implementation of IRegionModuleBase
@@ -88,7 +87,6 @@ namespace OpenSim.Region.CoreModules.InterGrid
88 { 87 {
89 if (m_settings.Configs["Startup"].GetBoolean("gridmode", false)) 88 if (m_settings.Configs["Startup"].GetBoolean("gridmode", false))
90 { 89 {
91 m_com = m_scenes[0].CommsManager;
92 MainServer.Instance.AddXmlRPCHandler("grid_message", GridWideMessage); 90 MainServer.Instance.AddXmlRPCHandler("grid_message", GridWideMessage);
93 } 91 }
94 } 92 }
@@ -119,14 +117,15 @@ namespace OpenSim.Region.CoreModules.InterGrid
119 117
120 Hashtable requestData = (Hashtable)req.Params[0]; 118 Hashtable requestData = (Hashtable)req.Params[0];
121 119
122 if ((!requestData.Contains("password") || (string)requestData["password"] != m_com.NetworkServersInfo.GridRecvKey)) 120 // REFACTORING PROBLEM. This authorization needs to be replaced with some other
123 { 121 //if ((!requestData.Contains("password") || (string)requestData["password"] != m_com.NetworkServersInfo.GridRecvKey))
124 responseData["accepted"] = false; 122 //{
125 responseData["success"] = false; 123 // responseData["accepted"] = false;
126 responseData["error"] = "Invalid Key"; 124 // responseData["success"] = false;
127 response.Value = responseData; 125 // responseData["error"] = "Invalid Key";
128 return response; 126 // response.Value = responseData;
129 } 127 // return response;
128 //}
130 129
131 string message = (string)requestData["message"]; 130 string message = (string)requestData["message"];
132 string user = (string)requestData["user"]; 131 string user = (string)requestData["user"];
diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
index 10a3232..8cf4619 100644
--- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
+++ b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
@@ -528,32 +528,34 @@ namespace OpenSim.Region.CoreModules.InterGrid
528 userProfile.PasswordHash = "$1$"; 528 userProfile.PasswordHash = "$1$";
529 userProfile.PasswordSalt = ""; 529 userProfile.PasswordSalt = "";
530 userProfile.SurName = agentData.lastname; 530 userProfile.SurName = agentData.lastname;
531 userProfile.UserAssetURI = homeScene.CommsManager.NetworkServersInfo.AssetURL; 531 //userProfile.UserAssetURI = homeScene.CommsManager.NetworkServersInfo.AssetURL;
532 userProfile.UserFlags = 0; 532 userProfile.UserFlags = 0;
533 userProfile.UserInventoryURI = homeScene.CommsManager.NetworkServersInfo.InventoryURL; 533 //userProfile.UserInventoryURI = homeScene.CommsManager.NetworkServersInfo.InventoryURL;
534 userProfile.WantDoMask = 0; 534 userProfile.WantDoMask = 0;
535 userProfile.WebLoginKey = UUID.Random(); 535 userProfile.WebLoginKey = UUID.Random();
536 536
537 // Do caps registration 537 // !!! REFACTORING PROBLEM. This needs to be changed for 0.7
538 // get seed capagentData.firstname = FirstName;agentData.lastname = LastName; 538 //
539 if (homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID) == null && !GridMode) 539 //// Do caps registration
540 { 540 //// get seed capagentData.firstname = FirstName;agentData.lastname = LastName;
541 homeScene.CommsManager.UserAdminService.AddUser( 541 //if (homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID) == null && !GridMode)
542 agentData.firstname, agentData.lastname, CreateRandomStr(7), "", 542 //{
543 homeScene.RegionInfo.RegionLocX, homeScene.RegionInfo.RegionLocY, agentData.AgentID); 543 // homeScene.CommsManager.UserAdminService.AddUser(
544 // agentData.firstname, agentData.lastname, CreateRandomStr(7), "",
545 // homeScene.RegionInfo.RegionLocX, homeScene.RegionInfo.RegionLocY, agentData.AgentID);
544 546
545 UserProfileData userProfile2 = homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID); 547 // UserProfileData userProfile2 = homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID);
546 if (userProfile2 != null) 548 // if (userProfile2 != null)
547 { 549 // {
548 userProfile = userProfile2; 550 // userProfile = userProfile2;
549 userProfile.AboutText = "OGP USER"; 551 // userProfile.AboutText = "OGP USER";
550 userProfile.FirstLifeAboutText = "OGP USER"; 552 // userProfile.FirstLifeAboutText = "OGP USER";
551 homeScene.CommsManager.UserService.UpdateUserProfile(userProfile); 553 // homeScene.CommsManager.UserService.UpdateUserProfile(userProfile);
552 } 554 // }
553 } 555 //}
554 556
555 // Stick our data in the cache so the region will know something about us 557 //// Stick our data in the cache so the region will know something about us
556 homeScene.CommsManager.UserProfileCacheService.PreloadUserCache(userProfile); 558 //homeScene.CommsManager.UserProfileCacheService.PreloadUserCache(userProfile);
557 559
558 // Call 'new user' event handler 560 // Call 'new user' event handler
559 string reason; 561 string reason;
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
index ebc7f59..0195c03 100644
--- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
+++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
@@ -8,6 +8,10 @@
8 </Dependencies> 8 </Dependencies>
9 9
10 <Extension path = "/OpenSim/RegionModules"> 10 <Extension path = "/OpenSim/RegionModules">
11 <RegionModule id="EntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule" />
12 <RegionModule id="HGEntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.HGEntityTransferModule" />
13 <RegionModule id="InventoryAccessModule" type="OpenSim.Region.CoreModules.Framework.InventoryAccess.BasicInventoryAccessModule" />
14 <RegionModule id="HGInventoryAccessModule" type="OpenSim.Region.CoreModules.Framework.InventoryAccess.HGInventoryAccessModule" />
11 <RegionModule id="LandManagementModule" type="OpenSim.Region.CoreModules.World.Land.LandManagementModule" /> 15 <RegionModule id="LandManagementModule" type="OpenSim.Region.CoreModules.World.Land.LandManagementModule" />
12 <RegionModule id="ExportSerialisationModule" type="OpenSim.Region.CoreModules.World.Serialiser.SerialiserModule" /> 16 <RegionModule id="ExportSerialisationModule" type="OpenSim.Region.CoreModules.World.Serialiser.SerialiserModule" />
13 <RegionModule id="ArchiverModule" type="OpenSim.Region.CoreModules.World.Archiver.ArchiverModule" /> 17 <RegionModule id="ArchiverModule" type="OpenSim.Region.CoreModules.World.Archiver.ArchiverModule" />
@@ -17,15 +21,25 @@
17 <RegionModule id="HGWorldMapModule" type="OpenSim.Region.CoreModules.Hypergrid.HGWorldMapModule" /> 21 <RegionModule id="HGWorldMapModule" type="OpenSim.Region.CoreModules.Hypergrid.HGWorldMapModule" />
18 <RegionModule id="UrlModule" type="OpenSim.Region.CoreModules.Scripting.LSLHttp.UrlModule" /> 22 <RegionModule id="UrlModule" type="OpenSim.Region.CoreModules.Scripting.LSLHttp.UrlModule" />
19 <RegionModule id="Chat" type="OpenSim.Region.CoreModules.Avatar.Chat.ChatModule" /> 23 <RegionModule id="Chat" type="OpenSim.Region.CoreModules.Avatar.Chat.ChatModule" />
24 <RegionModule id="FriendsModule" type="OpenSim.Region.CoreModules.Avatar.Friends.FriendsModule" />
25 <RegionModule id="PresenceModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.PresenceModule" />
26 <RegionModule id="MuteListModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.MuteListModule" />
27 <RegionModule id="OfflineMessageModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.OfflineMessageModule" />
28 <RegionModule id="InstantMessageModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.InstantMessageModule" />
29 <RegionModule id="MessageTransferModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.MessageTransferModule" />
30 <RegionModule id="LureModule" type="OpenSim.Region.CoreModules.Avatar.Lure.LureModule" />
31 <RegionModule id="InventoryTransferModule" type="OpenSim.Region.CoreModules.Avatar.Inventory.Transfer.InventoryTransferModule" />
20 <RegionModule id="CoreAssetCache" type="OpenSim.Region.CoreModules.Asset.CoreAssetCache" /> 32 <RegionModule id="CoreAssetCache" type="OpenSim.Region.CoreModules.Asset.CoreAssetCache" />
21 <RegionModule id="GlynnTuckerAssetCache" type="OpenSim.Region.CoreModules.Asset.GlynnTuckerAssetCache" /> 33 <RegionModule id="GlynnTuckerAssetCache" type="OpenSim.Region.CoreModules.Asset.GlynnTuckerAssetCache" />
22 <RegionModule id="CenomeMemoryAssetCache" type="OpenSim.Region.CoreModules.Asset.CenomeMemoryAssetCache"/> 34 <RegionModule id="CenomeMemoryAssetCache" type="OpenSim.Region.CoreModules.Asset.CenomeMemoryAssetCache"/>
23 <RegionModule id="LibraryModule" type="OpenSim.Region.CoreModules.Framework.Library.LibraryModule"/> 35 <RegionModule id="LibraryModule" type="OpenSim.Region.CoreModules.Framework.Library.LibraryModule"/>
24 <!-- Service connectors OUT modules --> 36 <!-- Service connectors OUT modules -->
25 <RegionModule id="LocalUserServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.User.LocalUserServicesConnector" />
26 <RegionModule id="RemoteUserServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.User.RemoteUserServicesConnector" />
27 <RegionModule id="LocalAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.LocalAssetServicesConnector" /> 37 <RegionModule id="LocalAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.LocalAssetServicesConnector" />
28 <RegionModule id="RemoteAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.RemoteAssetServicesConnector" /> 38 <RegionModule id="RemoteAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.RemoteAssetServicesConnector" />
39 <RegionModule id="LocalAvatarServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar.LocalAvatarServicesConnector" />
40 <RegionModule id="RemoteAvatarServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar.RemoteAvatarServicesConnector" />
41 <RegionModule id="LocalAuthenticationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication.LocalAuthenticationServicesConnector" />
42 <RegionModule id="RemoteAuthenticationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication.RemoteAuthenticationServicesConnector" />
29 <RegionModule id="LocalAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.LocalAuthorizationServicesConnector" /> 43 <RegionModule id="LocalAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.LocalAuthorizationServicesConnector" />
30 <RegionModule id="RemoteAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.RemoteAuthorizationServicesConnector" /> 44 <RegionModule id="RemoteAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.RemoteAuthorizationServicesConnector" />
31 <RegionModule id="HGAssetBroker" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.HGAssetBroker" /> 45 <RegionModule id="HGAssetBroker" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.HGAssetBroker" />
@@ -36,17 +50,24 @@
36 <RegionModule id="RemoteNeighbourServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour.RemoteNeighbourServicesConnector" /> 50 <RegionModule id="RemoteNeighbourServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour.RemoteNeighbourServicesConnector" />
37 <RegionModule id="LocalLandServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Land.LocalLandServicesConnector" /> 51 <RegionModule id="LocalLandServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Land.LocalLandServicesConnector" />
38 <RegionModule id="RemoteLandServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Land.RemoteLandServicesConnector" /> 52 <RegionModule id="RemoteLandServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Land.RemoteLandServicesConnector" />
39 <RegionModule id="LocalInterregionComms" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion.LocalInterregionComms" />
40 <RegionModule id="RESTInterregionComms" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion.RESTInterregionComms" />
41 <RegionModule id="LocalGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.LocalGridServicesConnector" /> 53 <RegionModule id="LocalGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.LocalGridServicesConnector" />
42 <RegionModule id="RemoteGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.RemoteGridServicesConnector" /> 54 <RegionModule id="RemoteGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.RemoteGridServicesConnector" />
43 <RegionModule id="HGGridConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.HGGridConnector" /> 55 <RegionModule id="LocalPresenceServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.LocalPresenceServicesConnector" />
56 <RegionModule id="RemotePresenceServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.RemotePresenceServicesConnector" />
57 <RegionModule id="LocalUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.LocalUserAccountServicesConnector" />
58 <RegionModule id="RemoteUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.RemoteUserAccountServicesConnector" />
59 <RegionModule id="LocalSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.LocalSimulationConnectorModule" />
60 <RegionModule id="RemoteSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.RemoteSimulationConnectorModule" />
44 <!-- Service connectors IN modules --> 61 <!-- Service connectors IN modules -->
45 <RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" /> 62 <RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" />
46 <RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" /> 63 <RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" />
47 <RegionModule id="LandServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Land.LandServiceInConnectorModule" /> 64 <RegionModule id="LandServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Land.LandServiceInConnectorModule" />
48 <RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour.NeighbourServiceInConnectorModule" /> \ 65 <RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour.NeighbourServiceInConnectorModule" /> \
49 <RegionModule id="HypergridServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid.HypergridServiceInConnectorModule" /> \ 66 <RegionModule id="HypergridServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Hypergrid.HypergridServiceInConnectorModule" /> \
67 <RegionModule id="LLLoginServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Login.LLLoginServiceInConnectorModule" /> \
68 <RegionModule id="SimulationServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation.SimulationServiceInConnectorModule" /> \
69 <RegionModule id="GridInfoServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid.GridInfoServiceInConnectorModule" /> \
70 <RegionModule id="AuthenticationServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Authentication.AuthenticationServiceInConnectorModule" />
50 <RegionModule id="AccessModule" type="OpenSim.Region.CoreModules.World.AccessModule" /> \ 71 <RegionModule id="AccessModule" type="OpenSim.Region.CoreModules.World.AccessModule" /> \
51 72
52 </Extension> 73 </Extension>
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
index e3c7bbf..643764f 100644
--- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
@@ -309,7 +309,8 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
309 } 309 }
310 310
311 // Create a new asset for user 311 // Create a new asset for user
312 AssetBase asset = new AssetBase(UUID.Random(), "DynamicImage" + Util.RandomClass.Next(1, 10000), (sbyte)AssetType.Texture); 312 AssetBase asset = new AssetBase(UUID.Random(), "DynamicImage" + Util.RandomClass.Next(1, 10000), (sbyte)AssetType.Texture,
313 scene.RegionInfo.RegionID.ToString());
313 asset.Data = assetData; 314 asset.Data = assetData;
314 asset.Description = String.Format("URL image : {0}", Url); 315 asset.Description = String.Format("URL image : {0}", Url);
315 asset.Local = false; 316 asset.Local = false;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs
index 879cc70..2324380 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs
@@ -51,11 +51,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset
51 51
52 public void Initialise(IConfigSource config) 52 public void Initialise(IConfigSource config)
53 { 53 {
54 //// This module is only on for standalones in hypergrid mode
55 //enabled = ((!config.Configs["Startup"].GetBoolean("gridmode", true)) &&
56 // config.Configs["Startup"].GetBoolean("hypergrid", true)) ||
57 // ((config.Configs["MXP"] != null) && config.Configs["MXP"].GetBoolean("Enabled", true));
58 //m_log.DebugFormat("[RegionAssetService]: enabled? {0}", enabled);
59 m_Config = config; 54 m_Config = config;
60 IConfig moduleConfig = config.Configs["Modules"]; 55 IConfig moduleConfig = config.Configs["Modules"];
61 if (moduleConfig != null) 56 if (moduleConfig != null)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs
new file mode 100644
index 0000000..02acddc
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs
@@ -0,0 +1,119 @@
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.Generic;
31using log4net;
32using Nini.Config;
33using OpenSim.Framework;
34using OpenSim.Framework.Servers.HttpServer;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Server.Base;
38using OpenSim.Server.Handlers.Base;
39using OpenSim.Server.Handlers.Authentication;
40using OpenSim.Services.Interfaces;
41
42namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Authentication
43{
44 public class AuthenticationServiceInConnectorModule : ISharedRegionModule
45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 private static bool m_Enabled = false;
48
49 private IConfigSource m_Config;
50 bool m_Registered = false;
51
52 #region IRegionModule interface
53
54 public void Initialise(IConfigSource config)
55 {
56 m_Config = config;
57 IConfig moduleConfig = config.Configs["Modules"];
58 if (moduleConfig != null)
59 {
60 m_Enabled = moduleConfig.GetBoolean("AuthenticationServiceInConnector", false);
61 if (m_Enabled)
62 {
63 m_log.Info("[AUTHENTICATION IN CONNECTOR]: Authentication Service In Connector enabled");
64 }
65
66 }
67
68 }
69
70 public void PostInitialise()
71 {
72 }
73
74 public void Close()
75 {
76 }
77
78 public Type ReplaceableInterface
79 {
80 get { return null; }
81 }
82
83 public string Name
84 {
85 get { return "AuthenticationServiceInConnectorModule"; }
86 }
87
88 public void AddRegion(Scene scene)
89 {
90 if (!m_Enabled)
91 return;
92 }
93
94 public void RemoveRegion(Scene scene)
95 {
96 if (!m_Enabled)
97 return;
98 }
99
100 public void RegionLoaded(Scene scene)
101 {
102 if (!m_Enabled)
103 return;
104
105 if (!m_Registered)
106 {
107 m_Registered = true;
108
109 m_log.Info("[AUTHENTICATION IN CONNECTOR]: Starting...");
110
111 new AuthenticationServiceConnector(m_Config, MainServer.Instance, "AuthenticationService");
112 }
113
114 }
115
116 #endregion
117
118 }
119}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs
new file mode 100644
index 0000000..6d975af
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs
@@ -0,0 +1,119 @@
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.Generic;
31using log4net;
32using Nini.Config;
33using OpenSim.Framework;
34using OpenSim.Framework.Servers.HttpServer;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Server.Base;
38using OpenSim.Server.Handlers.Base;
39using OpenSim.Server.Handlers.Grid;
40using OpenSim.Services.Interfaces;
41
42namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
43{
44 public class GridInfoServiceInConnectorModule : ISharedRegionModule
45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 private static bool m_Enabled = false;
48
49 private IConfigSource m_Config;
50 bool m_Registered = false;
51
52 #region IRegionModule interface
53
54 public void Initialise(IConfigSource config)
55 {
56 m_Config = config;
57 IConfig moduleConfig = config.Configs["Modules"];
58 if (moduleConfig != null)
59 {
60 m_Enabled = moduleConfig.GetBoolean("GridInfoServiceInConnector", false);
61 if (m_Enabled)
62 {
63 m_log.Info("[GRIDINFO IN CONNECTOR]: GridInfo Service In Connector enabled");
64 }
65
66 }
67
68 }
69
70 public void PostInitialise()
71 {
72 }
73
74 public void Close()
75 {
76 }
77
78 public Type ReplaceableInterface
79 {
80 get { return null; }
81 }
82
83 public string Name
84 {
85 get { return "GridInfoService"; }
86 }
87
88 public void AddRegion(Scene scene)
89 {
90 if (!m_Enabled)
91 return;
92 }
93
94 public void RemoveRegion(Scene scene)
95 {
96 if (!m_Enabled)
97 return;
98 }
99
100 public void RegionLoaded(Scene scene)
101 {
102 if (!m_Enabled)
103 return;
104
105 if (!m_Registered)
106 {
107 m_Registered = true;
108
109 m_log.Info("[GridInfo]: Starting...");
110
111 new GridInfoServerInConnector(m_Config, MainServer.Instance, "GridInfoService");
112 }
113
114 }
115
116 #endregion
117
118 }
119}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs
index b12d778..c6848bb 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs
@@ -36,11 +36,11 @@ using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Server.Base; 37using OpenSim.Server.Base;
38using OpenSim.Server.Handlers.Base; 38using OpenSim.Server.Handlers.Base;
39using OpenSim.Server.Handlers.Grid; 39using OpenSim.Server.Handlers.Hypergrid;
40using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion; 41using GridRegion = OpenSim.Services.Interfaces.GridRegion;
42 42
43namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid 43namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Hypergrid
44{ 44{
45 public class HypergridServiceInConnectorModule : ISharedRegionModule 45 public class HypergridServiceInConnectorModule : ISharedRegionModule
46 { 46 {
@@ -49,16 +49,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
49 49
50 private IConfigSource m_Config; 50 private IConfigSource m_Config;
51 bool m_Registered = false; 51 bool m_Registered = false;
52 HypergridServiceInConnector m_HypergridHandler; 52 GatekeeperServiceInConnector m_HypergridHandler;
53 53
54 #region IRegionModule interface 54 #region IRegionModule interface
55 55
56 public void Initialise(IConfigSource config) 56 public void Initialise(IConfigSource config)
57 { 57 {
58 //// This module is only on for standalones in hypergrid mode
59 //enabled = (!config.Configs["Startup"].GetBoolean("gridmode", true)) &&
60 // config.Configs["Startup"].GetBoolean("hypergrid", true);
61 //m_log.DebugFormat("[RegionInventoryService]: enabled? {0}", enabled);
62 m_Config = config; 58 m_Config = config;
63 IConfig moduleConfig = config.Configs["Modules"]; 59 IConfig moduleConfig = config.Configs["Modules"];
64 if (moduleConfig != null) 60 if (moduleConfig != null)
@@ -102,9 +98,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
102 { 98 {
103 if (!m_Enabled) 99 if (!m_Enabled)
104 return; 100 return;
105
106 GridRegion rinfo = new GridRegion(scene.RegionInfo);
107 m_HypergridHandler.RemoveRegion(rinfo);
108 } 101 }
109 102
110 public void RegionLoaded(Scene scene) 103 public void RegionLoaded(Scene scene)
@@ -118,14 +111,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
118 111
119 m_log.Info("[HypergridService]: Starting..."); 112 m_log.Info("[HypergridService]: Starting...");
120 113
121// Object[] args = new Object[] { m_Config, MainServer.Instance }; 114 ISimulationService simService = scene.RequestModuleInterface<ISimulationService>();
115 m_HypergridHandler = new GatekeeperServiceInConnector(m_Config, MainServer.Instance, simService);
116 scene.RegisterModuleInterface<IGatekeeperService>(m_HypergridHandler.GateKeeper);
122 117
123 m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance, scene.RequestModuleInterface<IHyperlinkService>()); 118 new UserAgentServerConnector(m_Config, MainServer.Instance);
124 //ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
125 } 119 }
126
127 GridRegion rinfo = new GridRegion(scene.RegionInfo);
128 m_HypergridHandler.AddRegion(rinfo);
129 } 120 }
130 121
131 #endregion 122 #endregion
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs
index 54c6d89..ae03cdf 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs
@@ -51,10 +51,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory
51 51
52 public void Initialise(IConfigSource config) 52 public void Initialise(IConfigSource config)
53 { 53 {
54 //// This module is only on for standalones in hypergrid mode
55 //enabled = (!config.Configs["Startup"].GetBoolean("gridmode", true)) &&
56 // config.Configs["Startup"].GetBoolean("hypergrid", true);
57 //m_log.DebugFormat("[RegionInventoryService]: enabled? {0}", enabled);
58 m_Config = config; 54 m_Config = config;
59 IConfig moduleConfig = config.Configs["Modules"]; 55 IConfig moduleConfig = config.Configs["Modules"];
60 if (moduleConfig != null) 56 if (moduleConfig != null)
@@ -98,9 +94,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory
98 94
99 m_log.Info("[RegionInventoryService]: Starting..."); 95 m_log.Info("[RegionInventoryService]: Starting...");
100 96
101 Object[] args = new Object[] { m_Config, MainServer.Instance, String.Empty }; 97 Object[] args = new Object[] { m_Config, MainServer.Instance, "HGInventoryService" };
102 98
103 ServerUtils.LoadPlugin<IServiceConnector>("OpenSim.Server.Handlers.dll:InventoryServiceInConnector", args); 99 ServerUtils.LoadPlugin<IServiceConnector>("OpenSim.Server.Handlers.dll:HGInventoryServiceInConnector", args);
104 } 100 }
105 } 101 }
106 102
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs
new file mode 100644
index 0000000..2a9366c
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs
@@ -0,0 +1,128 @@
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.Generic;
31using log4net;
32using Nini.Config;
33using OpenSim.Framework;
34using OpenSim.Framework.Servers.HttpServer;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Server.Base;
38using OpenSim.Server.Handlers.Base;
39using OpenSim.Server.Handlers.Login;
40using OpenSim.Services.Interfaces;
41
42
43namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Login
44{
45 public class LLLoginServiceInConnectorModule : ISharedRegionModule
46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 private static bool m_Enabled = false;
49 private static bool m_Registered = false;
50
51 private IConfigSource m_Config;
52 private List<Scene> m_Scenes = new List<Scene>();
53
54 #region IRegionModule interface
55
56 public void Initialise(IConfigSource config)
57 {
58 m_Config = config;
59
60 IConfig moduleConfig = config.Configs["Modules"];
61 if (moduleConfig != null)
62 {
63 m_Enabled = moduleConfig.GetBoolean("LLLoginServiceInConnector", false);
64 if (m_Enabled)
65 {
66 m_log.Info("[LLLOGIN IN CONNECTOR]: LLLoginerviceInConnector enabled");
67 }
68
69 }
70
71 }
72
73 public void PostInitialise()
74 {
75 if (!m_Enabled)
76 return;
77
78 m_log.Info("[LLLOGIN IN CONNECTOR]: Starting...");
79 }
80
81 public void Close()
82 {
83 }
84
85 public Type ReplaceableInterface
86 {
87 get { return null; }
88 }
89
90 public string Name
91 {
92 get { return "LLLoginServiceInConnectorModule"; }
93 }
94
95 public void AddRegion(Scene scene)
96 {
97 if (!m_Enabled)
98 return;
99
100 m_Scenes.Add(scene);
101
102 }
103
104 public void RemoveRegion(Scene scene)
105 {
106 if (m_Enabled && m_Scenes.Contains(scene))
107 m_Scenes.Remove(scene);
108 }
109
110 public void RegionLoaded(Scene scene)
111 {
112 if (!m_Enabled)
113 return;
114
115 if (!m_Registered)
116 {
117 m_Registered = true;
118 new LLLoginServiceInConnector(m_Config, MainServer.Instance, scene);
119 //Object[] args = new Object[] { m_Config, MainServer.Instance, this, scene };
120 //ServerUtils.LoadPlugin<IServiceConnector>("OpenSim.Server.Handlers.dll:LLLoginServiceInConnector", args);
121 }
122
123 }
124
125 #endregion
126
127 }
128}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs
index f28a318..5ee1c97 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs
@@ -58,11 +58,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation
58 IConfig moduleConfig = config.Configs["Modules"]; 58 IConfig moduleConfig = config.Configs["Modules"];
59 if (moduleConfig != null) 59 if (moduleConfig != null)
60 { 60 {
61 string name = moduleConfig.GetString("SimulationService", ""); 61 m_Enabled = moduleConfig.GetBoolean("SimulationServiceInConnector", false);
62 if (name == Name) 62 if (m_Enabled)
63 { 63 {
64 m_Enabled = true; 64 m_log.Info("[SIM SERVICE]: SimulationService IN connector enabled");
65 m_log.Info("[SIM SERVICE]: SimulationService enabled");
66 65
67 } 66 }
68 } 67 }
@@ -84,7 +83,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation
84 83
85 public string Name 84 public string Name
86 { 85 {
87 get { return "SimulationService"; } 86 get { return "SimulationServiceInConnectorModule"; }
88 } 87 }
89 88
90 public void AddRegion(Scene scene) 89 public void AddRegion(Scene scene)
@@ -92,6 +91,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation
92 if (!m_Enabled) 91 if (!m_Enabled)
93 return; 92 return;
94 93
94 }
95
96 public void RemoveRegion(Scene scene)
97 {
98 }
99
100 public void RegionLoaded(Scene scene)
101 {
102 if (!m_Enabled)
103 return;
104
95 if (!m_Registered) 105 if (!m_Registered)
96 { 106 {
97 m_Registered = true; 107 m_Registered = true;
@@ -104,14 +114,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation
104 } 114 }
105 } 115 }
106 116
107 public void RemoveRegion(Scene scene)
108 {
109 }
110
111 public void RegionLoaded(Scene scene)
112 {
113 }
114
115 #endregion 117 #endregion
116 118
117 } 119 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
index 0aa753d..af2f3d6 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
@@ -31,7 +31,7 @@ using System;
31using System.Collections.Generic; 31using System.Collections.Generic;
32using System.Reflection; 32using System.Reflection;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications.Cache; 34
35using OpenSim.Server.Base; 35using OpenSim.Server.Base;
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
@@ -366,18 +366,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
366 366
367 public string GetUserAssetServer(UUID userID) 367 public string GetUserAssetServer(UUID userID)
368 { 368 {
369 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID); 369 UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, userID);
370 if ((uinfo != null) && (uinfo.UserProfile != null)) 370
371 { 371 if (account != null && account.ServiceURLs.ContainsKey("AssetServerURI") && account.ServiceURLs["AssetServerURI"] != null)
372 if ((uinfo.UserProfile.UserAssetURI == string.Empty) || (uinfo.UserProfile.UserAssetURI == "")) 372 return account.ServiceURLs["AssetServerURI"].ToString();
373 return m_LocalAssetServiceURI; 373
374 return uinfo.UserProfile.UserAssetURI.Trim('/'); 374 return string.Empty;
375 }
376 else
377 {
378 // we don't know anyting about this user
379 return string.Empty;
380 }
381 } 375 }
382 376
383 public string GetSimAssetServer() 377 public string GetSimAssetServer()
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs
index 2f21e6d..50348da 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs
@@ -224,7 +224,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
224 m_Cache.Cache(a); 224 m_Cache.Cache(a);
225 225
226// if (null == a) 226// if (null == a)
227// m_log.WarnFormat("[LOCAL ASSET SERVICES CONNECTOR]: Could not asynchronously find asset with id {0}", id); 227// m_log.WarnFormat("[LOCAL ASSET SERVICES CONNECTOR]: Could not asynchronously find asset with id {0}", id);
228 228
229 Util.FireAndForget(delegate { handler(assetID, s, a); }); 229 Util.FireAndForget(delegate { handler(assetID, s, a); });
230 }); 230 });
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs
new file mode 100644
index 0000000..acc362b
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs
@@ -0,0 +1,164 @@
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 log4net;
32using Nini.Config;
33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Server.Base;
36using OpenSim.Services.Interfaces;
37
38using OpenMetaverse;
39
40namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication
41{
42 public class LocalAuthenticationServicesConnector : ISharedRegionModule, IAuthenticationService
43 {
44 private static readonly ILog m_log =
45 LogManager.GetLogger(
46 MethodBase.GetCurrentMethod().DeclaringType);
47
48 private IAuthenticationService m_AuthenticationService;
49
50 private bool m_Enabled = false;
51
52 #region ISharedRegionModule
53
54 public Type ReplaceableInterface
55 {
56 get { return null; }
57 }
58
59 public string Name
60 {
61 get { return "LocalAuthenticationServicesConnector"; }
62 }
63
64 public void Initialise(IConfigSource source)
65 {
66 IConfig moduleConfig = source.Configs["Modules"];
67 if (moduleConfig != null)
68 {
69 string name = moduleConfig.GetString("AuthenticationServices", "");
70 if (name == Name)
71 {
72 IConfig userConfig = source.Configs["AuthenticationService"];
73 if (userConfig == null)
74 {
75 m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini");
76 return;
77 }
78
79 string serviceDll = userConfig.GetString("LocalServiceModule",
80 String.Empty);
81
82 if (serviceDll == String.Empty)
83 {
84 m_log.Error("[AUTH CONNECTOR]: No LocalServiceModule named in section AuthenticationService");
85 return;
86 }
87
88 Object[] args = new Object[] { source };
89 m_AuthenticationService =
90 ServerUtils.LoadPlugin<IAuthenticationService>(serviceDll,
91 args);
92
93 if (m_AuthenticationService == null)
94 {
95 m_log.Error("[AUTH CONNECTOR]: Can't load Authentication service");
96 return;
97 }
98 m_Enabled = true;
99 m_log.Info("[AUTH CONNECTOR]: Local Authentication connector enabled");
100 }
101 }
102 }
103
104 public void PostInitialise()
105 {
106 if (!m_Enabled)
107 return;
108 }
109
110 public void Close()
111 {
112 if (!m_Enabled)
113 return;
114 }
115
116 public void AddRegion(Scene scene)
117 {
118 if (!m_Enabled)
119 return;
120
121 scene.RegisterModuleInterface<IAuthenticationService>(m_AuthenticationService);
122 }
123
124 public void RemoveRegion(Scene scene)
125 {
126 if (!m_Enabled)
127 return;
128 }
129
130 public void RegionLoaded(Scene scene)
131 {
132 if (!m_Enabled)
133 return;
134 }
135
136 #endregion
137
138 #region IAuthenticationService
139
140 public string Authenticate(UUID principalID, string password, int lifetime)
141 {
142 // Not implemented at the regions
143 return string.Empty;
144 }
145
146 public bool Verify(UUID principalID, string token, int lifetime)
147 {
148 return m_AuthenticationService.Verify(principalID, token, lifetime);
149 }
150
151 public bool Release(UUID principalID, string token)
152 {
153 return m_AuthenticationService.Release(principalID, token);
154 }
155
156 public bool SetPassword(UUID principalID, string passwd)
157 {
158 return m_AuthenticationService.SetPassword(principalID, passwd);
159 }
160
161 #endregion
162
163 }
164}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs
index cca5bb4..a053bc2 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs
@@ -26,24 +26,23 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Reflection;
30using log4net;
31using Nini.Config; 29using Nini.Config;
30using log4net;
31using System.Reflection;
32using OpenSim.Region.Framework.Interfaces; 32using OpenSim.Region.Framework.Interfaces;
33using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
34using OpenSim.Server.Base;
35using OpenSim.Services.Interfaces; 34using OpenSim.Services.Interfaces;
35using OpenSim.Services.Connectors;
36 36
37namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User 37namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication
38{ 38{
39 public class LocalUserServicesConnector : ISharedRegionModule 39 public class RemoteAuthenticationServicesConnector : AuthenticationServicesConnector,
40 ISharedRegionModule, IAuthenticationService
40 { 41 {
41 private static readonly ILog m_log = 42 private static readonly ILog m_log =
42 LogManager.GetLogger( 43 LogManager.GetLogger(
43 MethodBase.GetCurrentMethod().DeclaringType); 44 MethodBase.GetCurrentMethod().DeclaringType);
44 45
45 private IUserAccountService m_UserService;
46
47 private bool m_Enabled = false; 46 private bool m_Enabled = false;
48 47
49 public Type ReplaceableInterface 48 public Type ReplaceableInterface
@@ -53,45 +52,29 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User
53 52
54 public string Name 53 public string Name
55 { 54 {
56 get { return "LocalUserServicesConnector"; } 55 get { return "RemoteAuthenticationServicesConnector"; }
57 } 56 }
58 57
59 public void Initialise(IConfigSource source) 58 public override void Initialise(IConfigSource source)
60 { 59 {
61 IConfig moduleConfig = source.Configs["Modules"]; 60 IConfig moduleConfig = source.Configs["Modules"];
62 if (moduleConfig != null) 61 if (moduleConfig != null)
63 { 62 {
64 string name = moduleConfig.GetString("UserServices", ""); 63 string name = moduleConfig.GetString("AuthenticationServices", "");
65 if (name == Name) 64 if (name == Name)
66 { 65 {
67 IConfig userConfig = source.Configs["UserService"]; 66 IConfig userConfig = source.Configs["AuthenticationService"];
68 if (userConfig == null) 67 if (userConfig == null)
69 { 68 {
70 m_log.Error("[USER CONNECTOR]: UserService missing from OpenSim.ini"); 69 m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini");
71 return; 70 return;
72 } 71 }
73 72
74 string serviceDll = userConfig.GetString("LocalServiceModule", 73 m_Enabled = true;
75 String.Empty);
76
77 if (serviceDll == String.Empty)
78 {
79 m_log.Error("[USER CONNECTOR]: No LocalServiceModule named in section UserService");
80 return;
81 }
82 74
83 Object[] args = new Object[] { source }; 75 base.Initialise(source);
84 m_UserService =
85 ServerUtils.LoadPlugin<IUserAccountService>(serviceDll,
86 args);
87 76
88 if (m_UserService == null) 77 m_log.Info("[AUTH CONNECTOR]: Remote Authentication enabled");
89 {
90 m_log.Error("[USER CONNECTOR]: Can't load user service");
91 return;
92 }
93 m_Enabled = true;
94 m_log.Info("[USER CONNECTOR]: Local user connector enabled");
95 } 78 }
96 } 79 }
97 } 80 }
@@ -113,7 +96,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User
113 if (!m_Enabled) 96 if (!m_Enabled)
114 return; 97 return;
115 98
116 scene.RegisterModuleInterface<IUserAccountService>(m_UserService); 99 scene.RegisterModuleInterface<IAuthenticationService>(this);
117 } 100 }
118 101
119 public void RemoveRegion(Scene scene) 102 public void RemoveRegion(Scene scene)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
index 68499f3..01a2615 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
@@ -139,9 +139,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
139 139
140 if (scene != null) 140 if (scene != null)
141 { 141 {
142 UserProfileData profile = scene.CommsManager.UserService.GetUserProfile(new UUID(userID)); 142 UserAccount account = scene.UserAccountService.GetUserAccount(UUID.Zero, userID);
143 isAuthorized = IsAuthorizedForRegion(userID, profile.FirstName, profile.SurName, 143 isAuthorized = IsAuthorizedForRegion(userID, account.FirstName, account.LastName,
144 profile.Email, scene.RegionInfo.RegionName, regionID, out message); 144 account.Email, scene.RegionInfo.RegionName, regionID, out message);
145 } 145 }
146 else 146 else
147 { 147 {
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs
new file mode 100644
index 0000000..47f19a3
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs
@@ -0,0 +1,168 @@
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 log4net;
32using Nini.Config;
33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Server.Base;
36using OpenSim.Services.Interfaces;
37
38using OpenMetaverse;
39
40namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar
41{
42 public class LocalAvatarServicesConnector : ISharedRegionModule, IAvatarService
43 {
44 private static readonly ILog m_log =
45 LogManager.GetLogger(
46 MethodBase.GetCurrentMethod().DeclaringType);
47
48 private IAvatarService m_AvatarService;
49
50 private bool m_Enabled = false;
51
52 #region ISharedRegionModule
53
54 public Type ReplaceableInterface
55 {
56 get { return null; }
57 }
58
59 public string Name
60 {
61 get { return "LocalAvatarServicesConnector"; }
62 }
63
64 public void Initialise(IConfigSource source)
65 {
66 IConfig moduleConfig = source.Configs["Modules"];
67 if (moduleConfig != null)
68 {
69 string name = moduleConfig.GetString("AvatarServices", "");
70 if (name == Name)
71 {
72 IConfig userConfig = source.Configs["AvatarService"];
73 if (userConfig == null)
74 {
75 m_log.Error("[AVATAR CONNECTOR]: AvatarService missing from OpenSim.ini");
76 return;
77 }
78
79 string serviceDll = userConfig.GetString("LocalServiceModule",
80 String.Empty);
81
82 if (serviceDll == String.Empty)
83 {
84 m_log.Error("[AVATAR CONNECTOR]: No LocalServiceModule named in section AvatarService");
85 return;
86 }
87
88 Object[] args = new Object[] { source };
89 m_AvatarService =
90 ServerUtils.LoadPlugin<IAvatarService>(serviceDll,
91 args);
92
93 if (m_AvatarService == null)
94 {
95 m_log.Error("[AVATAR CONNECTOR]: Can't load user account service");
96 return;
97 }
98 m_Enabled = true;
99 m_log.Info("[AVATAR CONNECTOR]: Local avatar connector enabled");
100 }
101 }
102 }
103
104 public void PostInitialise()
105 {
106 if (!m_Enabled)
107 return;
108 }
109
110 public void Close()
111 {
112 if (!m_Enabled)
113 return;
114 }
115
116 public void AddRegion(Scene scene)
117 {
118 if (!m_Enabled)
119 return;
120
121 scene.RegisterModuleInterface<IAvatarService>(this);
122 }
123
124 public void RemoveRegion(Scene scene)
125 {
126 if (!m_Enabled)
127 return;
128 }
129
130 public void RegionLoaded(Scene scene)
131 {
132 if (!m_Enabled)
133 return;
134 }
135
136 #endregion
137
138 #region IAvatarService
139
140 public AvatarData GetAvatar(UUID userID)
141 {
142 return m_AvatarService.GetAvatar(userID);
143 }
144
145 public bool SetAvatar(UUID userID, AvatarData avatar)
146 {
147 return m_AvatarService.SetAvatar(userID, avatar);
148 }
149
150 public bool ResetAvatar(UUID userID)
151 {
152 return m_AvatarService.ResetAvatar(userID);
153 }
154
155 public bool SetItems(UUID userID, string[] names, string[] values)
156 {
157 return m_AvatarService.SetItems(userID, names, values);
158 }
159
160 public bool RemoveItems(UUID userID, string[] names)
161 {
162 return m_AvatarService.RemoveItems(userID, names);
163 }
164
165 #endregion
166
167 }
168}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs
index cef9129..48759b5 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs
@@ -34,10 +34,10 @@ using OpenSim.Region.Framework.Scenes;
34using OpenSim.Services.Interfaces; 34using OpenSim.Services.Interfaces;
35using OpenSim.Services.Connectors; 35using OpenSim.Services.Connectors;
36 36
37namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User 37namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar
38{ 38{
39 public class RemoteUserServicesConnector : UserServicesConnector, 39 public class RemoteAvatarServicesConnector : AvatarServicesConnector,
40 ISharedRegionModule, IUserAccountService 40 ISharedRegionModule, IAvatarService
41 { 41 {
42 private static readonly ILog m_log = 42 private static readonly ILog m_log =
43 LogManager.GetLogger( 43 LogManager.GetLogger(
@@ -52,7 +52,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User
52 52
53 public string Name 53 public string Name
54 { 54 {
55 get { return "RemoteUserServicesConnector"; } 55 get { return "RemoteAvatarServicesConnector"; }
56 } 56 }
57 57
58 public override void Initialise(IConfigSource source) 58 public override void Initialise(IConfigSource source)
@@ -60,13 +60,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User
60 IConfig moduleConfig = source.Configs["Modules"]; 60 IConfig moduleConfig = source.Configs["Modules"];
61 if (moduleConfig != null) 61 if (moduleConfig != null)
62 { 62 {
63 string name = moduleConfig.GetString("UserServices", ""); 63 string name = moduleConfig.GetString("AvatarServices", "");
64 if (name == Name) 64 if (name == Name)
65 { 65 {
66 IConfig userConfig = source.Configs["UserService"]; 66 IConfig userConfig = source.Configs["AvatarService"];
67 if (userConfig == null) 67 if (userConfig == null)
68 { 68 {
69 m_log.Error("[USER CONNECTOR]: UserService missing from OpanSim.ini"); 69 m_log.Error("[AVATAR CONNECTOR]: AvatarService missing from OpanSim.ini");
70 return; 70 return;
71 } 71 }
72 72
@@ -74,7 +74,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User
74 74
75 base.Initialise(source); 75 base.Initialise(source);
76 76
77 m_log.Info("[USER CONNECTOR]: Remote users enabled"); 77 m_log.Info("[AVATAR CONNECTOR]: Remote avatars enabled");
78 } 78 }
79 } 79 }
80 } 80 }
@@ -96,7 +96,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User
96 if (!m_Enabled) 96 if (!m_Enabled)
97 return; 97 return;
98 98
99 scene.RegisterModuleInterface<IUserAccountService>(this); 99 scene.RegisterModuleInterface<IAvatarService>(this);
100 } 100 }
101 101
102 public void RemoveRegion(Scene scene) 102 public void RemoveRegion(Scene scene)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs
deleted file mode 100644
index 0974372..0000000
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs
+++ /dev/null
@@ -1,303 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Xml;
32using log4net;
33using Nini.Config;
34using OpenSim.Framework;
35//using OpenSim.Framework.Communications;
36using OpenSim.Framework.Console;
37using OpenSim.Region.Framework;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.Framework.Scenes.Hypergrid;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41
42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
43{
44 public class HGCommands
45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 private HGGridConnector m_HGGridConnector;
48 private Scene m_scene;
49
50 private static uint m_autoMappingX = 0;
51 private static uint m_autoMappingY = 0;
52 private static bool m_enableAutoMapping = false;
53
54 public HGCommands(HGGridConnector hgConnector, Scene scene)
55 {
56 m_HGGridConnector = hgConnector;
57 m_scene = scene;
58 }
59
60 //public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager,
61 // StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version)
62 //{
63 // HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager, HGServices);
64
65 // return
66 // new HGScene(
67 // regionInfo, circuitManager, m_commsManager, sceneGridService, storageManager,
68 // m_moduleLoader, false, m_configSettings.PhysicalPrim,
69 // m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version);
70 //}
71
72 public void RunCommand(string module, string[] cmdparams)
73 {
74 List<string> args = new List<string>(cmdparams);
75 if (args.Count < 1)
76 return;
77
78 string command = args[0];
79 args.RemoveAt(0);
80
81 cmdparams = args.ToArray();
82
83 RunHGCommand(command, cmdparams);
84
85 }
86
87 private void RunHGCommand(string command, string[] cmdparams)
88 {
89 if (command.Equals("link-mapping"))
90 {
91 if (cmdparams.Length == 2)
92 {
93 try
94 {
95 m_autoMappingX = Convert.ToUInt32(cmdparams[0]);
96 m_autoMappingY = Convert.ToUInt32(cmdparams[1]);
97 m_enableAutoMapping = true;
98 }
99 catch (Exception)
100 {
101 m_autoMappingX = 0;
102 m_autoMappingY = 0;
103 m_enableAutoMapping = false;
104 }
105 }
106 }
107 else if (command.Equals("link-region"))
108 {
109 if (cmdparams.Length < 3)
110 {
111 if ((cmdparams.Length == 1) || (cmdparams.Length == 2))
112 {
113 LoadXmlLinkFile(cmdparams);
114 }
115 else
116 {
117 LinkRegionCmdUsage();
118 }
119 return;
120 }
121
122 if (cmdparams[2].Contains(":"))
123 {
124 // New format
125 int xloc, yloc;
126 string mapName;
127 try
128 {
129 xloc = Convert.ToInt32(cmdparams[0]);
130 yloc = Convert.ToInt32(cmdparams[1]);
131 mapName = cmdparams[2];
132 if (cmdparams.Length > 3)
133 for (int i = 3; i < cmdparams.Length; i++)
134 mapName += " " + cmdparams[i];
135
136 m_log.Info(">> MapName: " + mapName);
137 //internalPort = Convert.ToUInt32(cmdparams[4]);
138 //remotingPort = Convert.ToUInt32(cmdparams[5]);
139 }
140 catch (Exception e)
141 {
142 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
143 LinkRegionCmdUsage();
144 return;
145 }
146
147 // Convert cell coordinates given by the user to meters
148 xloc = xloc * (int)Constants.RegionSize;
149 yloc = yloc * (int)Constants.RegionSize;
150 m_HGGridConnector.TryLinkRegionToCoords(m_scene, null, mapName, xloc, yloc);
151 }
152 else
153 {
154 // old format
155 GridRegion regInfo;
156 int xloc, yloc;
157 uint externalPort;
158 string externalHostName;
159 try
160 {
161 xloc = Convert.ToInt32(cmdparams[0]);
162 yloc = Convert.ToInt32(cmdparams[1]);
163 externalPort = Convert.ToUInt32(cmdparams[3]);
164 externalHostName = cmdparams[2];
165 //internalPort = Convert.ToUInt32(cmdparams[4]);
166 //remotingPort = Convert.ToUInt32(cmdparams[5]);
167 }
168 catch (Exception e)
169 {
170 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
171 LinkRegionCmdUsage();
172 return;
173 }
174
175 // Convert cell coordinates given by the user to meters
176 xloc = xloc * (int)Constants.RegionSize;
177 yloc = yloc * (int)Constants.RegionSize;
178 if (m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo))
179 {
180 if (cmdparams.Length >= 5)
181 {
182 regInfo.RegionName = "";
183 for (int i = 4; i < cmdparams.Length; i++)
184 regInfo.RegionName += cmdparams[i] + " ";
185 }
186 }
187 }
188 return;
189 }
190 else if (command.Equals("unlink-region"))
191 {
192 if (cmdparams.Length < 1)
193 {
194 UnlinkRegionCmdUsage();
195 return;
196 }
197 if (m_HGGridConnector.TryUnlinkRegion(m_scene, cmdparams[0]))
198 m_log.InfoFormat("[HGrid]: Successfully unlinked {0}", cmdparams[0]);
199 else
200 m_log.InfoFormat("[HGrid]: Unable to unlink {0}, region not found", cmdparams[0]);
201 }
202 }
203
204 private void LoadXmlLinkFile(string[] cmdparams)
205 {
206 //use http://www.hgurl.com/hypergrid.xml for test
207 try
208 {
209 XmlReader r = XmlReader.Create(cmdparams[0]);
210 XmlConfigSource cs = new XmlConfigSource(r);
211 string[] excludeSections = null;
212
213 if (cmdparams.Length == 2)
214 {
215 if (cmdparams[1].ToLower().StartsWith("excludelist:"))
216 {
217 string excludeString = cmdparams[1].ToLower();
218 excludeString = excludeString.Remove(0, 12);
219 char[] splitter = { ';' };
220
221 excludeSections = excludeString.Split(splitter);
222 }
223 }
224
225 for (int i = 0; i < cs.Configs.Count; i++)
226 {
227 bool skip = false;
228 if ((excludeSections != null) && (excludeSections.Length > 0))
229 {
230 for (int n = 0; n < excludeSections.Length; n++)
231 {
232 if (excludeSections[n] == cs.Configs[i].Name.ToLower())
233 {
234 skip = true;
235 break;
236 }
237 }
238 }
239 if (!skip)
240 {
241 ReadLinkFromConfig(cs.Configs[i]);
242 }
243 }
244 }
245 catch (Exception e)
246 {
247 m_log.Error(e.ToString());
248 }
249 }
250
251
252 private void ReadLinkFromConfig(IConfig config)
253 {
254 GridRegion regInfo;
255 int xloc, yloc;
256 uint externalPort;
257 string externalHostName;
258 uint realXLoc, realYLoc;
259
260 xloc = Convert.ToInt32(config.GetString("xloc", "0"));
261 yloc = Convert.ToInt32(config.GetString("yloc", "0"));
262 externalPort = Convert.ToUInt32(config.GetString("externalPort", "0"));
263 externalHostName = config.GetString("externalHostName", "");
264 realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0"));
265 realYLoc = Convert.ToUInt32(config.GetString("real-yloc", "0"));
266
267 if (m_enableAutoMapping)
268 {
269 xloc = (int)((xloc % 100) + m_autoMappingX);
270 yloc = (int)((yloc % 100) + m_autoMappingY);
271 }
272
273 if (((realXLoc == 0) && (realYLoc == 0)) ||
274 (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) &&
275 ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896))))
276 {
277 xloc = xloc * (int)Constants.RegionSize;
278 yloc = yloc * (int)Constants.RegionSize;
279 if (
280 m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort,
281 externalHostName, out regInfo))
282 {
283 regInfo.RegionName = config.GetString("localName", "");
284 }
285 }
286 }
287
288
289 private void LinkRegionCmdUsage()
290 {
291 m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]");
292 m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]");
293 m_log.Info("Usage: link-region <URI_of_xml> [<exclude>]");
294 }
295
296 private void UnlinkRegionCmdUsage()
297 {
298 m_log.Info("Usage: unlink-region <HostName>:<HttpPort>");
299 m_log.Info("Usage: unlink-region <LocalName>");
300 }
301
302 }
303}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
deleted file mode 100644
index 131febd..0000000
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
+++ /dev/null
@@ -1,811 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Reflection;
32using System.Xml;
33
34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Region.Framework.Scenes.Hypergrid;
39using OpenSim.Services.Interfaces;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41using OpenSim.Server.Base;
42using OpenSim.Services.Connectors.Grid;
43using OpenSim.Framework.Console;
44
45using OpenMetaverse;
46using log4net;
47using Nini.Config;
48
49namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
50{
51 public class HGGridConnector : ISharedRegionModule, IGridService, IHyperlinkService
52 {
53 private static readonly ILog m_log =
54 LogManager.GetLogger(
55 MethodBase.GetCurrentMethod().DeclaringType);
56 private static string LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI;
57
58 private bool m_Enabled = false;
59 private bool m_Initialized = false;
60
61 private Scene m_aScene;
62 private Dictionary<ulong, Scene> m_LocalScenes = new Dictionary<ulong, Scene>();
63
64 private IGridService m_GridServiceConnector;
65 private HypergridServiceConnector m_HypergridServiceConnector;
66
67 // Hyperlink regions are hyperlinks on the map
68 protected Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>();
69
70 // Known regions are home regions of visiting foreign users.
71 // They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when
72 // the visitor goes away. They are mapped to X=0 on the map.
73 // This is key-ed on agent ID
74 protected Dictionary<UUID, GridRegion> m_knownRegions = new Dictionary<UUID, GridRegion>();
75
76 protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>();
77
78 #region ISharedRegionModule
79
80 public Type ReplaceableInterface
81 {
82 get { return null; }
83 }
84
85 public string Name
86 {
87 get { return "HGGridServicesConnector"; }
88 }
89
90 public void Initialise(IConfigSource source)
91 {
92 IConfig moduleConfig = source.Configs["Modules"];
93 if (moduleConfig != null)
94 {
95 string name = moduleConfig.GetString("GridServices", "");
96 if (name == Name)
97 {
98 IConfig gridConfig = source.Configs["GridService"];
99 if (gridConfig == null)
100 {
101 m_log.Error("[HGGRID CONNECTOR]: GridService missing from OpenSim.ini");
102 return;
103 }
104
105
106 InitialiseConnectorModule(source);
107
108 m_Enabled = true;
109 m_log.Info("[HGGRID CONNECTOR]: HG grid enabled");
110 }
111 }
112 }
113
114 private void InitialiseConnectorModule(IConfigSource source)
115 {
116 IConfig gridConfig = source.Configs["GridService"];
117 if (gridConfig == null)
118 {
119 m_log.Error("[HGGRID CONNECTOR]: GridService missing from OpenSim.ini");
120 throw new Exception("Grid connector init error");
121 }
122
123 string module = gridConfig.GetString("GridServiceConnectorModule", String.Empty);
124 if (module == String.Empty)
125 {
126 m_log.Error("[HGGRID CONNECTOR]: No GridServiceConnectorModule named in section GridService");
127 //return;
128 throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's");
129 }
130
131 Object[] args = new Object[] { source };
132 m_GridServiceConnector = ServerUtils.LoadPlugin<IGridService>(module, args);
133
134 }
135
136 public void PostInitialise()
137 {
138 if (m_Enabled)
139 ((ISharedRegionModule)m_GridServiceConnector).PostInitialise();
140 }
141
142 public void Close()
143 {
144 }
145
146 public void AddRegion(Scene scene)
147 {
148 if (!m_Enabled)
149 return;
150
151 m_LocalScenes[scene.RegionInfo.RegionHandle] = scene;
152 scene.RegisterModuleInterface<IGridService>(this);
153 scene.RegisterModuleInterface<IHyperlinkService>(this);
154
155 ((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene);
156
157 // Yikes!! Remove this as soon as user services get refactored
158 LocalAssetServerURI = scene.CommsManager.NetworkServersInfo.AssetURL;
159 LocalInventoryServerURI = scene.CommsManager.NetworkServersInfo.InventoryURL;
160 LocalUserServerURI = scene.CommsManager.NetworkServersInfo.UserURL;
161 HGNetworkServersInfo.Init(LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI);
162
163 }
164
165 public void RemoveRegion(Scene scene)
166 {
167 if (m_Enabled)
168 {
169 m_LocalScenes.Remove(scene.RegionInfo.RegionHandle);
170 ((ISharedRegionModule)m_GridServiceConnector).RemoveRegion(scene);
171 }
172 }
173
174 public void RegionLoaded(Scene scene)
175 {
176 if (!m_Enabled)
177 return;
178
179 if (!m_Initialized)
180 {
181 m_aScene = scene;
182
183 m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService);
184
185 HGCommands hgCommands = new HGCommands(this, scene);
186 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-region",
187 "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
188 "Link a hypergrid region", hgCommands.RunCommand);
189 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlink-region",
190 "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
191 "Unlink a hypergrid region", hgCommands.RunCommand);
192 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
193 "Set local coordinate to map HG regions to", hgCommands.RunCommand);
194
195 m_Initialized = true;
196 }
197 }
198
199 #endregion
200
201 #region IGridService
202
203 public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
204 {
205 // Region doesn't exist here. Trying to link remote region
206 if (regionInfo.RegionID.Equals(UUID.Zero))
207 {
208 m_log.Info("[HGrid]: Linking remote region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort);
209 ulong regionHandle = 0;
210 regionInfo.RegionID = m_HypergridServiceConnector.LinkRegion(regionInfo, out regionHandle);
211 if (!regionInfo.RegionID.Equals(UUID.Zero))
212 {
213 AddHyperlinkRegion(regionInfo, regionHandle);
214 m_log.Info("[HGrid]: Successfully linked to region_uuid " + regionInfo.RegionID);
215
216 // Try get the map image
217 m_HypergridServiceConnector.GetMapImage(regionInfo);
218 return String.Empty;
219 }
220 else
221 {
222 m_log.Info("[HGrid]: No such region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "(" + regionInfo.InternalEndPoint.Port + ")");
223 return "No such region";
224 }
225 // Note that these remote regions aren't registered in localBackend, so return null, no local listeners
226 }
227 else // normal grid
228 return m_GridServiceConnector.RegisterRegion(scopeID, regionInfo);
229 }
230
231 public bool DeregisterRegion(UUID regionID)
232 {
233 // Try the hyperlink collection
234 if (m_HyperlinkRegions.ContainsKey(regionID))
235 {
236 RemoveHyperlinkRegion(regionID);
237 return true;
238 }
239 // Try the foreign users home collection
240
241 foreach (GridRegion r in m_knownRegions.Values)
242 if (r.RegionID == regionID)
243 {
244 RemoveHyperlinkHomeRegion(regionID);
245 return true;
246 }
247
248 // Finally, try the normal route
249 return m_GridServiceConnector.DeregisterRegion(regionID);
250 }
251
252 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
253 {
254 // No serving neighbours on hyperliked regions.
255 // Just the regular regions.
256 return m_GridServiceConnector.GetNeighbours(scopeID, regionID);
257 }
258
259 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
260 {
261 // Try the hyperlink collection
262 if (m_HyperlinkRegions.ContainsKey(regionID))
263 return m_HyperlinkRegions[regionID];
264
265 // Try the foreign users home collection
266 foreach (GridRegion r in m_knownRegions.Values)
267 if (r.RegionID == regionID)
268 return r;
269
270 // Finally, try the normal route
271 return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID);
272 }
273
274 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
275 {
276 int snapX = (int) (x / Constants.RegionSize) * (int)Constants.RegionSize;
277 int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize;
278 // Try the hyperlink collection
279 foreach (GridRegion r in m_HyperlinkRegions.Values)
280 {
281 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
282 return r;
283 }
284
285 // Try the foreign users home collection
286 foreach (GridRegion r in m_knownRegions.Values)
287 {
288 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
289 {
290 return r;
291 }
292 }
293
294 // Finally, try the normal route
295 return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y);
296 }
297
298 public GridRegion GetRegionByName(UUID scopeID, string regionName)
299 {
300 // Try normal grid first
301 GridRegion region = m_GridServiceConnector.GetRegionByName(scopeID, regionName);
302 if (region != null)
303 return region;
304
305 // Try the hyperlink collection
306 foreach (GridRegion r in m_HyperlinkRegions.Values)
307 {
308 if (r.RegionName == regionName)
309 return r;
310 }
311
312 // Try the foreign users home collection
313 foreach (GridRegion r in m_knownRegions.Values)
314 {
315 if (r.RegionName == regionName)
316 return r;
317 }
318 return null;
319 }
320
321 public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
322 {
323 List<GridRegion> rinfos = new List<GridRegion>();
324
325 if (name == string.Empty)
326 return rinfos;
327
328 foreach (GridRegion r in m_HyperlinkRegions.Values)
329 if ((r.RegionName != null) && r.RegionName.ToLower().StartsWith(name.ToLower()))
330 rinfos.Add(r);
331
332 rinfos.AddRange(m_GridServiceConnector.GetRegionsByName(scopeID, name, maxNumber));
333 return rinfos;
334 }
335
336 public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
337 {
338 int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize;
339// int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize;
340 int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize;
341 int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize;
342
343 List<GridRegion> rinfos = new List<GridRegion>();
344 foreach (GridRegion r in m_HyperlinkRegions.Values)
345 if ((r.RegionLocX > snapXmin) && (r.RegionLocX < snapYmax) &&
346 (r.RegionLocY > snapYmin) && (r.RegionLocY < snapYmax))
347 rinfos.Add(r);
348
349 rinfos.AddRange(m_GridServiceConnector.GetRegionRange(scopeID, xmin, xmax, ymin, ymax));
350
351 return rinfos;
352 }
353
354 #endregion
355
356 #region Auxiliary
357
358 private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle)
359 {
360 m_HyperlinkRegions[regionInfo.RegionID] = regionInfo;
361 m_HyperlinkHandles[regionInfo.RegionID] = regionHandle;
362 }
363
364 private void RemoveHyperlinkRegion(UUID regionID)
365 {
366 m_HyperlinkRegions.Remove(regionID);
367 m_HyperlinkHandles.Remove(regionID);
368 }
369
370 private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle)
371 {
372 m_knownRegions[userID] = regionInfo;
373 m_HyperlinkHandles[regionInfo.RegionID] = regionHandle;
374 }
375
376 private void RemoveHyperlinkHomeRegion(UUID regionID)
377 {
378 foreach (KeyValuePair<UUID, GridRegion> kvp in m_knownRegions)
379 {
380 if (kvp.Value.RegionID == regionID)
381 {
382 m_knownRegions.Remove(kvp.Key);
383 }
384 }
385 m_HyperlinkHandles.Remove(regionID);
386 }
387 #endregion
388
389 #region IHyperlinkService
390
391 private static Random random = new Random();
392
393
394 public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc)
395 {
396 string host = "127.0.0.1";
397 string portstr;
398 string regionName = "";
399 uint port = 9000;
400 string[] parts = mapName.Split(new char[] { ':' });
401 if (parts.Length >= 1)
402 {
403 host = parts[0];
404 }
405 if (parts.Length >= 2)
406 {
407 portstr = parts[1];
408 //m_log.Debug("-- port = " + portstr);
409 if (!UInt32.TryParse(portstr, out port))
410 regionName = parts[1];
411 }
412 // always take the last one
413 if (parts.Length >= 3)
414 {
415 regionName = parts[2];
416 }
417
418 // Sanity check. Don't ever link to this sim.
419 IPAddress ipaddr = null;
420 try
421 {
422 ipaddr = Util.GetHostFromDNS(host);
423 }
424 catch { }
425
426 if ((ipaddr != null) &&
427 !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port)))
428 {
429 GridRegion regInfo;
430 bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo);
431 if (success)
432 {
433 regInfo.RegionName = mapName;
434 return regInfo;
435 }
436 }
437
438 return null;
439 }
440
441
442 // From the map search and secondlife://blah
443 public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
444 {
445 int xloc = random.Next(0, Int16.MaxValue) * (int) Constants.RegionSize;
446 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
447 }
448
449 public bool TryCreateLink(Scene m_scene, IClientAPI client, int xloc, int yloc,
450 string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo)
451 {
452 m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc);
453
454 regInfo = new GridRegion();
455 regInfo.RegionName = externalRegionName;
456 regInfo.HttpPort = externalPort;
457 regInfo.ExternalHostName = externalHostName;
458 regInfo.RegionLocX = xloc;
459 regInfo.RegionLocY = yloc;
460
461 try
462 {
463 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
464 }
465 catch (Exception e)
466 {
467 m_log.Warn("[HGrid]: Wrong format for link-region: " + e.Message);
468 return false;
469 }
470
471 // Finally, link it
472 if (RegisterRegion(UUID.Zero, regInfo) != String.Empty)
473 {
474 m_log.Warn("[HGrid]: Unable to link region");
475 return false;
476 }
477
478 int x, y;
479 if (!Check4096(m_scene, regInfo, out x, out y))
480 {
481 DeregisterRegion(regInfo.RegionID);
482 if (client != null)
483 client.SendAlertMessage("Region is too far (" + x + ", " + y + ")");
484 m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")");
485 return false;
486 }
487
488 if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y))
489 {
490 DeregisterRegion(regInfo.RegionID);
491 if (client != null)
492 client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")");
493 m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")");
494 return false;
495 }
496
497 m_log.Debug("[HGrid]: link region succeeded");
498 return true;
499 }
500
501 public bool TryUnlinkRegion(Scene m_scene, string mapName)
502 {
503 GridRegion regInfo = null;
504 if (mapName.Contains(":"))
505 {
506 string host = "127.0.0.1";
507 //string portstr;
508 //string regionName = "";
509 uint port = 9000;
510 string[] parts = mapName.Split(new char[] { ':' });
511 if (parts.Length >= 1)
512 {
513 host = parts[0];
514 }
515 // if (parts.Length >= 2)
516 // {
517 // portstr = parts[1];
518 // if (!UInt32.TryParse(portstr, out port))
519 // regionName = parts[1];
520 // }
521 // always take the last one
522 // if (parts.Length >= 3)
523 // {
524 // regionName = parts[2];
525 // }
526 foreach (GridRegion r in m_HyperlinkRegions.Values)
527 if (host.Equals(r.ExternalHostName) && (port == r.HttpPort))
528 regInfo = r;
529 }
530 else
531 {
532 foreach (GridRegion r in m_HyperlinkRegions.Values)
533 if (r.RegionName.Equals(mapName))
534 regInfo = r;
535 }
536 if (regInfo != null)
537 {
538 return DeregisterRegion(regInfo.RegionID);
539 }
540 else
541 {
542 m_log.InfoFormat("[HGrid]: Region {0} not found", mapName);
543 return false;
544 }
545 }
546
547 /// <summary>
548 /// Cope with this viewer limitation.
549 /// </summary>
550 /// <param name="regInfo"></param>
551 /// <returns></returns>
552 public bool Check4096(Scene m_scene, GridRegion regInfo, out int x, out int y)
553 {
554 ulong realHandle = m_HyperlinkHandles[regInfo.RegionID];
555 uint ux = 0, uy = 0;
556 Utils.LongToUInts(realHandle, out ux, out uy);
557 x = (int)(ux / Constants.RegionSize);
558 y = (int)(uy / Constants.RegionSize);
559
560 if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - x) >= 4096) ||
561 (Math.Abs((int)m_scene.RegionInfo.RegionLocY - y) >= 4096))
562 {
563 return false;
564 }
565 return true;
566 }
567
568 public bool CheckCoords(uint thisx, uint thisy, int x, int y)
569 {
570 if ((thisx == x) && (thisy == y))
571 return false;
572 return true;
573 }
574
575 public GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor)
576 {
577 return TryLinkRegion((Scene)client.Scene, client, regionDescriptor);
578 }
579
580 public GridRegion GetHyperlinkRegion(ulong handle)
581 {
582 foreach (GridRegion r in m_HyperlinkRegions.Values)
583 if (r.RegionHandle == handle)
584 return r;
585 foreach (GridRegion r in m_knownRegions.Values)
586 if (r.RegionHandle == handle)
587 return r;
588 return null;
589 }
590
591 public ulong FindRegionHandle(ulong handle)
592 {
593 foreach (GridRegion r in m_HyperlinkRegions.Values)
594 if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID)))
595 return m_HyperlinkHandles[r.RegionID];
596
597 foreach (GridRegion r in m_knownRegions.Values)
598 if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID)))
599 return m_HyperlinkHandles[r.RegionID];
600
601 return handle;
602 }
603
604 public bool SendUserInformation(GridRegion regInfo, AgentCircuitData agentData)
605 {
606 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID);
607
608 if (uinfo == null)
609 return false;
610
611 if ((IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) ||
612 (!IsLocalUser(uinfo) && !IsGoingHome(uinfo, regInfo)))
613 {
614 m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere");
615
616 // Set the position of the region on the remote grid
617// ulong realHandle = FindRegionHandle(regInfo.RegionHandle);
618 uint x = 0, y = 0;
619 Utils.LongToUInts(regInfo.RegionHandle, out x, out y);
620 GridRegion clonedRegion = new GridRegion(regInfo);
621 clonedRegion.RegionLocX = (int)x;
622 clonedRegion.RegionLocY = (int)y;
623
624 // Get the user's home region information and adapt the region handle
625 GridRegion home = GetRegionByUUID(m_aScene.RegionInfo.ScopeID, uinfo.UserProfile.HomeRegionID);
626 if (m_HyperlinkHandles.ContainsKey(uinfo.UserProfile.HomeRegionID))
627 {
628 ulong realHandle = m_HyperlinkHandles[uinfo.UserProfile.HomeRegionID];
629 Utils.LongToUInts(realHandle, out x, out y);
630 m_log.DebugFormat("[HGrid]: Foreign user is going elsewhere. Adjusting home handle from {0}-{1} to {2}-{3}", home.RegionLocX, home.RegionLocY, x, y);
631 home.RegionLocX = (int)x;
632 home.RegionLocY = (int)y;
633 }
634
635 // Get the user's service URLs
636 string serverURI = "";
637 if (uinfo.UserProfile is ForeignUserProfileData)
638 serverURI = Util.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI);
639 string userServer = (serverURI == "") || (serverURI == null) ? LocalUserServerURI : serverURI;
640
641 string assetServer = Util.ServerURI(uinfo.UserProfile.UserAssetURI);
642 if ((assetServer == null) || (assetServer == ""))
643 assetServer = LocalAssetServerURI;
644
645 string inventoryServer = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
646 if ((inventoryServer == null) || (inventoryServer == ""))
647 inventoryServer = LocalInventoryServerURI;
648
649 if (!m_HypergridServiceConnector.InformRegionOfUser(clonedRegion, agentData, home, userServer, assetServer, inventoryServer))
650 {
651 m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
652 return false;
653 }
654 }
655 //if ((uinfo == null) || !IsGoingHome(uinfo, regInfo))
656 //{
657 // m_log.Info("[HGrid]: User seems to be going to foreign region.");
658 // if (!InformRegionOfUser(regInfo, agentData))
659 // {
660 // m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
661 // return false;
662 // }
663 //}
664 //else
665 // m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
666
667 // May need to change agent's name
668 if (IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null))
669 {
670 agentData.firstname = agentData.firstname + "." + agentData.lastname;
671 agentData.lastname = "@" + LocalUserServerURI.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI;
672 }
673
674 return true;
675 }
676
677 public void AdjustUserInformation(AgentCircuitData agentData)
678 {
679 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID);
680 if ((uinfo != null) && (uinfo.UserProfile != null) &&
681 (IsLocalUser(uinfo) || !(uinfo.UserProfile is ForeignUserProfileData)))
682 {
683 //m_log.Debug("---------------> Local User!");
684 string[] parts = agentData.firstname.Split(new char[] { '.' });
685 if (parts.Length == 2)
686 {
687 agentData.firstname = parts[0];
688 agentData.lastname = parts[1];
689 }
690 }
691 //else
692 // m_log.Debug("---------------> Foreign User!");
693 }
694
695 // Check if a local user exists with the same UUID as the incoming foreign user
696 public bool CheckUserAtEntry(UUID userID, UUID sessionID, out bool comingHome)
697 {
698 comingHome = false;
699
700 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
701 if (uinfo != null)
702 {
703 // uh-oh we have a potential intruder
704 if (uinfo.SessionID != sessionID)
705 // can't have a foreigner with a local UUID
706 return false;
707 else
708 // oh, so it's you! welcome back
709 comingHome = true;
710 }
711
712 // OK, user can come in
713 return true;
714 }
715
716 public void AcceptUser(ForeignUserProfileData user, GridRegion home)
717 {
718 m_aScene.CommsManager.UserProfileCacheService.PreloadUserCache(user);
719 ulong realHandle = home.RegionHandle;
720 // Change the local coordinates
721 // X=0 on the map
722 home.RegionLocX = 0;
723 home.RegionLocY = random.Next(0, 10000) * (int)Constants.RegionSize;
724
725 AddHyperlinkHomeRegion(user.ID, home, realHandle);
726
727 DumpUserData(user);
728 DumpRegionData(home);
729
730 }
731
732 public bool IsLocalUser(UUID userID)
733 {
734 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
735 return IsLocalUser(uinfo);
736 }
737
738 #endregion
739
740 #region IHyperlink Misc
741
742 protected bool IsComingHome(ForeignUserProfileData userData)
743 {
744 return (userData.UserServerURI == LocalUserServerURI);
745 }
746
747 // Is the user going back to the home region or the home grid?
748 protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo)
749 {
750 if (uinfo == null)
751 return false;
752
753 if (uinfo.UserProfile == null)
754 return false;
755
756 if (!(uinfo.UserProfile is ForeignUserProfileData))
757 // it's a home user, can't be outside to return home
758 return false;
759
760 // OK, it's a foreign user with a ForeignUserProfileData
761 // and is going back to exactly the home region.
762 // We can't check if it's going back to a non-home region
763 // of the home grid. That will be dealt with in the
764 // receiving end
765 return (uinfo.UserProfile.HomeRegionID == rinfo.RegionID);
766 }
767
768 protected bool IsLocalUser(CachedUserInfo uinfo)
769 {
770 if (uinfo == null)
771 return false;
772
773 return !(uinfo.UserProfile is ForeignUserProfileData);
774
775 }
776
777
778 protected bool IsLocalRegion(ulong handle)
779 {
780 return m_LocalScenes.ContainsKey(handle);
781 }
782
783 private void DumpUserData(ForeignUserProfileData userData)
784 {
785 m_log.Info(" ------------ User Data Dump ----------");
786 m_log.Info(" >> Name: " + userData.FirstName + " " + userData.SurName);
787 m_log.Info(" >> HomeID: " + userData.HomeRegionID);
788 m_log.Info(" >> UserServer: " + userData.UserServerURI);
789 m_log.Info(" >> InvServer: " + userData.UserInventoryURI);
790 m_log.Info(" >> AssetServer: " + userData.UserAssetURI);
791 m_log.Info(" ------------ -------------- ----------");
792 }
793
794 private void DumpRegionData(GridRegion rinfo)
795 {
796 m_log.Info(" ------------ Region Data Dump ----------");
797 m_log.Info(" >> handle: " + rinfo.RegionHandle);
798 m_log.Info(" >> coords: " + rinfo.RegionLocX + ", " + rinfo.RegionLocY);
799 m_log.Info(" >> external host name: " + rinfo.ExternalHostName);
800 m_log.Info(" >> http port: " + rinfo.HttpPort);
801 m_log.Info(" >> external EP address: " + rinfo.ExternalEndPoint.Address);
802 m_log.Info(" >> external EP port: " + rinfo.ExternalEndPoint.Port);
803 m_log.Info(" ------------ -------------- ----------");
804 }
805
806
807 #endregion
808
809
810 }
811}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
index 144b5a4..1b00c8a 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
@@ -238,6 +238,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
238 return m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); 238 return m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax);
239 } 239 }
240 240
241 public List<GridRegion> GetDefaultRegions(UUID scopeID)
242 {
243 return m_GridService.GetDefaultRegions(scopeID);
244 }
245
246 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
247 {
248 return m_GridService.GetFallbackRegions(scopeID, x, y);
249 }
250
251 public int GetRegionFlags(UUID scopeID, UUID regionID)
252 {
253 return m_GridService.GetRegionFlags(scopeID, regionID);
254 }
255
241 #endregion 256 #endregion
242 257
243 public void NeighboursCommand(string module, string[] cmdparams) 258 public void NeighboursCommand(string module, string[] cmdparams)
@@ -250,5 +265,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
250 m_log.InfoFormat(" {0} @ {1}={2}", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize); 265 m_log.InfoFormat(" {0} @ {1}={2}", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize);
251 } 266 }
252 } 267 }
268
253 } 269 }
254} 270}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
index 391e7c8..2c234d2 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
@@ -188,9 +188,26 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
188 return rinfo; 188 return rinfo;
189 } 189 }
190 190
191 // Let's not override GetRegionsByName -- let's get them all from the grid server 191 public override List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
192 {
193 List<GridRegion> rinfo = m_LocalGridService.GetRegionsByName(scopeID, name, maxNumber);
194 List<GridRegion> grinfo = base.GetRegionsByName(scopeID, name, maxNumber);
195
196 if (grinfo != null)
197 rinfo.AddRange(grinfo);
198 return rinfo;
199 }
200
192 // Let's not override GetRegionRange -- let's get them all from the grid server 201 // Let's not override GetRegionRange -- let's get them all from the grid server
193 202
203 public override int GetRegionFlags(UUID scopeID, UUID regionID)
204 {
205 int flags = m_LocalGridService.GetRegionFlags(scopeID, regionID);
206 if (flags == -1)
207 flags = base.GetRegionFlags(scopeID, regionID);
208
209 return flags;
210 }
194 #endregion 211 #endregion
195 } 212 }
196} 213}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
index 2ca90f8..95d8737 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
@@ -56,7 +56,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
56 config.AddConfig("GridService"); 56 config.AddConfig("GridService");
57 config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector"); 57 config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector");
58 config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); 58 config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
59 config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData"); 59 config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
60 60
61 m_LocalConnector = new LocalGridServicesConnector(config); 61 m_LocalConnector = new LocalGridServicesConnector(config);
62 } 62 }
@@ -92,7 +92,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
92 r2.HttpPort = 9002; 92 r2.HttpPort = 9002;
93 r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); 93 r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
94 s = new Scene(new RegionInfo()); 94 s = new Scene(new RegionInfo());
95 s.RegionInfo.RegionID = r1.RegionID; 95 s.RegionInfo.RegionID = r2.RegionID;
96 m_LocalConnector.AddRegion(s); 96 m_LocalConnector.AddRegion(s);
97 97
98 GridRegion r3 = new GridRegion(); 98 GridRegion r3 = new GridRegion();
@@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
104 r3.HttpPort = 9003; 104 r3.HttpPort = 9003;
105 r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); 105 r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
106 s = new Scene(new RegionInfo()); 106 s = new Scene(new RegionInfo());
107 s.RegionInfo.RegionID = r1.RegionID; 107 s.RegionInfo.RegionID = r3.RegionID;
108 m_LocalConnector.AddRegion(s); 108 m_LocalConnector.AddRegion(s);
109 109
110 m_LocalConnector.RegisterRegion(UUID.Zero, r1); 110 m_LocalConnector.RegisterRegion(UUID.Zero, r1);
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
deleted file mode 100644
index b7f3adf..0000000
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
+++ /dev/null
@@ -1,842 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.IO;
31using System.Net;
32using System.Reflection;
33using System.Text;
34using log4net;
35using Nini.Config;
36using OpenMetaverse;
37using OpenMetaverse.StructuredData;
38using OpenSim.Framework;
39using OpenSim.Framework.Communications;
40using OpenSim.Framework.Communications.Clients;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Scenes.Hypergrid;
44using OpenSim.Region.Framework.Scenes.Serialization;
45using OpenSim.Services.Interfaces;
46using GridRegion = OpenSim.Services.Interfaces.GridRegion;
47
48namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
49{
50 public class RESTInterregionComms : ISharedRegionModule, IInterregionCommsOut
51 {
52 private bool initialized = false;
53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54
55 protected bool m_enabled = false;
56 protected Scene m_aScene;
57 // RESTInterregionComms does not care about local regions; it delegates that to the Local module
58 protected LocalInterregionComms m_localBackend;
59
60 protected CommunicationsManager m_commsManager;
61
62 protected RegionToRegionClient m_regionClient;
63
64 protected IHyperlinkService m_hyperlinkService;
65
66 protected bool m_safemode;
67 protected IPAddress m_thisIP;
68
69 #region IRegionModule
70
71 public virtual void Initialise(IConfigSource config)
72 {
73 IConfig startupConfig = config.Configs["Communications"];
74
75 if ((startupConfig == null) || ((startupConfig != null)
76 && (startupConfig.GetString("InterregionComms", "RESTComms") == "RESTComms")))
77 {
78 m_log.Info("[REST COMMS]: Enabling InterregionComms RESTComms module");
79 m_enabled = true;
80 if (config.Configs["Hypergrid"] != null)
81 m_safemode = config.Configs["Hypergrid"].GetBoolean("safemode", false);
82 }
83 }
84
85 public virtual void PostInitialise()
86 {
87 }
88
89 public virtual void Close()
90 {
91 }
92
93 public void AddRegion(Scene scene)
94 {
95 }
96
97 public void RemoveRegion(Scene scene)
98 {
99 if (m_enabled)
100 {
101 m_localBackend.RemoveScene(scene);
102 scene.UnregisterModuleInterface<IInterregionCommsOut>(this);
103 }
104 }
105
106 public void RegionLoaded(Scene scene)
107 {
108 if (m_enabled)
109 {
110 if (!initialized)
111 {
112 InitOnce(scene);
113 initialized = true;
114 AddHTTPHandlers();
115 }
116 InitEach(scene);
117 }
118 }
119
120 public Type ReplaceableInterface
121 {
122 get { return null; }
123 }
124
125 public virtual string Name
126 {
127 get { return "RESTInterregionCommsModule"; }
128 }
129
130 protected virtual void InitEach(Scene scene)
131 {
132 m_localBackend.Init(scene);
133 scene.RegisterModuleInterface<IInterregionCommsOut>(this);
134 }
135
136 protected virtual void InitOnce(Scene scene)
137 {
138 m_localBackend = new LocalInterregionComms();
139 m_commsManager = scene.CommsManager;
140 m_aScene = scene;
141 m_hyperlinkService = m_aScene.RequestModuleInterface<IHyperlinkService>();
142 m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService);
143 m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName);
144 }
145
146 protected virtual void AddHTTPHandlers()
147 {
148 MainServer.Instance.AddHTTPHandler("/agent/", AgentHandler);
149 MainServer.Instance.AddHTTPHandler("/object/", ObjectHandler);
150 }
151
152 #endregion /* IRegionModule */
153
154 #region IInterregionComms
155
156 /**
157 * Agent-related communications
158 */
159
160 public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, uint teleportFlags, out string reason)
161 {
162 // Try local first
163 if (m_localBackend.SendCreateChildAgent(regionHandle, aCircuit, teleportFlags, out reason))
164 return true;
165
166 // else do the remote thing
167 if (!m_localBackend.IsLocalRegion(regionHandle))
168 {
169 uint x = 0, y = 0;
170 Utils.LongToUInts(regionHandle, out x, out y);
171 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
172 if (regInfo != null)
173 {
174 m_regionClient.SendUserInformation(regInfo, aCircuit);
175
176 return m_regionClient.DoCreateChildAgentCall(regInfo, aCircuit, "None", teleportFlags, out reason);
177 }
178 //else
179 // m_log.Warn("[REST COMMS]: Region not found " + regionHandle);
180 }
181 return false;
182 }
183
184 public bool SendChildAgentUpdate(ulong regionHandle, AgentData cAgentData)
185 {
186 // Try local first
187 if (m_localBackend.SendChildAgentUpdate(regionHandle, cAgentData))
188 return true;
189
190 // else do the remote thing
191 if (!m_localBackend.IsLocalRegion(regionHandle))
192 {
193 uint x = 0, y = 0;
194 Utils.LongToUInts(regionHandle, out x, out y);
195 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
196 if (regInfo != null)
197 {
198 return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData);
199 }
200 //else
201 // m_log.Warn("[REST COMMS]: Region not found " + regionHandle);
202 }
203 return false;
204
205 }
206
207 public bool SendChildAgentUpdate(ulong regionHandle, AgentPosition cAgentData)
208 {
209 // Try local first
210 if (m_localBackend.SendChildAgentUpdate(regionHandle, cAgentData))
211 return true;
212
213 // else do the remote thing
214 if (!m_localBackend.IsLocalRegion(regionHandle))
215 {
216 uint x = 0, y = 0;
217 Utils.LongToUInts(regionHandle, out x, out y);
218 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
219 if (regInfo != null)
220 {
221 return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData);
222 }
223 //else
224 // m_log.Warn("[REST COMMS]: Region not found " + regionHandle);
225 }
226 return false;
227
228 }
229
230 public bool SendRetrieveRootAgent(ulong regionHandle, UUID id, out IAgentData agent)
231 {
232 // Try local first
233 if (m_localBackend.SendRetrieveRootAgent(regionHandle, id, out agent))
234 return true;
235
236 // else do the remote thing
237 if (!m_localBackend.IsLocalRegion(regionHandle))
238 {
239 uint x = 0, y = 0;
240 Utils.LongToUInts(regionHandle, out x, out y);
241 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
242 if (regInfo != null)
243 {
244 return m_regionClient.DoRetrieveRootAgentCall(regInfo, id, out agent);
245 }
246 //else
247 // m_log.Warn("[REST COMMS]: Region not found " + regionHandle);
248 }
249 return false;
250
251 }
252
253 public bool SendReleaseAgent(ulong regionHandle, UUID id, string uri)
254 {
255 // Try local first
256 if (m_localBackend.SendReleaseAgent(regionHandle, id, uri))
257 return true;
258
259 // else do the remote thing
260 return m_regionClient.DoReleaseAgentCall(regionHandle, id, uri);
261 }
262
263
264 public bool SendCloseAgent(ulong regionHandle, UUID id)
265 {
266 // Try local first
267 if (m_localBackend.SendCloseAgent(regionHandle, id))
268 return true;
269
270 // else do the remote thing
271 if (!m_localBackend.IsLocalRegion(regionHandle))
272 {
273 uint x = 0, y = 0;
274 Utils.LongToUInts(regionHandle, out x, out y);
275 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
276 if (regInfo != null)
277 {
278 return m_regionClient.DoCloseAgentCall(regInfo, id);
279 }
280 //else
281 // m_log.Warn("[REST COMMS]: Region not found " + regionHandle);
282 }
283 return false;
284 }
285
286 /**
287 * Object-related communications
288 */
289
290 public bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, bool isLocalCall)
291 {
292 // Try local first
293 if (m_localBackend.SendCreateObject(regionHandle, sog, true))
294 {
295 //m_log.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded");
296 return true;
297 }
298
299 // else do the remote thing
300 if (!m_localBackend.IsLocalRegion(regionHandle))
301 {
302 uint x = 0, y = 0;
303 Utils.LongToUInts(regionHandle, out x, out y);
304 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
305 if (regInfo != null)
306 {
307 return m_regionClient.DoCreateObjectCall(
308 regInfo, sog, SceneObjectSerializer.ToXml2Format(sog), m_aScene.m_allowScriptCrossings);
309 }
310 //else
311 // m_log.Warn("[REST COMMS]: Region not found " + regionHandle);
312 }
313 return false;
314 }
315
316 public bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID)
317 {
318 // Not Implemented
319 return false;
320 }
321
322 #endregion /* IInterregionComms */
323
324 #region Incoming calls from remote instances
325
326 /**
327 * Agent-related incoming calls
328 */
329
330 public Hashtable AgentHandler(Hashtable request)
331 {
332 //m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called");
333
334/* m_log.Debug("---------------------------");
335 m_log.Debug(" >> uri=" + request["uri"]);
336 m_log.Debug(" >> content-type=" + request["content-type"]);
337 m_log.Debug(" >> http-method=" + request["http-method"]);
338 m_log.Debug("---------------------------\n"); */
339 Hashtable responsedata = new Hashtable();
340 responsedata["content_type"] = "text/html";
341 responsedata["keepalive"] = false;
342
343
344 UUID agentID;
345 string action;
346 ulong regionHandle;
347 if (!GetParams((string)request["uri"], out agentID, out regionHandle, out action))
348 {
349 m_log.InfoFormat("[REST COMMS]: Invalid parameters for agent message {0}", request["uri"]);
350 responsedata["int_response_code"] = 404;
351 responsedata["str_response_string"] = "false";
352
353 return responsedata;
354 }
355
356 // Next, let's parse the verb
357 string method = (string)request["http-method"];
358 if (method.Equals("PUT"))
359 {
360 DoAgentPut(request, responsedata);
361 return responsedata;
362 }
363 else if (method.Equals("POST"))
364 {
365 DoAgentPost(request, responsedata, agentID);
366 return responsedata;
367 }
368 else if (method.Equals("GET"))
369 {
370 DoAgentGet(request, responsedata, agentID, regionHandle);
371 return responsedata;
372 }
373 else if (method.Equals("DELETE"))
374 {
375 DoAgentDelete(request, responsedata, agentID, action, regionHandle);
376 return responsedata;
377 }
378 else
379 {
380 m_log.InfoFormat("[REST COMMS]: method {0} not supported in agent message", method);
381 responsedata["int_response_code"] = 404;
382 responsedata["str_response_string"] = "false";
383
384 return responsedata;
385 }
386
387 }
388
389 protected virtual void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id)
390 {
391 if (m_safemode)
392 {
393 // Authentication
394 string authority = string.Empty;
395 string authToken = string.Empty;
396 if (!GetAuthentication(request, out authority, out authToken))
397 {
398 m_log.InfoFormat("[REST COMMS]: Authentication failed for agent message {0}", request["uri"]);
399 responsedata["int_response_code"] = 403;
400 responsedata["str_response_string"] = "Forbidden";
401 return ;
402 }
403 if (!VerifyKey(id, authority, authToken))
404 {
405 m_log.InfoFormat("[REST COMMS]: Authentication failed for agent message {0}", request["uri"]);
406 responsedata["int_response_code"] = 403;
407 responsedata["str_response_string"] = "Forbidden";
408 return ;
409 }
410 m_log.DebugFormat("[REST COMMS]: Authentication succeeded for {0}", id);
411 }
412
413 OSDMap args = RegionClient.GetOSDMap((string)request["body"]);
414 if (args == null)
415 {
416 responsedata["int_response_code"] = 400;
417 responsedata["str_response_string"] = "false";
418 return;
419 }
420
421 // retrieve the regionhandle
422 ulong regionhandle = 0;
423 if (args["destination_handle"] != null)
424 UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
425
426 AgentCircuitData aCircuit = new AgentCircuitData();
427 try
428 {
429 aCircuit.UnpackAgentCircuitData(args);
430 }
431 catch (Exception ex)
432 {
433 m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildCreate message {0}", ex.Message);
434 return;
435 }
436
437 OSDMap resp = new OSDMap(2);
438 string reason = String.Empty;
439 uint teleportFlags = 0;
440 if (args.ContainsKey("teleport_flags"))
441 {
442 teleportFlags = args["teleport_flags"].AsUInteger();
443 }
444
445 // This is the meaning of POST agent
446 m_regionClient.AdjustUserInformation(aCircuit);
447 bool result = m_localBackend.SendCreateChildAgent(regionhandle, aCircuit, teleportFlags, out reason);
448
449 resp["reason"] = OSD.FromString(reason);
450 resp["success"] = OSD.FromBoolean(result);
451
452 // TODO: add reason if not String.Empty?
453 responsedata["int_response_code"] = 200;
454 responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp);
455 }
456
457 protected virtual void DoAgentPut(Hashtable request, Hashtable responsedata)
458 {
459 OSDMap args = RegionClient.GetOSDMap((string)request["body"]);
460 if (args == null)
461 {
462 responsedata["int_response_code"] = 400;
463 responsedata["str_response_string"] = "false";
464 return;
465 }
466
467 // retrieve the regionhandle
468 ulong regionhandle = 0;
469 if (args["destination_handle"] != null)
470 UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
471
472 string messageType;
473 if (args["message_type"] != null)
474 messageType = args["message_type"].AsString();
475 else
476 {
477 m_log.Warn("[REST COMMS]: Agent Put Message Type not found. ");
478 messageType = "AgentData";
479 }
480
481 bool result = true;
482 if ("AgentData".Equals(messageType))
483 {
484 AgentData agent = new AgentData();
485 try
486 {
487 agent.Unpack(args);
488 }
489 catch (Exception ex)
490 {
491 m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildAgentUpdate message {0}", ex.Message);
492 return;
493 }
494
495 //agent.Dump();
496 // This is one of the meanings of PUT agent
497 result = m_localBackend.SendChildAgentUpdate(regionhandle, agent);
498
499 }
500 else if ("AgentPosition".Equals(messageType))
501 {
502 AgentPosition agent = new AgentPosition();
503 try
504 {
505 agent.Unpack(args);
506 }
507 catch (Exception ex)
508 {
509 m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildAgentUpdate message {0}", ex.Message);
510 return;
511 }
512 //agent.Dump();
513 // This is one of the meanings of PUT agent
514 result = m_localBackend.SendChildAgentUpdate(regionhandle, agent);
515
516 }
517
518 responsedata["int_response_code"] = 200;
519 responsedata["str_response_string"] = result.ToString();
520 }
521
522 protected virtual void DoAgentGet(Hashtable request, Hashtable responsedata, UUID id, ulong regionHandle)
523 {
524 IAgentData agent = null;
525 bool result = m_localBackend.SendRetrieveRootAgent(regionHandle, id, out agent);
526 OSDMap map = null;
527 if (result)
528 {
529 if (agent != null) // just to make sure
530 {
531 map = agent.Pack();
532 string strBuffer = "";
533 try
534 {
535 strBuffer = OSDParser.SerializeJsonString(map);
536 }
537 catch (Exception e)
538 {
539 m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message);
540 // ignore. buffer will be empty, caller should check.
541 }
542
543 responsedata["content_type"] = "application/json";
544 responsedata["int_response_code"] = 200;
545 responsedata["str_response_string"] = strBuffer;
546 }
547 else
548 {
549 responsedata["int_response_code"] = 500;
550 responsedata["str_response_string"] = "Internal error";
551 }
552 }
553 else
554 {
555 responsedata["int_response_code"] = 404;
556 responsedata["str_response_string"] = "Not Found";
557 }
558 }
559
560 protected virtual void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, ulong regionHandle)
561 {
562 //m_log.Debug(" >>> DoDelete action:" + action + "; regionHandle:" + regionHandle);
563
564 if (action.Equals("release"))
565 m_localBackend.SendReleaseAgent(regionHandle, id, "");
566 else
567 m_localBackend.SendCloseAgent(regionHandle, id);
568
569 responsedata["int_response_code"] = 200;
570 responsedata["str_response_string"] = "OpenSim agent " + id.ToString();
571
572 m_log.Debug("[REST COMMS]: Agent Deleted.");
573 }
574
575 /**
576 * Object-related incoming calls
577 */
578
579 public Hashtable ObjectHandler(Hashtable request)
580 {
581 m_log.Debug("[CONNECTION DEBUGGING]: ObjectHandler Called");
582
583 /* m_log.Debug("---------------------------");
584 m_log.Debug(" >> uri=" + request["uri"]);
585 m_log.Debug(" >> content-type=" + request["content-type"]);
586 m_log.Debug(" >> http-method=" + request["http-method"]);
587 m_log.Debug("---------------------------\n"); */
588
589 Hashtable responsedata = new Hashtable();
590 responsedata["content_type"] = "text/html";
591
592 UUID objectID;
593 string action;
594 ulong regionHandle;
595 if (!GetParams((string)request["uri"], out objectID, out regionHandle, out action))
596 {
597 m_log.InfoFormat("[REST COMMS]: Invalid parameters for object message {0}", request["uri"]);
598 responsedata["int_response_code"] = 404;
599 responsedata["str_response_string"] = "false";
600
601 return responsedata;
602 }
603
604 // Next, let's parse the verb
605 string method = (string)request["http-method"];
606 if (method.Equals("POST"))
607 {
608 DoObjectPost(request, responsedata, regionHandle);
609 return responsedata;
610 }
611 else if (method.Equals("PUT"))
612 {
613 DoObjectPut(request, responsedata, regionHandle);
614 return responsedata;
615 }
616 //else if (method.Equals("DELETE"))
617 //{
618 // DoObjectDelete(request, responsedata, agentID, action, regionHandle);
619 // return responsedata;
620 //}
621 else
622 {
623 m_log.InfoFormat("[REST COMMS]: method {0} not supported in object message", method);
624 responsedata["int_response_code"] = 404;
625 responsedata["str_response_string"] = "false";
626
627 return responsedata;
628 }
629
630 }
631
632 protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, ulong regionhandle)
633 {
634 OSDMap args = RegionClient.GetOSDMap((string)request["body"]);
635 if (args == null)
636 {
637 responsedata["int_response_code"] = 400;
638 responsedata["str_response_string"] = "false";
639 return;
640 }
641
642 string sogXmlStr = "", extraStr = "", stateXmlStr = "";
643 if (args["sog"] != null)
644 sogXmlStr = args["sog"].AsString();
645 if (args["extra"] != null)
646 extraStr = args["extra"].AsString();
647
648 IScene s = m_localBackend.GetScene(regionhandle);
649 SceneObjectGroup sog = null;
650 try
651 {
652 sog = SceneObjectSerializer.FromXml2Format(sogXmlStr);
653 sog.ExtraFromXmlString(extraStr);
654 }
655 catch (Exception ex)
656 {
657 m_log.InfoFormat("[REST COMMS]: exception on deserializing scene object {0}", ex.Message);
658 responsedata["int_response_code"] = 400;
659 responsedata["str_response_string"] = "false";
660 return;
661 }
662
663 if ((args["state"] != null) && m_aScene.m_allowScriptCrossings)
664 {
665 stateXmlStr = args["state"].AsString();
666 if (stateXmlStr != "")
667 {
668 try
669 {
670 sog.SetState(stateXmlStr, s);
671 }
672 catch (Exception ex)
673 {
674 m_log.InfoFormat("[REST COMMS]: exception on setting state for scene object {0}", ex.Message);
675
676 }
677 }
678 }
679 // This is the meaning of POST object
680 bool result = m_localBackend.SendCreateObject(regionhandle, sog, false);
681
682 responsedata["int_response_code"] = 200;
683 responsedata["str_response_string"] = result.ToString();
684 }
685
686 protected virtual void DoObjectPut(Hashtable request, Hashtable responsedata, ulong regionhandle)
687 {
688 OSDMap args = RegionClient.GetOSDMap((string)request["body"]);
689 if (args == null)
690 {
691 responsedata["int_response_code"] = 400;
692 responsedata["str_response_string"] = "false";
693 return;
694 }
695
696 UUID userID = UUID.Zero, itemID = UUID.Zero;
697 if (args["userid"] != null)
698 userID = args["userid"].AsUUID();
699 if (args["itemid"] != null)
700 itemID = args["itemid"].AsUUID();
701
702 // This is the meaning of PUT object
703 bool result = m_localBackend.SendCreateObject(regionhandle, userID, itemID);
704
705 responsedata["int_response_code"] = 200;
706 responsedata["str_response_string"] = result.ToString();
707 }
708
709 #endregion
710
711 #region Misc
712
713
714 /// <summary>
715 /// Extract the param from an uri.
716 /// </summary>
717 /// <param name="uri">Something like this: /agent/uuid/ or /agent/uuid/handle/release</param>
718 /// <param name="uri">uuid on uuid field</param>
719 /// <param name="action">optional action</param>
720 public static bool GetParams(string uri, out UUID uuid, out ulong regionHandle, out string action)
721 {
722 uuid = UUID.Zero;
723 action = "";
724 regionHandle = 0;
725
726 uri = uri.Trim(new char[] { '/' });
727 string[] parts = uri.Split('/');
728 if (parts.Length <= 1)
729 {
730 return false;
731 }
732 else
733 {
734 if (!UUID.TryParse(parts[1], out uuid))
735 return false;
736
737 if (parts.Length >= 3)
738 UInt64.TryParse(parts[2], out regionHandle);
739 if (parts.Length >= 4)
740 action = parts[3];
741
742 return true;
743 }
744 }
745
746 public static bool GetAuthentication(Hashtable request, out string authority, out string authKey)
747 {
748 authority = string.Empty;
749 authKey = string.Empty;
750
751 Uri authUri;
752 Hashtable headers = (Hashtable)request["headers"];
753
754 // Authorization keys look like this:
755 // http://orgrid.org:8002/<uuid>
756 if (headers.ContainsKey("authorization") && (string)headers["authorization"] != "None")
757 {
758 if (Uri.TryCreate((string)headers["authorization"], UriKind.Absolute, out authUri))
759 {
760 authority = authUri.Authority;
761 authKey = authUri.PathAndQuery.Trim('/');
762 m_log.DebugFormat("[REST COMMS]: Got authority {0} and key {1}", authority, authKey);
763 return true;
764 }
765 else
766 m_log.Debug("[REST COMMS]: Wrong format for Authorization header: " + (string)headers["authorization"]);
767 }
768 else
769 m_log.Debug("[REST COMMS]: Authorization header not found");
770
771 return false;
772 }
773
774 bool VerifyKey(UUID userID, string authority, string key)
775 {
776 string[] parts = authority.Split(':');
777 IPAddress ipaddr = IPAddress.None;
778 uint port = 0;
779 if (parts.Length <= 2)
780 ipaddr = Util.GetHostFromDNS(parts[0]);
781 if (parts.Length == 2)
782 UInt32.TryParse(parts[1], out port);
783
784 // local authority (standalone), local call
785 if (m_thisIP.Equals(ipaddr) && (m_aScene.RegionInfo.HttpPort == port))
786 return ((IAuthentication)m_aScene.CommsManager.UserAdminService).VerifyKey(userID, key);
787 // remote call
788 else
789 return AuthClient.VerifyKey("http://" + authority, userID, key);
790 }
791
792
793 #endregion Misc
794
795 protected class RegionToRegionClient : RegionClient
796 {
797 Scene m_aScene = null;
798 IHyperlinkService m_hyperlinkService;
799
800 public RegionToRegionClient(Scene s, IHyperlinkService hyperService)
801 {
802 m_aScene = s;
803 m_hyperlinkService = hyperService;
804 }
805
806 public override ulong GetRegionHandle(ulong handle)
807 {
808 if (m_aScene.SceneGridService is HGSceneCommunicationService)
809 {
810 if (m_hyperlinkService != null)
811 return m_hyperlinkService.FindRegionHandle(handle);
812 }
813
814 return handle;
815 }
816
817 public override bool IsHyperlink(ulong handle)
818 {
819 if (m_aScene.SceneGridService is HGSceneCommunicationService)
820 {
821 if ((m_hyperlinkService != null) && (m_hyperlinkService.GetHyperlinkRegion(handle) != null))
822 return true;
823 }
824 return false;
825 }
826
827 public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit)
828 {
829 if (m_hyperlinkService != null)
830 m_hyperlinkService.SendUserInformation(regInfo, aCircuit);
831
832 }
833
834 public override void AdjustUserInformation(AgentCircuitData aCircuit)
835 {
836 if (m_hyperlinkService != null)
837 m_hyperlinkService.AdjustUserInformation(aCircuit);
838 }
839 }
840
841 }
842}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs
index 811569f..1e51187 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs
@@ -40,12 +40,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
40{ 40{
41 public abstract class BaseInventoryConnector : IInventoryService 41 public abstract class BaseInventoryConnector : IInventoryService
42 { 42 {
43 protected InventoryCache m_cache; 43 protected static InventoryCache m_cache;
44 private static bool m_Initialized;
44 45
45 protected virtual void Init(IConfigSource source) 46 protected virtual void Init(IConfigSource source)
46 { 47 {
47 m_cache = new InventoryCache(); 48 if (!m_Initialized)
48 m_cache.Init(source, this); 49 {
50 m_cache = new InventoryCache();
51 m_cache.Init(source, this);
52 m_Initialized = true;
53 }
49 } 54 }
50 55
51 /// <summary> 56 /// <summary>
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index 1fdf1ef..c6312e0 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -31,7 +31,7 @@ using System;
31using System.Collections.Generic; 31using System.Collections.Generic;
32using System.Reflection; 32using System.Reflection;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications.Cache; 34
35using OpenSim.Server.Base; 35using OpenSim.Server.Base;
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
@@ -41,31 +41,20 @@ using OpenMetaverse;
41 41
42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory 42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
43{ 43{
44 public class HGInventoryBroker : BaseInventoryConnector, ISharedRegionModule, IInventoryService 44 public class HGInventoryBroker : BaseInventoryConnector, INonSharedRegionModule, IInventoryService
45 { 45 {
46 private static readonly ILog m_log = 46 private static readonly ILog m_log =
47 LogManager.GetLogger( 47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType); 48 MethodBase.GetCurrentMethod().DeclaringType);
49 49
50 private bool m_Enabled = false; 50 private static bool m_Initialized = false;
51 private bool m_Initialized = false; 51 private static bool m_Enabled = false;
52 private Scene m_Scene;
53 private UserProfileCacheService m_UserProfileService; // This should change to IUserProfileService
54
55 private IInventoryService m_GridService;
56 private ISessionAuthInventoryService m_HGService;
57 52
58 private string m_LocalGridInventoryURI = string.Empty; 53 private static IInventoryService m_GridService;
54 private static ISessionAuthInventoryService m_HGService;
59 55
60 private string LocalGridInventory 56 private Scene m_Scene;
61 { 57 private IUserAccountService m_UserAccountService;
62 get
63 {
64 if (m_LocalGridInventoryURI == null || m_LocalGridInventoryURI == "")
65 m_LocalGridInventoryURI = m_Scene.CommsManager.NetworkServersInfo.InventoryURL;
66 return m_LocalGridInventoryURI;
67 }
68 }
69 58
70 public Type ReplaceableInterface 59 public Type ReplaceableInterface
71 { 60 {
@@ -79,65 +68,67 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
79 68
80 public void Initialise(IConfigSource source) 69 public void Initialise(IConfigSource source)
81 { 70 {
82 IConfig moduleConfig = source.Configs["Modules"]; 71 if (!m_Initialized)
83 if (moduleConfig != null)
84 { 72 {
85 string name = moduleConfig.GetString("InventoryServices", ""); 73 IConfig moduleConfig = source.Configs["Modules"];
86 if (name == Name) 74 if (moduleConfig != null)
87 { 75 {
88 IConfig inventoryConfig = source.Configs["InventoryService"]; 76 string name = moduleConfig.GetString("InventoryServices", "");
89 if (inventoryConfig == null) 77 if (name == Name)
90 {
91 m_log.Error("[HG INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini");
92 return;
93 }
94
95 string localDll = inventoryConfig.GetString("LocalGridInventoryService",
96 String.Empty);
97 string HGDll = inventoryConfig.GetString("HypergridInventoryService",
98 String.Empty);
99
100 if (localDll == String.Empty)
101 {
102 m_log.Error("[HG INVENTORY CONNECTOR]: No LocalGridInventoryService named in section InventoryService");
103 //return;
104 throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's");
105 }
106
107 if (HGDll == String.Empty)
108 { 78 {
109 m_log.Error("[HG INVENTORY CONNECTOR]: No HypergridInventoryService named in section InventoryService"); 79 IConfig inventoryConfig = source.Configs["InventoryService"];
110 //return; 80 if (inventoryConfig == null)
111 throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); 81 {
82 m_log.Error("[HG INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini");
83 return;
84 }
85
86 string localDll = inventoryConfig.GetString("LocalGridInventoryService",
87 String.Empty);
88 string HGDll = inventoryConfig.GetString("HypergridInventoryService",
89 String.Empty);
90
91 if (localDll == String.Empty)
92 {
93 m_log.Error("[HG INVENTORY CONNECTOR]: No LocalGridInventoryService named in section InventoryService");
94 //return;
95 throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's");
96 }
97
98 if (HGDll == String.Empty)
99 {
100 m_log.Error("[HG INVENTORY CONNECTOR]: No HypergridInventoryService named in section InventoryService");
101 //return;
102 throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's");
103 }
104
105 Object[] args = new Object[] { source };
106 m_GridService =
107 ServerUtils.LoadPlugin<IInventoryService>(localDll,
108 args);
109
110 m_HGService =
111 ServerUtils.LoadPlugin<ISessionAuthInventoryService>(HGDll,
112 args);
113
114 if (m_GridService == null)
115 {
116 m_log.Error("[HG INVENTORY CONNECTOR]: Can't load local inventory service");
117 return;
118 }
119 if (m_HGService == null)
120 {
121 m_log.Error("[HG INVENTORY CONNECTOR]: Can't load hypergrid inventory service");
122 return;
123 }
124
125 Init(source);
126
127 m_Enabled = true;
128 m_log.Info("[HG INVENTORY CONNECTOR]: HG inventory broker enabled");
112 } 129 }
113
114 Object[] args = new Object[] { source };
115 m_GridService =
116 ServerUtils.LoadPlugin<IInventoryService>(localDll,
117 args);
118
119 m_HGService =
120 ServerUtils.LoadPlugin<ISessionAuthInventoryService>(HGDll,
121 args);
122
123 if (m_GridService == null)
124 {
125 m_log.Error("[HG INVENTORY CONNECTOR]: Can't load local inventory service");
126 return;
127 }
128 if (m_HGService == null)
129 {
130 m_log.Error("[HG INVENTORY CONNECTOR]: Can't load hypergrid inventory service");
131 return;
132 }
133
134 m_LocalGridInventoryURI = inventoryConfig.GetString("InventoryServerURI", string.Empty);
135
136 Init(source);
137
138 m_Enabled = true;
139 m_log.Info("[HG INVENTORY CONNECTOR]: HG inventory broker enabled");
140 } 130 }
131 m_Initialized = true;
141 } 132 }
142 } 133 }
143 134
@@ -154,17 +145,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
154 if (!m_Enabled) 145 if (!m_Enabled)
155 return; 146 return;
156 147
157 if (!m_Initialized) 148 m_Scene = scene;
158 { 149 m_UserAccountService = m_Scene.UserAccountService;
159 m_Scene = scene;
160 // HACK for now. Ugh!
161 m_UserProfileService = m_Scene.CommsManager.UserProfileCacheService;
162 // ugh!
163 m_UserProfileService.SetInventoryService(this);
164 scene.CommsManager.UserService.SetInventoryService(this);
165
166 m_Initialized = true;
167 }
168 150
169 scene.RegisterModuleInterface<IInventoryService>(this); 151 scene.RegisterModuleInterface<IInventoryService>(this);
170 m_cache.AddRegion(scene); 152 m_cache.AddRegion(scene);
@@ -201,22 +183,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
201 183
202 public override InventoryCollection GetUserInventory(UUID userID) 184 public override InventoryCollection GetUserInventory(UUID userID)
203 { 185 {
204 if (IsLocalGridUser(userID)) 186 return null;
205 return m_GridService.GetUserInventory(userID);
206 else
207 return null;
208 } 187 }
209 188
210 public override void GetUserInventory(UUID userID, InventoryReceiptCallback callback) 189 public override void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
211 { 190 {
212 if (IsLocalGridUser(userID))
213 m_GridService.GetUserInventory(userID, callback);
214 else
215 {
216 UUID sessionID = GetSessionID(userID);
217 string uri = GetUserInventoryURI(userID) + "/" + userID.ToString();
218 m_HGService.GetUserInventory(uri, sessionID, callback);
219 }
220 } 191 }
221 192
222 // Inherited. See base 193 // Inherited. See base
@@ -236,19 +207,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
236 207
237 public override InventoryCollection GetFolderContent(UUID userID, UUID folderID) 208 public override InventoryCollection GetFolderContent(UUID userID, UUID folderID)
238 { 209 {
239 if (IsLocalGridUser(userID)) 210 string uri = string.Empty;
211 if (!IsForeignUser(userID, out uri))
240 return m_GridService.GetFolderContent(userID, folderID); 212 return m_GridService.GetFolderContent(userID, folderID);
241 else 213 else
242 { 214 {
243 UUID sessionID = GetSessionID(userID); 215 UUID sessionID = GetSessionID(userID);
244 string uri = GetUserInventoryURI(userID) + "/" + userID.ToString(); 216 uri = uri + "/" + userID.ToString();
245 return m_HGService.GetFolderContent(uri, folderID, sessionID); 217 return m_HGService.GetFolderContent(uri, folderID, sessionID);
246 } 218 }
247 } 219 }
248 220
249 public override Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID) 221 public override Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
250 { 222 {
251 if (IsLocalGridUser(userID)) 223 string uri = string.Empty;
224 if (!IsForeignUser(userID, out uri))
252 { 225 {
253 // This is not pretty, but it will have to do for now 226 // This is not pretty, but it will have to do for now
254 if (m_GridService is BaseInventoryConnector) 227 if (m_GridService is BaseInventoryConnector)
@@ -265,7 +238,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
265 else 238 else
266 { 239 {
267 UUID sessionID = GetSessionID(userID); 240 UUID sessionID = GetSessionID(userID);
268 string uri = GetUserInventoryURI(userID) + "/" + userID.ToString(); 241 uri = uri + "/" + userID.ToString();
269 return m_HGService.GetSystemFolders(uri, sessionID); 242 return m_HGService.GetSystemFolders(uri, sessionID);
270 } 243 }
271 } 244 }
@@ -301,12 +274,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
301 274
302 public override List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) 275 public override List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
303 { 276 {
304 if (IsLocalGridUser(userID)) 277 string uri = string.Empty;
278 if (!IsForeignUser(userID, out uri))
305 return m_GridService.GetFolderItems(userID, folderID); 279 return m_GridService.GetFolderItems(userID, folderID);
306 else 280 else
307 { 281 {
308 UUID sessionID = GetSessionID(userID); 282 UUID sessionID = GetSessionID(userID);
309 string uri = GetUserInventoryURI(userID) + "/" + userID; 283 uri = uri + "/" + userID.ToString();
310 return m_HGService.GetFolderItems(uri, folderID, sessionID); 284 return m_HGService.GetFolderItems(uri, folderID, sessionID);
311 } 285 }
312 } 286 }
@@ -316,12 +290,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
316 if (folder == null) 290 if (folder == null)
317 return false; 291 return false;
318 292
319 if (IsLocalGridUser(folder.Owner)) 293 string uri = string.Empty;
294 if (!IsForeignUser(folder.Owner, out uri))
320 return m_GridService.AddFolder(folder); 295 return m_GridService.AddFolder(folder);
321 else 296 else
322 { 297 {
323 UUID sessionID = GetSessionID(folder.Owner); 298 UUID sessionID = GetSessionID(folder.Owner);
324 string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); 299 uri = uri + "/" + folder.Owner.ToString();
325 return m_HGService.AddFolder(uri, folder, sessionID); 300 return m_HGService.AddFolder(uri, folder, sessionID);
326 } 301 }
327 } 302 }
@@ -331,12 +306,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
331 if (folder == null) 306 if (folder == null)
332 return false; 307 return false;
333 308
334 if (IsLocalGridUser(folder.Owner)) 309 string uri = string.Empty;
310 if (!IsForeignUser(folder.Owner, out uri))
335 return m_GridService.UpdateFolder(folder); 311 return m_GridService.UpdateFolder(folder);
336 else 312 else
337 { 313 {
338 UUID sessionID = GetSessionID(folder.Owner); 314 UUID sessionID = GetSessionID(folder.Owner);
339 string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); 315 uri = uri + "/" + folder.Owner.ToString();
340 return m_HGService.UpdateFolder(uri, folder, sessionID); 316 return m_HGService.UpdateFolder(uri, folder, sessionID);
341 } 317 }
342 } 318 }
@@ -348,12 +324,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
348 if (folderIDs.Count == 0) 324 if (folderIDs.Count == 0)
349 return false; 325 return false;
350 326
351 if (IsLocalGridUser(ownerID)) 327 string uri = string.Empty;
328 if (!IsForeignUser(ownerID, out uri))
352 return m_GridService.DeleteFolders(ownerID, folderIDs); 329 return m_GridService.DeleteFolders(ownerID, folderIDs);
353 else 330 else
354 { 331 {
355 UUID sessionID = GetSessionID(ownerID); 332 UUID sessionID = GetSessionID(ownerID);
356 string uri = GetUserInventoryURI(ownerID) + "/" + ownerID.ToString(); 333 uri = uri + "/" + ownerID.ToString();
357 return m_HGService.DeleteFolders(uri, folderIDs, sessionID); 334 return m_HGService.DeleteFolders(uri, folderIDs, sessionID);
358 } 335 }
359 } 336 }
@@ -363,12 +340,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
363 if (folder == null) 340 if (folder == null)
364 return false; 341 return false;
365 342
366 if (IsLocalGridUser(folder.Owner)) 343 string uri = string.Empty;
344 if (!IsForeignUser(folder.Owner, out uri))
367 return m_GridService.MoveFolder(folder); 345 return m_GridService.MoveFolder(folder);
368 else 346 else
369 { 347 {
370 UUID sessionID = GetSessionID(folder.Owner); 348 UUID sessionID = GetSessionID(folder.Owner);
371 string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); 349 uri = uri + "/" + folder.Owner.ToString();
372 return m_HGService.MoveFolder(uri, folder, sessionID); 350 return m_HGService.MoveFolder(uri, folder, sessionID);
373 } 351 }
374 } 352 }
@@ -378,12 +356,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
378 if (folder == null) 356 if (folder == null)
379 return false; 357 return false;
380 358
381 if (IsLocalGridUser(folder.Owner)) 359 string uri = string.Empty;
360 if (!IsForeignUser(folder.Owner, out uri))
382 return m_GridService.PurgeFolder(folder); 361 return m_GridService.PurgeFolder(folder);
383 else 362 else
384 { 363 {
385 UUID sessionID = GetSessionID(folder.Owner); 364 UUID sessionID = GetSessionID(folder.Owner);
386 string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); 365 uri = uri + "/" + folder.Owner.ToString();
387 return m_HGService.PurgeFolder(uri, folder, sessionID); 366 return m_HGService.PurgeFolder(uri, folder, sessionID);
388 } 367 }
389 } 368 }
@@ -396,14 +375,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
396 if (item == null) 375 if (item == null)
397 return false; 376 return false;
398 377
399 if (IsLocalGridUser(item.Owner)) 378 string uri = string.Empty;
379 if (!IsForeignUser(item.Owner, out uri))
400 { 380 {
401 return m_GridService.AddItem(item); 381 return m_GridService.AddItem(item);
402 } 382 }
403 else 383 else
404 { 384 {
405 UUID sessionID = GetSessionID(item.Owner); 385 UUID sessionID = GetSessionID(item.Owner);
406 string uri = GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); 386 uri = uri + "/" + item.Owner.ToString();
407 return m_HGService.AddItem(uri, item, sessionID); 387 return m_HGService.AddItem(uri, item, sessionID);
408 } 388 }
409 } 389 }
@@ -413,12 +393,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
413 if (item == null) 393 if (item == null)
414 return false; 394 return false;
415 395
416 if (IsLocalGridUser(item.Owner)) 396 string uri = string.Empty;
397 if (!IsForeignUser(item.Owner, out uri))
417 return m_GridService.UpdateItem(item); 398 return m_GridService.UpdateItem(item);
418 else 399 else
419 { 400 {
420 UUID sessionID = GetSessionID(item.Owner); 401 UUID sessionID = GetSessionID(item.Owner);
421 string uri = GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); 402 uri = uri + "/" + item.Owner.ToString();
422 return m_HGService.UpdateItem(uri, item, sessionID); 403 return m_HGService.UpdateItem(uri, item, sessionID);
423 } 404 }
424 } 405 }
@@ -430,12 +411,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
430 if (items.Count == 0) 411 if (items.Count == 0)
431 return true; 412 return true;
432 413
433 if (IsLocalGridUser(ownerID)) 414 string uri = string.Empty;
415 if (!IsForeignUser(ownerID, out uri))
434 return m_GridService.MoveItems(ownerID, items); 416 return m_GridService.MoveItems(ownerID, items);
435 else 417 else
436 { 418 {
437 UUID sessionID = GetSessionID(ownerID); 419 UUID sessionID = GetSessionID(ownerID);
438 string uri = GetUserInventoryURI(ownerID) + "/" + ownerID.ToString(); 420 uri = uri + "/" + ownerID.ToString();
439 return m_HGService.MoveItems(uri, items, sessionID); 421 return m_HGService.MoveItems(uri, items, sessionID);
440 } 422 }
441 } 423 }
@@ -449,12 +431,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
449 if (itemIDs.Count == 0) 431 if (itemIDs.Count == 0)
450 return true; 432 return true;
451 433
452 if (IsLocalGridUser(ownerID)) 434 string uri = string.Empty;
435 if (!IsForeignUser(ownerID, out uri))
453 return m_GridService.DeleteItems(ownerID, itemIDs); 436 return m_GridService.DeleteItems(ownerID, itemIDs);
454 else 437 else
455 { 438 {
456 UUID sessionID = GetSessionID(ownerID); 439 UUID sessionID = GetSessionID(ownerID);
457 string uri = GetUserInventoryURI(ownerID) + "/" + ownerID.ToString(); 440 uri = uri + "/" + ownerID.ToString();
458 return m_HGService.DeleteItems(uri, itemIDs, sessionID); 441 return m_HGService.DeleteItems(uri, itemIDs, sessionID);
459 } 442 }
460 } 443 }
@@ -464,12 +447,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
464 if (item == null) 447 if (item == null)
465 return null; 448 return null;
466 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetItem {0} for user {1}", item.ID, item.Owner); 449 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetItem {0} for user {1}", item.ID, item.Owner);
467 if (IsLocalGridUser(item.Owner)) 450 string uri = string.Empty;
451 if (!IsForeignUser(item.Owner, out uri))
468 return m_GridService.GetItem(item); 452 return m_GridService.GetItem(item);
469 else 453 else
470 { 454 {
471 UUID sessionID = GetSessionID(item.Owner); 455 UUID sessionID = GetSessionID(item.Owner);
472 string uri = GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); 456 uri = uri + "/" + item.Owner.ToString();
473 return m_HGService.QueryItem(uri, item, sessionID); 457 return m_HGService.QueryItem(uri, item, sessionID);
474 } 458 }
475 } 459 }
@@ -479,12 +463,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
479 if (folder == null) 463 if (folder == null)
480 return null; 464 return null;
481 465
482 if (IsLocalGridUser(folder.Owner)) 466 string uri = string.Empty;
467 if (!IsForeignUser(folder.Owner, out uri))
483 return m_GridService.GetFolder(folder); 468 return m_GridService.GetFolder(folder);
484 else 469 else
485 { 470 {
486 UUID sessionID = GetSessionID(folder.Owner); 471 UUID sessionID = GetSessionID(folder.Owner);
487 string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); 472 uri = uri + "/" + folder.Owner.ToString();
488 return m_HGService.QueryFolder(uri, folder, sessionID); 473 return m_HGService.QueryFolder(uri, folder, sessionID);
489 } 474 }
490 } 475 }
@@ -501,12 +486,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
501 486
502 public override int GetAssetPermissions(UUID userID, UUID assetID) 487 public override int GetAssetPermissions(UUID userID, UUID assetID)
503 { 488 {
504 if (IsLocalGridUser(userID)) 489 string uri = string.Empty;
490 if (!IsForeignUser(userID, out uri))
505 return m_GridService.GetAssetPermissions(userID, assetID); 491 return m_GridService.GetAssetPermissions(userID, assetID);
506 else 492 else
507 { 493 {
508 UUID sessionID = GetSessionID(userID); 494 UUID sessionID = GetSessionID(userID);
509 string uri = GetUserInventoryURI(userID) + "/" + userID.ToString(); 495 uri = uri + "/" + userID.ToString();
510 return m_HGService.GetAssetPermissions(uri, assetID, sessionID); 496 return m_HGService.GetAssetPermissions(uri, assetID, sessionID);
511 } 497 }
512 } 498 }
@@ -515,61 +501,40 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
515 501
516 private UUID GetSessionID(UUID userID) 502 private UUID GetSessionID(UUID userID)
517 { 503 {
518 CachedUserInfo uinfo = m_UserProfileService.GetUserDetails(userID); 504 ScenePresence sp = null;
519 if (uinfo != null) 505 if (m_Scene.TryGetAvatar(userID, out sp))
520 return uinfo.SessionID; 506 {
507 return sp.ControllingClient.SessionId;
508 }
521 509
522 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: user profile for {0} not found", userID); 510 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: scene presence for {0} not found", userID);
523 return UUID.Zero; 511 return UUID.Zero;
524 } 512 }
525 513
526 private bool IsLocalGridUser(UUID userID) 514 private bool IsForeignUser(UUID userID, out string inventoryURL)
527 { 515 {
528 if (m_UserProfileService == null) 516 inventoryURL = string.Empty;
529 { 517 UserAccount account = null;
530 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: IsLocalGridUser, no profile service. Returning false."); 518 if (m_Scene.UserAccountService != null)
531 return false; 519 account = m_Scene.UserAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, userID);
532 }
533 520
534 CachedUserInfo uinfo = m_UserProfileService.GetUserDetails(userID); 521 if (account == null) // foreign user
535 if (uinfo == null)
536 { 522 {
537 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: IsLocalGridUser, no profile for user {0}. Returning true.", userID); 523 ScenePresence sp = null;
538 return true; 524 m_Scene.TryGetAvatar(userID, out sp);
539 } 525 if (sp != null)
540 526 {
541 if ((uinfo.UserProfile.UserInventoryURI == null) || (uinfo.UserProfile.UserInventoryURI == "")) 527 AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
542 // this happens in standalone profiles, apparently 528 if (aCircuit.ServiceURLs.ContainsKey("InventoryServerURI"))
543 return true; 529 {
544 530 inventoryURL = aCircuit.ServiceURLs["InventoryServerURI"].ToString();
545 string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI); 531 inventoryURL = inventoryURL.Trim(new char[] { '/' });
546 532 return true;
547 string uri = LocalGridInventory.TrimEnd('/'); 533 }
548 534 }
549 if ((userInventoryServerURI == uri) || (userInventoryServerURI == ""))
550 {
551 return true;
552 } 535 }
553 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: user {0} is foreign({1} - {2})", userID, userInventoryServerURI, uri);
554 return false; 536 return false;
555 } 537 }
556 538
557 private string GetUserInventoryURI(UUID userID)
558 {
559 string invURI = LocalGridInventory;
560
561 CachedUserInfo uinfo = m_UserProfileService.GetUserDetails(userID);
562 if ((uinfo == null) || (uinfo.UserProfile == null))
563 return invURI;
564
565 string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
566
567 if ((userInventoryServerURI != null) &&
568 (userInventoryServerURI != ""))
569 invURI = userInventoryServerURI;
570 return invURI;
571 }
572
573
574 } 539 }
575} 540}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
index 3883dc6..e97d21f 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
@@ -131,9 +131,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
131 131
132 if (!m_Initialized) 132 if (!m_Initialized)
133 { 133 {
134 // ugh!
135 scene.CommsManager.UserProfileCacheService.SetInventoryService(this);
136 scene.CommsManager.UserService.SetInventoryService(this);
137 m_Initialized = true; 134 m_Initialized = true;
138 } 135 }
139 136
@@ -317,7 +314,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
317 item = m_InventoryService.GetItem(item); 314 item = m_InventoryService.GetItem(item);
318 315
319 if (null == item) 316 if (null == item)
320 m_log.ErrorFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find item with id {0}"); 317 m_log.ErrorFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find item with id {0}", item.ID);
321 318
322 return item; 319 return item;
323 } 320 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
index 69504df..aa3b30d 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
@@ -32,7 +32,7 @@ using System.Reflection;
32using Nini.Config; 32using Nini.Config;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Statistics; 34using OpenSim.Framework.Statistics;
35using OpenSim.Framework.Communications.Cache; 35
36using OpenSim.Services.Connectors; 36using OpenSim.Services.Connectors;
37using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
@@ -49,7 +49,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
49 private bool m_Enabled = false; 49 private bool m_Enabled = false;
50 private bool m_Initialized = false; 50 private bool m_Initialized = false;
51 private Scene m_Scene; 51 private Scene m_Scene;
52 private UserProfileCacheService m_UserProfileService;
53 private InventoryServicesConnector m_RemoteConnector; 52 private InventoryServicesConnector m_RemoteConnector;
54 53
55 public Type ReplaceableInterface 54 public Type ReplaceableInterface
@@ -114,9 +113,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
114 113
115 if (!m_Initialized) 114 if (!m_Initialized)
116 { 115 {
117 // ugh!
118 scene.CommsManager.UserProfileCacheService.SetInventoryService(this);
119 scene.CommsManager.UserService.SetInventoryService(this);
120 m_Initialized = true; 116 m_Initialized = true;
121 } 117 }
122 118
@@ -134,10 +130,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
134 130
135 public void RegionLoaded(Scene scene) 131 public void RegionLoaded(Scene scene)
136 { 132 {
137 m_UserProfileService = m_Scene.CommsManager.UserProfileCacheService;
138 if (m_UserProfileService != null)
139 m_log.Debug("[XXXX] Set m_UserProfileService in " + m_Scene.RegionInfo.RegionName);
140
141 if (!m_Enabled) 133 if (!m_Enabled)
142 return; 134 return;
143 135
@@ -345,23 +337,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
345 337
346 private UUID GetSessionID(UUID userID) 338 private UUID GetSessionID(UUID userID)
347 { 339 {
348 //if (m_Scene == null)
349 //{
350 // m_log.Debug("[INVENTORY CONNECTOR]: OOPS! scene is null");
351 //}
352
353 if (m_UserProfileService == null)
354 {
355 //m_log.Debug("[INVENTORY CONNECTOR]: OOPS! UserProfileCacheService is null");
356 return UUID.Zero;
357 }
358
359 CachedUserInfo uinfo = m_UserProfileService.GetUserDetails(userID);
360 if (uinfo != null)
361 return uinfo.SessionID;
362 m_log.DebugFormat("[INVENTORY CONNECTOR]: user profile for {0} not found", userID);
363 return UUID.Zero; 340 return UUID.Zero;
364
365 } 341 }
366 342
367 } 343 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs
new file mode 100644
index 0000000..d78daf9
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs
@@ -0,0 +1,200 @@
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 */
27using System;
28using System.Collections.Generic;
29using System.Reflection;
30
31using OpenSim.Region.Framework.Interfaces;
32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Server.Base;
34using OpenSim.Services.Interfaces;
35using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
36
37using OpenMetaverse;
38using log4net;
39using Nini.Config;
40
41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
42{
43 public class LocalPresenceServicesConnector : ISharedRegionModule, IPresenceService
44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
47 private bool m_Enabled = false;
48
49 private PresenceDetector m_PresenceDetector;
50 private IPresenceService m_PresenceService;
51
52 public LocalPresenceServicesConnector()
53 {
54 }
55
56 public LocalPresenceServicesConnector(IConfigSource source)
57 {
58 Initialise(source);
59 }
60
61 #region ISharedRegionModule
62
63 public Type ReplaceableInterface
64 {
65 get { return null; }
66 }
67
68 public string Name
69 {
70 get { return "LocalPresenceServicesConnector"; }
71 }
72
73 public void Initialise(IConfigSource source)
74 {
75 IConfig moduleConfig = source.Configs["Modules"];
76 if (moduleConfig != null)
77 {
78 string name = moduleConfig.GetString("PresenceServices", "");
79 if (name == Name)
80 {
81 IConfig inventoryConfig = source.Configs["PresenceService"];
82 if (inventoryConfig == null)
83 {
84 m_log.Error("[LOCAL PRESENCE CONNECTOR]: PresenceService missing from OpenSim.ini");
85 return;
86 }
87
88 string serviceDll = inventoryConfig.GetString("LocalServiceModule", String.Empty);
89
90 if (serviceDll == String.Empty)
91 {
92 m_log.Error("[LOCAL PRESENCE CONNECTOR]: No LocalServiceModule named in section PresenceService");
93 return;
94 }
95
96 Object[] args = new Object[] { source };
97 m_log.DebugFormat("[LOCAL PRESENCE CONNECTOR]: Service dll = {0}", serviceDll);
98
99 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(serviceDll, args);
100
101 if (m_PresenceService == null)
102 {
103 m_log.Error("[LOCAL PRESENCE CONNECTOR]: Can't load presence service");
104 //return;
105 throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's");
106 }
107
108 //Init(source);
109
110 m_PresenceDetector = new PresenceDetector(this);
111
112 m_Enabled = true;
113 m_log.Info("[LOCAL PRESENCE CONNECTOR]: Local presence connector enabled");
114 }
115 }
116 }
117
118 public void PostInitialise()
119 {
120 }
121
122 public void Close()
123 {
124 }
125
126 public void AddRegion(Scene scene)
127 {
128 if (!m_Enabled)
129 return;
130
131 // m_log.DebugFormat(
132 // "[LOCAL PRESENCE CONNECTOR]: Registering IPresenceService to scene {0}", scene.RegionInfo.RegionName);
133
134 scene.RegisterModuleInterface<IPresenceService>(this);
135 m_PresenceDetector.AddRegion(scene);
136
137 m_log.InfoFormat("[LOCAL PRESENCE CONNECTOR]: Enabled local presence for region {0}", scene.RegionInfo.RegionName);
138
139 }
140
141 public void RemoveRegion(Scene scene)
142 {
143 if (!m_Enabled)
144 return;
145
146 m_PresenceDetector.RemoveRegion(scene);
147 }
148
149 public void RegionLoaded(Scene scene)
150 {
151 if (!m_Enabled)
152 return;
153
154 }
155
156 #endregion
157
158 #region IPresenceService
159
160 public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID)
161 {
162 m_log.Warn("[LOCAL PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators");
163 return false;
164 }
165
166 public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat)
167 {
168 return m_PresenceService.LogoutAgent(sessionID, position, lookat);
169 }
170
171
172 public bool LogoutRegionAgents(UUID regionID)
173 {
174 return m_PresenceService.LogoutRegionAgents(regionID);
175 }
176
177 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
178 {
179 return m_PresenceService.ReportAgent(sessionID, regionID, position, lookAt);
180 }
181
182 public PresenceInfo GetAgent(UUID sessionID)
183 {
184 return m_PresenceService.GetAgent(sessionID);
185 }
186
187 public PresenceInfo[] GetAgents(string[] userIDs)
188 {
189 return m_PresenceService.GetAgents(userIDs);
190 }
191
192 public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
193 {
194 return m_PresenceService.SetHomeLocation(userID, regionID, position, lookAt);
195 }
196
197 #endregion
198
199 }
200}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
new file mode 100644
index 0000000..891fc14
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
@@ -0,0 +1,100 @@
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 */
27using System;
28using System.Collections.Generic;
29using System.Reflection;
30
31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Services.Interfaces;
34
35using OpenMetaverse;
36using log4net;
37
38namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
39{
40 public class PresenceDetector
41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43
44 private IPresenceService m_PresenceService;
45 private Scene m_aScene;
46
47 public PresenceDetector(IPresenceService presenceservice)
48 {
49 m_PresenceService = presenceservice;
50 }
51
52 public void AddRegion(Scene scene)
53 {
54 scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
55 scene.EventManager.OnNewClient += OnNewClient;
56
57 m_PresenceService.LogoutRegionAgents(scene.RegionInfo.RegionID);
58
59 if (m_aScene == null)
60 m_aScene = scene;
61 }
62
63 public void RemoveRegion(Scene scene)
64 {
65 scene.EventManager.OnMakeRootAgent -= OnMakeRootAgent;
66 scene.EventManager.OnNewClient -= OnNewClient;
67
68 m_PresenceService.LogoutRegionAgents(scene.RegionInfo.RegionID);
69
70 }
71
72 public void OnMakeRootAgent(ScenePresence sp)
73 {
74 m_log.DebugFormat("[PRESENCE DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName);
75 m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
76 }
77
78 public void OnNewClient(IClientAPI client)
79 {
80 client.OnLogout += OnLogout;
81 }
82
83 public void OnLogout(IClientAPI client)
84 {
85 client.OnLogout -= OnLogout;
86
87 ScenePresence sp = null;
88 Vector3 position = new Vector3(128, 128, 0);
89 Vector3 lookat = new Vector3(0, 1, 0);
90
91 if (m_aScene.TryGetAvatar(client.AgentId, out sp))
92 {
93 position = sp.AbsolutePosition;
94 lookat = sp.Lookat;
95 }
96 m_PresenceService.LogoutAgent(client.SessionId, position, lookat);
97
98 }
99 }
100}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs
new file mode 100644
index 0000000..865f99e
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs
@@ -0,0 +1,164 @@
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 */
27using System;
28using System.Collections.Generic;
29using System.Reflection;
30
31using OpenSim.Region.Framework.Interfaces;
32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Server.Base;
34using OpenSim.Services.Interfaces;
35using OpenSim.Services.Connectors;
36using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
37
38using OpenMetaverse;
39using log4net;
40using Nini.Config;
41
42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
43{
44 public class RemotePresenceServicesConnector : ISharedRegionModule, IPresenceService
45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 #region ISharedRegionModule
49
50 private bool m_Enabled = false;
51
52 private PresenceDetector m_PresenceDetector;
53 private IPresenceService m_RemoteConnector;
54
55 public Type ReplaceableInterface
56 {
57 get { return null; }
58 }
59
60 public string Name
61 {
62 get { return "RemotePresenceServicesConnector"; }
63 }
64
65 public void Initialise(IConfigSource source)
66 {
67 IConfig moduleConfig = source.Configs["Modules"];
68 if (moduleConfig != null)
69 {
70 string name = moduleConfig.GetString("PresenceServices", "");
71 if (name == Name)
72 {
73 m_RemoteConnector = new PresenceServicesConnector(source);
74
75 m_Enabled = true;
76
77 m_PresenceDetector = new PresenceDetector(this);
78
79 m_log.Info("[INVENTORY CONNECTOR]: Remote presence enabled");
80 }
81 }
82
83 }
84
85 public void PostInitialise()
86 {
87 }
88
89 public void Close()
90 {
91 }
92
93 public void AddRegion(Scene scene)
94 {
95 if (!m_Enabled)
96 return;
97
98 scene.RegisterModuleInterface<IPresenceService>(this);
99 m_PresenceDetector.AddRegion(scene);
100
101 m_log.InfoFormat("[REMOTE PRESENCE CONNECTOR]: Enabled remote presence for region {0}", scene.RegionInfo.RegionName);
102
103 }
104
105 public void RemoveRegion(Scene scene)
106 {
107 if (!m_Enabled)
108 return;
109
110 m_PresenceDetector.RemoveRegion(scene);
111 }
112
113 public void RegionLoaded(Scene scene)
114 {
115 if (!m_Enabled)
116 return;
117
118 }
119
120 #endregion
121
122 #region IPresenceService
123
124 public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID)
125 {
126 m_log.Warn("[REMOTE PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators");
127 return false;
128 }
129
130 public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat)
131 {
132 return m_RemoteConnector.LogoutAgent(sessionID, position, lookat);
133 }
134
135
136 public bool LogoutRegionAgents(UUID regionID)
137 {
138 return m_RemoteConnector.LogoutRegionAgents(regionID);
139 }
140
141 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
142 {
143 return m_RemoteConnector.ReportAgent(sessionID, regionID, position, lookAt);
144 }
145
146 public PresenceInfo GetAgent(UUID sessionID)
147 {
148 return m_RemoteConnector.GetAgent(sessionID);
149 }
150
151 public PresenceInfo[] GetAgents(string[] userIDs)
152 {
153 return m_RemoteConnector.GetAgents(userIDs);
154 }
155
156 public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
157 {
158 return m_RemoteConnector.SetHomeLocation(userID, regionID, position, lookAt);
159 }
160
161 #endregion
162
163 }
164}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
new file mode 100644
index 0000000..ca42461
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
@@ -0,0 +1,104 @@
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 NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse;
37using OpenSim.Framework;
38using Nini.Config;
39
40using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence;
41using OpenSim.Region.Framework.Scenes;
42using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
43using OpenSim.Tests.Common;
44using OpenSim.Tests.Common.Setup;
45
46namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests
47{
48 [TestFixture]
49 public class PresenceConnectorsTests
50 {
51 LocalPresenceServicesConnector m_LocalConnector;
52 private void SetUp()
53 {
54 IConfigSource config = new IniConfigSource();
55 config.AddConfig("Modules");
56 config.AddConfig("PresenceService");
57 config.Configs["Modules"].Set("PresenceServices", "LocalPresenceServicesConnector");
58 config.Configs["PresenceService"].Set("LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService");
59 config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
60
61 m_LocalConnector = new LocalPresenceServicesConnector(config);
62 }
63
64 /// <summary>
65 /// Test OpenSim Presence.
66 /// </summary>
67 [Test]
68 public void TestPresenceV0_1()
69 {
70 SetUp();
71
72 string user1 = UUID.Zero.ToString();
73 UUID session1 = UUID.Zero;
74
75 // this is not implemented by this connector
76 //m_LocalConnector.LoginAgent(user1, session1, UUID.Zero);
77 PresenceInfo result = m_LocalConnector.GetAgent(session1);
78 Assert.IsNotNull(result, "Retrieved GetAgent is null");
79 Assert.That(result.UserID, Is.EqualTo(user1), "Retrieved userID does not match");
80 Assert.IsTrue(result.Online, "Agent just logged in but is offline");
81
82 UUID region1 = UUID.Random();
83 bool r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero);
84 Assert.IsTrue(r, "First ReportAgent returned false");
85 result = m_LocalConnector.GetAgent(session1);
86 Assert.That(result.RegionID, Is.EqualTo(region1), "Agent is not in the right region (region1)");
87
88 UUID region2 = UUID.Random();
89 r = m_LocalConnector.ReportAgent(session1, region2, Vector3.Zero, Vector3.Zero);
90 Assert.IsTrue(r, "Second ReportAgent returned false");
91 result = m_LocalConnector.GetAgent(session1);
92 Assert.That(result.RegionID, Is.EqualTo(region2), "Agent is not in the right region (region2)");
93
94 r = m_LocalConnector.LogoutAgent(session1, Vector3.Zero, Vector3.UnitY);
95 Assert.IsTrue(r, "LogoutAgent returned false");
96 result = m_LocalConnector.GetAgent(session1);
97 Assert.IsNotNull(result, "Agent session disappeared from storage after logout");
98 Assert.IsFalse(result.Online, "Agent is reported to be Online after logout");
99
100 r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero);
101 Assert.IsFalse(r, "ReportAgent of non-logged in user returned true");
102 }
103 }
104}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index d68c683..e913891 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -33,33 +33,49 @@ using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Services.Interfaces;
37using GridRegion = OpenSim.Services.Interfaces.GridRegion;
36 38
37namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion 39namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
38{ 40{
39 public class LocalInterregionComms : ISharedRegionModule, IInterregionCommsOut, IInterregionCommsIn 41 public class LocalSimulationConnectorModule : ISharedRegionModule, ISimulationService
40 { 42 {
41 private bool m_enabled = false;
42
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 private List<Scene> m_sceneList = new List<Scene>(); 44 private List<Scene> m_sceneList = new List<Scene>();
45 45
46 #region Events 46 private IEntityTransferModule m_AgentTransferModule;
47 public event ChildAgentUpdateReceived OnChildAgentUpdate; 47 protected IEntityTransferModule AgentTransferModule
48 {
49 get
50 {
51 if (m_AgentTransferModule == null)
52 m_AgentTransferModule = m_sceneList[0].RequestModuleInterface<IEntityTransferModule>();
53 return m_AgentTransferModule;
54 }
55 }
48 56
49 #endregion /* Events */ 57 private bool m_ModuleEnabled = false;
50 58
51 #region IRegionModule 59 #region IRegionModule
52 60
53 public void Initialise(IConfigSource config) 61 public void Initialise(IConfigSource config)
54 { 62 {
55 if (m_sceneList.Count == 0) 63 IConfig moduleConfig = config.Configs["Modules"];
64 if (moduleConfig != null)
56 { 65 {
57 IConfig startupConfig = config.Configs["Communications"]; 66 string name = moduleConfig.GetString("SimulationServices", "");
58 67 if (name == Name)
59 if ((startupConfig != null) && (startupConfig.GetString("InterregionComms", "RESTComms") == "LocalComms"))
60 { 68 {
61 m_log.Debug("[LOCAL COMMS]: Enabling InterregionComms LocalComms module"); 69 //IConfig userConfig = config.Configs["SimulationService"];
62 m_enabled = true; 70 //if (userConfig == null)
71 //{
72 // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini");
73 // return;
74 //}
75
76 m_ModuleEnabled = true;
77
78 m_log.Info("[SIMULATION CONNECTOR]: Local simulation enabled");
63 } 79 }
64 } 80 }
65 } 81 }
@@ -70,22 +86,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
70 86
71 public void AddRegion(Scene scene) 87 public void AddRegion(Scene scene)
72 { 88 {
89 if (!m_ModuleEnabled)
90 return;
91
92 Init(scene);
93 scene.RegisterModuleInterface<ISimulationService>(this);
73 } 94 }
74 95
75 public void RemoveRegion(Scene scene) 96 public void RemoveRegion(Scene scene)
76 { 97 {
77 if (m_enabled) 98 if (!m_ModuleEnabled)
78 { 99 return;
79 RemoveScene(scene); 100
80 } 101 RemoveScene(scene);
102 scene.UnregisterModuleInterface<ISimulationService>(this);
81 } 103 }
82 104
83 public void RegionLoaded(Scene scene) 105 public void RegionLoaded(Scene scene)
84 { 106 {
85 if (m_enabled)
86 {
87 Init(scene);
88 }
89 } 107 }
90 108
91 public void Close() 109 public void Close()
@@ -99,7 +117,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
99 117
100 public string Name 118 public string Name
101 { 119 {
102 get { return "LocalInterregionCommsModule"; } 120 get { return "LocalSimulationConnectorModule"; }
103 } 121 }
104 122
105 /// <summary> 123 /// <summary>
@@ -128,9 +146,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
128 lock (m_sceneList) 146 lock (m_sceneList)
129 { 147 {
130 m_sceneList.Add(scene); 148 m_sceneList.Add(scene);
131 if (m_enabled)
132 scene.RegisterModuleInterface<IInterregionCommsOut>(this);
133 scene.RegisterModuleInterface<IInterregionCommsIn>(this);
134 } 149 }
135 150
136 } 151 }
@@ -138,40 +153,58 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
138 153
139 #endregion /* IRegionModule */ 154 #endregion /* IRegionModule */
140 155
141 #region IInterregionComms 156 #region ISimulation
157
158 public IScene GetScene(ulong regionhandle)
159 {
160 foreach (Scene s in m_sceneList)
161 {
162 if (s.RegionInfo.RegionHandle == regionhandle)
163 return s;
164 }
165 // ? weird. should not happen
166 return m_sceneList[0];
167 }
142 168
143 /** 169 /**
144 * Agent-related communications 170 * Agent-related communications
145 */ 171 */
146 172
147 public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, uint teleportFlags, out string reason) 173 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason)
148 { 174 {
175 if (destination == null)
176 {
177 reason = "Given destination was null";
178 m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: CreateAgent was given a null destination");
179 return false;
180 }
149 181
150 foreach (Scene s in m_sceneList) 182 foreach (Scene s in m_sceneList)
151 { 183 {
152 if (s.RegionInfo.RegionHandle == regionHandle) 184 if (s.RegionInfo.RegionHandle == destination.RegionHandle)
153 { 185 {
154// m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); 186 m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Found region {0} to send SendCreateChildAgent", destination.RegionName);
155 return s.NewUserConnection(aCircuit, teleportFlags, out reason); 187 return s.NewUserConnection(aCircuit, teleportFlags, out reason);
156 } 188 }
157 } 189 }
158 190
159// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); 191 m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Did not find region {0} for SendCreateChildAgent", destination.RegionName);
160 uint x = 0, y = 0; 192 reason = "Did not find region " + destination.RegionName;
161 Utils.LongToUInts(regionHandle, out x, out y);
162 reason = "Did not find region " + x + "-" + y;
163 return false; 193 return false;
164 } 194 }
165 195
166 public bool SendChildAgentUpdate(ulong regionHandle, AgentData cAgentData) 196 public bool UpdateAgent(GridRegion destination, AgentData cAgentData)
167 { 197 {
198 if (destination == null)
199 return false;
200
168 foreach (Scene s in m_sceneList) 201 foreach (Scene s in m_sceneList)
169 { 202 {
170 if (s.RegionInfo.RegionHandle == regionHandle) 203 if (s.RegionInfo.RegionHandle == destination.RegionHandle)
171 { 204 {
172 //m_log.DebugFormat( 205 m_log.DebugFormat(
173 // "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate", 206 "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
174 // s.RegionInfo.RegionName, regionHandle); 207 s.RegionInfo.RegionName, destination.RegionHandle);
175 208
176 s.IncomingChildAgentDataUpdate(cAgentData); 209 s.IncomingChildAgentDataUpdate(cAgentData);
177 return true; 210 return true;
@@ -182,11 +215,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
182 return false; 215 return false;
183 } 216 }
184 217
185 public bool SendChildAgentUpdate(ulong regionHandle, AgentPosition cAgentData) 218 public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData)
186 { 219 {
220 if (destination == null)
221 return false;
222
187 foreach (Scene s in m_sceneList) 223 foreach (Scene s in m_sceneList)
188 { 224 {
189 if (s.RegionInfo.RegionHandle == regionHandle) 225 if (s.RegionInfo.RegionHandle == destination.RegionHandle)
190 { 226 {
191 //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); 227 //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
192 s.IncomingChildAgentDataUpdate(cAgentData); 228 s.IncomingChildAgentDataUpdate(cAgentData);
@@ -197,12 +233,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
197 return false; 233 return false;
198 } 234 }
199 235
200 public bool SendRetrieveRootAgent(ulong regionHandle, UUID id, out IAgentData agent) 236 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
201 { 237 {
202 agent = null; 238 agent = null;
239
240 if (destination == null)
241 return false;
242
203 foreach (Scene s in m_sceneList) 243 foreach (Scene s in m_sceneList)
204 { 244 {
205 if (s.RegionInfo.RegionHandle == regionHandle) 245 if (s.RegionInfo.RegionHandle == destination.RegionHandle)
206 { 246 {
207 //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); 247 //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
208 return s.IncomingRetrieveRootAgent(id, out agent); 248 return s.IncomingRetrieveRootAgent(id, out agent);
@@ -212,35 +252,30 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
212 return false; 252 return false;
213 } 253 }
214 254
215 public bool SendReleaseAgent(ulong regionHandle, UUID id, string uri) 255 public bool ReleaseAgent(UUID origin, UUID id, string uri)
216 { 256 {
217 //uint x, y;
218 //Utils.LongToUInts(regionHandle, out x, out y);
219 //x = x / Constants.RegionSize;
220 //y = y / Constants.RegionSize;
221 //m_log.Debug("\n >>> Local SendReleaseAgent " + x + "-" + y);
222 foreach (Scene s in m_sceneList) 257 foreach (Scene s in m_sceneList)
223 { 258 {
224 if (s.RegionInfo.RegionHandle == regionHandle) 259 if (s.RegionInfo.RegionID == origin)
225 { 260 {
226 //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); 261 m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent");
227 return s.IncomingReleaseAgent(id); 262 AgentTransferModule.AgentArrivedAtDestination(id);
263 return true;
264// return s.IncomingReleaseAgent(id);
228 } 265 }
229 } 266 }
230 //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent"); 267 //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent " + origin);
231 return false; 268 return false;
232 } 269 }
233 270
234 public bool SendCloseAgent(ulong regionHandle, UUID id) 271 public bool CloseAgent(GridRegion destination, UUID id)
235 { 272 {
236 //uint x, y; 273 if (destination == null)
237 //Utils.LongToUInts(regionHandle, out x, out y); 274 return false;
238 //x = x / Constants.RegionSize; 275
239 //y = y / Constants.RegionSize;
240 //m_log.Debug("\n >>> Local SendCloseAgent " + x + "-" + y);
241 foreach (Scene s in m_sceneList) 276 foreach (Scene s in m_sceneList)
242 { 277 {
243 if (s.RegionInfo.RegionHandle == regionHandle) 278 if (s.RegionInfo.RegionID == destination.RegionID)
244 { 279 {
245 //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); 280 //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent");
246 return s.IncomingCloseAgent(id); 281 return s.IncomingCloseAgent(id);
@@ -254,11 +289,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
254 * Object-related communications 289 * Object-related communications
255 */ 290 */
256 291
257 public bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, bool isLocalCall) 292 public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall)
258 { 293 {
294 if (destination == null)
295 return false;
296
259 foreach (Scene s in m_sceneList) 297 foreach (Scene s in m_sceneList)
260 { 298 {
261 if (s.RegionInfo.RegionHandle == regionHandle) 299 if (s.RegionInfo.RegionHandle == destination.RegionHandle)
262 { 300 {
263 //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); 301 //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject");
264 if (isLocalCall) 302 if (isLocalCall)
@@ -278,11 +316,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
278 return false; 316 return false;
279 } 317 }
280 318
281 public bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID) 319 public bool CreateObject(GridRegion destination, UUID userID, UUID itemID)
282 { 320 {
321 if (destination == null)
322 return false;
323
283 foreach (Scene s in m_sceneList) 324 foreach (Scene s in m_sceneList)
284 { 325 {
285 if (s.RegionInfo.RegionHandle == regionHandle) 326 if (s.RegionInfo.RegionHandle == destination.RegionHandle)
286 { 327 {
287 return s.IncomingCreateObject(userID, itemID); 328 return s.IncomingCreateObject(userID, itemID);
288 } 329 }
@@ -295,21 +336,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
295 336
296 #region Misc 337 #region Misc
297 338
298 public Scene GetScene(ulong regionhandle) 339 public bool IsLocalRegion(ulong regionhandle)
299 { 340 {
300 foreach (Scene s in m_sceneList) 341 foreach (Scene s in m_sceneList)
301 {
302 if (s.RegionInfo.RegionHandle == regionhandle) 342 if (s.RegionInfo.RegionHandle == regionhandle)
303 return s; 343 return true;
304 } 344 return false;
305 // ? weird. should not happen
306 return m_sceneList[0];
307 } 345 }
308 346
309 public bool IsLocalRegion(ulong regionhandle) 347 public bool IsLocalRegion(UUID id)
310 { 348 {
311 foreach (Scene s in m_sceneList) 349 foreach (Scene s in m_sceneList)
312 if (s.RegionInfo.RegionHandle == regionhandle) 350 if (s.RegionInfo.RegionID == id)
313 return true; 351 return true;
314 return false; 352 return false;
315 } 353 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
new file mode 100644
index 0000000..2b1f815
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -0,0 +1,300 @@
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;
30using System.IO;
31using System.Net;
32using System.Reflection;
33using System.Text;
34using log4net;
35using Nini.Config;
36using OpenMetaverse;
37using OpenMetaverse.StructuredData;
38using OpenSim.Framework;
39using OpenSim.Framework.Communications;
40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Scenes.Serialization;
43using OpenSim.Services.Interfaces;
44using OpenSim.Services.Connectors.Simulation;
45using GridRegion = OpenSim.Services.Interfaces.GridRegion;
46
47namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
48{
49 public class RemoteSimulationConnectorModule : ISharedRegionModule, ISimulationService
50 {
51 private bool initialized = false;
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53
54 protected bool m_enabled = false;
55 protected Scene m_aScene;
56 // RemoteSimulationConnector does not care about local regions; it delegates that to the Local module
57 protected LocalSimulationConnectorModule m_localBackend;
58 protected SimulationServiceConnector m_remoteConnector;
59
60 protected bool m_safemode;
61 protected IPAddress m_thisIP;
62
63 #region IRegionModule
64
65 public virtual void Initialise(IConfigSource config)
66 {
67
68 IConfig moduleConfig = config.Configs["Modules"];
69 if (moduleConfig != null)
70 {
71 string name = moduleConfig.GetString("SimulationServices", "");
72 if (name == Name)
73 {
74 //IConfig userConfig = config.Configs["SimulationService"];
75 //if (userConfig == null)
76 //{
77 // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini");
78 // return;
79 //}
80
81 m_remoteConnector = new SimulationServiceConnector();
82
83 m_enabled = true;
84
85 m_log.Info("[SIMULATION CONNECTOR]: Remote simulation enabled");
86 }
87 }
88 }
89
90 public virtual void PostInitialise()
91 {
92 }
93
94 public virtual void Close()
95 {
96 }
97
98 public void AddRegion(Scene scene)
99 {
100 if (!m_enabled)
101 return;
102
103 if (!initialized)
104 {
105 InitOnce(scene);
106 initialized = true;
107 }
108 InitEach(scene);
109 }
110
111 public void RemoveRegion(Scene scene)
112 {
113 if (m_enabled)
114 {
115 m_localBackend.RemoveScene(scene);
116 scene.UnregisterModuleInterface<ISimulationService>(this);
117 }
118 }
119
120 public void RegionLoaded(Scene scene)
121 {
122 if (!m_enabled)
123 return;
124 }
125
126 public Type ReplaceableInterface
127 {
128 get { return null; }
129 }
130
131 public virtual string Name
132 {
133 get { return "RemoteSimulationConnectorModule"; }
134 }
135
136 protected virtual void InitEach(Scene scene)
137 {
138 m_localBackend.Init(scene);
139 scene.RegisterModuleInterface<ISimulationService>(this);
140 }
141
142 protected virtual void InitOnce(Scene scene)
143 {
144 m_localBackend = new LocalSimulationConnectorModule();
145 m_aScene = scene;
146 //m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService);
147 m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName);
148 }
149
150 #endregion /* IRegionModule */
151
152 #region IInterregionComms
153
154 public IScene GetScene(ulong handle)
155 {
156 return m_localBackend.GetScene(handle);
157 }
158
159 /**
160 * Agent-related communications
161 */
162
163 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason)
164 {
165 if (destination == null)
166 {
167 reason = "Given destination was null";
168 m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent was given a null destination");
169 return false;
170 }
171
172 // Try local first
173 if (m_localBackend.CreateAgent(destination, aCircuit, teleportFlags, out reason))
174 return true;
175
176 // else do the remote thing
177 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
178 {
179 //m_regionClient.SendUserInformation(regInfo, aCircuit);
180 return m_remoteConnector.CreateAgent(destination, aCircuit, teleportFlags, out reason);
181 }
182 return false;
183 }
184
185 public bool UpdateAgent(GridRegion destination, AgentData cAgentData)
186 {
187 if (destination == null)
188 return false;
189
190 // Try local first
191 if (m_localBackend.UpdateAgent(destination, cAgentData))
192 return true;
193
194 // else do the remote thing
195 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
196 return m_remoteConnector.UpdateAgent(destination, cAgentData);
197
198 return false;
199
200 }
201
202 public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData)
203 {
204 if (destination == null)
205 return false;
206
207 // Try local first
208 if (m_localBackend.UpdateAgent(destination, cAgentData))
209 return true;
210
211 // else do the remote thing
212 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
213 return m_remoteConnector.UpdateAgent(destination, cAgentData);
214
215 return false;
216
217 }
218
219 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
220 {
221 agent = null;
222
223 if (destination == null)
224 return false;
225
226 // Try local first
227 if (m_localBackend.RetrieveAgent(destination, id, out agent))
228 return true;
229
230 // else do the remote thing
231 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
232 return m_remoteConnector.RetrieveAgent(destination, id, out agent);
233
234 return false;
235
236 }
237
238 public bool ReleaseAgent(UUID origin, UUID id, string uri)
239 {
240 // Try local first
241 if (m_localBackend.ReleaseAgent(origin, id, uri))
242 return true;
243
244 // else do the remote thing
245 if (!m_localBackend.IsLocalRegion(origin))
246 return m_remoteConnector.ReleaseAgent(origin, id, uri);
247
248 return false;
249 }
250
251
252 public bool CloseAgent(GridRegion destination, UUID id)
253 {
254 if (destination == null)
255 return false;
256
257 // Try local first
258 if (m_localBackend.CloseAgent(destination, id))
259 return true;
260
261 // else do the remote thing
262 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
263 return m_remoteConnector.CloseAgent(destination, id);
264
265 return false;
266 }
267
268 /**
269 * Object-related communications
270 */
271
272 public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall)
273 {
274 if (destination == null)
275 return false;
276
277 // Try local first
278 if (m_localBackend.CreateObject(destination, sog, isLocalCall))
279 {
280 //m_log.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded");
281 return true;
282 }
283
284 // else do the remote thing
285 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
286 return m_remoteConnector.CreateObject(destination, sog, isLocalCall);
287
288 return false;
289 }
290
291 public bool CreateObject(GridRegion destination, UUID userID, UUID itemID)
292 {
293 // Not Implemented
294 return false;
295 }
296
297 #endregion /* IInterregionComms */
298
299 }
300}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs
new file mode 100644
index 0000000..07fee79
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs
@@ -0,0 +1,189 @@
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 log4net;
32using Nini.Config;
33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Server.Base;
36using OpenSim.Services.Interfaces;
37
38using OpenMetaverse;
39
40namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
41{
42 public class LocalUserAccountServicesConnector : ISharedRegionModule, IUserAccountService
43 {
44 private static readonly ILog m_log =
45 LogManager.GetLogger(
46 MethodBase.GetCurrentMethod().DeclaringType);
47
48 private IUserAccountService m_UserService;
49 private UserAccountCache m_Cache;
50
51 private bool m_Enabled = false;
52
53 #region ISharedRegionModule
54
55 public Type ReplaceableInterface
56 {
57 get { return null; }
58 }
59
60 public string Name
61 {
62 get { return "LocalUserAccountServicesConnector"; }
63 }
64
65 public void Initialise(IConfigSource source)
66 {
67 IConfig moduleConfig = source.Configs["Modules"];
68 if (moduleConfig != null)
69 {
70 string name = moduleConfig.GetString("UserAccountServices", "");
71 if (name == Name)
72 {
73 IConfig userConfig = source.Configs["UserAccountService"];
74 if (userConfig == null)
75 {
76 m_log.Error("[USER CONNECTOR]: UserAccountService missing from OpenSim.ini");
77 return;
78 }
79
80 string serviceDll = userConfig.GetString("LocalServiceModule",
81 String.Empty);
82
83 if (serviceDll == String.Empty)
84 {
85 m_log.Error("[USER CONNECTOR]: No LocalServiceModule named in section UserService");
86 return;
87 }
88
89 Object[] args = new Object[] { source };
90 m_UserService =
91 ServerUtils.LoadPlugin<IUserAccountService>(serviceDll,
92 args);
93
94 if (m_UserService == null)
95 {
96 m_log.Error("[USER CONNECTOR]: Can't load user account service");
97 return;
98 }
99 m_Enabled = true;
100 m_Cache = new UserAccountCache();
101
102 m_log.Info("[USER CONNECTOR]: Local user connector enabled");
103 }
104 }
105 }
106
107 public void PostInitialise()
108 {
109 if (!m_Enabled)
110 return;
111 }
112
113 public void Close()
114 {
115 if (!m_Enabled)
116 return;
117 }
118
119 public void AddRegion(Scene scene)
120 {
121 if (!m_Enabled)
122 return;
123
124 scene.RegisterModuleInterface<IUserAccountService>(m_UserService);
125 }
126
127 public void RemoveRegion(Scene scene)
128 {
129 if (!m_Enabled)
130 return;
131 }
132
133 public void RegionLoaded(Scene scene)
134 {
135 if (!m_Enabled)
136 return;
137 }
138
139 #endregion
140
141 #region IUserAccountService
142
143 public UserAccount GetUserAccount(UUID scopeID, UUID userID)
144 {
145 UserAccount account = m_Cache.Get(userID);
146 if (account != null)
147 return account;
148
149 account = m_UserService.GetUserAccount(scopeID, userID);
150 if (account != null)
151 m_Cache.Cache(account);
152
153 return account;
154 }
155
156 public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName)
157 {
158 UserAccount account = m_Cache.Get(firstName + " " + lastName);
159 if (account != null)
160 return account;
161
162 account = m_UserService.GetUserAccount(scopeID, firstName, lastName);
163 if (account != null)
164 m_Cache.Cache(account);
165
166 return account;
167 }
168
169 public UserAccount GetUserAccount(UUID scopeID, string Email)
170 {
171 return m_UserService.GetUserAccount(scopeID, Email);
172 }
173
174 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
175 {
176 return m_UserService.GetUserAccounts(scopeID, query);
177 }
178
179 // Update all updatable fields
180 //
181 public bool StoreUserAccount(UserAccount data)
182 {
183 return m_UserService.StoreUserAccount(data);
184 }
185
186 #endregion
187
188 }
189}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs
new file mode 100644
index 0000000..13acdf2
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs
@@ -0,0 +1,148 @@
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 Nini.Config;
30using log4net;
31using System.Reflection;
32using OpenSim.Region.Framework.Interfaces;
33using OpenSim.Region.Framework.Scenes;
34using OpenSim.Services.Interfaces;
35using OpenSim.Services.Connectors;
36
37using OpenMetaverse;
38
39namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
40{
41 public class RemoteUserAccountServicesConnector : UserAccountServicesConnector,
42 ISharedRegionModule, IUserAccountService
43 {
44 private static readonly ILog m_log =
45 LogManager.GetLogger(
46 MethodBase.GetCurrentMethod().DeclaringType);
47
48 private bool m_Enabled = false;
49 private UserAccountCache m_Cache;
50
51 public Type ReplaceableInterface
52 {
53 get { return null; }
54 }
55
56 public string Name
57 {
58 get { return "RemoteUserAccountServicesConnector"; }
59 }
60
61 public override void Initialise(IConfigSource source)
62 {
63 IConfig moduleConfig = source.Configs["Modules"];
64 if (moduleConfig != null)
65 {
66 string name = moduleConfig.GetString("UserAccountServices", "");
67 if (name == Name)
68 {
69 IConfig userConfig = source.Configs["UserAccountService"];
70 if (userConfig == null)
71 {
72 m_log.Error("[USER CONNECTOR]: UserAccountService missing from OpanSim.ini");
73 return;
74 }
75
76 m_Enabled = true;
77
78 base.Initialise(source);
79 m_Cache = new UserAccountCache();
80
81 m_log.Info("[USER CONNECTOR]: Remote users enabled");
82 }
83 }
84 }
85
86 public void PostInitialise()
87 {
88 if (!m_Enabled)
89 return;
90 }
91
92 public void Close()
93 {
94 if (!m_Enabled)
95 return;
96 }
97
98 public void AddRegion(Scene scene)
99 {
100 if (!m_Enabled)
101 return;
102
103 scene.RegisterModuleInterface<IUserAccountService>(this);
104 }
105
106 public void RemoveRegion(Scene scene)
107 {
108 if (!m_Enabled)
109 return;
110 }
111
112 public void RegionLoaded(Scene scene)
113 {
114 if (!m_Enabled)
115 return;
116 }
117
118 #region Overwritten methods from IUserAccountService
119
120 public override UserAccount GetUserAccount(UUID scopeID, UUID userID)
121 {
122 UserAccount account = m_Cache.Get(userID);
123 if (account != null)
124 return account;
125
126 account = base.GetUserAccount(scopeID, userID);
127 if (account != null)
128 m_Cache.Cache(account);
129
130 return account;
131 }
132
133 public override UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName)
134 {
135 UserAccount account = m_Cache.Get(firstName + " " + lastName);
136 if (account != null)
137 return account;
138
139 account = base.GetUserAccount(scopeID, firstName, lastName);
140 if (account != null)
141 m_Cache.Cache(account);
142
143 return account;
144 }
145
146 #endregion
147 }
148}
diff --git a/OpenSim/Region/Communications/Hypergrid/HGUserDataPlugin.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs
index 4b8fc26..e430fc7 100644
--- a/OpenSim/Region/Communications/Hypergrid/HGUserDataPlugin.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -24,49 +24,64 @@
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
28using System; 27using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection; 28using System.Reflection;
33using System.Text.RegularExpressions; 29using System.Collections.Generic;
34using System.Xml.Serialization;
35using log4net;
36using Nwc.XmlRpc;
37using OpenMetaverse;
38using OpenSim.Data;
39using OpenSim.Framework; 30using OpenSim.Framework;
40using OpenSim.Framework.Communications; 31using OpenSim.Services.Interfaces;
41using OpenSim.Framework.Communications.Clients; 32using OpenMetaverse;
42using OpenSim.Region.Communications.OGS1; 33using log4net;
43 34
44namespace OpenSim.Region.Communications.Hypergrid 35namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
45{ 36{
46 public class HGUserDataPlugin : OGS1UserDataPlugin 37 public class UserAccountCache
47 { 38 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 39 //private static readonly ILog m_log =
40 // LogManager.GetLogger(
41 // MethodBase.GetCurrentMethod().DeclaringType);
42
43 private ICnmCache<UUID, UserAccount> m_UUIDCache;
44 private Dictionary<string, UUID> m_NameCache;
49 45
50 HGUserServices m_UserServices; 46 public UserAccountCache()
51
52 public HGUserDataPlugin()
53 { 47 {
48 // Warning: the size values are a bit fuzzy. What matters
49 // most for this cache is the count value (128 entries).
50 m_UUIDCache = CnmSynchronizedCache<UUID, UserAccount>.Synchronized(new CnmMemoryCache<UUID, UserAccount>(
51 128, 128*512, TimeSpan.FromMinutes(30.0)));
52 m_NameCache = new Dictionary<string, UUID>(); // this one is unbound
54 } 53 }
55 54
56 public HGUserDataPlugin(CommunicationsManager commsManager, HGUserServices userServices) 55 public void Cache(UserAccount account)
57 { 56 {
58 m_log.DebugFormat("[HG USER SERVICES]: {0} initialized", Name); 57 m_UUIDCache.Set(account.PrincipalID, account, 512);
59 m_commsManager = commsManager; 58 m_NameCache[account.Name] = account.PrincipalID;
60 m_UserServices = userServices; 59
60 //m_log.DebugFormat("[USER CACHE]: cached user {0} {1}", account.FirstName, account.LastName);
61 } 61 }
62 62
63 protected override string GetUserServerURL(UUID userID) 63 public UserAccount Get(UUID userID)
64 { 64 {
65 string url = string.Empty; 65 UserAccount account = null;
66 if (m_UserServices.IsForeignUser(userID, out url)) 66 if (m_UUIDCache.TryGetValue(userID, out account))
67 return url; 67 {
68 return m_commsManager.NetworkServersInfo.UserURL; 68 //m_log.DebugFormat("[USER CACHE]: Account {0} {1} found in cache", account.FirstName, account.LastName);
69 return account;
70 }
71
72 return null;
69 } 73 }
70 74
75 public UserAccount Get(string name)
76 {
77 if (!m_NameCache.ContainsKey(name))
78 return null;
79
80 UserAccount account = null;
81 if (m_UUIDCache.TryGetValue(m_NameCache[name], out account))
82 return account;
83
84 return null;
85 }
71 } 86 }
72} 87}
diff --git a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs
index 73f7ae3..c355b13 100644
--- a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs
+++ b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs
@@ -33,7 +33,6 @@ using Nini.Config;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
36using OpenSim.Framework.Communications.Cache;
37using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
39using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
@@ -109,7 +108,7 @@ namespace OpenSim.Region.CoreModules.World
109 { 108 {
110 foreach (Scene s in m_SceneList) 109 foreach (Scene s in m_SceneList)
111 { 110 {
112 if(!ProcessCommand(s, cmd)) 111 if (!ProcessCommand(s, cmd))
113 break; 112 break;
114 } 113 }
115 } 114 }
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index c7c9778..14bab6e 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -38,10 +38,11 @@ using OpenMetaverse;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Serialization; 39using OpenSim.Framework.Serialization;
40using OpenSim.Framework.Serialization.External; 40using OpenSim.Framework.Serialization.External;
41using OpenSim.Framework.Communications.Cache; 41
42using OpenSim.Region.CoreModules.World.Terrain; 42using OpenSim.Region.CoreModules.World.Terrain;
43using OpenSim.Region.Framework.Interfaces; 43using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.Framework.Scenes; 44using OpenSim.Region.Framework.Scenes;
45using OpenSim.Services.Interfaces;
45 46
46namespace OpenSim.Region.CoreModules.World.Archiver 47namespace OpenSim.Region.CoreModules.World.Archiver
47{ 48{
@@ -73,7 +74,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver
73 public ArchiveReadRequest(Scene scene, string loadPath, bool merge, Guid requestId) 74 public ArchiveReadRequest(Scene scene, string loadPath, bool merge, Guid requestId)
74 { 75 {
75 m_scene = scene; 76 m_scene = scene;
76 m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress); 77
78 try
79 {
80 m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress);
81 }
82 catch (EntryPointNotFoundException e)
83 {
84 m_log.ErrorFormat(
85 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
86 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
87 m_log.Error(e);
88 }
89
77 m_errorMessage = String.Empty; 90 m_errorMessage = String.Empty;
78 m_merge = merge; 91 m_merge = merge;
79 m_requestId = requestId; 92 m_requestId = requestId;
@@ -181,10 +194,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
181 194
182 // Try to retain the original creator/owner/lastowner if their uuid is present on this grid 195 // Try to retain the original creator/owner/lastowner if their uuid is present on this grid
183 // otherwise, use the master avatar uuid instead 196 // otherwise, use the master avatar uuid instead
184 UUID masterAvatarId = m_scene.RegionInfo.MasterAvatarAssignedUUID;
185
186 if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero)
187 masterAvatarId = m_scene.RegionInfo.EstateSettings.EstateOwner;
188 197
189 // Reload serialized parcels 198 // Reload serialized parcels
190 m_log.InfoFormat("[ARCHIVER]: Loading {0} parcels. Please wait.", serialisedParcels.Count); 199 m_log.InfoFormat("[ARCHIVER]: Loading {0} parcels. Please wait.", serialisedParcels.Count);
@@ -193,7 +202,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
193 { 202 {
194 LandData parcel = LandDataSerializer.Deserialize(serialisedParcel); 203 LandData parcel = LandDataSerializer.Deserialize(serialisedParcel);
195 if (!ResolveUserUuid(parcel.OwnerID)) 204 if (!ResolveUserUuid(parcel.OwnerID))
196 parcel.OwnerID = masterAvatarId; 205 parcel.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
197 landData.Add(parcel); 206 landData.Add(parcel);
198 } 207 }
199 m_scene.EventManager.TriggerIncomingLandDataFromStorage(landData); 208 m_scene.EventManager.TriggerIncomingLandDataFromStorage(landData);
@@ -232,13 +241,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver
232 foreach (SceneObjectPart part in sceneObject.Children.Values) 241 foreach (SceneObjectPart part in sceneObject.Children.Values)
233 { 242 {
234 if (!ResolveUserUuid(part.CreatorID)) 243 if (!ResolveUserUuid(part.CreatorID))
235 part.CreatorID = masterAvatarId; 244 part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
236 245
237 if (!ResolveUserUuid(part.OwnerID)) 246 if (!ResolveUserUuid(part.OwnerID))
238 part.OwnerID = masterAvatarId; 247 part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
239 248
240 if (!ResolveUserUuid(part.LastOwnerID)) 249 if (!ResolveUserUuid(part.LastOwnerID))
241 part.LastOwnerID = masterAvatarId; 250 part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
242 251
243 // And zap any troublesome sit target information 252 // And zap any troublesome sit target information
244 part.SitTargetOrientation = new Quaternion(0, 0, 0, 1); 253 part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
@@ -253,11 +262,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver
253 { 262 {
254 if (!ResolveUserUuid(kvp.Value.OwnerID)) 263 if (!ResolveUserUuid(kvp.Value.OwnerID))
255 { 264 {
256 kvp.Value.OwnerID = masterAvatarId; 265 if (!ResolveUserUuid(kvp.Value.OwnerID))
257 } 266 {
258 if (!ResolveUserUuid(kvp.Value.CreatorID)) 267 kvp.Value.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
259 { 268 }
260 kvp.Value.CreatorID = masterAvatarId; 269 if (!ResolveUserUuid(kvp.Value.CreatorID))
270 {
271 kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
272 }
261 } 273 }
262 } 274 }
263 part.TaskInventory.LockItemsForRead(false); 275 part.TaskInventory.LockItemsForRead(false);
@@ -291,8 +303,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
291 { 303 {
292 if (!m_validUserUuids.ContainsKey(uuid)) 304 if (!m_validUserUuids.ContainsKey(uuid))
293 { 305 {
294 CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(uuid); 306 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid);
295 if (profile != null && profile.UserProfile != null) 307 if (account != null)
296 m_validUserUuids.Add(uuid, true); 308 m_validUserUuids.Add(uuid, true);
297 else 309 else
298 m_validUserUuids.Add(uuid, false); 310 m_validUserUuids.Add(uuid, false);
@@ -337,7 +349,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
337 349
338 //m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); 350 //m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
339 351
340 AssetBase asset = new AssetBase(new UUID(uuid), String.Empty, assetType); 352 AssetBase asset = new AssetBase(new UUID(uuid), String.Empty, assetType, UUID.Zero.ToString());
341 asset.Data = data; 353 asset.Data = data;
342 354
343 // We're relying on the asset service to do the sensible thing and not store the asset if it already 355 // We're relying on the asset service to do the sensible thing and not store the asset if it already
@@ -422,6 +434,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
422 currentRegionSettings.TerrainTexture4 = loadedRegionSettings.TerrainTexture4; 434 currentRegionSettings.TerrainTexture4 = loadedRegionSettings.TerrainTexture4;
423 currentRegionSettings.UseEstateSun = loadedRegionSettings.UseEstateSun; 435 currentRegionSettings.UseEstateSun = loadedRegionSettings.UseEstateSun;
424 currentRegionSettings.WaterHeight = loadedRegionSettings.WaterHeight; 436 currentRegionSettings.WaterHeight = loadedRegionSettings.WaterHeight;
437
438 currentRegionSettings.Save();
425 439
426 IEstateModule estateModule = m_scene.RequestModuleInterface<IEstateModule>(); 440 IEstateModule estateModule = m_scene.RequestModuleInterface<IEstateModule>();
427 441
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
index 71bfe57..b61b341 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -65,7 +65,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver
65 public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId) 65 public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId)
66 { 66 {
67 m_scene = scene; 67 m_scene = scene;
68 m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress); 68
69 try
70 {
71 m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress);
72 }
73 catch (EntryPointNotFoundException e)
74 {
75 m_log.ErrorFormat(
76 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
77 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
78 m_log.Error(e);
79 }
80
69 m_requestId = requestId; 81 m_requestId = requestId;
70 } 82 }
71 83
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs
index 2d2c570..2c04008 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs
@@ -158,7 +158,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
158 158
159 m_log.DebugFormat("[ARCHIVER]: Importing asset {0}", filename); 159 m_log.DebugFormat("[ARCHIVER]: Importing asset {0}", filename);
160 160
161 AssetBase asset = new AssetBase(new UUID(filename), metadata.Name, metadata.AssetType); 161 AssetBase asset = new AssetBase(new UUID(filename), metadata.Name, metadata.AssetType, UUID.Zero.ToString());
162 asset.Description = metadata.Description; 162 asset.Description = metadata.Description;
163 asset.Data = data; 163 asset.Data = data;
164 164
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index c3e57f0..de16d89 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -34,7 +34,7 @@ using NUnit.Framework;
34using NUnit.Framework.SyntaxHelpers; 34using NUnit.Framework.SyntaxHelpers;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Communications.Cache; 37
38using OpenSim.Framework.Serialization; 38using OpenSim.Framework.Serialization;
39using OpenSim.Framework.Serialization.External; 39using OpenSim.Framework.Serialization.External;
40using OpenSim.Region.CoreModules.World.Serialiser; 40using OpenSim.Region.CoreModules.World.Serialiser;
@@ -63,7 +63,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
63 SerialiserModule serialiserModule = new SerialiserModule(); 63 SerialiserModule serialiserModule = new SerialiserModule();
64 TerrainModule terrainModule = new TerrainModule(); 64 TerrainModule terrainModule = new TerrainModule();
65 65
66 m_scene = SceneSetupHelpers.SetupScene("scene1"); 66 m_scene = SceneSetupHelpers.SetupScene("useraccounts");
67 SceneSetupHelpers.SetupSceneModules(m_scene, m_archiverModule, serialiserModule, terrainModule); 67 SceneSetupHelpers.SetupSceneModules(m_scene, m_archiverModule, serialiserModule, terrainModule);
68 } 68 }
69 69
@@ -99,7 +99,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
99 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); 99 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
100 Vector3 offsetPosition = new Vector3(5, 10, 15); 100 Vector3 offsetPosition = new Vector3(5, 10, 15);
101 101
102 return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName }; 102 return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName };
103 } 103 }
104 104
105 protected SceneObjectPart CreateSceneObjectPart2() 105 protected SceneObjectPart CreateSceneObjectPart2()
@@ -112,7 +112,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
112 Vector3 offsetPosition = new Vector3(20, 25, 30); 112 Vector3 offsetPosition = new Vector3(20, 25, 30);
113 113
114 return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName }; 114 return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName };
115 } 115 }
116 116
117 /// <summary> 117 /// <summary>
118 /// Test saving a V0.2 OpenSim Region Archive. 118 /// Test saving a V0.2 OpenSim Region Archive.
@@ -231,7 +231,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
231 foreach (string name in names) 231 foreach (string name in names)
232 { 232 {
233 if (name.EndsWith(".Resources.test-sound.wav")) 233 if (name.EndsWith(".Resources.test-sound.wav"))
234 soundDataResourceName = name; 234 soundDataResourceName = name;
235 } 235 }
236 Assert.That(soundDataResourceName, Is.Not.Null); 236 Assert.That(soundDataResourceName, Is.Not.Null);
237 237
@@ -259,7 +259,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
259 = new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid, Name = soundItemName }; 259 = new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid, Name = soundItemName };
260 part1.Inventory.AddInventoryItem(item1, true); 260 part1.Inventory.AddInventoryItem(item1, true);
261 } 261 }
262 } 262 }
263 263
264 m_scene.AddNewSceneObject(object1, false); 264 m_scene.AddNewSceneObject(object1, false);
265 265
@@ -306,15 +306,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
306 /// Test loading the region settings of a V0.2 OpenSim Region Archive. 306 /// Test loading the region settings of a V0.2 OpenSim Region Archive.
307 /// </summary> 307 /// </summary>
308 [Test] 308 [Test]
309 public void TestLoadOarV0_2RegionSettings() 309 public void TestLoadOarV0_2RegionSettings()
310 { 310 {
311 TestHelper.InMethod(); 311 TestHelper.InMethod();
312 //log4net.Config.XmlConfigurator.Configure(); 312 //log4net.Config.XmlConfigurator.Configure();
313 313
314 MemoryStream archiveWriteStream = new MemoryStream(); 314 MemoryStream archiveWriteStream = new MemoryStream();
315 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); 315 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
316 316
317 tar.WriteDir(ArchiveConstants.TERRAINS_PATH); 317 tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
318 tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile()); 318 tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile());
319 319
320 RegionSettings rs = new RegionSettings(); 320 RegionSettings rs = new RegionSettings();
@@ -329,11 +329,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
329 rs.DisablePhysics = true; 329 rs.DisablePhysics = true;
330 rs.DisableScripts = true; 330 rs.DisableScripts = true;
331 rs.Elevation1NW = 15.9; 331 rs.Elevation1NW = 15.9;
332 rs.Elevation1NE = 45.3; 332 rs.Elevation1NE = 45.3;
333 rs.Elevation1SE = 49; 333 rs.Elevation1SE = 49;
334 rs.Elevation1SW = 1.9; 334 rs.Elevation1SW = 1.9;
335 rs.Elevation2NW = 4.5; 335 rs.Elevation2NW = 4.5;
336 rs.Elevation2NE = 19.2; 336 rs.Elevation2NE = 19.2;
337 rs.Elevation2SE = 9.2; 337 rs.Elevation2SE = 9.2;
338 rs.Elevation2SW = 2.1; 338 rs.Elevation2SW = 2.1;
339 rs.FixedSun = true; 339 rs.FixedSun = true;
@@ -411,7 +411,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
411// Quaternion part2RotationOffset = new Quaternion(60, 70, 80, 90); 411// Quaternion part2RotationOffset = new Quaternion(60, 70, 80, 90);
412// Vector3 part2OffsetPosition = new Vector3(20, 25, 30); 412// Vector3 part2OffsetPosition = new Vector3(20, 25, 30);
413 413
414 SceneObjectPart part2 = CreateSceneObjectPart2(); 414 SceneObjectPart part2 = CreateSceneObjectPart2();
415 415
416 // Create an oar file that we can use for the merge 416 // Create an oar file that we can use for the merge
417 { 417 {
@@ -420,9 +420,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
420 TerrainModule terrainModule = new TerrainModule(); 420 TerrainModule terrainModule = new TerrainModule();
421 421
422 Scene scene = SceneSetupHelpers.SetupScene(); 422 Scene scene = SceneSetupHelpers.SetupScene();
423 SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); 423 SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule);
424 424
425 m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); 425 m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false);
426 426
427 // Write out this scene 427 // Write out this scene
428 scene.EventManager.OnOarFileSaved += SaveCompleted; 428 scene.EventManager.OnOarFileSaved += SaveCompleted;
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 03da269..e3bab2d 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -57,10 +57,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
57 if (!m_scene.RegionInfo.EstateSettings.UseGlobalTime) 57 if (!m_scene.RegionInfo.EstateSettings.UseGlobalTime)
58 sun=(uint)(m_scene.RegionInfo.EstateSettings.SunPosition*1024.0) + 0x1800; 58 sun=(uint)(m_scene.RegionInfo.EstateSettings.SunPosition*1024.0) + 0x1800;
59 UUID estateOwner; 59 UUID estateOwner;
60 if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) 60 estateOwner = m_scene.RegionInfo.EstateSettings.EstateOwner;
61 estateOwner = m_scene.RegionInfo.EstateSettings.EstateOwner;
62 else
63 estateOwner = m_scene.RegionInfo.MasterAvatarAssignedUUID;
64 61
65 if (m_scene.Permissions.IsGod(remote_client.AgentId)) 62 if (m_scene.Permissions.IsGod(remote_client.AgentId))
66 estateOwner = remote_client.AgentId; 63 estateOwner = remote_client.AgentId;
@@ -241,8 +238,6 @@ namespace OpenSim.Region.CoreModules.World.Estate
241 238
242 if (user == m_scene.RegionInfo.EstateSettings.EstateOwner) 239 if (user == m_scene.RegionInfo.EstateSettings.EstateOwner)
243 return; // never process EO 240 return; // never process EO
244 if (user == m_scene.RegionInfo.MasterAvatarAssignedUUID)
245 return; // never process owner
246 241
247 if ((estateAccessType & 4) != 0) // User add 242 if ((estateAccessType & 4) != 0) // User add
248 { 243 {
@@ -709,16 +704,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
709 lsri.TaskID = sog.UUID; 704 lsri.TaskID = sog.UUID;
710 lsri.TaskLocalID = sog.LocalId; 705 lsri.TaskLocalID = sog.LocalId;
711 lsri.TaskName = sog.GetPartName(obj); 706 lsri.TaskName = sog.GetPartName(obj);
712 if (m_scene.CommsManager.UUIDNameCachedTest(sog.OwnerID)) 707 lsri.OwnerName = "waiting";
713 { 708 lock (uuidNameLookupList)
714 lsri.OwnerName = m_scene.CommsManager.UUIDNameRequestString(sog.OwnerID); 709 uuidNameLookupList.Add(sog.OwnerID);
715 }
716 else
717 {
718 lsri.OwnerName = "waiting";
719 lock (uuidNameLookupList)
720 uuidNameLookupList.Add(sog.OwnerID);
721 }
722 710
723 if (filter.Length != 0) 711 if (filter.Length != 0)
724 { 712 {
@@ -769,7 +757,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
769 for (int i = 0; i < uuidarr.Length; i++) 757 for (int i = 0; i < uuidarr.Length; i++)
770 { 758 {
771 // string lookupname = m_scene.CommsManager.UUIDNameRequestString(uuidarr[i]); 759 // string lookupname = m_scene.CommsManager.UUIDNameRequestString(uuidarr[i]);
772 m_scene.CommsManager.UUIDNameRequestString(uuidarr[i]); 760 m_scene.GetUserName(uuidarr[i]);
773 // we drop it. It gets cached though... so we're ready for the next request. 761 // we drop it. It gets cached though... so we're ready for the next request.
774 } 762 }
775 } 763 }
@@ -808,14 +796,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
808 args.waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight; 796 args.waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight;
809 args.regionFlags = GetRegionFlags(); 797 args.regionFlags = GetRegionFlags();
810 args.regionName = m_scene.RegionInfo.RegionName; 798 args.regionName = m_scene.RegionInfo.RegionName;
811 if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) 799 args.SimOwner = m_scene.RegionInfo.EstateSettings.EstateOwner;
812 args.SimOwner = m_scene.RegionInfo.EstateSettings.EstateOwner;
813 else
814 args.SimOwner = m_scene.RegionInfo.MasterAvatarAssignedUUID;
815
816 // Fudge estate owner
817 //if (m_scene.Permissions.IsGod(remoteClient.AgentId))
818 // args.SimOwner = remoteClient.AgentId;
819 800
820 args.terrainBase0 = UUID.Zero; 801 args.terrainBase0 = UUID.Zero;
821 args.terrainBase1 = UUID.Zero; 802 args.terrainBase1 = UUID.Zero;
@@ -1194,8 +1175,6 @@ namespace OpenSim.Region.CoreModules.World.Estate
1194 1175
1195 public bool IsManager(UUID avatarID) 1176 public bool IsManager(UUID avatarID)
1196 { 1177 {
1197 if (avatarID == m_scene.RegionInfo.MasterAvatarAssignedUUID)
1198 return true;
1199 if (avatarID == m_scene.RegionInfo.EstateSettings.EstateOwner) 1178 if (avatarID == m_scene.RegionInfo.EstateSettings.EstateOwner)
1200 return true; 1179 return true;
1201 1180
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs b/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs
index 2ff635b..b8d8b10 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs
@@ -52,7 +52,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
52 52
53 public EstateTerrainXferHandler(IClientAPI pRemoteClient, string pClientFilename) 53 public EstateTerrainXferHandler(IClientAPI pRemoteClient, string pClientFilename)
54 { 54 {
55 m_asset = new AssetBase(UUID.Zero, pClientFilename, type); 55 m_asset = new AssetBase(UUID.Zero, pClientFilename, type, pRemoteClient.AgentId.ToString());
56 m_asset.Data = new byte[0]; 56 m_asset.Data = new byte[0];
57 m_asset.Description = "empty"; 57 m_asset.Description = "empty";
58 m_asset.Local = true; 58 m_asset.Local = true;
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 9be94ce..ef3e722 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -239,10 +239,7 @@ namespace OpenSim.Region.CoreModules.World.Land
239 ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); 239 ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene);
240 240
241 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); 241 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
242 if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) 242 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
243 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
244 else
245 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID;
246 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); 243 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch();
247 AddLandObject(fullSimParcel); 244 AddLandObject(fullSimParcel);
248 } 245 }
@@ -1214,10 +1211,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1214 { 1211 {
1215 if (m_scene.Permissions.CanAbandonParcel(remote_client.AgentId, land)) 1212 if (m_scene.Permissions.CanAbandonParcel(remote_client.AgentId, land))
1216 { 1213 {
1217 if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) 1214 land.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
1218 land.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
1219 else
1220 land.LandData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID;
1221 land.LandData.GroupID = UUID.Zero; 1215 land.LandData.GroupID = UUID.Zero;
1222 land.LandData.IsGroupOwned = false; 1216 land.LandData.IsGroupOwned = false;
1223 m_scene.ForEachClient(SendParcelOverlay); 1217 m_scene.ForEachClient(SendParcelOverlay);
@@ -1238,10 +1232,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1238 { 1232 {
1239 if (m_scene.Permissions.CanReclaimParcel(remote_client.AgentId, land)) 1233 if (m_scene.Permissions.CanReclaimParcel(remote_client.AgentId, land))
1240 { 1234 {
1241 if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) 1235 land.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
1242 land.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
1243 else
1244 land.LandData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID;
1245 land.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); 1236 land.LandData.ClaimDate = Util.UnixTimeSinceEpoch();
1246 land.LandData.GroupID = UUID.Zero; 1237 land.LandData.GroupID = UUID.Zero;
1247 land.LandData.IsGroupOwned = false; 1238 land.LandData.IsGroupOwned = false;
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 1533462..4652d70 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -32,7 +32,7 @@ using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache; 35
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
@@ -95,6 +95,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions
95 95
96 protected Scene m_scene; 96 protected Scene m_scene;
97 97
98 private InventoryFolderImpl m_libraryRootFolder;
99 protected InventoryFolderImpl LibraryRootFolder
100 {
101 get
102 {
103 if (m_libraryRootFolder != null)
104 return m_libraryRootFolder;
105
106 ILibraryService lib = m_scene.RequestModuleInterface<ILibraryService>();
107 if (lib != null)
108 {
109 m_libraryRootFolder = lib.LibraryRootFolder;
110 }
111 return m_libraryRootFolder;
112 }
113 }
114
98 #region Constants 115 #region Constants
99 // These are here for testing. They will be taken out 116 // These are here for testing. They will be taken out
100 117
@@ -462,12 +479,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions
462 { 479 {
463 if (user == UUID.Zero) return false; 480 if (user == UUID.Zero) return false;
464 481
465 if (m_scene.RegionInfo.MasterAvatarAssignedUUID != UUID.Zero)
466 {
467 if (m_RegionOwnerIsGod && (m_scene.RegionInfo.MasterAvatarAssignedUUID == user))
468 return true;
469 }
470
471 if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) 482 if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero)
472 { 483 {
473 if (m_scene.RegionInfo.EstateSettings.EstateOwner == user && m_RegionOwnerIsGod) 484 if (m_scene.RegionInfo.EstateSettings.EstateOwner == user && m_RegionOwnerIsGod)
@@ -479,10 +490,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions
479 490
480 if (m_allowGridGods) 491 if (m_allowGridGods)
481 { 492 {
482 CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(user); 493 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, user);
483 if (profile != null && profile.UserProfile != null) 494 if (account != null)
484 { 495 {
485 if (profile.UserProfile.GodLevel >= 200) 496 if (account.UserLevel >= 200)
486 return true; 497 return true;
487 } 498 }
488 } 499 }
@@ -499,13 +510,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions
499 if (m_friendsModule == null) 510 if (m_friendsModule == null)
500 return false; 511 return false;
501 512
502 List<FriendListItem> profile = m_friendsModule.GetUserFriends(user); 513 uint friendPerms = m_friendsModule.GetFriendPerms(user, objectOwner);
514 if ((friendPerms & (uint)FriendRights.CanModifyObjects) != 0)
515 return true;
503 516
504 foreach (FriendListItem item in profile)
505 {
506 if (item.Friend == objectOwner && (item.FriendPerms & (uint)FriendRights.CanModifyObjects) != 0)
507 return true;
508 }
509 return false; 517 return false;
510 } 518 }
511 519
@@ -1011,9 +1019,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1011 IInventoryService invService = m_scene.InventoryService; 1019 IInventoryService invService = m_scene.InventoryService;
1012 InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user); 1020 InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user);
1013 assetRequestItem = invService.GetItem(assetRequestItem); 1021 assetRequestItem = invService.GetItem(assetRequestItem);
1014 if (assetRequestItem == null) // Library item 1022 if (assetRequestItem == null && LibraryRootFolder != null) // Library item
1015 { 1023 {
1016 assetRequestItem = scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard); 1024 assetRequestItem = LibraryRootFolder.FindItem(notecard);
1017 1025
1018 if (assetRequestItem != null) // Implicitly readable 1026 if (assetRequestItem != null) // Implicitly readable
1019 return true; 1027 return true;
@@ -1431,9 +1439,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1431 IInventoryService invService = m_scene.InventoryService; 1439 IInventoryService invService = m_scene.InventoryService;
1432 InventoryItemBase assetRequestItem = new InventoryItemBase(script, user); 1440 InventoryItemBase assetRequestItem = new InventoryItemBase(script, user);
1433 assetRequestItem = invService.GetItem(assetRequestItem); 1441 assetRequestItem = invService.GetItem(assetRequestItem);
1434 if (assetRequestItem == null) // Library item 1442 if (assetRequestItem == null && LibraryRootFolder != null) // Library item
1435 { 1443 {
1436 assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(script); 1444 assetRequestItem = LibraryRootFolder.FindItem(script);
1437 1445
1438 if (assetRequestItem != null) // Implicitly readable 1446 if (assetRequestItem != null) // Implicitly readable
1439 return true; 1447 return true;
@@ -1526,9 +1534,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1526 IInventoryService invService = m_scene.InventoryService; 1534 IInventoryService invService = m_scene.InventoryService;
1527 InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user); 1535 InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user);
1528 assetRequestItem = invService.GetItem(assetRequestItem); 1536 assetRequestItem = invService.GetItem(assetRequestItem);
1529 if (assetRequestItem == null) // Library item 1537 if (assetRequestItem == null && LibraryRootFolder != null) // Library item
1530 { 1538 {
1531 assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard); 1539 assetRequestItem = LibraryRootFolder.FindItem(notecard);
1532 1540
1533 if (assetRequestItem != null) // Implicitly readable 1541 if (assetRequestItem != null) // Implicitly readable
1534 return true; 1542 return true;
diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
index 37f1f2e..1f5a4ff 100644
--- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
60 } 60 }
61 61
62 public virtual void PlayAttachedSound( 62 public virtual void PlayAttachedSound(
63 UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags) 63 UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius)
64 { 64 {
65 foreach (ScenePresence p in m_scene.GetAvatars()) 65 foreach (ScenePresence p in m_scene.GetAvatars())
66 { 66 {
@@ -69,14 +69,17 @@ namespace OpenSim.Region.CoreModules.World.Sound
69 continue; 69 continue;
70 70
71 // Scale by distance 71 // Scale by distance
72 gain = (float)((double)gain*((100.0 - dis) / 100.0)); 72 if (radius == 0)
73 gain = (float)((double)gain * ((100.0 - dis) / 100.0));
74 else
75 gain = (float)((double)gain * ((radius - dis) / radius));
73 76
74 p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)gain, flags); 77 p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)gain, flags);
75 } 78 }
76 } 79 }
77 80
78 public virtual void TriggerSound( 81 public virtual void TriggerSound(
79 UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle) 82 UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius)
80 { 83 {
81 foreach (ScenePresence p in m_scene.GetAvatars()) 84 foreach (ScenePresence p in m_scene.GetAvatars())
82 { 85 {
@@ -85,7 +88,10 @@ namespace OpenSim.Region.CoreModules.World.Sound
85 continue; 88 continue;
86 89
87 // Scale by distance 90 // Scale by distance
88 gain = (float)((double)gain*((100.0 - dis) / 100.0)); 91 if (radius == 0)
92 gain = (float)((double)gain * ((100.0 - dis) / 100.0));
93 else
94 gain = (float)((double)gain * ((radius - dis) / radius));
89 95
90 p.ControllingClient.SendTriggeredSound( 96 p.ControllingClient.SendTriggeredSound(
91 soundId, ownerID, objectID, parentID, handle, position, (float)gain); 97 soundId, ownerID, objectID, parentID, handle, position, (float)gain);
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index a40828b..1e7ea7b 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -84,6 +84,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
84 private ITerrainChannel m_revert; 84 private ITerrainChannel m_revert;
85 private Scene m_scene; 85 private Scene m_scene;
86 private volatile bool m_tainted; 86 private volatile bool m_tainted;
87 private readonly UndoStack<LandUndoState> m_undo = new UndoStack<LandUndoState>(5);
87 88
88 #region ICommandableModule Members 89 #region ICommandableModule Members
89 90
@@ -174,6 +175,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain
174 175
175 #region ITerrainModule Members 176 #region ITerrainModule Members
176 177
178 public void UndoTerrain(ITerrainChannel channel)
179 {
180 m_channel = channel;
181 }
182
177 /// <summary> 183 /// <summary>
178 /// Loads a terrain file from disk and installs it in the scene. 184 /// Loads a terrain file from disk and installs it in the scene.
179 /// </summary> 185 /// </summary>
@@ -574,6 +580,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
574 { 580 {
575 client.OnModifyTerrain += client_OnModifyTerrain; 581 client.OnModifyTerrain += client_OnModifyTerrain;
576 client.OnBakeTerrain += client_OnBakeTerrain; 582 client.OnBakeTerrain += client_OnBakeTerrain;
583 client.OnLandUndo += client_OnLandUndo;
577 } 584 }
578 585
579 /// <summary> 586 /// <summary>
@@ -664,6 +671,19 @@ namespace OpenSim.Region.CoreModules.World.Terrain
664 return changesLimited; 671 return changesLimited;
665 } 672 }
666 673
674 private void client_OnLandUndo(IClientAPI client)
675 {
676 lock (m_undo)
677 {
678 if (m_undo.Count > 0)
679 {
680 LandUndoState goback = m_undo.Pop();
681 if (goback != null)
682 goback.PlaybackState();
683 }
684 }
685 }
686
667 /// <summary> 687 /// <summary>
668 /// Sends a copy of the current terrain to the scenes clients 688 /// Sends a copy of the current terrain to the scenes clients
669 /// </summary> 689 /// </summary>
@@ -718,6 +738,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
718 } 738 }
719 if (allowed) 739 if (allowed)
720 { 740 {
741 StoreUndoState();
721 m_painteffects[(StandardTerrainEffects) action].PaintEffect( 742 m_painteffects[(StandardTerrainEffects) action].PaintEffect(
722 m_channel, allowMask, west, south, height, size, seconds); 743 m_channel, allowMask, west, south, height, size, seconds);
723 744
@@ -758,6 +779,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
758 779
759 if (allowed) 780 if (allowed)
760 { 781 {
782 StoreUndoState();
761 m_floodeffects[(StandardTerrainEffects) action].FloodEffect( 783 m_floodeffects[(StandardTerrainEffects) action].FloodEffect(
762 m_channel, fillArea, size); 784 m_channel, fillArea, size);
763 785
@@ -782,6 +804,25 @@ namespace OpenSim.Region.CoreModules.World.Terrain
782 } 804 }
783 } 805 }
784 806
807 private void StoreUndoState()
808 {
809 lock (m_undo)
810 {
811 if (m_undo.Count > 0)
812 {
813 LandUndoState last = m_undo.Peek();
814 if (last != null)
815 {
816 if (last.Compare(m_channel))
817 return;
818 }
819 }
820
821 LandUndoState nUndo = new LandUndoState(this, m_channel);
822 m_undo.Push(nUndo);
823 }
824 }
825
785 #region Console Commands 826 #region Console Commands
786 827
787 private void InterfaceLoadFile(Object[] args) 828 private void InterfaceLoadFile(Object[] args)
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index be46fa5..56b50dc 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -32,7 +32,6 @@ using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Region.Framework.Scenes.Hypergrid;
36using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
37using GridRegion = OpenSim.Services.Interfaces.GridRegion; 36using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38 37
@@ -104,25 +103,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
104 if (info != null) regionInfos.Add(info); 103 if (info != null) regionInfos.Add(info);
105 } 104 }
106 105
107 if ((regionInfos.Count == 0) && IsHypergridOn())
108 {
109 // OK, we tried but there are no regions matching that name.
110 // Let's check quickly if this is a domain name, and if so link to it
111 if (mapName.Contains("."))
112 {
113 // It probably is a domain name. Try to link to it.
114 GridRegion regInfo;
115 Scene cScene = GetClientScene(remoteClient);
116 IHyperlinkService hyperService = cScene.RequestModuleInterface<IHyperlinkService>();
117 if (hyperService != null)
118 {
119 regInfo = hyperService.TryLinkRegion(remoteClient, mapName);
120 if (regInfo != null)
121 regionInfos.Add(regInfo);
122 }
123 }
124 }
125
126 List<MapBlockData> blocks = new List<MapBlockData>(); 106 List<MapBlockData> blocks = new List<MapBlockData>();
127 107
128 MapBlockData data; 108 MapBlockData data;
@@ -158,11 +138,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
158 remoteClient.SendMapBlock(blocks, 0); 138 remoteClient.SendMapBlock(blocks, 0);
159 } 139 }
160 140
161 private bool IsHypergridOn()
162 {
163 return (m_scene.SceneGridService is HGSceneCommunicationService);
164 }
165
166 private Scene GetClientScene(IClientAPI client) 141 private Scene GetClientScene(IClientAPI client)
167 { 142 {
168 foreach (Scene s in m_scenes) 143 foreach (Scene s in m_scenes)
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 44a651f..b63d014 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -1080,7 +1080,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1080 AssetBase asset = new AssetBase( 1080 AssetBase asset = new AssetBase(
1081 m_scene.RegionInfo.RegionSettings.TerrainImageID, 1081 m_scene.RegionInfo.RegionSettings.TerrainImageID,
1082 "terrainImage_" + m_scene.RegionInfo.RegionID.ToString() + "_" + lastMapRefresh.ToString(), 1082 "terrainImage_" + m_scene.RegionInfo.RegionID.ToString() + "_" + lastMapRefresh.ToString(),
1083 (sbyte)AssetType.Texture); 1083 (sbyte)AssetType.Texture,
1084 m_scene.RegionInfo.RegionID.ToString());
1084 asset.Data = data; 1085 asset.Data = data;
1085 asset.Description = m_scene.RegionInfo.RegionName; 1086 asset.Description = m_scene.RegionInfo.RegionName;
1086 asset.Temporary = temporary; 1087 asset.Temporary = temporary;
diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
index 4df9094..6949d7c 100644
--- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
+++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
@@ -101,21 +101,9 @@ namespace OpenSim.Region.DataSnapshot
101 try 101 try
102 { 102 {
103 m_enabled = config.Configs["DataSnapshot"].GetBoolean("index_sims", m_enabled); 103 m_enabled = config.Configs["DataSnapshot"].GetBoolean("index_sims", m_enabled);
104 if (config.Configs["Startup"].GetBoolean("gridmode", false)) 104 IConfig conf = config.Configs["GridService"];
105 { 105 if (conf != null)
106 m_gridinfo.Add( 106 m_gridinfo.Add("gridserverURL", conf.GetString("GridServerURI", "http://127.0.0.1:8003"));
107 "gridserverURL",
108 config.Configs["Network"].GetString(
109 "grid_server_url", "http://127.0.0.1:" + ConfigSettings.DefaultGridServerHttpPort.ToString()));
110 m_gridinfo.Add(
111 "userserverURL",
112 config.Configs["Network"].GetString(
113 "user_server_url", "http://127.0.0.1:" + ConfigSettings.DefaultUserServerHttpPort.ToString()));
114 m_gridinfo.Add(
115 "assetserverURL",
116 config.Configs["Network"].GetString(
117 "asset_server_url", "http://127.0.0.1:" + ConfigSettings.DefaultAssetServerHttpPort.ToString()));
118 }
119 107
120 m_gridinfo.Add( 108 m_gridinfo.Add(
121 "Name", config.Configs["DataSnapshot"].GetString("gridname", "the lost continent of hippo")); 109 "Name", config.Configs["DataSnapshot"].GetString("gridname", "the lost continent of hippo"));
diff --git a/OpenSim/Region/DataSnapshot/EstateSnapshot.cs b/OpenSim/Region/DataSnapshot/EstateSnapshot.cs
index 5fff89f..8da9e8c 100644
--- a/OpenSim/Region/DataSnapshot/EstateSnapshot.cs
+++ b/OpenSim/Region/DataSnapshot/EstateSnapshot.cs
@@ -29,9 +29,10 @@ using System;
29using System.Xml; 29using System.Xml;
30using OpenMetaverse; 30using OpenMetaverse;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Framework.Communications.Cache; 32
33using OpenSim.Region.DataSnapshot.Interfaces; 33using OpenSim.Region.DataSnapshot.Interfaces;
34using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Services.Interfaces;
35 36
36namespace OpenSim.Region.DataSnapshot.Providers 37namespace OpenSim.Region.DataSnapshot.Providers
37{ 38{
@@ -55,21 +56,17 @@ namespace OpenSim.Region.DataSnapshot.Providers
55 //Now in DataSnapshotProvider module form! 56 //Now in DataSnapshotProvider module form!
56 XmlNode estatedata = factory.CreateNode(XmlNodeType.Element, "estate", ""); 57 XmlNode estatedata = factory.CreateNode(XmlNodeType.Element, "estate", "");
57 58
58 UUID ownerid = m_scene.RegionInfo.MasterAvatarAssignedUUID; 59 UUID ownerid = m_scene.RegionInfo.EstateSettings.EstateOwner;
59 if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero)
60 ownerid = m_scene.RegionInfo.EstateSettings.EstateOwner;
61
62 CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(ownerid);
63 60
61 UserAccount userInfo = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerid);
64 //TODO: Change to query userserver about the master avatar UUID ? 62 //TODO: Change to query userserver about the master avatar UUID ?
65 String firstname; 63 String firstname;
66 String lastname; 64 String lastname;
67 65
68 if (userInfo != null) 66 if (userInfo != null)
69 { 67 {
70 UserProfileData userProfile = userInfo.UserProfile; 68 firstname = userInfo.FirstName;
71 firstname = userProfile.FirstName; 69 lastname = userInfo.LastName;
72 lastname = userProfile.SurName;
73 70
74 //TODO: Fix the marshalling system to have less copypasta gruntwork 71 //TODO: Fix the marshalling system to have less copypasta gruntwork
75 XmlNode user = factory.CreateNode(XmlNodeType.Element, "user", ""); 72 XmlNode user = factory.CreateNode(XmlNodeType.Element, "user", "");
diff --git a/OpenSim/Region/DataSnapshot/LandSnapshot.cs b/OpenSim/Region/DataSnapshot/LandSnapshot.cs
index 51eacef..64d29f2 100644
--- a/OpenSim/Region/DataSnapshot/LandSnapshot.cs
+++ b/OpenSim/Region/DataSnapshot/LandSnapshot.cs
@@ -32,11 +32,12 @@ using System.Xml;
32using log4net; 32using log4net;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache; 35
36using OpenSim.Region.CoreModules.World.Land; 36using OpenSim.Region.CoreModules.World.Land;
37using OpenSim.Region.DataSnapshot.Interfaces; 37using OpenSim.Region.DataSnapshot.Interfaces;
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Services.Interfaces;
40 41
41namespace OpenSim.Region.DataSnapshot.Providers 42namespace OpenSim.Region.DataSnapshot.Providers
42{ 43{
@@ -258,8 +259,8 @@ namespace OpenSim.Region.DataSnapshot.Providers
258 try 259 try
259 { 260 {
260 XmlNode username = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); 261 XmlNode username = nodeFactory.CreateNode(XmlNodeType.Element, "name", "");
261 CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userOwnerUUID); 262 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, userOwnerUUID);
262 username.InnerText = profile.UserProfile.FirstName + " " + profile.UserProfile.SurName; 263 username.InnerText = account.FirstName + " " + account.LastName;
263 userblock.AppendChild(username); 264 userblock.AppendChild(username);
264 } 265 }
265 catch (Exception) 266 catch (Exception)
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index 172d012..58e3de9 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -83,7 +83,7 @@ namespace OpenSim.Region.Examples.SimpleModule
83 public event DeRezObject OnDeRezObject; 83 public event DeRezObject OnDeRezObject;
84 public event Action<IClientAPI> OnRegionHandShakeReply; 84 public event Action<IClientAPI> OnRegionHandShakeReply;
85 public event GenericCall2 OnRequestWearables; 85 public event GenericCall2 OnRequestWearables;
86 public event GenericCall2 OnCompleteMovementToRegion; 86 public event GenericCall1 OnCompleteMovementToRegion;
87 public event UpdateAgent OnAgentUpdate; 87 public event UpdateAgent OnAgentUpdate;
88 public event AgentRequestSit OnAgentRequestSit; 88 public event AgentRequestSit OnAgentRequestSit;
89 public event AgentSit OnAgentSit; 89 public event AgentSit OnAgentSit;
@@ -194,6 +194,8 @@ namespace OpenSim.Region.Examples.SimpleModule
194 public event ObjectBuy OnObjectBuy; 194 public event ObjectBuy OnObjectBuy;
195 public event BuyObjectInventory OnBuyObjectInventory; 195 public event BuyObjectInventory OnBuyObjectInventory;
196 public event AgentSit OnUndo; 196 public event AgentSit OnUndo;
197 public event AgentSit OnRedo;
198 public event LandUndo OnLandUndo;
197 199
198 public event ForceReleaseControls OnForceReleaseControls; 200 public event ForceReleaseControls OnForceReleaseControls;
199 201
@@ -351,7 +353,11 @@ namespace OpenSim.Region.Examples.SimpleModule
351 get { return true; } 353 get { return true; }
352 set { } 354 set { }
353 } 355 }
354 356 public bool IsLoggingOut
357 {
358 get { return false; }
359 set { }
360 }
355 public UUID ActiveGroupId 361 public UUID ActiveGroupId
356 { 362 {
357 get { return UUID.Zero; } 363 get { return UUID.Zero; }
@@ -653,7 +659,7 @@ namespace OpenSim.Region.Examples.SimpleModule
653 659
654 if (OnCompleteMovementToRegion != null) 660 if (OnCompleteMovementToRegion != null)
655 { 661 {
656 OnCompleteMovementToRegion(); 662 OnCompleteMovementToRegion(this);
657 } 663 }
658 } 664 }
659 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) 665 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
@@ -1143,5 +1149,9 @@ namespace OpenSim.Region.Examples.SimpleModule
1143 public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals) 1149 public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals)
1144 { 1150 {
1145 } 1151 }
1152
1153 public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
1154 {
1155 }
1146 } 1156 }
1147} 1157}
diff --git a/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs b/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs
index c289cdb..8954513 100644
--- a/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs
+++ b/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs
@@ -65,7 +65,7 @@ namespace OpenSim.Region.Framework.Interfaces
65 /// The UUID of the texture updater, not the texture UUID. If you need the texture UUID then you will need 65 /// The UUID of the texture updater, not the texture UUID. If you need the texture UUID then you will need
66 /// to obtain it directly from the SceneObjectPart. For instance, if ALL_SIDES is set then this texture 66 /// to obtain it directly from the SceneObjectPart. For instance, if ALL_SIDES is set then this texture
67 /// can be obtained as SceneObjectPart.Shape.Textures.DefaultTexture.TextureID 67 /// can be obtained as SceneObjectPart.Shape.Textures.DefaultTexture.TextureID
68 /// </returns> 68 /// </returns>
69 UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams, 69 UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams,
70 int updateTimer, bool SetBlending, byte AlphaValue); 70 int updateTimer, bool SetBlending, byte AlphaValue);
71 71
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index fa9bf19..f58904f 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -150,7 +150,7 @@ namespace OpenSim.Region.Framework.Interfaces
150 /// <returns> 150 /// <returns>
151 /// A list of inventory items with that name. 151 /// A list of inventory items with that name.
152 /// If no inventory item has that name then an empty list is returned. 152 /// If no inventory item has that name then an empty list is returned.
153 /// </returns> 153 /// </returns>
154 IList<TaskInventoryItem> GetInventoryItems(string name); 154 IList<TaskInventoryItem> GetInventoryItems(string name);
155 155
156 /// <summary> 156 /// <summary>
diff --git a/OpenSim/Region/Framework/Interfaces/ITeleportModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
index 5f9129d..e8738c4 100644
--- a/OpenSim/Region/Framework/Interfaces/ITeleportModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
@@ -26,16 +26,35 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using OpenSim.Services.Interfaces;
30using System.Text; 30using GridRegion = OpenSim.Services.Interfaces.GridRegion;
31
31using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
33 35
34namespace OpenSim.Region.Framework.Interfaces 36namespace OpenSim.Region.Framework.Interfaces
35{ 37{
36 public interface ITeleportModule 38 public interface IEntityTransferModule
37 { 39 {
38 void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position, 40 void Teleport(ScenePresence agent, ulong regionHandle, Vector3 position,
39 Vector3 lookAt, uint teleportFlags); 41 Vector3 lookAt, uint teleportFlags);
42
43 void TeleportHome(UUID id, IClientAPI client);
44
45 void Cross(ScenePresence agent, bool isFlying);
46
47 void AgentArrivedAtDestination(UUID agent);
48
49 void EnableChildAgents(ScenePresence agent);
50
51 void EnableChildAgent(ScenePresence agent, GridRegion region);
52
53 void Cross(SceneObjectGroup sog, Vector3 position, bool silent);
54 }
55
56 public interface IUserAgentVerificationModule
57 {
58 bool VerifyClient(AgentCircuitData aCircuit, string token);
40 } 59 }
41} 60}
diff --git a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
index 8386030..0ff7dee 100644
--- a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
@@ -33,19 +33,7 @@ namespace OpenSim.Region.Framework.Interfaces
33{ 33{
34 public interface IFriendsModule 34 public interface IFriendsModule
35 { 35 {
36 /// <summary> 36 uint GetFriendPerms(UUID PrincipalID, UUID FriendID);
37 /// Offer a friendship to a user from the server end rather than by direct initiation from a client. 37 void SendFriendsOnlineIfNeeded(IClientAPI client);
38 /// </summary>
39 /// <param name="fromUserId">
40 /// A user with this id must existing in the user data store, but need not be logged on.
41 /// </param>
42 /// <param name="toUserClient">
43 /// An actually logged in client to which the offer is being made.
44 /// FIXME: This is somewhat too tightly coupled - it should arguably be possible to offer friendships even if the
45 /// receiving user is not currently online.
46 /// </param>
47 /// <param name="offerMessage"></param>
48 void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage);
49 List<FriendListItem> GetUserFriends(UUID agentID);
50 } 38 }
51} 39}
diff --git a/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
new file mode 100644
index 0000000..2401402
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
@@ -0,0 +1,20 @@
1using System;
2using System.Collections.Generic;
3
4using OpenSim.Framework;
5using OpenSim.Region.Framework.Scenes;
6
7using OpenMetaverse;
8
9namespace OpenSim.Region.Framework.Interfaces
10{
11 public interface IInventoryAccessModule
12 {
13 UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data);
14 UUID DeleteToInventory(DeRezAction action, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient);
15 SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart,
16 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
17 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment);
18 void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver);
19 }
20}
diff --git a/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs
index 2d038ce..fbadd91 100644
--- a/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs
@@ -27,7 +27,7 @@
27 27
28using System; 28using System;
29using System.IO; 29using System.IO;
30using OpenSim.Framework.Communications.Cache; 30using OpenSim.Services.Interfaces;
31 31
32namespace OpenSim.Region.Framework.Interfaces 32namespace OpenSim.Region.Framework.Interfaces
33{ 33{
@@ -41,7 +41,7 @@ namespace OpenSim.Region.Framework.Interfaces
41 /// <param name="savePath">The stream to which the archive was saved</param> 41 /// <param name="savePath">The stream to which the archive was saved</param>
42 /// <param name="reportedException">Contains the exception generated if the save did not succeed</param> 42 /// <param name="reportedException">Contains the exception generated if the save did not succeed</param>
43 public delegate void InventoryArchiveSaved( 43 public delegate void InventoryArchiveSaved(
44 Guid id, bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException); 44 Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, Exception reportedException);
45 45
46 public interface IInventoryArchiverModule 46 public interface IInventoryArchiverModule
47 { 47 {
diff --git a/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs b/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs
index 630c6a3..d44c1e1 100644
--- a/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs
@@ -31,13 +31,13 @@ namespace OpenSim.Region.Framework.Interfaces
31{ 31{
32 public struct PresenceInfo 32 public struct PresenceInfo
33 { 33 {
34 public UUID userID; 34 public string UserID;
35 public UUID regionID; 35 public UUID RegionID;
36 36
37 public PresenceInfo(UUID userID, UUID regionID) 37 public PresenceInfo(string userID, UUID regionID)
38 { 38 {
39 this.userID = userID; 39 UserID = userID;
40 this.regionID = regionID; 40 RegionID = regionID;
41 } 41 }
42 } 42 }
43 43
diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs
index 379fabd..6117a80 100644
--- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs
@@ -32,9 +32,9 @@ namespace OpenSim.Region.Framework.Interfaces
32{ 32{
33 public interface ISoundModule 33 public interface ISoundModule
34 { 34 {
35 void PlayAttachedSound(UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags); 35 void PlayAttachedSound(UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius);
36 36
37 void TriggerSound( 37 void TriggerSound(
38 UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle); 38 UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius);
39 } 39 }
40} \ No newline at end of file 40} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs b/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs
index 7caac55..5947afb 100644
--- a/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs
@@ -62,5 +62,7 @@ namespace OpenSim.Region.Framework.Interfaces
62 void SaveToStream(string filename, Stream stream); 62 void SaveToStream(string filename, Stream stream);
63 63
64 void InstallPlugin(string name, ITerrainEffect plug); 64 void InstallPlugin(string name, ITerrainEffect plug);
65
66 void UndoTerrain(ITerrainChannel channel);
65 } 67 }
66} 68}
diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
index 948b9dc..8da99a0 100644
--- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
+++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
@@ -62,7 +62,7 @@ namespace OpenSim.Region.Framework.Interfaces
62 /// <param name="name">name to filter on</param> 62 /// <param name="name">name to filter on</param>
63 /// <param name="id">key to filter on (user given, could be totally faked)</param> 63 /// <param name="id">key to filter on (user given, could be totally faked)</param>
64 /// <param name="msg">msg to filter on</param> 64 /// <param name="msg">msg to filter on</param>
65 /// <returns>number of the scripts handle</returns> 65 /// <returns>number of the scripts handle</returns>
66 int Listen(uint LocalID, UUID itemID, UUID hostID, int channel, string name, UUID id, string msg); 66 int Listen(uint LocalID, UUID itemID, UUID hostID, int channel, string name, UUID id, string msg);
67 67
68 /// <summary> 68 /// <summary>
@@ -77,19 +77,19 @@ namespace OpenSim.Region.Framework.Interfaces
77 /// <param name="channel">channel to sent on</param> 77 /// <param name="channel">channel to sent on</param>
78 /// <param name="name">name of sender (object or avatar)</param> 78 /// <param name="name">name of sender (object or avatar)</param>
79 /// <param name="id">key of sender (object or avatar)</param> 79 /// <param name="id">key of sender (object or avatar)</param>
80 /// <param name="msg">msg to sent</param> 80 /// <param name="msg">msg to sent</param>
81 void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg); 81 void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg);
82 82
83 /// <summary> 83 /// <summary>
84 /// Are there any listen events ready to be dispatched? 84 /// Are there any listen events ready to be dispatched?
85 /// </summary> 85 /// </summary>
86 /// <returns>boolean indication</returns> 86 /// <returns>boolean indication</returns>
87 bool HasMessages(); 87 bool HasMessages();
88 88
89 /// <summary> 89 /// <summary>
90 /// Pop the first availlable listen event from the queue 90 /// Pop the first availlable listen event from the queue
91 /// </summary> 91 /// </summary>
92 /// <returns>ListenerInfo with filter filled in</returns> 92 /// <returns>ListenerInfo with filter filled in</returns>
93 IWorldCommListenerInfo GetNextMessage(); 93 IWorldCommListenerInfo GetNextMessage();
94 94
95 void ListenControl(UUID itemID, int handle, int active); 95 void ListenControl(UUID itemID, int handle, int active);
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index e98f0e7..fd7d44f 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -385,7 +385,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
385 } 385 }
386 } 386 }
387 387
388 AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation); 388 AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation, m_scenePresence.UUID.ToString());
389 Animasset.Data = anim.ToBytes(); 389 Animasset.Data = anim.ToBytes();
390 Animasset.Temporary = true; 390 Animasset.Temporary = true;
391 Animasset.Local = true; 391 Animasset.Local = true;
@@ -419,15 +419,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation
419 { 419 {
420 if (m_scenePresence.IsChildAgent) 420 if (m_scenePresence.IsChildAgent)
421 return; 421 return;
422
423 UUID[] animIDs;
424 int[] sequenceNums;
425 UUID[] objectIDs;
426 422
427 m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); 423 m_scenePresence.Scene.ForEachScenePresence(
428 424 delegate(ScenePresence SP)
429 m_scenePresence.ControllingClient.SendAnimations( 425 {
430 animIDs, sequenceNums, m_scenePresence.ControllingClient.AgentId, objectIDs); 426 SP.Animator.SendAnimPack();
427 });
431 } 428 }
432 429
433 /// <summary> 430 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
index 9a7863b..c08b961 100644
--- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
+++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
@@ -32,6 +32,7 @@ using System.Timers;
32using log4net; 32using log4net;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
35 36
36namespace OpenSim.Region.Framework.Scenes 37namespace OpenSim.Region.Framework.Scenes
37{ 38{
@@ -137,7 +138,9 @@ namespace OpenSim.Region.Framework.Scenes
137 138
138 try 139 try
139 { 140 {
140 m_scene.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient); 141 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
142 if (invAccess != null)
143 invAccess.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient);
141 if (x.permissionToDelete) 144 if (x.permissionToDelete)
142 m_scene.DeleteSceneObject(x.objectGroup, false); 145 m_scene.DeleteSceneObject(x.objectGroup, false);
143 } 146 }
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 22909bc..3cce53d 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -66,13 +66,16 @@ namespace OpenSim.Region.Framework.Scenes
66 public event OnClientConnectCoreDelegate OnClientConnect; 66 public event OnClientConnectCoreDelegate OnClientConnect;
67 67
68 public delegate void OnNewClientDelegate(IClientAPI client); 68 public delegate void OnNewClientDelegate(IClientAPI client);
69 69
70 /// <summary> 70 /// <summary>
71 /// Deprecated in favour of OnClientConnect. 71 /// Deprecated in favour of OnClientConnect.
72 /// Will be marked Obsolete after IClientCore has 100% of IClientAPI interfaces. 72 /// Will be marked Obsolete after IClientCore has 100% of IClientAPI interfaces.
73 /// </summary> 73 /// </summary>
74 public event OnNewClientDelegate OnNewClient; 74 public event OnNewClientDelegate OnNewClient;
75 75
76 public delegate void OnClientLoginDelegate(IClientAPI client);
77 public event OnClientLoginDelegate OnClientLogin;
78
76 public delegate void OnNewPresenceDelegate(ScenePresence presence); 79 public delegate void OnNewPresenceDelegate(ScenePresence presence);
77 80
78 public event OnNewPresenceDelegate OnNewPresence; 81 public event OnNewPresenceDelegate OnNewPresence;
@@ -213,7 +216,7 @@ namespace OpenSim.Region.Framework.Scenes
213 /// Triggered when an object or attachment enters a scene 216 /// Triggered when an object or attachment enters a scene
214 /// </summary> 217 /// </summary>
215 public event OnIncomingSceneObjectDelegate OnIncomingSceneObject; 218 public event OnIncomingSceneObjectDelegate OnIncomingSceneObject;
216 public delegate void OnIncomingSceneObjectDelegate(SceneObjectGroup so); 219 public delegate void OnIncomingSceneObjectDelegate(SceneObjectGroup so);
217 220
218 public delegate void NewInventoryItemUploadComplete(UUID avatarID, UUID assetID, string name, int userlevel); 221 public delegate void NewInventoryItemUploadComplete(UUID avatarID, UUID assetID, string name, int userlevel);
219 222
@@ -417,7 +420,7 @@ namespace OpenSim.Region.Framework.Scenes
417 } 420 }
418 } 421 }
419 } 422 }
420 } 423 }
421 424
422 public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) 425 public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
423 { 426 {
@@ -437,7 +440,7 @@ namespace OpenSim.Region.Framework.Scenes
437 e.Message, e.StackTrace); 440 e.Message, e.StackTrace);
438 } 441 }
439 } 442 }
440 } 443 }
441 } 444 }
442 445
443 public void TriggerOnScriptChangedEvent(uint localID, uint change) 446 public void TriggerOnScriptChangedEvent(uint localID, uint change)
@@ -458,7 +461,7 @@ namespace OpenSim.Region.Framework.Scenes
458 e.Message, e.StackTrace); 461 e.Message, e.StackTrace);
459 } 462 }
460 } 463 }
461 } 464 }
462 } 465 }
463 466
464 public void TriggerOnClientMovement(ScenePresence avatar) 467 public void TriggerOnClientMovement(ScenePresence avatar)
@@ -479,7 +482,7 @@ namespace OpenSim.Region.Framework.Scenes
479 e.Message, e.StackTrace); 482 e.Message, e.StackTrace);
480 } 483 }
481 } 484 }
482 } 485 }
483 } 486 }
484 487
485 public void TriggerPermissionError(UUID user, string reason) 488 public void TriggerPermissionError(UUID user, string reason)
@@ -500,7 +503,7 @@ namespace OpenSim.Region.Framework.Scenes
500 e.Message, e.StackTrace); 503 e.Message, e.StackTrace);
501 } 504 }
502 } 505 }
503 } 506 }
504 } 507 }
505 508
506 public void TriggerOnPluginConsole(string[] args) 509 public void TriggerOnPluginConsole(string[] args)
@@ -521,7 +524,7 @@ namespace OpenSim.Region.Framework.Scenes
521 e.Message, e.StackTrace); 524 e.Message, e.StackTrace);
522 } 525 }
523 } 526 }
524 } 527 }
525 } 528 }
526 529
527 public void TriggerOnFrame() 530 public void TriggerOnFrame()
@@ -542,11 +545,11 @@ namespace OpenSim.Region.Framework.Scenes
542 e.Message, e.StackTrace); 545 e.Message, e.StackTrace);
543 } 546 }
544 } 547 }
545 } 548 }
546 } 549 }
547 550
548 public void TriggerOnNewClient(IClientAPI client) 551 public void TriggerOnNewClient(IClientAPI client)
549 { 552 {
550 OnNewClientDelegate handlerNewClient = OnNewClient; 553 OnNewClientDelegate handlerNewClient = OnNewClient;
551 if (handlerNewClient != null) 554 if (handlerNewClient != null)
552 { 555 {
@@ -563,10 +566,10 @@ namespace OpenSim.Region.Framework.Scenes
563 e.Message, e.StackTrace); 566 e.Message, e.StackTrace);
564 } 567 }
565 } 568 }
566 } 569 }
567 570
568 if (client is IClientCore) 571 if (client is IClientCore)
569 { 572 {
570 OnClientConnectCoreDelegate handlerClientConnect = OnClientConnect; 573 OnClientConnectCoreDelegate handlerClientConnect = OnClientConnect;
571 if (handlerClientConnect != null) 574 if (handlerClientConnect != null)
572 { 575 {
@@ -583,10 +586,32 @@ namespace OpenSim.Region.Framework.Scenes
583 e.Message, e.StackTrace); 586 e.Message, e.StackTrace);
584 } 587 }
585 } 588 }
586 } 589 }
587 } 590 }
588 } 591 }
589 592
593 public void TriggerOnClientLogin(IClientAPI client)
594 {
595 OnClientLoginDelegate handlerClientLogin = OnClientLogin;
596 if (handlerClientLogin != null)
597 {
598 foreach (OnClientLoginDelegate d in handlerClientLogin.GetInvocationList())
599 {
600 try
601 {
602 d(client);
603 }
604 catch (Exception e)
605 {
606 m_log.ErrorFormat(
607 "[EVENT MANAGER]: Delegate for TriggerOnClientLogin failed - continuing. {0} {1}",
608 e.Message, e.StackTrace);
609 }
610 }
611 }
612
613 }
614
590 public void TriggerOnNewPresence(ScenePresence presence) 615 public void TriggerOnNewPresence(ScenePresence presence)
591 { 616 {
592 OnNewPresenceDelegate handlerNewPresence = OnNewPresence; 617 OnNewPresenceDelegate handlerNewPresence = OnNewPresence;
@@ -605,11 +630,11 @@ namespace OpenSim.Region.Framework.Scenes
605 e.Message, e.StackTrace); 630 e.Message, e.StackTrace);
606 } 631 }
607 } 632 }
608 } 633 }
609 } 634 }
610 635
611 public void TriggerOnRemovePresence(UUID agentId) 636 public void TriggerOnRemovePresence(UUID agentId)
612 { 637 {
613 OnRemovePresenceDelegate handlerRemovePresence = OnRemovePresence; 638 OnRemovePresenceDelegate handlerRemovePresence = OnRemovePresence;
614 if (handlerRemovePresence != null) 639 if (handlerRemovePresence != null)
615 { 640 {
@@ -626,11 +651,11 @@ namespace OpenSim.Region.Framework.Scenes
626 e.Message, e.StackTrace); 651 e.Message, e.StackTrace);
627 } 652 }
628 } 653 }
629 } 654 }
630 } 655 }
631 656
632 public void TriggerOnBackup(IRegionDataStore dstore) 657 public void TriggerOnBackup(IRegionDataStore dstore)
633 { 658 {
634 OnBackupDelegate handlerOnAttach = OnBackup; 659 OnBackupDelegate handlerOnAttach = OnBackup;
635 if (handlerOnAttach != null) 660 if (handlerOnAttach != null)
636 { 661 {
@@ -647,7 +672,7 @@ namespace OpenSim.Region.Framework.Scenes
647 e.Message, e.StackTrace); 672 e.Message, e.StackTrace);
648 } 673 }
649 } 674 }
650 } 675 }
651 } 676 }
652 677
653 public void TriggerParcelPrimCountUpdate() 678 public void TriggerParcelPrimCountUpdate()
@@ -668,7 +693,7 @@ namespace OpenSim.Region.Framework.Scenes
668 e.Message, e.StackTrace); 693 e.Message, e.StackTrace);
669 } 694 }
670 } 695 }
671 } 696 }
672 } 697 }
673 698
674 public void TriggerMoneyTransfer(Object sender, MoneyTransferArgs args) 699 public void TriggerMoneyTransfer(Object sender, MoneyTransferArgs args)
@@ -689,7 +714,7 @@ namespace OpenSim.Region.Framework.Scenes
689 e.Message, e.StackTrace); 714 e.Message, e.StackTrace);
690 } 715 }
691 } 716 }
692 } 717 }
693 } 718 }
694 719
695 public void TriggerTerrainTick() 720 public void TriggerTerrainTick()
@@ -710,7 +735,7 @@ namespace OpenSim.Region.Framework.Scenes
710 e.Message, e.StackTrace); 735 e.Message, e.StackTrace);
711 } 736 }
712 } 737 }
713 } 738 }
714 } 739 }
715 740
716 public void TriggerParcelPrimCountAdd(SceneObjectGroup obj) 741 public void TriggerParcelPrimCountAdd(SceneObjectGroup obj)
@@ -731,7 +756,7 @@ namespace OpenSim.Region.Framework.Scenes
731 e.Message, e.StackTrace); 756 e.Message, e.StackTrace);
732 } 757 }
733 } 758 }
734 } 759 }
735 } 760 }
736 761
737 public void TriggerObjectBeingRemovedFromScene(SceneObjectGroup obj) 762 public void TriggerObjectBeingRemovedFromScene(SceneObjectGroup obj)
@@ -752,11 +777,11 @@ namespace OpenSim.Region.Framework.Scenes
752 e.Message, e.StackTrace); 777 e.Message, e.StackTrace);
753 } 778 }
754 } 779 }
755 } 780 }
756 } 781 }
757 782
758 public void TriggerShutdown() 783 public void TriggerShutdown()
759 { 784 {
760 OnShutdownDelegate handlerShutdown = OnShutdown; 785 OnShutdownDelegate handlerShutdown = OnShutdown;
761 if (handlerShutdown != null) 786 if (handlerShutdown != null)
762 { 787 {
@@ -773,11 +798,11 @@ namespace OpenSim.Region.Framework.Scenes
773 e.Message, e.StackTrace); 798 e.Message, e.StackTrace);
774 } 799 }
775 } 800 }
776 } 801 }
777 } 802 }
778 803
779 public void TriggerObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) 804 public void TriggerObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
780 { 805 {
781 ObjectGrabDelegate handlerObjectGrab = OnObjectGrab; 806 ObjectGrabDelegate handlerObjectGrab = OnObjectGrab;
782 if (handlerObjectGrab != null) 807 if (handlerObjectGrab != null)
783 { 808 {
@@ -794,11 +819,11 @@ namespace OpenSim.Region.Framework.Scenes
794 e.Message, e.StackTrace); 819 e.Message, e.StackTrace);
795 } 820 }
796 } 821 }
797 } 822 }
798 } 823 }
799 824
800 public void TriggerObjectGrabbing(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) 825 public void TriggerObjectGrabbing(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
801 { 826 {
802 ObjectGrabDelegate handlerObjectGrabbing = OnObjectGrabbing; 827 ObjectGrabDelegate handlerObjectGrabbing = OnObjectGrabbing;
803 if (handlerObjectGrabbing != null) 828 if (handlerObjectGrabbing != null)
804 { 829 {
@@ -815,11 +840,11 @@ namespace OpenSim.Region.Framework.Scenes
815 e.Message, e.StackTrace); 840 e.Message, e.StackTrace);
816 } 841 }
817 } 842 }
818 } 843 }
819 } 844 }
820 845
821 public void TriggerObjectDeGrab(uint localID, uint originalID, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) 846 public void TriggerObjectDeGrab(uint localID, uint originalID, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
822 { 847 {
823 ObjectDeGrabDelegate handlerObjectDeGrab = OnObjectDeGrab; 848 ObjectDeGrabDelegate handlerObjectDeGrab = OnObjectDeGrab;
824 if (handlerObjectDeGrab != null) 849 if (handlerObjectDeGrab != null)
825 { 850 {
@@ -836,11 +861,11 @@ namespace OpenSim.Region.Framework.Scenes
836 e.Message, e.StackTrace); 861 e.Message, e.StackTrace);
837 } 862 }
838 } 863 }
839 } 864 }
840 } 865 }
841 866
842 public void TriggerScriptReset(uint localID, UUID itemID) 867 public void TriggerScriptReset(uint localID, UUID itemID)
843 { 868 {
844 ScriptResetDelegate handlerScriptReset = OnScriptReset; 869 ScriptResetDelegate handlerScriptReset = OnScriptReset;
845 if (handlerScriptReset != null) 870 if (handlerScriptReset != null)
846 { 871 {
@@ -857,11 +882,11 @@ namespace OpenSim.Region.Framework.Scenes
857 e.Message, e.StackTrace); 882 e.Message, e.StackTrace);
858 } 883 }
859 } 884 }
860 } 885 }
861 } 886 }
862 887
863 public void TriggerRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) 888 public void TriggerRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
864 { 889 {
865 NewRezScript handlerRezScript = OnRezScript; 890 NewRezScript handlerRezScript = OnRezScript;
866 if (handlerRezScript != null) 891 if (handlerRezScript != null)
867 { 892 {
@@ -878,7 +903,7 @@ namespace OpenSim.Region.Framework.Scenes
878 e.Message, e.StackTrace); 903 e.Message, e.StackTrace);
879 } 904 }
880 } 905 }
881 } 906 }
882 } 907 }
883 908
884 public void TriggerStartScript(uint localID, UUID itemID) 909 public void TriggerStartScript(uint localID, UUID itemID)
@@ -899,7 +924,7 @@ namespace OpenSim.Region.Framework.Scenes
899 e.Message, e.StackTrace); 924 e.Message, e.StackTrace);
900 } 925 }
901 } 926 }
902 } 927 }
903 } 928 }
904 929
905 public void TriggerStopScript(uint localID, UUID itemID) 930 public void TriggerStopScript(uint localID, UUID itemID)
@@ -920,11 +945,11 @@ namespace OpenSim.Region.Framework.Scenes
920 e.Message, e.StackTrace); 945 e.Message, e.StackTrace);
921 } 946 }
922 } 947 }
923 } 948 }
924 } 949 }
925 950
926 public void TriggerRemoveScript(uint localID, UUID itemID) 951 public void TriggerRemoveScript(uint localID, UUID itemID)
927 { 952 {
928 RemoveScript handlerRemoveScript = OnRemoveScript; 953 RemoveScript handlerRemoveScript = OnRemoveScript;
929 if (handlerRemoveScript != null) 954 if (handlerRemoveScript != null)
930 { 955 {
@@ -941,7 +966,7 @@ namespace OpenSim.Region.Framework.Scenes
941 e.Message, e.StackTrace); 966 e.Message, e.StackTrace);
942 } 967 }
943 } 968 }
944 } 969 }
945 } 970 }
946 971
947 public bool TriggerGroupMove(UUID groupID, Vector3 delta) 972 public bool TriggerGroupMove(UUID groupID, Vector3 delta)
@@ -1040,7 +1065,7 @@ namespace OpenSim.Region.Framework.Scenes
1040 e.Message, e.StackTrace); 1065 e.Message, e.StackTrace);
1041 } 1066 }
1042 } 1067 }
1043 } 1068 }
1044 } 1069 }
1045 1070
1046 public void TriggerLandObjectAdded(ILandObject newParcel) 1071 public void TriggerLandObjectAdded(ILandObject newParcel)
@@ -1061,7 +1086,7 @@ namespace OpenSim.Region.Framework.Scenes
1061 e.Message, e.StackTrace); 1086 e.Message, e.StackTrace);
1062 } 1087 }
1063 } 1088 }
1064 } 1089 }
1065 } 1090 }
1066 1091
1067 public void TriggerLandObjectRemoved(UUID globalID) 1092 public void TriggerLandObjectRemoved(UUID globalID)
@@ -1082,7 +1107,7 @@ namespace OpenSim.Region.Framework.Scenes
1082 e.Message, e.StackTrace); 1107 e.Message, e.StackTrace);
1083 } 1108 }
1084 } 1109 }
1085 } 1110 }
1086 } 1111 }
1087 1112
1088 public void TriggerLandObjectUpdated(uint localParcelID, ILandObject newParcel) 1113 public void TriggerLandObjectUpdated(uint localParcelID, ILandObject newParcel)
@@ -1108,7 +1133,7 @@ namespace OpenSim.Region.Framework.Scenes
1108 e.Message, e.StackTrace); 1133 e.Message, e.StackTrace);
1109 } 1134 }
1110 } 1135 }
1111 } 1136 }
1112 } 1137 }
1113 1138
1114 public void TriggerIncomingInstantMessage(GridInstantMessage message) 1139 public void TriggerIncomingInstantMessage(GridInstantMessage message)
@@ -1129,7 +1154,7 @@ namespace OpenSim.Region.Framework.Scenes
1129 e.Message, e.StackTrace); 1154 e.Message, e.StackTrace);
1130 } 1155 }
1131 } 1156 }
1132 } 1157 }
1133 } 1158 }
1134 1159
1135 public void TriggerUnhandledInstantMessage(GridInstantMessage message) 1160 public void TriggerUnhandledInstantMessage(GridInstantMessage message)
@@ -1150,7 +1175,7 @@ namespace OpenSim.Region.Framework.Scenes
1150 e.Message, e.StackTrace); 1175 e.Message, e.StackTrace);
1151 } 1176 }
1152 } 1177 }
1153 } 1178 }
1154 } 1179 }
1155 1180
1156 public void TriggerClientClosed(UUID ClientID, Scene scene) 1181 public void TriggerClientClosed(UUID ClientID, Scene scene)
@@ -1171,7 +1196,7 @@ namespace OpenSim.Region.Framework.Scenes
1171 e.Message, e.StackTrace); 1196 e.Message, e.StackTrace);
1172 } 1197 }
1173 } 1198 }
1174 } 1199 }
1175 } 1200 }
1176 1201
1177 public void TriggerOnMakeChildAgent(ScenePresence presence) 1202 public void TriggerOnMakeChildAgent(ScenePresence presence)
@@ -1192,7 +1217,7 @@ namespace OpenSim.Region.Framework.Scenes
1192 e.Message, e.StackTrace); 1217 e.Message, e.StackTrace);
1193 } 1218 }
1194 } 1219 }
1195 } 1220 }
1196 } 1221 }
1197 1222
1198 public void TriggerOnSendNewWindlightProfileTargeted(RegionMeta7WindlightData wl, UUID user) 1223 public void TriggerOnSendNewWindlightProfileTargeted(RegionMeta7WindlightData wl, UUID user)
@@ -1231,7 +1256,7 @@ namespace OpenSim.Region.Framework.Scenes
1231 e.Message, e.StackTrace); 1256 e.Message, e.StackTrace);
1232 } 1257 }
1233 } 1258 }
1234 } 1259 }
1235 } 1260 }
1236 1261
1237 public void TriggerOnIncomingSceneObject(SceneObjectGroup so) 1262 public void TriggerOnIncomingSceneObject(SceneObjectGroup so)
@@ -1251,12 +1276,12 @@ namespace OpenSim.Region.Framework.Scenes
1251 "[EVENT MANAGER]: Delegate for TriggerOnIncomingSceneObject failed - continuing. {0} {1}", 1276 "[EVENT MANAGER]: Delegate for TriggerOnIncomingSceneObject failed - continuing. {0} {1}",
1252 e.Message, e.StackTrace); 1277 e.Message, e.StackTrace);
1253 } 1278 }
1254 } 1279 }
1255 } 1280 }
1256 } 1281 }
1257 1282
1258 public void TriggerOnRegisterCaps(UUID agentID, Caps caps) 1283 public void TriggerOnRegisterCaps(UUID agentID, Caps caps)
1259 { 1284 {
1260 RegisterCapsEvent handlerRegisterCaps = OnRegisterCaps; 1285 RegisterCapsEvent handlerRegisterCaps = OnRegisterCaps;
1261 if (handlerRegisterCaps != null) 1286 if (handlerRegisterCaps != null)
1262 { 1287 {
@@ -1273,7 +1298,7 @@ namespace OpenSim.Region.Framework.Scenes
1273 e.Message, e.StackTrace); 1298 e.Message, e.StackTrace);
1274 } 1299 }
1275 } 1300 }
1276 } 1301 }
1277 } 1302 }
1278 1303
1279 public void TriggerOnDeregisterCaps(UUID agentID, Caps caps) 1304 public void TriggerOnDeregisterCaps(UUID agentID, Caps caps)
@@ -1294,7 +1319,7 @@ namespace OpenSim.Region.Framework.Scenes
1294 e.Message, e.StackTrace); 1319 e.Message, e.StackTrace);
1295 } 1320 }
1296 } 1321 }
1297 } 1322 }
1298 } 1323 }
1299 1324
1300 public void TriggerOnNewInventoryItemUploadComplete(UUID agentID, UUID AssetID, String AssetName, int userlevel) 1325 public void TriggerOnNewInventoryItemUploadComplete(UUID agentID, UUID AssetID, String AssetName, int userlevel)
@@ -1315,7 +1340,7 @@ namespace OpenSim.Region.Framework.Scenes
1315 e.Message, e.StackTrace); 1340 e.Message, e.StackTrace);
1316 } 1341 }
1317 } 1342 }
1318 } 1343 }
1319 } 1344 }
1320 1345
1321 public void TriggerLandBuy(Object sender, LandBuyArgs args) 1346 public void TriggerLandBuy(Object sender, LandBuyArgs args)
@@ -1336,7 +1361,7 @@ namespace OpenSim.Region.Framework.Scenes
1336 e.Message, e.StackTrace); 1361 e.Message, e.StackTrace);
1337 } 1362 }
1338 } 1363 }
1339 } 1364 }
1340 } 1365 }
1341 1366
1342 public void TriggerValidateLandBuy(Object sender, LandBuyArgs args) 1367 public void TriggerValidateLandBuy(Object sender, LandBuyArgs args)
@@ -1357,11 +1382,11 @@ namespace OpenSim.Region.Framework.Scenes
1357 e.Message, e.StackTrace); 1382 e.Message, e.StackTrace);
1358 } 1383 }
1359 } 1384 }
1360 } 1385 }
1361 } 1386 }
1362 1387
1363 public void TriggerAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 currentpos) 1388 public void TriggerAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 currentpos)
1364 { 1389 {
1365 ScriptAtTargetEvent handlerScriptAtTargetEvent = OnScriptAtTargetEvent; 1390 ScriptAtTargetEvent handlerScriptAtTargetEvent = OnScriptAtTargetEvent;
1366 if (handlerScriptAtTargetEvent != null) 1391 if (handlerScriptAtTargetEvent != null)
1367 { 1392 {
@@ -1378,7 +1403,7 @@ namespace OpenSim.Region.Framework.Scenes
1378 e.Message, e.StackTrace); 1403 e.Message, e.StackTrace);
1379 } 1404 }
1380 } 1405 }
1381 } 1406 }
1382 } 1407 }
1383 1408
1384 public void TriggerNotAtTargetEvent(uint localID) 1409 public void TriggerNotAtTargetEvent(uint localID)
@@ -1399,11 +1424,11 @@ namespace OpenSim.Region.Framework.Scenes
1399 e.Message, e.StackTrace); 1424 e.Message, e.StackTrace);
1400 } 1425 }
1401 } 1426 }
1402 } 1427 }
1403 } 1428 }
1404 1429
1405 public void TriggerAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion currentrot) 1430 public void TriggerAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion currentrot)
1406 { 1431 {
1407 ScriptAtRotTargetEvent handlerScriptAtRotTargetEvent = OnScriptAtRotTargetEvent; 1432 ScriptAtRotTargetEvent handlerScriptAtRotTargetEvent = OnScriptAtRotTargetEvent;
1408 if (handlerScriptAtRotTargetEvent != null) 1433 if (handlerScriptAtRotTargetEvent != null)
1409 { 1434 {
@@ -1420,7 +1445,7 @@ namespace OpenSim.Region.Framework.Scenes
1420 e.Message, e.StackTrace); 1445 e.Message, e.StackTrace);
1421 } 1446 }
1422 } 1447 }
1423 } 1448 }
1424 } 1449 }
1425 1450
1426 public void TriggerNotAtRotTargetEvent(uint localID) 1451 public void TriggerNotAtRotTargetEvent(uint localID)
@@ -1441,7 +1466,7 @@ namespace OpenSim.Region.Framework.Scenes
1441 e.Message, e.StackTrace); 1466 e.Message, e.StackTrace);
1442 } 1467 }
1443 } 1468 }
1444 } 1469 }
1445 } 1470 }
1446 1471
1447 public void TriggerRequestChangeWaterHeight(float height) 1472 public void TriggerRequestChangeWaterHeight(float height)
@@ -1462,7 +1487,7 @@ namespace OpenSim.Region.Framework.Scenes
1462 e.Message, e.StackTrace); 1487 e.Message, e.StackTrace);
1463 } 1488 }
1464 } 1489 }
1465 } 1490 }
1466 } 1491 }
1467 1492
1468 public void TriggerAvatarKill(uint KillerObjectLocalID, ScenePresence DeadAvatar) 1493 public void TriggerAvatarKill(uint KillerObjectLocalID, ScenePresence DeadAvatar)
@@ -1483,7 +1508,7 @@ namespace OpenSim.Region.Framework.Scenes
1483 e.Message, e.StackTrace); 1508 e.Message, e.StackTrace);
1484 } 1509 }
1485 } 1510 }
1486 } 1511 }
1487 } 1512 }
1488 1513
1489 public void TriggerSignificantClientMovement(IClientAPI client) 1514 public void TriggerSignificantClientMovement(IClientAPI client)
@@ -1504,7 +1529,7 @@ namespace OpenSim.Region.Framework.Scenes
1504 e.Message, e.StackTrace); 1529 e.Message, e.StackTrace);
1505 } 1530 }
1506 } 1531 }
1507 } 1532 }
1508 } 1533 }
1509 1534
1510 public void TriggerOnChatFromWorld(Object sender, OSChatMessage chat) 1535 public void TriggerOnChatFromWorld(Object sender, OSChatMessage chat)
@@ -1525,7 +1550,7 @@ namespace OpenSim.Region.Framework.Scenes
1525 e.Message, e.StackTrace); 1550 e.Message, e.StackTrace);
1526 } 1551 }
1527 } 1552 }
1528 } 1553 }
1529 } 1554 }
1530 1555
1531 public void TriggerOnChatFromClient(Object sender, OSChatMessage chat) 1556 public void TriggerOnChatFromClient(Object sender, OSChatMessage chat)
@@ -1546,7 +1571,7 @@ namespace OpenSim.Region.Framework.Scenes
1546 e.Message, e.StackTrace); 1571 e.Message, e.StackTrace);
1547 } 1572 }
1548 } 1573 }
1549 } 1574 }
1550 } 1575 }
1551 1576
1552 public void TriggerOnChatBroadcast(Object sender, OSChatMessage chat) 1577 public void TriggerOnChatBroadcast(Object sender, OSChatMessage chat)
@@ -1567,7 +1592,7 @@ namespace OpenSim.Region.Framework.Scenes
1567 e.Message, e.StackTrace); 1592 e.Message, e.StackTrace);
1568 } 1593 }
1569 } 1594 }
1570 } 1595 }
1571 } 1596 }
1572 1597
1573 internal void TriggerControlEvent(uint p, UUID scriptUUID, UUID avatarID, uint held, uint _changed) 1598 internal void TriggerControlEvent(uint p, UUID scriptUUID, UUID avatarID, uint held, uint _changed)
@@ -1588,7 +1613,7 @@ namespace OpenSim.Region.Framework.Scenes
1588 e.Message, e.StackTrace); 1613 e.Message, e.StackTrace);
1589 } 1614 }
1590 } 1615 }
1591 } 1616 }
1592 } 1617 }
1593 1618
1594 public void TriggerNoticeNoLandDataFromStorage() 1619 public void TriggerNoticeNoLandDataFromStorage()
@@ -1609,7 +1634,7 @@ namespace OpenSim.Region.Framework.Scenes
1609 e.Message, e.StackTrace); 1634 e.Message, e.StackTrace);
1610 } 1635 }
1611 } 1636 }
1612 } 1637 }
1613 } 1638 }
1614 1639
1615 public void TriggerIncomingLandDataFromStorage(List<LandData> landData) 1640 public void TriggerIncomingLandDataFromStorage(List<LandData> landData)
@@ -1630,7 +1655,7 @@ namespace OpenSim.Region.Framework.Scenes
1630 e.Message, e.StackTrace); 1655 e.Message, e.StackTrace);
1631 } 1656 }
1632 } 1657 }
1633 } 1658 }
1634 } 1659 }
1635 1660
1636 public void TriggerSetAllowForcefulBan(bool allow) 1661 public void TriggerSetAllowForcefulBan(bool allow)
@@ -1651,7 +1676,7 @@ namespace OpenSim.Region.Framework.Scenes
1651 e.Message, e.StackTrace); 1676 e.Message, e.StackTrace);
1652 } 1677 }
1653 } 1678 }
1654 } 1679 }
1655 } 1680 }
1656 1681
1657 public void TriggerRequestParcelPrimCountUpdate() 1682 public void TriggerRequestParcelPrimCountUpdate()
@@ -1672,7 +1697,7 @@ namespace OpenSim.Region.Framework.Scenes
1672 e.Message, e.StackTrace); 1697 e.Message, e.StackTrace);
1673 } 1698 }
1674 } 1699 }
1675 } 1700 }
1676 } 1701 }
1677 1702
1678 public void TriggerParcelPrimCountTainted() 1703 public void TriggerParcelPrimCountTainted()
@@ -1693,7 +1718,7 @@ namespace OpenSim.Region.Framework.Scenes
1693 e.Message, e.StackTrace); 1718 e.Message, e.StackTrace);
1694 } 1719 }
1695 } 1720 }
1696 } 1721 }
1697 } 1722 }
1698 1723
1699 // this lets us keep track of nasty script events like timer, etc. 1724 // this lets us keep track of nasty script events like timer, etc.
@@ -1732,7 +1757,7 @@ namespace OpenSim.Region.Framework.Scenes
1732 e.Message, e.StackTrace); 1757 e.Message, e.StackTrace);
1733 } 1758 }
1734 } 1759 }
1735 } 1760 }
1736 } 1761 }
1737 1762
1738 public float GetCurrentTimeAsSunLindenHour() 1763 public float GetCurrentTimeAsSunLindenHour()
@@ -1759,7 +1784,7 @@ namespace OpenSim.Region.Framework.Scenes
1759 } 1784 }
1760 1785
1761 public void TriggerOarFileLoaded(Guid requestId, string message) 1786 public void TriggerOarFileLoaded(Guid requestId, string message)
1762 { 1787 {
1763 OarFileLoaded handlerOarFileLoaded = OnOarFileLoaded; 1788 OarFileLoaded handlerOarFileLoaded = OnOarFileLoaded;
1764 if (handlerOarFileLoaded != null) 1789 if (handlerOarFileLoaded != null)
1765 { 1790 {
@@ -1776,7 +1801,7 @@ namespace OpenSim.Region.Framework.Scenes
1776 e.Message, e.StackTrace); 1801 e.Message, e.StackTrace);
1777 } 1802 }
1778 } 1803 }
1779 } 1804 }
1780 } 1805 }
1781 1806
1782 public void TriggerOarFileSaved(Guid requestId, string message) 1807 public void TriggerOarFileSaved(Guid requestId, string message)
@@ -1797,7 +1822,7 @@ namespace OpenSim.Region.Framework.Scenes
1797 e.Message, e.StackTrace); 1822 e.Message, e.StackTrace);
1798 } 1823 }
1799 } 1824 }
1800 } 1825 }
1801 } 1826 }
1802 1827
1803 public void TriggerEmptyScriptCompileQueue(int numScriptsFailed, string message) 1828 public void TriggerEmptyScriptCompileQueue(int numScriptsFailed, string message)
@@ -1818,7 +1843,7 @@ namespace OpenSim.Region.Framework.Scenes
1818 e.Message, e.StackTrace); 1843 e.Message, e.StackTrace);
1819 } 1844 }
1820 } 1845 }
1821 } 1846 }
1822 } 1847 }
1823 1848
1824 public void TriggerScriptCollidingStart(uint localId, ColliderArgs colliders) 1849 public void TriggerScriptCollidingStart(uint localId, ColliderArgs colliders)
@@ -1839,7 +1864,7 @@ namespace OpenSim.Region.Framework.Scenes
1839 e.Message, e.StackTrace); 1864 e.Message, e.StackTrace);
1840 } 1865 }
1841 } 1866 }
1842 } 1867 }
1843 } 1868 }
1844 1869
1845 public void TriggerScriptColliding(uint localId, ColliderArgs colliders) 1870 public void TriggerScriptColliding(uint localId, ColliderArgs colliders)
@@ -1860,7 +1885,7 @@ namespace OpenSim.Region.Framework.Scenes
1860 e.Message, e.StackTrace); 1885 e.Message, e.StackTrace);
1861 } 1886 }
1862 } 1887 }
1863 } 1888 }
1864 } 1889 }
1865 1890
1866 public void TriggerScriptCollidingEnd(uint localId, ColliderArgs colliders) 1891 public void TriggerScriptCollidingEnd(uint localId, ColliderArgs colliders)
@@ -1881,7 +1906,7 @@ namespace OpenSim.Region.Framework.Scenes
1881 e.Message, e.StackTrace); 1906 e.Message, e.StackTrace);
1882 } 1907 }
1883 } 1908 }
1884 } 1909 }
1885 } 1910 }
1886 1911
1887 public void TriggerScriptLandCollidingStart(uint localId, ColliderArgs colliders) 1912 public void TriggerScriptLandCollidingStart(uint localId, ColliderArgs colliders)
@@ -1902,7 +1927,7 @@ namespace OpenSim.Region.Framework.Scenes
1902 e.Message, e.StackTrace); 1927 e.Message, e.StackTrace);
1903 } 1928 }
1904 } 1929 }
1905 } 1930 }
1906 } 1931 }
1907 1932
1908 public void TriggerScriptLandColliding(uint localId, ColliderArgs colliders) 1933 public void TriggerScriptLandColliding(uint localId, ColliderArgs colliders)
@@ -1923,7 +1948,7 @@ namespace OpenSim.Region.Framework.Scenes
1923 e.Message, e.StackTrace); 1948 e.Message, e.StackTrace);
1924 } 1949 }
1925 } 1950 }
1926 } 1951 }
1927 } 1952 }
1928 1953
1929 public void TriggerScriptLandCollidingEnd(uint localId, ColliderArgs colliders) 1954 public void TriggerScriptLandCollidingEnd(uint localId, ColliderArgs colliders)
@@ -1944,11 +1969,11 @@ namespace OpenSim.Region.Framework.Scenes
1944 e.Message, e.StackTrace); 1969 e.Message, e.StackTrace);
1945 } 1970 }
1946 } 1971 }
1947 } 1972 }
1948 } 1973 }
1949 1974
1950 public void TriggerSetRootAgentScene(UUID agentID, Scene scene) 1975 public void TriggerSetRootAgentScene(UUID agentID, Scene scene)
1951 { 1976 {
1952 OnSetRootAgentSceneDelegate handlerSetRootAgentScene = OnSetRootAgentScene; 1977 OnSetRootAgentSceneDelegate handlerSetRootAgentScene = OnSetRootAgentScene;
1953 if (handlerSetRootAgentScene != null) 1978 if (handlerSetRootAgentScene != null)
1954 { 1979 {
@@ -1965,7 +1990,7 @@ namespace OpenSim.Region.Framework.Scenes
1965 e.Message, e.StackTrace); 1990 e.Message, e.StackTrace);
1966 } 1991 }
1967 } 1992 }
1968 } 1993 }
1969 } 1994 }
1970 1995
1971 public void TriggerOnRegionUp(GridRegion otherRegion) 1996 public void TriggerOnRegionUp(GridRegion otherRegion)
@@ -1986,7 +2011,7 @@ namespace OpenSim.Region.Framework.Scenes
1986 e.Message, e.StackTrace); 2011 e.Message, e.StackTrace);
1987 } 2012 }
1988 } 2013 }
1989 } 2014 }
1990 } 2015 }
1991 } 2016 }
1992} 2017}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
deleted file mode 100644
index ec50598..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ /dev/null
@@ -1,265 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Threading;
32using log4net;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Communications.Clients;
37using OpenSim.Region.Framework.Scenes.Serialization;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Services.Interfaces;
40
41//using HyperGrid.Framework;
42//using OpenSim.Region.Communications.Hypergrid;
43
44namespace OpenSim.Region.Framework.Scenes.Hypergrid
45{
46 public class HGAssetMapper
47 {
48 #region Fields
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 // This maps between inventory server urls and inventory server clients
52// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
53
54 private Scene m_scene;
55
56 private IHyperAssetService m_hyper;
57 IHyperAssetService HyperlinkAssets
58 {
59 get
60 {
61 if (m_hyper == null)
62 m_hyper = m_scene.RequestModuleInterface<IHyperAssetService>();
63 return m_hyper;
64 }
65 }
66
67 #endregion
68
69 #region Constructor
70
71 public HGAssetMapper(Scene scene)
72 {
73 m_scene = scene;
74 }
75
76 #endregion
77
78 #region Internal functions
79
80// private string UserAssetURL(UUID userID)
81// {
82// CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
83// if (uinfo != null)
84// return (uinfo.UserProfile.UserAssetURI == "") ? null : uinfo.UserProfile.UserAssetURI;
85// return null;
86// }
87
88// private string UserInventoryURL(UUID userID)
89// {
90// CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
91// if (uinfo != null)
92// return (uinfo.UserProfile.UserInventoryURI == "") ? null : uinfo.UserProfile.UserInventoryURI;
93// return null;
94// }
95
96
97 public AssetBase FetchAsset(string url, UUID assetID)
98 {
99 AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString());
100
101 if (asset != null)
102 {
103 m_log.DebugFormat("[HGScene]: Copied asset {0} from {1} to local asset server. ", asset.ID, url);
104 return asset;
105 }
106 return null;
107 }
108
109 public bool PostAsset(string url, AssetBase asset)
110 {
111 if (asset != null)
112 {
113 // See long comment in AssetCache.AddAsset
114 if (!asset.Temporary || asset.Local)
115 {
116 // We need to copy the asset into a new asset, because
117 // we need to set its ID to be URL+UUID, so that the
118 // HGAssetService dispatches it to the remote grid.
119 // It's not pretty, but the best that can be done while
120 // not having a global naming infrastructure
121 AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type);
122 Copy(asset, asset1);
123 try
124 {
125 asset1.ID = url + "/" + asset.ID;
126 }
127 catch
128 {
129 m_log.Warn("[HGScene]: Oops.");
130 }
131
132 m_scene.AssetService.Store(asset1);
133 m_log.DebugFormat("[HGScene]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url);
134 }
135 return true;
136 }
137 else
138 m_log.Warn("[HGScene]: Tried to post asset to remote server, but asset not in local cache.");
139
140 return false;
141 }
142
143 private void Copy(AssetBase from, AssetBase to)
144 {
145 to.Data = from.Data;
146 to.Description = from.Description;
147 to.FullID = from.FullID;
148 to.ID = from.ID;
149 to.Local = from.Local;
150 to.Name = from.Name;
151 to.Temporary = from.Temporary;
152 to.Type = from.Type;
153
154 }
155
156 // TODO: unused
157 // private void Dump(Dictionary<UUID, bool> lst)
158 // {
159 // m_log.Debug("XXX -------- UUID DUMP ------- XXX");
160 // foreach (KeyValuePair<UUID, bool> kvp in lst)
161 // m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")");
162 // m_log.Debug("XXX -------- UUID DUMP ------- XXX");
163 // }
164
165 #endregion
166
167
168 #region Public interface
169
170 public void Get(UUID assetID, UUID ownerID)
171 {
172 // Get the item from the remote asset server onto the local AssetCache
173 // and place an entry in m_assetMap
174
175 string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID);
176 if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer()))
177 {
178 m_log.Debug("[HGScene]: Fetching object " + assetID + " from asset server " + userAssetURL);
179 AssetBase asset = FetchAsset(userAssetURL, assetID);
180
181 if (asset != null)
182 {
183 // OK, now fetch the inside.
184 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
185 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
186 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
187 foreach (UUID uuid in ids.Keys)
188 FetchAsset(userAssetURL, uuid);
189
190 m_log.DebugFormat("[HGScene]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL);
191
192 }
193 else
194 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL);
195 }
196 else
197 m_log.Debug("[HGScene]: user's asset server is the local region's asset server");
198 }
199
200 //public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo)
201 //{
202 // InventoryClient invCli = null;
203 // string inventoryURL = UserInventoryURL(item.Owner);
204 // if (!m_inventoryServers.TryGetValue(inventoryURL, out invCli))
205 // {
206 // m_log.Debug("[HGScene]: Starting new InventorytClient for " + inventoryURL);
207 // invCli = new InventoryClient(inventoryURL);
208 // m_inventoryServers.Add(inventoryURL, invCli);
209 // }
210
211 // item = invCli.GetInventoryItem(item);
212 // if (item != null)
213 // {
214 // // Change the folder, stick it in root folder, all items flattened out here in this region cache
215 // item.Folder = rootFolder;
216 // //userInfo.AddItem(item); don't use this, it calls back to the inventory server
217 // lock (userInfo.RootFolder.Items)
218 // {
219 // userInfo.RootFolder.Items[item.ID] = item;
220 // }
221
222 // }
223 // return item;
224 //}
225
226 public void Post(UUID assetID, UUID ownerID)
227 {
228 // Post the item from the local AssetCache onto the remote asset server
229 // and place an entry in m_assetMap
230
231 string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID);
232 if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer()))
233 {
234 m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL);
235 AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
236 if (asset != null)
237 {
238 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
239 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty);
240 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
241 foreach (UUID uuid in ids.Keys)
242 {
243 asset = m_scene.AssetService.Get(uuid.ToString());
244 if (asset == null)
245 m_log.DebugFormat("[HGScene]: Could not find asset {0}", uuid);
246 else
247 PostAsset(userAssetURL, asset);
248 }
249
250 // maybe all pieces got there...
251 m_log.DebugFormat("[HGScene]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL);
252
253 }
254 else
255 m_log.DebugFormat("[HGScene]: Something wrong with asset {0}, it could not be found", assetID);
256 }
257 else
258 m_log.Debug("[HGScene]: user's asset server is local region's asset server");
259
260 }
261
262 #endregion
263
264 }
265}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
deleted file mode 100644
index b1981b6..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
+++ /dev/null
@@ -1,77 +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 OpenMetaverse;
29using OpenSim.Framework;
30using OpenSim.Framework.Communications.Cache;
31using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
32using GridRegion = OpenSim.Services.Interfaces.GridRegion;
33
34namespace OpenSim.Region.Framework.Scenes.Hypergrid
35{
36 public partial class HGScene : Scene
37 {
38 /// <summary>
39 /// Teleport an avatar to their home region
40 /// </summary>
41 /// <param name="agentId"></param>
42 /// <param name="client"></param>
43 public override void TeleportClientHome(UUID agentId, IClientAPI client)
44 {
45 m_log.Debug("[HGScene]: TeleportClientHome " + client.FirstName + " " + client.LastName);
46
47 CachedUserInfo uinfo = CommsManager.UserProfileCacheService.GetUserDetails(agentId);
48 if (uinfo != null)
49 {
50 UserProfileData UserProfile = uinfo.UserProfile;
51
52 if (UserProfile != null)
53 {
54 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
55 //if (regionInfo != null)
56 //{
57 // UserProfile.HomeRegionID = regionInfo.RegionID;
58 // //CommsManager.UserService.UpdateUserProfile(UserProfile);
59 //}
60 if (regionInfo == null)
61 {
62 // can't find the Home region: Tell viewer and abort
63 client.SendTeleportFailed("Your home-region could not be found.");
64 return;
65 }
66 RequestTeleportLocation(
67 client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt,
68 (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome));
69 }
70 }
71 else
72 client.SendTeleportFailed("Sorry! I lost your home-region information.");
73
74 }
75
76 }
77}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
deleted file mode 100644
index 416826c..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
+++ /dev/null
@@ -1,391 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Reflection;
32using System.Threading;
33using log4net;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Framework.Client;
37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Capabilities;
40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Services.Interfaces;
42using GridRegion = OpenSim.Services.Interfaces.GridRegion;
43
44namespace OpenSim.Region.Framework.Scenes.Hypergrid
45{
46 public class HGSceneCommunicationService : SceneCommunicationService
47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 private IHyperlinkService m_hg;
51 IHyperlinkService HyperlinkService
52 {
53 get
54 {
55 if (m_hg == null)
56 m_hg = m_scene.RequestModuleInterface<IHyperlinkService>();
57 return m_hg;
58 }
59 }
60
61 public HGSceneCommunicationService(CommunicationsManager commsMan) : base(commsMan)
62 {
63 }
64
65
66 /// <summary>
67 /// Try to teleport an agent to a new region.
68 /// </summary>
69 /// <param name="remoteClient"></param>
70 /// <param name="RegionHandle"></param>
71 /// <param name="position"></param>
72 /// <param name="lookAt"></param>
73 /// <param name="flags"></param>
74 public override void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position,
75 Vector3 lookAt, uint teleportFlags)
76 {
77 if (!avatar.Scene.Permissions.CanTeleport(avatar.UUID))
78 return;
79
80 bool destRegionUp = true;
81
82 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
83
84 // Reset animations; the viewer does that in teleports.
85 avatar.Animator.ResetAnimations();
86
87 if (regionHandle == m_regionInfo.RegionHandle)
88 {
89 // Teleport within the same region
90 if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0)
91 {
92 Vector3 emergencyPos = new Vector3(128, 128, 128);
93
94 m_log.WarnFormat(
95 "[HGSceneCommService]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
96 position, avatar.Name, avatar.UUID, emergencyPos);
97 position = emergencyPos;
98 }
99 // TODO: Get proper AVG Height
100 float localAVHeight = 1.56f;
101
102 float posZLimit = 22;
103
104 if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize)
105 {
106 posZLimit = (float) avatar.Scene.Heightmap[(int) position.X, (int) position.Y];
107 }
108
109 float newPosZ = posZLimit + localAVHeight;
110 if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
111 {
112 position.Z = newPosZ;
113 }
114
115 // Only send this if the event queue is null
116 if (eq == null)
117 avatar.ControllingClient.SendTeleportLocationStart();
118
119
120 avatar.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
121 avatar.Teleport(position);
122 }
123 else
124 {
125 uint x = 0, y = 0;
126 Utils.LongToUInts(regionHandle, out x, out y);
127 GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
128
129 if (reg != null)
130 {
131
132 uint newRegionX = (uint)(reg.RegionHandle >> 40);
133 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
134 uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
135 uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
136
137 ///
138 /// Hypergrid mod start
139 ///
140 ///
141 bool isHyperLink = (HyperlinkService.GetHyperlinkRegion(reg.RegionHandle) != null);
142 bool isHomeUser = true;
143 ulong realHandle = regionHandle;
144 CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID);
145 if (uinfo != null)
146 {
147 isHomeUser = HyperlinkService.IsLocalUser(uinfo.UserProfile.ID);
148 realHandle = m_hg.FindRegionHandle(regionHandle);
149 m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString());
150 }
151 ///
152 /// Hypergrid mod stop
153 ///
154 ///
155
156 if (eq == null)
157 avatar.ControllingClient.SendTeleportLocationStart();
158
159
160 // Let's do DNS resolution only once in this process, please!
161 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
162 // it's actually doing a lot of work.
163 IPEndPoint endPoint = reg.ExternalEndPoint;
164 if (endPoint.Address == null)
165 {
166 // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses.
167 destRegionUp = false;
168 }
169
170 if (destRegionUp)
171 {
172 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
173 // both regions
174 if (avatar.ParentID != (uint)0)
175 avatar.StandUp();
176
177 if (!avatar.ValidateAttachments())
178 {
179 avatar.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
180 return;
181 }
182
183 // the avatar.Close below will clear the child region list. We need this below for (possibly)
184 // closing the child agents, so save it here (we need a copy as it is Clear()-ed).
185 //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList());
186 // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
187 // failure at this point (unlike a border crossing failure). So perhaps this can never fail
188 // once we reach here...
189 //avatar.Scene.RemoveCapsHandler(avatar.UUID);
190
191 string capsPath = String.Empty;
192 AgentCircuitData agentCircuit = avatar.ControllingClient.RequestClientInfo();
193 agentCircuit.BaseFolder = UUID.Zero;
194 agentCircuit.InventoryFolder = UUID.Zero;
195 agentCircuit.startpos = position;
196 agentCircuit.child = true;
197 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
198 {
199 // brand new agent, let's create a new caps seed
200 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
201 }
202
203 string reason = String.Empty;
204
205 //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
206 if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, teleportFlags, out reason))
207 {
208 avatar.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}",
209 reason));
210 return;
211 }
212
213 // Let's close some agents
214 if (isHyperLink) // close them all except this one
215 {
216 List<ulong> regions = new List<ulong>(avatar.KnownChildRegionHandles);
217 regions.Remove(avatar.Scene.RegionInfo.RegionHandle);
218 SendCloseChildAgentConnections(avatar.UUID, regions);
219 }
220 else // close just a few
221 avatar.CloseChildAgents(newRegionX, newRegionY);
222
223 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY) || isHyperLink)
224 {
225 capsPath
226 = "http://"
227 + reg.ExternalHostName
228 + ":"
229 + reg.HttpPort
230 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
231
232 if (eq != null)
233 {
234 #region IP Translation for NAT
235 IClientIPEndpoint ipepClient;
236 if (avatar.ClientView.TryGet(out ipepClient))
237 {
238 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
239 }
240 #endregion
241
242 eq.EnableSimulator(realHandle, endPoint, avatar.UUID);
243
244 // ES makes the client send a UseCircuitCode message to the destination,
245 // which triggers a bunch of things there.
246 // So let's wait
247 Thread.Sleep(2000);
248
249 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
250 }
251 else
252 {
253 avatar.ControllingClient.InformClientOfNeighbour(realHandle, endPoint);
254 // TODO: make Event Queue disablable!
255 }
256 }
257 else
258 {
259 // child agent already there
260 agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle);
261 capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
262 + "/CAPS/" + agentCircuit.CapsPath + "0000/";
263 }
264
265 //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
266 // position, false);
267
268 //if (!m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
269 // position, false))
270 //{
271 // avatar.ControllingClient.SendTeleportFailed("Problem with destination.");
272 // // We should close that agent we just created over at destination...
273 // List<ulong> lst = new List<ulong>();
274 // lst.Add(realHandle);
275 // SendCloseChildAgentAsync(avatar.UUID, lst);
276 // return;
277 //}
278
279 SetInTransit(avatar.UUID);
280 // Let's send a full update of the agent. This is a synchronous call.
281 AgentData agent = new AgentData();
282 avatar.CopyTo(agent);
283 agent.Position = position;
284 agent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort +
285 "/agent/" + avatar.UUID.ToString() + "/" + avatar.Scene.RegionInfo.RegionHandle.ToString() + "/release/";
286
287 m_interregionCommsOut.SendChildAgentUpdate(reg.RegionHandle, agent);
288
289 m_log.DebugFormat(
290 "[CAPS]: Sending new CAPS seed url {0} to client {1}", agentCircuit.CapsPath, avatar.UUID);
291
292
293 ///
294 /// Hypergrid mod: realHandle instead of reg.RegionHandle
295 ///
296 ///
297 if (eq != null)
298 {
299 eq.TeleportFinishEvent(realHandle, 13, endPoint,
300 4, teleportFlags, capsPath, avatar.UUID);
301 }
302 else
303 {
304 avatar.ControllingClient.SendRegionTeleport(realHandle, 13, endPoint, 4,
305 teleportFlags, capsPath);
306 }
307 ///
308 /// Hypergrid mod stop
309 ///
310
311
312 // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
313 // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
314 // that the client contacted the destination before we send the attachments and close things here.
315 if (!WaitForCallback(avatar.UUID))
316 {
317 // Client never contacted destination. Let's restore everything back
318 avatar.ControllingClient.SendTeleportFailed("Problems connecting to destination.");
319
320 ResetFromTransit(avatar.UUID);
321 // Yikes! We should just have a ref to scene here.
322 avatar.Scene.InformClientOfNeighbours(avatar);
323
324 // Finally, kill the agent we just created at the destination.
325 m_interregionCommsOut.SendCloseAgent(reg.RegionHandle, avatar.UUID);
326
327 return;
328 }
329
330 // Can't go back from here
331 if (KiPrimitive != null)
332 {
333 KiPrimitive(avatar.LocalId);
334 }
335
336 avatar.MakeChildAgent();
337
338 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
339 avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true);
340
341
342 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
343 ///
344 /// Hypergrid mod: extra check for isHyperLink
345 ///
346 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY) || isHyperLink)
347 {
348 Thread.Sleep(5000);
349 avatar.Close();
350 CloseConnection(avatar.UUID);
351 }
352 // if (teleport success) // seems to be always success here
353 // the user may change their profile information in other region,
354 // so the userinfo in UserProfileCache is not reliable any more, delete it
355 if (avatar.Scene.NeedSceneCacheClear(avatar.UUID) || isHyperLink)
356 {
357 m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID);
358 m_log.DebugFormat(
359 "[HGSceneCommService]: User {0} is going to another region, profile cache removed",
360 avatar.UUID);
361 }
362 }
363 else
364 {
365 avatar.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
366 }
367 }
368 else
369 {
370 // TP to a place that doesn't exist (anymore)
371 // Inform the viewer about that
372 avatar.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
373
374 // and set the map-tile to '(Offline)'
375 uint regX, regY;
376 Utils.LongToUInts(regionHandle, out regX, out regY);
377
378 MapBlockData block = new MapBlockData();
379 block.X = (ushort)(regX / Constants.RegionSize);
380 block.Y = (ushort)(regY / Constants.RegionSize);
381 block.Access = 254; // == not there
382
383 List<MapBlockData> blocks = new List<MapBlockData>();
384 blocks.Add(block);
385 avatar.ControllingClient.SendMapBlock(blocks, 0);
386 }
387 }
388 }
389
390 }
391}
diff --git a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
index e9660b1..d25d5dd 100644
--- a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
+++ b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
@@ -36,8 +36,7 @@ using OpenMetaverse;
36using OpenMetaverse.StructuredData; 36using OpenMetaverse.StructuredData;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Services; 39
40using OpenSim.Framework.Communications.Cache;
41using OpenSim.Framework.Console; 40using OpenSim.Framework.Console;
42using OpenSim.Framework.Servers; 41using OpenSim.Framework.Servers;
43using OpenSim.Framework.Servers.HttpServer; 42using OpenSim.Framework.Servers.HttpServer;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index b2b061e..e458ecf 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -35,7 +35,7 @@ using OpenMetaverse;
35using OpenMetaverse.Packets; 35using OpenMetaverse.Packets;
36using log4net; 36using log4net;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications.Cache; 38
39using OpenSim.Region.Framework; 39using OpenSim.Region.Framework;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes.Serialization; 41using OpenSim.Region.Framework.Scenes.Serialization;
@@ -101,12 +101,6 @@ namespace OpenSim.Region.Framework.Scenes
101 { 101 {
102 userlevel = 1; 102 userlevel = 1;
103 } 103 }
104 // TODO: remove this cruft once MasterAvatar is fully deprecated
105 //
106 if (m_regInfo.MasterAvatarAssignedUUID == AgentID)
107 {
108 userlevel = 2;
109 }
110 EventManager.TriggerOnNewInventoryItemUploadComplete(AgentID, item.AssetID, item.Name, userlevel); 104 EventManager.TriggerOnNewInventoryItemUploadComplete(AgentID, item.AssetID, item.Name, userlevel);
111 } 105 }
112 else 106 else
@@ -132,61 +126,6 @@ namespace OpenSim.Region.Framework.Scenes
132 } 126 }
133 127
134 /// <summary> 128 /// <summary>
135 /// Capability originating call to update the asset of an item in an agent's inventory
136 /// </summary>
137 /// <param name="remoteClient"></param>
138 /// <param name="itemID"></param>
139 /// <param name="data"></param>
140 /// <returns></returns>
141 public virtual UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data)
142 {
143 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
144 item = InventoryService.GetItem(item);
145
146 if (item != null)
147 {
148 if ((InventoryType)item.InvType == InventoryType.Notecard)
149 {
150 if (!Permissions.CanEditNotecard(itemID, UUID.Zero, remoteClient.AgentId))
151 {
152 remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false);
153 return UUID.Zero;
154 }
155
156 remoteClient.SendAgentAlertMessage("Notecard saved", false);
157 }
158 else if ((InventoryType)item.InvType == InventoryType.LSL)
159 {
160 if (!Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId))
161 {
162 remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false);
163 return UUID.Zero;
164 }
165
166 remoteClient.SendAgentAlertMessage("Script saved", false);
167 }
168
169 AssetBase asset =
170 CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data);
171 item.AssetID = asset.FullID;
172 AssetService.Store(asset);
173
174 InventoryService.UpdateItem(item);
175
176 // remoteClient.SendInventoryItemCreateUpdate(item);
177 return (asset.FullID);
178 }
179 else
180 {
181 m_log.ErrorFormat(
182 "[AGENT INVENTORY]: Could not find item {0} for caps inventory update",
183 itemID);
184 }
185
186 return UUID.Zero;
187 }
188
189 /// <summary>
190 /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see> 129 /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see>
191 /// </summary> 130 /// </summary>
192 public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data) 131 public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data)
@@ -195,7 +134,9 @@ namespace OpenSim.Region.Framework.Scenes
195 134
196 if (TryGetAvatar(avatarId, out avatar)) 135 if (TryGetAvatar(avatarId, out avatar))
197 { 136 {
198 return CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data); 137 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
138 if (invAccess != null)
139 return invAccess.CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data);
199 } 140 }
200 else 141 else
201 { 142 {
@@ -251,7 +192,7 @@ namespace OpenSim.Region.Framework.Scenes
251 return new ArrayList(); 192 return new ArrayList();
252 } 193 }
253 194
254 AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data); 195 AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data, remoteClient.AgentId);
255 AssetService.Store(asset); 196 AssetService.Store(asset);
256 197
257 if (isScriptRunning) 198 if (isScriptRunning)
@@ -478,7 +419,11 @@ namespace OpenSim.Region.Framework.Scenes
478 itemCopy.SaleType = item.SaleType; 419 itemCopy.SaleType = item.SaleType;
479 420
480 if (InventoryService.AddItem(itemCopy)) 421 if (InventoryService.AddItem(itemCopy))
481 TransferInventoryAssets(itemCopy, senderId, recipient); 422 {
423 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
424 if (invAccess != null)
425 invAccess.TransferInventoryAssets(itemCopy, senderId, recipient);
426 }
482 427
483 if (!Permissions.BypassPermissions()) 428 if (!Permissions.BypassPermissions())
484 { 429 {
@@ -500,10 +445,6 @@ namespace OpenSim.Region.Framework.Scenes
500 445
501 } 446 }
502 447
503 protected virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
504 {
505 }
506
507 /// <summary> 448 /// <summary>
508 /// Give an entire inventory folder from one user to another. The entire contents (including all descendent 449 /// Give an entire inventory folder from one user to another. The entire contents (including all descendent
509 /// folders) is given. 450 /// folders) is given.
@@ -573,7 +514,9 @@ namespace OpenSim.Region.Framework.Scenes
573 "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}", 514 "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}",
574 remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); 515 remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName);
575 516
576 InventoryItemBase item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(oldItemID); 517 InventoryItemBase item = null;
518 if (LibraryService != null && LibraryService.LibraryRootFolder != null)
519 item = LibraryService.LibraryRootFolder.FindItem(oldItemID);
577 520
578 if (item == null) 521 if (item == null)
579 { 522 {
@@ -627,15 +570,9 @@ namespace OpenSim.Region.Framework.Scenes
627 /// <summary> 570 /// <summary>
628 /// Create a new asset data structure. 571 /// Create a new asset data structure.
629 /// </summary> 572 /// </summary>
630 /// <param name="name"></param> 573 private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data, UUID creatorID)
631 /// <param name="description"></param>
632 /// <param name="invType"></param>
633 /// <param name="assetType"></param>
634 /// <param name="data"></param>
635 /// <returns></returns>
636 private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data)
637 { 574 {
638 AssetBase asset = new AssetBase(UUID.Random(), name, assetType); 575 AssetBase asset = new AssetBase(UUID.Random(), name, assetType, creatorID.ToString());
639 asset.Description = description; 576 asset.Description = description;
640 asset.Data = (data == null) ? new byte[1] : data; 577 asset.Data = (data == null) ? new byte[1] : data;
641 578
@@ -745,13 +682,9 @@ namespace OpenSim.Region.Framework.Scenes
745 682
746 if (transactionID == UUID.Zero) 683 if (transactionID == UUID.Zero)
747 { 684 {
748 CachedUserInfo userInfo 685 ScenePresence presence;
749 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 686 if (TryGetAvatar(remoteClient.AgentId, out presence))
750
751 if (userInfo != null)
752 { 687 {
753 ScenePresence presence;
754 TryGetAvatar(remoteClient.AgentId, out presence);
755 byte[] data = null; 688 byte[] data = null;
756 689
757 if (invType == (sbyte)InventoryType.Landmark && presence != null) 690 if (invType == (sbyte)InventoryType.Landmark && presence != null)
@@ -765,7 +698,7 @@ namespace OpenSim.Region.Framework.Scenes
765 data = Encoding.ASCII.GetBytes(strdata); 698 data = Encoding.ASCII.GetBytes(strdata);
766 } 699 }
767 700
768 AssetBase asset = CreateAsset(name, description, assetType, data); 701 AssetBase asset = CreateAsset(name, description, assetType, data, remoteClient.AgentId);
769 AssetService.Store(asset); 702 AssetService.Store(asset);
770 703
771 CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate); 704 CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate);
@@ -773,7 +706,7 @@ namespace OpenSim.Region.Framework.Scenes
773 else 706 else
774 { 707 {
775 m_log.ErrorFormat( 708 m_log.ErrorFormat(
776 "userInfo for agent uuid {0} unexpectedly null in CreateNewInventoryItem", 709 "ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem",
777 remoteClient.AgentId); 710 remoteClient.AgentId);
778 } 711 }
779 } 712 }
@@ -1170,15 +1103,21 @@ namespace OpenSim.Region.Framework.Scenes
1170 1103
1171 private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems) 1104 private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems)
1172 { 1105 {
1106 if (folder == null)
1107 return;
1108
1173 m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName); 1109 m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName);
1174 InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); 1110 InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID);
1175 InventoryFolderBase containingFolder = new InventoryFolderBase(); 1111 InventoryFolderBase containingFolder = new InventoryFolderBase();
1176 containingFolder.ID = folder.ID; 1112 containingFolder.ID = folder.ID;
1177 containingFolder.Owner = client.AgentId; 1113 containingFolder.Owner = client.AgentId;
1178 containingFolder = InventoryService.GetFolder(containingFolder); 1114 containingFolder = InventoryService.GetFolder(containingFolder);
1179 int version = containingFolder.Version; 1115 if (containingFolder != null)
1116 {
1117 int version = containingFolder.Version;
1180 1118
1181 client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems); 1119 client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems);
1120 }
1182 } 1121 }
1183 1122
1184 /// <summary> 1123 /// <summary>
@@ -1220,9 +1159,9 @@ namespace OpenSim.Region.Framework.Scenes
1220 item = InventoryService.GetItem(item); 1159 item = InventoryService.GetItem(item);
1221 1160
1222 // Try library 1161 // Try library
1223 if (null == item) 1162 if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null)
1224 { 1163 {
1225 item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); 1164 item = LibraryService.LibraryRootFolder.FindItem(itemID);
1226 } 1165 }
1227 1166
1228 if (item != null) 1167 if (item != null)
@@ -1289,9 +1228,9 @@ namespace OpenSim.Region.Framework.Scenes
1289 1228
1290 // Try library 1229 // Try library
1291 // XXX clumsy, possibly should be one call 1230 // XXX clumsy, possibly should be one call
1292 if (null == item) 1231 if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null)
1293 { 1232 {
1294 item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); 1233 item = LibraryService.LibraryRootFolder.FindItem(itemID);
1295 } 1234 }
1296 1235
1297 if (item != null) 1236 if (item != null)
@@ -1348,7 +1287,9 @@ namespace OpenSim.Region.Framework.Scenes
1348 itemBase.InvType, part.UUID, remoteClient.AgentId)) 1287 itemBase.InvType, part.UUID, remoteClient.AgentId))
1349 return; 1288 return;
1350 1289
1351 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}")); 1290 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType,
1291 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"),
1292 remoteClient.AgentId);
1352 AssetService.Store(asset); 1293 AssetService.Store(asset);
1353 1294
1354 TaskInventoryItem taskItem = new TaskInventoryItem(); 1295 TaskInventoryItem taskItem = new TaskInventoryItem();
@@ -1616,237 +1557,6 @@ namespace OpenSim.Region.Framework.Scenes
1616 } 1557 }
1617 } 1558 }
1618 1559
1619 /// <summary>
1620 /// Delete a scene object from a scene and place in the given avatar's inventory.
1621 /// Returns the UUID of the newly created asset.
1622 /// </summary>
1623 /// <param name="action"></param>
1624 /// <param name="folderID"></param>
1625 /// <param name="objectGroup"></param>
1626 /// <param name="remoteClient"> </param>
1627 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
1628 SceneObjectGroup objectGroup, IClientAPI remoteClient)
1629 {
1630 UUID assetID = UUID.Zero;
1631
1632 Vector3 inventoryStoredPosition = new Vector3
1633 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
1634 ? 250
1635 : objectGroup.AbsolutePosition.X)
1636 ,
1637 (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
1638 ? 250
1639 : objectGroup.AbsolutePosition.X,
1640 objectGroup.AbsolutePosition.Z);
1641
1642 Vector3 originalPosition = objectGroup.AbsolutePosition;
1643
1644 objectGroup.AbsolutePosition = inventoryStoredPosition;
1645
1646 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
1647
1648 objectGroup.AbsolutePosition = originalPosition;
1649
1650 // Get the user info of the item destination
1651 //
1652 UUID userID = UUID.Zero;
1653
1654 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
1655 action == DeRezAction.SaveToExistingUserInventoryItem)
1656 {
1657 // Take or take copy require a taker
1658 // Saving changes requires a local user
1659 //
1660 if (remoteClient == null)
1661 return UUID.Zero;
1662
1663 userID = remoteClient.AgentId;
1664 }
1665 else
1666 {
1667 // All returns / deletes go to the object owner
1668 //
1669
1670 userID = objectGroup.RootPart.OwnerID;
1671 }
1672
1673 if (userID == UUID.Zero) // Can't proceed
1674 {
1675 return UUID.Zero;
1676 }
1677
1678 // If we're returning someone's item, it goes back to the
1679 // owner's Lost And Found folder.
1680 // Delete is treated like return in this case
1681 // Deleting your own items makes them go to trash
1682 //
1683
1684 InventoryFolderBase folder = null;
1685 InventoryItemBase item = null;
1686
1687 if (DeRezAction.SaveToExistingUserInventoryItem == action)
1688 {
1689 item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID);
1690 item = InventoryService.GetItem(item);
1691
1692 //item = userInfo.RootFolder.FindItem(
1693 // objectGroup.RootPart.FromUserInventoryItemID);
1694
1695 if (null == item)
1696 {
1697 m_log.DebugFormat(
1698 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
1699 objectGroup.Name, objectGroup.UUID);
1700 return UUID.Zero;
1701 }
1702 }
1703 else
1704 {
1705 // Folder magic
1706 //
1707 if (action == DeRezAction.Delete)
1708 {
1709 // Deleting someone else's item
1710 //
1711
1712
1713 if (remoteClient == null ||
1714 objectGroup.OwnerID != remoteClient.AgentId)
1715 {
1716 // Folder skeleton may not be loaded and we
1717 // have to wait for the inventory to find
1718 // the destination folder
1719 //
1720 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1721 }
1722 else
1723 {
1724 // Assume inventory skeleton was loaded during login
1725 // and all folders can be found
1726 //
1727 folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
1728 }
1729 }
1730 else if (action == DeRezAction.Return)
1731 {
1732
1733 // Dump to lost + found unconditionally
1734 //
1735 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1736 }
1737
1738 if (folderID == UUID.Zero && folder == null)
1739 {
1740 if (action == DeRezAction.Delete)
1741 {
1742 // Deletes go to trash by default
1743 //
1744 folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
1745 }
1746 else
1747 {
1748 // Catch all. Use lost & found
1749 //
1750
1751 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1752 }
1753 }
1754
1755 if (folder == null) // None of the above
1756 {
1757 //folder = userInfo.RootFolder.FindFolder(folderID);
1758 folder = new InventoryFolderBase(folderID);
1759
1760 if (folder == null) // Nowhere to put it
1761 {
1762 return UUID.Zero;
1763 }
1764 }
1765
1766 item = new InventoryItemBase();
1767 item.CreatorId = objectGroup.RootPart.CreatorID.ToString();
1768 item.ID = UUID.Random();
1769 item.InvType = (int)InventoryType.Object;
1770 item.Folder = folder.ID;
1771 item.Owner = userID;
1772 }
1773
1774 AssetBase asset = CreateAsset(
1775 objectGroup.GetPartName(objectGroup.RootPart.LocalId),
1776 objectGroup.GetPartDescription(objectGroup.RootPart.LocalId),
1777 (sbyte)AssetType.Object,
1778 Utils.StringToBytes(sceneObjectXml));
1779 AssetService.Store(asset);
1780 assetID = asset.FullID;
1781
1782 if (DeRezAction.SaveToExistingUserInventoryItem == action)
1783 {
1784 item.AssetID = asset.FullID;
1785 InventoryService.UpdateItem(item);
1786 }
1787 else
1788 {
1789 item.AssetID = asset.FullID;
1790
1791 if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && Permissions.PropagatePermissions())
1792 {
1793 uint perms=objectGroup.GetEffectivePermissions();
1794 uint nextPerms=(perms & 7) << 13;
1795 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
1796 perms &= ~(uint)PermissionMask.Copy;
1797 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
1798 perms &= ~(uint)PermissionMask.Transfer;
1799 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
1800 perms &= ~(uint)PermissionMask.Modify;
1801
1802 item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask;
1803 item.CurrentPermissions = item.BasePermissions;
1804 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1805 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
1806 item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask;
1807 item.CurrentPermissions |= 8; // Slam!
1808 }
1809 else
1810 {
1811 uint ownerPerms = objectGroup.GetEffectivePermissions();
1812 if ((objectGroup.RootPart.OwnerMask & (uint)PermissionMask.Modify) != 0)
1813 ownerPerms |= (uint)PermissionMask.Modify;
1814
1815 item.BasePermissions = ownerPerms;
1816 item.CurrentPermissions = ownerPerms;
1817
1818 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1819 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
1820 item.GroupPermissions = objectGroup.RootPart.GroupMask;
1821
1822 item.CurrentPermissions |= 8; // Slam!
1823 }
1824
1825 // TODO: add the new fields (Flags, Sale info, etc)
1826 item.CreationDate = Util.UnixTimeSinceEpoch();
1827 item.Description = asset.Description;
1828 item.Name = asset.Name;
1829 item.AssetType = asset.Type;
1830
1831 InventoryService.AddItem(item);
1832
1833 if (remoteClient != null && item.Owner == remoteClient.AgentId)
1834 {
1835 remoteClient.SendInventoryItemCreateUpdate(item, 0);
1836 }
1837 else
1838 {
1839 ScenePresence notifyUser = GetScenePresence(item.Owner);
1840 if (notifyUser != null)
1841 {
1842 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
1843 }
1844 }
1845 }
1846
1847 return assetID;
1848 }
1849
1850 public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID) 1560 public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
1851 { 1561 {
1852 SceneObjectGroup objectGroup = grp; 1562 SceneObjectGroup objectGroup = grp;
@@ -1873,7 +1583,8 @@ namespace OpenSim.Region.Framework.Scenes
1873 objectGroup.GetPartName(objectGroup.LocalId), 1583 objectGroup.GetPartName(objectGroup.LocalId),
1874 objectGroup.GetPartDescription(objectGroup.LocalId), 1584 objectGroup.GetPartDescription(objectGroup.LocalId),
1875 (sbyte)AssetType.Object, 1585 (sbyte)AssetType.Object,
1876 Utils.StringToBytes(sceneObjectXml)); 1586 Utils.StringToBytes(sceneObjectXml),
1587 remoteClient.AgentId);
1877 AssetService.Store(asset); 1588 AssetService.Store(asset);
1878 1589
1879 item.AssetID = asset.FullID; 1590 item.AssetID = asset.FullID;
@@ -1920,7 +1631,8 @@ namespace OpenSim.Region.Framework.Scenes
1920 grp.GetPartName(grp.LocalId), 1631 grp.GetPartName(grp.LocalId),
1921 grp.GetPartDescription(grp.LocalId), 1632 grp.GetPartDescription(grp.LocalId),
1922 (sbyte)AssetType.Object, 1633 (sbyte)AssetType.Object,
1923 Utils.StringToBytes(sceneObjectXml)); 1634 Utils.StringToBytes(sceneObjectXml),
1635 remoteClient.AgentId);
1924 AssetService.Store(asset); 1636 AssetService.Store(asset);
1925 1637
1926 InventoryItemBase item = new InventoryItemBase(); 1638 InventoryItemBase item = new InventoryItemBase();
@@ -1987,225 +1699,11 @@ namespace OpenSim.Region.Framework.Scenes
1987 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 1699 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
1988 bool RezSelected, bool RemoveItem, UUID fromTaskID) 1700 bool RezSelected, bool RemoveItem, UUID fromTaskID)
1989 { 1701 {
1990 RezObject( 1702 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
1991 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, 1703 if (invAccess != null)
1992 RezSelected, RemoveItem, fromTaskID, false); 1704 invAccess.RezObject(
1993 } 1705 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
1994 1706 RezSelected, RemoveItem, fromTaskID, false);
1995 /// <summary>
1996 /// Rez an object into the scene from the user's inventory
1997 /// </summary>
1998 /// <param name="remoteClient"></param>
1999 /// <param name="itemID"></param>
2000 /// <param name="RayEnd"></param>
2001 /// <param name="RayStart"></param>
2002 /// <param name="RayTargetID"></param>
2003 /// <param name="BypassRayCast"></param>
2004 /// <param name="RayEndIsIntersection"></param>
2005 /// <param name="RezSelected"></param>
2006 /// <param name="RemoveItem"></param>
2007 /// <param name="fromTaskID"></param>
2008 /// <param name="attachment"></param>
2009 /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful.</returns>
2010 public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart,
2011 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
2012 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
2013 {
2014 // Work out position details
2015 byte bRayEndIsIntersection = (byte)0;
2016
2017 if (RayEndIsIntersection)
2018 {
2019 bRayEndIsIntersection = (byte)1;
2020 }
2021 else
2022 {
2023 bRayEndIsIntersection = (byte)0;
2024 }
2025
2026 Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f);
2027
2028
2029 Vector3 pos = GetNewRezLocation(
2030 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
2031 BypassRayCast, bRayEndIsIntersection,true,scale, false);
2032
2033 // Rez object
2034 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2035 item = InventoryService.GetItem(item);
2036
2037 if (item != null)
2038 {
2039 AssetBase rezAsset = AssetService.Get(item.AssetID.ToString());
2040
2041 if (rezAsset != null)
2042 {
2043 UUID itemId = UUID.Zero;
2044
2045 // If we have permission to copy then link the rezzed object back to the user inventory
2046 // item that it came from. This allows us to enable 'save object to inventory'
2047 if (!Permissions.BypassPermissions())
2048 {
2049 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy)
2050 {
2051 itemId = item.ID;
2052 }
2053 }
2054 else
2055 {
2056 // Brave new fullperm world
2057 //
2058 itemId = item.ID;
2059 }
2060
2061 string xmlData = Utils.BytesToString(rezAsset.Data);
2062 SceneObjectGroup group
2063 = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData);
2064
2065 if (!Permissions.CanRezObject(
2066 group.Children.Count, remoteClient.AgentId, pos)
2067 && !attachment)
2068 {
2069 // The client operates in no fail mode. It will
2070 // have already removed the item from the folder
2071 // if it's no copy.
2072 // Put it back if it's not an attachment
2073 //
2074 if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment))
2075 remoteClient.SendBulkUpdateInventory(item);
2076 return null;
2077 }
2078
2079 group.ResetIDs();
2080
2081 if (attachment)
2082 {
2083 group.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom;
2084 group.RootPart.IsAttachment = true;
2085 }
2086
2087 AddNewSceneObject(group, true);
2088
2089 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z);
2090 // if attachment we set it's asset id so object updates can reflect that
2091 // if not, we set it's position in world.
2092 if (!attachment)
2093 {
2094 float offsetHeight = 0;
2095 pos = GetNewRezLocation(
2096 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
2097 BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false);
2098 pos.Z += offsetHeight;
2099 group.AbsolutePosition = pos;
2100 // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight);
2101
2102 }
2103 else
2104 {
2105 group.SetFromItemID(itemID);
2106 }
2107
2108 SceneObjectPart rootPart = null;
2109 try
2110 {
2111 rootPart = group.GetChildPart(group.UUID);
2112 }
2113 catch (NullReferenceException)
2114 {
2115 string isAttachment = "";
2116
2117 if (attachment)
2118 isAttachment = " Object was an attachment";
2119
2120 m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment);
2121 }
2122
2123 // Since renaming the item in the inventory does not affect the name stored
2124 // in the serialization, transfer the correct name from the inventory to the
2125 // object itself before we rez.
2126 rootPart.Name = item.Name;
2127 rootPart.Description = item.Description;
2128
2129 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values);
2130
2131 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
2132 if (rootPart.OwnerID != item.Owner)
2133 {
2134 //Need to kill the for sale here
2135 rootPart.ObjectSaleType = 0;
2136 rootPart.SalePrice = 10;
2137
2138 if (Permissions.PropagatePermissions())
2139 {
2140 if ((item.CurrentPermissions & 8) != 0)
2141 {
2142 foreach (SceneObjectPart part in partList)
2143 {
2144 part.EveryoneMask = item.EveryOnePermissions;
2145 part.NextOwnerMask = item.NextPermissions;
2146 part.GroupMask = 0; // DO NOT propagate here
2147 }
2148 }
2149 group.ApplyNextOwnerPermissions();
2150 }
2151 }
2152
2153 foreach (SceneObjectPart part in partList)
2154 {
2155 if (part.OwnerID != item.Owner)
2156 {
2157 part.LastOwnerID = part.OwnerID;
2158 part.OwnerID = item.Owner;
2159 part.Inventory.ChangeInventoryOwner(item.Owner);
2160 }
2161 else if (((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam!
2162 {
2163 part.EveryoneMask = item.EveryOnePermissions;
2164 part.NextOwnerMask = item.NextPermissions;
2165
2166 part.GroupMask = 0; // DO NOT propagate here
2167 }
2168 }
2169
2170 rootPart.TrimPermissions();
2171
2172 if (!attachment)
2173 {
2174 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
2175 {
2176 group.ClearPartAttachmentData();
2177 }
2178 }
2179
2180 if (!attachment)
2181 {
2182 // Fire on_rez
2183 group.CreateScriptInstances(0, true, DefaultScriptEngine, 0);
2184
2185 rootPart.ScheduleFullUpdate();
2186 }
2187
2188 if (!Permissions.BypassPermissions())
2189 {
2190 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
2191 {
2192 // If this is done on attachments, no
2193 // copy ones will be lost, so avoid it
2194 //
2195 if (!attachment)
2196 {
2197 List<UUID> uuids = new List<UUID>();
2198 uuids.Add(item.ID);
2199 InventoryService.DeleteItems(item.Owner, uuids);
2200 }
2201 }
2202 }
2203
2204 return rootPart.ParentGroup;
2205 }
2206 }
2207
2208 return null;
2209 } 1707 }
2210 1708
2211 /// <summary> 1709 /// <summary>
@@ -2429,7 +1927,7 @@ namespace OpenSim.Region.Framework.Scenes
2429 // XXYY!! 1927 // XXYY!!
2430 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 1928 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2431 item = InventoryService.GetItem(item); 1929 item = InventoryService.GetItem(item);
2432 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); 1930 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */);
2433 1931
2434 if (m_AvatarFactory != null) 1932 if (m_AvatarFactory != null)
2435 { 1933 {
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index ac04dc7..bc10230 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -32,7 +32,7 @@ using OpenMetaverse;
32using OpenMetaverse.Packets; 32using OpenMetaverse.Packets;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache; 35using OpenSim.Services.Interfaces;
36 36
37namespace OpenSim.Region.Framework.Scenes 37namespace OpenSim.Region.Framework.Scenes
38{ 38{
@@ -371,14 +371,16 @@ namespace OpenSim.Region.Framework.Scenes
371 { 371 {
372 //EventManager.TriggerAvatarPickerRequest(); 372 //EventManager.TriggerAvatarPickerRequest();
373 373
374 List<AvatarPickerAvatar> AvatarResponses = new List<AvatarPickerAvatar>(); 374 List<UserAccount> accounts = UserAccountService.GetUserAccounts(RegionInfo.ScopeID, query);
375 AvatarResponses = m_sceneGridService.GenerateAgentPickerRequestResponse(RequestID, query); 375
376 if (accounts == null)
377 return;
376 378
377 AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply); 379 AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply);
378 // TODO: don't create new blocks if recycling an old packet 380 // TODO: don't create new blocks if recycling an old packet
379 381
380 AvatarPickerReplyPacket.DataBlock[] searchData = 382 AvatarPickerReplyPacket.DataBlock[] searchData =
381 new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count]; 383 new AvatarPickerReplyPacket.DataBlock[accounts.Count];
382 AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); 384 AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock();
383 385
384 agentData.AgentID = avatarID; 386 agentData.AgentID = avatarID;
@@ -387,16 +389,16 @@ namespace OpenSim.Region.Framework.Scenes
387 //byte[] bytes = new byte[AvatarResponses.Count*32]; 389 //byte[] bytes = new byte[AvatarResponses.Count*32];
388 390
389 int i = 0; 391 int i = 0;
390 foreach (AvatarPickerAvatar item in AvatarResponses) 392 foreach (UserAccount item in accounts)
391 { 393 {
392 UUID translatedIDtem = item.AvatarID; 394 UUID translatedIDtem = item.PrincipalID;
393 searchData[i] = new AvatarPickerReplyPacket.DataBlock(); 395 searchData[i] = new AvatarPickerReplyPacket.DataBlock();
394 searchData[i].AvatarID = translatedIDtem; 396 searchData[i].AvatarID = translatedIDtem;
395 searchData[i].FirstName = Utils.StringToBytes((string) item.firstName); 397 searchData[i].FirstName = Utils.StringToBytes((string) item.FirstName);
396 searchData[i].LastName = Utils.StringToBytes((string) item.lastName); 398 searchData[i].LastName = Utils.StringToBytes((string) item.LastName);
397 i++; 399 i++;
398 } 400 }
399 if (AvatarResponses.Count == 0) 401 if (accounts.Count == 0)
400 { 402 {
401 searchData = new AvatarPickerReplyPacket.DataBlock[0]; 403 searchData = new AvatarPickerReplyPacket.DataBlock[0];
402 } 404 }
@@ -455,7 +457,24 @@ namespace OpenSim.Region.Framework.Scenes
455 } 457 }
456 ); 458 );
457 } 459 }
458 460
461 public void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client)
462 {
463 if (LibraryService != null && (LibraryService.LibraryRootFolder.Owner == uuid))
464 {
465 remote_client.SendNameReply(uuid, "Mr", "OpenSim");
466 }
467 else
468 {
469 string[] names = GetUserNames(uuid);
470 if (names.Length == 2)
471 {
472 remote_client.SendNameReply(uuid, names[0], names[1]);
473 }
474
475 }
476 }
477
459 /// <summary> 478 /// <summary>
460 /// Handle a fetch inventory request from the client 479 /// Handle a fetch inventory request from the client
461 /// </summary> 480 /// </summary>
@@ -464,7 +483,7 @@ namespace OpenSim.Region.Framework.Scenes
464 /// <param name="ownerID"></param> 483 /// <param name="ownerID"></param>
465 public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID) 484 public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID)
466 { 485 {
467 if (ownerID == CommsManager.UserProfileCacheService.LibraryRoot.Owner) 486 if (LibraryService != null && LibraryService.LibraryRootFolder != null && ownerID == LibraryService.LibraryRootFolder.Owner)
468 { 487 {
469 //m_log.Debug("request info for library item"); 488 //m_log.Debug("request info for library item");
470 return; 489 return;
@@ -498,13 +517,14 @@ namespace OpenSim.Region.Framework.Scenes
498 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. 517 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc.
499 // can be handled transparently). 518 // can be handled transparently).
500 InventoryFolderImpl fold = null; 519 InventoryFolderImpl fold = null;
501 if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) 520 if (LibraryService != null && LibraryService.LibraryRootFolder != null)
502 { 521 if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null)
503 remoteClient.SendInventoryFolderDetails( 522 {
504 fold.Owner, folderID, fold.RequestListOfItems(), 523 remoteClient.SendInventoryFolderDetails(
505 fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); 524 fold.Owner, folderID, fold.RequestListOfItems(),
506 return; 525 fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems);
507 } 526 return;
527 }
508 528
509 // We're going to send the reply async, because there may be 529 // We're going to send the reply async, because there may be
510 // an enormous quantity of packets -- basically the entire inventory! 530 // an enormous quantity of packets -- basically the entire inventory!
@@ -552,15 +572,16 @@ namespace OpenSim.Region.Framework.Scenes
552 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. 572 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc.
553 // can be handled transparently). 573 // can be handled transparently).
554 InventoryFolderImpl fold; 574 InventoryFolderImpl fold;
555 if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) 575 if (LibraryService != null && LibraryService.LibraryRootFolder != null)
556 { 576 if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null)
557 version = 0; 577 {
558 InventoryCollection ret = new InventoryCollection(); 578 version = 0;
559 ret.Folders = new List<InventoryFolderBase>(); 579 InventoryCollection ret = new InventoryCollection();
560 ret.Items = fold.RequestListOfItems(); 580 ret.Folders = new List<InventoryFolderBase>();
581 ret.Items = fold.RequestListOfItems();
561 582
562 return ret; 583 return ret;
563 } 584 }
564 585
565 InventoryCollection contents = new InventoryCollection(); 586 InventoryCollection contents = new InventoryCollection();
566 587
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 4d357fd..181b7c5 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -41,8 +41,7 @@ using OpenMetaverse.Imaging;
41using OpenSim.Framework; 41using OpenSim.Framework;
42using OpenSim.Services.Interfaces; 42using OpenSim.Services.Interfaces;
43using OpenSim.Framework.Communications; 43using OpenSim.Framework.Communications;
44using OpenSim.Framework.Communications.Cache; 44
45using OpenSim.Framework.Communications.Clients;
46using OpenSim.Framework.Console; 45using OpenSim.Framework.Console;
47using OpenSim.Region.Framework.Interfaces; 46using OpenSim.Region.Framework.Interfaces;
48using OpenSim.Region.Framework.Scenes.Scripting; 47using OpenSim.Region.Framework.Scenes.Scripting;
@@ -141,7 +140,6 @@ namespace OpenSim.Region.Framework.Scenes
141 protected ModuleLoader m_moduleLoader; 140 protected ModuleLoader m_moduleLoader;
142 protected StorageManager m_storageManager; 141 protected StorageManager m_storageManager;
143 protected AgentCircuitManager m_authenticateHandler; 142 protected AgentCircuitManager m_authenticateHandler;
144 public CommunicationsManager CommsManager;
145 143
146 protected SceneCommunicationService m_sceneGridService; 144 protected SceneCommunicationService m_sceneGridService;
147 public bool LoginsDisabled = true; 145 public bool LoginsDisabled = true;
@@ -189,11 +187,11 @@ namespace OpenSim.Region.Framework.Scenes
189 { 187 {
190 m_AuthorizationService = RequestModuleInterface<IAuthorizationService>(); 188 m_AuthorizationService = RequestModuleInterface<IAuthorizationService>();
191 189
192 if (m_AuthorizationService == null) 190 //if (m_AuthorizationService == null)
193 { 191 //{
194 // don't throw an exception if no authorization service is set for the time being 192 // // don't throw an exception if no authorization service is set for the time being
195 m_log.InfoFormat("[SCENE]: No Authorization service is configured"); 193 // m_log.InfoFormat("[SCENE]: No Authorization service is configured");
196 } 194 //}
197 } 195 }
198 196
199 return m_AuthorizationService; 197 return m_AuthorizationService;
@@ -240,6 +238,73 @@ namespace OpenSim.Region.Framework.Scenes
240 } 238 }
241 } 239 }
242 240
241 protected ILibraryService m_LibraryService;
242
243 public ILibraryService LibraryService
244 {
245 get
246 {
247 if (m_LibraryService == null)
248 m_LibraryService = RequestModuleInterface<ILibraryService>();
249
250 return m_LibraryService;
251 }
252 }
253
254 protected ISimulationService m_simulationService;
255 public ISimulationService SimulationService
256 {
257 get
258 {
259 if (m_simulationService == null)
260 m_simulationService = RequestModuleInterface<ISimulationService>();
261 return m_simulationService;
262 }
263 }
264
265 protected IAuthenticationService m_AuthenticationService;
266 public IAuthenticationService AuthenticationService
267 {
268 get
269 {
270 if (m_AuthenticationService == null)
271 m_AuthenticationService = RequestModuleInterface<IAuthenticationService>();
272 return m_AuthenticationService;
273 }
274 }
275
276 protected IPresenceService m_PresenceService;
277 public IPresenceService PresenceService
278 {
279 get
280 {
281 if (m_PresenceService == null)
282 m_PresenceService = RequestModuleInterface<IPresenceService>();
283 return m_PresenceService;
284 }
285 }
286 protected IUserAccountService m_UserAccountService;
287 public IUserAccountService UserAccountService
288 {
289 get
290 {
291 if (m_UserAccountService == null)
292 m_UserAccountService = RequestModuleInterface<IUserAccountService>();
293 return m_UserAccountService;
294 }
295 }
296
297 protected OpenSim.Services.Interfaces.IAvatarService m_AvatarService;
298 public OpenSim.Services.Interfaces.IAvatarService AvatarService
299 {
300 get
301 {
302 if (m_AvatarService == null)
303 m_AvatarService = RequestModuleInterface<IAvatarService>();
304 return m_AvatarService;
305 }
306 }
307
243 protected IXMLRPC m_xmlrpcModule; 308 protected IXMLRPC m_xmlrpcModule;
244 protected IWorldComm m_worldCommModule; 309 protected IWorldComm m_worldCommModule;
245 protected IAvatarFactory m_AvatarFactory; 310 protected IAvatarFactory m_AvatarFactory;
@@ -249,10 +314,8 @@ namespace OpenSim.Region.Framework.Scenes
249 } 314 }
250 protected IConfigSource m_config; 315 protected IConfigSource m_config;
251 protected IRegionSerialiserModule m_serialiser; 316 protected IRegionSerialiserModule m_serialiser;
252 protected IInterregionCommsOut m_interregionCommsOut;
253 protected IInterregionCommsIn m_interregionCommsIn;
254 protected IDialogModule m_dialogModule; 317 protected IDialogModule m_dialogModule;
255 protected ITeleportModule m_teleportModule; 318 protected IEntityTransferModule m_teleportModule;
256 319
257 protected ICapabilitiesModule m_capsModule; 320 protected ICapabilitiesModule m_capsModule;
258 public ICapabilitiesModule CapsModule 321 public ICapabilitiesModule CapsModule
@@ -483,7 +546,7 @@ namespace OpenSim.Region.Framework.Scenes
483 #region Constructors 546 #region Constructors
484 547
485 public Scene(RegionInfo regInfo, AgentCircuitManager authen, 548 public Scene(RegionInfo regInfo, AgentCircuitManager authen,
486 CommunicationsManager commsMan, SceneCommunicationService sceneGridService, 549 SceneCommunicationService sceneGridService,
487 StorageManager storeManager, 550 StorageManager storeManager,
488 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, 551 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim,
489 bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) 552 bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion)
@@ -519,7 +582,6 @@ namespace OpenSim.Region.Framework.Scenes
519 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); 582 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4);
520 m_moduleLoader = moduleLoader; 583 m_moduleLoader = moduleLoader;
521 m_authenticateHandler = authen; 584 m_authenticateHandler = authen;
522 CommsManager = commsMan;
523 m_sceneGridService = sceneGridService; 585 m_sceneGridService = sceneGridService;
524 m_storageManager = storeManager; 586 m_storageManager = storeManager;
525 m_regInfo = regInfo; 587 m_regInfo = regInfo;
@@ -778,6 +840,36 @@ namespace OpenSim.Region.Framework.Scenes
778 return m_simulatorVersion; 840 return m_simulatorVersion;
779 } 841 }
780 842
843 public string[] GetUserNames(UUID uuid)
844 {
845 string[] returnstring = new string[0];
846
847 UserAccount account = UserAccountService.GetUserAccount(RegionInfo.ScopeID, uuid);
848
849 if (account != null)
850 {
851 returnstring = new string[2];
852 returnstring[0] = account.FirstName;
853 returnstring[1] = account.LastName;
854 }
855
856 return returnstring;
857 }
858
859 public string GetUserName(UUID uuid)
860 {
861 string[] names = GetUserNames(uuid);
862 if (names.Length == 2)
863 {
864 string firstname = names[0];
865 string lastname = names[1];
866
867 return firstname + " " + lastname;
868
869 }
870 return "(hippos)";
871 }
872
781 /// <summary> 873 /// <summary>
782 /// Another region is up. 874 /// Another region is up.
783 /// 875 ///
@@ -811,7 +903,7 @@ namespace OpenSim.Region.Framework.Scenes
811 regInfo.RegionName = otherRegion.RegionName; 903 regInfo.RegionName = otherRegion.RegionName;
812 regInfo.ScopeID = otherRegion.ScopeID; 904 regInfo.ScopeID = otherRegion.ScopeID;
813 regInfo.ExternalHostName = otherRegion.ExternalHostName; 905 regInfo.ExternalHostName = otherRegion.ExternalHostName;
814 906 GridRegion r = new GridRegion(regInfo);
815 try 907 try
816 { 908 {
817 ForEachScenePresence(delegate(ScenePresence agent) 909 ForEachScenePresence(delegate(ScenePresence agent)
@@ -825,7 +917,8 @@ namespace OpenSim.Region.Framework.Scenes
825 List<ulong> old = new List<ulong>(); 917 List<ulong> old = new List<ulong>();
826 old.Add(otherRegion.RegionHandle); 918 old.Add(otherRegion.RegionHandle);
827 agent.DropOldNeighbours(old); 919 agent.DropOldNeighbours(old);
828 InformClientOfNeighbor(agent, regInfo); 920 if (m_teleportModule != null)
921 m_teleportModule.EnableChildAgent(agent, r);
829 } 922 }
830 } 923 }
831 ); 924 );
@@ -985,6 +1078,7 @@ namespace OpenSim.Region.Framework.Scenes
985 { 1078 {
986 foreach (RegionInfo region in m_regionRestartNotifyList) 1079 foreach (RegionInfo region in m_regionRestartNotifyList)
987 { 1080 {
1081 GridRegion r = new GridRegion(region);
988 try 1082 try
989 { 1083 {
990 ForEachScenePresence(delegate(ScenePresence agent) 1084 ForEachScenePresence(delegate(ScenePresence agent)
@@ -992,9 +1086,8 @@ namespace OpenSim.Region.Framework.Scenes
992 // If agent is a root agent. 1086 // If agent is a root agent.
993 if (!agent.IsChildAgent) 1087 if (!agent.IsChildAgent)
994 { 1088 {
995 //agent.ControllingClient.new 1089 if (m_teleportModule != null)
996 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); 1090 m_teleportModule.EnableChildAgent(agent, r);
997 InformClientOfNeighbor(agent, region);
998 } 1091 }
999 } 1092 }
1000 ); 1093 );
@@ -1137,11 +1230,9 @@ namespace OpenSim.Region.Framework.Scenes
1137 XferManager = RequestModuleInterface<IXfer>(); 1230 XferManager = RequestModuleInterface<IXfer>();
1138 m_AvatarFactory = RequestModuleInterface<IAvatarFactory>(); 1231 m_AvatarFactory = RequestModuleInterface<IAvatarFactory>();
1139 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); 1232 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>();
1140 m_interregionCommsOut = RequestModuleInterface<IInterregionCommsOut>();
1141 m_interregionCommsIn = RequestModuleInterface<IInterregionCommsIn>();
1142 m_dialogModule = RequestModuleInterface<IDialogModule>(); 1233 m_dialogModule = RequestModuleInterface<IDialogModule>();
1143 m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); 1234 m_capsModule = RequestModuleInterface<ICapabilitiesModule>();
1144 m_teleportModule = RequestModuleInterface<ITeleportModule>(); 1235 m_teleportModule = RequestModuleInterface<IEntityTransferModule>();
1145 } 1236 }
1146 1237
1147 #endregion 1238 #endregion
@@ -1591,7 +1682,9 @@ namespace OpenSim.Region.Framework.Scenes
1591 GridRegion region = new GridRegion(RegionInfo); 1682 GridRegion region = new GridRegion(RegionInfo);
1592 string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); 1683 string error = GridService.RegisterRegion(RegionInfo.ScopeID, region);
1593 if (error != String.Empty) 1684 if (error != String.Empty)
1685 {
1594 throw new Exception(error); 1686 throw new Exception(error);
1687 }
1595 1688
1596 m_sceneGridService.SetScene(this); 1689 m_sceneGridService.SetScene(this);
1597 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); 1690 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo);
@@ -1978,7 +2071,6 @@ namespace OpenSim.Region.Framework.Scenes
1978 /// Move the given scene object into a new region depending on which region its absolute position has moved 2071 /// Move the given scene object into a new region depending on which region its absolute position has moved
1979 /// into. 2072 /// into.
1980 /// 2073 ///
1981 /// This method locates the new region handle and offsets the prim position for the new region
1982 /// </summary> 2074 /// </summary>
1983 /// <param name="attemptedPosition">the attempted out of region position of the scene object</param> 2075 /// <param name="attemptedPosition">the attempted out of region position of the scene object</param>
1984 /// <param name="grp">the scene object that we're crossing</param> 2076 /// <param name="grp">the scene object that we're crossing</param>
@@ -2003,185 +2095,25 @@ namespace OpenSim.Region.Framework.Scenes
2003 return; 2095 return;
2004 } 2096 }
2005 2097
2006 int thisx = (int)RegionInfo.RegionLocX; 2098 if (grp.RootPart.RETURN_AT_EDGE)
2007 int thisy = (int)RegionInfo.RegionLocY;
2008 Vector3 EastCross = new Vector3(0.1f,0,0);
2009 Vector3 WestCross = new Vector3(-0.1f, 0, 0);
2010 Vector3 NorthCross = new Vector3(0, 0.1f, 0);
2011 Vector3 SouthCross = new Vector3(0, -0.1f, 0);
2012
2013
2014 // use this if no borders were crossed!
2015 ulong newRegionHandle
2016 = Util.UIntsToLong((uint)((thisx) * Constants.RegionSize),
2017 (uint)((thisy) * Constants.RegionSize));
2018
2019 Vector3 pos = attemptedPosition;
2020
2021 int changeX = 1;
2022 int changeY = 1;
2023
2024 if (TestBorderCross(attemptedPosition + WestCross, Cardinals.W))
2025 {
2026 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
2027 {
2028
2029 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
2030
2031 if (crossedBorderx.BorderLine.Z > 0)
2032 {
2033 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
2034 changeX = (int)(crossedBorderx.BorderLine.Z /(int) Constants.RegionSize);
2035 }
2036 else
2037 pos.X = ((pos.X + Constants.RegionSize));
2038
2039 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2040 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2041
2042 if (crossedBordery.BorderLine.Z > 0)
2043 {
2044 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
2045 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2046 }
2047 else
2048 pos.Y = ((pos.Y + Constants.RegionSize));
2049
2050
2051
2052 newRegionHandle
2053 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
2054 (uint)((thisy - changeY) * Constants.RegionSize));
2055 // x - 1
2056 // y - 1
2057 }
2058 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
2059 {
2060 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
2061
2062 if (crossedBorderx.BorderLine.Z > 0)
2063 {
2064 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
2065 changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize);
2066 }
2067 else
2068 pos.X = ((pos.X + Constants.RegionSize));
2069
2070
2071 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2072 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2073
2074 if (crossedBordery.BorderLine.Z > 0)
2075 {
2076 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
2077 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2078 }
2079 else
2080 pos.Y = ((pos.Y + Constants.RegionSize));
2081
2082 newRegionHandle
2083 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
2084 (uint)((thisy + changeY) * Constants.RegionSize));
2085 // x - 1
2086 // y + 1
2087 }
2088 else
2089 {
2090 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
2091
2092 if (crossedBorderx.BorderLine.Z > 0)
2093 {
2094 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
2095 changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize);
2096 }
2097 else
2098 pos.X = ((pos.X + Constants.RegionSize));
2099
2100 newRegionHandle
2101 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
2102 (uint) (thisy*Constants.RegionSize));
2103 // x - 1
2104 }
2105 }
2106 else if (TestBorderCross(attemptedPosition + EastCross, Cardinals.E))
2107 { 2099 {
2108 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) 2100 // We remove the object here
2109 { 2101 try
2110
2111 pos.X = ((pos.X - Constants.RegionSize));
2112 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2113 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2114
2115 if (crossedBordery.BorderLine.Z > 0)
2116 {
2117 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
2118 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2119 }
2120 else
2121 pos.Y = ((pos.Y + Constants.RegionSize));
2122
2123
2124 newRegionHandle
2125 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
2126 (uint)((thisy - changeY) * Constants.RegionSize));
2127 // x + 1
2128 // y - 1
2129 }
2130 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
2131 {
2132 pos.X = ((pos.X - Constants.RegionSize));
2133 pos.Y = ((pos.Y - Constants.RegionSize));
2134 newRegionHandle
2135 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
2136 (uint)((thisy + changeY) * Constants.RegionSize));
2137 // x + 1
2138 // y + 1
2139 }
2140 else
2141 { 2102 {
2142 pos.X = ((pos.X - Constants.RegionSize)); 2103 List<SceneObjectGroup> objects = new List<SceneObjectGroup>();
2143 newRegionHandle 2104 objects.Add(grp);
2144 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), 2105 SceneObjectGroup[] objectsArray = objects.ToArray();
2145 (uint) (thisy*Constants.RegionSize)); 2106 returnObjects(objectsArray, UUID.Zero);
2146 // x + 1
2147 } 2107 }
2148 } 2108 catch (Exception)
2149 else if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
2150 {
2151 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2152 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2153
2154 if (crossedBordery.BorderLine.Z > 0)
2155 { 2109 {
2156 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); 2110 m_log.Warn("[DATABASE]: exception when trying to return the prim that crossed the border.");
2157 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2158 } 2111 }
2159 else 2112 return;
2160 pos.Y = ((pos.Y + Constants.RegionSize));
2161
2162 newRegionHandle
2163 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - changeY) * Constants.RegionSize));
2164 // y - 1
2165 }
2166 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
2167 {
2168
2169 pos.Y = ((pos.Y - Constants.RegionSize));
2170 newRegionHandle
2171 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + changeY) * Constants.RegionSize));
2172 // y + 1
2173 } 2113 }
2174 2114
2175 // Offset the positions for the new region across the border 2115 if (m_teleportModule != null)
2176 Vector3 oldGroupPosition = grp.RootPart.GroupPosition; 2116 m_teleportModule.Cross(grp, attemptedPosition, silent);
2177 grp.OffsetForNewRegion(pos);
2178
2179 // If we fail to cross the border, then reset the position of the scene object on that border.
2180 if (!CrossPrimGroupIntoNewRegion(newRegionHandle, grp, silent))
2181 {
2182 grp.OffsetForNewRegion(oldGroupPosition);
2183 grp.ScheduleGroupForFullUpdate();
2184 }
2185 } 2117 }
2186 2118
2187 public Border GetCrossedBorder(Vector3 position, Cardinals gridline) 2119 public Border GetCrossedBorder(Vector3 position, Cardinals gridline)
@@ -2365,75 +2297,6 @@ namespace OpenSim.Region.Framework.Scenes
2365 2297
2366 2298
2367 /// <summary> 2299 /// <summary>
2368 /// Move the given scene object into a new region
2369 /// </summary>
2370 /// <param name="newRegionHandle"></param>
2371 /// <param name="grp">Scene Object Group that we're crossing</param>
2372 /// <returns>
2373 /// true if the crossing itself was successful, false on failure
2374 /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region
2375 /// </returns>
2376 public bool CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp, bool silent)
2377 {
2378 //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<");
2379
2380 bool successYN = false;
2381 grp.RootPart.UpdateFlag = 0;
2382 //int primcrossingXMLmethod = 0;
2383
2384 if (newRegionHandle != 0)
2385 {
2386 //string objectState = grp.GetStateSnapshot();
2387
2388 //successYN
2389 // = m_sceneGridService.PrimCrossToNeighboringRegion(
2390 // newRegionHandle, grp.UUID, m_serialiser.SaveGroupToXml2(grp), primcrossingXMLmethod);
2391 //if (successYN && (objectState != "") && m_allowScriptCrossings)
2392 //{
2393 // successYN = m_sceneGridService.PrimCrossToNeighboringRegion(
2394 // newRegionHandle, grp.UUID, objectState, 100);
2395 //}
2396
2397 // And the new channel...
2398 if (m_interregionCommsOut != null)
2399 successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp, true);
2400
2401 if (successYN)
2402 {
2403 // We remove the object here
2404 try
2405 {
2406 DeleteSceneObject(grp, silent);
2407 }
2408 catch (Exception e)
2409 {
2410 m_log.ErrorFormat(
2411 "[INTERREGION]: Exception deleting the old object left behind on a border crossing for {0}, {1}",
2412 grp, e);
2413 }
2414 }
2415 else
2416 {
2417 if (!grp.IsDeleted)
2418 {
2419 if (grp.RootPart.PhysActor != null)
2420 {
2421 grp.RootPart.PhysActor.CrossingFailure();
2422 }
2423 }
2424
2425 m_log.ErrorFormat("[INTERREGION]: Prim crossing failed for {0}", grp);
2426 }
2427 }
2428 else
2429 {
2430 m_log.Error("[INTERREGION]: region handle was unexpectedly 0 in Scene.CrossPrimGroupIntoNewRegion()");
2431 }
2432
2433 return successYN;
2434 }
2435
2436 /// <summary>
2437 /// Called when objects or attachments cross the border between regions. 2300 /// Called when objects or attachments cross the border between regions.
2438 /// </summary> 2301 /// </summary>
2439 /// <param name="sog"></param> 2302 /// <param name="sog"></param>
@@ -2505,6 +2368,9 @@ namespace OpenSim.Region.Framework.Scenes
2505 2368
2506 return false; 2369 return false;
2507 } 2370 }
2371
2372 sceneObject.SetScene(this);
2373
2508 // Force allocation of new LocalId 2374 // Force allocation of new LocalId
2509 // 2375 //
2510 foreach (SceneObjectPart p in sceneObject.Children.Values) 2376 foreach (SceneObjectPart p in sceneObject.Children.Values)
@@ -2545,7 +2411,7 @@ namespace OpenSim.Region.Framework.Scenes
2545 AttachObject( 2411 AttachObject(
2546 sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false); 2412 sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false);
2547 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2413 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2548 grp.SendGroupFullUpdate(); 2414 grp.SendGroupFullUpdate();
2549 } 2415 }
2550 else 2416 else
2551 { 2417 {
@@ -2583,6 +2449,8 @@ namespace OpenSim.Region.Framework.Scenes
2583 /// <param name="client"></param> 2449 /// <param name="client"></param>
2584 public override void AddNewClient(IClientAPI client) 2450 public override void AddNewClient(IClientAPI client)
2585 { 2451 {
2452 bool vialogin = false;
2453
2586 m_clientManager.Add(client); 2454 m_clientManager.Add(client);
2587 2455
2588 CheckHeartbeat(); 2456 CheckHeartbeat();
@@ -2617,23 +2485,48 @@ namespace OpenSim.Region.Framework.Scenes
2617 { 2485 {
2618 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); 2486 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
2619 2487
2620 m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); 2488 // Do the verification here
2621 /* 2489 System.Net.EndPoint ep = client.GetClientEP();
2622 string logMsg = string.Format("[SCENE]: Adding new {0} agent for {1} in {2}", 2490 if (aCircuit != null)
2623 ((aCircuit.child == true) ? "child" : "root"), client.Name, 2491 {
2624 RegionInfo.RegionName); 2492 if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0)
2625 2493 {
2626 m_log.Debug(logMsg); 2494 m_log.DebugFormat("[Scene]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
2627 */ 2495 vialogin = true;
2496 IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>();
2497 if (userVerification != null && ep != null)
2498 {
2499 if (!userVerification.VerifyClient(aCircuit, ep.ToString()))
2500 {
2501 // uh-oh, this is fishy
2502 m_log.WarnFormat("[Scene]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.",
2503 client.AgentId, client.SessionId, ep.ToString());
2504 try
2505 {
2506 client.Close();
2507 }
2508 catch (Exception e)
2509 {
2510 m_log.DebugFormat("[Scene]: Exception while closing aborted client: {0}", e.StackTrace);
2511 }
2512 return;
2513 }
2514 else
2515 m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} returned true", aCircuit.firstname, aCircuit.lastname);
2516 }
2517 }
2518 }
2628 2519
2629 CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); 2520 m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName);
2630 2521
2631 ScenePresence sp = CreateAndAddScenePresence(client); 2522 ScenePresence sp = CreateAndAddScenePresence(client);
2523 if (aCircuit != null)
2524 sp.Appearance = aCircuit.Appearance;
2632 2525
2633 // HERE!!! Do the initial attachments right here 2526 // HERE!!! Do the initial attachments right here
2634 // first agent upon login is a root agent by design. 2527 // first agent upon login is a root agent by design.
2635 // All other AddNewClient calls find aCircuit.child to be true 2528 // All other AddNewClient calls find aCircuit.child to be true
2636 if (aCircuit == null || aCircuit.child == false) 2529 if (aCircuit == null || (aCircuit != null && aCircuit.child == false))
2637 { 2530 {
2638 sp.IsChildAgent = false; 2531 sp.IsChildAgent = false;
2639 Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); 2532 Util.FireAndForget(delegate(object o) { sp.RezAttachments(); });
@@ -2642,6 +2535,8 @@ namespace OpenSim.Region.Framework.Scenes
2642 2535
2643 m_LastLogin = Util.EnvironmentTickCount(); 2536 m_LastLogin = Util.EnvironmentTickCount();
2644 EventManager.TriggerOnNewClient(client); 2537 EventManager.TriggerOnNewClient(client);
2538 if (vialogin)
2539 EventManager.TriggerOnClientLogin(client);
2645 } 2540 }
2646 2541
2647 2542
@@ -2711,6 +2606,7 @@ namespace OpenSim.Region.Framework.Scenes
2711 client.OnGrabUpdate += ProcessObjectGrabUpdate; 2606 client.OnGrabUpdate += ProcessObjectGrabUpdate;
2712 client.OnDeGrabObject += ProcessObjectDeGrab; 2607 client.OnDeGrabObject += ProcessObjectDeGrab;
2713 client.OnUndo += m_sceneGraph.HandleUndo; 2608 client.OnUndo += m_sceneGraph.HandleUndo;
2609 client.OnRedo += m_sceneGraph.HandleRedo;
2714 client.OnObjectDescription += m_sceneGraph.PrimDescription; 2610 client.OnObjectDescription += m_sceneGraph.PrimDescription;
2715 client.OnObjectDrop += m_sceneGraph.DropObject; 2611 client.OnObjectDrop += m_sceneGraph.DropObject;
2716 client.OnObjectSaleInfo += ObjectSaleInfo; 2612 client.OnObjectSaleInfo += ObjectSaleInfo;
@@ -2758,7 +2654,6 @@ namespace OpenSim.Region.Framework.Scenes
2758 { 2654 {
2759 client.OnTeleportLocationRequest += RequestTeleportLocation; 2655 client.OnTeleportLocationRequest += RequestTeleportLocation;
2760 client.OnTeleportLandmarkRequest += RequestTeleportLandmark; 2656 client.OnTeleportLandmarkRequest += RequestTeleportLandmark;
2761 client.OnTeleportHomeRequest += TeleportClientHome;
2762 } 2657 }
2763 2658
2764 public virtual void SubscribeToClientScriptEvents(IClientAPI client) 2659 public virtual void SubscribeToClientScriptEvents(IClientAPI client)
@@ -2778,7 +2673,7 @@ namespace OpenSim.Region.Framework.Scenes
2778 2673
2779 public virtual void SubscribeToClientGridEvents(IClientAPI client) 2674 public virtual void SubscribeToClientGridEvents(IClientAPI client)
2780 { 2675 {
2781 client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest; 2676 client.OnNameFromUUIDRequest += HandleUUIDNameRequest;
2782 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; 2677 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest;
2783 client.OnAvatarPickerRequest += ProcessAvatarPickerRequest; 2678 client.OnAvatarPickerRequest += ProcessAvatarPickerRequest;
2784 client.OnSetStartLocationRequest += SetHomeRezPoint; 2679 client.OnSetStartLocationRequest += SetHomeRezPoint;
@@ -2865,6 +2760,7 @@ namespace OpenSim.Region.Framework.Scenes
2865 client.OnGrabObject -= ProcessObjectGrab; 2760 client.OnGrabObject -= ProcessObjectGrab;
2866 client.OnDeGrabObject -= ProcessObjectDeGrab; 2761 client.OnDeGrabObject -= ProcessObjectDeGrab;
2867 client.OnUndo -= m_sceneGraph.HandleUndo; 2762 client.OnUndo -= m_sceneGraph.HandleUndo;
2763 client.OnRedo -= m_sceneGraph.HandleRedo;
2868 client.OnObjectDescription -= m_sceneGraph.PrimDescription; 2764 client.OnObjectDescription -= m_sceneGraph.PrimDescription;
2869 client.OnObjectDrop -= m_sceneGraph.DropObject; 2765 client.OnObjectDrop -= m_sceneGraph.DropObject;
2870 client.OnObjectSaleInfo -= ObjectSaleInfo; 2766 client.OnObjectSaleInfo -= ObjectSaleInfo;
@@ -2913,7 +2809,7 @@ namespace OpenSim.Region.Framework.Scenes
2913 { 2809 {
2914 client.OnTeleportLocationRequest -= RequestTeleportLocation; 2810 client.OnTeleportLocationRequest -= RequestTeleportLocation;
2915 client.OnTeleportLandmarkRequest -= RequestTeleportLandmark; 2811 client.OnTeleportLandmarkRequest -= RequestTeleportLandmark;
2916 client.OnTeleportHomeRequest -= TeleportClientHome; 2812 //client.OnTeleportHomeRequest -= TeleportClientHome;
2917 } 2813 }
2918 2814
2919 public virtual void UnSubscribeToClientScriptEvents(IClientAPI client) 2815 public virtual void UnSubscribeToClientScriptEvents(IClientAPI client)
@@ -2933,7 +2829,7 @@ namespace OpenSim.Region.Framework.Scenes
2933 2829
2934 public virtual void UnSubscribeToClientGridEvents(IClientAPI client) 2830 public virtual void UnSubscribeToClientGridEvents(IClientAPI client)
2935 { 2831 {
2936 client.OnNameFromUUIDRequest -= CommsManager.HandleUUIDNameRequest; 2832 client.OnNameFromUUIDRequest -= HandleUUIDNameRequest;
2937 client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest; 2833 client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest;
2938 client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest; 2834 client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest;
2939 client.OnSetStartLocationRequest -= SetHomeRezPoint; 2835 client.OnSetStartLocationRequest -= SetHomeRezPoint;
@@ -2960,30 +2856,12 @@ namespace OpenSim.Region.Framework.Scenes
2960 /// <param name="client">The IClientAPI for the client</param> 2856 /// <param name="client">The IClientAPI for the client</param>
2961 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 2857 public virtual void TeleportClientHome(UUID agentId, IClientAPI client)
2962 { 2858 {
2963 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId); 2859 if (m_teleportModule != null)
2964 if (UserProfile != null) 2860 m_teleportModule.TeleportHome(agentId, client);
2861 else
2965 { 2862 {
2966 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID); 2863 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2967 if (regionInfo == null) 2864 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2968 {
2969 uint x = 0, y = 0;
2970 Utils.LongToUInts(UserProfile.HomeRegion, out x, out y);
2971 regionInfo = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
2972 if (regionInfo != null) // home region can be away temporarily, too
2973 {
2974 UserProfile.HomeRegionID = regionInfo.RegionID;
2975 CommsManager.UserService.UpdateUserProfile(UserProfile);
2976 }
2977 }
2978 if (regionInfo == null)
2979 {
2980 // can't find the Home region: Tell viewer and abort
2981 client.SendTeleportFailed("Your home-region could not be found.");
2982 return;
2983 }
2984 RequestTeleportLocation(
2985 client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt,
2986 (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome));
2987 } 2865 }
2988 } 2866 }
2989 2867
@@ -3074,7 +2952,7 @@ namespace OpenSim.Region.Framework.Scenes
3074 } 2952 }
3075 2953
3076 /// <summary> 2954 /// <summary>
3077 /// Sets the Home Point. The GridService uses this to know where to put a user when they log-in 2955 /// Sets the Home Point. The LoginService uses this to know where to put a user when they log-in
3078 /// </summary> 2956 /// </summary>
3079 /// <param name="remoteClient"></param> 2957 /// <param name="remoteClient"></param>
3080 /// <param name="regionHandle"></param> 2958 /// <param name="regionHandle"></param>
@@ -3083,27 +2961,11 @@ namespace OpenSim.Region.Framework.Scenes
3083 /// <param name="flags"></param> 2961 /// <param name="flags"></param>
3084 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 2962 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3085 { 2963 {
3086 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId); 2964 if (PresenceService.SetHomeLocation(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3087 if (UserProfile != null)
3088 {
3089 // I know I'm ignoring the regionHandle provided by the teleport location request.
3090 // reusing the TeleportLocationRequest delegate, so regionHandle isn't valid
3091 UserProfile.HomeRegionID = RegionInfo.RegionID;
3092 // TODO: The next line can be removed, as soon as only homeRegionID based UserServers are around.
3093 // TODO: The HomeRegion property can be removed then, too
3094 UserProfile.HomeRegion = RegionInfo.RegionHandle;
3095
3096 UserProfile.HomeLocation = position;
3097 UserProfile.HomeLookAt = lookAt;
3098 CommsManager.UserService.UpdateUserProfile(UserProfile);
3099
3100 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 2965 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3101 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 2966 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
3102 }
3103 else 2967 else
3104 {
3105 m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed."); 2968 m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed.");
3106 }
3107 } 2969 }
3108 2970
3109 /// <summary> 2971 /// <summary>
@@ -3176,14 +3038,12 @@ namespace OpenSim.Region.Framework.Scenes
3176 m_sceneGraph.removeUserCount(!childagentYN); 3038 m_sceneGraph.removeUserCount(!childagentYN);
3177 CapsModule.RemoveCapsHandler(agentID); 3039 CapsModule.RemoveCapsHandler(agentID);
3178 3040
3179 if (avatar.Scene.NeedSceneCacheClear(avatar.UUID)) 3041 // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
3180 { 3042 // this method is doing is HORRIBLE!!!
3181 CommsManager.UserProfileCacheService.RemoveUser(agentID); 3043 avatar.Scene.NeedSceneCacheClear(avatar.UUID);
3182 }
3183 3044
3184 if (!avatar.IsChildAgent) 3045 if (!avatar.IsChildAgent)
3185 { 3046 {
3186 m_sceneGridService.LogOffUser(agentID, RegionInfo.RegionID, RegionInfo.RegionHandle, avatar.AbsolutePosition, avatar.Lookat);
3187 //List<ulong> childknownRegions = new List<ulong>(); 3047 //List<ulong> childknownRegions = new List<ulong>();
3188 //List<ulong> ckn = avatar.KnownChildRegionHandles; 3048 //List<ulong> ckn = avatar.KnownChildRegionHandles;
3189 //for (int i = 0; i < ckn.Count; i++) 3049 //for (int i = 0; i < ckn.Count; i++)
@@ -3238,12 +3098,6 @@ namespace OpenSim.Region.Framework.Scenes
3238 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3098 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3239 } 3099 }
3240 3100
3241 // Remove client agent from profile, so new logins will work
3242 if (!childagentYN)
3243 {
3244 m_sceneGridService.ClearUserAgent(agentID);
3245 }
3246
3247 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3101 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3248 3102
3249 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3103 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
@@ -3317,14 +3171,6 @@ namespace OpenSim.Region.Framework.Scenes
3317 m_sceneGridService.KiPrimitive += SendKillObject; 3171 m_sceneGridService.KiPrimitive += SendKillObject;
3318 m_sceneGridService.OnGetLandData += GetLandData; 3172 m_sceneGridService.OnGetLandData += GetLandData;
3319 3173
3320 if (m_interregionCommsIn != null)
3321 {
3322 m_log.Debug("[SCENE]: Registering with InterregionCommsIn");
3323 m_interregionCommsIn.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3324 }
3325 else
3326 m_log.Debug("[SCENE]: Unable to register with InterregionCommsIn");
3327
3328 } 3174 }
3329 3175
3330 /// <summary> 3176 /// <summary>
@@ -3342,9 +3188,6 @@ namespace OpenSim.Region.Framework.Scenes
3342 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; 3188 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent;
3343 m_sceneGridService.OnGetLandData -= GetLandData; 3189 m_sceneGridService.OnGetLandData -= GetLandData;
3344 3190
3345 if (m_interregionCommsIn != null)
3346 m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
3347
3348 // this does nothing; should be removed 3191 // this does nothing; should be removed
3349 m_sceneGridService.Close(); 3192 m_sceneGridService.Close();
3350 3193
@@ -3401,7 +3244,7 @@ namespace OpenSim.Region.Framework.Scenes
3401 agent.AgentID, agent.circuitcode, teleportFlags); 3244 agent.AgentID, agent.circuitcode, teleportFlags);
3402 3245
3403 reason = String.Empty; 3246 reason = String.Empty;
3404 if (!AuthenticateUser(agent, out reason)) 3247 if (!VerifyUserPresence(agent, out reason))
3405 return false; 3248 return false;
3406 3249
3407 if (!AuthorizeUser(agent, out reason)) 3250 if (!AuthorizeUser(agent, out reason))
@@ -3501,40 +3344,39 @@ namespace OpenSim.Region.Framework.Scenes
3501 */// This is now handled properly in ScenePresence.MakeRootAgent 3344 */// This is now handled properly in ScenePresence.MakeRootAgent
3502 } 3345 }
3503 3346
3347 agent.teleportFlags = teleportFlags;
3504 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 3348 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
3505 3349
3506 // rewrite session_id
3507 CachedUserInfo userinfo = CommsManager.UserProfileCacheService.GetUserDetails(agent.AgentID);
3508 if (userinfo != null)
3509 {
3510 userinfo.SessionID = agent.SessionID;
3511 }
3512 else
3513 {
3514 m_log.WarnFormat(
3515 "[CONNECTION BEGIN]: We couldn't find a User Info record for {0}. This is usually an indication that the UUID we're looking up is invalid", agent.AgentID);
3516 }
3517
3518 return true; 3350 return true;
3519 } 3351 }
3520 3352
3521 /// <summary> 3353 /// <summary>
3522 /// Verifies that the user has a session on the Grid 3354 /// Verifies that the user has a presence on the Grid
3523 /// </summary> 3355 /// </summary>
3524 /// <param name="agent">Circuit Data of the Agent we're verifying</param> 3356 /// <param name="agent">Circuit Data of the Agent we're verifying</param>
3525 /// <param name="reason">Outputs the reason for the false response on this string</param> 3357 /// <param name="reason">Outputs the reason for the false response on this string</param>
3526 /// <returns>True if the user has a session on the grid. False if it does not. False will 3358 /// <returns>True if the user has a session on the grid. False if it does not. False will
3527 /// also return a reason.</returns> 3359 /// also return a reason.</returns>
3528 public virtual bool AuthenticateUser(AgentCircuitData agent, out string reason) 3360 public virtual bool VerifyUserPresence(AgentCircuitData agent, out string reason)
3529 { 3361 {
3530 reason = String.Empty; 3362 reason = String.Empty;
3531 3363
3532 bool result = CommsManager.UserService.VerifySession(agent.AgentID, agent.SessionID); 3364 IPresenceService presence = RequestModuleInterface<IPresenceService>();
3533 m_log.Debug("[CONNECTION BEGIN]: User authentication returned " + result); 3365 if (presence == null)
3534 if (!result) 3366 {
3535 reason = String.Format("Failed to authenticate user {0} {1}, access denied.", agent.firstname, agent.lastname); 3367 reason = String.Format("Failed to verify user {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName);
3368 return false;
3369 }
3370
3371 OpenSim.Services.Interfaces.PresenceInfo pinfo = presence.GetAgent(agent.SessionID);
3536 3372
3537 return result; 3373 if (pinfo == null || (pinfo != null && pinfo.Online == false))
3374 {
3375 reason = String.Format("Failed to verify user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName);
3376 return false;
3377 }
3378
3379 return true;
3538 } 3380 }
3539 3381
3540 /// <summary> 3382 /// <summary>
@@ -3735,8 +3577,8 @@ namespace OpenSim.Region.Framework.Scenes
3735 /// <returns>true if we handled it.</returns> 3577 /// <returns>true if we handled it.</returns>
3736 public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData) 3578 public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData)
3737 { 3579 {
3738// m_log.DebugFormat( 3580 m_log.DebugFormat(
3739// "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); 3581 "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName);
3740 3582
3741 // We have to wait until the viewer contacts this region after receiving EAC. 3583 // We have to wait until the viewer contacts this region after receiving EAC.
3742 // That calls AddNewClient, which finally creates the ScenePresence 3584 // That calls AddNewClient, which finally creates the ScenePresence
@@ -3805,16 +3647,6 @@ namespace OpenSim.Region.Framework.Scenes
3805 return false; 3647 return false;
3806 } 3648 }
3807 3649
3808 public virtual bool IncomingReleaseAgent(UUID id)
3809 {
3810 return m_sceneGridService.ReleaseAgent(id);
3811 }
3812
3813 public void SendReleaseAgent(ulong regionHandle, UUID id, string uri)
3814 {
3815 m_interregionCommsOut.SendReleaseAgent(regionHandle, id, uri);
3816 }
3817
3818 /// <summary> 3650 /// <summary>
3819 /// Tell a single agent to disconnect from the region. 3651 /// Tell a single agent to disconnect from the region.
3820 /// </summary> 3652 /// </summary>
@@ -3859,30 +3691,6 @@ namespace OpenSim.Region.Framework.Scenes
3859 } 3691 }
3860 3692
3861 /// <summary> 3693 /// <summary>
3862 /// Tell neighboring regions about this agent
3863 /// When the regions respond with a true value,
3864 /// tell the agents about the region.
3865 ///
3866 /// We have to tell the regions about the agents first otherwise it'll deny them access
3867 ///
3868 /// </summary>
3869 /// <param name="presence"></param>
3870 public void InformClientOfNeighbours(ScenePresence presence)
3871 {
3872 m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours);
3873 }
3874
3875 /// <summary>
3876 /// Tell a neighboring region about this agent
3877 /// </summary>
3878 /// <param name="presence"></param>
3879 /// <param name="region"></param>
3880 public void InformClientOfNeighbor(ScenePresence presence, RegionInfo region)
3881 {
3882 m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours);
3883 }
3884
3885 /// <summary>
3886 /// Tries to teleport agent to other region. 3694 /// Tries to teleport agent to other region.
3887 /// </summary> 3695 /// </summary>
3888 /// <param name="remoteClient"></param> 3696 /// <param name="remoteClient"></param>
@@ -3957,16 +3765,12 @@ namespace OpenSim.Region.Framework.Scenes
3957 } 3765 }
3958 3766
3959 if (m_teleportModule != null) 3767 if (m_teleportModule != null)
3960 { 3768 m_teleportModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);
3961 m_teleportModule.RequestTeleportToLocation(sp, regionHandle,
3962 position, lookAt, teleportFlags);
3963 }
3964 else 3769 else
3965 { 3770 {
3966 m_sceneGridService.RequestTeleportToLocation(sp, regionHandle, 3771 m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
3967 position, lookAt, teleportFlags); 3772 sp.ControllingClient.SendTeleportFailed("Unable to perform teleports on this simulator.");
3968 } 3773 }
3969
3970 } 3774 }
3971 } 3775 }
3972 3776
@@ -3992,7 +3796,12 @@ namespace OpenSim.Region.Framework.Scenes
3992 3796
3993 public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying) 3797 public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying)
3994 { 3798 {
3995 m_sceneGridService.CrossAgentToNewRegion(this, agent, isFlying); 3799 if (m_teleportModule != null)
3800 m_teleportModule.Cross(agent, isFlying);
3801 else
3802 {
3803 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule");
3804 }
3996 } 3805 }
3997 3806
3998 public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence) 3807 public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence)
@@ -4018,35 +3827,6 @@ namespace OpenSim.Region.Framework.Scenes
4018 objectCapacity = objects; 3827 objectCapacity = objects;
4019 } 3828 }
4020 3829
4021 public List<FriendListItem> GetFriendList(string id)
4022 {
4023 UUID avatarID;
4024 if (!UUID.TryParse(id, out avatarID))
4025 return new List<FriendListItem>();
4026
4027 return CommsManager.GetUserFriendList(avatarID);
4028 }
4029
4030 public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids)
4031 {
4032 return CommsManager.GetFriendRegionInfos(uuids);
4033 }
4034
4035 public virtual void StoreAddFriendship(UUID ownerID, UUID friendID, uint perms)
4036 {
4037 m_sceneGridService.AddNewUserFriend(ownerID, friendID, perms);
4038 }
4039
4040 public virtual void StoreUpdateFriendship(UUID ownerID, UUID friendID, uint perms)
4041 {
4042 m_sceneGridService.UpdateUserFriendPerms(ownerID, friendID, perms);
4043 }
4044
4045 public virtual void StoreRemoveFriendship(UUID ownerID, UUID ExfriendID)
4046 {
4047 m_sceneGridService.RemoveUserFriend(ownerID, ExfriendID);
4048 }
4049
4050 #endregion 3830 #endregion
4051 3831
4052 public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set) 3832 public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set)
@@ -4638,7 +4418,8 @@ namespace OpenSim.Region.Framework.Scenes
4638 group.GetPartName(localID), 4418 group.GetPartName(localID),
4639 group.GetPartDescription(localID), 4419 group.GetPartDescription(localID),
4640 (sbyte)AssetType.Object, 4420 (sbyte)AssetType.Object,
4641 Utils.StringToBytes(sceneObjectXml)); 4421 Utils.StringToBytes(sceneObjectXml),
4422 group.OwnerID);
4642 AssetService.Store(asset); 4423 AssetService.Store(asset);
4643 4424
4644 InventoryItemBase item = new InventoryItemBase(); 4425 InventoryItemBase item = new InventoryItemBase();
@@ -4962,5 +4743,15 @@ namespace OpenSim.Region.Framework.Scenes
4962 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4743 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000)
4963 StartTimer(); 4744 StartTimer();
4964 } 4745 }
4746
4747 public override ISceneObject DeserializeObject(string representation)
4748 {
4749 return SceneObjectSerializer.FromXml2Format(representation);
4750 }
4751
4752 public override bool AllowScriptCrossings
4753 {
4754 get { return m_allowScriptCrossings; }
4755 }
4965 } 4756 }
4966} 4757}
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 1547f9a..4f6e824 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -34,7 +34,7 @@ using log4net;
34using Nini.Config; 34using Nini.Config;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
37using OpenSim.Framework.Communications.Cache; 37
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion; 39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40 40
@@ -262,7 +262,7 @@ namespace OpenSim.Region.Framework.Scenes
262 /// Returns a new unallocated local ID 262 /// Returns a new unallocated local ID
263 /// </summary> 263 /// </summary>
264 /// <returns>A brand new local ID</returns> 264 /// <returns>A brand new local ID</returns>
265 protected internal uint AllocateLocalId() 265 public uint AllocateLocalId()
266 { 266 {
267 uint myID; 267 uint myID;
268 268
@@ -510,5 +510,16 @@ namespace OpenSim.Region.Framework.Scenes
510 510
511 MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback); 511 MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback);
512 } 512 }
513
514 public virtual ISceneObject DeserializeObject(string representation)
515 {
516 return null;
517 }
518
519 public virtual bool AllowScriptCrossings
520 {
521 get { return false; }
522 }
523
513 } 524 }
514} 525}
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 5f84252..8a74d7b 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -36,7 +36,6 @@ using log4net;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Client; 37using OpenSim.Framework.Client;
38using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Capabilities; 39using OpenSim.Framework.Capabilities;
41using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Services.Interfaces; 41using OpenSim.Services.Interfaces;
@@ -56,8 +55,6 @@ namespace OpenSim.Region.Framework.Scenes
56 { 55 {
57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 56 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58 57
59 protected CommunicationsManager m_commsProvider;
60 protected IInterregionCommsOut m_interregionCommsOut;
61 protected RegionInfo m_regionInfo; 58 protected RegionInfo m_regionInfo;
62 protected Scene m_scene; 59 protected Scene m_scene;
63 60
@@ -118,17 +115,14 @@ namespace OpenSim.Region.Framework.Scenes
118 115
119 public KiPrimitiveDelegate KiPrimitive; 116 public KiPrimitiveDelegate KiPrimitive;
120 117
121 public SceneCommunicationService(CommunicationsManager commsMan) 118 public SceneCommunicationService()
122 { 119 {
123 m_commsProvider = commsMan;
124 m_agentsInTransit = new List<UUID>();
125 } 120 }
126 121
127 public void SetScene(Scene s) 122 public void SetScene(Scene s)
128 { 123 {
129 m_scene = s; 124 m_scene = s;
130 m_regionInfo = s.RegionInfo; 125 m_regionInfo = s.RegionInfo;
131 m_interregionCommsOut = m_scene.RequestModuleInterface<IInterregionCommsOut>();
132 } 126 }
133 127
134 /// <summary> 128 /// <summary>
@@ -148,377 +142,6 @@ namespace OpenSim.Region.Framework.Scenes
148 { 142 {
149 } 143 }
150 144
151 #region CommsManager Event handlers
152
153 /// <summary>
154 /// A New User will arrive shortly, Informs the scene that there's a new user on the way
155 /// </summary>
156 /// <param name="agent">Data we need to ensure that the agent can connect</param>
157 ///
158 protected void NewUserConnection(AgentCircuitData agent)
159 {
160 handlerExpectUser = OnExpectUser;
161 if (handlerExpectUser != null)
162 {
163 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: OnExpectUser Fired for User:" + agent.firstname + " " + agent.lastname);
164 handlerExpectUser(agent);
165 }
166 }
167
168 /// <summary>
169 /// The Grid has requested us to log-off the user
170 /// </summary>
171 /// <param name="AgentID">Unique ID of agent to log-off</param>
172 /// <param name="RegionSecret">The secret string that the region establishes with the grid when registering</param>
173 /// <param name="message">The message to send to the user that tells them why they were logged off</param>
174 protected void GridLogOffUser(UUID AgentID, UUID RegionSecret, string message)
175 {
176 handlerLogOffUser = OnLogOffUser;
177 if (handlerLogOffUser != null)
178 {
179 handlerLogOffUser(AgentID, RegionSecret, message);
180 }
181 }
182
183 /// <summary>
184 /// Inform the scene that we've got an update about a child agent that we have
185 /// </summary>
186 /// <param name="cAgentData"></param>
187 /// <returns></returns>
188 protected bool ChildAgentUpdate(ChildAgentDataUpdate cAgentData)
189 {
190 handlerChildAgentUpdate = OnChildAgentUpdate;
191 if (handlerChildAgentUpdate != null)
192 handlerChildAgentUpdate(cAgentData);
193
194 return true;
195 }
196
197
198 protected void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
199 {
200 handlerAvatarCrossingIntoRegion = OnAvatarCrossingIntoRegion;
201 if (handlerAvatarCrossingIntoRegion != null)
202 {
203 handlerAvatarCrossingIntoRegion(agentID, position, isFlying);
204 }
205 }
206
207 protected void PrimCrossing(UUID primID, Vector3 position, bool isPhysical)
208 {
209 handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion;
210 if (handlerPrimCrossingIntoRegion != null)
211 {
212 handlerPrimCrossingIntoRegion(primID, position, isPhysical);
213 }
214 }
215
216 protected bool CloseConnection(UUID agentID)
217 {
218 m_log.Debug("[INTERREGION]: Incoming Agent Close Request for agent: " + agentID);
219
220 handlerCloseAgentConnection = OnCloseAgentConnection;
221 if (handlerCloseAgentConnection != null)
222 {
223 return handlerCloseAgentConnection(agentID);
224 }
225
226 return false;
227 }
228
229 protected LandData FetchLandData(uint x, uint y)
230 {
231 handlerGetLandData = OnGetLandData;
232 if (handlerGetLandData != null)
233 {
234 return handlerGetLandData(x, y);
235 }
236 return null;
237 }
238
239 #endregion
240
241 #region Inform Client of Neighbours
242
243 private delegate void InformClientOfNeighbourDelegate(
244 ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
245
246 private void InformClientOfNeighbourCompleted(IAsyncResult iar)
247 {
248 InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate) iar.AsyncState;
249 icon.EndInvoke(iar);
250 }
251
252 /// <summary>
253 /// Async component for informing client of which neighbours exist
254 /// </summary>
255 /// <remarks>
256 /// This needs to run asynchronously, as a network timeout may block the thread for a long while
257 /// </remarks>
258 /// <param name="remoteClient"></param>
259 /// <param name="a"></param>
260 /// <param name="regionHandle"></param>
261 /// <param name="endPoint"></param>
262 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, GridRegion reg,
263 IPEndPoint endPoint, bool newAgent)
264 {
265 // Let's wait just a little to give time to originating regions to catch up with closing child agents
266 // after a cross here
267 Thread.Sleep(500);
268
269 uint x, y;
270 Utils.LongToUInts(reg.RegionHandle, out x, out y);
271 x = x / Constants.RegionSize;
272 y = y / Constants.RegionSize;
273 m_log.Info("[INTERGRID]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")");
274
275 string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
276 + "/CAPS/" + a.CapsPath + "0000/";
277
278 string reason = String.Empty;
279
280
281 bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, 0, out reason);
282
283 if (regionAccepted && newAgent)
284 {
285 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
286 if (eq != null)
287 {
288 #region IP Translation for NAT
289 IClientIPEndpoint ipepClient;
290 if (avatar.ClientView.TryGet(out ipepClient))
291 {
292 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
293 }
294 #endregion
295
296 eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID);
297 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
298 m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1} in region {2}",
299 capsPath, avatar.UUID, avatar.Scene.RegionInfo.RegionName);
300 }
301 else
302 {
303 avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
304 // TODO: make Event Queue disablable!
305 }
306
307 m_log.Info("[INTERGRID]: Completed inform client about neighbour " + endPoint.ToString());
308
309 }
310
311 }
312
313 public List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY)
314 {
315 Border[] northBorders = pScene.NorthBorders.ToArray();
316 Border[] southBorders = pScene.SouthBorders.ToArray();
317 Border[] eastBorders = pScene.EastBorders.ToArray();
318 Border[] westBorders = pScene.WestBorders.ToArray();
319
320 // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement.
321 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1)
322 {
323 return m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
324 }
325 else
326 {
327 Vector2 extent = Vector2.Zero;
328 for (int i = 0; i < eastBorders.Length; i++)
329 {
330 extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X;
331 }
332 for (int i = 0; i < northBorders.Length; i++)
333 {
334 extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
335 }
336
337 // Loss of fraction on purpose
338 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
339 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
340
341 int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize;
342 int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize;
343
344 int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize;
345 int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize;
346
347 List<GridRegion> neighbours = m_scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
348 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
349
350 return neighbours;
351 }
352 }
353
354 /// <summary>
355 /// This informs all neighboring regions about agent "avatar".
356 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
357 /// </summary>
358 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours)
359 {
360 List<GridRegion> neighbours = new List<GridRegion>();
361
362 if (m_regionInfo != null)
363 {
364 neighbours = RequestNeighbours(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
365 }
366 else
367 {
368 m_log.Debug("[ENABLENEIGHBOURCHILDAGENTS]: m_regionInfo was null in EnableNeighbourChildAgents, is this a NPC?");
369 }
370
371 /// We need to find the difference between the new regions where there are no child agents
372 /// and the regions where there are already child agents. We only send notification to the former.
373 List<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region
374 neighbourHandles.Add(avatar.Scene.RegionInfo.RegionHandle); // add this region too
375 List<ulong> previousRegionNeighbourHandles ;
376
377 if (avatar.Scene.CapsModule != null)
378 {
379 previousRegionNeighbourHandles =
380 new List<ulong>(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID).Keys);
381 }
382 else
383 {
384 previousRegionNeighbourHandles = new List<ulong>();
385 }
386
387 List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles);
388 List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles);
389
390 //Dump("Current Neighbors", neighbourHandles);
391 //Dump("Previous Neighbours", previousRegionNeighbourHandles);
392 //Dump("New Neighbours", newRegions);
393 //Dump("Old Neighbours", oldRegions);
394
395 /// Update the scene presence's known regions here on this region
396 avatar.DropOldNeighbours(oldRegions);
397
398 /// Collect as many seeds as possible
399 Dictionary<ulong, string> seeds;
400 if (avatar.Scene.CapsModule != null)
401 seeds
402 = new Dictionary<ulong, string>(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID));
403 else
404 seeds = new Dictionary<ulong, string>();
405
406 //m_log.Debug(" !!! No. of seeds: " + seeds.Count);
407 if (!seeds.ContainsKey(avatar.Scene.RegionInfo.RegionHandle))
408 seeds.Add(avatar.Scene.RegionInfo.RegionHandle, avatar.ControllingClient.RequestClientInfo().CapsPath);
409
410 /// Create the necessary child agents
411 List<AgentCircuitData> cagents = new List<AgentCircuitData>();
412 foreach (GridRegion neighbour in neighbours)
413 {
414 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
415 {
416
417 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
418 agent.BaseFolder = UUID.Zero;
419 agent.InventoryFolder = UUID.Zero;
420 agent.startpos = new Vector3(128, 128, 70);
421 agent.child = true;
422
423 if (newRegions.Contains(neighbour.RegionHandle))
424 {
425 agent.CapsPath = CapsUtil.GetRandomCapsObjectPath();
426 avatar.AddNeighbourRegion(neighbour.RegionHandle, agent.CapsPath);
427 seeds.Add(neighbour.RegionHandle, agent.CapsPath);
428 }
429 else
430 agent.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, neighbour.RegionHandle);
431
432 cagents.Add(agent);
433 }
434 }
435
436 /// Update all child agent with everyone's seeds
437 foreach (AgentCircuitData a in cagents)
438 {
439 a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
440 }
441
442 if (avatar.Scene.CapsModule != null)
443 {
444 // These two are the same thing!
445 avatar.Scene.CapsModule.SetChildrenSeed(avatar.UUID, seeds);
446 }
447 avatar.KnownRegions = seeds;
448 //avatar.Scene.DumpChildrenSeeds(avatar.UUID);
449 //avatar.DumpKnownRegions();
450
451 bool newAgent = false;
452 int count = 0;
453 foreach (GridRegion neighbour in neighbours)
454 {
455 // Don't do it if there's already an agent in that region
456 if (newRegions.Contains(neighbour.RegionHandle))
457 newAgent = true;
458 else
459 newAgent = false;
460
461 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
462 {
463 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
464 try
465 {
466 d.BeginInvoke(avatar, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent,
467 InformClientOfNeighbourCompleted,
468 d);
469 }
470
471 catch (ArgumentOutOfRangeException)
472 {
473 m_log.ErrorFormat(
474 "[REGIONINFO]: Neighbour Regions response included the current region in the neighbor list. The following region will not display to the client: {0} for region {1} ({2}, {3}).",
475 neighbour.ExternalHostName,
476 neighbour.RegionHandle,
477 neighbour.RegionLocX,
478 neighbour.RegionLocY);
479 }
480 catch (Exception e)
481 {
482 m_log.ErrorFormat(
483 "[REGIONINFO]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}",
484 neighbour.ExternalHostName,
485 neighbour.RegionHandle,
486 neighbour.RegionLocX,
487 neighbour.RegionLocY,
488 e);
489
490 // FIXME: Okay, even though we've failed, we're still going to throw the exception on,
491 // since I don't know what will happen if we just let the client continue
492
493 // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes.
494 // throw e;
495
496 }
497 }
498 count++;
499 }
500 }
501
502 /// <summary>
503 /// This informs a single neighboring region about agent "avatar".
504 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
505 /// </summary>
506 public void InformNeighborChildAgent(ScenePresence avatar, GridRegion region)
507 {
508 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
509 agent.BaseFolder = UUID.Zero;
510 agent.InventoryFolder = UUID.Zero;
511 agent.startpos = new Vector3(128, 128, 70);
512 agent.child = true;
513
514 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
515 d.BeginInvoke(avatar, agent, region, region.ExternalEndPoint, true,
516 InformClientOfNeighbourCompleted,
517 d);
518 }
519
520 #endregion
521
522 public delegate void InformNeighbourThatRegionUpDelegate(INeighbourService nService, RegionInfo region, ulong regionhandle); 145 public delegate void InformNeighbourThatRegionUpDelegate(INeighbourService nService, RegionInfo region, ulong regionhandle);
523 146
524 private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar) 147 private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar)
@@ -550,7 +173,7 @@ namespace OpenSim.Region.Framework.Scenes
550 } 173 }
551 else 174 else
552 { 175 {
553 m_log.WarnFormat("[INTERGRID]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize); 176 m_log.InfoFormat("[INTERGRID]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize);
554 } 177 }
555 } 178 }
556 179
@@ -592,7 +215,10 @@ namespace OpenSim.Region.Framework.Scenes
592 try 215 try
593 { 216 {
594 //m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData); 217 //m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData);
595 m_interregionCommsOut.SendChildAgentUpdate(regionHandle, cAgentData); 218 uint x = 0, y = 0;
219 Utils.LongToUInts(regionHandle, out x, out y);
220 GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
221 m_scene.SimulationService.UpdateAgent(destination, cAgentData);
596 } 222 }
597 catch 223 catch
598 { 224 {
@@ -652,7 +278,10 @@ namespace OpenSim.Region.Framework.Scenes
652 // let's do our best, but there's not much we can do if the neighbour doesn't accept. 278 // let's do our best, but there's not much we can do if the neighbour doesn't accept.
653 279
654 //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); 280 //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID);
655 m_interregionCommsOut.SendCloseAgent(regionHandle, agentID); 281 uint x = 0, y = 0;
282 Utils.LongToUInts(regionHandle, out x, out y);
283 GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
284 m_scene.SimulationService.CloseAgent(destination, agentID);
656 } 285 }
657 286
658 private void SendCloseChildAgentCompleted(IAsyncResult iar) 287 private void SendCloseChildAgentCompleted(IAsyncResult iar)
@@ -672,848 +301,10 @@ namespace OpenSim.Region.Framework.Scenes
672 } 301 }
673 } 302 }
674 303
675
676 /// <summary>
677 /// Try to teleport an agent to a new region.
678 /// </summary>
679 /// <param name="remoteClient"></param>
680 /// <param name="RegionHandle"></param>
681 /// <param name="position"></param>
682 /// <param name="lookAt"></param>
683 /// <param name="flags"></param>
684 public virtual void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position,
685 Vector3 lookAt, uint teleportFlags)
686 {
687 if (!avatar.Scene.Permissions.CanTeleport(avatar.UUID))
688 return;
689
690 bool destRegionUp = true;
691
692 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
693
694 // Reset animations; the viewer does that in teleports.
695 avatar.Animator.ResetAnimations();
696
697 if (regionHandle == m_regionInfo.RegionHandle)
698 {
699 m_log.DebugFormat(
700 "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation {0} within {1}",
701 position, m_regionInfo.RegionName);
702
703 // Teleport within the same region
704 if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0)
705 {
706 Vector3 emergencyPos = new Vector3(128, 128, 128);
707
708 m_log.WarnFormat(
709 "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
710 position, avatar.Name, avatar.UUID, emergencyPos);
711 position = emergencyPos;
712 }
713
714 Vector3 currentPos = avatar.AbsolutePosition;
715 ILandObject srcLand = m_scene.LandChannel.GetLandObject(currentPos.X, currentPos.Y);
716 ILandObject destLand = m_scene.LandChannel.GetLandObject(position.X, position.Y);
717 if (srcLand != null && destLand != null && (teleportFlags & (uint)TeleportFlags.ViaLure) == 0 && (teleportFlags & (uint)TeleportFlags.ViaGodlikeLure) == 0)
718 {
719 if (srcLand.LandData.LocalID == destLand.LandData.LocalID)
720 {
721 //TPing within the same parcel. If the landing point is restricted, block the TP.
722 //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni.
723 if (destLand.LandData.LandingType == (byte)1 && destLand.LandData.UserLocation != Vector3.Zero && avatar.GodLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar.UUID) && destLand.LandData.OwnerID != avatar.UUID)
724 {
725 //Disabling this behaviour for now pending review. ~CasperW
726
727 //avatar.ControllingClient.SendAgentAlertMessage("Can't TP to the destination; landing point set.", false);
728 //position = currentPos;
729 }
730 }
731 else
732 {
733 //Tping to a different parcel. Respect the landing point on the destination parcel.
734 if (destLand.LandData.LandingType == (byte)1 && destLand.LandData.UserLocation != Vector3.Zero && avatar.GodLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar.UUID) && destLand.LandData.OwnerID != avatar.UUID)
735 {
736 position = destLand.LandData.UserLocation;
737 }
738 }
739 }
740
741 // TODO: Get proper AVG Height
742 float localAVHeight = 1.56f;
743 float posZLimit = 22;
744
745 // TODO: Check other Scene HeightField
746 if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <=(int)Constants.RegionSize)
747 {
748 posZLimit = (float) avatar.Scene.Heightmap[(int) position.X, (int) position.Y];
749 }
750
751 float newPosZ = posZLimit + localAVHeight;
752 if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
753 {
754 position.Z = newPosZ;
755 }
756
757 // Only send this if the event queue is null
758 if (eq == null)
759 avatar.ControllingClient.SendTeleportLocationStart();
760
761 avatar.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
762 avatar.Teleport(position);
763 }
764 else
765 {
766 uint x = 0, y = 0;
767 Utils.LongToUInts(regionHandle, out x, out y);
768 GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
769
770 if (reg != null)
771 {
772 m_log.DebugFormat(
773 "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation to {0} in {1}",
774 position, reg.RegionName);
775
776 if (eq == null)
777 avatar.ControllingClient.SendTeleportLocationStart();
778
779 // Let's do DNS resolution only once in this process, please!
780 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
781 // it's actually doing a lot of work.
782 IPEndPoint endPoint = reg.ExternalEndPoint;
783 if (endPoint.Address == null)
784 {
785 // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses.
786 destRegionUp = false;
787 }
788
789 if (destRegionUp)
790 {
791 uint newRegionX = (uint)(reg.RegionHandle >> 40);
792 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
793 uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
794 uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
795
796 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
797 // both regions
798 if (avatar.ParentID != (uint)0)
799 avatar.StandUp();
800
801 if (!avatar.ValidateAttachments())
802 {
803 avatar.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
804 return;
805 }
806
807 // the avatar.Close below will clear the child region list. We need this below for (possibly)
808 // closing the child agents, so save it here (we need a copy as it is Clear()-ed).
809 //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList());
810 // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
811 // failure at this point (unlike a border crossing failure). So perhaps this can never fail
812 // once we reach here...
813 //avatar.Scene.RemoveCapsHandler(avatar.UUID);
814
815 string capsPath = String.Empty;
816 AgentCircuitData agentCircuit = avatar.ControllingClient.RequestClientInfo();
817 agentCircuit.BaseFolder = UUID.Zero;
818 agentCircuit.InventoryFolder = UUID.Zero;
819 agentCircuit.startpos = position;
820 agentCircuit.child = true;
821
822 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
823 {
824 // brand new agent, let's create a new caps seed
825 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
826 }
827
828 string reason = String.Empty;
829
830 // Let's create an agent there if one doesn't exist yet.
831 //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
832 if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, teleportFlags, out reason))
833 {
834 avatar.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}",
835 reason));
836 return;
837 }
838
839 // OK, it got this agent. Let's close some child agents
840 avatar.CloseChildAgents(newRegionX, newRegionY);
841
842 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
843 {
844 #region IP Translation for NAT
845 IClientIPEndpoint ipepClient;
846 if (avatar.ClientView.TryGet(out ipepClient))
847 {
848 capsPath
849 = "http://"
850 + NetworkUtil.GetHostFor(ipepClient.EndPoint, reg.ExternalHostName)
851 + ":"
852 + reg.HttpPort
853 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
854 }
855 else
856 {
857 capsPath
858 = "http://"
859 + reg.ExternalHostName
860 + ":"
861 + reg.HttpPort
862 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
863 }
864 #endregion
865
866 if (eq != null)
867 {
868 #region IP Translation for NAT
869 // Uses ipepClient above
870 if (avatar.ClientView.TryGet(out ipepClient))
871 {
872 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
873 }
874 #endregion
875
876 eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID);
877
878 // ES makes the client send a UseCircuitCode message to the destination,
879 // which triggers a bunch of things there.
880 // So let's wait
881 Thread.Sleep(2000);
882
883 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
884 }
885 else
886 {
887 avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
888 }
889 }
890 else
891 {
892 agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle);
893 capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
894 + "/CAPS/" + agentCircuit.CapsPath + "0000/";
895 }
896
897 // Expect avatar crossing is a heavy-duty function at the destination.
898 // That is where MakeRoot is called, which fetches appearance and inventory.
899 // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates.
900 //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
901 // position, false);
902
903 //{
904 // avatar.ControllingClient.SendTeleportFailed("Problem with destination.");
905 // // We should close that agent we just created over at destination...
906 // List<ulong> lst = new List<ulong>();
907 // lst.Add(reg.RegionHandle);
908 // SendCloseChildAgentAsync(avatar.UUID, lst);
909 // return;
910 //}
911
912 SetInTransit(avatar.UUID);
913 // Let's send a full update of the agent. This is a synchronous call.
914 AgentData agent = new AgentData();
915 avatar.CopyTo(agent);
916 agent.Position = position;
917 agent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort +
918 "/agent/" + avatar.UUID.ToString() + "/" + avatar.Scene.RegionInfo.RegionHandle.ToString() + "/release/";
919
920 m_interregionCommsOut.SendChildAgentUpdate(reg.RegionHandle, agent);
921
922 m_log.DebugFormat(
923 "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID);
924
925
926 if (eq != null)
927 {
928 eq.TeleportFinishEvent(reg.RegionHandle, 13, endPoint,
929 0, teleportFlags, capsPath, avatar.UUID);
930 }
931 else
932 {
933 avatar.ControllingClient.SendRegionTeleport(reg.RegionHandle, 13, endPoint, 4,
934 teleportFlags, capsPath);
935 }
936
937 // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
938 // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
939 // that the client contacted the destination before we send the attachments and close things here.
940 if (!WaitForCallback(avatar.UUID))
941 {
942 // Client never contacted destination. Let's restore everything back
943 avatar.ControllingClient.SendTeleportFailed("Problems connecting to destination.");
944
945 ResetFromTransit(avatar.UUID);
946
947 // Yikes! We should just have a ref to scene here.
948 avatar.Scene.InformClientOfNeighbours(avatar);
949
950 // Finally, kill the agent we just created at the destination.
951 m_interregionCommsOut.SendCloseAgent(reg.RegionHandle, avatar.UUID);
952
953 return;
954 }
955
956 // Can't go back from here
957 if (KiPrimitive != null)
958 {
959 KiPrimitive(avatar.LocalId);
960 }
961
962 avatar.MakeChildAgent();
963
964 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
965 avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true);
966
967 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
968
969 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
970 {
971 Thread.Sleep(5000);
972 avatar.Close();
973 CloseConnection(avatar.UUID);
974 }
975 else
976 // now we have a child agent in this region.
977 avatar.Reset();
978
979
980 // if (teleport success) // seems to be always success here
981 // the user may change their profile information in other region,
982 // so the userinfo in UserProfileCache is not reliable any more, delete it
983 if (avatar.Scene.NeedSceneCacheClear(avatar.UUID))
984 {
985 m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID);
986 m_log.DebugFormat(
987 "[SCENE COMMUNICATION SERVICE]: User {0} is going to another region, profile cache removed",
988 avatar.UUID);
989 }
990 }
991 else
992 {
993 avatar.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
994 }
995 }
996 else
997 {
998 // TP to a place that doesn't exist (anymore)
999 // Inform the viewer about that
1000 avatar.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
1001
1002 // and set the map-tile to '(Offline)'
1003 uint regX, regY;
1004 Utils.LongToUInts(regionHandle, out regX, out regY);
1005
1006 MapBlockData block = new MapBlockData();
1007 block.X = (ushort)(regX / Constants.RegionSize);
1008 block.Y = (ushort)(regY / Constants.RegionSize);
1009 block.Access = 254; // == not there
1010
1011 List<MapBlockData> blocks = new List<MapBlockData>();
1012 blocks.Add(block);
1013 avatar.ControllingClient.SendMapBlock(blocks, 0);
1014 }
1015 }
1016 }
1017
1018 protected bool IsOutsideRegion(Scene s, Vector3 pos)
1019 {
1020
1021 if (s.TestBorderCross(pos,Cardinals.N))
1022 return true;
1023 if (s.TestBorderCross(pos, Cardinals.S))
1024 return true;
1025 if (s.TestBorderCross(pos, Cardinals.E))
1026 return true;
1027 if (s.TestBorderCross(pos, Cardinals.W))
1028 return true;
1029
1030 return false;
1031 }
1032
1033 public bool WaitForCallback(UUID id)
1034 {
1035 int count = 200;
1036 while (m_agentsInTransit.Contains(id) && count-- > 0)
1037 {
1038 //m_log.Debug(" >>> Waiting... " + count);
1039 Thread.Sleep(100);
1040 }
1041
1042 if (count > 0)
1043 return true;
1044 else
1045 return false;
1046 }
1047
1048 public bool ReleaseAgent(UUID id)
1049 {
1050 //m_log.Debug(" >>> ReleaseAgent called <<< ");
1051 return ResetFromTransit(id);
1052 }
1053
1054 public void SetInTransit(UUID id)
1055 {
1056 lock (m_agentsInTransit)
1057 {
1058 if (!m_agentsInTransit.Contains(id))
1059 m_agentsInTransit.Add(id);
1060 }
1061 }
1062
1063 protected bool ResetFromTransit(UUID id)
1064 {
1065 lock (m_agentsInTransit)
1066 {
1067 if (m_agentsInTransit.Contains(id))
1068 {
1069 m_agentsInTransit.Remove(id);
1070 return true;
1071 }
1072 }
1073 return false;
1074 }
1075
1076 private List<ulong> NeighbourHandles(List<GridRegion> neighbours)
1077 {
1078 List<ulong> handles = new List<ulong>();
1079 foreach (GridRegion reg in neighbours)
1080 {
1081 handles.Add(reg.RegionHandle);
1082 }
1083 return handles;
1084 }
1085
1086 private List<ulong> NewNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1087 {
1088 return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); });
1089 }
1090
1091// private List<ulong> CommonNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1092// {
1093// return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); });
1094// }
1095
1096 private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1097 {
1098 return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); });
1099 }
1100
1101 public void CrossAgentToNewRegion(Scene scene, ScenePresence agent, bool isFlying)
1102 {
1103 Vector3 pos = agent.AbsolutePosition;
1104 Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z);
1105 uint neighbourx = m_regionInfo.RegionLocX;
1106 uint neighboury = m_regionInfo.RegionLocY;
1107 const float boundaryDistance = 1.7f;
1108 Vector3 northCross = new Vector3(0,boundaryDistance, 0);
1109 Vector3 southCross = new Vector3(0, -1 * boundaryDistance, 0);
1110 Vector3 eastCross = new Vector3(boundaryDistance, 0, 0);
1111 Vector3 westCross = new Vector3(-1 * boundaryDistance, 0, 0);
1112
1113 // distance to edge that will trigger crossing
1114
1115
1116 // distance into new region to place avatar
1117 const float enterDistance = 0.5f;
1118
1119 if (scene.TestBorderCross(pos + westCross, Cardinals.W))
1120 {
1121 if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1122 {
1123 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1124 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1125 }
1126 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1127 {
1128 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1129 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0)
1130 {
1131 neighboury--;
1132 newpos.Y = Constants.RegionSize - enterDistance;
1133 }
1134 else
1135 {
1136 neighboury = b.TriggerRegionY;
1137 neighbourx = b.TriggerRegionX;
1138
1139 Vector3 newposition = pos;
1140 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1141 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1142 agent.ControllingClient.SendAgentAlertMessage(
1143 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1144 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1145 return;
1146 }
1147 }
1148
1149 Border ba = scene.GetCrossedBorder(pos + westCross, Cardinals.W);
1150 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
1151 {
1152 neighbourx--;
1153 newpos.X = Constants.RegionSize - enterDistance;
1154 }
1155 else
1156 {
1157 neighboury = ba.TriggerRegionY;
1158 neighbourx = ba.TriggerRegionX;
1159
1160
1161 Vector3 newposition = pos;
1162 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1163 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1164 agent.ControllingClient.SendAgentAlertMessage(
1165 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1166 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1167
1168
1169 return;
1170 }
1171
1172 }
1173 else if (scene.TestBorderCross(pos + eastCross, Cardinals.E))
1174 {
1175 Border b = scene.GetCrossedBorder(pos + eastCross, Cardinals.E);
1176 neighbourx += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1177 newpos.X = enterDistance;
1178
1179 if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1180 {
1181 Border ba = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1182 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
1183 {
1184 neighboury--;
1185 newpos.Y = Constants.RegionSize - enterDistance;
1186 }
1187 else
1188 {
1189 neighboury = ba.TriggerRegionY;
1190 neighbourx = ba.TriggerRegionX;
1191 Vector3 newposition = pos;
1192 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1193 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1194 agent.ControllingClient.SendAgentAlertMessage(
1195 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1196 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1197 return;
1198 }
1199 }
1200 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1201 {
1202 Border c = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1203 neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize);
1204 newpos.Y = enterDistance;
1205 }
1206
1207
1208 }
1209 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1210 {
1211 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1212 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0)
1213 {
1214 neighboury--;
1215 newpos.Y = Constants.RegionSize - enterDistance;
1216 }
1217 else
1218 {
1219 neighboury = b.TriggerRegionY;
1220 neighbourx = b.TriggerRegionX;
1221 Vector3 newposition = pos;
1222 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1223 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1224 agent.ControllingClient.SendAgentAlertMessage(
1225 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1226 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1227 return;
1228 }
1229 }
1230 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1231 {
1232
1233 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1234 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1235 newpos.Y = enterDistance;
1236 }
1237
1238 /*
1239
1240 if (pos.X < boundaryDistance) //West
1241 {
1242 neighbourx--;
1243 newpos.X = Constants.RegionSize - enterDistance;
1244 }
1245 else if (pos.X > Constants.RegionSize - boundaryDistance) // East
1246 {
1247 neighbourx++;
1248 newpos.X = enterDistance;
1249 }
1250
1251 if (pos.Y < boundaryDistance) // South
1252 {
1253 neighboury--;
1254 newpos.Y = Constants.RegionSize - enterDistance;
1255 }
1256 else if (pos.Y > Constants.RegionSize - boundaryDistance) // North
1257 {
1258 neighboury++;
1259 newpos.Y = enterDistance;
1260 }
1261 */
1262
1263 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync;
1264 d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d);
1265 }
1266
1267 public delegate void InformClientToInitateTeleportToLocationDelegate(ScenePresence agent, uint regionX, uint regionY,
1268 Vector3 position,
1269 Scene initiatingScene);
1270
1271 public void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position,
1272 Scene initiatingScene)
1273 {
1274
1275 // This assumes that we know what our neighbors are.
1276
1277 InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync;
1278 d.BeginInvoke(agent,regionX,regionY,position,initiatingScene,
1279 InformClientToInitiateTeleportToLocationCompleted,
1280 d);
1281 }
1282
1283 public void InformClientToInitiateTeleportToLocationAsync(ScenePresence agent, uint regionX, uint regionY, Vector3 position,
1284 Scene initiatingScene)
1285 {
1286 Thread.Sleep(10000);
1287 IMessageTransferModule im = initiatingScene.RequestModuleInterface<IMessageTransferModule>();
1288 if (im != null)
1289 {
1290 UUID gotoLocation = Util.BuildFakeParcelID(
1291 Util.UIntsToLong(
1292 (regionX *
1293 (uint)Constants.RegionSize),
1294 (regionY *
1295 (uint)Constants.RegionSize)),
1296 (uint)(int)position.X,
1297 (uint)(int)position.Y,
1298 (uint)(int)position.Z);
1299 GridInstantMessage m = new GridInstantMessage(initiatingScene, UUID.Zero,
1300 "Region", agent.UUID,
1301 (byte)InstantMessageDialog.GodLikeRequestTeleport, false,
1302 "", gotoLocation, false, new Vector3(127, 0, 0),
1303 new Byte[0]);
1304 im.SendInstantMessage(m, delegate(bool success)
1305 {
1306 m_log.DebugFormat("[CLIENT]: Client Initiating Teleport sending IM success = {0}", success);
1307 });
1308
1309 }
1310 }
1311
1312 private void InformClientToInitiateTeleportToLocationCompleted(IAsyncResult iar)
1313 {
1314 InformClientToInitateTeleportToLocationDelegate icon =
1315 (InformClientToInitateTeleportToLocationDelegate) iar.AsyncState;
1316 icon.EndInvoke(iar);
1317 }
1318
1319 public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying);
1320
1321 /// <summary>
1322 /// This Closes child agents on neighboring regions
1323 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
1324 /// </summary>
1325 protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying)
1326 {
1327 m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury);
1328
1329 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
1330
1331 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
1332 GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
1333
1334 if (neighbourRegion != null && agent.ValidateAttachments())
1335 {
1336 pos = pos + (agent.Velocity);
1337
1338 //CachedUserInfo userInfo = m_commsProvider.UserProfileCacheService.GetUserDetails(agent.UUID);
1339 //if (userInfo != null)
1340 //{
1341 // userInfo.DropInventory();
1342 //}
1343 //else
1344 //{
1345 // m_log.WarnFormat("[SCENE COMM]: No cached user info found for {0} {1} on leaving region {2}",
1346 // agent.Name, agent.UUID, agent.Scene.RegionInfo.RegionName);
1347 //}
1348
1349 //bool crossingSuccessful =
1350 // CrossToNeighbouringRegion(neighbourHandle, agent.ControllingClient.AgentId, pos,
1351 //isFlying);
1352
1353 SetInTransit(agent.UUID);
1354 AgentData cAgent = new AgentData();
1355 agent.CopyTo(cAgent);
1356 cAgent.Position = pos;
1357 if (isFlying)
1358 cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
1359 cAgent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort +
1360 "/agent/" + agent.UUID.ToString() + "/" + agent.Scene.RegionInfo.RegionHandle.ToString() + "/release/";
1361
1362 m_interregionCommsOut.SendChildAgentUpdate(neighbourHandle, cAgent);
1363
1364 // Next, let's close the child agent connections that are too far away.
1365 agent.CloseChildAgents(neighbourx, neighboury);
1366
1367 //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo();
1368 agent.ControllingClient.RequestClientInfo();
1369
1370 //m_log.Debug("BEFORE CROSS");
1371 //Scene.DumpChildrenSeeds(UUID);
1372 //DumpKnownRegions();
1373 string agentcaps;
1374 if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps))
1375 {
1376 m_log.ErrorFormat("[SCENE COMM]: No CAPS information for region handle {0}, exiting CrossToNewRegion.",
1377 neighbourRegion.RegionHandle);
1378 return agent;
1379 }
1380 // TODO Should construct this behind a method
1381 string capsPath =
1382 "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort
1383 + "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/";
1384
1385 m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
1386
1387 IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>();
1388 if (eq != null)
1389 {
1390 eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
1391 capsPath, agent.UUID, agent.ControllingClient.SessionId);
1392 }
1393 else
1394 {
1395 agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
1396 capsPath);
1397 }
1398
1399 if (!WaitForCallback(agent.UUID))
1400 {
1401 ResetFromTransit(agent.UUID);
1402
1403 // Yikes! We should just have a ref to scene here.
1404 agent.Scene.InformClientOfNeighbours(agent);
1405
1406 return agent;
1407 }
1408
1409 agent.MakeChildAgent();
1410 // now we have a child agent in this region. Request all interesting data about other (root) agents
1411 agent.SendInitialFullUpdateToAllClients();
1412
1413 agent.CrossAttachmentsIntoNewRegion(neighbourHandle, true);
1414
1415 // m_scene.SendKillObject(m_localId);
1416
1417 agent.Scene.NotifyMyCoarseLocationChange();
1418 // the user may change their profile information in other region,
1419 // so the userinfo in UserProfileCache is not reliable any more, delete it
1420 if (agent.Scene.NeedSceneCacheClear(agent.UUID))
1421 {
1422 agent.Scene.CommsManager.UserProfileCacheService.RemoveUser(agent.UUID);
1423 m_log.DebugFormat(
1424 "[SCENE COMM]: User {0} is going to another region, profile cache removed", agent.UUID);
1425 }
1426 }
1427
1428 //m_log.Debug("AFTER CROSS");
1429 //Scene.DumpChildrenSeeds(UUID);
1430 //DumpKnownRegions();
1431 return agent;
1432 }
1433
1434 private void CrossAgentToNewRegionCompleted(IAsyncResult iar)
1435 {
1436 CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState;
1437 ScenePresence agent = icon.EndInvoke(iar);
1438
1439 // If the cross was successful, this agent is a child agent
1440 if (agent.IsChildAgent)
1441 {
1442 agent.Reset();
1443 }
1444 else // Not successful
1445 {
1446 //CachedUserInfo userInfo = m_commsProvider.UserProfileCacheService.GetUserDetails(agent.UUID);
1447 //if (userInfo != null)
1448 //{
1449 // userInfo.FetchInventory();
1450 //}
1451 agent.RestoreInCurrentScene();
1452 }
1453 // In any case
1454 agent.NotInTransit();
1455
1456 //m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname);
1457 }
1458
1459
1460 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
1461 {
1462 m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat);
1463 }
1464
1465 // deprecated as of 2008-08-27
1466 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
1467 {
1468 m_commsProvider.LogOffUser(userid, regionid, regionhandle, posx, posy, posz);
1469 }
1470
1471 public void ClearUserAgent(UUID avatarID)
1472 {
1473 m_commsProvider.UserService.ClearUserAgent(avatarID);
1474 }
1475
1476 public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
1477 {
1478 m_commsProvider.AddNewUserFriend(friendlistowner, friend, perms);
1479 }
1480
1481 public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
1482 {
1483 m_commsProvider.UpdateUserFriendPerms(friendlistowner, friend, perms);
1484 }
1485
1486 public void RemoveUserFriend(UUID friendlistowner, UUID friend)
1487 {
1488 m_commsProvider.RemoveUserFriend(friendlistowner, friend);
1489 }
1490
1491 public List<FriendListItem> GetUserFriendList(UUID friendlistowner)
1492 {
1493 return m_commsProvider.GetUserFriendList(friendlistowner);
1494 }
1495
1496 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
1497 {
1498 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
1499 }
1500
1501 public List<GridRegion> RequestNamedRegions(string name, int maxNumber) 304 public List<GridRegion> RequestNamedRegions(string name, int maxNumber)
1502 { 305 {
1503 return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); 306 return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber);
1504 } 307 }
1505 308
1506 //private void Dump(string msg, List<ulong> handles)
1507 //{
1508 // m_log.InfoFormat("-------------- HANDLE DUMP ({0}) ---------", msg);
1509 // foreach (ulong handle in handles)
1510 // {
1511 // uint x, y;
1512 // Utils.LongToUInts(handle, out x, out y);
1513 // x = x / Constants.RegionSize;
1514 // y = y / Constants.RegionSize;
1515 // m_log.InfoFormat("({0}, {1})", x, y);
1516 // }
1517 //}
1518 } 309 }
1519} 310}
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 2c66719..928dc97 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -35,6 +35,7 @@ using log4net;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Region.Framework.Scenes.Types; 36using OpenSim.Region.Framework.Scenes.Types;
37using OpenSim.Region.Physics.Manager; 37using OpenSim.Region.Physics.Manager;
38using OpenSim.Region.Framework.Interfaces;
38 39
39namespace OpenSim.Region.Framework.Scenes 40namespace OpenSim.Region.Framework.Scenes
40{ 41{
@@ -476,6 +477,15 @@ namespace OpenSim.Region.Framework.Scenes
476 part.Undo(); 477 part.Undo();
477 } 478 }
478 } 479 }
480 protected internal void HandleRedo(IClientAPI remoteClient, UUID primId)
481 {
482 if (primId != UUID.Zero)
483 {
484 SceneObjectPart part = m_parentScene.GetSceneObjectPart(primId);
485 if (part != null)
486 part.Redo();
487 }
488 }
479 489
480 protected internal void HandleObjectGroupUpdate( 490 protected internal void HandleObjectGroupUpdate(
481 IClientAPI remoteClient, UUID GroupID, uint objectLocalID, UUID Garbage) 491 IClientAPI remoteClient, UUID GroupID, uint objectLocalID, UUID Garbage)
@@ -532,33 +542,32 @@ namespace OpenSim.Region.Framework.Scenes
532 /// <returns>The scene object that was attached. Null if the scene object could not be found</returns> 542 /// <returns>The scene object that was attached. Null if the scene object could not be found</returns>
533 public SceneObjectGroup RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) 543 public SceneObjectGroup RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
534 { 544 {
535 SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient, 545 IInventoryAccessModule invAccess = m_parentScene.RequestModuleInterface<IInventoryAccessModule>();
536 itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, 546 if (invAccess != null)
537 false, false, remoteClient.AgentId, true);
538
539 if (objatt != null)
540 { 547 {
541 bool tainted = false; 548 SceneObjectGroup objatt = invAccess.RezObject(remoteClient,
542 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) 549 itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
543 tainted = true; 550 false, false, remoteClient.AgentId, true);
544 551
545 if (AttachObject( 552
546 remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false)) 553 if (objatt != null)
547 { 554 {
555 bool tainted = false;
556 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint())
557 tainted = true;
558
559 AttachObject(remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false);
548 objatt.ScheduleGroupForFullUpdate(); 560 objatt.ScheduleGroupForFullUpdate();
549 if (tainted) 561 if (tainted)
550 objatt.HasGroupChanged = true; 562 objatt.HasGroupChanged = true;
551 563
552 // Fire after attach, so we don't get messy perms dialogs 564 // Fire after attach, so we don't get messy perms dialogs
553 // 3 == AttachedRez 565 // 3 == AttachedRez
554 objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3); 566 objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3);
555
556 // Do this last so that event listeners have access to all the effects of the attachment
557 m_parentScene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId);
558 } 567 }
568 return objatt;
559 } 569 }
560 570 return null;
561 return objatt;
562 } 571 }
563 572
564 // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. 573 // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
@@ -669,7 +678,7 @@ namespace OpenSim.Region.Framework.Scenes
669 // it get cleaned up 678 // it get cleaned up
670 // 679 //
671 group.RootPart.RemFlag(PrimFlags.TemporaryOnRez); 680 group.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
672 group.HasGroupChanged = false; 681 group.HasGroupChanged = false;
673 } 682 }
674 else 683 else
675 { 684 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs
index c2e3370..6395d98 100644
--- a/OpenSim/Region/Framework/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs
@@ -468,11 +468,11 @@ namespace OpenSim.Region.Framework.Scenes
468 return presences; 468 return presences;
469 } 469 }
470 470
471 public RegionInfo GetRegionInfo(ulong regionHandle) 471 public RegionInfo GetRegionInfo(UUID regionID)
472 { 472 {
473 foreach (Scene scene in m_localScenes) 473 foreach (Scene scene in m_localScenes)
474 { 474 {
475 if (scene.RegionInfo.RegionHandle == regionHandle) 475 if (scene.RegionInfo.RegionID == regionID)
476 { 476 {
477 return scene.RegionInfo; 477 return scene.RegionInfo;
478 } 478 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 4676a30..2a4e5a2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -369,14 +369,22 @@ namespace OpenSim.Region.Framework.Scenes
369 } 369 }
370 370
371 lockPartsForRead(true); 371 lockPartsForRead(true);
372
373 if (RootPart.GetStatusSandbox())
372 { 374 {
373 foreach (SceneObjectPart part in m_parts.Values) 375 if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10)
374 { 376 {
375 377 RootPart.ScriptSetPhysicsStatus(false);
376 part.GroupPosition = val; 378 Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"),
377 379 ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false);
380 lockPartsForRead(false);
381 return;
378 } 382 }
379 } 383 }
384
385 foreach (SceneObjectPart part in m_parts.Values)
386 part.GroupPosition = val;
387
380 lockPartsForRead(false); 388 lockPartsForRead(false);
381 389
382 //if (m_rootPart.PhysActor != null) 390 //if (m_rootPart.PhysActor != null)
@@ -470,6 +478,34 @@ namespace OpenSim.Region.Framework.Scenes
470 } 478 }
471 } 479 }
472 480
481 private SceneObjectPart m_PlaySoundMasterPrim = null;
482 public SceneObjectPart PlaySoundMasterPrim
483 {
484 get { return m_PlaySoundMasterPrim; }
485 set { m_PlaySoundMasterPrim = value; }
486 }
487
488 private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>();
489 public List<SceneObjectPart> PlaySoundSlavePrims
490 {
491 get { return m_LoopSoundSlavePrims; }
492 set { m_LoopSoundSlavePrims = value; }
493 }
494
495 private SceneObjectPart m_LoopSoundMasterPrim = null;
496 public SceneObjectPart LoopSoundMasterPrim
497 {
498 get { return m_LoopSoundMasterPrim; }
499 set { m_LoopSoundMasterPrim = value; }
500 }
501
502 private List<SceneObjectPart> m_LoopSoundSlavePrims = new List<SceneObjectPart>();
503 public List<SceneObjectPart> LoopSoundSlavePrims
504 {
505 get { return m_LoopSoundSlavePrims; }
506 set { m_LoopSoundSlavePrims = value; }
507 }
508
473 // The UUID for the Region this Object is in. 509 // The UUID for the Region this Object is in.
474 public UUID RegionUUID 510 public UUID RegionUUID
475 { 511 {
@@ -584,7 +620,7 @@ namespace OpenSim.Region.Framework.Scenes
584 620
585 if (m_rootPart.Shape.PCode != 9 || m_rootPart.Shape.State == 0) 621 if (m_rootPart.Shape.PCode != 9 || m_rootPart.Shape.State == 0)
586 m_rootPart.ParentID = 0; 622 m_rootPart.ParentID = 0;
587 if (m_rootPart.LocalId==0) 623 if (m_rootPart.LocalId == 0)
588 m_rootPart.LocalId = m_scene.AllocateLocalId(); 624 m_rootPart.LocalId = m_scene.AllocateLocalId();
589 625
590 // No need to lock here since the object isn't yet in a scene 626 // No need to lock here since the object isn't yet in a scene
@@ -1586,6 +1622,9 @@ namespace OpenSim.Region.Framework.Scenes
1586 /// <param name="part"></param> 1622 /// <param name="part"></param>
1587 internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags) 1623 internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags)
1588 { 1624 {
1625// m_log.DebugFormat(
1626// "[SOG]: Sendinging part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId);
1627
1589 if (m_rootPart.UUID == part.UUID) 1628 if (m_rootPart.UUID == part.UUID)
1590 { 1629 {
1591 if (IsAttachment) 1630 if (IsAttachment)
@@ -1898,33 +1937,6 @@ namespace OpenSim.Region.Framework.Scenes
1898 } 1937 }
1899 } 1938 }
1900 1939
1901 public void rotLookAt(Quaternion target, float strength, float damping)
1902 {
1903 SceneObjectPart rootpart = m_rootPart;
1904 if (rootpart != null)
1905 {
1906 if (IsAttachment)
1907 {
1908 /*
1909 ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar);
1910 if (avatar != null)
1911 {
1912 Rotate the Av?
1913 } */
1914 }
1915 else
1916 {
1917 if (rootpart.PhysActor != null)
1918 {
1919 rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W);
1920 rootpart.PhysActor.APIDStrength = strength;
1921 rootpart.PhysActor.APIDDamping = damping;
1922 rootpart.PhysActor.APIDActive = true;
1923 }
1924 }
1925 }
1926 }
1927
1928 public void stopLookAt() 1940 public void stopLookAt()
1929 { 1941 {
1930 SceneObjectPart rootpart = m_rootPart; 1942 SceneObjectPart rootpart = m_rootPart;
@@ -2084,7 +2096,9 @@ namespace OpenSim.Region.Framework.Scenes
2084 2096
2085 foreach (SceneObjectPart part in m_parts.Values) 2097 foreach (SceneObjectPart part in m_parts.Values)
2086 { 2098 {
2087 2099 if (!IsSelected)
2100 part.UpdateLookAt();
2101
2088 part.SendScheduledUpdates(); 2102 part.SendScheduledUpdates();
2089 2103
2090 } 2104 }
@@ -2434,7 +2448,6 @@ namespace OpenSim.Region.Framework.Scenes
2434 2448
2435 AttachToBackup(); 2449 AttachToBackup();
2436 2450
2437
2438 // Here's the deal, this is ABSOLUTELY CRITICAL so the physics scene gets the update about the 2451 // Here's the deal, this is ABSOLUTELY CRITICAL so the physics scene gets the update about the
2439 // position of linkset prims. IF YOU CHANGE THIS, YOU MUST TEST colliding with just linked and 2452 // position of linkset prims. IF YOU CHANGE THIS, YOU MUST TEST colliding with just linked and
2440 // unmoved prims! 2453 // unmoved prims!
@@ -2449,9 +2462,10 @@ namespace OpenSim.Region.Framework.Scenes
2449 /// an independent SceneObjectGroup. 2462 /// an independent SceneObjectGroup.
2450 /// </summary> 2463 /// </summary>
2451 /// <param name="partID"></param> 2464 /// <param name="partID"></param>
2452 public void DelinkFromGroup(uint partID) 2465 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns>
2466 public SceneObjectGroup DelinkFromGroup(uint partID)
2453 { 2467 {
2454 DelinkFromGroup(partID, true); 2468 return DelinkFromGroup(partID, true);
2455 } 2469 }
2456 2470
2457 /// <summary> 2471 /// <summary>
@@ -2460,28 +2474,39 @@ namespace OpenSim.Region.Framework.Scenes
2460 /// </summary> 2474 /// </summary>
2461 /// <param name="partID"></param> 2475 /// <param name="partID"></param>
2462 /// <param name="sendEvents"></param> 2476 /// <param name="sendEvents"></param>
2463 public void DelinkFromGroup(uint partID, bool sendEvents) 2477 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns>
2478 public SceneObjectGroup DelinkFromGroup(uint partID, bool sendEvents)
2464 { 2479 {
2465 SceneObjectPart linkPart = GetChildPart(partID); 2480 SceneObjectPart linkPart = GetChildPart(partID);
2466 2481
2467 if (linkPart != null) 2482 if (linkPart != null)
2468 { 2483 {
2469 DelinkFromGroup(linkPart, sendEvents); 2484 return DelinkFromGroup(linkPart, sendEvents);
2470 } 2485 }
2471 else 2486 else
2472 { 2487 {
2473 m_log.InfoFormat("[SCENE OBJECT GROUP]: " + 2488 m_log.WarnFormat("[SCENE OBJECT GROUP]: " +
2474 "DelinkFromGroup(): Child prim {0} not found in object {1}, {2}", 2489 "DelinkFromGroup(): Child prim {0} not found in object {1}, {2}",
2475 partID, LocalId, UUID); 2490 partID, LocalId, UUID);
2491
2492 return null;
2476 } 2493 }
2477 } 2494 }
2478 2495
2479 public void DelinkFromGroup(SceneObjectPart linkPart, bool sendEvents) 2496 /// <summary>
2497 /// Delink the given prim from this group. The delinked prim is established as
2498 /// an independent SceneObjectGroup.
2499 /// </summary>
2500 /// <param name="partID"></param>
2501 /// <param name="sendEvents"></param>
2502 /// <returns>The object group of the newly delinked prim.</returns>
2503 public SceneObjectGroup DelinkFromGroup(SceneObjectPart linkPart, bool sendEvents)
2480 { 2504 {
2481 linkPart.ClearUndoState();
2482// m_log.DebugFormat( 2505// m_log.DebugFormat(
2483// "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", 2506// "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}",
2484// linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); 2507// linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID);
2508
2509 linkPart.ClearUndoState();
2485 2510
2486 Quaternion worldRot = linkPart.GetWorldRotation(); 2511 Quaternion worldRot = linkPart.GetWorldRotation();
2487 2512
@@ -2536,6 +2561,8 @@ namespace OpenSim.Region.Framework.Scenes
2536 2561
2537 //HasGroupChanged = true; 2562 //HasGroupChanged = true;
2538 //ScheduleGroupForFullUpdate(); 2563 //ScheduleGroupForFullUpdate();
2564
2565 return objectGroup;
2539 } 2566 }
2540 2567
2541 /// <summary> 2568 /// <summary>
@@ -2574,7 +2601,6 @@ namespace OpenSim.Region.Framework.Scenes
2574 2601
2575 part.LinkNum = linkNum; 2602 part.LinkNum = linkNum;
2576 2603
2577
2578 part.OffsetPosition = part.GroupPosition - AbsolutePosition; 2604 part.OffsetPosition = part.GroupPosition - AbsolutePosition;
2579 2605
2580 Quaternion rootRotation = m_rootPart.RotationOffset; 2606 Quaternion rootRotation = m_rootPart.RotationOffset;
@@ -2604,11 +2630,14 @@ namespace OpenSim.Region.Framework.Scenes
2604 { 2630 {
2605 if (m_rootPart.PhysActor.IsPhysical) 2631 if (m_rootPart.PhysActor.IsPhysical)
2606 { 2632 {
2607 Vector3 llmoveforce = pos - AbsolutePosition; 2633 if (!m_rootPart.BlockGrab)
2608 Vector3 grabforce = llmoveforce; 2634 {
2609 grabforce = (grabforce / 10) * m_rootPart.PhysActor.Mass; 2635 Vector3 llmoveforce = pos - AbsolutePosition;
2610 m_rootPart.PhysActor.AddForce(grabforce,true); 2636 Vector3 grabforce = llmoveforce;
2611 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); 2637 grabforce = (grabforce / 10) * m_rootPart.PhysActor.Mass;
2638 m_rootPart.PhysActor.AddForce(grabforce, true);
2639 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
2640 }
2612 } 2641 }
2613 else 2642 else
2614 { 2643 {
@@ -2966,6 +2995,7 @@ namespace OpenSim.Region.Framework.Scenes
2966 SceneObjectPart part = GetChildPart(localID); 2995 SceneObjectPart part = GetChildPart(localID);
2967 if (part != null) 2996 if (part != null)
2968 { 2997 {
2998 part.IgnoreUndoUpdate = true;
2969 if (scale.X > m_scene.m_maxNonphys) 2999 if (scale.X > m_scene.m_maxNonphys)
2970 scale.X = m_scene.m_maxNonphys; 3000 scale.X = m_scene.m_maxNonphys;
2971 if (scale.Y > m_scene.m_maxNonphys) 3001 if (scale.Y > m_scene.m_maxNonphys)
@@ -2993,6 +3023,7 @@ namespace OpenSim.Region.Framework.Scenes
2993 if (obPart.UUID != m_rootPart.UUID) 3023 if (obPart.UUID != m_rootPart.UUID)
2994 { 3024 {
2995 Vector3 oldSize = new Vector3(obPart.Scale); 3025 Vector3 oldSize = new Vector3(obPart.Scale);
3026 obPart.IgnoreUndoUpdate = true;
2996 3027
2997 float f = 1.0f; 3028 float f = 1.0f;
2998 float a = 1.0f; 3029 float a = 1.0f;
@@ -3050,6 +3081,8 @@ namespace OpenSim.Region.Framework.Scenes
3050 y *= a; 3081 y *= a;
3051 z *= a; 3082 z *= a;
3052 } 3083 }
3084 obPart.IgnoreUndoUpdate = false;
3085 obPart.StoreUndoState();
3053 } 3086 }
3054 } 3087 }
3055 } 3088 }
@@ -3066,6 +3099,7 @@ namespace OpenSim.Region.Framework.Scenes
3066 { 3099 {
3067 foreach (SceneObjectPart obPart in m_parts.Values) 3100 foreach (SceneObjectPart obPart in m_parts.Values)
3068 { 3101 {
3102 obPart.IgnoreUndoUpdate = true;
3069 if (obPart.UUID != m_rootPart.UUID) 3103 if (obPart.UUID != m_rootPart.UUID)
3070 { 3104 {
3071 Vector3 currentpos = new Vector3(obPart.OffsetPosition); 3105 Vector3 currentpos = new Vector3(obPart.OffsetPosition);
@@ -3079,6 +3113,8 @@ namespace OpenSim.Region.Framework.Scenes
3079 obPart.Resize(newSize); 3113 obPart.Resize(newSize);
3080 obPart.UpdateOffSet(currentpos); 3114 obPart.UpdateOffSet(currentpos);
3081 } 3115 }
3116 obPart.IgnoreUndoUpdate = false;
3117 obPart.StoreUndoState();
3082 } 3118 }
3083 } 3119 }
3084 lockPartsForRead(false); 3120 lockPartsForRead(false);
@@ -3089,6 +3125,8 @@ namespace OpenSim.Region.Framework.Scenes
3089 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); 3125 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
3090 } 3126 }
3091 3127
3128 part.IgnoreUndoUpdate = false;
3129 part.StoreUndoState();
3092 HasGroupChanged = true; 3130 HasGroupChanged = true;
3093 ScheduleGroupForTerseUpdate(); 3131 ScheduleGroupForTerseUpdate();
3094 } 3132 }
@@ -3104,13 +3142,26 @@ namespace OpenSim.Region.Framework.Scenes
3104 /// <param name="pos"></param> 3142 /// <param name="pos"></param>
3105 public void UpdateGroupPosition(Vector3 pos) 3143 public void UpdateGroupPosition(Vector3 pos)
3106 { 3144 {
3145 foreach (SceneObjectPart part in Children.Values)
3146 {
3147 part.StoreUndoState();
3148 }
3107 if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) 3149 if (m_scene.EventManager.TriggerGroupMove(UUID, pos))
3108 { 3150 {
3109 if (IsAttachment) 3151 if (IsAttachment)
3110 { 3152 {
3111 m_rootPart.AttachedPos = pos; 3153 m_rootPart.AttachedPos = pos;
3112 } 3154 }
3113 3155 if (RootPart.GetStatusSandbox())
3156 {
3157 if (Util.GetDistanceTo(RootPart.StatusSandboxPos, pos) > 10)
3158 {
3159 RootPart.ScriptSetPhysicsStatus(false);
3160 pos = AbsolutePosition;
3161 Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"),
3162 ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false);
3163 }
3164 }
3114 AbsolutePosition = pos; 3165 AbsolutePosition = pos;
3115 3166
3116 HasGroupChanged = true; 3167 HasGroupChanged = true;
@@ -3129,7 +3180,10 @@ namespace OpenSim.Region.Framework.Scenes
3129 public void UpdateSinglePosition(Vector3 pos, uint localID) 3180 public void UpdateSinglePosition(Vector3 pos, uint localID)
3130 { 3181 {
3131 SceneObjectPart part = GetChildPart(localID); 3182 SceneObjectPart part = GetChildPart(localID);
3132 3183 foreach (SceneObjectPart parts in Children.Values)
3184 {
3185 parts.StoreUndoState();
3186 }
3133 if (part != null) 3187 if (part != null)
3134 { 3188 {
3135 if (part.UUID == m_rootPart.UUID) 3189 if (part.UUID == m_rootPart.UUID)
@@ -3151,6 +3205,10 @@ namespace OpenSim.Region.Framework.Scenes
3151 /// <param name="pos"></param> 3205 /// <param name="pos"></param>
3152 private void UpdateRootPosition(Vector3 pos) 3206 private void UpdateRootPosition(Vector3 pos)
3153 { 3207 {
3208 foreach (SceneObjectPart part in Children.Values)
3209 {
3210 part.StoreUndoState();
3211 }
3154 Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); 3212 Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z);
3155 Vector3 oldPos = 3213 Vector3 oldPos =
3156 new Vector3(AbsolutePosition.X + m_rootPart.OffsetPosition.X, 3214 new Vector3(AbsolutePosition.X + m_rootPart.OffsetPosition.X,
@@ -3195,6 +3253,10 @@ namespace OpenSim.Region.Framework.Scenes
3195 /// <param name="rot"></param> 3253 /// <param name="rot"></param>
3196 public void UpdateGroupRotationR(Quaternion rot) 3254 public void UpdateGroupRotationR(Quaternion rot)
3197 { 3255 {
3256 foreach (SceneObjectPart parts in Children.Values)
3257 {
3258 parts.StoreUndoState();
3259 }
3198 m_rootPart.UpdateRotation(rot); 3260 m_rootPart.UpdateRotation(rot);
3199 3261
3200 PhysicsActor actor = m_rootPart.PhysActor; 3262 PhysicsActor actor = m_rootPart.PhysActor;
@@ -3215,6 +3277,10 @@ namespace OpenSim.Region.Framework.Scenes
3215 /// <param name="rot"></param> 3277 /// <param name="rot"></param>
3216 public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) 3278 public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot)
3217 { 3279 {
3280 foreach (SceneObjectPart parts in Children.Values)
3281 {
3282 parts.StoreUndoState();
3283 }
3218 m_rootPart.UpdateRotation(rot); 3284 m_rootPart.UpdateRotation(rot);
3219 3285
3220 PhysicsActor actor = m_rootPart.PhysActor; 3286 PhysicsActor actor = m_rootPart.PhysActor;
@@ -3238,6 +3304,10 @@ namespace OpenSim.Region.Framework.Scenes
3238 public void UpdateSingleRotation(Quaternion rot, uint localID) 3304 public void UpdateSingleRotation(Quaternion rot, uint localID)
3239 { 3305 {
3240 SceneObjectPart part = GetChildPart(localID); 3306 SceneObjectPart part = GetChildPart(localID);
3307 foreach (SceneObjectPart parts in Children.Values)
3308 {
3309 parts.StoreUndoState();
3310 }
3241 if (part != null) 3311 if (part != null)
3242 { 3312 {
3243 if (part.UUID == m_rootPart.UUID) 3313 if (part.UUID == m_rootPart.UUID)
@@ -3268,8 +3338,11 @@ namespace OpenSim.Region.Framework.Scenes
3268 } 3338 }
3269 else 3339 else
3270 { 3340 {
3341 part.IgnoreUndoUpdate = true;
3271 part.UpdateRotation(rot); 3342 part.UpdateRotation(rot);
3272 part.OffsetPosition = pos; 3343 part.OffsetPosition = pos;
3344 part.IgnoreUndoUpdate = false;
3345 part.StoreUndoState();
3273 } 3346 }
3274 } 3347 }
3275 } 3348 }
@@ -3283,6 +3356,7 @@ namespace OpenSim.Region.Framework.Scenes
3283 Quaternion axRot = rot; 3356 Quaternion axRot = rot;
3284 Quaternion oldParentRot = m_rootPart.RotationOffset; 3357 Quaternion oldParentRot = m_rootPart.RotationOffset;
3285 3358
3359 m_rootPart.StoreUndoState();
3286 m_rootPart.UpdateRotation(rot); 3360 m_rootPart.UpdateRotation(rot);
3287 if (m_rootPart.PhysActor != null) 3361 if (m_rootPart.PhysActor != null)
3288 { 3362 {
@@ -3296,6 +3370,7 @@ namespace OpenSim.Region.Framework.Scenes
3296 { 3370 {
3297 if (prim.UUID != m_rootPart.UUID) 3371 if (prim.UUID != m_rootPart.UUID)
3298 { 3372 {
3373 prim.IgnoreUndoUpdate = true;
3299 Vector3 axPos = prim.OffsetPosition; 3374 Vector3 axPos = prim.OffsetPosition;
3300 axPos *= oldParentRot; 3375 axPos *= oldParentRot;
3301 axPos *= Quaternion.Inverse(axRot); 3376 axPos *= Quaternion.Inverse(axRot);
@@ -3308,6 +3383,16 @@ namespace OpenSim.Region.Framework.Scenes
3308 } 3383 }
3309 } 3384 }
3310 } 3385 }
3386
3387 foreach (SceneObjectPart childpart in Children.Values)
3388 {
3389 if (childpart != m_rootPart)
3390 {
3391 childpart.IgnoreUndoUpdate = false;
3392 childpart.StoreUndoState();
3393 }
3394 }
3395
3311 lockPartsForRead(false); 3396 lockPartsForRead(false);
3312 3397
3313 m_rootPart.ScheduleTerseUpdate(); 3398 m_rootPart.ScheduleTerseUpdate();
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 0d19589..57635f5 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -133,6 +133,18 @@ namespace OpenSim.Region.Framework.Scenes
133 [XmlIgnore] 133 [XmlIgnore]
134 public bool DIE_AT_EDGE; 134 public bool DIE_AT_EDGE;
135 135
136 [XmlIgnore]
137 public bool RETURN_AT_EDGE;
138
139 [XmlIgnore]
140 public bool BlockGrab;
141
142 [XmlIgnore]
143 public bool StatusSandbox;
144
145 [XmlIgnore]
146 public Vector3 StatusSandboxPos;
147
136 // TODO: This needs to be persisted in next XML version update! 148 // TODO: This needs to be persisted in next XML version update!
137 [XmlIgnore] 149 [XmlIgnore]
138 public int[] PayPrice = {-2,-2,-2,-2,-2}; 150 public int[] PayPrice = {-2,-2,-2,-2,-2};
@@ -219,6 +231,15 @@ namespace OpenSim.Region.Framework.Scenes
219 [XmlIgnore] 231 [XmlIgnore]
220 public Quaternion SpinOldOrientation = Quaternion.Identity; 232 public Quaternion SpinOldOrientation = Quaternion.Identity;
221 233
234 [XmlIgnore]
235 public Quaternion m_APIDTarget = Quaternion.Identity;
236
237 [XmlIgnore]
238 public float m_APIDDamp = 0;
239
240 [XmlIgnore]
241 public float m_APIDStrength = 0;
242
222 /// <summary> 243 /// <summary>
223 /// This part's inventory 244 /// This part's inventory
224 /// </summary> 245 /// </summary>
@@ -233,6 +254,9 @@ namespace OpenSim.Region.Framework.Scenes
233 public bool Undoing; 254 public bool Undoing;
234 255
235 [XmlIgnore] 256 [XmlIgnore]
257 public bool IgnoreUndoUpdate = false;
258
259 [XmlIgnore]
236 private PrimFlags LocalFlags; 260 private PrimFlags LocalFlags;
237 [XmlIgnore] 261 [XmlIgnore]
238 private float m_damage = -1.0f; 262 private float m_damage = -1.0f;
@@ -254,6 +278,7 @@ namespace OpenSim.Region.Framework.Scenes
254 private string m_text = String.Empty; 278 private string m_text = String.Empty;
255 private string m_touchName = String.Empty; 279 private string m_touchName = String.Empty;
256 private readonly UndoStack<UndoState> m_undo = new UndoStack<UndoState>(5); 280 private readonly UndoStack<UndoState> m_undo = new UndoStack<UndoState>(5);
281 private readonly UndoStack<UndoState> m_redo = new UndoStack<UndoState>(5);
257 private UUID _creatorID; 282 private UUID _creatorID;
258 283
259 private bool m_passTouches; 284 private bool m_passTouches;
@@ -506,6 +531,27 @@ namespace OpenSim.Region.Framework.Scenes
506 } 531 }
507 } 532 }
508 533
534 [XmlIgnore]
535 public Quaternion APIDTarget
536 {
537 get { return m_APIDTarget; }
538 set { m_APIDTarget = value; }
539 }
540
541 [XmlIgnore]
542 public float APIDDamp
543 {
544 get { return m_APIDDamp; }
545 set { m_APIDDamp = value; }
546 }
547
548 [XmlIgnore]
549 public float APIDStrength
550 {
551 get { return m_APIDStrength; }
552 set { m_APIDStrength = value; }
553 }
554
509 public ulong RegionHandle 555 public ulong RegionHandle
510 { 556 {
511 get { return m_regionHandle; } 557 get { return m_regionHandle; }
@@ -517,6 +563,33 @@ namespace OpenSim.Region.Framework.Scenes
517 get { return m_scriptAccessPin; } 563 get { return m_scriptAccessPin; }
518 set { m_scriptAccessPin = (int)value; } 564 set { m_scriptAccessPin = (int)value; }
519 } 565 }
566 private SceneObjectPart m_PlaySoundMasterPrim = null;
567 public SceneObjectPart PlaySoundMasterPrim
568 {
569 get { return m_PlaySoundMasterPrim; }
570 set { m_PlaySoundMasterPrim = value; }
571 }
572
573 private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>();
574 public List<SceneObjectPart> PlaySoundSlavePrims
575 {
576 get { return m_LoopSoundSlavePrims; }
577 set { m_LoopSoundSlavePrims = value; }
578 }
579
580 private SceneObjectPart m_LoopSoundMasterPrim = null;
581 public SceneObjectPart LoopSoundMasterPrim
582 {
583 get { return m_LoopSoundMasterPrim; }
584 set { m_LoopSoundMasterPrim = value; }
585 }
586
587 private List<SceneObjectPart> m_LoopSoundSlavePrims = new List<SceneObjectPart>();
588 public List<SceneObjectPart> LoopSoundSlavePrims
589 {
590 get { return m_LoopSoundSlavePrims; }
591 set { m_LoopSoundSlavePrims = value; }
592 }
520 593
521 public Byte[] TextureAnimation 594 public Byte[] TextureAnimation
522 { 595 {
@@ -576,8 +649,6 @@ namespace OpenSim.Region.Framework.Scenes
576 } 649 }
577 set 650 set
578 { 651 {
579 StoreUndoState();
580
581 m_groupPosition = value; 652 m_groupPosition = value;
582 PhysicsActor actor = PhysActor; 653 PhysicsActor actor = PhysActor;
583 if (actor != null) 654 if (actor != null)
@@ -1403,6 +1474,10 @@ namespace OpenSim.Region.Framework.Scenes
1403 { 1474 {
1404 m_undo.Clear(); 1475 m_undo.Clear();
1405 } 1476 }
1477 lock (m_redo)
1478 {
1479 m_redo.Clear();
1480 }
1406 StoreUndoState(); 1481 StoreUndoState();
1407 } 1482 }
1408 1483
@@ -1713,6 +1788,66 @@ namespace OpenSim.Region.Framework.Scenes
1713 return m_parentGroup.RootPart.DIE_AT_EDGE; 1788 return m_parentGroup.RootPart.DIE_AT_EDGE;
1714 } 1789 }
1715 1790
1791 public bool GetReturnAtEdge()
1792 {
1793 if (m_parentGroup == null)
1794 return false;
1795 if (m_parentGroup.IsDeleted)
1796 return false;
1797
1798 return m_parentGroup.RootPart.RETURN_AT_EDGE;
1799 }
1800
1801 public void SetReturnAtEdge(bool p)
1802 {
1803 if (m_parentGroup == null)
1804 return;
1805 if (m_parentGroup.IsDeleted)
1806 return;
1807
1808 m_parentGroup.RootPart.RETURN_AT_EDGE = p;
1809 }
1810
1811 public bool GetBlockGrab()
1812 {
1813 if (m_parentGroup == null)
1814 return false;
1815 if (m_parentGroup.IsDeleted)
1816 return false;
1817
1818 return m_parentGroup.RootPart.BlockGrab;
1819 }
1820
1821 public void SetBlockGrab(bool p)
1822 {
1823 if (m_parentGroup == null)
1824 return;
1825 if (m_parentGroup.IsDeleted)
1826 return;
1827
1828 m_parentGroup.RootPart.BlockGrab = p;
1829 }
1830
1831 public void SetStatusSandbox(bool p)
1832 {
1833 if (m_parentGroup == null)
1834 return;
1835 if (m_parentGroup.IsDeleted)
1836 return;
1837 StatusSandboxPos = m_parentGroup.RootPart.AbsolutePosition;
1838 m_parentGroup.RootPart.StatusSandbox = p;
1839 }
1840
1841 public bool GetStatusSandbox()
1842 {
1843 if (m_parentGroup == null)
1844 return false;
1845 if (m_parentGroup.IsDeleted)
1846 return false;
1847
1848 return m_parentGroup.RootPart.StatusSandbox;
1849 }
1850
1716 public int GetAxisRotation(int axis) 1851 public int GetAxisRotation(int axis)
1717 { 1852 {
1718 //Cannot use ScriptBaseClass constants as no referance to it currently. 1853 //Cannot use ScriptBaseClass constants as no referance to it currently.
@@ -1924,7 +2059,7 @@ namespace OpenSim.Region.Framework.Scenes
1924 // play the sound. 2059 // play the sound.
1925 if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) 2060 if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f)
1926 { 2061 {
1927 SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0); 2062 SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false);
1928 } 2063 }
1929 2064
1930 if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.collision_start) != 0) 2065 if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.collision_start) != 0)
@@ -2499,9 +2634,8 @@ namespace OpenSim.Region.Framework.Scenes
2499 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); 2634 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars();
2500 foreach (ScenePresence p in avatarts) 2635 foreach (ScenePresence p in avatarts)
2501 { 2636 {
2502 // TODO: some filtering by distance of avatar 2637 if (!(Util.GetDistanceTo(p.AbsolutePosition, AbsolutePosition) >= 100))
2503 2638 p.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
2504 p.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
2505 } 2639 }
2506 } 2640 }
2507 2641
@@ -2562,7 +2696,38 @@ namespace OpenSim.Region.Framework.Scenes
2562 2696
2563 public void RotLookAt(Quaternion target, float strength, float damping) 2697 public void RotLookAt(Quaternion target, float strength, float damping)
2564 { 2698 {
2565 m_parentGroup.rotLookAt(target, strength, damping); 2699 rotLookAt(target, strength, damping);
2700 }
2701
2702 public void rotLookAt(Quaternion target, float strength, float damping)
2703 {
2704 if (IsAttachment)
2705 {
2706 /*
2707 ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar);
2708 if (avatar != null)
2709 {
2710 Rotate the Av?
2711 } */
2712 }
2713 else
2714 {
2715 APIDDamp = damping;
2716 APIDStrength = strength;
2717 APIDTarget = target;
2718 }
2719 }
2720
2721 public void startLookAt(Quaternion rot, float damp, float strength)
2722 {
2723 APIDDamp = damp;
2724 APIDStrength = strength;
2725 APIDTarget = rot;
2726 }
2727
2728 public void stopLookAt()
2729 {
2730 APIDTarget = Quaternion.Identity;
2566 } 2731 }
2567 2732
2568 /// <summary> 2733 /// <summary>
@@ -2824,7 +2989,7 @@ namespace OpenSim.Region.Framework.Scenes
2824 /// <param name="volume"></param> 2989 /// <param name="volume"></param>
2825 /// <param name="triggered"></param> 2990 /// <param name="triggered"></param>
2826 /// <param name="flags"></param> 2991 /// <param name="flags"></param>
2827 public void SendSound(string sound, double volume, bool triggered, byte flags) 2992 public void SendSound(string sound, double volume, bool triggered, byte flags, float radius, bool useMaster, bool isMaster)
2828 { 2993 {
2829 if (volume > 1) 2994 if (volume > 1)
2830 volume = 1; 2995 volume = 1;
@@ -2859,10 +3024,51 @@ namespace OpenSim.Region.Framework.Scenes
2859 ISoundModule soundModule = m_parentGroup.Scene.RequestModuleInterface<ISoundModule>(); 3024 ISoundModule soundModule = m_parentGroup.Scene.RequestModuleInterface<ISoundModule>();
2860 if (soundModule != null) 3025 if (soundModule != null)
2861 { 3026 {
2862 if (triggered) 3027 if (useMaster)
2863 soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle); 3028 {
3029 if (isMaster)
3030 {
3031 if (triggered)
3032 soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius);
3033 else
3034 soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius);
3035 ParentGroup.PlaySoundMasterPrim = this;
3036 ownerID = this._ownerID;
3037 objectID = this.UUID;
3038 parentID = this.GetRootPartUUID();
3039 position = this.AbsolutePosition; // region local
3040 regionHandle = this.ParentGroup.Scene.RegionInfo.RegionHandle;
3041 if (triggered)
3042 soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius);
3043 else
3044 soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius);
3045 foreach (SceneObjectPart prim in ParentGroup.PlaySoundSlavePrims)
3046 {
3047 ownerID = prim._ownerID;
3048 objectID = prim.UUID;
3049 parentID = prim.GetRootPartUUID();
3050 position = prim.AbsolutePosition; // region local
3051 regionHandle = prim.ParentGroup.Scene.RegionInfo.RegionHandle;
3052 if (triggered)
3053 soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius);
3054 else
3055 soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius);
3056 }
3057 ParentGroup.PlaySoundSlavePrims.Clear();
3058 ParentGroup.PlaySoundMasterPrim = null;
3059 }
3060 else
3061 {
3062 ParentGroup.PlaySoundSlavePrims.Add(this);
3063 }
3064 }
2864 else 3065 else
2865 soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags); 3066 {
3067 if (triggered)
3068 soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius);
3069 else
3070 soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius);
3071 }
2866 } 3072 }
2867 } 3073 }
2868 3074
@@ -3181,6 +3387,14 @@ namespace OpenSim.Region.Framework.Scenes
3181 hasProfileCut = hasDimple; // is it the same thing? 3387 hasProfileCut = hasDimple; // is it the same thing?
3182 } 3388 }
3183 3389
3390 public void SetVehicleFlags(int param, bool remove)
3391 {
3392 if (PhysActor != null)
3393 {
3394 PhysActor.VehicleFlags(param, remove);
3395 }
3396 }
3397
3184 public void SetGroup(UUID groupID, IClientAPI client) 3398 public void SetGroup(UUID groupID, IClientAPI client)
3185 { 3399 {
3186 _groupID = groupID; 3400 _groupID = groupID;
@@ -3285,27 +3499,30 @@ namespace OpenSim.Region.Framework.Scenes
3285 { 3499 {
3286 if (!Undoing) 3500 if (!Undoing)
3287 { 3501 {
3288 if (m_parentGroup != null) 3502 if (!IgnoreUndoUpdate)
3289 { 3503 {
3290 lock (m_undo) 3504 if (m_parentGroup != null)
3291 { 3505 {
3292 if (m_undo.Count > 0) 3506 lock (m_undo)
3293 { 3507 {
3294 UndoState last = m_undo.Peek(); 3508 if (m_undo.Count > 0)
3295 if (last != null)
3296 { 3509 {
3297 if (last.Compare(this)) 3510 UndoState last = m_undo.Peek();
3298 return; 3511 if (last != null)
3512 {
3513 if (last.Compare(this))
3514 return;
3515 }
3299 } 3516 }
3300 }
3301 3517
3302 if (m_parentGroup.GetSceneMaxUndo() > 0) 3518 if (m_parentGroup.GetSceneMaxUndo() > 0)
3303 { 3519 {
3304 UndoState nUndo = new UndoState(this); 3520 UndoState nUndo = new UndoState(this);
3305 3521
3306 m_undo.Push(nUndo); 3522 m_undo.Push(nUndo);
3307 } 3523 }
3308 3524
3525 }
3309 } 3526 }
3310 } 3527 }
3311 } 3528 }
@@ -3776,11 +3993,36 @@ namespace OpenSim.Region.Framework.Scenes
3776 lock (m_undo) 3993 lock (m_undo)
3777 { 3994 {
3778 if (m_undo.Count > 0) 3995 if (m_undo.Count > 0)
3996 {
3997 UndoState nUndo = null;
3998 if (m_parentGroup.GetSceneMaxUndo() > 0)
3779 { 3999 {
3780 UndoState goback = m_undo.Pop(); 4000 nUndo = new UndoState(this);
3781 if (goback != null) 4001 }
3782 goback.PlaybackState(this); 4002 UndoState goback = m_undo.Pop();
4003 if (goback != null)
4004 {
4005 goback.PlaybackState(this);
4006 if (nUndo != null)
4007 m_redo.Push(nUndo);
4008 }
4009 }
4010 }
4011 }
4012
4013 public void Redo()
4014 {
4015 lock (m_redo)
4016 {
4017 if (m_parentGroup.GetSceneMaxUndo() > 0)
4018 {
4019 UndoState nUndo = new UndoState(this);
4020
4021 m_undo.Push(nUndo);
3783 } 4022 }
4023 UndoState gofwd = m_redo.Pop();
4024 if (gofwd != null)
4025 gofwd.PlayfwdState(this);
3784 } 4026 }
3785 } 4027 }
3786 4028
@@ -3827,6 +4069,18 @@ namespace OpenSim.Region.Framework.Scenes
3827 (pos.Z != OffsetPosition.Z)) 4069 (pos.Z != OffsetPosition.Z))
3828 { 4070 {
3829 Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); 4071 Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z);
4072
4073 if (ParentGroup.RootPart.GetStatusSandbox())
4074 {
4075 if (Util.GetDistanceTo(ParentGroup.RootPart.StatusSandboxPos, newPos) > 10)
4076 {
4077 ParentGroup.RootPart.ScriptSetPhysicsStatus(false);
4078 newPos = OffsetPosition;
4079 ParentGroup.Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"),
4080 ChatTypeEnum.DebugChannel, 0x7FFFFFFF, ParentGroup.RootPart.AbsolutePosition, Name, UUID, false);
4081 }
4082 }
4083
3830 OffsetPosition = newPos; 4084 OffsetPosition = newPos;
3831 ScheduleTerseUpdate(); 4085 ScheduleTerseUpdate();
3832 } 4086 }
@@ -4119,7 +4373,6 @@ namespace OpenSim.Region.Framework.Scenes
4119 (rot.Z != RotationOffset.Z) || 4373 (rot.Z != RotationOffset.Z) ||
4120 (rot.W != RotationOffset.W)) 4374 (rot.W != RotationOffset.W))
4121 { 4375 {
4122 //StoreUndoState();
4123 RotationOffset = rot; 4376 RotationOffset = rot;
4124 ParentGroup.HasGroupChanged = true; 4377 ParentGroup.HasGroupChanged = true;
4125 ScheduleTerseUpdate(); 4378 ScheduleTerseUpdate();
@@ -4303,7 +4556,7 @@ namespace OpenSim.Region.Framework.Scenes
4303 else 4556 else
4304 { 4557 {
4305// m_log.DebugFormat( 4558// m_log.DebugFormat(
4306// "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents()", Name, LocalId); 4559// "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents()", Name, LocalId);
4307 ScheduleFullUpdate(); 4560 ScheduleFullUpdate();
4308 } 4561 }
4309 } 4562 }
@@ -4421,5 +4674,36 @@ namespace OpenSim.Region.Framework.Scenes
4421 4674
4422 Inventory.ApplyNextOwnerPermissions(); 4675 Inventory.ApplyNextOwnerPermissions();
4423 } 4676 }
4677 public void UpdateLookAt()
4678 {
4679 try
4680 {
4681 if (APIDTarget != Quaternion.Identity)
4682 {
4683 if (Single.IsNaN(APIDTarget.W) == true)
4684 {
4685 APIDTarget = Quaternion.Identity;
4686 return;
4687 }
4688 Quaternion rot = RotationOffset;
4689 Quaternion dir = (rot - APIDTarget);
4690 float speed = ((APIDStrength / APIDDamp) * (float)(Math.PI / 180.0f));
4691 if (dir.Z > speed)
4692 {
4693 rot.Z -= speed;
4694 }
4695 if (dir.Z < -speed)
4696 {
4697 rot.Z += speed;
4698 }
4699 rot.Normalize();
4700 UpdateRotation(rot);
4701 }
4702 }
4703 catch (Exception ex)
4704 {
4705 m_log.Error("[Physics] " + ex);
4706 }
4707 }
4424 } 4708 }
4425} 4709}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 3317dd3..013285f 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -34,7 +34,6 @@ using System.Reflection;
34using OpenMetaverse; 34using OpenMetaverse;
35using log4net; 35using log4net;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Communications.Cache;
38using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes.Scripting; 38using OpenSim.Region.Framework.Scenes.Scripting;
40 39
@@ -318,8 +317,6 @@ namespace OpenSim.Region.Framework.Scenes
318 } 317 }
319 } 318 }
320 319
321 static System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
322
323 private void RestoreSavedScriptState(UUID oldID, UUID newID) 320 private void RestoreSavedScriptState(UUID oldID, UUID newID)
324 { 321 {
325 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); 322 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
@@ -585,7 +582,7 @@ namespace OpenSim.Region.Framework.Scenes
585 m_items.TryGetValue(itemId, out item); 582 m_items.TryGetValue(itemId, out item);
586 m_items.LockItemsForRead(false); 583 m_items.LockItemsForRead(false);
587 return item; 584 return item;
588 } 585 }
589 586
590 /// <summary> 587 /// <summary>
591 /// Get inventory items by name. 588 /// Get inventory items by name.
@@ -594,7 +591,7 @@ namespace OpenSim.Region.Framework.Scenes
594 /// <returns> 591 /// <returns>
595 /// A list of inventory items with that name. 592 /// A list of inventory items with that name.
596 /// If no inventory item has that name then an empty list is returned. 593 /// If no inventory item has that name then an empty list is returned.
597 /// </returns> 594 /// </returns>
598 public IList<TaskInventoryItem> GetInventoryItems(string name) 595 public IList<TaskInventoryItem> GetInventoryItems(string name)
599 { 596 {
600 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(); 597 IList<TaskInventoryItem> items = new List<TaskInventoryItem>();
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 6a2ab02..453523a 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -33,12 +33,12 @@ using OpenMetaverse;
33using log4net; 33using log4net;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Client; 35using OpenSim.Framework.Client;
36using OpenSim.Framework.Communications.Cache;
37using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes.Animation; 37using OpenSim.Region.Framework.Scenes.Animation;
39using OpenSim.Region.Framework.Scenes.Types; 38using OpenSim.Region.Framework.Scenes.Types;
40using OpenSim.Region.Physics.Manager; 39using OpenSim.Region.Physics.Manager;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion; 40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41using OpenSim.Services.Interfaces;
42 42
43namespace OpenSim.Region.Framework.Scenes 43namespace OpenSim.Region.Framework.Scenes
44{ 44{
@@ -167,6 +167,8 @@ namespace OpenSim.Region.Framework.Scenes
167 167
168 private Quaternion m_bodyRot= Quaternion.Identity; 168 private Quaternion m_bodyRot= Quaternion.Identity;
169 169
170 private Quaternion m_bodyRotPrevious = Quaternion.Identity;
171
170 private const int LAND_VELOCITYMAG_MAX = 12; 172 private const int LAND_VELOCITYMAG_MAX = 12;
171 173
172 public bool IsRestrictedToRegion; 174 public bool IsRestrictedToRegion;
@@ -233,7 +235,7 @@ namespace OpenSim.Region.Framework.Scenes
233 // Agent's Draw distance. 235 // Agent's Draw distance.
234 protected float m_DrawDistance; 236 protected float m_DrawDistance;
235 237
236 protected AvatarAppearance m_appearance; 238 protected AvatarAppearance m_appearance;
237 239
238 // neighbouring regions we have enabled a child agent in 240 // neighbouring regions we have enabled a child agent in
239 // holds the seed cap for the child agent in that region 241 // holds the seed cap for the child agent in that region
@@ -264,6 +266,8 @@ namespace OpenSim.Region.Framework.Scenes
264 266
265 // For teleports and crossings callbacks 267 // For teleports and crossings callbacks
266 string m_callbackURI; 268 string m_callbackURI;
269 UUID m_originRegionID;
270
267 ulong m_rootRegionHandle; 271 ulong m_rootRegionHandle;
268 272
269 /// <value> 273 /// <value>
@@ -518,6 +522,12 @@ namespace OpenSim.Region.Framework.Scenes
518 set { m_bodyRot = value; } 522 set { m_bodyRot = value; }
519 } 523 }
520 524
525 public Quaternion PreviousRotation
526 {
527 get { return m_bodyRotPrevious; }
528 set { m_bodyRotPrevious = value; }
529 }
530
521 /// <summary> 531 /// <summary>
522 /// If this is true, agent doesn't have a representation in this scene. 532 /// If this is true, agent doesn't have a representation in this scene.
523 /// this is an agent 'looking into' this scene from a nearby scene(region) 533 /// this is an agent 'looking into' this scene from a nearby scene(region)
@@ -650,7 +660,7 @@ namespace OpenSim.Region.Framework.Scenes
650 #region Constructor(s) 660 #region Constructor(s)
651 661
652 public ScenePresence() 662 public ScenePresence()
653 { 663 {
654 m_sendCourseLocationsMethod = SendCoarseLocationsDefault; 664 m_sendCourseLocationsMethod = SendCoarseLocationsDefault;
655 CreateSceneViewer(); 665 CreateSceneViewer();
656 m_animator = new ScenePresenceAnimator(this); 666 m_animator = new ScenePresenceAnimator(this);
@@ -868,6 +878,31 @@ namespace OpenSim.Region.Framework.Scenes
868 if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) 878 if (pos.X < 0 || pos.Y < 0 || pos.Z < 0)
869 { 879 {
870 Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); 880 Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128);
881
882 if (pos.X < 0)
883 {
884 emergencyPos.X = (int)Constants.RegionSize + pos.X;
885 if (!(pos.Y < 0))
886 emergencyPos.Y = pos.Y;
887 if (!(pos.Z < 0))
888 emergencyPos.X = pos.X;
889 }
890 if (pos.Y < 0)
891 {
892 emergencyPos.Y = (int)Constants.RegionSize + pos.Y;
893 if (!(pos.X < 0))
894 emergencyPos.X = pos.X;
895 if (!(pos.Z < 0))
896 emergencyPos.Z = pos.Z;
897 }
898 if (pos.Z < 0)
899 {
900 if (!(pos.X < 0))
901 emergencyPos.X = pos.X;
902 if (!(pos.Y < 0))
903 emergencyPos.Y = pos.Y;
904 //Leave as 128
905 }
871 906
872 m_log.WarnFormat( 907 m_log.WarnFormat(
873 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", 908 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
@@ -1127,8 +1162,10 @@ namespace OpenSim.Region.Framework.Scenes
1127 /// This is called upon a very important packet sent from the client, 1162 /// This is called upon a very important packet sent from the client,
1128 /// so it's client-controlled. Never call this method directly. 1163 /// so it's client-controlled. Never call this method directly.
1129 /// </summary> 1164 /// </summary>
1130 public void CompleteMovement() 1165 public void CompleteMovement(IClientAPI client)
1131 { 1166 {
1167 //m_log.Debug("[SCENE PRESENCE]: CompleteMovement");
1168
1132 Vector3 look = Velocity; 1169 Vector3 look = Velocity;
1133 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) 1170 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
1134 { 1171 {
@@ -1153,7 +1190,7 @@ namespace OpenSim.Region.Framework.Scenes
1153 if ((m_callbackURI != null) && !m_callbackURI.Equals("")) 1190 if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
1154 { 1191 {
1155 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); 1192 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI);
1156 Scene.SendReleaseAgent(m_rootRegionHandle, UUID, m_callbackURI); 1193 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI);
1157 m_callbackURI = null; 1194 m_callbackURI = null;
1158 } 1195 }
1159 1196
@@ -1161,6 +1198,21 @@ namespace OpenSim.Region.Framework.Scenes
1161 1198
1162 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); 1199 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look);
1163 SendInitialData(); 1200 SendInitialData();
1201
1202 // Create child agents in neighbouring regions
1203 if (!m_isChildAgent)
1204 {
1205 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
1206 if (m_agentTransfer != null)
1207 m_agentTransfer.EnableChildAgents(this);
1208 else
1209 m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active");
1210
1211 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
1212 if (friendsModule != null)
1213 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1214 }
1215
1164 } 1216 }
1165 1217
1166 /// <summary> 1218 /// <summary>
@@ -2364,6 +2416,7 @@ namespace OpenSim.Region.Framework.Scenes
2364 { 2416 {
2365 if (m_isChildAgent) 2417 if (m_isChildAgent)
2366 { 2418 {
2419 // WHAT???
2367 m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); 2420 m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!");
2368 2421
2369 // we have to reset the user's child agent connections. 2422 // we have to reset the user's child agent connections.
@@ -2387,7 +2440,9 @@ namespace OpenSim.Region.Framework.Scenes
2387 2440
2388 if (m_scene.SceneGridService != null) 2441 if (m_scene.SceneGridService != null)
2389 { 2442 {
2390 m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List<RegionInfo>()); 2443 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
2444 if (m_agentTransfer != null)
2445 m_agentTransfer.EnableChildAgents(this);
2391 } 2446 }
2392 2447
2393 return; 2448 return;
@@ -2687,14 +2742,9 @@ namespace OpenSim.Region.Framework.Scenes
2687 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, 2742 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId,
2688 pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); 2743 pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot));
2689 2744
2690 if (!m_isChildAgent)
2691 {
2692 m_scene.InformClientOfNeighbours(this);
2693 }
2694
2695 SendInitialFullUpdateToAllClients(); 2745 SendInitialFullUpdateToAllClients();
2696 SendAppearanceToAllOtherAgents(); 2746 SendAppearanceToAllOtherAgents();
2697 } 2747 }
2698 2748
2699 /// <summary> 2749 /// <summary>
2700 /// Tell the client for this scene presence what items it should be wearing now 2750 /// Tell the client for this scene presence what items it should be wearing now
@@ -2776,14 +2826,19 @@ namespace OpenSim.Region.Framework.Scenes
2776 } 2826 }
2777 } 2827 }
2778 } 2828 }
2829
2779 } 2830 }
2780 2831
2832
2781 #endregion Bake Cache Check 2833 #endregion Bake Cache Check
2782 2834
2783 m_appearance.SetAppearance(textureEntry, visualParams); 2835 m_appearance.SetAppearance(textureEntry, visualParams);
2784 if (m_appearance.AvatarHeight > 0) 2836 if (m_appearance.AvatarHeight > 0)
2785 SetHeight(m_appearance.AvatarHeight); 2837 SetHeight(m_appearance.AvatarHeight);
2786 m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); 2838
2839 // This is not needed, because only the transient data changed
2840 //AvatarData adata = new AvatarData(m_appearance);
2841 //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2787 2842
2788 SendAppearanceToAllOtherAgents(); 2843 SendAppearanceToAllOtherAgents();
2789 if (!m_startAnimationSet) 2844 if (!m_startAnimationSet)
@@ -2803,7 +2858,8 @@ namespace OpenSim.Region.Framework.Scenes
2803 public void SetWearable(int wearableId, AvatarWearable wearable) 2858 public void SetWearable(int wearableId, AvatarWearable wearable)
2804 { 2859 {
2805 m_appearance.SetWearable(wearableId, wearable); 2860 m_appearance.SetWearable(wearableId, wearable);
2806 m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); 2861 AvatarData adata = new AvatarData(m_appearance);
2862 m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2807 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); 2863 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
2808 } 2864 }
2809 2865
@@ -2900,36 +2956,75 @@ namespace OpenSim.Region.Framework.Scenes
2900 { 2956 {
2901 // Checks if where it's headed exists a region 2957 // Checks if where it's headed exists a region
2902 2958
2959 bool needsTransit = false;
2903 if (m_scene.TestBorderCross(pos2, Cardinals.W)) 2960 if (m_scene.TestBorderCross(pos2, Cardinals.W))
2904 { 2961 {
2905 if (m_scene.TestBorderCross(pos2, Cardinals.S)) 2962 if (m_scene.TestBorderCross(pos2, Cardinals.S))
2963 {
2964 needsTransit = true;
2906 neighbor = HaveNeighbor(Cardinals.SW, ref fix); 2965 neighbor = HaveNeighbor(Cardinals.SW, ref fix);
2966 }
2907 else if (m_scene.TestBorderCross(pos2, Cardinals.N)) 2967 else if (m_scene.TestBorderCross(pos2, Cardinals.N))
2968 {
2969 needsTransit = true;
2908 neighbor = HaveNeighbor(Cardinals.NW, ref fix); 2970 neighbor = HaveNeighbor(Cardinals.NW, ref fix);
2971 }
2909 else 2972 else
2973 {
2974 needsTransit = true;
2910 neighbor = HaveNeighbor(Cardinals.W, ref fix); 2975 neighbor = HaveNeighbor(Cardinals.W, ref fix);
2976 }
2911 } 2977 }
2912 else if (m_scene.TestBorderCross(pos2, Cardinals.E)) 2978 else if (m_scene.TestBorderCross(pos2, Cardinals.E))
2913 { 2979 {
2914 if (m_scene.TestBorderCross(pos2, Cardinals.S)) 2980 if (m_scene.TestBorderCross(pos2, Cardinals.S))
2981 {
2982 needsTransit = true;
2915 neighbor = HaveNeighbor(Cardinals.SE, ref fix); 2983 neighbor = HaveNeighbor(Cardinals.SE, ref fix);
2984 }
2916 else if (m_scene.TestBorderCross(pos2, Cardinals.N)) 2985 else if (m_scene.TestBorderCross(pos2, Cardinals.N))
2986 {
2987 needsTransit = true;
2917 neighbor = HaveNeighbor(Cardinals.NE, ref fix); 2988 neighbor = HaveNeighbor(Cardinals.NE, ref fix);
2989 }
2918 else 2990 else
2991 {
2992 needsTransit = true;
2919 neighbor = HaveNeighbor(Cardinals.E, ref fix); 2993 neighbor = HaveNeighbor(Cardinals.E, ref fix);
2994 }
2920 } 2995 }
2921 else if (m_scene.TestBorderCross(pos2, Cardinals.S)) 2996 else if (m_scene.TestBorderCross(pos2, Cardinals.S))
2997 {
2998 needsTransit = true;
2922 neighbor = HaveNeighbor(Cardinals.S, ref fix); 2999 neighbor = HaveNeighbor(Cardinals.S, ref fix);
3000 }
2923 else if (m_scene.TestBorderCross(pos2, Cardinals.N)) 3001 else if (m_scene.TestBorderCross(pos2, Cardinals.N))
3002 {
3003 needsTransit = true;
2924 neighbor = HaveNeighbor(Cardinals.N, ref fix); 3004 neighbor = HaveNeighbor(Cardinals.N, ref fix);
3005 }
3006
2925 3007
2926
2927 // Makes sure avatar does not end up outside region 3008 // Makes sure avatar does not end up outside region
2928 if (neighbor < 0) 3009 if (neighbor <= 0)
2929 AbsolutePosition = new Vector3( 3010 {
2930 AbsolutePosition.X + 3*fix[0], 3011 if (!needsTransit)
2931 AbsolutePosition.Y + 3*fix[1], 3012 {
2932 AbsolutePosition.Z); 3013 if (m_requestedSitTargetUUID == UUID.Zero)
3014 {
3015 Vector3 pos = AbsolutePosition;
3016 if (AbsolutePosition.X < 0)
3017 pos.X += Velocity.X;
3018 else if (AbsolutePosition.X > Constants.RegionSize)
3019 pos.X -= Velocity.X;
3020 if (AbsolutePosition.Y < 0)
3021 pos.Y += Velocity.Y;
3022 else if (AbsolutePosition.Y > Constants.RegionSize)
3023 pos.Y -= Velocity.Y;
3024 AbsolutePosition = pos;
3025 }
3026 }
3027 }
2933 else if (neighbor > 0) 3028 else if (neighbor > 0)
2934 CrossToNewRegion(); 3029 CrossToNewRegion();
2935 } 3030 }
@@ -3087,11 +3182,14 @@ namespace OpenSim.Region.Framework.Scenes
3087 // For now, assign god level 200 to anyone 3182 // For now, assign god level 200 to anyone
3088 // who is granted god powers, but has no god level set. 3183 // who is granted god powers, but has no god level set.
3089 // 3184 //
3090 CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); 3185 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID);
3091 if (profile.UserProfile.GodLevel > 0) 3186 if (account != null)
3092 m_godlevel = profile.UserProfile.GodLevel; 3187 {
3093 else 3188 if (account.UserLevel > 0)
3094 m_godlevel = 200; 3189 m_godlevel = account.UserLevel;
3190 else
3191 m_godlevel = 200;
3192 }
3095 } 3193 }
3096 else 3194 else
3097 { 3195 {
@@ -3157,7 +3255,7 @@ namespace OpenSim.Region.Framework.Scenes
3157 public void CopyTo(AgentData cAgent) 3255 public void CopyTo(AgentData cAgent)
3158 { 3256 {
3159 cAgent.AgentID = UUID; 3257 cAgent.AgentID = UUID;
3160 cAgent.RegionHandle = m_rootRegionHandle; 3258 cAgent.RegionID = Scene.RegionInfo.RegionID;
3161 3259
3162 cAgent.Position = AbsolutePosition; 3260 cAgent.Position = AbsolutePosition;
3163 cAgent.Velocity = m_velocity; 3261 cAgent.Velocity = m_velocity;
@@ -3256,7 +3354,7 @@ namespace OpenSim.Region.Framework.Scenes
3256 3354
3257 public void CopyFrom(AgentData cAgent) 3355 public void CopyFrom(AgentData cAgent)
3258 { 3356 {
3259 m_rootRegionHandle = cAgent.RegionHandle; 3357 m_originRegionID = cAgent.RegionID;
3260 3358
3261 m_callbackURI = cAgent.CallbackURI; 3359 m_callbackURI = cAgent.CallbackURI;
3262 3360
@@ -3400,7 +3498,7 @@ namespace OpenSim.Region.Framework.Scenes
3400 m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; 3498 m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
3401 m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong 3499 m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong
3402 m_physicsActor.SubscribeEvents(500); 3500 m_physicsActor.SubscribeEvents(500);
3403 m_physicsActor.LocalID = LocalId; 3501 m_physicsActor.LocalID = LocalId;
3404 } 3502 }
3405 3503
3406 private void OutOfBoundsCall(Vector3 pos) 3504 private void OutOfBoundsCall(Vector3 pos)
@@ -3503,7 +3601,7 @@ namespace OpenSim.Region.Framework.Scenes
3503 } 3601 }
3504 if (m_health <= 0) 3602 if (m_health <= 0)
3505 m_scene.EventManager.TriggerAvatarKill(killerObj, this); 3603 m_scene.EventManager.TriggerAvatarKill(killerObj, this);
3506 } 3604 }
3507 } 3605 }
3508 3606
3509 public void setHealthWithUpdate(float health) 3607 public void setHealthWithUpdate(float health)
@@ -3636,36 +3734,6 @@ namespace OpenSim.Region.Framework.Scenes
3636 } 3734 }
3637 } 3735 }
3638 3736
3639 public bool CrossAttachmentsIntoNewRegion(ulong regionHandle, bool silent)
3640 {
3641 lock (m_attachments)
3642 {
3643 // Validate
3644 foreach (SceneObjectGroup gobj in m_attachments)
3645 {
3646 if (gobj == null || gobj.IsDeleted)
3647 return false;
3648 }
3649
3650 foreach (SceneObjectGroup gobj in m_attachments)
3651 {
3652 // If the prim group is null then something must have happened to it!
3653 if (gobj != null && gobj.RootPart != null)
3654 {
3655 // Set the parent localID to 0 so it transfers over properly.
3656 gobj.RootPart.SetParentLocalId(0);
3657 gobj.AbsolutePosition = gobj.RootPart.AttachedPos;
3658 gobj.RootPart.IsAttachment = false;
3659 //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
3660 m_log.DebugFormat("[ATTACHMENT]: Sending attachment {0} to region {1}", gobj.UUID, regionHandle);
3661 m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj, silent);
3662 }
3663 }
3664 m_attachments.Clear();
3665
3666 return true;
3667 }
3668 }
3669 3737
3670 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) 3738 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene)
3671 { 3739 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
index 1cff0eb..4ba4fab 100644
--- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
@@ -31,7 +31,6 @@ using OpenMetaverse;
31using log4net; 31using log4net;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Client; 33using OpenSim.Framework.Client;
34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes.Types; 35using OpenSim.Region.Framework.Scenes.Types;
37 36
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index 0ed00de..b50d4ca 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -32,8 +32,7 @@ using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache; 35
36using OpenSim.Region.Communications.Local;
37using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
38using OpenSim.Tests.Common; 37using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock; 38using OpenSim.Tests.Common.Mock;
@@ -95,16 +94,24 @@ namespace OpenSim.Region.Framework.Scenes.Tests
95 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. 94 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
96 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; 95 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
97 sogd.Enabled = false; 96 sogd.Enabled = false;
98 97
99 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); 98 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene);
100 99
101 IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId); 100 try
102 scene.DeRezObject(client, part.LocalId, UUID.Zero, DeRezAction.Delete, UUID.Zero); 101 {
103 102 IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId);
103 scene.DeRezObject(client, part.LocalId, UUID.Zero, DeRezAction.Delete, UUID.Zero);
104 }
105 catch (Exception e)
106 {
107 Console.WriteLine("Exception: " + e.StackTrace);
108 }
104 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 109 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
110
105 Assert.That(retrievedPart, Is.Not.Null); 111 Assert.That(retrievedPart, Is.Not.Null);
106 112
107 sogd.InventoryDeQueueAndDelete(); 113 sogd.InventoryDeQueueAndDelete();
114
108 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); 115 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId);
109 Assert.That(retrievedPart2, Is.Null); 116 Assert.That(retrievedPart2, Is.Null);
110 } 117 }
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
index 709cca2..0b7608d 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
@@ -32,8 +32,7 @@ using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache; 35
36using OpenSim.Region.Communications.Local;
37using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
38using OpenSim.Tests.Common; 37using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock; 38using OpenSim.Tests.Common.Mock;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
index f00dd66..501207e 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
@@ -40,8 +40,8 @@ using OpenSim.Framework;
40using OpenSim.Framework.Communications; 40using OpenSim.Framework.Communications;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion;
44using OpenSim.Region.CoreModules.World.Serialiser; 43using OpenSim.Region.CoreModules.World.Serialiser;
44using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
45using OpenSim.Tests.Common; 45using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock; 46using OpenSim.Tests.Common.Mock;
47using OpenSim.Tests.Common.Setup; 47using OpenSim.Tests.Common.Setup;
@@ -58,7 +58,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
58 public UUID agent1, agent2, agent3; 58 public UUID agent1, agent2, agent3;
59 public static Random random; 59 public static Random random;
60 public ulong region1,region2,region3; 60 public ulong region1,region2,region3;
61 public TestCommunicationsManager cm;
62 public AgentCircuitData acd1; 61 public AgentCircuitData acd1;
63 public SceneObjectGroup sog1, sog2, sog3; 62 public SceneObjectGroup sog1, sog2, sog3;
64 public TestClient testclient; 63 public TestClient testclient;
@@ -66,12 +65,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
66 [TestFixtureSetUp] 65 [TestFixtureSetUp]
67 public void Init() 66 public void Init()
68 { 67 {
69 cm = new TestCommunicationsManager(); 68 scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
70 scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000, cm); 69 scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000);
71 scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000, cm); 70 scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000);
72 scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000, cm);
73 71
74 ISharedRegionModule interregionComms = new RESTInterregionComms(); 72 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
75 interregionComms.Initialise(new IniConfigSource()); 73 interregionComms.Initialise(new IniConfigSource());
76 interregionComms.PostInitialise(); 74 interregionComms.PostInitialise();
77 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); 75 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
@@ -373,7 +371,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
373 371
374 Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); 372 Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross");
375 373
376 Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); 374 //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful");
377 Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); 375 Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted");
378 Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); 376 Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects");
379 } 377 }
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
index 5abbb82..68035ca 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
@@ -141,7 +141,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
141 RegionInfo regionInfo = new RegionInfo(0,0,null,null); 141 RegionInfo regionInfo = new RegionInfo(0,0,null,null);
142 FakeStorageManager storageManager = new FakeStorageManager(); 142 FakeStorageManager storageManager = new FakeStorageManager();
143 143
144 new Scene(regionInfo, null, null, null, storageManager, null, false, false, false, null, null); 144 new Scene(regionInfo, null, null, storageManager, null, false, false, false, null, null);
145 } 145 }
146 } 146 }
147} 147}
diff --git a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
index b46eb8e..cafe48a 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
@@ -34,7 +34,7 @@ using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion; 37using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
38using OpenSim.Tests.Common; 38using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock; 39using OpenSim.Tests.Common.Mock;
40using OpenSim.Tests.Common.Setup; 40using OpenSim.Tests.Common.Setup;
@@ -113,17 +113,16 @@ namespace OpenSim.Region.Framework.Scenes.Tests
113 113
114 UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100"); 114 UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100");
115 UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200"); 115 UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200");
116 TestCommunicationsManager cm = new TestCommunicationsManager();
117 116
118 // shared module 117 // shared module
119 ISharedRegionModule interregionComms = new RESTInterregionComms(); 118 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
120 119
121 120
122 Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010, cm, "grid"); 121 Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010, "grid");
123 SceneSetupHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms); 122 SceneSetupHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms);
124 sceneB.RegisterRegionWithGrid(); 123 sceneB.RegisterRegionWithGrid();
125 124
126 Scene sceneA = SceneSetupHelpers.SetupScene("sceneA", sceneAId, 1000, 1000, cm, "grid"); 125 Scene sceneA = SceneSetupHelpers.SetupScene("sceneA", sceneAId, 1000, 1000, "grid");
127 SceneSetupHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms); 126 SceneSetupHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms);
128 sceneA.RegisterRegionWithGrid(); 127 sceneA.RegisterRegionWithGrid();
129 128
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
index a36c4db..6686264 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
58 TestHelper.InMethod(); 58 TestHelper.InMethod();
59 59
60 UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); 60 UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
61 AssetBase corruptAsset = AssetHelpers.CreateAsset(corruptAssetUuid, "CORRUPT ASSET"); 61 AssetBase corruptAsset = AssetHelpers.CreateAsset(corruptAssetUuid, "CORRUPT ASSET", UUID.Zero);
62 m_assetService.Store(corruptAsset); 62 m_assetService.Store(corruptAsset);
63 63
64 IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>(); 64 IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>();
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index 713ff69..55e407e 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using OpenMetaverse; 28using OpenMetaverse;
29using OpenSim.Region.Framework.Interfaces;
29 30
30namespace OpenSim.Region.Framework.Scenes 31namespace OpenSim.Region.Framework.Scenes
31{ 32{
@@ -35,29 +36,21 @@ namespace OpenSim.Region.Framework.Scenes
35 public Vector3 Scale = Vector3.Zero; 36 public Vector3 Scale = Vector3.Zero;
36 public Quaternion Rotation = Quaternion.Identity; 37 public Quaternion Rotation = Quaternion.Identity;
37 38
38 public UndoState(Vector3 pos, Quaternion rot, Vector3 scale)
39 {
40 Position = pos;
41 Rotation = rot;
42 Scale = scale;
43 }
44
45 public UndoState(SceneObjectPart part) 39 public UndoState(SceneObjectPart part)
46 { 40 {
47 if (part != null) 41 if (part != null)
48 { 42 {
49 if (part.ParentID == 0) 43 if (part.ParentID == 0)
50 { 44 {
51 Position = part.AbsolutePosition; 45 Position = part.ParentGroup.AbsolutePosition;
52 Rotation = part.RotationOffset; 46 Rotation = part.RotationOffset;
53 47 Scale = part.Shape.Scale;
54 } 48 }
55 else 49 else
56 { 50 {
57 Position = part.OffsetPosition; 51 Position = part.OffsetPosition;
58 Rotation = part.RotationOffset; 52 Rotation = part.RotationOffset;
59 Scale = part.Shape.Scale; 53 Scale = part.Shape.Scale;
60
61 } 54 }
62 } 55 }
63 } 56 }
@@ -68,7 +61,7 @@ namespace OpenSim.Region.Framework.Scenes
68 { 61 {
69 if (part.ParentID == 0) 62 if (part.ParentID == 0)
70 { 63 {
71 if (Position == part.AbsolutePosition && Rotation == part.RotationOffset) 64 if (Position == part.ParentGroup.AbsolutePosition && Rotation == part.ParentGroup.Rotation)
72 return true; 65 return true;
73 else 66 else
74 return false; 67 return false;
@@ -93,24 +86,78 @@ namespace OpenSim.Region.Framework.Scenes
93 86
94 if (part.ParentID == 0) 87 if (part.ParentID == 0)
95 { 88 {
96 part.ParentGroup.AbsolutePosition = Position; 89 if (Position != Vector3.Zero)
97 part.UpdateRotation(Rotation); 90 part.ParentGroup.AbsolutePosition = Position;
91 part.RotationOffset = Rotation;
92 if (Scale != Vector3.Zero)
93 part.Resize(Scale);
98 part.ParentGroup.ScheduleGroupForTerseUpdate(); 94 part.ParentGroup.ScheduleGroupForTerseUpdate();
99 } 95 }
100 else 96 else
101 { 97 {
102 part.OffsetPosition = Position; 98 if (Position != Vector3.Zero)
99 part.OffsetPosition = Position;
103 part.UpdateRotation(Rotation); 100 part.UpdateRotation(Rotation);
104 part.Resize(Scale); 101 if (Scale != Vector3.Zero)
102 part.Resize(Scale); part.ScheduleTerseUpdate();
103 }
104 part.Undoing = false;
105
106 }
107 }
108 public void PlayfwdState(SceneObjectPart part)
109 {
110 if (part != null)
111 {
112 part.Undoing = true;
113
114 if (part.ParentID == 0)
115 {
116 if (Position != Vector3.Zero)
117 part.ParentGroup.AbsolutePosition = Position;
118 if (Rotation != Quaternion.Identity)
119 part.UpdateRotation(Rotation);
120 if (Scale != Vector3.Zero)
121 part.Resize(Scale);
122 part.ParentGroup.ScheduleGroupForTerseUpdate();
123 }
124 else
125 {
126 if (Position != Vector3.Zero)
127 part.OffsetPosition = Position;
128 if (Rotation != Quaternion.Identity)
129 part.UpdateRotation(Rotation);
130 if (Scale != Vector3.Zero)
131 part.Resize(Scale);
105 part.ScheduleTerseUpdate(); 132 part.ScheduleTerseUpdate();
106 } 133 }
107 part.Undoing = false; 134 part.Undoing = false;
108 135
109 } 136 }
110 } 137 }
138 }
139 public class LandUndoState
140 {
141 public ITerrainModule m_terrainModule;
142 public ITerrainChannel m_terrainChannel;
143
144 public LandUndoState(ITerrainModule terrainModule, ITerrainChannel terrainChannel)
145 {
146 m_terrainModule = terrainModule;
147 m_terrainChannel = terrainChannel;
148 }
149
150 public bool Compare(ITerrainChannel terrainChannel)
151 {
152 if (m_terrainChannel != terrainChannel)
153 return false;
154 else
155 return false;
156 }
111 157
112 public UndoState() 158 public void PlaybackState()
113 { 159 {
160 m_terrainModule.UndoTerrain(m_terrainChannel);
114 } 161 }
115 } 162 }
116} 163}
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index cc38a30..99e5b84 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -627,6 +627,12 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
627 set { if (!value) Disconnect("IsActive Disconnected?"); } 627 set { if (!value) Disconnect("IsActive Disconnected?"); }
628 } 628 }
629 629
630 public bool IsLoggingOut
631 {
632 get { return false; }
633 set { }
634 }
635
630 public bool SendLogoutPacketWhenClosing 636 public bool SendLogoutPacketWhenClosing
631 { 637 {
632 set { } 638 set { }
@@ -673,7 +679,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
673 public event DeRezObject OnDeRezObject; 679 public event DeRezObject OnDeRezObject;
674 public event Action<IClientAPI> OnRegionHandShakeReply; 680 public event Action<IClientAPI> OnRegionHandShakeReply;
675 public event GenericCall2 OnRequestWearables; 681 public event GenericCall2 OnRequestWearables;
676 public event GenericCall2 OnCompleteMovementToRegion; 682 public event GenericCall1 OnCompleteMovementToRegion;
677 public event UpdateAgent OnAgentUpdate; 683 public event UpdateAgent OnAgentUpdate;
678 public event AgentRequestSit OnAgentRequestSit; 684 public event AgentRequestSit OnAgentRequestSit;
679 public event AgentSit OnAgentSit; 685 public event AgentSit OnAgentSit;
@@ -774,6 +780,8 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
774 public event UUIDNameRequest OnTeleportHomeRequest; 780 public event UUIDNameRequest OnTeleportHomeRequest;
775 public event ScriptAnswer OnScriptAnswer; 781 public event ScriptAnswer OnScriptAnswer;
776 public event AgentSit OnUndo; 782 public event AgentSit OnUndo;
783 public event AgentSit OnRedo;
784 public event LandUndo OnLandUndo;
777 public event ForceReleaseControls OnForceReleaseControls; 785 public event ForceReleaseControls OnForceReleaseControls;
778 public event GodLandStatRequest OnLandStatRequest; 786 public event GodLandStatRequest OnLandStatRequest;
779 public event DetailedEstateDataRequest OnDetailedEstateDataRequest; 787 public event DetailedEstateDataRequest OnDetailedEstateDataRequest;
@@ -905,7 +913,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
905 913
906 if (OnCompleteMovementToRegion != null) 914 if (OnCompleteMovementToRegion != null)
907 { 915 {
908 OnCompleteMovementToRegion(); 916 OnCompleteMovementToRegion(this);
909 } 917 }
910 } 918 }
911 919
@@ -1667,5 +1675,9 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1667 public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals) 1675 public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals)
1668 { 1676 {
1669 } 1677 }
1678
1679 public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
1680 {
1681 }
1670 } 1682 }
1671} 1683}
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs
index b3fa07f..66265d8 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs
@@ -483,12 +483,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
483 case "%host" : 483 case "%host" :
484 result = result.Replace(vvar, rs.Host); 484 result = result.Replace(vvar, rs.Host);
485 break; 485 break;
486 case "%master1" :
487 result = result.Replace(vvar, rs.MA1);
488 break;
489 case "%master2" :
490 result = result.Replace(vvar, rs.MA2);
491 break;
492 case "%locx" : 486 case "%locx" :
493 result = result.Replace(vvar, rs.LocX); 487 result = result.Replace(vvar, rs.LocX);
494 break; 488 break;
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs
index 773507c..53b103e 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs
@@ -57,8 +57,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
57 internal string Host = String.Empty; 57 internal string Host = String.Empty;
58 internal string LocX = String.Empty; 58 internal string LocX = String.Empty;
59 internal string LocY = String.Empty; 59 internal string LocY = String.Empty;
60 internal string MA1 = String.Empty;
61 internal string MA2 = String.Empty;
62 internal string IDK = String.Empty; 60 internal string IDK = String.Empty;
63 61
64 // System values - used only be the IRC classes themselves 62 // System values - used only be the IRC classes themselves
@@ -85,8 +83,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
85 Host = scene.RegionInfo.ExternalHostName; 83 Host = scene.RegionInfo.ExternalHostName;
86 LocX = Convert.ToString(scene.RegionInfo.RegionLocX); 84 LocX = Convert.ToString(scene.RegionInfo.RegionLocX);
87 LocY = Convert.ToString(scene.RegionInfo.RegionLocY); 85 LocY = Convert.ToString(scene.RegionInfo.RegionLocY);
88 MA1 = scene.RegionInfo.MasterAvatarFirstName;
89 MA2 = scene.RegionInfo.MasterAvatarLastName;
90 IDK = Convert.ToString(_idk_++); 86 IDK = Convert.ToString(_idk_++);
91 87
92 // OpenChannel conditionally establishes a connection to the 88 // OpenChannel conditionally establishes a connection to the
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
index b04b076..242bc3f 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
@@ -41,7 +41,7 @@ using log4net;
41using Nini.Config; 41using Nini.Config;
42using Nwc.XmlRpc; 42using Nwc.XmlRpc;
43using OpenSim.Framework; 43using OpenSim.Framework;
44using OpenSim.Framework.Communications.Cache; 44
45using OpenSim.Framework.Capabilities; 45using OpenSim.Framework.Capabilities;
46using OpenSim.Framework.Servers; 46using OpenSim.Framework.Servers;
47using OpenSim.Framework.Servers.HttpServer; 47using OpenSim.Framework.Servers.HttpServer;
@@ -50,7 +50,6 @@ using OpenSim.Region.Framework.Scenes;
50using Caps = OpenSim.Framework.Capabilities.Caps; 50using Caps = OpenSim.Framework.Capabilities.Caps;
51using System.Text.RegularExpressions; 51using System.Text.RegularExpressions;
52 52
53
54namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice 53namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
55{ 54{
56 public class FreeSwitchVoiceModule : IRegionModule, IVoiceModule 55 public class FreeSwitchVoiceModule : IRegionModule, IVoiceModule
@@ -76,7 +75,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
76 // SLVoice client will do a GET on this prefix 75 // SLVoice client will do a GET on this prefix
77 private static string m_freeSwitchAPIPrefix; 76 private static string m_freeSwitchAPIPrefix;
78 77
79 // We need to return some information to SLVoice 78 // We need to return some information to SLVoice
80 // figured those out via curl 79 // figured those out via curl
81 // http://vd1.vivox.com/api2/viv_get_prelogin.php 80 // http://vd1.vivox.com/api2/viv_get_prelogin.php
82 // 81 //
@@ -102,9 +101,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
102 101
103 private readonly Dictionary<string, string> m_UUIDName = new Dictionary<string, string>(); 102 private readonly Dictionary<string, string> m_UUIDName = new Dictionary<string, string>();
104 private Dictionary<string, string> m_ParcelAddress = new Dictionary<string, string>(); 103 private Dictionary<string, string> m_ParcelAddress = new Dictionary<string, string>();
105 104
106 private Scene m_scene; 105 private Scene m_scene;
107 106
108 107
109 private IConfig m_config; 108 private IConfig m_config;
110 109
@@ -136,9 +135,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
136 m_freeSwitchServerUser = m_config.GetString("freeswitch_server_user", String.Empty); 135 m_freeSwitchServerUser = m_config.GetString("freeswitch_server_user", String.Empty);
137 m_freeSwitchServerPass = m_config.GetString("freeswitch_server_pass", String.Empty); 136 m_freeSwitchServerPass = m_config.GetString("freeswitch_server_pass", String.Empty);
138 m_freeSwitchAPIPrefix = m_config.GetString("freeswitch_api_prefix", String.Empty); 137 m_freeSwitchAPIPrefix = m_config.GetString("freeswitch_api_prefix", String.Empty);
139 138
140 // XXX: get IP address of HTTP server. (This can be this OpenSim server or another, or could be a dedicated grid service or may live on the freeswitch server) 139 // XXX: get IP address of HTTP server. (This can be this OpenSim server or another, or could be a dedicated grid service or may live on the freeswitch server)
141 140
142 string serviceIP = m_config.GetString("freeswitch_service_server", String.Empty); 141 string serviceIP = m_config.GetString("freeswitch_service_server", String.Empty);
143 int servicePort = m_config.GetInt("freeswitch_service_port", 80); 142 int servicePort = m_config.GetInt("freeswitch_service_port", 80);
144 IPAddress serviceIPAddress = IPAddress.Parse(serviceIP); 143 IPAddress serviceIPAddress = IPAddress.Parse(serviceIP);
@@ -156,7 +155,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
156 // m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120); 155 // m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120);
157 m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty); 156 m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty);
158 m_freeSwitchContext = m_config.GetString("freeswitch_context", "default"); 157 m_freeSwitchContext = m_config.GetString("freeswitch_context", "default");
159 158
160 if (String.IsNullOrEmpty(m_freeSwitchServerUser) || 159 if (String.IsNullOrEmpty(m_freeSwitchServerUser) ||
161 String.IsNullOrEmpty(m_freeSwitchServerPass) || 160 String.IsNullOrEmpty(m_freeSwitchServerPass) ||
162 String.IsNullOrEmpty(m_freeSwitchRealm) || 161 String.IsNullOrEmpty(m_freeSwitchRealm) ||
@@ -182,9 +181,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
182 { 181 {
183 MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), 182 MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix),
184 FreeSwitchSLVoiceGetPreloginHTTPHandler); 183 FreeSwitchSLVoiceGetPreloginHTTPHandler);
185 184
186 // RestStreamHandler h = new 185 // RestStreamHandler h = new
187 // RestStreamHandler("GET", 186 // RestStreamHandler("GET",
188 // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); 187 // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler);
189 // MainServer.Instance.AddStreamHandler(h); 188 // MainServer.Instance.AddStreamHandler(h);
190 189
@@ -202,13 +201,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
202 MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), 201 MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix),
203 FreeSwitchSLVoiceBuddyHTTPHandler); 202 FreeSwitchSLVoiceBuddyHTTPHandler);
204 } 203 }
205
206
207
208 204
209
210 m_log.InfoFormat("[FreeSwitchVoice] using FreeSwitch server {0}", m_freeSwitchRealm); 205 m_log.InfoFormat("[FreeSwitchVoice] using FreeSwitch server {0}", m_freeSwitchRealm);
211 206
212 m_FreeSwitchDirectory = new FreeSwitchDirectory(); 207 m_FreeSwitchDirectory = new FreeSwitchDirectory();
213 m_FreeSwitchDialplan = new FreeSwitchDialplan(); 208 m_FreeSwitchDialplan = new FreeSwitchDialplan();
214 209
@@ -225,7 +220,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
225 } 220 }
226 } 221 }
227 222
228 if (m_pluginEnabled) 223 if (m_pluginEnabled)
229 { 224 {
230 // we need to capture scene in an anonymous method 225 // we need to capture scene in an anonymous method
231 // here as we need it later in the callbacks 226 // here as we need it later in the callbacks
@@ -233,8 +228,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
233 { 228 {
234 OnRegisterCaps(scene, agentID, caps); 229 OnRegisterCaps(scene, agentID, caps);
235 }; 230 };
236
237
238 231
239 try 232 try
240 { 233 {
@@ -254,16 +247,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
254 m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); 247 m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions.");
255 } 248 }
256 } 249 }
257
258 } 250 }
259 } 251 }
260 252
261 public void PostInitialise() 253 public void PostInitialise()
262 { 254 {
263 if (m_pluginEnabled) 255 if (m_pluginEnabled)
264 { 256 {
265 m_log.Info("[FreeSwitchVoice] registering IVoiceModule with the scene"); 257 m_log.Info("[FreeSwitchVoice] registering IVoiceModule with the scene");
266 258
267 // register the voice interface for this module, so the script engine can call us 259 // register the voice interface for this module, so the script engine can call us
268 m_scene.RegisterModuleInterface<IVoiceModule>(this); 260 m_scene.RegisterModuleInterface<IVoiceModule>(this);
269 } 261 }
@@ -282,15 +274,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
282 { 274 {
283 get { return true; } 275 get { return true; }
284 } 276 }
285 277
286 // <summary> 278 // <summary>
287 // implementation of IVoiceModule, called by osSetParcelSIPAddress script function 279 // implementation of IVoiceModule, called by osSetParcelSIPAddress script function
288 // </summary> 280 // </summary>
289 public void setLandSIPAddress(string SIPAddress,UUID GlobalID) 281 public void setLandSIPAddress(string SIPAddress,UUID GlobalID)
290 { 282 {
291 m_log.DebugFormat("[FreeSwitchVoice]: setLandSIPAddress parcel id {0}: setting sip address {1}", 283 m_log.DebugFormat("[FreeSwitchVoice]: setLandSIPAddress parcel id {0}: setting sip address {1}",
292 GlobalID, SIPAddress); 284 GlobalID, SIPAddress);
293 285
294 lock (m_ParcelAddress) 286 lock (m_ParcelAddress)
295 { 287 {
296 if (m_ParcelAddress.ContainsKey(GlobalID.ToString())) 288 if (m_ParcelAddress.ContainsKey(GlobalID.ToString()))
@@ -303,18 +295,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
303 } 295 }
304 } 296 }
305 } 297 }
306 298
307 // <summary> 299 // <summary>
308 // OnRegisterCaps is invoked via the scene.EventManager 300 // OnRegisterCaps is invoked via the scene.EventManager
309 // everytime OpenSim hands out capabilities to a client 301 // everytime OpenSim hands out capabilities to a client
310 // (login, region crossing). We contribute two capabilities to 302 // (login, region crossing). We contribute two capabilities to
311 // the set of capabilities handed back to the client: 303 // the set of capabilities handed back to the client:
312 // ProvisionVoiceAccountRequest and ParcelVoiceInfoRequest. 304 // ProvisionVoiceAccountRequest and ParcelVoiceInfoRequest.
313 // 305 //
314 // ProvisionVoiceAccountRequest allows the client to obtain 306 // ProvisionVoiceAccountRequest allows the client to obtain
315 // the voice account credentials for the avatar it is 307 // the voice account credentials for the avatar it is
316 // controlling (e.g., user name, password, etc). 308 // controlling (e.g., user name, password, etc).
317 // 309 //
318 // ParcelVoiceInfoRequest is invoked whenever the client 310 // ParcelVoiceInfoRequest is invoked whenever the client
319 // changes from one region or parcel to another. 311 // changes from one region or parcel to another.
320 // 312 //
@@ -371,7 +363,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
371 { 363 {
372 System.Threading.Thread.Sleep(2000); 364 System.Threading.Thread.Sleep(2000);
373 avatar = scene.GetScenePresence(agentID); 365 avatar = scene.GetScenePresence(agentID);
374 366
375 if (avatar == null) 367 if (avatar == null)
376 return "<llsd>undef</llsd>"; 368 return "<llsd>undef</llsd>";
377 } 369 }
@@ -407,8 +399,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
407 // new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, "http://etsvc02.hursley.ibm.com/api"); 399 // new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, "http://etsvc02.hursley.ibm.com/api");
408 LLSDVoiceAccountResponse voiceAccountResponse = 400 LLSDVoiceAccountResponse voiceAccountResponse =
409 new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, 401 new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm,
410 String.Format("http://{0}:{1}{2}/", m_openSimWellKnownHTTPAddress, 402 String.Format("http://{0}:{1}{2}/", m_openSimWellKnownHTTPAddress,
411 m_freeSwitchServicePort, m_freeSwitchAPIPrefix)); 403 m_freeSwitchServicePort, m_freeSwitchAPIPrefix));
412 404
413 string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); 405 string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse);
414 406
@@ -442,7 +434,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
442 string avatarName = avatar.Name; 434 string avatarName = avatar.Name;
443 435
444 // - check whether we have a region channel in our cache 436 // - check whether we have a region channel in our cache
445 // - if not: 437 // - if not:
446 // create it and cache it 438 // create it and cache it
447 // - send it to the client 439 // - send it to the client
448 // - send channel_uri: as "sip:regionID@m_sipDomain" 440 // - send channel_uri: as "sip:regionID@m_sipDomain"
@@ -451,12 +443,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
451 LLSDParcelVoiceInfoResponse parcelVoiceInfo; 443 LLSDParcelVoiceInfoResponse parcelVoiceInfo;
452 string channelUri; 444 string channelUri;
453 445
454 if (null == scene.LandChannel) 446 if (null == scene.LandChannel)
455 throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available", 447 throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available",
456 scene.RegionInfo.RegionName, avatarName)); 448 scene.RegionInfo.RegionName, avatarName));
457 449
458
459
460 // get channel_uri: check first whether estate 450 // get channel_uri: check first whether estate
461 // settings allow voice, then whether parcel allows 451 // settings allow voice, then whether parcel allows
462 // voice, if all do retrieve or obtain the parcel 452 // voice, if all do retrieve or obtain the parcel
@@ -493,22 +483,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
493 parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds); 483 parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds);
494 string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); 484 string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo);
495 485
496 m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}", 486 m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}",
497 scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r); 487 scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r);
498 return r; 488 return r;
499 } 489 }
500 catch (Exception e) 490 catch (Exception e)
501 { 491 {
502 m_log.ErrorFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2}, retry later", 492 m_log.ErrorFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2}, retry later",
503 scene.RegionInfo.RegionName, avatarName, e.Message); 493 scene.RegionInfo.RegionName, avatarName, e.Message);
504 m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed", 494 m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed",
505 scene.RegionInfo.RegionName, avatarName, e.ToString()); 495 scene.RegionInfo.RegionName, avatarName, e.ToString());
506 496
507 return "<llsd>undef</llsd>"; 497 return "<llsd>undef</llsd>";
508 } 498 }
509 } 499 }
510 500
511
512 /// <summary> 501 /// <summary>
513 /// Callback for a client request for ChatSessionRequest 502 /// Callback for a client request for ChatSessionRequest
514 /// </summary> 503 /// </summary>
@@ -550,7 +539,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
550 string fwdresponsestr = ""; 539 string fwdresponsestr = "";
551 int fwdresponsecode = 200; 540 int fwdresponsecode = 200;
552 string fwdresponsecontenttype = "text/xml"; 541 string fwdresponsecontenttype = "text/xml";
553
554 542
555 HttpWebRequest forwardreq = (HttpWebRequest)WebRequest.Create(forwardaddress); 543 HttpWebRequest forwardreq = (HttpWebRequest)WebRequest.Create(forwardaddress);
556 forwardreq.Method = method; 544 forwardreq.Method = method;
@@ -577,7 +565,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
577 response["content_type"] = fwdresponsecontenttype; 565 response["content_type"] = fwdresponsecontenttype;
578 response["str_response_string"] = fwdresponsestr; 566 response["str_response_string"] = fwdresponsestr;
579 response["int_response_code"] = fwdresponsecode; 567 response["int_response_code"] = fwdresponsecode;
580 568
581 return response; 569 return response;
582 } 570 }
583 571
@@ -585,11 +573,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
585 public Hashtable FreeSwitchSLVoiceGetPreloginHTTPHandler(Hashtable request) 573 public Hashtable FreeSwitchSLVoiceGetPreloginHTTPHandler(Hashtable request)
586 { 574 {
587 m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler called"); 575 m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler called");
588 576
589 Hashtable response = new Hashtable(); 577 Hashtable response = new Hashtable();
590 response["content_type"] = "text/xml"; 578 response["content_type"] = "text/xml";
591 response["keepalive"] = false; 579 response["keepalive"] = false;
592 580
593 response["str_response_string"] = String.Format( 581 response["str_response_string"] = String.Format(
594 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" + 582 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
595 "<VCConfiguration>\r\n"+ 583 "<VCConfiguration>\r\n"+
@@ -607,9 +595,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
607 "</VCConfiguration>", 595 "</VCConfiguration>",
608 m_freeSwitchRealm, m_freeSwitchSIPProxy, m_freeSwitchAttemptUseSTUN, 596 m_freeSwitchRealm, m_freeSwitchSIPProxy, m_freeSwitchAttemptUseSTUN,
609 m_freeSwitchEchoServer, m_freeSwitchEchoPort, 597 m_freeSwitchEchoServer, m_freeSwitchEchoPort,
610 m_freeSwitchDefaultWellKnownIP, m_freeSwitchDefaultTimeout, 598 m_freeSwitchDefaultWellKnownIP, m_freeSwitchDefaultTimeout,
611 m_freeSwitchUrlResetPassword, ""); 599 m_freeSwitchUrlResetPassword, "");
612 600
613 response["int_response_code"] = 200; 601 response["int_response_code"] = 200;
614 602
615 m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler return {0}",response["str_response_string"]); 603 m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler return {0}",response["str_response_string"]);
@@ -624,7 +612,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
624 response["content-type"] = "text/xml"; 612 response["content-type"] = "text/xml";
625 613
626 Hashtable requestBody = parseRequestBody((string)request["body"]); 614 Hashtable requestBody = parseRequestBody((string)request["body"]);
627 615
628 if (!requestBody.ContainsKey("auth_token")) 616 if (!requestBody.ContainsKey("auth_token"))
629 return response; 617 return response;
630 618
@@ -632,7 +620,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
632 //string[] auth_tokenvals = auth_token.Split(':'); 620 //string[] auth_tokenvals = auth_token.Split(':');
633 //string username = auth_tokenvals[0]; 621 //string username = auth_tokenvals[0];
634 int strcount = 0; 622 int strcount = 0;
635 623
636 string[] ids = new string[strcount]; 624 string[] ids = new string[strcount];
637 625
638 int iter = -1; 626 int iter = -1;
@@ -648,7 +636,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
648 } 636 }
649 StringBuilder resp = new StringBuilder(); 637 StringBuilder resp = new StringBuilder();
650 resp.Append("<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?><response xmlns=\"http://www.vivox.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation= \"/xsd/buddy_list.xsd\">"); 638 resp.Append("<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?><response xmlns=\"http://www.vivox.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation= \"/xsd/buddy_list.xsd\">");
651 639
652 resp.Append(string.Format(@"<level0> 640 resp.Append(string.Format(@"<level0>
653 <status>OK</status> 641 <status>OK</status>
654 <cookie_name>lib_session</cookie_name> 642 <cookie_name>lib_session</cookie_name>
@@ -678,7 +666,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
678 <b2g_group_id></b2g_group_id> 666 <b2g_group_id></b2g_group_id>
679 </level3>", ids[i],i,m_freeSwitchRealm,dt)); 667 </level3>", ids[i],i,m_freeSwitchRealm,dt));
680 } 668 }
681 669
682 resp.Append("</buddies><groups></groups></body></level0></response>"); 670 resp.Append("</buddies><groups></groups></body></level0></response>");
683 671
684 response["str_response_string"] = resp.ToString(); 672 response["str_response_string"] = resp.ToString();
@@ -694,7 +682,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
694 string requestbody = (string)request["body"]; 682 string requestbody = (string)request["body"];
695 string uri = (string)request["uri"]; 683 string uri = (string)request["uri"];
696 string contenttype = (string)request["content-type"]; 684 string contenttype = (string)request["content-type"];
697 685
698 Hashtable requestBody = parseRequestBody((string)request["body"]); 686 Hashtable requestBody = parseRequestBody((string)request["body"]);
699 687
700 //string pwd = (string) requestBody["pwd"]; 688 //string pwd = (string) requestBody["pwd"];
@@ -712,7 +700,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
712 pos++; 700 pos++;
713 if (s == userid) 701 if (s == userid)
714 break; 702 break;
715
716 } 703 }
717 } 704 }
718 } 705 }
@@ -735,7 +722,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
735 </body> 722 </body>
736 </level0> 723 </level0>
737 </response>", userid, pos, avatarName); 724 </response>", userid, pos, avatarName);
738 725
739 response["int_response_code"] = 200; 726 response["int_response_code"] = 200;
740 return response; 727 return response;
741 /* 728 /*
@@ -752,13 +739,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
752 public Hashtable FreeSwitchConfigHTTPHandler(Hashtable request) 739 public Hashtable FreeSwitchConfigHTTPHandler(Hashtable request)
753 { 740 {
754 m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler called with {0}", (string)request["body"]); 741 m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler called with {0}", (string)request["body"]);
755 742
756 Hashtable response = new Hashtable(); 743 Hashtable response = new Hashtable();
757 response["str_response_string"] = string.Empty; 744 response["str_response_string"] = string.Empty;
758 // all the params come as NVPs in the request body 745 // all the params come as NVPs in the request body
759 Hashtable requestBody = parseRequestBody((string) request["body"]); 746 Hashtable requestBody = parseRequestBody((string) request["body"]);
760 747
761 // is this a dialplan or directory request 748 // is this a dialplan or directory request
762 string section = (string) requestBody["section"]; 749 string section = (string) requestBody["section"];
763 750
764 if (section == "directory") 751 if (section == "directory")
@@ -767,40 +754,39 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
767 response = m_FreeSwitchDialplan.HandleDialplanRequest(m_freeSwitchContext, m_freeSwitchRealm, requestBody); 754 response = m_FreeSwitchDialplan.HandleDialplanRequest(m_freeSwitchContext, m_freeSwitchRealm, requestBody);
768 else 755 else
769 m_log.WarnFormat("[FreeSwitchVoice]: section was {0}", section); 756 m_log.WarnFormat("[FreeSwitchVoice]: section was {0}", section);
770 757
771 // XXX: re-generate dialplan: 758 // XXX: re-generate dialplan:
772 // - conf == region UUID 759 // - conf == region UUID
773 // - conf number = region port 760 // - conf number = region port
774 // -> TODO Initialise(): keep track of regions via events 761 // -> TODO Initialise(): keep track of regions via events
775 // re-generate accounts for all avatars 762 // re-generate accounts for all avatars
776 // -> TODO Initialise(): keep track of avatars via events 763 // -> TODO Initialise(): keep track of avatars via events
777 Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); 764 Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline);
778 765
779 m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler return {0}",normalizeEndLines.Replace(((string)response["str_response_string"]), "")); 766 m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler return {0}",normalizeEndLines.Replace(((string)response["str_response_string"]), ""));
780 return response; 767 return response;
781 } 768 }
782 769
783 public Hashtable parseRequestBody(string body) 770 public Hashtable parseRequestBody(string body)
784 { 771 {
785 Hashtable bodyParams = new Hashtable(); 772 Hashtable bodyParams = new Hashtable();
786 // split string 773 // split string
787 string [] nvps = body.Split(new Char [] {'&'}); 774 string [] nvps = body.Split(new Char [] {'&'});
788 775
789 foreach (string s in nvps) { 776 foreach (string s in nvps)
790 777 {
791 if (s.Trim() != "") 778 if (s.Trim() != "")
792 { 779 {
793 string [] nvp = s.Split(new Char [] {'='}); 780 string [] nvp = s.Split(new Char [] {'='});
794 bodyParams.Add(HttpUtility.UrlDecode(nvp[0]), HttpUtility.UrlDecode(nvp[1])); 781 bodyParams.Add(HttpUtility.UrlDecode(nvp[0]), HttpUtility.UrlDecode(nvp[1]));
795 } 782 }
796 } 783 }
797 784
798 return bodyParams; 785 return bodyParams;
799 } 786 }
800 787
801 private string ChannelUri(Scene scene, LandData land) 788 private string ChannelUri(Scene scene, LandData land)
802 { 789 {
803
804 string channelUri = null; 790 string channelUri = null;
805 791
806 string landUUID; 792 string landUUID;
@@ -808,12 +794,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
808 794
809 // Create parcel voice channel. If no parcel exists, then the voice channel ID is the same 795 // Create parcel voice channel. If no parcel exists, then the voice channel ID is the same
810 // as the directory ID. Otherwise, it reflects the parcel's ID. 796 // as the directory ID. Otherwise, it reflects the parcel's ID.
811 797
812 lock (m_ParcelAddress) 798 lock (m_ParcelAddress)
813 { 799 {
814 if (m_ParcelAddress.ContainsKey(land.GlobalID.ToString())) 800 if (m_ParcelAddress.ContainsKey(land.GlobalID.ToString()))
815 { 801 {
816 m_log.DebugFormat("[FreeSwitchVoice]: parcel id {0}: using sip address {1}", 802 m_log.DebugFormat("[FreeSwitchVoice]: parcel id {0}: using sip address {1}",
817 land.GlobalID, m_ParcelAddress[land.GlobalID.ToString()]); 803 land.GlobalID, m_ParcelAddress[land.GlobalID.ToString()]);
818 return m_ParcelAddress[land.GlobalID.ToString()]; 804 return m_ParcelAddress[land.GlobalID.ToString()];
819 } 805 }
@@ -823,22 +809,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
823 { 809 {
824 landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, land.Name); 810 landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, land.Name);
825 landUUID = land.GlobalID.ToString(); 811 landUUID = land.GlobalID.ToString();
826 m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", 812 m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}",
827 landName, land.LocalID, landUUID); 813 landName, land.LocalID, landUUID);
828 } 814 }
829 else 815 else
830 { 816 {
831 landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, scene.RegionInfo.RegionName); 817 landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, scene.RegionInfo.RegionName);
832 landUUID = scene.RegionInfo.RegionID.ToString(); 818 landUUID = scene.RegionInfo.RegionID.ToString();
833 m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", 819 m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}",
834 landName, land.LocalID, landUUID); 820 landName, land.LocalID, landUUID);
835 } 821 }
836 System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); 822 System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
837 823
838 // slvoice handles the sip address differently if it begins with confctl, hiding it from the user in the friends list. however it also disables 824 // slvoice handles the sip address differently if it begins with confctl, hiding it from the user in the friends list. however it also disables
839 // the personal speech indicators as well unless some siren14-3d codec magic happens. we dont have siren143d so we'll settle for the personal speech indicator. 825 // the personal speech indicators as well unless some siren14-3d codec magic happens. we dont have siren143d so we'll settle for the personal speech indicator.
840 channelUri = String.Format("sip:conf-{0}@{1}", "x" + Convert.ToBase64String(encoding.GetBytes(landUUID)), m_freeSwitchRealm); 826 channelUri = String.Format("sip:conf-{0}@{1}", "x" + Convert.ToBase64String(encoding.GetBytes(landUUID)), m_freeSwitchRealm);
841 827
842 lock (m_ParcelAddress) 828 lock (m_ParcelAddress)
843 { 829 {
844 if (!m_ParcelAddress.ContainsKey(land.GlobalID.ToString())) 830 if (!m_ParcelAddress.ContainsKey(land.GlobalID.ToString()))
@@ -849,14 +835,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
849 835
850 return channelUri; 836 return channelUri;
851 } 837 }
852 838
853 private static bool CustomCertificateValidation(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error) 839 private static bool CustomCertificateValidation(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error)
854 { 840 {
855
856 return true; 841 return true;
857
858 } 842 }
859 } 843 }
844
860 public class MonoCert : ICertificatePolicy 845 public class MonoCert : ICertificatePolicy
861 { 846 {
862 #region ICertificatePolicy Members 847 #region ICertificatePolicy Members
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
index cb76200..34d0e24 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
@@ -39,7 +39,7 @@ using log4net;
39using Nini.Config; 39using Nini.Config;
40using Nwc.XmlRpc; 40using Nwc.XmlRpc;
41using OpenSim.Framework; 41using OpenSim.Framework;
42using OpenSim.Framework.Communications.Cache; 42
43using OpenSim.Framework.Capabilities; 43using OpenSim.Framework.Capabilities;
44using OpenSim.Framework.Servers; 44using OpenSim.Framework.Servers;
45using OpenSim.Framework.Servers.HttpServer; 45using OpenSim.Framework.Servers.HttpServer;
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index 8d32e66..68e6497 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -43,6 +43,8 @@ using OpenSim.Region.CoreModules.Framework.EventQueue;
43using OpenSim.Region.Framework.Interfaces; 43using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.Framework.Scenes; 44using OpenSim.Region.Framework.Scenes;
45 45
46using OpenSim.Services.Interfaces;
47
46using Caps = OpenSim.Framework.Capabilities.Caps; 48using Caps = OpenSim.Framework.Capabilities.Caps;
47using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags; 49using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags;
48 50
@@ -507,10 +509,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
507 { 509 {
508 if (m_debugEnabled) 510 if (m_debugEnabled)
509 { 511 {
510 UserProfileData targetUserProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(member.AgentID); 512 UserAccount targetUser = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, member.AgentID);
511 if (targetUserProfile != null) 513 if (targetUser != null)
512 { 514 {
513 m_log.DebugFormat("[GROUPS]: Prepping group notice {0} for agent: {1} who Accepts Notices ({2})", NoticeID, targetUserProfile.Name, member.AcceptNotices); 515 m_log.DebugFormat("[GROUPS]: Prepping group notice {0} for agent: {1} who Accepts Notices ({2})", NoticeID, targetUser.FirstName + " " + targetUser.LastName, member.AcceptNotices);
514 } 516 }
515 else 517 else
516 { 518 {
@@ -990,9 +992,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
990 remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true); 992 remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true);
991 993
992 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, groupID, null); 994 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, groupID, null);
993 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(ejecteeID); 995 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, ejecteeID);
994 996 if ((groupInfo == null) || (account == null))
995 if ((groupInfo == null) || (userProfile == null))
996 { 997 {
997 return; 998 return;
998 } 999 }
@@ -1032,9 +1033,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1032 msg.toAgentID = remoteClient.AgentId.Guid; 1033 msg.toAgentID = remoteClient.AgentId.Guid;
1033 msg.timestamp = 0; 1034 msg.timestamp = 0;
1034 msg.fromAgentName = remoteClient.Name; 1035 msg.fromAgentName = remoteClient.Name;
1035 if (userProfile != null) 1036 if (account != null)
1036 { 1037 {
1037 msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", remoteClient.Name, groupInfo.GroupName, userProfile.Name); 1038 msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", remoteClient.Name, groupInfo.GroupName, account.FirstName + " " + account.LastName);
1038 } 1039 }
1039 else 1040 else
1040 { 1041 {
@@ -1147,8 +1148,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1147 info.RequestID.AgentID = client.AgentId; 1148 info.RequestID.AgentID = client.AgentId;
1148 info.RequestID.SessionID = client.SessionId; 1149 info.RequestID.SessionID = client.SessionId;
1149 1150
1150 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(client.AgentId); 1151 //UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(client.AgentId);
1151 if (userProfile == null) 1152 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, client.AgentId);
1153 if (account == null)
1152 { 1154 {
1153 // This should be impossible. If I've been passed a reference to a client 1155 // This should be impossible. If I've been passed a reference to a client
1154 // that client should be registered with the UserService. So something 1156 // that client should be registered with the UserService. So something
@@ -1157,19 +1159,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1157 m_log.WarnFormat("[GROUPS]: Could not find a user profile for {0} / {1}", client.Name, client.AgentId); 1159 m_log.WarnFormat("[GROUPS]: Could not find a user profile for {0} / {1}", client.Name, client.AgentId);
1158 1160
1159 // Default to local user service and hope for the best? 1161 // Default to local user service and hope for the best?
1160 info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL; 1162 // REFACTORING PROBLEM
1163 //info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
1161 1164
1162 } 1165 }
1163 else if (userProfile is ForeignUserProfileData)
1164 {
1165 // They aren't from around here
1166 ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
1167 info.RequestID.UserServiceURL = fupd.UserServerURI;
1168 }
1169 else 1166 else
1170 { 1167 {
1168 string domain = string.Empty; //m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
1169 if (account.ServiceURLs["HomeURI"] != null)
1170 domain = account.ServiceURLs["HomeURI"].ToString();
1171 // They're a local user, use this: 1171 // They're a local user, use this:
1172 info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL; 1172 info.RequestID.UserServiceURL = domain;
1173 } 1173 }
1174 1174
1175 m_clientRequestIDInfo.Add(client.AgentId, info); 1175 m_clientRequestIDInfo.Add(client.AgentId, info);
@@ -1342,12 +1342,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1342 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 1342 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1343 1343
1344 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff 1344 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff
1345 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(dataForAgentID); 1345 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, dataForAgentID);
1346 string firstname, lastname; 1346 string firstname, lastname;
1347 if (userProfile != null) 1347 if (account != null)
1348 { 1348 {
1349 firstname = userProfile.FirstName; 1349 firstname = account.FirstName;
1350 lastname = userProfile.SurName; 1350 lastname = account.LastName;
1351 } 1351 }
1352 else 1352 else
1353 { 1353 {
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs
index 8ea7ad3..a0dc38b 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs
@@ -49,7 +49,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
49 49
50 public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary) 50 public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary)
51 { 51 {
52 AssetBase asset = new AssetBase(UUID.Random(), "MRMDynamicImage", (sbyte)AssetType.Texture); 52 AssetBase asset = new AssetBase(UUID.Random(), "MRMDynamicImage", (sbyte)AssetType.Texture, m_scene.RegionInfo.RegionID.ToString());
53 asset.Data = OpenJPEG.EncodeFromImage(data, lossless); 53 asset.Data = OpenJPEG.EncodeFromImage(data, lossless);
54 asset.Description = "MRM Image"; 54 asset.Description = "MRM Image";
55 asset.Local = false; 55 asset.Local = false;
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs
index 03c1e95..3d49732 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs
@@ -34,6 +34,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
34{ 34{
35 public interface IAvatar : IEntity 35 public interface IAvatar : IEntity
36 { 36 {
37
38 bool IsChildAgent { get; }
39
37 //// <value> 40 //// <value>
38 /// Array of worn attachments, empty but not null, if no attachments are worn 41 /// Array of worn attachments, empty but not null, if no attachments are worn
39 /// </value> 42 /// </value>
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
index f2adcb7..2ddc31b 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
@@ -212,8 +212,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
212 if (script.StartsWith("//MRM:C#")) 212 if (script.StartsWith("//MRM:C#"))
213 { 213 {
214 if (m_config.GetBoolean("OwnerOnly", true)) 214 if (m_config.GetBoolean("OwnerOnly", true))
215 if (m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.MasterAvatarAssignedUUID 215 if (m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.EstateSettings.EstateOwner
216 || m_scene.GetSceneObjectPart(localID).CreatorID != m_scene.RegionInfo.MasterAvatarAssignedUUID) 216 || m_scene.GetSceneObjectPart(localID).CreatorID != m_scene.RegionInfo.EstateSettings.EstateOwner)
217 return; 217 return;
218 218
219 script = ConvertMRMKeywords(script); 219 script = ConvertMRMKeywords(script);
@@ -280,7 +280,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
280 public void GetGlobalEnvironment(uint localID, out IWorld world, out IHost host) 280 public void GetGlobalEnvironment(uint localID, out IWorld world, out IHost host)
281 { 281 {
282 // UUID should be changed to object owner. 282 // UUID should be changed to object owner.
283 UUID owner = m_scene.RegionInfo.MasterAvatarAssignedUUID; 283 UUID owner = m_scene.RegionInfo.EstateSettings.EstateOwner;
284 SEUser securityUser = new SEUser(owner, "Name Unassigned"); 284 SEUser securityUser = new SEUser(owner, "Name Unassigned");
285 SecurityCredential creds = new SecurityCredential(securityUser, m_scene); 285 SecurityCredential creds = new SecurityCredential(securityUser, m_scene);
286 286
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
index 31f28e0..5bfe4be 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
@@ -767,7 +767,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
767 if (!CanEdit()) 767 if (!CanEdit())
768 return; 768 return;
769 769
770 GetSOP().SendSound(asset.ToString(), volume, true, 0); 770 GetSOP().SendSound(asset.ToString(), volume, true, 0, 0, false, false);
771 } 771 }
772 772
773 #endregion 773 #endregion
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs
index 4427426..0786bd9 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs
@@ -70,6 +70,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
70 set { GetSP().TeleportWithMomentum(value); } 70 set { GetSP().TeleportWithMomentum(value); }
71 } 71 }
72 72
73 public bool IsChildAgent
74 {
75 get { return GetSP().IsChildAgent; }
76 }
77
73 #region IAvatar implementation 78 #region IAvatar implementation
74 public IAvatarAttachment[] Attachments 79 public IAvatarAttachment[] Attachments
75 { 80 {
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs
index c7cd37b..45bb005 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs
@@ -231,7 +231,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
231 if (soundModule != null) 231 if (soundModule != null)
232 { 232 {
233 soundModule.TriggerSound(audio, UUID.Zero, UUID.Zero, UUID.Zero, volume, position, 233 soundModule.TriggerSound(audio, UUID.Zero, UUID.Zero, UUID.Zero, volume, position,
234 m_internalScene.RegionInfo.RegionHandle); 234 m_internalScene.RegionInfo.RegionHandle, 0);
235 } 235 }
236 } 236 }
237 237
@@ -241,7 +241,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
241 if (soundModule != null) 241 if (soundModule != null)
242 { 242 {
243 soundModule.TriggerSound(audio, UUID.Zero, UUID.Zero, UUID.Zero, 1.0, position, 243 soundModule.TriggerSound(audio, UUID.Zero, UUID.Zero, UUID.Zero, 1.0, position,
244 m_internalScene.RegionInfo.RegionHandle); 244 m_internalScene.RegionInfo.RegionHandle, 0);
245 } 245 }
246 } 246 }
247 247
diff --git a/OpenSim/Region/OptionalModules/SvnSerialiser/SvnBackupModule.cs b/OpenSim/Region/OptionalModules/SvnSerialiser/SvnBackupModule.cs
index 3490a8b..ccdea14 100644
--- a/OpenSim/Region/OptionalModules/SvnSerialiser/SvnBackupModule.cs
+++ b/OpenSim/Region/OptionalModules/SvnSerialiser/SvnBackupModule.cs
@@ -121,19 +121,19 @@ namespace OpenSim.Region.Modules.SvnSerialiser
121 { 121 {
122 serialiser.LoadPrimsFromXml2( 122 serialiser.LoadPrimsFromXml2(
123 scene, 123 scene,
124 m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID 124 m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID
125 + Slash.DirectorySeparatorChar + "objects.xml"); 125 + Slash.DirectorySeparatorChar + "objects.xml");
126 126
127 scene.RequestModuleInterface<ITerrainModule>().LoadFromFile( 127 scene.RequestModuleInterface<ITerrainModule>().LoadFromFile(
128 m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID 128 m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID
129 + Slash.DirectorySeparatorChar + "heightmap.r32"); 129 + Slash.DirectorySeparatorChar + "heightmap.r32");
130 130
131 m_log.Info("[SVNBACKUP]: Region load successful (" + scene.RegionInfo.RegionName + ")."); 131 m_log.Info("[SVNBACKUP]: Region load successful (" + scene.RegionInfo.RegionName + ").");
132 } 132 }
133 else 133 else
134 { 134 {
135 m_log.ErrorFormat( 135 m_log.ErrorFormat(
136 "[SVNBACKUP]: Region load of {0} failed - no serialisation module available", 136 "[SVNBACKUP]: Region load of {0} failed - no serialisation module available",
137 scene.RegionInfo.RegionName); 137 scene.RegionInfo.RegionName);
138 } 138 }
139 } 139 }
diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
index 3160cd3..b9a75cc 100644
--- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
+++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
@@ -36,10 +36,11 @@ using Nwc.XmlRpc;
36using Mono.Addins; 36using Mono.Addins;
37using OpenMetaverse; 37using OpenMetaverse;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Communications.Cache; 39
40using OpenSim.Framework.Servers.HttpServer; 40using OpenSim.Framework.Servers.HttpServer;
41using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Services.Interfaces;
43 44
44namespace OpenSim.Region.OptionalModules.World.MoneyModule 45namespace OpenSim.Region.OptionalModules.World.MoneyModule
45{ 46{
@@ -65,7 +66,6 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
65 // private UUID EconomyBaseAccount = UUID.Zero; 66 // private UUID EconomyBaseAccount = UUID.Zero;
66 67
67 private float EnergyEfficiency = 0f; 68 private float EnergyEfficiency = 0f;
68 private bool gridmode = false;
69 // private ObjectPaid handerOnObjectPaid; 69 // private ObjectPaid handerOnObjectPaid;
70 private bool m_enabled = true; 70 private bool m_enabled = true;
71 private bool m_sellEnabled = false; 71 private bool m_sellEnabled = false;
@@ -242,7 +242,6 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
242 { 242 {
243 if (config == "Startup" && startupConfig != null) 243 if (config == "Startup" && startupConfig != null)
244 { 244 {
245 gridmode = startupConfig.GetBoolean("gridmode", false);
246 m_enabled = (startupConfig.GetString("economymodule", "BetaGridLikeMoneyModule") == "BetaGridLikeMoneyModule"); 245 m_enabled = (startupConfig.GetString("economymodule", "BetaGridLikeMoneyModule") == "BetaGridLikeMoneyModule");
247 } 246 }
248 247
@@ -292,18 +291,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
292 291
293 private void GetClientFunds(IClientAPI client) 292 private void GetClientFunds(IClientAPI client)
294 { 293 {
295 // Here we check if we're in grid mode 294 CheckExistAndRefreshFunds(client.AgentId);
296 // I imagine that the 'check balance'
297 // function for the client should be here or shortly after
298
299 if (gridmode)
300 {
301 CheckExistAndRefreshFunds(client.AgentId);
302 }
303 else
304 {
305 CheckExistAndRefreshFunds(client.AgentId);
306 }
307 295
308 } 296 }
309 297
@@ -398,10 +386,10 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
398 { 386 {
399 // try avatar username surname 387 // try avatar username surname
400 Scene scene = GetRandomScene(); 388 Scene scene = GetRandomScene();
401 CachedUserInfo profile = scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); 389 UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, agentID);
402 if (profile != null && profile.UserProfile != null) 390 if (account != null)
403 { 391 {
404 string avatarname = profile.UserProfile.FirstName + " " + profile.UserProfile.SurName; 392 string avatarname = account.FirstName + " " + account.LastName;
405 return avatarname; 393 return avatarname;
406 } 394 }
407 else 395 else
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 3135cdc..15473d8 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -189,7 +189,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
189 public event DeRezObject OnDeRezObject; 189 public event DeRezObject OnDeRezObject;
190 public event Action<IClientAPI> OnRegionHandShakeReply; 190 public event Action<IClientAPI> OnRegionHandShakeReply;
191 public event GenericCall2 OnRequestWearables; 191 public event GenericCall2 OnRequestWearables;
192 public event GenericCall2 OnCompleteMovementToRegion; 192 public event GenericCall1 OnCompleteMovementToRegion;
193 public event UpdateAgent OnAgentUpdate; 193 public event UpdateAgent OnAgentUpdate;
194 public event AgentRequestSit OnAgentRequestSit; 194 public event AgentRequestSit OnAgentRequestSit;
195 public event AgentSit OnAgentSit; 195 public event AgentSit OnAgentSit;
@@ -298,6 +298,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
298 public event ObjectBuy OnObjectBuy; 298 public event ObjectBuy OnObjectBuy;
299 public event BuyObjectInventory OnBuyObjectInventory; 299 public event BuyObjectInventory OnBuyObjectInventory;
300 public event AgentSit OnUndo; 300 public event AgentSit OnUndo;
301 public event AgentSit OnRedo;
302 public event LandUndo OnLandUndo;
301 303
302 public event ForceReleaseControls OnForceReleaseControls; 304 public event ForceReleaseControls OnForceReleaseControls;
303 public event GodLandStatRequest OnLandStatRequest; 305 public event GodLandStatRequest OnLandStatRequest;
@@ -455,6 +457,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
455 set { } 457 set { }
456 } 458 }
457 459
460 public bool IsLoggingOut
461 {
462 get { return false; }
463 set { }
464 }
458 public UUID ActiveGroupId 465 public UUID ActiveGroupId
459 { 466 {
460 get { return UUID.Zero; } 467 get { return UUID.Zero; }
@@ -737,7 +744,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
737 744
738 if (OnCompleteMovementToRegion != null) 745 if (OnCompleteMovementToRegion != null)
739 { 746 {
740 OnCompleteMovementToRegion(); 747 OnCompleteMovementToRegion(this);
741 } 748 }
742 } 749 }
743 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) 750 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
@@ -1148,5 +1155,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
1148 public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals) 1155 public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals)
1149 { 1156 {
1150 } 1157 }
1158
1159 public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
1160 {
1161 }
1151 } 1162 }
1152} 1163}
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index ac39a53..6e742f1 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -34,6 +34,7 @@ using OpenSim.Region.Framework.Scenes;
34using OpenSim.Region.CoreModules.Avatar.NPC; 34using OpenSim.Region.CoreModules.Avatar.NPC;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using Timer=System.Timers.Timer; 36using Timer=System.Timers.Timer;
37using OpenSim.Services.Interfaces;
37 38
38namespace OpenSim.Region.OptionalModules.World.NPC 39namespace OpenSim.Region.OptionalModules.World.NPC
39{ 40{
@@ -63,11 +64,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC
63 if (m_appearanceCache.ContainsKey(target)) 64 if (m_appearanceCache.ContainsKey(target))
64 return m_appearanceCache[target]; 65 return m_appearanceCache[target];
65 66
66 AvatarAppearance x = scene.CommsManager.AvatarService.GetUserAppearance(target); 67 AvatarData adata = scene.AvatarService.GetAvatar(target);
68 if (adata != null)
69 {
70 AvatarAppearance x = adata.ToAvatarAppearance(target);
67 71
68 m_appearanceCache.Add(target, x); 72 m_appearanceCache.Add(target, x);
69 73
70 return x; 74 return x;
75 }
76 return new AvatarAppearance();
71 } 77 }
72 78
73 public UUID CreateNPC(string firstname, string lastname,Vector3 position, Scene scene, UUID cloneAppearanceFrom) 79 public UUID CreateNPC(string firstname, string lastname,Vector3 position, Scene scene, UUID cloneAppearanceFrom)
diff --git a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
index c8e6e4b..3ed338b 100644
--- a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
+++ b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
@@ -306,8 +306,6 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
306 306
307 m_log.InfoFormat("[TREES]: New tree planting for copse {0}", copsename); 307 m_log.InfoFormat("[TREES]: New tree planting for copse {0}", copsename);
308 UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner; 308 UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner;
309 if (uuid == UUID.Zero)
310 uuid = m_scene.RegionInfo.MasterAvatarAssignedUUID;
311 309
312 foreach (Copse copse in m_copse) 310 foreach (Copse copse in m_copse)
313 { 311 {
@@ -760,8 +758,6 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
760 Util.GetDistanceTo(position, copse.m_seed_point) <= copse.m_range) 758 Util.GetDistanceTo(position, copse.m_seed_point) <= copse.m_range)
761 { 759 {
762 UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner; 760 UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner;
763 if (uuid == UUID.Zero)
764 uuid = m_scene.RegionInfo.MasterAvatarAssignedUUID;
765 761
766 CreateTree(uuid, copse, position); 762 CreateTree(uuid, copse, position);
767 } 763 }
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs
index 25b9099..25bf297 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs
@@ -195,6 +195,11 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
195 195
196 } 196 }
197 197
198 public override void VehicleFlags(int param, bool remove)
199 {
200
201 }
202
198 public override void SetVolumeDetect(int param) 203 public override void SetVolumeDetect(int param)
199 { 204 {
200 205
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs
index 120d040..7d5c078 100644
--- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs
+++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs
@@ -372,6 +372,11 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
372 372
373 } 373 }
374 374
375 public override void VehicleFlags(int param, bool remove)
376 {
377
378 }
379
375 public override void SetVolumeDetect(int param) 380 public override void SetVolumeDetect(int param)
376 { 381 {
377 382
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
index f430def..1f3e031 100644
--- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
+++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
@@ -407,6 +407,11 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
407 407
408 } 408 }
409 409
410 public override void VehicleFlags(int param, bool remove)
411 {
412
413 }
414
410 public override void SetVolumeDetect(int param) 415 public override void SetVolumeDetect(int param)
411 { 416 {
412 //TODO: GhostObject 417 //TODO: GhostObject
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
index 9113ebe..17f99f5 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
@@ -500,6 +500,18 @@ namespace OpenSim.Region.Physics.BulletXPlugin
500 public BulletXScene(String sceneIdentifier) 500 public BulletXScene(String sceneIdentifier)
501 { 501 {
502 //identifier = sceneIdentifier; 502 //identifier = sceneIdentifier;
503 cDispatcher = new CollisionDispatcherLocal(this);
504 Vector3 worldMinDim = new Vector3((float)minXY, (float)minXY, (float)minZ);
505 Vector3 worldMaxDim = new Vector3((float)maxXY, (float)maxXY, (float)maxZ);
506 opCache = new AxisSweep3(worldMinDim, worldMaxDim, maxHandles);
507 sicSolver = new SequentialImpulseConstraintSolver();
508
509 lock (BulletXLock)
510 {
511 ddWorld = new DiscreteDynamicsWorld(cDispatcher, opCache, sicSolver);
512 ddWorld.Gravity = new Vector3(0, 0, -gravity);
513 }
514 //this._heightmap = new float[65536];
503 } 515 }
504 516
505 public static float Gravity 517 public static float Gravity
@@ -582,12 +594,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin
582 pos.Y = position.Y; 594 pos.Y = position.Y;
583 pos.Z = position.Z + 20; 595 pos.Z = position.Z + 20;
584 BulletXCharacter newAv = null; 596 BulletXCharacter newAv = null;
585 newAv.Flying = isFlying;
586 lock (BulletXLock) 597 lock (BulletXLock)
587 { 598 {
588 newAv = new BulletXCharacter(avName, this, pos); 599 newAv = new BulletXCharacter(avName, this, pos);
589 _characters.Add(newAv.RigidBody, newAv); 600 _characters.Add(newAv.RigidBody, newAv);
590 } 601 }
602 newAv.Flying = isFlying;
591 return newAv; 603 return newAv;
592 } 604 }
593 605
@@ -994,6 +1006,11 @@ namespace OpenSim.Region.Physics.BulletXPlugin
994 { 1006 {
995 1007
996 } 1008 }
1009
1010 public override void VehicleFlags(int param, bool remove)
1011 {
1012
1013 }
997 1014
998 public override void SetVolumeDetect(int param) 1015 public override void SetVolumeDetect(int param)
999 { 1016 {
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs
index 2eb519f..6dadbe5 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs
@@ -734,6 +734,10 @@ namespace OpenSim.Region.Physics.OdePlugin
734 734
735 } 735 }
736 736
737 public override void VehicleFlags(int flags, bool remove)
738 {
739 }
740
737 public override void VehicleFlagsSet(int flags) 741 public override void VehicleFlagsSet(int flags)
738 { 742 {
739 743
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
index 8502aef..0eb9bb5 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
@@ -2426,6 +2426,14 @@ Console.WriteLine(" JointCreateFixed");
2426 m_vehicle.ProcessFlagsVehicleRemove(flags); 2426 m_vehicle.ProcessFlagsVehicleRemove(flags);
2427 } 2427 }
2428 2428
2429 public override void VehicleFlags(int flags, bool remove)
2430 {
2431 if (!remove)
2432 m_vehicle.ProcessFlagsVehicleSet(flags);
2433 else
2434 m_vehicle.ProcessFlagsVehicleRemove(flags);
2435 }
2436
2429 public override void SetVolumeDetect(int param) 2437 public override void SetVolumeDetect(int param)
2430 { 2438 {
2431 lock (_parent_scene.OdeLock) 2439 lock (_parent_scene.OdeLock)
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index f43de48..8060ba0 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -210,6 +210,7 @@ namespace OpenSim.Region.Physics.Manager
210 public abstract void VehicleRotationParam(int param, Quaternion rotation); 210 public abstract void VehicleRotationParam(int param, Quaternion rotation);
211 public abstract void VehicleFlagsSet(int flags); 211 public abstract void VehicleFlagsSet(int flags);
212 public abstract void VehicleFlagsRemove(int flags); 212 public abstract void VehicleFlagsRemove(int flags);
213 public abstract void VehicleFlags(int param, bool remove);
213 214
214 public abstract void SetVolumeDetect(int param); // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more 215 public abstract void SetVolumeDetect(int param); // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more
215 216
@@ -364,6 +365,11 @@ namespace OpenSim.Region.Physics.Manager
364 365
365 } 366 }
366 367
368 public override void VehicleFlags(int param, bool remove)
369 {
370
371 }
372
367 public override void SetVolumeDetect(int param) 373 public override void SetVolumeDetect(int param)
368 { 374 {
369 375
diff --git a/OpenSim/Region/Physics/Manager/VehicleConstants.cs b/OpenSim/Region/Physics/Manager/VehicleConstants.cs
index 532e55e..f0775c1 100644
--- a/OpenSim/Region/Physics/Manager/VehicleConstants.cs
+++ b/OpenSim/Region/Physics/Manager/VehicleConstants.cs
@@ -91,7 +91,9 @@ namespace OpenSim.Region.Physics.Manager
91 BANKING_EFFICIENCY = 38, 91 BANKING_EFFICIENCY = 38,
92 BANKING_MIX = 39, 92 BANKING_MIX = 39,
93 BANKING_TIMESCALE = 40, 93 BANKING_TIMESCALE = 40,
94 REFERENCE_FRAME = 44 94 REFERENCE_FRAME = 44,
95 BLOCK_EXIT = 45,
96 ROLL_FRAME = 46
95 97
96 } 98 }
97 99
@@ -107,7 +109,13 @@ namespace OpenSim.Region.Physics.Manager
107 LIMIT_MOTOR_UP = 64, 109 LIMIT_MOTOR_UP = 64,
108 MOUSELOOK_STEER = 128, 110 MOUSELOOK_STEER = 128,
109 MOUSELOOK_BANK = 256, 111 MOUSELOOK_BANK = 256,
110 CAMERA_DECOUPLED = 512 112 CAMERA_DECOUPLED = 512,
113 NO_X = 1024,
114 NO_Y = 2048,
115 NO_Z = 4096,
116 LOCK_HOVER_HEIGHT = 8192,
117 NO_DEFLECTION = 16392,
118 LOCK_ROTATION = 32784
111 } 119 }
112 120
113} 121}
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index b713142..6b8d1e2 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -744,6 +744,11 @@ namespace OpenSim.Region.Physics.OdePlugin
744 744
745 } 745 }
746 746
747 public override void VehicleFlags(int param, bool remove)
748 {
749
750 }
751
747 public override void SetVolumeDetect(int param) 752 public override void SetVolumeDetect(int param)
748 { 753 {
749 754
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
index 008070b..9beeabb 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
@@ -72,37 +72,40 @@ namespace OpenSim.Region.Physics.OdePlugin
72 72
73 73
74 // Vehicle properties 74 // Vehicle properties
75 private Vehicle m_type = Vehicle.TYPE_NONE; // If a 'VEHICLE', and what kind 75 private Vehicle m_type = Vehicle.TYPE_NONE; // If a 'VEHICLE', and what kind
76 // private Quaternion m_referenceFrame = Quaternion.Identity; // Axis modifier 76 // private Quaternion m_referenceFrame = Quaternion.Identity; // Axis modifier
77 private VehicleFlag m_flags = (VehicleFlag) 0; // Boolean settings: 77 private VehicleFlag m_flags = (VehicleFlag) 0; // Boolean settings:
78 // HOVER_TERRAIN_ONLY 78 // HOVER_TERRAIN_ONLY
79 // HOVER_GLOBAL_HEIGHT 79 // HOVER_GLOBAL_HEIGHT
80 // NO_DEFLECTION_UP 80 // NO_DEFLECTION_UP
81 // HOVER_WATER_ONLY 81 // HOVER_WATER_ONLY
82 // HOVER_UP_ONLY 82 // HOVER_UP_ONLY
83 // LIMIT_MOTOR_UP 83 // LIMIT_MOTOR_UP
84 // LIMIT_ROLL_ONLY 84 // LIMIT_ROLL_ONLY
85 85 private VehicleFlag m_Hoverflags = (VehicleFlag)0;
86 private Vector3 m_BlockingEndPoint = Vector3.Zero;
87 private Quaternion m_RollreferenceFrame = Quaternion.Identity;
86 // Linear properties 88 // Linear properties
87 private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time 89 private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time
88 private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero; // velocity requested by LSL 90 private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero; // velocity requested by LSL
89 private Vector3 m_dir = Vector3.Zero; // velocity applied to body 91 private Vector3 m_dir = Vector3.Zero; // velocity applied to body
90 private Vector3 m_linearFrictionTimescale = Vector3.Zero; 92 private Vector3 m_linearFrictionTimescale = Vector3.Zero;
91 private float m_linearMotorDecayTimescale = 0; 93 private float m_linearMotorDecayTimescale = 0;
92 private float m_linearMotorTimescale = 0; 94 private float m_linearMotorTimescale = 0;
93 private Vector3 m_lastLinearVelocityVector = Vector3.Zero; 95 private Vector3 m_lastLinearVelocityVector = Vector3.Zero;
96 private d.Vector3 m_lastPositionVector = new d.Vector3();
94 // private bool m_LinearMotorSetLastFrame = false; 97 // private bool m_LinearMotorSetLastFrame = false;
95 // private Vector3 m_linearMotorOffset = Vector3.Zero; 98 // private Vector3 m_linearMotorOffset = Vector3.Zero;
96 99
97 //Angular properties 100 //Angular properties
98 private Vector3 m_angularMotorDirection = Vector3.Zero; // angular velocity requested by LSL motor 101 private Vector3 m_angularMotorDirection = Vector3.Zero; // angular velocity requested by LSL motor
99 private int m_angularMotorApply = 0; // application frame counter 102 private int m_angularMotorApply = 0; // application frame counter
100 private Vector3 m_angularMotorVelocity = Vector3.Zero; // current angular motor velocity 103 private Vector3 m_angularMotorVelocity = Vector3.Zero; // current angular motor velocity
101 private float m_angularMotorTimescale = 0; // motor angular velocity ramp up rate 104 private float m_angularMotorTimescale = 0; // motor angular velocity ramp up rate
102 private float m_angularMotorDecayTimescale = 0; // motor angular velocity decay rate 105 private float m_angularMotorDecayTimescale = 0; // motor angular velocity decay rate
103 private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate 106 private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate
104 private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body 107 private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body
105 // private Vector3 m_lastVertAttractor = Vector3.Zero; // what VA was last applied to body 108 // private Vector3 m_lastVertAttractor = Vector3.Zero; // what VA was last applied to body
106 109
107 //Deflection properties 110 //Deflection properties
108 // private float m_angularDeflectionEfficiency = 0; 111 // private float m_angularDeflectionEfficiency = 0;
@@ -120,14 +123,14 @@ namespace OpenSim.Region.Physics.OdePlugin
120// private float m_VhoverEfficiency = 0f; 123// private float m_VhoverEfficiency = 0f;
121 private float m_VhoverTimescale = 0f; 124 private float m_VhoverTimescale = 0f;
122 private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height 125 private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height
123 private float m_VehicleBuoyancy = 0f; //KF: m_VehicleBuoyancy is set by VEHICLE_BUOYANCY for a vehicle. 126 private float m_VehicleBuoyancy = 0f; //KF: m_VehicleBuoyancy is set by VEHICLE_BUOYANCY for a vehicle.
124 // Modifies gravity. Slider between -1 (double-gravity) and 1 (full anti-gravity) 127 // Modifies gravity. Slider between -1 (double-gravity) and 1 (full anti-gravity)
125 // KF: So far I have found no good method to combine a script-requested .Z velocity and gravity. 128 // KF: So far I have found no good method to combine a script-requested .Z velocity and gravity.
126 // Therefore only m_VehicleBuoyancy=1 (0g) will use the script-requested .Z velocity. 129 // Therefore only m_VehicleBuoyancy=1 (0g) will use the script-requested .Z velocity.
127 130
128 //Attractor properties 131 //Attractor properties
129 private float m_verticalAttractionEfficiency = 1.0f; // damped 132 private float m_verticalAttractionEfficiency = 1.0f; // damped
130 private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor. 133 private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor.
131 134
132 internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue) 135 internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue)
133 { 136 {
@@ -255,6 +258,9 @@ namespace OpenSim.Region.Physics.OdePlugin
255 case Vehicle.LINEAR_MOTOR_OFFSET: 258 case Vehicle.LINEAR_MOTOR_OFFSET:
256 // m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z); 259 // m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z);
257 break; 260 break;
261 case Vehicle.BLOCK_EXIT:
262 m_BlockingEndPoint = new Vector3(pValue.X, pValue.Y, pValue.Z);
263 break;
258 } 264 }
259 }//end ProcessVectorVehicleParam 265 }//end ProcessVectorVehicleParam
260 266
@@ -265,15 +271,189 @@ namespace OpenSim.Region.Physics.OdePlugin
265 case Vehicle.REFERENCE_FRAME: 271 case Vehicle.REFERENCE_FRAME:
266 // m_referenceFrame = pValue; 272 // m_referenceFrame = pValue;
267 break; 273 break;
274 case Vehicle.ROLL_FRAME:
275 m_RollreferenceFrame = pValue;
276 break;
268 } 277 }
269 }//end ProcessRotationVehicleParam 278 }//end ProcessRotationVehicleParam
270 279
280 internal void ProcessVehicleFlags(int pParam, bool remove)
281 {
282 if (remove)
283 {
284 if (pParam == -1)
285 {
286 m_flags = (VehicleFlag)0;
287 m_Hoverflags = (VehicleFlag)0;
288 return;
289 }
290 if ((pParam & (int)VehicleFlag.HOVER_GLOBAL_HEIGHT) == (int)VehicleFlag.HOVER_GLOBAL_HEIGHT)
291 {
292 if ((m_Hoverflags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != (VehicleFlag)0)
293 m_Hoverflags &= ~(VehicleFlag.HOVER_GLOBAL_HEIGHT);
294 }
295 if ((pParam & (int)VehicleFlag.HOVER_TERRAIN_ONLY) == (int)VehicleFlag.HOVER_TERRAIN_ONLY)
296 {
297 if ((m_Hoverflags & VehicleFlag.HOVER_TERRAIN_ONLY) != (VehicleFlag)0)
298 m_Hoverflags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY);
299 }
300 if ((pParam & (int)VehicleFlag.HOVER_UP_ONLY) == (int)VehicleFlag.HOVER_UP_ONLY)
301 {
302 if ((m_Hoverflags & VehicleFlag.HOVER_UP_ONLY) != (VehicleFlag)0)
303 m_Hoverflags &= ~(VehicleFlag.HOVER_UP_ONLY);
304 }
305 if ((pParam & (int)VehicleFlag.HOVER_WATER_ONLY) == (int)VehicleFlag.HOVER_WATER_ONLY)
306 {
307 if ((m_Hoverflags & VehicleFlag.HOVER_WATER_ONLY) != (VehicleFlag)0)
308 m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY);
309 }
310 if ((pParam & (int)VehicleFlag.LIMIT_MOTOR_UP) == (int)VehicleFlag.LIMIT_MOTOR_UP)
311 {
312 if ((m_flags & VehicleFlag.LIMIT_MOTOR_UP) != (VehicleFlag)0)
313 m_flags &= ~(VehicleFlag.LIMIT_MOTOR_UP);
314 }
315 if ((pParam & (int)VehicleFlag.LIMIT_ROLL_ONLY) == (int)VehicleFlag.LIMIT_ROLL_ONLY)
316 {
317 if ((m_flags & VehicleFlag.LIMIT_ROLL_ONLY) != (VehicleFlag)0)
318 m_flags &= ~(VehicleFlag.LIMIT_ROLL_ONLY);
319 }
320 if ((pParam & (int)VehicleFlag.MOUSELOOK_BANK) == (int)VehicleFlag.MOUSELOOK_BANK)
321 {
322 if ((m_flags & VehicleFlag.MOUSELOOK_BANK) != (VehicleFlag)0)
323 m_flags &= ~(VehicleFlag.MOUSELOOK_BANK);
324 }
325 if ((pParam & (int)VehicleFlag.MOUSELOOK_STEER) == (int)VehicleFlag.MOUSELOOK_STEER)
326 {
327 if ((m_flags & VehicleFlag.MOUSELOOK_STEER) != (VehicleFlag)0)
328 m_flags &= ~(VehicleFlag.MOUSELOOK_STEER);
329 }
330 if ((pParam & (int)VehicleFlag.NO_DEFLECTION_UP) == (int)VehicleFlag.NO_DEFLECTION_UP)
331 {
332 if ((m_flags & VehicleFlag.NO_DEFLECTION_UP) != (VehicleFlag)0)
333 m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP);
334 }
335 if ((pParam & (int)VehicleFlag.CAMERA_DECOUPLED) == (int)VehicleFlag.CAMERA_DECOUPLED)
336 {
337 if ((m_flags & VehicleFlag.CAMERA_DECOUPLED) != (VehicleFlag)0)
338 m_flags &= ~(VehicleFlag.CAMERA_DECOUPLED);
339 }
340 if ((pParam & (int)VehicleFlag.NO_X) == (int)VehicleFlag.NO_X)
341 {
342 if ((m_flags & VehicleFlag.NO_X) != (VehicleFlag)0)
343 m_flags &= ~(VehicleFlag.NO_X);
344 }
345 if ((pParam & (int)VehicleFlag.NO_Y) == (int)VehicleFlag.NO_Y)
346 {
347 if ((m_flags & VehicleFlag.NO_Y) != (VehicleFlag)0)
348 m_flags &= ~(VehicleFlag.NO_Y);
349 }
350 if ((pParam & (int)VehicleFlag.NO_Z) == (int)VehicleFlag.NO_Z)
351 {
352 if ((m_flags & VehicleFlag.NO_Z) != (VehicleFlag)0)
353 m_flags &= ~(VehicleFlag.NO_Z);
354 }
355 if ((pParam & (int)VehicleFlag.LOCK_HOVER_HEIGHT) == (int)VehicleFlag.LOCK_HOVER_HEIGHT)
356 {
357 if ((m_Hoverflags & VehicleFlag.LOCK_HOVER_HEIGHT) != (VehicleFlag)0)
358 m_Hoverflags &= ~(VehicleFlag.LOCK_HOVER_HEIGHT);
359 }
360 if ((pParam & (int)VehicleFlag.NO_DEFLECTION) == (int)VehicleFlag.NO_DEFLECTION)
361 {
362 if ((m_flags & VehicleFlag.NO_DEFLECTION) != (VehicleFlag)0)
363 m_flags &= ~(VehicleFlag.NO_DEFLECTION);
364 }
365 if ((pParam & (int)VehicleFlag.LOCK_ROTATION) == (int)VehicleFlag.LOCK_ROTATION)
366 {
367 if ((m_flags & VehicleFlag.LOCK_ROTATION) != (VehicleFlag)0)
368 m_flags &= ~(VehicleFlag.LOCK_ROTATION);
369 }
370 }
371 else
372 {
373 if ((pParam & (int)VehicleFlag.HOVER_GLOBAL_HEIGHT) == (int)VehicleFlag.HOVER_GLOBAL_HEIGHT)
374 {
375 m_Hoverflags |= (VehicleFlag.HOVER_GLOBAL_HEIGHT | m_flags);
376 }
377 if ((pParam & (int)VehicleFlag.HOVER_TERRAIN_ONLY) == (int)VehicleFlag.HOVER_TERRAIN_ONLY)
378 {
379 m_Hoverflags |= (VehicleFlag.HOVER_TERRAIN_ONLY | m_flags);
380 }
381 if ((pParam & (int)VehicleFlag.HOVER_UP_ONLY) == (int)VehicleFlag.HOVER_UP_ONLY)
382 {
383 m_Hoverflags |= (VehicleFlag.HOVER_UP_ONLY | m_flags);
384 }
385 if ((pParam & (int)VehicleFlag.HOVER_WATER_ONLY) == (int)VehicleFlag.HOVER_WATER_ONLY)
386 {
387 m_Hoverflags |= (VehicleFlag.HOVER_WATER_ONLY | m_flags);
388 }
389 if ((pParam & (int)VehicleFlag.LIMIT_MOTOR_UP) == (int)VehicleFlag.LIMIT_MOTOR_UP)
390 {
391 m_flags |= (VehicleFlag.LIMIT_MOTOR_UP | m_flags);
392 }
393 if ((pParam & (int)VehicleFlag.MOUSELOOK_BANK) == (int)VehicleFlag.MOUSELOOK_BANK)
394 {
395 m_flags |= (VehicleFlag.MOUSELOOK_BANK | m_flags);
396 }
397 if ((pParam & (int)VehicleFlag.MOUSELOOK_STEER) == (int)VehicleFlag.MOUSELOOK_STEER)
398 {
399 m_flags |= (VehicleFlag.MOUSELOOK_STEER | m_flags);
400 }
401 if ((pParam & (int)VehicleFlag.NO_DEFLECTION_UP) == (int)VehicleFlag.NO_DEFLECTION_UP)
402 {
403 m_flags |= (VehicleFlag.NO_DEFLECTION_UP | m_flags);
404 }
405 if ((pParam & (int)VehicleFlag.CAMERA_DECOUPLED) == (int)VehicleFlag.CAMERA_DECOUPLED)
406 {
407 m_flags |= (VehicleFlag.CAMERA_DECOUPLED | m_flags);
408 }
409 if ((pParam & (int)VehicleFlag.NO_X) == (int)VehicleFlag.NO_X)
410 {
411 m_flags |= (VehicleFlag.NO_X);
412 }
413 if ((pParam & (int)VehicleFlag.NO_Y) == (int)VehicleFlag.NO_Y)
414 {
415 m_flags |= (VehicleFlag.NO_Y);
416 }
417 if ((pParam & (int)VehicleFlag.NO_Z) == (int)VehicleFlag.NO_Z)
418 {
419 m_flags |= (VehicleFlag.NO_Z);
420 }
421 if ((pParam & (int)VehicleFlag.LOCK_HOVER_HEIGHT) == (int)VehicleFlag.LOCK_HOVER_HEIGHT)
422 {
423 m_Hoverflags |= (VehicleFlag.LOCK_HOVER_HEIGHT);
424 }
425 if ((pParam & (int)VehicleFlag.NO_DEFLECTION) == (int)VehicleFlag.NO_DEFLECTION)
426 {
427 m_flags |= (VehicleFlag.NO_DEFLECTION);
428 }
429 if ((pParam & (int)VehicleFlag.LOCK_ROTATION) == (int)VehicleFlag.LOCK_ROTATION)
430 {
431 m_flags |= (VehicleFlag.LOCK_ROTATION);
432 }
433 }
434 }//end ProcessVehicleFlags
435
271 internal void ProcessTypeChange(Vehicle pType) 436 internal void ProcessTypeChange(Vehicle pType)
272 { 437 {
273 // Set Defaults For Type 438 // Set Defaults For Type
274 m_type = pType; 439 m_type = pType;
275 switch (pType) 440 switch (pType)
276 { 441 {
442 case Vehicle.TYPE_NONE:
443 m_linearFrictionTimescale = new Vector3(0, 0, 0);
444 m_angularFrictionTimescale = new Vector3(0, 0, 0);
445 m_linearMotorDirection = Vector3.Zero;
446 m_linearMotorTimescale = 0;
447 m_linearMotorDecayTimescale = 0;
448 m_angularMotorDirection = Vector3.Zero;
449 m_angularMotorTimescale = 0;
450 m_angularMotorDecayTimescale = 0;
451 m_VhoverHeight = 0;
452 m_VhoverTimescale = 0;
453 m_VehicleBuoyancy = 0;
454 m_flags = (VehicleFlag)0;
455 break;
456
277 case Vehicle.TYPE_SLED: 457 case Vehicle.TYPE_SLED:
278 m_linearFrictionTimescale = new Vector3(30, 1, 1000); 458 m_linearFrictionTimescale = new Vector3(30, 1, 1000);
279 m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); 459 m_angularFrictionTimescale = new Vector3(1000, 1000, 1000);
@@ -295,9 +475,9 @@ namespace OpenSim.Region.Physics.OdePlugin
295 // m_bankingMix = 1; 475 // m_bankingMix = 1;
296 // m_bankingTimescale = 10; 476 // m_bankingTimescale = 10;
297 // m_referenceFrame = Quaternion.Identity; 477 // m_referenceFrame = Quaternion.Identity;
298 m_flags &= 478 m_Hoverflags &=
299 ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | 479 ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY |
300 VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); 480 VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY);
301 m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP); 481 m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP);
302 break; 482 break;
303 case Vehicle.TYPE_CAR: 483 case Vehicle.TYPE_CAR:
@@ -323,9 +503,10 @@ namespace OpenSim.Region.Physics.OdePlugin
323 // m_bankingMix = 1; 503 // m_bankingMix = 1;
324 // m_bankingTimescale = 1; 504 // m_bankingTimescale = 1;
325 // m_referenceFrame = Quaternion.Identity; 505 // m_referenceFrame = Quaternion.Identity;
326 m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); 506 m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT);
327 m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.HOVER_UP_ONLY | 507 m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY |
328 VehicleFlag.LIMIT_MOTOR_UP); 508 VehicleFlag.LIMIT_MOTOR_UP);
509 m_Hoverflags |= (VehicleFlag.HOVER_UP_ONLY);
329 break; 510 break;
330 case Vehicle.TYPE_BOAT: 511 case Vehicle.TYPE_BOAT:
331 m_linearFrictionTimescale = new Vector3(10, 3, 2); 512 m_linearFrictionTimescale = new Vector3(10, 3, 2);
@@ -350,10 +531,12 @@ namespace OpenSim.Region.Physics.OdePlugin
350 // m_bankingMix = 0.8f; 531 // m_bankingMix = 0.8f;
351 // m_bankingTimescale = 1; 532 // m_bankingTimescale = 1;
352 // m_referenceFrame = Quaternion.Identity; 533 // m_referenceFrame = Quaternion.Identity;
353 m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.LIMIT_ROLL_ONLY | 534 m_Hoverflags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY |
354 VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); 535 VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY);
355 m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.HOVER_WATER_ONLY | 536 m_flags &= ~(VehicleFlag.LIMIT_ROLL_ONLY);
537 m_flags |= (VehicleFlag.NO_DEFLECTION_UP |
356 VehicleFlag.LIMIT_MOTOR_UP); 538 VehicleFlag.LIMIT_MOTOR_UP);
539 m_Hoverflags |= (VehicleFlag.HOVER_WATER_ONLY);
357 break; 540 break;
358 case Vehicle.TYPE_AIRPLANE: 541 case Vehicle.TYPE_AIRPLANE:
359 m_linearFrictionTimescale = new Vector3(200, 10, 5); 542 m_linearFrictionTimescale = new Vector3(200, 10, 5);
@@ -378,8 +561,9 @@ namespace OpenSim.Region.Physics.OdePlugin
378 // m_bankingMix = 0.7f; 561 // m_bankingMix = 0.7f;
379 // m_bankingTimescale = 2; 562 // m_bankingTimescale = 2;
380 // m_referenceFrame = Quaternion.Identity; 563 // m_referenceFrame = Quaternion.Identity;
381 m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | 564 m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY |
382 VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY | VehicleFlag.LIMIT_MOTOR_UP); 565 VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY);
566 m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP);
383 m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); 567 m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY);
384 break; 568 break;
385 case Vehicle.TYPE_BALLOON: 569 case Vehicle.TYPE_BALLOON:
@@ -405,9 +589,11 @@ namespace OpenSim.Region.Physics.OdePlugin
405 // m_bankingMix = 0.7f; 589 // m_bankingMix = 0.7f;
406 // m_bankingTimescale = 5; 590 // m_bankingTimescale = 5;
407 // m_referenceFrame = Quaternion.Identity; 591 // m_referenceFrame = Quaternion.Identity;
408 m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | 592 m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY |
409 VehicleFlag.HOVER_UP_ONLY | VehicleFlag.LIMIT_MOTOR_UP); 593 VehicleFlag.HOVER_UP_ONLY);
410 m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); 594 m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP);
595 m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY);
596 m_Hoverflags |= (VehicleFlag.HOVER_GLOBAL_HEIGHT);
411 break; 597 break;
412 598
413 } 599 }
@@ -431,6 +617,7 @@ namespace OpenSim.Region.Physics.OdePlugin
431 617
432 MoveLinear(pTimestep, pParentScene); 618 MoveLinear(pTimestep, pParentScene);
433 MoveAngular(pTimestep); 619 MoveAngular(pTimestep);
620 LimitRotation(pTimestep);
434 }// end Step 621 }// end Step
435 622
436 private void MoveLinear(float pTimestep, OdeScene _pParentScene) 623 private void MoveLinear(float pTimestep, OdeScene _pParentScene)
@@ -477,61 +664,152 @@ namespace OpenSim.Region.Physics.OdePlugin
477 // .Z velocity and gravity. Therefore only 0g will used script-requested 664 // .Z velocity and gravity. Therefore only 0g will used script-requested
478 // .Z velocity. >0g (m_VehicleBuoyancy < 1) will used modified gravity only. 665 // .Z velocity. >0g (m_VehicleBuoyancy < 1) will used modified gravity only.
479 Vector3 grav = Vector3.Zero; 666 Vector3 grav = Vector3.Zero;
480 if (m_VehicleBuoyancy < 1.0f) 667 // There is some gravity, make a gravity force vector
668 // that is applied after object velocity.
669 d.Mass objMass;
670 d.BodyGetMass(Body, out objMass);
671 // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g;
672 grav.Z = _pParentScene.gravityz * objMass.mass * (1f - m_VehicleBuoyancy);
673 // Preserve the current Z velocity
674 d.Vector3 vel_now = d.BodyGetLinearVel(Body);
675 m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity
676
677 d.Vector3 pos = d.BodyGetPosition(Body);
678 Vector3 accel = new Vector3(-(m_dir.X - m_lastLinearVelocityVector.X / 0.1f), -(m_dir.Y - m_lastLinearVelocityVector.Y / 0.1f), m_dir.Z - m_lastLinearVelocityVector.Z / 0.1f);
679 Vector3 posChange = new Vector3();
680 posChange.X = pos.X - m_lastPositionVector.X;
681 posChange.Y = pos.Y - m_lastPositionVector.Y;
682 posChange.Z = pos.Z - m_lastPositionVector.Z;
683 double Zchange = Math.Abs(posChange.Z);
684 if (m_BlockingEndPoint != Vector3.Zero)
685 {
686 if (pos.X >= (m_BlockingEndPoint.X - (float)1))
687 {
688 pos.X -= posChange.X + 1;
689 d.BodySetPosition(Body, pos.X, pos.Y, pos.Z);
690 }
691 if (pos.Y >= (m_BlockingEndPoint.Y - (float)1))
692 {
693 pos.Y -= posChange.Y + 1;
694 d.BodySetPosition(Body, pos.X, pos.Y, pos.Z);
695 }
696 if (pos.Z >= (m_BlockingEndPoint.Z - (float)1))
697 {
698 pos.Z -= posChange.Z + 1;
699 d.BodySetPosition(Body, pos.X, pos.Y, pos.Z);
700 }
701 if (pos.X <= 0)
702 {
703 pos.X += posChange.X + 1;
704 d.BodySetPosition(Body, pos.X, pos.Y, pos.Z);
705 }
706 if (pos.Y <= 0)
707 {
708 pos.Y += posChange.Y + 1;
709 d.BodySetPosition(Body, pos.X, pos.Y, pos.Z);
710 }
711 }
712 if (pos.Z < _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y))
481 { 713 {
482 // There is some gravity, make a gravity force vector 714 pos.Z = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y) + 2;
483 // that is applied after object velocity. 715 d.BodySetPosition(Body, pos.X, pos.Y, pos.Z);
484 d.Mass objMass; 716 }
485 d.BodyGetMass(Body, out objMass);
486 // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g;
487 grav.Z = _pParentScene.gravityz * objMass.mass * (1f - m_VehicleBuoyancy);
488 // Preserve the current Z velocity
489 d.Vector3 vel_now = d.BodyGetLinearVel(Body);
490 m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity
491 } // else its 1.0, no gravity.
492 717
493 // Check if hovering 718 // Check if hovering
494 if ((m_flags & (VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT)) != 0) 719 if ((m_Hoverflags & (VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT)) != 0)
495 { 720 {
496 // We should hover, get the target height 721 // We should hover, get the target height
497 d.Vector3 pos = d.BodyGetPosition(Body); 722 if ((m_Hoverflags & VehicleFlag.HOVER_WATER_ONLY) != 0)
498 if ((m_flags & VehicleFlag.HOVER_WATER_ONLY) == VehicleFlag.HOVER_WATER_ONLY)
499 { 723 {
500 m_VhoverTargetHeight = _pParentScene.GetWaterLevel() + m_VhoverHeight; 724 m_VhoverTargetHeight = _pParentScene.GetWaterLevel() + m_VhoverHeight;
501 } 725 }
502 else if ((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) == VehicleFlag.HOVER_TERRAIN_ONLY) 726 if ((m_Hoverflags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0)
503 { 727 {
504 m_VhoverTargetHeight = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y) + m_VhoverHeight; 728 m_VhoverTargetHeight = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y) + m_VhoverHeight;
505 } 729 }
506 else if ((m_flags & VehicleFlag.HOVER_GLOBAL_HEIGHT) == VehicleFlag.HOVER_GLOBAL_HEIGHT) 730 if ((m_Hoverflags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != 0)
507 { 731 {
508 m_VhoverTargetHeight = m_VhoverHeight; 732 m_VhoverTargetHeight = m_VhoverHeight;
509 } 733 }
510 734
511 if ((m_flags & VehicleFlag.HOVER_UP_ONLY) == VehicleFlag.HOVER_UP_ONLY) 735 if ((m_Hoverflags & VehicleFlag.HOVER_UP_ONLY) != 0)
512 { 736 {
513 // If body is aready heigher, use its height as target height 737 // If body is aready heigher, use its height as target height
514 if (pos.Z > m_VhoverTargetHeight) m_VhoverTargetHeight = pos.Z; 738 if (pos.Z > m_VhoverTargetHeight) m_VhoverTargetHeight = pos.Z;
515 } 739 }
740 if ((m_Hoverflags & VehicleFlag.LOCK_HOVER_HEIGHT) != 0)
741 {
742 if ((pos.Z - m_VhoverTargetHeight) > .2 || (pos.Z - m_VhoverTargetHeight) < -.2)
743 {
744 d.BodySetPosition(Body, pos.X, pos.Y, m_VhoverTargetHeight);
745 }
746 }
747 else
748 {
749 float herr0 = pos.Z - m_VhoverTargetHeight;
750 // Replace Vertical speed with correction figure if significant
751 if (Math.Abs(herr0) > 0.01f)
752 {
753 m_dir.Z = -((herr0 * pTimestep * 50.0f) / m_VhoverTimescale);
754 //KF: m_VhoverEfficiency is not yet implemented
755 }
756 else
757 {
758 m_dir.Z = 0f;
759 }
760 }
516 761
517// m_VhoverEfficiency = 0f; // 0=boucy, 1=Crit.damped 762// m_VhoverEfficiency = 0f; // 0=boucy, 1=Crit.damped
518// m_VhoverTimescale = 0f; // time to acheive height 763// m_VhoverTimescale = 0f; // time to acheive height
519// pTimestep is time since last frame,in secs 764// pTimestep is time since last frame,in secs
520 float herr0 = pos.Z - m_VhoverTargetHeight; 765 }
521 // Replace Vertical speed with correction figure if significant 766
522 if (Math.Abs(herr0) > 0.01f) 767 if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0)
768 {
769 //Start Experimental Values
770 if (Zchange > .3)
523 { 771 {
524 d.Mass objMass; 772 grav.Z = (float)(grav.Z * 3);
525 d.BodyGetMass(Body, out objMass);
526 m_dir.Z = - ((herr0 * pTimestep * 50.0f) / m_VhoverTimescale);
527 //KF: m_VhoverEfficiency is not yet implemented
528 } 773 }
529 else 774 if (Zchange > .15)
775 {
776 grav.Z = (float)(grav.Z * 2);
777 }
778 if (Zchange > .75)
779 {
780 grav.Z = (float)(grav.Z * 1.5);
781 }
782 if (Zchange > .05)
783 {
784 grav.Z = (float)(grav.Z * 1.25);
785 }
786 if (Zchange > .025)
787 {
788 grav.Z = (float)(grav.Z * 1.125);
789 }
790 float terraintemp = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y);
791 float postemp = (pos.Z - terraintemp);
792 if (postemp > 2.5f)
530 { 793 {
531 m_dir.Z = 0f; 794 grav.Z = (float)(grav.Z * 1.037125);
532 } 795 }
796 //End Experimental Values
797 }
798 if ((m_flags & (VehicleFlag.NO_X)) != 0)
799 {
800 m_dir.X = 0;
801 }
802 if ((m_flags & (VehicleFlag.NO_Y)) != 0)
803 {
804 m_dir.Y = 0;
805 }
806 if ((m_flags & (VehicleFlag.NO_Z)) != 0)
807 {
808 m_dir.Z = 0;
533 } 809 }
534 810
811 m_lastPositionVector = d.BodyGetPosition(Body);
812
535 // Apply velocity 813 // Apply velocity
536 d.BodySetLinearVel(Body, m_dir.X, m_dir.Y, m_dir.Z); 814 d.BodySetLinearVel(Body, m_dir.X, m_dir.Y, m_dir.Z);
537 // apply gravity force 815 // apply gravity force
@@ -629,6 +907,12 @@ namespace OpenSim.Region.Physics.OdePlugin
629 907
630 // Sum velocities 908 // Sum velocities
631 m_lastAngularVelocity = m_angularMotorVelocity + vertattr; // + bank + deflection 909 m_lastAngularVelocity = m_angularMotorVelocity + vertattr; // + bank + deflection
910
911 if ((m_flags & (VehicleFlag.NO_DEFLECTION_UP)) != 0)
912 {
913 m_lastAngularVelocity.X = 0;
914 m_lastAngularVelocity.Y = 0;
915 }
632 916
633 if (!m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f)) 917 if (!m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f))
634 { 918 {
@@ -647,5 +931,44 @@ namespace OpenSim.Region.Physics.OdePlugin
647 d.BodySetAngularVel (Body, m_lastAngularVelocity.X, m_lastAngularVelocity.Y, m_lastAngularVelocity.Z); 931 d.BodySetAngularVel (Body, m_lastAngularVelocity.X, m_lastAngularVelocity.Y, m_lastAngularVelocity.Z);
648 932
649 } //end MoveAngular 933 } //end MoveAngular
934 internal void LimitRotation(float timestep)
935 {
936 d.Quaternion rot = d.BodyGetQuaternion(Body);
937 Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object
938 d.Quaternion m_rot = new d.Quaternion();
939 bool changed = false;
940 m_rot.X = rotq.X;
941 m_rot.Y = rotq.Y;
942 m_rot.Z = rotq.Z;
943 m_rot.W = rotq.W;
944 if (m_RollreferenceFrame != Quaternion.Identity)
945 {
946 if (rotq.X >= m_RollreferenceFrame.X)
947 {
948 m_rot.X = rotq.X - (m_RollreferenceFrame.X / 2);
949 }
950 if (rotq.Y >= m_RollreferenceFrame.Y)
951 {
952 m_rot.Y = rotq.Y - (m_RollreferenceFrame.Y / 2);
953 }
954 if (rotq.X <= -m_RollreferenceFrame.X)
955 {
956 m_rot.X = rotq.X + (m_RollreferenceFrame.X / 2);
957 }
958 if (rotq.Y <= -m_RollreferenceFrame.Y)
959 {
960 m_rot.Y = rotq.Y + (m_RollreferenceFrame.Y / 2);
961 }
962 changed = true;
963 }
964 if ((m_flags & VehicleFlag.LOCK_ROTATION) != 0)
965 {
966 m_rot.X = 0;
967 m_rot.Y = 0;
968 changed = true;
969 }
970 if (changed)
971 d.BodySetQuaternion(Body, ref m_rot);
972 }
650 } 973 }
651} 974}
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index f354328..9ef2e9c 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -2365,6 +2365,11 @@ Console.WriteLine(" JointCreateFixed");
2365 2365
2366 } 2366 }
2367 2367
2368 public override void VehicleFlags(int param, bool remove)
2369 {
2370 m_vehicle.ProcessVehicleFlags(param, remove);
2371 }
2372
2368 public override void SetVolumeDetect(int param) 2373 public override void SetVolumeDetect(int param)
2369 { 2374 {
2370 lock (_parent_scene.OdeLock) 2375 lock (_parent_scene.OdeLock)
diff --git a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs b/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs
index 491e200..e722666 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs
@@ -192,6 +192,8 @@ namespace OpenSim.Region.Physics.POSPlugin
192 192
193 } 193 }
194 194
195 public override void VehicleFlags(int param, bool remove) { }
196
195 public override void SetVolumeDetect(int param) 197 public override void SetVolumeDetect(int param)
196 { 198 {
197 199
diff --git a/OpenSim/Region/Physics/POSPlugin/POSPrim.cs b/OpenSim/Region/Physics/POSPlugin/POSPrim.cs
index f8d49f9..c129340 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSPrim.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSPrim.cs
@@ -149,6 +149,8 @@ namespace OpenSim.Region.Physics.POSPlugin
149 149
150 } 150 }
151 151
152 public override void VehicleFlags(int param, bool remove) { }
153
152 public override void SetVolumeDetect(int param) 154 public override void SetVolumeDetect(int param)
153 { 155 {
154 156
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXCharacter.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXCharacter.cs
new file mode 100644
index 0000000..fc3adac
--- /dev/null
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXCharacter.cs
@@ -0,0 +1,361 @@
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 Nini.Config;
31using OpenSim.Framework;
32using OpenSim.Region.Physics.Manager;
33using PhysXWrapper;
34using Quaternion=OpenMetaverse.Quaternion;
35using System.Reflection;
36using log4net;
37using OpenMetaverse;
38
39namespace OpenSim.Region.Physics.PhysXPlugin
40{
41 public class PhysXCharacter : PhysicsActor
42 {
43 private Vector3 _position;
44 private Vector3 _velocity;
45 private Vector3 m_rotationalVelocity = Vector3.Zero;
46 private Vector3 _acceleration;
47 private NxCharacter _character;
48 private bool flying;
49 private bool iscolliding = false;
50 private float gravityAccel;
51
52 public PhysXCharacter(NxCharacter character)
53 {
54 _character = character;
55 }
56
57 public override int PhysicsActorType
58 {
59 get { return (int) ActorTypes.Agent; }
60 set { return; }
61 }
62
63 public override bool SetAlwaysRun
64 {
65 get { return false; }
66 set { return; }
67 }
68
69 public override uint LocalID
70 {
71 set { return; }
72 }
73
74 public override bool Grabbed
75 {
76 set { return; }
77 }
78
79 public override bool Selected
80 {
81 set { return; }
82 }
83
84 public override float Buoyancy
85 {
86 get { return 0f; }
87 set { return; }
88 }
89
90 public override bool FloatOnWater
91 {
92 set { return; }
93 }
94
95 public override bool IsPhysical
96 {
97 get { return false; }
98 set { return; }
99 }
100
101 public override bool ThrottleUpdates
102 {
103 get { return false; }
104 set { return; }
105 }
106
107 public override bool Flying
108 {
109 get { return flying; }
110 set { flying = value; }
111 }
112
113 public override bool IsColliding
114 {
115 get { return iscolliding; }
116 set { iscolliding = value; }
117 }
118
119 public override bool CollidingGround
120 {
121 get { return false; }
122 set { return; }
123 }
124
125 public override bool CollidingObj
126 {
127 get { return false; }
128 set { return; }
129 }
130
131 public override Vector3 RotationalVelocity
132 {
133 get { return m_rotationalVelocity; }
134 set { m_rotationalVelocity = value; }
135 }
136
137 public override bool Stopped
138 {
139 get { return false; }
140 }
141
142 public override Vector3 Position
143 {
144 get { return _position; }
145 set
146 {
147 _position = value;
148 Vec3 ps = new Vec3();
149 ps.X = value.X;
150 ps.Y = value.Y;
151 ps.Z = value.Z;
152 _character.Position = ps;
153 }
154 }
155
156 public override Vector3 Size
157 {
158 get { return Vector3.Zero; }
159 set { }
160 }
161
162 public override float Mass
163 {
164 get { return 0f; }
165 }
166
167 public override Vector3 Force
168 {
169 get { return Vector3.Zero; }
170 set { return; }
171 }
172
173 public override int VehicleType
174 {
175 get { return 0; }
176 set { return; }
177 }
178
179 public override void VehicleFloatParam(int param, float value)
180 {
181 }
182
183 public override void VehicleVectorParam(int param, Vector3 value)
184 {
185 }
186
187 public override void VehicleRotationParam(int param, Quaternion rotation)
188 {
189 }
190
191 public override void VehicleFlagsSet(int param)
192 {
193 }
194
195 public override void VehicleFlagsRemove(int param)
196 {
197 }
198
199 public override void VehicleFlags(int param, bool remove)
200 {
201 }
202
203 public override void SetVolumeDetect(int param)
204 {
205 }
206
207 public override Vector3 CenterOfMass
208 {
209 get { return Vector3.Zero; }
210 }
211
212 public override Vector3 GeometricCenter
213 {
214 get { return Vector3.Zero; }
215 }
216
217 public override Vector3 Velocity
218 {
219 get { return _velocity; }
220 set { _velocity = value; }
221 }
222
223 public override float CollisionScore
224 {
225 get { return 0f; }
226 set { }
227 }
228
229 public override bool Kinematic
230 {
231 get { return false; }
232 set { }
233 }
234
235 public override Quaternion Orientation
236 {
237 get { return Quaternion.Identity; }
238 set { }
239 }
240
241 public override Vector3 Acceleration
242 {
243 get { return _acceleration; }
244 }
245
246 public void SetAcceleration(Vector3 accel)
247 {
248 _acceleration = accel;
249 }
250
251 public override void AddForce(Vector3 force, bool pushforce)
252 {
253 }
254
255 public override Vector3 Torque
256 {
257 get { return Vector3.Zero; }
258 set { return; }
259 }
260
261 public override void AddAngularForce(Vector3 force, bool pushforce)
262 {
263 }
264
265 public override void link(PhysicsActor obj)
266 {
267 }
268
269 public override void delink()
270 {
271 }
272
273 public override void LockAngularMotion(Vector3 axis)
274 {
275 }
276
277 public override void SetMomentum(Vector3 momentum)
278 {
279 }
280
281 public void Move(float timeStep)
282 {
283 Vec3 vec = new Vec3();
284 vec.X = _velocity.X*timeStep;
285 vec.Y = _velocity.Y*timeStep;
286 if (flying)
287 {
288 vec.Z = (_velocity.Z)*timeStep;
289 }
290 else
291 {
292 gravityAccel += -9.8f;
293 vec.Z = (gravityAccel + _velocity.Z)*timeStep;
294 }
295 int res = _character.Move(vec);
296 if (res == 1)
297 {
298 gravityAccel = 0;
299 }
300 }
301
302 public override PrimitiveBaseShape Shape
303 {
304 set { return; }
305 }
306
307 public void UpdatePosition()
308 {
309 Vec3 vec = _character.Position;
310 _position.X = vec.X;
311 _position.Y = vec.Y;
312 _position.Z = vec.Z;
313 }
314
315 public override void CrossingFailure()
316 {
317 }
318
319 public override Vector3 PIDTarget { set { return; } }
320 public override bool PIDActive { set { return; } }
321 public override float PIDTau { set { return; } }
322
323 public override float PIDHoverHeight { set { return; } }
324 public override bool PIDHoverActive { set { return; } }
325 public override PIDHoverType PIDHoverType { set { return; } }
326 public override float PIDHoverTau { set { return; } }
327
328 public override Quaternion APIDTarget
329 {
330 set { return; }
331 }
332
333 public override bool APIDActive
334 {
335 set { return; }
336 }
337
338 public override float APIDStrength
339 {
340 set { return; }
341 }
342
343 public override float APIDDamping
344 {
345 set { return; }
346 }
347
348 public override void SubscribeEvents(int ms)
349 {
350
351 }
352 public override void UnSubscribeEvents()
353 {
354
355 }
356 public override bool SubscribedEvents()
357 {
358 return false;
359 }
360 }
361}
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
deleted file mode 100644
index e54065c..0000000
--- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
+++ /dev/null
@@ -1,861 +0,0 @@
1/*/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using Nini.Config;
31using OpenSim.Framework;
32using OpenSim.Region.Physics.Manager;
33using PhysXWrapper;
34using Quaternion=OpenMetaverse.Quaternion;
35using System.Reflection;
36using log4net;
37using OpenMetaverse;
38
39namespace OpenSim.Region.Physics.PhysXPlugin
40{
41 /// <summary>
42 /// Will be the PhysX plugin but for now will be a very basic physics engine
43 /// </summary>
44 public class PhysXPlugin : IPhysicsPlugin
45 {
46 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 private PhysXScene _mScene;
48
49 public PhysXPlugin()
50 {
51 }
52
53 public bool Init()
54 {
55 return true;
56 }
57
58 public PhysicsScene GetScene(string sceneIdentifier)
59 {
60 if (_mScene == null)
61 {
62 _mScene = new PhysXScene(sceneIdentifier);
63 }
64 return (_mScene);
65 }
66
67 public string GetName()
68 {
69 return ("RealPhysX");
70 }
71
72 public void Dispose()
73 {
74 }
75 }
76
77 public class PhysXScene : PhysicsScene
78 {
79 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
80 private List<PhysXCharacter> _characters = new List<PhysXCharacter>();
81 private List<PhysXPrim> _prims = new List<PhysXPrim>();
82 private float[] _heightMap = null;
83 private NxPhysicsSDK mySdk;
84 private NxScene scene;
85
86 // protected internal string sceneIdentifier;
87 public PhysXScene(string _sceneIdentifier)
88 {
89 //sceneIdentifier = _sceneIdentifier;
90
91 mySdk = NxPhysicsSDK.CreateSDK();
92 m_log.Info("Sdk created - now creating scene");
93 scene = mySdk.CreateScene();
94 }
95
96 public override void Initialise(IMesher meshmerizer, IConfigSource config)
97 {
98 // Does nothing right now
99 }
100 public override void Dispose()
101 {
102
103 }
104
105 public override void SetWaterLevel(float baseheight)
106 {
107
108 }
109
110 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
111 {
112 Vec3 pos = new Vec3();
113 pos.X = position.X;
114 pos.Y = position.Y;
115 pos.Z = position.Z;
116 PhysXCharacter act = new PhysXCharacter(scene.AddCharacter(pos));
117 act.Flying = isFlying;
118 act.Position = position;
119 _characters.Add(act);
120 return act;
121 }
122
123 public override void RemovePrim(PhysicsActor prim)
124 {
125 }
126
127 public override void RemoveAvatar(PhysicsActor actor)
128 {
129 }
130
131 private PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
132 {
133 Vec3 pos = new Vec3();
134 pos.X = position.X;
135 pos.Y = position.Y;
136 pos.Z = position.Z;
137 Vec3 siz = new Vec3();
138 siz.X = size.X;
139 siz.Y = size.Y;
140 siz.Z = size.Z;
141 PhysXPrim act = new PhysXPrim(scene.AddNewBox(pos, siz));
142 _prims.Add(act);
143 return act;
144 }
145
146 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
147 Vector3 size, Quaternion rotation) //To be removed
148 {
149 return AddPrimShape(primName, pbs, position, size, rotation, false);
150 }
151
152 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
153 Vector3 size, Quaternion rotation, bool isPhysical)
154 {
155 return AddPrim(position, size, rotation);
156 }
157
158 public override void AddPhysicsActorTaint(PhysicsActor prim)
159 {
160 }
161
162 public override float Simulate(float timeStep)
163 {
164 float fps = 0f;
165 try
166 {
167 foreach (PhysXCharacter actor in _characters)
168 {
169 actor.Move(timeStep);
170 }
171 scene.Simulate(timeStep);
172 scene.FetchResults();
173 scene.UpdateControllers();
174
175 foreach (PhysXCharacter actor in _characters)
176 {
177 actor.UpdatePosition();
178 }
179 }
180 catch (Exception e)
181 {
182 m_log.Error(e.Message);
183 }
184 return fps;
185 }
186
187 public override void GetResults()
188 {
189 }
190
191 public override bool IsThreaded
192 {
193 get { return (false); // for now we won't be multithreaded
194 }
195 }
196
197 public override void SetTerrain(float[] heightMap)
198 {
199 if (_heightMap != null)
200 {
201 m_log.Debug("PhysX - deleting old terrain");
202 scene.DeleteTerrain();
203 }
204 _heightMap = heightMap;
205 scene.AddTerrain(heightMap);
206 }
207
208 public override void DeleteTerrain()
209 {
210 scene.DeleteTerrain();
211 }
212
213 public override Dictionary<uint, float> GetTopColliders()
214 {
215 Dictionary<uint, float> returncolliders = new Dictionary<uint, float>();
216 return returncolliders;
217 }
218
219 }
220
221 public class PhysXCharacter : PhysicsActor
222 {
223 private Vector3 _position;
224 private Vector3 _velocity;
225 private Vector3 m_rotationalVelocity = Vector3.Zero;
226 private Vector3 _acceleration;
227 private NxCharacter _character;
228 private bool flying;
229 private bool iscolliding = false;
230 private float gravityAccel;
231
232 public PhysXCharacter(NxCharacter character)
233 {
234 _character = character;
235 }
236
237 public override int PhysicsActorType
238 {
239 get { return (int) ActorTypes.Agent; }
240 set { return; }
241 }
242
243 public override bool SetAlwaysRun
244 {
245 get { return false; }
246 set { return; }
247 }
248
249 public override uint LocalID
250 {
251 set { return; }
252 }
253
254 public override bool Grabbed
255 {
256 set { return; }
257 }
258
259 public override bool Selected
260 {
261 set { return; }
262 }
263
264 public override float Buoyancy
265 {
266 get { return 0f; }
267 set { return; }
268 }
269
270 public override bool FloatOnWater
271 {
272 set { return; }
273 }
274
275 public override bool IsPhysical
276 {
277 get { return false; }
278 set { return; }
279 }
280
281 public override bool ThrottleUpdates
282 {
283 get { return false; }
284 set { return; }
285 }
286
287 public override bool Flying
288 {
289 get { return flying; }
290 set { flying = value; }
291 }
292
293 public override bool IsColliding
294 {
295 get { return iscolliding; }
296 set { iscolliding = value; }
297 }
298
299 public override bool CollidingGround
300 {
301 get { return false; }
302 set { return; }
303 }
304
305 public override bool CollidingObj
306 {
307 get { return false; }
308 set { return; }
309 }
310
311 public override Vector3 RotationalVelocity
312 {
313 get { return m_rotationalVelocity; }
314 set { m_rotationalVelocity = value; }
315 }
316
317 public override bool Stopped
318 {
319 get { return false; }
320 }
321
322 public override Vector3 Position
323 {
324 get { return _position; }
325 set
326 {
327 _position = value;
328 Vec3 ps = new Vec3();
329 ps.X = value.X;
330 ps.Y = value.Y;
331 ps.Z = value.Z;
332 _character.Position = ps;
333 }
334 }
335
336 public override Vector3 Size
337 {
338 get { return Vector3.Zero; }
339 set { }
340 }
341
342 public override float Mass
343 {
344 get { return 0f; }
345 }
346
347 public override Vector3 Force
348 {
349 get { return Vector3.Zero; }
350 set { return; }
351 }
352
353 public override int VehicleType
354 {
355 get { return 0; }
356 set { return; }
357 }
358
359 public override void VehicleFloatParam(int param, float value)
360 {
361
362 }
363
364 public override void VehicleVectorParam(int param, Vector3 value)
365 {
366
367 }
368
369 public override void VehicleRotationParam(int param, Quaternion rotation)
370 {
371
372 }
373
374 public override void VehicleFlagsSet(int flags)
375 {
376
377 }
378
379 public override void VehicleFlagsRemove(int flags)
380 {
381
382 }
383
384 public override void SetVolumeDetect(int param)
385 {
386
387 }
388
389
390 public override Vector3 CenterOfMass
391 {
392 get { return Vector3.Zero; }
393 }
394
395 public override Vector3 GeometricCenter
396 {
397 get { return Vector3.Zero; }
398 }
399
400 public override Vector3 Velocity
401 {
402 get { return _velocity; }
403 set { _velocity = value; }
404 }
405
406 public override float CollisionScore
407 {
408 get { return 0f; }
409 set { }
410 }
411
412 public override bool Kinematic
413 {
414 get { return false; }
415 set { }
416 }
417
418 public override Quaternion Orientation
419 {
420 get { return Quaternion.Identity; }
421 set { }
422 }
423
424 public override Vector3 Acceleration
425 {
426 get { return _acceleration; }
427 }
428
429 public void SetAcceleration(Vector3 accel)
430 {
431 _acceleration = accel;
432 }
433
434 public override void AddForce(Vector3 force, bool pushforce)
435 {
436 }
437 public override Vector3 Torque
438 {
439 get { return Vector3.Zero; }
440 set { return; }
441 }
442 public override void AddAngularForce(Vector3 force, bool pushforce)
443 {
444 }
445
446 public override void link(PhysicsActor obj)
447 {
448
449 }
450
451 public override void delink()
452 {
453
454 }
455
456 public override void LockAngularMotion(Vector3 axis)
457 {
458
459 }
460
461 public override void SetMomentum(Vector3 momentum)
462 {
463 }
464
465 public void Move(float timeStep)
466 {
467 Vec3 vec = new Vec3();
468 vec.X = _velocity.X*timeStep;
469 vec.Y = _velocity.Y*timeStep;
470 if (flying)
471 {
472 vec.Z = (_velocity.Z)*timeStep;
473 }
474 else
475 {
476 gravityAccel += -9.8f;
477 vec.Z = (gravityAccel + _velocity.Z)*timeStep;
478 }
479 int res = _character.Move(vec);
480 if (res == 1)
481 {
482 gravityAccel = 0;
483 }
484 }
485
486 public override PrimitiveBaseShape Shape
487 {
488 set { return; }
489 }
490
491 public void UpdatePosition()
492 {
493 Vec3 vec = _character.Position;
494 _position.X = vec.X;
495 _position.Y = vec.Y;
496 _position.Z = vec.Z;
497 }
498 public override void CrossingFailure()
499 {
500
501 }
502
503 public override Vector3 PIDTarget { set { return; } }
504 public override bool PIDActive { set { return; } }
505 public override float PIDTau { set { return; } }
506
507 public override float PIDHoverHeight { set { return; } }
508 public override bool PIDHoverActive { set { return; } }
509 public override PIDHoverType PIDHoverType { set { return; } }
510 public override float PIDHoverTau { set { return; } }
511
512 public override Quaternion APIDTarget
513 {
514 set { return; }
515 }
516
517 public override bool APIDActive
518 {
519 set { return; }
520 }
521
522 public override float APIDStrength
523 {
524 set { return; }
525 }
526
527 public override float APIDDamping
528 {
529 set { return; }
530 }
531
532
533
534 public override void SubscribeEvents(int ms)
535 {
536
537 }
538 public override void UnSubscribeEvents()
539 {
540
541 }
542 public override bool SubscribedEvents()
543 {
544 return false;
545 }
546 }
547
548
549 public class PhysXPrim : PhysicsActor
550 {
551 private Vector3 _velocity;
552 private Vector3 _acceleration;
553 private Vector3 m_rotationalVelocity;
554 private NxActor _prim;
555
556 public PhysXPrim(NxActor prim)
557 {
558 _velocity = Vector3.Zero;
559 _acceleration = Vector3.Zero;
560 _prim = prim;
561 }
562
563 public override int PhysicsActorType
564 {
565 get { return (int) ActorTypes.Prim; }
566 set { return; }
567 }
568
569 public override bool IsPhysical
570 {
571 get { return false; }
572 set { return; }
573 }
574
575 public override bool SetAlwaysRun
576 {
577 get { return false; }
578 set { return; }
579 }
580
581 public override uint LocalID
582 {
583 set { return; }
584 }
585
586 public override bool Grabbed
587 {
588 set { return; }
589 }
590
591 public override bool Selected
592 {
593 set { return; }
594 }
595
596 public override float Buoyancy
597 {
598 get { return 0f; }
599 set { return; }
600 }
601
602 public override bool FloatOnWater
603 {
604 set { return; }
605 }
606
607 public override bool ThrottleUpdates
608 {
609 get { return false; }
610 set { return; }
611 }
612
613 public override Vector3 RotationalVelocity
614 {
615 get { return m_rotationalVelocity; }
616 set { m_rotationalVelocity = value; }
617 }
618
619 public override bool Flying
620 {
621 get { return false; //no flying prims for you
622 }
623 set { }
624 }
625
626 public override bool IsColliding
627 {
628 get { return false; }
629 set { }
630 }
631
632 public override bool CollidingGround
633 {
634 get { return false; }
635 set { return; }
636 }
637
638 public override bool CollidingObj
639 {
640 get { return false; }
641 set { return; }
642 }
643
644 public override bool Stopped
645 {
646 get { return false; }
647 }
648
649 public override Vector3 Position
650 {
651 get
652 {
653 Vector3 pos = Vector3.Zero;
654 Vec3 vec = _prim.Position;
655 pos.X = vec.X;
656 pos.Y = vec.Y;
657 pos.Z = vec.Z;
658 return pos;
659 }
660 set
661 {
662 Vector3 vec = value;
663 Vec3 pos = new Vec3();
664 pos.X = vec.X;
665 pos.Y = vec.Y;
666 pos.Z = vec.Z;
667 _prim.Position = pos;
668 }
669 }
670
671 public override PrimitiveBaseShape Shape
672 {
673 set { return; }
674 }
675
676 public override Vector3 Velocity
677 {
678 get { return _velocity; }
679 set { _velocity = value; }
680 }
681
682 public override Vector3 Torque
683 {
684 get { return Vector3.Zero; }
685 set { return; }
686 }
687
688 public override float CollisionScore
689 {
690 get { return 0f; }
691 set { }
692 }
693
694 public override bool Kinematic
695 {
696 get { return _prim.Kinematic; }
697 set { _prim.Kinematic = value; }
698 }
699
700 public override Quaternion Orientation
701 {
702 get
703 {
704 Quaternion res;
705 PhysXWrapper.Quaternion quat = _prim.GetOrientation();
706 res.W = quat.W;
707 res.X = quat.X;
708 res.Y = quat.Y;
709 res.Z = quat.Z;
710 return res;
711 }
712 set { }
713 }
714
715 public override Vector3 Acceleration
716 {
717 get { return _acceleration; }
718 }
719
720 public void SetAcceleration(Vector3 accel)
721 {
722 _acceleration = accel;
723 }
724
725 public override void AddForce(Vector3 force, bool pushforce)
726 {
727 }
728
729 public override void AddAngularForce(Vector3 force, bool pushforce)
730 {
731 }
732
733 public override void SetMomentum(Vector3 momentum)
734 {
735 }
736
737 public override Vector3 Size
738 {
739 get { return Vector3.Zero; }
740 set { }
741 }
742
743 public override void link(PhysicsActor obj)
744 {
745 }
746
747 public override void delink()
748 {
749 }
750
751 public override void LockAngularMotion(Vector3 axis)
752 {
753
754 }
755
756 public override float Mass
757 {
758 get { return 0f; }
759 }
760
761 public override Vector3 Force
762 {
763 get { return Vector3.Zero; }
764 set { return; }
765 }
766
767 public override int VehicleType
768 {
769 get { return 0; }
770 set { return; }
771 }
772
773 public override void VehicleFloatParam(int param, float value)
774 {
775
776 }
777
778 public override void VehicleVectorParam(int param, Vector3 value)
779 {
780
781 }
782
783 public override void VehicleRotationParam(int param, Quaternion rotation)
784 {
785
786 }
787
788 public override void VehicleFlagsSet(int flags)
789 {
790
791 }
792
793 public override void VehicleFlagsRemove(int flags)
794 {
795
796 }
797
798 public override void SetVolumeDetect(int param)
799 {
800
801 }
802
803 public override Vector3 CenterOfMass
804 {
805 get { return Vector3.Zero; }
806 }
807
808 public override Vector3 GeometricCenter
809 {
810 get { return Vector3.Zero; }
811 }
812
813 public override void CrossingFailure()
814 {
815 }
816
817 public override Vector3 PIDTarget { set { return; } }
818 public override bool PIDActive { set { return; } }
819 public override float PIDTau { set { return; } }
820
821 public override float PIDHoverHeight { set { return; } }
822 public override bool PIDHoverActive { set { return; } }
823 public override PIDHoverType PIDHoverType { set { return; } }
824 public override float PIDHoverTau { set { return; } }
825
826 public override Quaternion APIDTarget
827 {
828 set { return; }
829 }
830
831 public override bool APIDActive
832 {
833 set { return; }
834 }
835
836 public override float APIDStrength
837 {
838 set { return; }
839 }
840
841 public override float APIDDamping
842 {
843 set { return; }
844 }
845
846
847
848 public override void SubscribeEvents(int ms)
849 {
850
851 }
852 public override void UnSubscribeEvents()
853 {
854
855 }
856 public override bool SubscribedEvents()
857 {
858 return false;
859 }
860 }
861}
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPrim.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPrim.cs
new file mode 100644
index 0000000..dc70c80
--- /dev/null
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPrim.cs
@@ -0,0 +1,347 @@
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 Nini.Config;
31using OpenSim.Framework;
32using OpenSim.Region.Physics.Manager;
33using PhysXWrapper;
34using Quaternion=OpenMetaverse.Quaternion;
35using System.Reflection;
36using log4net;
37using OpenMetaverse;
38
39namespace OpenSim.Region.Physics.PhysXPlugin
40{
41 public class PhysXPrim : PhysicsActor
42 {
43 private Vector3 _velocity;
44 private Vector3 _acceleration;
45 private Vector3 m_rotationalVelocity;
46 private NxActor _prim;
47
48 public PhysXPrim(NxActor prim)
49 {
50 _velocity = Vector3.Zero;
51 _acceleration = Vector3.Zero;
52 _prim = prim;
53 }
54
55 public override int PhysicsActorType
56 {
57 get { return (int) ActorTypes.Prim; }
58 set { return; }
59 }
60
61 public override bool IsPhysical
62 {
63 get { return false; }
64 set { return; }
65 }
66
67 public override bool SetAlwaysRun
68 {
69 get { return false; }
70 set { return; }
71 }
72
73 public override uint LocalID
74 {
75 set { return; }
76 }
77
78 public override bool Grabbed
79 {
80 set { return; }
81 }
82
83 public override bool Selected
84 {
85 set { return; }
86 }
87
88 public override float Buoyancy
89 {
90 get { return 0f; }
91 set { return; }
92 }
93
94 public override bool FloatOnWater
95 {
96 set { return; }
97 }
98
99 public override bool ThrottleUpdates
100 {
101 get { return false; }
102 set { return; }
103 }
104
105 public override Vector3 RotationalVelocity
106 {
107 get { return m_rotationalVelocity; }
108 set { m_rotationalVelocity = value; }
109 }
110
111 public override bool Flying
112 {
113 get { return false; //no flying prims for you
114 }
115 set { }
116 }
117
118 public override bool IsColliding
119 {
120 get { return false; }
121 set { }
122 }
123
124 public override bool CollidingGround
125 {
126 get { return false; }
127 set { return; }
128 }
129
130 public override bool CollidingObj
131 {
132 get { return false; }
133 set { return; }
134 }
135
136 public override bool Stopped
137 {
138 get { return false; }
139 }
140
141 public override Vector3 Position
142 {
143 get
144 {
145 Vector3 pos = Vector3.Zero;
146 Vec3 vec = _prim.Position;
147 pos.X = vec.X;
148 pos.Y = vec.Y;
149 pos.Z = vec.Z;
150 return pos;
151 }
152 set
153 {
154 Vector3 vec = value;
155 Vec3 pos = new Vec3();
156 pos.X = vec.X;
157 pos.Y = vec.Y;
158 pos.Z = vec.Z;
159 _prim.Position = pos;
160 }
161 }
162
163 public override PrimitiveBaseShape Shape
164 {
165 set { return; }
166 }
167
168 public override Vector3 Velocity
169 {
170 get { return _velocity; }
171 set { _velocity = value; }
172 }
173
174 public override Vector3 Torque
175 {
176 get { return Vector3.Zero; }
177 set { return; }
178 }
179
180 public override float CollisionScore
181 {
182 get { return 0f; }
183 set { }
184 }
185
186 public override bool Kinematic
187 {
188 get { return _prim.Kinematic; }
189 set { _prim.Kinematic = value; }
190 }
191
192 public override Quaternion Orientation
193 {
194 get
195 {
196 Quaternion res;
197 PhysXWrapper.Quaternion quat = _prim.GetOrientation();
198 res.W = quat.W;
199 res.X = quat.X;
200 res.Y = quat.Y;
201 res.Z = quat.Z;
202 return res;
203 }
204 set { }
205 }
206
207 public override Vector3 Acceleration
208 {
209 get { return _acceleration; }
210 }
211
212 public void SetAcceleration(Vector3 accel)
213 {
214 _acceleration = accel;
215 }
216
217 public override void AddForce(Vector3 force, bool pushforce)
218 {
219 }
220
221 public override void AddAngularForce(Vector3 force, bool pushforce)
222 {
223 }
224
225 public override void SetMomentum(Vector3 momentum)
226 {
227 }
228
229 public override Vector3 Size
230 {
231 get { return Vector3.Zero; }
232 set { }
233 }
234
235 public override void link(PhysicsActor obj)
236 {
237 }
238
239 public override void delink()
240 {
241 }
242
243 public override void LockAngularMotion(Vector3 axis)
244 {
245
246 }
247
248 public override float Mass
249 {
250 get { return 0f; }
251 }
252
253 public override Vector3 Force
254 {
255 get { return Vector3.Zero; }
256 set { return; }
257 }
258
259 public override int VehicleType
260 {
261 get { return 0; }
262 set { return; }
263 }
264
265 public override void VehicleFloatParam(int param, float value)
266 {
267
268 }
269
270 public override void VehicleVectorParam(int param, Vector3 value)
271 {
272
273 }
274
275 public override void VehicleRotationParam(int param, Quaternion rotation)
276 {
277
278 }
279
280 public override void VehicleFlagsSet(int param) { }
281 public override void VehicleFlagsRemove(int param) { }
282 public override void VehicleFlags(int param, bool remove) { }
283
284 public override void SetVolumeDetect(int param)
285 {
286
287 }
288
289 public override Vector3 CenterOfMass
290 {
291 get { return Vector3.Zero; }
292 }
293
294 public override Vector3 GeometricCenter
295 {
296 get { return Vector3.Zero; }
297 }
298
299 public override void CrossingFailure()
300 {
301 }
302
303 public override Vector3 PIDTarget { set { return; } }
304 public override bool PIDActive { set { return; } }
305 public override float PIDTau { set { return; } }
306
307 public override float PIDHoverHeight { set { return; } }
308 public override bool PIDHoverActive { set { return; } }
309 public override PIDHoverType PIDHoverType { set { return; } }
310 public override float PIDHoverTau { set { return; } }
311
312 public override Quaternion APIDTarget
313 {
314 set { return; }
315 }
316
317 public override bool APIDActive
318 {
319 set { return; }
320 }
321
322 public override float APIDStrength
323 {
324 set { return; }
325 }
326
327 public override float APIDDamping
328 {
329 set { return; }
330 }
331
332
333
334 public override void SubscribeEvents(int ms)
335 {
336
337 }
338 public override void UnSubscribeEvents()
339 {
340
341 }
342 public override bool SubscribedEvents()
343 {
344 return false;
345 }
346 }
347}
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs
new file mode 100644
index 0000000..4de4b01
--- /dev/null
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs
@@ -0,0 +1,183 @@
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 Nini.Config;
31using OpenSim.Framework;
32using OpenSim.Region.Physics.Manager;
33using PhysXWrapper;
34using Quaternion=OpenMetaverse.Quaternion;
35using System.Reflection;
36using log4net;
37using OpenMetaverse;
38
39namespace OpenSim.Region.Physics.PhysXPlugin
40{
41 public class PhysXScene : PhysicsScene
42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 private List<PhysXCharacter> _characters = new List<PhysXCharacter>();
45 private List<PhysXPrim> _prims = new List<PhysXPrim>();
46 private float[] _heightMap = null;
47 private NxPhysicsSDK mySdk;
48 private NxScene scene;
49
50 // protected internal string sceneIdentifier;
51 public PhysXScene(string _sceneIdentifier)
52 {
53 //sceneIdentifier = _sceneIdentifier;
54
55 mySdk = NxPhysicsSDK.CreateSDK();
56 m_log.Info("Sdk created - now creating scene");
57 scene = mySdk.CreateScene();
58 }
59
60 public override void Initialise(IMesher meshmerizer, IConfigSource config)
61 {
62 // Does nothing right now
63 }
64 public override void Dispose()
65 {
66
67 }
68
69 public override void SetWaterLevel(float baseheight)
70 {
71
72 }
73
74 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
75 {
76 Vec3 pos = new Vec3();
77 pos.X = position.X;
78 pos.Y = position.Y;
79 pos.Z = position.Z;
80 PhysXCharacter act = new PhysXCharacter(scene.AddCharacter(pos));
81 act.Flying = isFlying;
82 act.Position = position;
83 _characters.Add(act);
84 return act;
85 }
86
87 public override void RemovePrim(PhysicsActor prim)
88 {
89 }
90
91 public override void RemoveAvatar(PhysicsActor actor)
92 {
93 }
94
95 private PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
96 {
97 Vec3 pos = new Vec3();
98 pos.X = position.X;
99 pos.Y = position.Y;
100 pos.Z = position.Z;
101 Vec3 siz = new Vec3();
102 siz.X = size.X;
103 siz.Y = size.Y;
104 siz.Z = size.Z;
105 PhysXPrim act = new PhysXPrim(scene.AddNewBox(pos, siz));
106 _prims.Add(act);
107 return act;
108 }
109
110 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
111 Vector3 size, Quaternion rotation) //To be removed
112 {
113 return AddPrimShape(primName, pbs, position, size, rotation, false);
114 }
115
116 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
117 Vector3 size, Quaternion rotation, bool isPhysical)
118 {
119 return AddPrim(position, size, rotation);
120 }
121
122 public override void AddPhysicsActorTaint(PhysicsActor prim)
123 {
124 }
125
126 public override float Simulate(float timeStep)
127 {
128 float fps = 0f;
129 try
130 {
131 foreach (PhysXCharacter actor in _characters)
132 {
133 actor.Move(timeStep);
134 }
135 scene.Simulate(timeStep);
136 scene.FetchResults();
137 scene.UpdateControllers();
138
139 foreach (PhysXCharacter actor in _characters)
140 {
141 actor.UpdatePosition();
142 }
143 }
144 catch (Exception e)
145 {
146 m_log.Error(e.Message);
147 }
148 return fps;
149 }
150
151 public override void GetResults()
152 {
153 }
154
155 public override bool IsThreaded
156 {
157 // for now we won't be multithreaded
158 get { return (false); }
159 }
160
161 public override void SetTerrain(float[] heightMap)
162 {
163 if (_heightMap != null)
164 {
165 m_log.Debug("PhysX - deleting old terrain");
166 scene.DeleteTerrain();
167 }
168 _heightMap = heightMap;
169 scene.AddTerrain(heightMap);
170 }
171
172 public override void DeleteTerrain()
173 {
174 scene.DeleteTerrain();
175 }
176
177 public override Dictionary<uint, float> GetTopColliders()
178 {
179 Dictionary<uint, float> returncolliders = new Dictionary<uint, float>();
180 return returncolliders;
181 }
182 }
183}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 7a6739b..3f9c026 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -39,7 +39,7 @@ using OpenMetaverse;
39using OpenMetaverse.Packets; 39using OpenMetaverse.Packets;
40using OpenSim; 40using OpenSim;
41using OpenSim.Framework; 41using OpenSim.Framework;
42using OpenSim.Framework.Communications.Cache; 42
43using OpenSim.Region.CoreModules; 43using OpenSim.Region.CoreModules;
44using OpenSim.Region.CoreModules.World.Land; 44using OpenSim.Region.CoreModules.World.Land;
45using OpenSim.Region.CoreModules.World.Terrain; 45using OpenSim.Region.CoreModules.World.Terrain;
@@ -53,9 +53,10 @@ using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
53using OpenSim.Region.ScriptEngine.Interfaces; 53using OpenSim.Region.ScriptEngine.Interfaces;
54using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; 54using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
55using OpenSim.Services.Interfaces; 55using OpenSim.Services.Interfaces;
56 56using OpenSim.Services.Interfaces;
57using PrimType = OpenSim.Region.Framework.Scenes.PrimType;
58using GridRegion = OpenSim.Services.Interfaces.GridRegion; 57using GridRegion = OpenSim.Services.Interfaces.GridRegion;
58using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
59using PrimType = OpenSim.Region.Framework.Scenes.PrimType;
59using AssetLandmark = OpenSim.Framework.AssetLandmark; 60using AssetLandmark = OpenSim.Framework.AssetLandmark;
60 61
61using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; 62using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
@@ -917,10 +918,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
917 public string resolveName(UUID objecUUID) 918 public string resolveName(UUID objecUUID)
918 { 919 {
919 // try avatar username surname 920 // try avatar username surname
920 CachedUserInfo profile = World.CommsManager.UserProfileCacheService.GetUserDetails(objecUUID); 921 UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, objecUUID);
921 if (profile != null && profile.UserProfile != null) 922 if (account != null)
922 { 923 {
923 string avatarname = profile.UserProfile.FirstName + " " + profile.UserProfile.SurName; 924 string avatarname = account.Name;
924 return avatarname; 925 return avatarname;
925 } 926 }
926 // try an scene object 927 // try an scene object
@@ -1252,7 +1253,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1252 1253
1253 if ((status & ScriptBaseClass.STATUS_BLOCK_GRAB) == ScriptBaseClass.STATUS_BLOCK_GRAB) 1254 if ((status & ScriptBaseClass.STATUS_BLOCK_GRAB) == ScriptBaseClass.STATUS_BLOCK_GRAB)
1254 { 1255 {
1255 NotImplemented("llSetStatus - STATUS_BLOCK_GRAB"); 1256 if (value != 0)
1257 m_host.SetBlockGrab(true);
1258 else
1259 m_host.SetBlockGrab(false);
1256 } 1260 }
1257 1261
1258 if ((status & ScriptBaseClass.STATUS_DIE_AT_EDGE) == ScriptBaseClass.STATUS_DIE_AT_EDGE) 1262 if ((status & ScriptBaseClass.STATUS_DIE_AT_EDGE) == ScriptBaseClass.STATUS_DIE_AT_EDGE)
@@ -1265,12 +1269,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1265 1269
1266 if ((status & ScriptBaseClass.STATUS_RETURN_AT_EDGE) == ScriptBaseClass.STATUS_RETURN_AT_EDGE) 1270 if ((status & ScriptBaseClass.STATUS_RETURN_AT_EDGE) == ScriptBaseClass.STATUS_RETURN_AT_EDGE)
1267 { 1271 {
1268 NotImplemented("llSetStatus - STATUS_RETURN_AT_EDGE"); 1272 if (value != 0)
1273 m_host.SetReturnAtEdge(true);
1274 else
1275 m_host.SetReturnAtEdge(false);
1269 } 1276 }
1270 1277
1271 if ((status & ScriptBaseClass.STATUS_SANDBOX) == ScriptBaseClass.STATUS_SANDBOX) 1278 if ((status & ScriptBaseClass.STATUS_SANDBOX) == ScriptBaseClass.STATUS_SANDBOX)
1272 { 1279 {
1273 NotImplemented("llSetStatus - STATUS_SANDBOX"); 1280 if (value != 0)
1281 m_host.SetStatusSandbox(true);
1282 else
1283 m_host.SetStatusSandbox(false);
1274 } 1284 }
1275 1285
1276 if (statusrotationaxis != 0) 1286 if (statusrotationaxis != 0)
@@ -1307,8 +1317,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1307 return 0; 1317 return 0;
1308 1318
1309 case ScriptBaseClass.STATUS_BLOCK_GRAB: 1319 case ScriptBaseClass.STATUS_BLOCK_GRAB:
1310 NotImplemented("llGetStatus - STATUS_BLOCK_GRAB"); 1320 if (m_host.GetBlockGrab())
1311 return 0; 1321 return 1;
1322 else
1323 return 0;
1312 1324
1313 case ScriptBaseClass.STATUS_DIE_AT_EDGE: 1325 case ScriptBaseClass.STATUS_DIE_AT_EDGE:
1314 if (m_host.GetDieAtEdge()) 1326 if (m_host.GetDieAtEdge())
@@ -1317,24 +1329,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1317 return 0; 1329 return 0;
1318 1330
1319 case ScriptBaseClass.STATUS_RETURN_AT_EDGE: 1331 case ScriptBaseClass.STATUS_RETURN_AT_EDGE:
1320 NotImplemented("llGetStatus - STATUS_RETURN_AT_EDGE"); 1332 if (m_host.GetReturnAtEdge())
1321 return 0; 1333 return 1;
1334 else
1335 return 0;
1322 1336
1323 case ScriptBaseClass.STATUS_ROTATE_X: 1337 case ScriptBaseClass.STATUS_ROTATE_X:
1324 NotImplemented("llGetStatus - STATUS_ROTATE_X"); 1338 if (m_host.GetAxisRotation(2) == 2)
1325 return 0; 1339 return 1;
1340 else
1341 return 0;
1326 1342
1327 case ScriptBaseClass.STATUS_ROTATE_Y: 1343 case ScriptBaseClass.STATUS_ROTATE_Y:
1328 NotImplemented("llGetStatus - STATUS_ROTATE_Y"); 1344 if (m_host.GetAxisRotation(4) == 4)
1329 return 0; 1345 return 1;
1346 else
1347 return 0;
1330 1348
1331 case ScriptBaseClass.STATUS_ROTATE_Z: 1349 case ScriptBaseClass.STATUS_ROTATE_Z:
1332 NotImplemented("llGetStatus - STATUS_ROTATE_Z"); 1350 if (m_host.GetAxisRotation(8) == 8)
1333 return 0; 1351 return 1;
1352 else
1353 return 0;
1334 1354
1335 case ScriptBaseClass.STATUS_SANDBOX: 1355 case ScriptBaseClass.STATUS_SANDBOX:
1336 NotImplemented("llGetStatus - STATUS_SANDBOX"); 1356 if (m_host.GetStatusSandbox())
1337 return 0; 1357 return 1;
1358 else
1359 return 0;
1338 } 1360 }
1339 return 0; 1361 return 0;
1340 } 1362 }
@@ -2346,7 +2368,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2346 m_host.AddScriptLPS(1); 2368 m_host.AddScriptLPS(1);
2347 2369
2348 // send the sound, once, to all clients in range 2370 // send the sound, once, to all clients in range
2349 m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0); 2371 m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0, 0, false, false);
2350 } 2372 }
2351 2373
2352 // Xantor 20080528 we should do this differently. 2374 // Xantor 20080528 we should do this differently.
@@ -2376,42 +2398,98 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2376 public void llLoopSoundMaster(string sound, double volume) 2398 public void llLoopSoundMaster(string sound, double volume)
2377 { 2399 {
2378 m_host.AddScriptLPS(1); 2400 m_host.AddScriptLPS(1);
2379 NotImplemented("llLoopSoundMaster"); 2401 m_host.ParentGroup.LoopSoundMasterPrim = m_host;
2402 lock (m_host.ParentGroup.LoopSoundSlavePrims)
2403 {
2404 foreach (SceneObjectPart prim in m_host.ParentGroup.LoopSoundSlavePrims)
2405 {
2406 if (prim.Sound != UUID.Zero)
2407 llStopSound();
2408
2409 prim.Sound = KeyOrName(sound);
2410 prim.SoundGain = volume;
2411 prim.SoundFlags = 1; // looping
2412 prim.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable?
2413
2414 prim.ScheduleFullUpdate();
2415 prim.SendFullUpdateToAllClients();
2416 }
2417 }
2418 if (m_host.Sound != UUID.Zero)
2419 llStopSound();
2420
2421 m_host.Sound = KeyOrName(sound);
2422 m_host.SoundGain = volume;
2423 m_host.SoundFlags = 1; // looping
2424 m_host.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable?
2425
2426 m_host.ScheduleFullUpdate();
2427 m_host.SendFullUpdateToAllClients();
2380 } 2428 }
2381 2429
2382 public void llLoopSoundSlave(string sound, double volume) 2430 public void llLoopSoundSlave(string sound, double volume)
2383 { 2431 {
2384 m_host.AddScriptLPS(1); 2432 m_host.AddScriptLPS(1);
2385 NotImplemented("llLoopSoundSlave"); 2433 lock (m_host.ParentGroup.LoopSoundSlavePrims)
2434 {
2435 m_host.ParentGroup.LoopSoundSlavePrims.Add(m_host);
2436 }
2386 } 2437 }
2387 2438
2388 public void llPlaySoundSlave(string sound, double volume) 2439 public void llPlaySoundSlave(string sound, double volume)
2389 { 2440 {
2390 m_host.AddScriptLPS(1); 2441 m_host.AddScriptLPS(1);
2391 NotImplemented("llPlaySoundSlave"); 2442
2443 // send the sound, once, to all clients in range
2444 m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0, 0, true, false);
2392 } 2445 }
2393 2446
2394 public void llTriggerSound(string sound, double volume) 2447 public void llTriggerSound(string sound, double volume)
2395 { 2448 {
2396 m_host.AddScriptLPS(1); 2449 m_host.AddScriptLPS(1);
2397 // send the sound, once, to all clients in range 2450 // send the sound, once, to all clients in range
2398 m_host.SendSound(KeyOrName(sound).ToString(), volume, true, 0); 2451 m_host.SendSound(KeyOrName(sound).ToString(), volume, true, 0, 0, false, false);
2399 } 2452 }
2400 2453
2401 // Xantor 20080528: Clear prim data of sound instead 2454 // Xantor 20080528: Clear prim data of sound instead
2402 public void llStopSound() 2455 public void llStopSound()
2403 { 2456 {
2404 m_host.AddScriptLPS(1); 2457 m_host.AddScriptLPS(1);
2405 2458 if (m_host.ParentGroup.LoopSoundSlavePrims.Contains(m_host))
2406 m_host.Sound = UUID.Zero; 2459 {
2407 m_host.SoundGain = 0; 2460 if (m_host.ParentGroup.LoopSoundMasterPrim == m_host)
2408 m_host.SoundFlags = 0; 2461 {
2409 m_host.SoundRadius = 0; 2462 foreach (SceneObjectPart part in m_host.ParentGroup.LoopSoundSlavePrims)
2410 2463 {
2411 m_host.ScheduleFullUpdate(); 2464 part.Sound = UUID.Zero;
2412 m_host.SendFullUpdateToAllClients(); 2465 part.SoundGain = 0;
2413 2466 part.SoundFlags = 0;
2414 // m_host.SendSound(UUID.Zero.ToString(), 1.0, false, 2); 2467 part.SoundRadius = 0;
2468 part.ScheduleFullUpdate();
2469 part.SendFullUpdateToAllClients();
2470 }
2471 m_host.ParentGroup.LoopSoundMasterPrim = null;
2472 m_host.ParentGroup.LoopSoundSlavePrims.Clear();
2473 }
2474 else
2475 {
2476 m_host.Sound = UUID.Zero;
2477 m_host.SoundGain = 0;
2478 m_host.SoundFlags = 0;
2479 m_host.SoundRadius = 0;
2480 m_host.ScheduleFullUpdate();
2481 m_host.SendFullUpdateToAllClients();
2482 }
2483 }
2484 else
2485 {
2486 m_host.Sound = UUID.Zero;
2487 m_host.SoundGain = 0;
2488 m_host.SoundFlags = 0;
2489 m_host.SoundRadius = 0;
2490 m_host.ScheduleFullUpdate();
2491 m_host.SendFullUpdateToAllClients();
2492 }
2415 } 2493 }
2416 2494
2417 public void llPreloadSound(string sound) 2495 public void llPreloadSound(string sound)
@@ -2803,8 +2881,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2803 2881
2804 public void llLookAt(LSL_Vector target, double strength, double damping) 2882 public void llLookAt(LSL_Vector target, double strength, double damping)
2805 { 2883 {
2806 // partial implementation, rotates objects correctly but does not apply strength or damping attributes
2807
2808 m_host.AddScriptLPS(1); 2884 m_host.AddScriptLPS(1);
2809 // Determine where we are looking from 2885 // Determine where we are looking from
2810 LSL_Vector from = llGetPos(); 2886 LSL_Vector from = llGetPos();
@@ -2824,9 +2900,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2824 // the angles of rotation in radians into rotation value 2900 // the angles of rotation in radians into rotation value
2825 2901
2826 LSL_Types.Quaternion rot = llEuler2Rot(angle); 2902 LSL_Types.Quaternion rot = llEuler2Rot(angle);
2827 2903 Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s);
2904 m_host.startLookAt(rotation, (float)damping, (float)strength);
2828 // Orient the object to the angle calculated 2905 // Orient the object to the angle calculated
2829 llSetRot(rot); 2906 //llSetRot(rot);
2830 } 2907 }
2831 2908
2832 public void llRotLookAt(LSL_Rotation target, double strength, double damping) 2909 public void llRotLookAt(LSL_Rotation target, double strength, double damping)
@@ -3329,13 +3406,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3329 public void llPointAt(LSL_Vector pos) 3406 public void llPointAt(LSL_Vector pos)
3330 { 3407 {
3331 m_host.AddScriptLPS(1); 3408 m_host.AddScriptLPS(1);
3332 NotImplemented("llPointAt"); 3409 ScenePresence Owner = World.GetScenePresence(m_host.UUID);
3410 LSL_Rotation rot = llEuler2Rot(pos);
3411 Owner.PreviousRotation = Owner.Rotation;
3412 Owner.Rotation = (new Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s));
3333 } 3413 }
3334 3414
3335 public void llStopPointAt() 3415 public void llStopPointAt()
3336 { 3416 {
3337 m_host.AddScriptLPS(1); 3417 m_host.AddScriptLPS(1);
3338 NotImplemented("llStopPointAt"); 3418 ScenePresence Owner = m_host.ParentGroup.Scene.GetScenePresence(m_host.OwnerID);
3419 Owner.Rotation = Owner.PreviousRotation;
3339 } 3420 }
3340 3421
3341 public void llTargetOmega(LSL_Vector axis, double spinrate, double gain) 3422 public void llTargetOmega(LSL_Vector axis, double spinrate, double gain)
@@ -3998,13 +4079,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3998 4079
3999 UUID uuid = (UUID)id; 4080 UUID uuid = (UUID)id;
4000 4081
4001 UserProfileData userProfile = 4082 UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid);
4002 World.CommsManager.UserService.GetUserProfile(uuid);
4003 4083
4004 UserAgentData userAgent = 4084 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
4005 World.CommsManager.UserService.GetAgentByUUID(uuid); 4085 PresenceInfo pinfo = PresenceInfo.GetOnlinePresence(pinfos);
4006 4086
4007 if (userProfile == null || userAgent == null) 4087 if (pinfo == null)
4008 return UUID.Zero.ToString(); 4088 return UUID.Zero.ToString();
4009 4089
4010 string reply = String.Empty; 4090 string reply = String.Empty;
@@ -4013,17 +4093,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4013 { 4093 {
4014 case 1: // DATA_ONLINE (0|1) 4094 case 1: // DATA_ONLINE (0|1)
4015 // TODO: implement fetching of this information 4095 // TODO: implement fetching of this information
4016 if (userProfile.CurrentAgent!=null && userProfile.CurrentAgent.AgentOnline) 4096 if (pinfo != null)
4017 reply = "1"; 4097 reply = "1";
4018 else 4098 else
4019 reply = "0"; 4099 reply = "0";
4020 break; 4100 break;
4021 case 2: // DATA_NAME (First Last) 4101 case 2: // DATA_NAME (First Last)
4022 reply = userProfile.FirstName + " " + userProfile.SurName; 4102 reply = account.FirstName + " " + account.LastName;
4023 break; 4103 break;
4024 case 3: // DATA_BORN (YYYY-MM-DD) 4104 case 3: // DATA_BORN (YYYY-MM-DD)
4025 DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); 4105 DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0);
4026 born = born.AddSeconds(userProfile.Created); 4106 born = born.AddSeconds(account.Created);
4027 reply = born.ToString("yyyy-MM-dd"); 4107 reply = born.ToString("yyyy-MM-dd");
4028 break; 4108 break;
4029 case 4: // DATA_RATING (0,0,0,0,0,0) 4109 case 4: // DATA_RATING (0,0,0,0,0,0)
@@ -4138,8 +4218,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4138 public void llCollisionSound(string impact_sound, double impact_volume) 4218 public void llCollisionSound(string impact_sound, double impact_volume)
4139 { 4219 {
4140 m_host.AddScriptLPS(1); 4220 m_host.AddScriptLPS(1);
4141 //NotImplemented("llCollisionSound");
4142
4143 // TODO: Parameter check logic required. 4221 // TODO: Parameter check logic required.
4144 UUID soundId = UUID.Zero; 4222 UUID soundId = UUID.Zero;
4145 if (!UUID.TryParse(impact_sound, out soundId)) 4223 if (!UUID.TryParse(impact_sound, out soundId))
@@ -4727,8 +4805,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4727 public LSL_Vector llGetCenterOfMass() 4805 public LSL_Vector llGetCenterOfMass()
4728 { 4806 {
4729 m_host.AddScriptLPS(1); 4807 m_host.AddScriptLPS(1);
4730 NotImplemented("llGetCenterOfMass"); 4808 Vector3 center = m_host.GetGeometricCenter();
4731 return new LSL_Vector(); 4809 return new LSL_Vector(center.X,center.Y,center.Z);
4732 } 4810 }
4733 4811
4734 public LSL_List llListSort(LSL_List src, int stride, int ascending) 4812 public LSL_List llListSort(LSL_List src, int stride, int ascending)
@@ -5461,8 +5539,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5461 flags |= ScriptBaseClass.AGENT_SITTING; 5539 flags |= ScriptBaseClass.AGENT_SITTING;
5462 } 5540 }
5463 5541
5464 //NotImplemented("llGetAgentInfo");
5465
5466 return flags; 5542 return flags;
5467 } 5543 }
5468 5544
@@ -5545,7 +5621,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5545 LSL_Vector bottom_south_west) 5621 LSL_Vector bottom_south_west)
5546 { 5622 {
5547 m_host.AddScriptLPS(1); 5623 m_host.AddScriptLPS(1);
5548 NotImplemented("llTriggerSoundLimited"); 5624 float radius1 = (float)llVecDist(llGetPos(), top_north_east);
5625 float radius2 = (float)llVecDist(llGetPos(), bottom_south_west);
5626 float radius = Math.Abs(radius1 - radius2);
5627 m_host.SendSound(KeyOrName(sound).ToString(), volume, true, 0, radius, false, false);
5549 } 5628 }
5550 5629
5551 public void llEjectFromLand(string pest) 5630 public void llEjectFromLand(string pest)
@@ -6084,7 +6163,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6084 public void llGroundRepel(double height, int water, double tau) 6163 public void llGroundRepel(double height, int water, double tau)
6085 { 6164 {
6086 m_host.AddScriptLPS(1); 6165 m_host.AddScriptLPS(1);
6087 NotImplemented("llGroundRepel"); 6166 if (m_host.PhysActor != null)
6167 {
6168 float ground = (float)llGround(new LSL_Types.Vector3(0, 0, 0));
6169 float waterLevel = (float)llWater(new LSL_Types.Vector3(0, 0, 0));
6170 PIDHoverType hoverType = PIDHoverType.Ground;
6171 if (water != 0)
6172 {
6173 hoverType = PIDHoverType.GroundAndWater;
6174 if (ground < waterLevel)
6175 height += waterLevel;
6176 else
6177 height += ground;
6178 }
6179 else
6180 {
6181 height += ground;
6182 }
6183
6184 m_host.SetHoverHeight((float)height, hoverType, (float)tau);
6185 }
6088 } 6186 }
6089 6187
6090 protected UUID GetTaskInventoryItem(string name) 6188 protected UUID GetTaskInventoryItem(string name)
@@ -6219,7 +6317,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6219 { 6317 {
6220 if (!m_host.ParentGroup.IsDeleted) 6318 if (!m_host.ParentGroup.IsDeleted)
6221 { 6319 {
6222 m_host.ParentGroup.RootPart.SetVehicleFlags(flags); 6320 m_host.ParentGroup.RootPart.SetVehicleFlags(flags, false);
6223 } 6321 }
6224 } 6322 }
6225 } 6323 }
@@ -6231,7 +6329,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6231 { 6329 {
6232 if (!m_host.ParentGroup.IsDeleted) 6330 if (!m_host.ParentGroup.IsDeleted)
6233 { 6331 {
6234 m_host.ParentGroup.RootPart.RemoveVehicleFlags(flags); 6332 m_host.ParentGroup.RootPart.SetVehicleFlags(flags, true);
6235 } 6333 }
6236 } 6334 }
6237 } 6335 }
@@ -7271,7 +7369,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7271 public void llRemoteDataSetRegion() 7369 public void llRemoteDataSetRegion()
7272 { 7370 {
7273 m_host.AddScriptLPS(1); 7371 m_host.AddScriptLPS(1);
7274 NotImplemented("llRemoteDataSetRegion"); 7372 Deprecated("llRemoteDataSetRegion");
7275 } 7373 }
7276 7374
7277 public LSL_Float llLog10(double val) 7375 public LSL_Float llLog10(double val)
@@ -8409,7 +8507,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8409 public void llSetInventoryPermMask(string item, int mask, int value) 8507 public void llSetInventoryPermMask(string item, int mask, int value)
8410 { 8508 {
8411 m_host.AddScriptLPS(1); 8509 m_host.AddScriptLPS(1);
8412 NotImplemented("llSetInventoryPermMask"); 8510 if (m_ScriptEngine.Config.GetBoolean("AllowGodFunctions", false))
8511 {
8512 if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID))
8513 {
8514 lock (m_host.TaskInventory)
8515 {
8516 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
8517 {
8518 if (inv.Value.Name == item)
8519 {
8520 switch (mask)
8521 {
8522 case 0:
8523 inv.Value.BasePermissions = (uint)value;
8524 break;
8525 case 1:
8526 inv.Value.CurrentPermissions = (uint)value;
8527 break;
8528 case 2:
8529 inv.Value.GroupPermissions = (uint)value;
8530 break;
8531 case 3:
8532 inv.Value.EveryonePermissions = (uint)value;
8533 break;
8534 case 4:
8535 inv.Value.NextPermissions = (uint)value;
8536 break;
8537 }
8538 }
8539 }
8540 }
8541 }
8542 }
8413 } 8543 }
8414 8544
8415 public LSL_String llGetInventoryCreator(string item) 8545 public LSL_String llGetInventoryCreator(string item)
@@ -8843,6 +8973,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8843 // we send to all 8973 // we send to all
8844 landData.MediaID = new UUID(texture); 8974 landData.MediaID = new UUID(texture);
8845 landData.MediaAutoScale = autoAlign ? (byte)1 : (byte)0; 8975 landData.MediaAutoScale = autoAlign ? (byte)1 : (byte)0;
8976 landData.MediaSize[0] = width;
8977 landData.MediaSize[1] = height;
8978 landData.MediaType = mediaType;
8846 8979
8847 // do that one last, it will cause a ParcelPropertiesUpdate 8980 // do that one last, it will cause a ParcelPropertiesUpdate
8848 landObject.SetMediaUrl(url); 8981 landObject.SetMediaUrl(url);
@@ -8902,11 +9035,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8902 m_host.AddScriptLPS(1); 9035 m_host.AddScriptLPS(1);
8903 LSL_List list = new LSL_List(); 9036 LSL_List list = new LSL_List();
8904 //TO DO: make the implementation for the missing commands 9037 //TO DO: make the implementation for the missing commands
8905 //PARCEL_MEDIA_COMMAND_TEXTURE key uuid Use this to get or set the parcel's media texture.
8906 //PARCEL_MEDIA_COMMAND_URL string url Used to get or set the parcel's media url.
8907 //PARCEL_MEDIA_COMMAND_TYPE string mime_type Use this to get or set the parcel media MIME type (e.g. "text/html"). (1.19.1 RC0 or later)
8908 //PARCEL_MEDIA_COMMAND_SIZE integer x, integer y Use this to get or set the parcel media pixel resolution. (1.19.1 RC0 or later)
8909 //PARCEL_MEDIA_COMMAND_DESC string desc Use this to get or set the parcel media description. (1.19.1 RC0 or later)
8910 //PARCEL_MEDIA_COMMAND_LOOP_SET float loop Use this to get or set the parcel's media loop duration. (1.19.1 RC0 or later) 9038 //PARCEL_MEDIA_COMMAND_LOOP_SET float loop Use this to get or set the parcel's media loop duration. (1.19.1 RC0 or later)
8911 for (int i = 0; i < aList.Data.Length; i++) 9039 for (int i = 0; i < aList.Data.Length; i++)
8912 { 9040 {
@@ -8924,6 +9052,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8924 case ParcelMediaCommandEnum.Texture: 9052 case ParcelMediaCommandEnum.Texture:
8925 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaID.ToString())); 9053 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaID.ToString()));
8926 break; 9054 break;
9055 case ParcelMediaCommandEnum.Type:
9056 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaType));
9057 break;
9058 case ParcelMediaCommandEnum.Size:
9059 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaSize[0]));
9060 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaSize[1]));
9061 break;
8927 default: 9062 default:
8928 ParcelMediaCommandEnum mediaCommandEnum = ParcelMediaCommandEnum.Url; 9063 ParcelMediaCommandEnum mediaCommandEnum = ParcelMediaCommandEnum.Url;
8929 NotImplemented("llParcelMediaQuery parameter do not supported yet: " + Enum.Parse(mediaCommandEnum.GetType() , aList.Data[i].ToString()).ToString()); 9064 NotImplemented("llParcelMediaQuery parameter do not supported yet: " + Enum.Parse(mediaCommandEnum.GetType() , aList.Data[i].ToString()).ToString());
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 1ddba1e..845834e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -36,12 +36,11 @@ using OpenMetaverse;
36using Nini.Config; 36using Nini.Config;
37using OpenSim; 37using OpenSim;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Communications.Cache; 39
40using OpenSim.Framework.Console; 40using OpenSim.Framework.Console;
41using OpenSim.Region.CoreModules.Avatar.NPC; 41using OpenSim.Region.CoreModules.Avatar.NPC;
42using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Scenes.Hypergrid;
45using OpenSim.Region.ScriptEngine.Shared; 44using OpenSim.Region.ScriptEngine.Shared;
46using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; 45using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
47using OpenSim.Region.ScriptEngine.Shared.ScriptBase; 46using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
@@ -607,21 +606,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
607 // and convert the regionName to the target region 606 // and convert the regionName to the target region
608 if (regionName.Contains(".") && regionName.Contains(":")) 607 if (regionName.Contains(".") && regionName.Contains(":"))
609 { 608 {
609 List<GridRegion> regions = World.GridService.GetRegionsByName(World.RegionInfo.ScopeID, regionName, 1);
610 // Try to link the region 610 // Try to link the region
611 IHyperlinkService hyperService = World.RequestModuleInterface<IHyperlinkService>(); 611 if (regions != null && regions.Count > 0)
612 if (hyperService != null)
613 { 612 {
614 GridRegion regInfo = hyperService.TryLinkRegion(presence.ControllingClient, 613 GridRegion regInfo = regions[0];
615 regionName); 614 regionName = regInfo.RegionName;
616 // Get the region name
617 if (regInfo != null)
618 {
619 regionName = regInfo.RegionName;
620 }
621 else
622 {
623 // Might need to ping the client here in case of failure??
624 }
625 } 615 }
626 } 616 }
627 presence.ControllingClient.SendTeleportLocationStart(); 617 presence.ControllingClient.SendTeleportLocationStart();
@@ -1482,7 +1472,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1482 m_host.AddScriptLPS(1); 1472 m_host.AddScriptLPS(1);
1483 1473
1484 // Create new asset 1474 // Create new asset
1485 AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard); 1475 AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString());
1486 asset.Description = "Script Generated Notecard"; 1476 asset.Description = "Script Generated Notecard";
1487 string notecardData = String.Empty; 1477 string notecardData = String.Empty;
1488 1478
@@ -1695,15 +1685,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1695 { 1685 {
1696 CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key"); 1686 CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key");
1697 1687
1698 CachedUserInfo userInfo = World.CommsManager.UserProfileCacheService.GetUserDetails(firstname, lastname); 1688 UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, firstname, lastname);
1699 1689 if (null == account)
1700 if (null == userInfo)
1701 { 1690 {
1702 return UUID.Zero.ToString(); 1691 return UUID.Zero.ToString();
1703 } 1692 }
1704 else 1693 else
1705 { 1694 {
1706 return userInfo.UserProfile.ID.ToString(); 1695 return account.PrincipalID.ToString();
1707 } 1696 }
1708 } 1697 }
1709 1698
@@ -1714,15 +1703,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1714 1703
1715 if (UUID.TryParse(id, out key)) 1704 if (UUID.TryParse(id, out key))
1716 { 1705 {
1717 CachedUserInfo userInfo = World.CommsManager.UserProfileCacheService.GetUserDetails(key); 1706 UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, key);
1718 1707 if (null == account)
1719 if (null == userInfo)
1720 { 1708 {
1721 return ""; 1709 return "";
1722 } 1710 }
1723 else 1711 else
1724 { 1712 {
1725 return userInfo.UserProfile.Name; 1713 return account.Name;
1726 } 1714 }
1727 } 1715 }
1728 else 1716 else
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index b75a2e4..829fbb7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -29,7 +29,7 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using OpenMetaverse; 30using OpenMetaverse;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Framework.Communications.Cache; 32
33using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
34using OpenSim.Region.ScriptEngine.Shared; 34using OpenSim.Region.ScriptEngine.Shared;
35using OpenSim.Region.ScriptEngine.Shared.Api; 35using OpenSim.Region.ScriptEngine.Shared.Api;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index 13b855f..7cf82b2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -160,6 +160,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
160 public const int VEHICLE_BANKING_MIX = 39; 160 public const int VEHICLE_BANKING_MIX = 39;
161 public const int VEHICLE_BANKING_TIMESCALE = 40; 161 public const int VEHICLE_BANKING_TIMESCALE = 40;
162 public const int VEHICLE_REFERENCE_FRAME = 44; 162 public const int VEHICLE_REFERENCE_FRAME = 44;
163 public const int VEHICLE_RANGE_BLOCK = 45;
164 public const int VEHICLE_ROLL_FRAME = 46;
163 public const int VEHICLE_FLAG_NO_DEFLECTION_UP = 1; 165 public const int VEHICLE_FLAG_NO_DEFLECTION_UP = 1;
164 public const int VEHICLE_FLAG_LIMIT_ROLL_ONLY = 2; 166 public const int VEHICLE_FLAG_LIMIT_ROLL_ONLY = 2;
165 public const int VEHICLE_FLAG_HOVER_WATER_ONLY = 4; 167 public const int VEHICLE_FLAG_HOVER_WATER_ONLY = 4;
@@ -170,6 +172,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
170 public const int VEHICLE_FLAG_MOUSELOOK_STEER = 128; 172 public const int VEHICLE_FLAG_MOUSELOOK_STEER = 128;
171 public const int VEHICLE_FLAG_MOUSELOOK_BANK = 256; 173 public const int VEHICLE_FLAG_MOUSELOOK_BANK = 256;
172 public const int VEHICLE_FLAG_CAMERA_DECOUPLED = 512; 174 public const int VEHICLE_FLAG_CAMERA_DECOUPLED = 512;
175 public const int VEHICLE_FLAG_NO_X = 1024;
176 public const int VEHICLE_FLAG_NO_Y = 2048;
177 public const int VEHICLE_FLAG_NO_Z = 4096;
178 public const int VEHICLE_FLAG_LOCK_HOVER_HEIGHT = 8192;
179 public const int VEHICLE_FLAG_NO_DEFLECTION = 16392;
180 public const int VEHICLE_FLAG_LOCK_ROTATION = 32784;
173 181
174 public const int INVENTORY_ALL = -1; 182 public const int INVENTORY_ALL = -1;
175 public const int INVENTORY_NONE = -1; 183 public const int INVENTORY_NONE = -1;