aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorAdam Frisby2007-07-11 08:10:25 +0000
committerAdam Frisby2007-07-11 08:10:25 +0000
commite2ff441e31328e60c8bb1d4bb32fa4ac64f91978 (patch)
tree8405b6cef57b66a58f31a24c859846085d0b81f7 /OpenSim
parent* Wiping trunk in prep for Sugilite (diff)
parent* Applying dalien's patches from bug#177 and #179 (diff)
downloadopensim-SC_OLD-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.zip
opensim-SC_OLD-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.tar.gz
opensim-SC_OLD-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.tar.bz2
opensim-SC_OLD-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.tar.xz
* Bringing Sugilite in to trunk
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Communications/CommunicationsManager.cs70
-rw-r--r--OpenSim/Framework/Communications/IGridServices.cs43
-rw-r--r--OpenSim/Framework/Communications/IInterRegionCommunications.cs38
-rw-r--r--OpenSim/Framework/Communications/IUserServices.cs43
-rw-r--r--OpenSim/Framework/Communications/Properties/AssemblyInfo.cs60
-rw-r--r--OpenSim/Framework/Console/AssemblyInfo.cs56
-rw-r--r--OpenSim/Framework/Console/ConsoleCallbacksBase.cs35
-rw-r--r--OpenSim/Framework/Console/LogBase.cs282
-rw-r--r--OpenSim/Framework/Console/MainLog.cs47
-rw-r--r--OpenSim/Framework/Data.DB4o/DB4oGridData.cs162
-rw-r--r--OpenSim/Framework/Data.DB4o/DB4oManager.cs163
-rw-r--r--OpenSim/Framework/Data.DB4o/DB4oUserData.cs202
-rw-r--r--OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs194
-rw-r--r--OpenSim/Framework/Data.MSSQL/MSSQLManager.cs211
-rw-r--r--OpenSim/Framework/Data.MSSQL/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLGridData.cs287
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs309
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLLogData.cs105
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLManager.cs602
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLUserData.cs256
-rw-r--r--OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteGridData.cs197
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteManager.cs206
-rw-r--r--OpenSim/Framework/Data/GridData.cs111
-rw-r--r--OpenSim/Framework/Data/ILogData.cs90
-rw-r--r--OpenSim/Framework/Data/IniConfig.cs96
-rw-r--r--OpenSim/Framework/Data/InventoryData.cs185
-rw-r--r--OpenSim/Framework/Data/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Framework/Data/ReservationData.cs47
-rw-r--r--OpenSim/Framework/Data/SimProfileData.cs192
-rw-r--r--OpenSim/Framework/Data/UserData.cs128
-rw-r--r--OpenSim/Framework/Data/UserProfileData.cs180
-rw-r--r--OpenSim/Framework/General/AgentInventory.cs265
-rw-r--r--OpenSim/Framework/General/AuthenticateSessionBase.cs130
-rw-r--r--OpenSim/Framework/General/BlockingQueue.cs58
-rw-r--r--OpenSim/Framework/General/ClientManager.cs36
-rw-r--r--OpenSim/Framework/General/IRegionCommsListener.cs46
-rw-r--r--OpenSim/Framework/General/Interfaces/AuthenticateResponse.cs43
-rw-r--r--OpenSim/Framework/General/Interfaces/Config/IGenericConfig.cs38
-rw-r--r--OpenSim/Framework/General/Interfaces/Config/IGridConfig.cs59
-rw-r--r--OpenSim/Framework/General/Interfaces/Config/IUserConfig.cs53
-rw-r--r--OpenSim/Framework/General/Interfaces/IAssetServer.cs64
-rw-r--r--OpenSim/Framework/General/Interfaces/IClientAPI.cs180
-rw-r--r--OpenSim/Framework/General/Interfaces/ILocalStorage.cs68
-rw-r--r--OpenSim/Framework/General/Interfaces/IUserServer.cs39
-rw-r--r--OpenSim/Framework/General/Interfaces/IWorld.cs42
-rw-r--r--OpenSim/Framework/General/LoginService.cs34
-rw-r--r--OpenSim/Framework/General/Properties/AssemblyInfo.cs31
-rw-r--r--OpenSim/Framework/General/RegionCommsListener.cs68
-rw-r--r--OpenSim/Framework/General/Remoting.cs135
-rw-r--r--OpenSim/Framework/General/Types/AgentCiruitData.cs49
-rw-r--r--OpenSim/Framework/General/Types/AgentWearable.cs57
-rw-r--r--OpenSim/Framework/General/Types/AssetBase.cs46
-rw-r--r--OpenSim/Framework/General/Types/AssetLandmark.cs59
-rw-r--r--OpenSim/Framework/General/Types/AssetStorage.cs47
-rw-r--r--OpenSim/Framework/General/Types/EstateSettings.cs93
-rw-r--r--OpenSim/Framework/General/Types/Login.cs49
-rw-r--r--OpenSim/Framework/General/Types/MapBlockData.cs23
-rw-r--r--OpenSim/Framework/General/Types/NeighbourInfo.cs42
-rw-r--r--OpenSim/Framework/General/Types/NetworkServersInfo.cs219
-rw-r--r--OpenSim/Framework/General/Types/ParcelData.cs112
-rw-r--r--OpenSim/Framework/General/Types/PrimData.cs228
-rw-r--r--OpenSim/Framework/General/Types/PrimitiveBaseShape.cs102
-rw-r--r--OpenSim/Framework/General/Types/RegionHandle.cs121
-rw-r--r--OpenSim/Framework/General/Types/RegionInfo.cs342
-rw-r--r--OpenSim/Framework/General/Types/UUID.cs127
-rw-r--r--OpenSim/Framework/General/UserProfile.cs87
-rw-r--r--OpenSim/Framework/General/Util.cs184
-rw-r--r--OpenSim/Framework/GenericConfig/Xml/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Framework/GenericConfig/Xml/XmlConfig.cs122
-rw-r--r--OpenSim/Framework/Servers/BaseHttpServer.cs224
-rw-r--r--OpenSim/Framework/Servers/BaseStreamHandler.cs40
-rw-r--r--OpenSim/Framework/Servers/CheckSumServer.cs127
-rw-r--r--OpenSim/Framework/Servers/IStreamHandler.cs22
-rw-r--r--OpenSim/Framework/Servers/RestMethod.cs31
-rw-r--r--OpenSim/Framework/Servers/RestStreamHandler.cs31
-rw-r--r--OpenSim/Framework/Servers/UDPServerBase.cs87
-rw-r--r--OpenSim/Framework/Servers/XmlRpcMethod.cs33
-rw-r--r--OpenSim/Framework/UserManager/LoginResponse.cs643
-rw-r--r--OpenSim/Framework/UserManager/UserManagerBase.cs630
-rw-r--r--OpenSim/Grid/AssetServer/Main.cs406
-rw-r--r--OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs58
-rw-r--r--OpenSim/Grid/Framework.Manager/GridManagementAgent.cs138
-rw-r--r--OpenSim/Grid/Framework.Manager/GridServerManager.cs93
-rw-r--r--OpenSim/Grid/GridServer.Config/AssemblyInfo.cs56
-rw-r--r--OpenSim/Grid/GridServer.Config/DbGridConfig.cs160
-rw-r--r--OpenSim/Grid/GridServer/GridManager.cs703
-rw-r--r--OpenSim/Grid/GridServer/Main.cs258
-rw-r--r--OpenSim/Grid/GridServer/Properties/AssemblyInfo.cs58
-rw-r--r--OpenSim/Grid/InventoryServer/InventoryManager.cs125
-rw-r--r--OpenSim/Grid/InventoryServer/Main.cs87
-rw-r--r--OpenSim/Grid/Manager/OpenGridServices.Manager.mds16
-rw-r--r--OpenSim/Grid/Manager/OpenGridServices.Manager.userprefs39
-rw-r--r--OpenSim/Grid/Manager/OpenGridServices.Manager.usertasks2
-rw-r--r--OpenSim/Grid/Manager/OpenGridServices.Manager/AssemblyInfo.cs32
-rw-r--r--OpenSim/Grid/Manager/OpenGridServices.Manager/BlockingQueue.cs33
-rw-r--r--OpenSim/Grid/Manager/OpenGridServices.Manager/Connect to grid server.cs16
-rw-r--r--OpenSim/Grid/Manager/OpenGridServices.Manager/ConnectToGridServerDialog.cs29
-rw-r--r--OpenSim/Grid/Manager/OpenGridServices.Manager/GridServerConnectionManager.cs106
-rw-r--r--OpenSim/Grid/Manager/OpenGridServices.Manager/Main.cs96
-rw-r--r--OpenSim/Grid/Manager/OpenGridServices.Manager/MainWindow.cs76
-rw-r--r--OpenSim/Grid/Manager/OpenGridServices.Manager/OpenGridServices.Manager.mdp43
-rw-r--r--OpenSim/Grid/Manager/OpenGridServices.Manager/OpenGridServices.Manager.pidbbin0 -> 12308 bytes
-rw-r--r--OpenSim/Grid/Manager/OpenGridServices.Manager/RegionBlock.cs37
-rw-r--r--OpenSim/Grid/Manager/OpenGridServices.Manager/Util.cs133
-rw-r--r--OpenSim/Grid/Manager/OpenGridServices.Manager/gtk-gui/OpenGridServices.Manager.ConnectToGridServerDialog.cs226
-rw-r--r--OpenSim/Grid/Manager/OpenGridServices.Manager/gtk-gui/OpenGridServices.Manager.MainWindow.cs256
-rw-r--r--OpenSim/Grid/Manager/OpenGridServices.Manager/gtk-gui/generated.cs35
-rw-r--r--OpenSim/Grid/Manager/OpenGridServices.Manager/gtk-gui/gui.stetic502
-rw-r--r--OpenSim/Grid/UserServer.Config/AssemblyInfo.cs56
-rw-r--r--OpenSim/Grid/UserServer.Config/DbUserConfig.cs95
-rw-r--r--OpenSim/Grid/UserServer/Main.cs214
-rw-r--r--OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs31
-rw-r--r--OpenSim/Grid/UserServer/UserManager.cs94
-rw-r--r--OpenSim/Region/Application/Application.cs120
-rw-r--r--OpenSim/Region/Application/OpenSimMain.cs482
-rw-r--r--OpenSim/Region/Application/VersionInfo.cs36
-rw-r--r--OpenSim/Region/Caches/AssetCache.cs669
-rw-r--r--OpenSim/Region/Caches/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Region/Capabilities/Caps.cs336
-rw-r--r--OpenSim/Region/Capabilities/LLSDArray.cs42
-rw-r--r--OpenSim/Region/Capabilities/LLSDCapEvent.cs41
-rw-r--r--OpenSim/Region/Capabilities/LLSDCapsDetails.cs15
-rw-r--r--OpenSim/Region/Capabilities/LLSDEmpty.cs38
-rw-r--r--OpenSim/Region/Capabilities/LLSDHelpers.cs164
-rw-r--r--OpenSim/Region/Capabilities/LLSDMapLayer.cs46
-rw-r--r--OpenSim/Region/Capabilities/LLSDMapLayerResponse.cs41
-rw-r--r--OpenSim/Region/Capabilities/LLSDMapRequest.cs13
-rw-r--r--OpenSim/Region/Capabilities/LLSDMethod.cs8
-rw-r--r--OpenSim/Region/Capabilities/LLSDStreamHandler.cs42
-rw-r--r--OpenSim/Region/Capabilities/LLSDTest.cs41
-rw-r--r--OpenSim/Region/Capabilities/LLSDType.cs59
-rw-r--r--OpenSim/Region/Capabilities/LLSDUploadReply.cs44
-rw-r--r--OpenSim/Region/ClientStack/Assets/InventoryCache.cs337
-rw-r--r--OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs40
-rw-r--r--OpenSim/Region/ClientStack/ClientView.API.cs1122
-rw-r--r--OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs357
-rw-r--r--OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs236
-rw-r--r--OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs596
-rw-r--r--OpenSim/Region/ClientStack/ClientView.cs293
-rw-r--r--OpenSim/Region/ClientStack/ClientViewBase.cs326
-rw-r--r--OpenSim/Region/ClientStack/PacketServer.cs184
-rw-r--r--OpenSim/Region/ClientStack/RegionApplicationBase.cs117
-rw-r--r--OpenSim/Region/ClientStack/UDPServer.cs196
-rw-r--r--OpenSim/Region/Communications/Local/CommunicationsLocal.cs54
-rw-r--r--OpenSim/Region/Communications/Local/LocalBackEndServices.cs206
-rw-r--r--OpenSim/Region/Communications/Local/LocalUserServices.cs142
-rw-r--r--OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs18
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1GridServices.cs378
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs69
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1UserServices.cs105
-rw-r--r--OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Region/Environment/EstateManager.cs300
-rw-r--r--OpenSim/Region/Environment/ParcelManager.cs891
-rw-r--r--OpenSim/Region/Environment/RegionManager.cs29
-rw-r--r--OpenSim/Region/Environment/Scenes/Entity.cs115
-rw-r--r--OpenSim/Region/Environment/Scenes/EntityBase.cs142
-rw-r--r--OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs14
-rw-r--r--OpenSim/Region/Environment/Scenes/Primitive.cs594
-rw-r--r--OpenSim/Region/Environment/Scenes/PrimitiveOld.cs583
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs570
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs806
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneBase.cs198
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneEvents.cs50
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObject.cs246
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs74
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs85
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs597
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs102
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs102
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/ClassInstance.cs45
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/ClassRecord.cs503
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Heap.cs43
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Interpreter.cs135
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterLogic.cs427
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterMethods.cs96
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterReturn.cs40
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JavaEngine.cs29
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/MainMemory.cs45
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/MethodMemory.cs46
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Object.cs37
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/OpenSimJVM.cs171
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Stack.cs42
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/StackFrame.cs49
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Thread.cs119
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ArrayReference.cs10
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/BaseType.cs10
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ObjectReference.cs16
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs10
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs10
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs16
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs16
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Script.cs64
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs25
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs58
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs99
-rw-r--r--OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs10
-rw-r--r--OpenSim/Region/Examples/SimpleApp/MyWorld.cs93
-rw-r--r--OpenSim/Region/Examples/SimpleApp/Program.cs130
-rw-r--r--OpenSim/Region/Examples/SimpleApp/Properties/AssemblyInfo.cs31
-rw-r--r--OpenSim/Region/GridInterfaces/Local/AssemblyInfo.cs56
-rw-r--r--OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs311
-rw-r--r--OpenSim/Region/GridInterfaces/Remote/AssemblyInfo.cs56
-rw-r--r--OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs133
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs56
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs301
-rw-r--r--OpenSim/Region/Physics/Manager/AssemblyInfo.cs56
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs167
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsManager.cs115
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsScene.cs110
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsVector.cs55
-rw-r--r--OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs56
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs457
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs56
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs425
-rw-r--r--OpenSim/Region/Scripting/Properties/AssemblyInfo.cs35
-rw-r--r--OpenSim/Region/Scripting/Script.cs32
-rw-r--r--OpenSim/Region/Scripting/ScriptAccess.cs31
-rw-r--r--OpenSim/Region/Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs112
-rw-r--r--OpenSim/Region/Storage/LocalStorageDb4o/AssemblyInfo.cs56
-rw-r--r--OpenSim/Region/Storage/LocalStorageDb4o/Db4LocalStorage.cs267
-rw-r--r--OpenSim/Region/Storage/LocalStorageDb4o/MapStorage.cs39
-rw-r--r--OpenSim/Region/Storage/LocalStorageDb4o/UUIDParcelQuery.cs47
-rw-r--r--OpenSim/Region/Storage/LocalStorageDb4o/UUIDPrimQuery.cs47
-rw-r--r--OpenSim/Region/Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs60
-rw-r--r--OpenSim/Region/Storage/LocalStorageSQLite/SQLiteLocalStorage.cs198
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs60
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs928
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs126
232 files changed, 33953 insertions, 0 deletions
diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs
new file mode 100644
index 0000000..109d027
--- /dev/null
+++ b/OpenSim/Framework/Communications/CommunicationsManager.cs
@@ -0,0 +1,70 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
29using libsecondlife;
30using libsecondlife.Packets;
31using OpenSim.Framework.Data;
32using OpenSim.Framework.Interfaces;
33using OpenSim.Framework.Types;
34using OpenSim.Framework.Servers;
35
36namespace OpenSim.Framework.Communications
37{
38
39 public class CommunicationsManager
40 {
41 public IUserServices UserServer;
42 public IGridServices GridServer;
43 public IInterRegionCommunications InterRegion;
44
45 public NetworkServersInfo ServersInfo;
46 public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer)
47 {
48 ServersInfo = serversInfo;
49 }
50
51 #region Packet Handlers
52 public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client)
53 {
54 Encoding enc = Encoding.ASCII;
55 UserProfileData profileData = this.UserServer.GetUserProfile(uuid);
56 if (profileData != null)
57 {
58 UUIDNameReplyPacket packet = new UUIDNameReplyPacket();
59 packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1];
60 packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
61 packet.UUIDNameBlock[0].ID = profileData.UUID;
62 packet.UUIDNameBlock[0].FirstName = enc.GetBytes(profileData.username + "\0");
63 packet.UUIDNameBlock[0].LastName = enc.GetBytes(profileData.surname +"\0");
64 remote_client.OutPacket((Packet)packet);
65 }
66
67 }
68 #endregion
69 }
70}
diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs
new file mode 100644
index 0000000..c296209
--- /dev/null
+++ b/OpenSim/Framework/Communications/IGridServices.cs
@@ -0,0 +1,43 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28
29using System.Collections.Generic;
30using OpenSim.Framework.Types;
31
32namespace OpenSim.Framework.Communications
33{
34
35
36 public interface IGridServices
37 {
38 RegionCommsListener RegisterRegion(RegionInfo regionInfos);
39 List<RegionInfo> RequestNeighbours(RegionInfo regionInfo);
40 RegionInfo RequestNeighbourInfo(ulong regionHandle);
41 List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY);
42 }
43}
diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs
new file mode 100644
index 0000000..55f12ac
--- /dev/null
+++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs
@@ -0,0 +1,38 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29using OpenSim.Framework.Types;
30
31namespace OpenSim.Framework.Communications
32{
33 public interface IInterRegionCommunications
34 {
35 bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData);
36 bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position);
37 }
38}
diff --git a/OpenSim/Framework/Communications/IUserServices.cs b/OpenSim/Framework/Communications/IUserServices.cs
new file mode 100644
index 0000000..0b1f86c
--- /dev/null
+++ b/OpenSim/Framework/Communications/IUserServices.cs
@@ -0,0 +1,43 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29using OpenSim.Framework.Data;
30
31namespace OpenSim.Framework.Communications
32{
33 public interface IUserServices
34 {
35 UserProfileData GetUserProfile(string firstName, string lastName);
36 UserProfileData GetUserProfile(string name);
37 UserProfileData GetUserProfile(LLUUID avatarID);
38
39 UserProfileData SetupMasterUser(string firstName, string lastName);
40 UserProfileData SetupMasterUser(string firstName, string lastName, string password);
41
42 }
43}
diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..09f6473
--- /dev/null
+++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs
@@ -0,0 +1,60 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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// General Information about an assembly is controlled through the following
31// set of attributes. Change these attribute values to modify the information
32// associated with an assembly.
33[assembly: AssemblyTitle("OpenGrid.Framework.Communications")]
34[assembly: AssemblyDescription("")]
35[assembly: AssemblyConfiguration("")]
36[assembly: AssemblyCompany("")]
37[assembly: AssemblyProduct("OpenGrid.Framework.Communications")]
38[assembly: AssemblyCopyright("Copyright © 2007")]
39[assembly: AssemblyTrademark("")]
40[assembly: AssemblyCulture("")]
41
42// Setting ComVisible to false makes the types in this assembly not visible
43// to COM components. If you need to access a type in this assembly from
44// COM, set the ComVisible attribute to true on that type.
45[assembly: ComVisible(false)]
46
47// The following GUID is for the ID of the typelib if this project is exposed to COM
48[assembly: Guid("13e7c396-78a9-4a5c-baf2-6f980ea75d95")]
49
50// Version information for an assembly consists of the following four values:
51//
52// Major Version
53// Minor Version
54// Build Number
55// Revision
56//
57// You can specify all the values or you can default the Revision and Build Numbers
58// by using the '*' as shown below:
59[assembly: AssemblyVersion("1.0.0.0")]
60[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Framework/Console/AssemblyInfo.cs b/OpenSim/Framework/Console/AssemblyInfo.cs
new file mode 100644
index 0000000..30f6167
--- /dev/null
+++ b/OpenSim/Framework/Console/AssemblyInfo.cs
@@ -0,0 +1,56 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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// Information about this assembly is defined by the following
31// attributes.
32//
33// change them to the information which is associated with the assembly
34// you compile.
35
36[assembly: AssemblyTitle("ServerConsole")]
37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("ServerConsole")]
41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")]
44
45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)]
48
49// The assembly version has following format :
50//
51// Major.Minor.Build.Revision
52//
53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default):
55
56[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Framework/Console/ConsoleCallbacksBase.cs b/OpenSim/Framework/Console/ConsoleCallbacksBase.cs
new file mode 100644
index 0000000..346cfe6
--- /dev/null
+++ b/OpenSim/Framework/Console/ConsoleCallbacksBase.cs
@@ -0,0 +1,35 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28namespace OpenSim.Framework.Console
29{
30 public interface conscmd_callback
31 {
32 void RunCmd(string cmd, string[] cmdparams);
33 void Show(string ShowWhat);
34 }
35}
diff --git a/OpenSim/Framework/Console/LogBase.cs b/OpenSim/Framework/Console/LogBase.cs
new file mode 100644
index 0000000..f73e15e
--- /dev/null
+++ b/OpenSim/Framework/Console/LogBase.cs
@@ -0,0 +1,282 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.IO;
30using System.Net;
31
32namespace OpenSim.Framework.Console
33{
34 public enum LogPriority : int
35 {
36 CRITICAL,
37 HIGH,
38 MEDIUM,
39 NORMAL,
40 LOW,
41 VERBOSE,
42 EXTRAVERBOSE
43 }
44
45 public class LogBase
46 {
47 StreamWriter Log;
48 public conscmd_callback cmdparser;
49 public string componentname;
50 private bool m_silent;
51
52 public LogBase(string LogFile, string componentname, conscmd_callback cmdparser, bool silent)
53 {
54 this.componentname = componentname;
55 this.cmdparser = cmdparser;
56 this.m_silent = silent;
57 System.Console.WriteLine("ServerConsole.cs - creating new local console");
58
59 if (String.IsNullOrEmpty(LogFile))
60 {
61 LogFile = componentname + ".log";
62 }
63
64 System.Console.WriteLine("Logs will be saved to current directory in " + LogFile);
65 Log = File.AppendText(LogFile);
66 Log.WriteLine("========================================================================");
67 Log.WriteLine(componentname + " Started at " + DateTime.Now.ToString());
68 }
69
70 public void Close()
71 {
72 Log.WriteLine("Shutdown at " + DateTime.Now.ToString());
73 Log.Close();
74 }
75
76 public void Write(string format, params object[] args)
77 {
78 Notice(format, args);
79 return;
80 }
81
82 public void WriteLine(LogPriority importance, string format, params object[] args)
83 {
84 Log.WriteLine(format, args);
85 Log.Flush();
86 if (!m_silent)
87 {
88 System.Console.WriteLine(format, args);
89 }
90 return;
91 }
92
93 public void Warn(string format, params object[] args)
94 {
95 WriteNewLine(ConsoleColor.Yellow, format, args);
96 return;
97 }
98
99 public void Notice(string format, params object[] args)
100 {
101 WriteNewLine(ConsoleColor.White, format, args);
102 return;
103 }
104
105 public void Error(string format, params object[] args)
106 {
107 WriteNewLine(ConsoleColor.Red, format, args);
108 return;
109 }
110
111 public void Verbose(string format, params object[] args)
112 {
113 WriteNewLine(ConsoleColor.Gray, format, args);
114 return;
115 }
116
117 public void Status(string format, params object[] args)
118 {
119 WriteNewLine(ConsoleColor.Blue, format, args);
120 return;
121 }
122
123 private void WriteNewLine(ConsoleColor color, string format, params object[] args)
124 {
125 Log.WriteLine(format, args);
126 Log.Flush();
127 if (!m_silent)
128 {
129 try
130 {
131 System.Console.ForegroundColor = color;
132 System.Console.WriteLine(format, args);
133 System.Console.ResetColor();
134 }
135 catch (ArgumentNullException)
136 {
137 // Some older systems dont support coloured text.
138 System.Console.WriteLine(format, args);
139 }
140 }
141 return;
142 }
143
144 public string ReadLine()
145 {
146 string TempStr = System.Console.ReadLine();
147 Log.WriteLine(TempStr);
148 return TempStr;
149 }
150
151 public int Read()
152 {
153 int TempInt = System.Console.Read();
154 Log.Write((char)TempInt);
155 return TempInt;
156 }
157
158 public IPAddress CmdPromptIPAddress(string prompt, string defaultvalue)
159 {
160 IPAddress address;
161 string addressStr;
162
163 while (true)
164 {
165 addressStr = MainLog.Instance.CmdPrompt(prompt, defaultvalue);
166 if (IPAddress.TryParse(addressStr, out address))
167 {
168 break;
169 }
170 else
171 {
172 MainLog.Instance.Error("Illegal address. Please re-enter.");
173 }
174 }
175
176 return address;
177 }
178
179 public int CmdPromptIPPort(string prompt, string defaultvalue)
180 {
181 int port;
182 string portStr;
183
184 while (true)
185 {
186 portStr = MainLog.Instance.CmdPrompt(prompt, defaultvalue);
187 if (int.TryParse(portStr, out port))
188 {
189 if (port >= IPEndPoint.MinPort && port <= IPEndPoint.MaxPort)
190 {
191 break;
192 }
193 }
194
195 MainLog.Instance.Error("Illegal address. Please re-enter.");
196 }
197
198 return port;
199 }
200
201 // Displays a prompt and waits for the user to enter a string, then returns that string
202 // Done with no echo and suitable for passwords
203 public string PasswdPrompt(string prompt)
204 {
205 // FIXME: Needs to be better abstracted
206 Log.WriteLine(prompt);
207 this.Write(prompt);
208 ConsoleColor oldfg = System.Console.ForegroundColor;
209 System.Console.ForegroundColor = System.Console.BackgroundColor;
210 string temp = System.Console.ReadLine();
211 System.Console.ForegroundColor = oldfg;
212 return temp;
213 }
214
215 // Displays a command prompt and waits for the user to enter a string, then returns that string
216 public string CmdPrompt(string prompt)
217 {
218 this.Write(String.Format("{0}: ", prompt));
219 return this.ReadLine();
220 }
221
222 // Displays a command prompt and returns a default value if the user simply presses enter
223 public string CmdPrompt(string prompt, string defaultresponse)
224 {
225 string temp = CmdPrompt(String.Format("{0} [{1}]", prompt, defaultresponse));
226 if (temp == "")
227 {
228 return defaultresponse;
229 }
230 else
231 {
232 return temp;
233 }
234 }
235
236 // Displays a command prompt and returns a default value, user may only enter 1 of 2 options
237 public string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB)
238 {
239 bool itisdone = false;
240 string temp = CmdPrompt(prompt, defaultresponse);
241 while (itisdone == false)
242 {
243 if ((temp == OptionA) || (temp == OptionB))
244 {
245 itisdone = true;
246 }
247 else
248 {
249 Notice("Valid options are " + OptionA + " or " + OptionB);
250 temp = CmdPrompt(prompt, defaultresponse);
251 }
252 }
253 return temp;
254 }
255
256 // Runs a command with a number of parameters
257 public Object RunCmd(string Cmd, string[] cmdparams)
258 {
259 cmdparser.RunCmd(Cmd, cmdparams);
260 return null;
261 }
262
263 // Shows data about something
264 public void ShowCommands(string ShowWhat)
265 {
266 cmdparser.Show(ShowWhat);
267 }
268
269 public void MainLogPrompt()
270 {
271 string[] tempstrarray;
272 string tempstr = this.CmdPrompt(this.componentname + "# ");
273 tempstrarray = tempstr.Split(' ');
274 string cmd = tempstrarray[0];
275 Array.Reverse(tempstrarray);
276 Array.Resize<string>(ref tempstrarray, tempstrarray.Length - 1);
277 Array.Reverse(tempstrarray);
278 string[] cmdparams = (string[])tempstrarray;
279 RunCmd(cmd, cmdparams);
280 }
281 }
282}
diff --git a/OpenSim/Framework/Console/MainLog.cs b/OpenSim/Framework/Console/MainLog.cs
new file mode 100644
index 0000000..7d52622
--- /dev/null
+++ b/OpenSim/Framework/Console/MainLog.cs
@@ -0,0 +1,47 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28namespace OpenSim.Framework.Console
29{
30 public class MainLog {
31
32 private static LogBase instance;
33
34 public static LogBase Instance
35 {
36 get
37 {
38 return instance;
39 }
40 set
41 {
42 instance = value;
43 }
44 }
45 }
46
47}
diff --git a/OpenSim/Framework/Data.DB4o/DB4oGridData.cs b/OpenSim/Framework/Data.DB4o/DB4oGridData.cs
new file mode 100644
index 0000000..5fec367
--- /dev/null
+++ b/OpenSim/Framework/Data.DB4o/DB4oGridData.cs
@@ -0,0 +1,162 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28
29using System;
30using libsecondlife;
31
32namespace OpenSim.Framework.Data.DB4o
33{
34 /// <summary>
35 /// A grid server storage mechanism employing the DB4o database system
36 /// </summary>
37 class DB4oGridData : IGridData
38 {
39 /// <summary>
40 /// The database manager object
41 /// </summary>
42 DB4oGridManager manager;
43
44 /// <summary>
45 /// Called when the plugin is first loaded (as constructors are not called)
46 /// </summary>
47 public void Initialise() {
48 manager = new DB4oGridManager("gridserver.yap");
49 }
50
51 /// <summary>
52 /// Returns a list of regions within the specified ranges
53 /// </summary>
54 /// <param name="a">minimum X coordinate</param>
55 /// <param name="b">minimum Y coordinate</param>
56 /// <param name="c">maximum X coordinate</param>
57 /// <param name="d">maximum Y coordinate</param>
58 /// <returns>An array of region profiles</returns>
59 public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
60 {
61 return null;
62 }
63
64 /// <summary>
65 /// Returns a region located at the specified regionHandle (warning multiple regions may occupy the one spot, first found is returned)
66 /// </summary>
67 /// <param name="handle">The handle to search for</param>
68 /// <returns>A region profile</returns>
69 public SimProfileData GetProfileByHandle(ulong handle) {
70 lock (manager.simProfiles)
71 {
72 foreach (LLUUID UUID in manager.simProfiles.Keys)
73 {
74 if (manager.simProfiles[UUID].regionHandle == handle)
75 {
76 return manager.simProfiles[UUID];
77 }
78 }
79 }
80 throw new Exception("Unable to find profile with handle (" + handle.ToString() + ")");
81 }
82
83 /// <summary>
84 /// Returns a specific region
85 /// </summary>
86 /// <param name="uuid">The region ID code</param>
87 /// <returns>A region profile</returns>
88 public SimProfileData GetProfileByLLUUID(LLUUID uuid)
89 {
90 lock (manager.simProfiles)
91 {
92 if (manager.simProfiles.ContainsKey(uuid))
93 return manager.simProfiles[uuid];
94 }
95 throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + "). Total Registered Regions: " + manager.simProfiles.Count);
96 }
97
98 /// <summary>
99 /// Adds a new specified region to the database
100 /// </summary>
101 /// <param name="profile">The profile to add</param>
102 /// <returns>A dataresponse enum indicating success</returns>
103 public DataResponse AddProfile(SimProfileData profile)
104 {
105 lock (manager.simProfiles)
106 {
107 if (manager.AddRow(profile))
108 {
109 return DataResponse.RESPONSE_OK;
110 }
111 else
112 {
113 return DataResponse.RESPONSE_ERROR;
114 }
115 }
116 }
117
118 /// <summary>
119 /// Authenticates a new region using the shared secrets. NOT SECURE.
120 /// </summary>
121 /// <param name="uuid">The UUID the region is authenticating with</param>
122 /// <param name="handle">The location the region is logging into (unused in Db4o)</param>
123 /// <param name="key">The shared secret</param>
124 /// <returns>Authenticated?</returns>
125 public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) {
126 if (manager.simProfiles[uuid].regionRecvKey == key)
127 return true;
128 return false;
129 }
130
131 /// <summary>
132 /// Shuts down the database
133 /// </summary>
134 public void Close()
135 {
136 manager = null;
137 }
138
139 /// <summary>
140 /// Returns the providers name
141 /// </summary>
142 /// <returns>The name of the storage system</returns>
143 public string getName()
144 {
145 return "DB4o Grid Provider";
146 }
147
148 /// <summary>
149 /// Returns the providers version
150 /// </summary>
151 /// <returns>The version of the storage system</returns>
152 public string getVersion()
153 {
154 return "0.1";
155 }
156
157 public ReservationData GetReservationAtPoint(uint x, uint y)
158 {
159 return null;
160 }
161 }
162}
diff --git a/OpenSim/Framework/Data.DB4o/DB4oManager.cs b/OpenSim/Framework/Data.DB4o/DB4oManager.cs
new file mode 100644
index 0000000..0df6350
--- /dev/null
+++ b/OpenSim/Framework/Data.DB4o/DB4oManager.cs
@@ -0,0 +1,163 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 Db4objects.Db4o;
31using libsecondlife;
32
33namespace OpenSim.Framework.Data.DB4o
34{
35 /// <summary>
36 /// A Database manager for Db4o
37 /// </summary>
38 class DB4oGridManager
39 {
40 /// <summary>
41 /// A list of the current regions connected (in-memory cache)
42 /// </summary>
43 public Dictionary<LLUUID, SimProfileData> simProfiles = new Dictionary<LLUUID, SimProfileData>();
44 /// <summary>
45 /// Database File Name
46 /// </summary>
47 string dbfl;
48
49 /// <summary>
50 /// Creates a new grid storage manager
51 /// </summary>
52 /// <param name="db4odb">Filename to the database file</param>
53 public DB4oGridManager(string db4odb)
54 {
55 dbfl = db4odb;
56 IObjectContainer database;
57 database = Db4oFactory.OpenFile(dbfl);
58 IObjectSet result = database.Get(typeof(SimProfileData));
59 // Loads the file into the in-memory cache
60 foreach(SimProfileData row in result) {
61 simProfiles.Add(row.UUID, row);
62 }
63 database.Close();
64 }
65
66 /// <summary>
67 /// Adds a new profile to the database (Warning: Probably slow.)
68 /// </summary>
69 /// <param name="row">The profile to add</param>
70 /// <returns>Successful?</returns>
71 public bool AddRow(SimProfileData row)
72 {
73 if (simProfiles.ContainsKey(row.UUID))
74 {
75 simProfiles[row.UUID] = row;
76 }
77 else
78 {
79 simProfiles.Add(row.UUID, row);
80 }
81
82 try
83 {
84 IObjectContainer database;
85 database = Db4oFactory.OpenFile(dbfl);
86 database.Set(row);
87 database.Close();
88 return true;
89 }
90 catch (Exception)
91 {
92 return false;
93 }
94 }
95
96
97 }
98
99 /// <summary>
100 /// A manager for the DB4o database (user profiles)
101 /// </summary>
102 class DB4oUserManager
103 {
104 /// <summary>
105 /// A list of the user profiles (in memory cache)
106 /// </summary>
107 public Dictionary<LLUUID, UserProfileData> userProfiles = new Dictionary<LLUUID, UserProfileData>();
108 /// <summary>
109 /// Database filename
110 /// </summary>
111 string dbfl;
112
113 /// <summary>
114 /// Initialises a new DB manager
115 /// </summary>
116 /// <param name="db4odb">The filename to the database</param>
117 public DB4oUserManager(string db4odb)
118 {
119 dbfl = db4odb;
120 IObjectContainer database;
121 database = Db4oFactory.OpenFile(dbfl);
122 // Load to cache
123 IObjectSet result = database.Get(typeof(UserProfileData));
124 foreach (UserProfileData row in result)
125 {
126 userProfiles.Add(row.UUID, row);
127 }
128 database.Close();
129 }
130
131 /// <summary>
132 /// Adds a new profile to the database (Warning: Probably slow.)
133 /// </summary>
134 /// <param name="row">The profile to add</param>
135 /// <returns>Successful?</returns>
136 public bool AddRow(UserProfileData row)
137 {
138 if (userProfiles.ContainsKey(row.UUID))
139 {
140 userProfiles[row.UUID] = row;
141 }
142 else
143 {
144 userProfiles.Add(row.UUID, row);
145 }
146
147 try
148 {
149 IObjectContainer database;
150 database = Db4oFactory.OpenFile(dbfl);
151 database.Set(row);
152 database.Close();
153 return true;
154 }
155 catch (Exception)
156 {
157 return false;
158 }
159 }
160
161
162 }
163}
diff --git a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs
new file mode 100644
index 0000000..2e33ab0
--- /dev/null
+++ b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs
@@ -0,0 +1,202 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
30
31namespace OpenSim.Framework.Data.DB4o
32{
33 /// <summary>
34 /// A User storage interface for the DB4o database system
35 /// </summary>
36 public class DB4oUserData : IUserData
37 {
38 /// <summary>
39 /// The database manager
40 /// </summary>
41 DB4oUserManager manager;
42
43 /// <summary>
44 /// Artificial constructor called upon plugin load
45 /// </summary>
46 public void Initialise()
47 {
48 manager = new DB4oUserManager("userprofiles.yap");
49 }
50
51 /// <summary>
52 /// Loads a specified user profile from a UUID
53 /// </summary>
54 /// <param name="uuid">The users UUID</param>
55 /// <returns>A user profile</returns>
56 public UserProfileData getUserByUUID(LLUUID uuid)
57 {
58 if(manager.userProfiles.ContainsKey(uuid))
59 return manager.userProfiles[uuid];
60 return null;
61 }
62
63 /// <summary>
64 /// Returns a user by searching for its name
65 /// </summary>
66 /// <param name="name">The users account name</param>
67 /// <returns>A matching users profile</returns>
68 public UserProfileData getUserByName(string name)
69 {
70 return getUserByName(name.Split(' ')[0], name.Split(' ')[1]);
71 }
72
73 /// <summary>
74 /// Returns a user by searching for its name
75 /// </summary>
76 /// <param name="fname">The first part of the users account name</param>
77 /// <param name="lname">The second part of the users account name</param>
78 /// <returns>A matching users profile</returns>
79 public UserProfileData getUserByName(string fname, string lname)
80 {
81 foreach (UserProfileData profile in manager.userProfiles.Values)
82 {
83 if (profile.username == fname && profile.surname == lname)
84 return profile;
85 }
86 return null;
87 }
88
89 /// <summary>
90 /// Returns a user by UUID direct
91 /// </summary>
92 /// <param name="uuid">The users account ID</param>
93 /// <returns>A matching users profile</returns>
94 public UserAgentData getAgentByUUID(LLUUID uuid)
95 {
96 try
97 {
98 return getUserByUUID(uuid).currentAgent;
99 }
100 catch (Exception)
101 {
102 return null;
103 }
104 }
105
106 /// <summary>
107 /// Returns a session by account name
108 /// </summary>
109 /// <param name="name">The account name</param>
110 /// <returns>The users session agent</returns>
111 public UserAgentData getAgentByName(string name)
112 {
113 return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]);
114 }
115
116 /// <summary>
117 /// Returns a session by account name
118 /// </summary>
119 /// <param name="fname">The first part of the users account name</param>
120 /// <param name="lname">The second part of the users account name</param>
121 /// <returns>A user agent</returns>
122 public UserAgentData getAgentByName(string fname, string lname)
123 {
124 try
125 {
126 return getUserByName(fname,lname).currentAgent;
127 }
128 catch (Exception)
129 {
130 return null;
131 }
132 }
133
134 /// <summary>
135 /// Creates a new user profile
136 /// </summary>
137 /// <param name="user">The profile to add to the database</param>
138 public void addNewUserProfile(UserProfileData user)
139 {
140 try
141 {
142 manager.AddRow(user);
143 }
144 catch (Exception e)
145 {
146 Console.WriteLine(e.ToString());
147 }
148 }
149
150 /// <summary>
151 /// Creates a new user agent
152 /// </summary>
153 /// <param name="agent">The agent to add to the database</param>
154 public void addNewUserAgent(UserAgentData agent)
155 {
156 // Do nothing. yet.
157 }
158
159 /// <summary>
160 /// Transfers money between two user accounts
161 /// </summary>
162 /// <param name="from">Starting account</param>
163 /// <param name="to">End account</param>
164 /// <param name="amount">The amount to move</param>
165 /// <returns>Success?</returns>
166 public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount)
167 {
168 return true;
169 }
170
171 /// <summary>
172 /// Transfers inventory between two accounts
173 /// </summary>
174 /// <remarks>Move to inventory server</remarks>
175 /// <param name="from">Senders account</param>
176 /// <param name="to">Recievers account</param>
177 /// <param name="item">Inventory item</param>
178 /// <returns>Success?</returns>
179 public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
180 {
181 return true;
182 }
183
184 /// <summary>
185 /// Returns the name of the storage provider
186 /// </summary>
187 /// <returns>Storage provider name</returns>
188 public string getName()
189 {
190 return "DB4o Userdata";
191 }
192
193 /// <summary>
194 /// Returns the version of the storage provider
195 /// </summary>
196 /// <returns>Storage provider version</returns>
197 public string getVersion()
198 {
199 return "0.1";
200 }
201 }
202}
diff --git a/OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..905cd9b
--- /dev/null
+++ b/OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Framework.Data.DB4o")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenSim.Framework.Data.DB4o")]
11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("57991e15-79da-41b7-aa06-2e6b49165a63")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs
new file mode 100644
index 0000000..ca9196a5
--- /dev/null
+++ b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs
@@ -0,0 +1,194 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Data;
31using System.Security.Cryptography;
32using System.Text;
33using libsecondlife;
34
35namespace OpenSim.Framework.Data.MSSQL
36{
37 /// <summary>
38 /// A grid data interface for Microsoft SQL Server
39 /// </summary>
40 public class SqlGridData : IGridData
41 {
42 /// <summary>
43 /// Database manager
44 /// </summary>
45 private MSSqlManager database;
46
47 /// <summary>
48 /// Initialises the Grid Interface
49 /// </summary>
50 public void Initialise()
51 {
52 database = new MSSqlManager("localhost", "db", "user", "password", "false");
53 }
54
55 /// <summary>
56 /// Shuts down the grid interface
57 /// </summary>
58 public void Close()
59 {
60 database.Close();
61 }
62
63 /// <summary>
64 /// Returns the storage system name
65 /// </summary>
66 /// <returns>A string containing the storage system name</returns>
67 public string getName()
68 {
69 return "Sql OpenGridData";
70 }
71
72 /// <summary>
73 /// Returns the storage system version
74 /// </summary>
75 /// <returns>A string containing the storage system version</returns>
76 public string getVersion()
77 {
78 return "0.1";
79 }
80
81 /// <summary>
82 /// Returns a list of regions within the specified ranges
83 /// </summary>
84 /// <param name="a">minimum X coordinate</param>
85 /// <param name="b">minimum Y coordinate</param>
86 /// <param name="c">maximum X coordinate</param>
87 /// <param name="d">maximum Y coordinate</param>
88 /// <returns>An array of region profiles</returns>
89 public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
90 {
91 return null;
92 }
93
94 /// <summary>
95 /// Returns a sim profile from it's location
96 /// </summary>
97 /// <param name="handle">Region location handle</param>
98 /// <returns>Sim profile</returns>
99 public SimProfileData GetProfileByHandle(ulong handle)
100 {
101 Dictionary<string, string> param = new Dictionary<string, string>();
102 param["handle"] = handle.ToString();
103
104 IDbCommand result = database.Query("SELECT * FROM regions WHERE handle = @handle", param);
105 IDataReader reader = result.ExecuteReader();
106
107 SimProfileData row = database.getRow(reader);
108 reader.Close();
109 result.Dispose();
110
111 return row;
112 }
113
114 /// <summary>
115 /// Returns a sim profile from it's UUID
116 /// </summary>
117 /// <param name="uuid">The region UUID</param>
118 /// <returns>The sim profile</returns>
119 public SimProfileData GetProfileByLLUUID(LLUUID uuid)
120 {
121 Dictionary<string, string> param = new Dictionary<string, string>();
122 param["uuid"] = uuid.ToStringHyphenated();
123
124 IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = @uuid", param);
125 IDataReader reader = result.ExecuteReader();
126
127 SimProfileData row = database.getRow(reader);
128 reader.Close();
129 result.Dispose();
130
131 return row;
132 }
133
134 /// <summary>
135 /// Adds a new specified region to the database
136 /// </summary>
137 /// <param name="profile">The profile to add</param>
138 /// <returns>A dataresponse enum indicating success</returns>
139 public DataResponse AddProfile(SimProfileData profile)
140 {
141 if (database.insertRow(profile))
142 {
143 return DataResponse.RESPONSE_OK;
144 }
145 else
146 {
147 return DataResponse.RESPONSE_ERROR;
148 }
149 }
150
151 /// <summary>
152 /// DEPRECIATED. Attempts to authenticate a region by comparing a shared secret.
153 /// </summary>
154 /// <param name="uuid">The UUID of the challenger</param>
155 /// <param name="handle">The attempted regionHandle of the challenger</param>
156 /// <param name="authkey">The secret</param>
157 /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
158 public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey)
159 {
160 bool throwHissyFit = false; // Should be true by 1.0
161
162 if (throwHissyFit)
163 throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
164
165 SimProfileData data = GetProfileByLLUUID(uuid);
166
167 return (handle == data.regionHandle && authkey == data.regionSecret);
168 }
169
170 /// <summary>
171 /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region
172 /// </summary>
173 /// <remarks>This requires a security audit.</remarks>
174 /// <param name="uuid"></param>
175 /// <param name="handle"></param>
176 /// <param name="authhash"></param>
177 /// <param name="challenge"></param>
178 /// <returns></returns>
179 public bool AuthenticateSim(LLUUID uuid, ulong handle, string authhash, string challenge)
180 {
181 SHA512Managed HashProvider = new SHA512Managed();
182 ASCIIEncoding TextProvider = new ASCIIEncoding();
183
184 byte[] stream = TextProvider.GetBytes(uuid.ToStringHyphenated() + ":" + handle.ToString() + ":" + challenge);
185 byte[] hash = HashProvider.ComputeHash(stream);
186 return false;
187 }
188 public ReservationData GetReservationAtPoint(uint x, uint y)
189 {
190 return null;
191 }
192 }
193
194}
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs b/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
new file mode 100644
index 0000000..49bf31c
--- /dev/null
+++ b/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
@@ -0,0 +1,211 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Data;
31using System.Data.SqlClient;
32using libsecondlife;
33
34namespace OpenSim.Framework.Data.MSSQL
35{
36 /// <summary>
37 /// A management class for the MS SQL Storage Engine
38 /// </summary>
39 class MSSqlManager
40 {
41 /// <summary>
42 /// The database connection object
43 /// </summary>
44 IDbConnection dbcon;
45
46 /// <summary>
47 /// Initialises and creates a new Sql connection and maintains it.
48 /// </summary>
49 /// <param name="hostname">The Sql server being connected to</param>
50 /// <param name="database">The name of the Sql database being used</param>
51 /// <param name="username">The username logging into the database</param>
52 /// <param name="password">The password for the user logging in</param>
53 /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param>
54 public MSSqlManager(string hostname, string database, string username, string password, string cpooling)
55 {
56 try
57 {
58 string connectionString = "Server=" + hostname + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";";
59 dbcon = new SqlConnection(connectionString);
60
61 dbcon.Open();
62 }
63 catch (Exception e)
64 {
65 throw new Exception("Error initialising Sql Database: " + e.ToString());
66 }
67 }
68
69 /// <summary>
70 /// Shuts down the database connection
71 /// </summary>
72 public void Close()
73 {
74 dbcon.Close();
75 dbcon = null;
76 }
77
78 /// <summary>
79 /// Runs a query with protection against SQL Injection by using parameterised input.
80 /// </summary>
81 /// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param>
82 /// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param>
83 /// <returns>A Sql DB Command</returns>
84 public IDbCommand Query(string sql, Dictionary<string, string> parameters)
85 {
86 SqlCommand dbcommand = (SqlCommand)dbcon.CreateCommand();
87 dbcommand.CommandText = sql;
88 foreach (KeyValuePair<string, string> param in parameters)
89 {
90 dbcommand.Parameters.AddWithValue(param.Key, param.Value);
91 }
92
93 return (IDbCommand)dbcommand;
94 }
95
96 /// <summary>
97 /// Runs a database reader object and returns a region row
98 /// </summary>
99 /// <param name="reader">An active database reader</param>
100 /// <returns>A region row</returns>
101 public SimProfileData getRow(IDataReader reader)
102 {
103 SimProfileData regionprofile = new SimProfileData();
104
105 if (reader.Read())
106 {
107 // Region Main
108 regionprofile.regionHandle = (ulong)reader["regionHandle"];
109 regionprofile.regionName = (string)reader["regionName"];
110 regionprofile.UUID = new LLUUID((string)reader["uuid"]);
111
112 // Secrets
113 regionprofile.regionRecvKey = (string)reader["regionRecvKey"];
114 regionprofile.regionSecret = (string)reader["regionSecret"];
115 regionprofile.regionSendKey = (string)reader["regionSendKey"];
116
117 // Region Server
118 regionprofile.regionDataURI = (string)reader["regionDataURI"];
119 regionprofile.regionOnline = false; // Needs to be pinged before this can be set.
120 regionprofile.serverIP = (string)reader["serverIP"];
121 regionprofile.serverPort = (uint)reader["serverPort"];
122 regionprofile.serverURI = (string)reader["serverURI"];
123
124 // Location
125 regionprofile.regionLocX = (uint)((int)reader["locX"]);
126 regionprofile.regionLocY = (uint)((int)reader["locY"]);
127 regionprofile.regionLocZ = (uint)((int)reader["locZ"]);
128
129 // Neighbours - 0 = No Override
130 regionprofile.regionEastOverrideHandle = (ulong)reader["eastOverrideHandle"];
131 regionprofile.regionWestOverrideHandle = (ulong)reader["westOverrideHandle"];
132 regionprofile.regionSouthOverrideHandle = (ulong)reader["southOverrideHandle"];
133 regionprofile.regionNorthOverrideHandle = (ulong)reader["northOverrideHandle"];
134
135 // Assets
136 regionprofile.regionAssetURI = (string)reader["regionAssetURI"];
137 regionprofile.regionAssetRecvKey = (string)reader["regionAssetRecvKey"];
138 regionprofile.regionAssetSendKey = (string)reader["regionAssetSendKey"];
139
140 // Userserver
141 regionprofile.regionUserURI = (string)reader["regionUserURI"];
142 regionprofile.regionUserRecvKey = (string)reader["regionUserRecvKey"];
143 regionprofile.regionUserSendKey = (string)reader["regionUserSendKey"];
144 }
145 else
146 {
147 throw new Exception("No rows to return");
148 }
149 return regionprofile;
150 }
151
152 /// <summary>
153 /// Creates a new region in the database
154 /// </summary>
155 /// <param name="profile">The region profile to insert</param>
156 /// <returns>Successful?</returns>
157 public bool insertRow(SimProfileData profile)
158 {
159 string sql = "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
160 sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
161 sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey) VALUES ";
162
163 sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, ";
164 sql += "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, ";
165 sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);";
166
167 Dictionary<string, string> parameters = new Dictionary<string, string>();
168
169 parameters["regionHandle"] = profile.regionHandle.ToString();
170 parameters["regionName"] = profile.regionName;
171 parameters["uuid"] = profile.UUID.ToString();
172 parameters["regionRecvKey"] = profile.regionRecvKey;
173 parameters["regionSendKey"] = profile.regionSendKey;
174 parameters["regionDataURI"] = profile.regionDataURI;
175 parameters["serverIP"] = profile.serverIP;
176 parameters["serverPort"] = profile.serverPort.ToString();
177 parameters["serverURI"] = profile.serverURI;
178 parameters["locX"] = profile.regionLocX.ToString();
179 parameters["locY"] = profile.regionLocY.ToString();
180 parameters["locZ"] = profile.regionLocZ.ToString();
181 parameters["eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString();
182 parameters["westOverrideHandle"] = profile.regionWestOverrideHandle.ToString();
183 parameters["northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString();
184 parameters["southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString();
185 parameters["regionAssetURI"] = profile.regionAssetURI;
186 parameters["regionAssetRecvKey"] = profile.regionAssetRecvKey;
187 parameters["regionAssetSendKey"] = profile.regionAssetSendKey;
188 parameters["regionUserURI"] = profile.regionUserURI;
189 parameters["regionUserRecvKey"] = profile.regionUserRecvKey;
190 parameters["regionUserSendKey"] = profile.regionUserSendKey;
191
192 bool returnval = false;
193
194 try
195 {
196 IDbCommand result = Query(sql, parameters);
197
198 if (result.ExecuteNonQuery() == 1)
199 returnval = true;
200
201 result.Dispose();
202 }
203 catch (Exception)
204 {
205 return false;
206 }
207
208 return returnval;
209 }
210 }
211}
diff --git a/OpenSim/Framework/Data.MSSQL/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.MSSQL/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..066c739
--- /dev/null
+++ b/OpenSim/Framework/Data.MSSQL/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Framework.Data.MSSQL")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenSim.Framework.Data.MSSQL")]
11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("0e1c1ca4-2cf2-4315-b0e7-432c02feea8a")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs
new file mode 100644
index 0000000..ef643d2
--- /dev/null
+++ b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs
@@ -0,0 +1,287 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Data;
31using System.Security.Cryptography;
32using System.Text;
33using libsecondlife;
34
35namespace OpenSim.Framework.Data.MySQL
36{
37 /// <summary>
38 /// A MySQL Interface for the Grid Server
39 /// </summary>
40 public class MySQLGridData : IGridData
41 {
42 /// <summary>
43 /// MySQL Database Manager
44 /// </summary>
45 private MySQLManager database;
46
47 /// <summary>
48 /// Initialises the Grid Interface
49 /// </summary>
50 public void Initialise()
51 {
52 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
53 string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
54 string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
55 string settingUsername = GridDataMySqlFile.ParseFileReadValue("username");
56 string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
57 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
58 string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
59
60 database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
61 }
62
63 /// <summary>
64 /// Shuts down the grid interface
65 /// </summary>
66 public void Close()
67 {
68 database.Close();
69 }
70
71 /// <summary>
72 /// Returns the plugin name
73 /// </summary>
74 /// <returns>Plugin name</returns>
75 public string getName()
76 {
77 return "MySql OpenGridData";
78 }
79
80 /// <summary>
81 /// Returns the plugin version
82 /// </summary>
83 /// <returns>Plugin version</returns>
84 public string getVersion()
85 {
86 return "0.1";
87 }
88
89 /// <summary>
90 /// Returns all the specified region profiles within coordates -- coordinates are inclusive
91 /// </summary>
92 /// <param name="xmin">Minimum X coordinate</param>
93 /// <param name="ymin">Minimum Y coordinate</param>
94 /// <param name="xmax">Maximum X coordinate</param>
95 /// <param name="ymax">Maximum Y coordinate</param>
96 /// <returns></returns>
97 public SimProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax)
98 {
99 try
100 {
101 lock (database)
102 {
103 Dictionary<string, string> param = new Dictionary<string, string>();
104 param["?xmin"] = xmin.ToString();
105 param["?ymin"] = ymin.ToString();
106 param["?xmax"] = xmax.ToString();
107 param["?ymax"] = ymax.ToString();
108
109 IDbCommand result = database.Query("SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", param);
110 IDataReader reader = result.ExecuteReader();
111
112 SimProfileData row;
113
114 List<SimProfileData> rows = new List<SimProfileData>();
115
116 while ((row = database.readSimRow(reader)) != null)
117 {
118 rows.Add(row);
119 }
120 reader.Close();
121 result.Dispose();
122
123 return rows.ToArray();
124
125 }
126 }
127 catch (Exception e)
128 {
129 database.Reconnect();
130 Console.WriteLine(e.ToString());
131 return null;
132 }
133 }
134
135 /// <summary>
136 /// Returns a sim profile from it's location
137 /// </summary>
138 /// <param name="handle">Region location handle</param>
139 /// <returns>Sim profile</returns>
140 public SimProfileData GetProfileByHandle(ulong handle)
141 {
142 try
143 {
144 lock (database)
145 {
146 Dictionary<string, string> param = new Dictionary<string, string>();
147 param["?handle"] = handle.ToString();
148
149 IDbCommand result = database.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param);
150 IDataReader reader = result.ExecuteReader();
151
152 SimProfileData row = database.readSimRow(reader);
153 reader.Close();
154 result.Dispose();
155
156 return row;
157 }
158 }
159 catch (Exception e)
160 {
161 database.Reconnect();
162 Console.WriteLine(e.ToString());
163 return null;
164 }
165 }
166
167 /// <summary>
168 /// Returns a sim profile from it's UUID
169 /// </summary>
170 /// <param name="uuid">The region UUID</param>
171 /// <returns>The sim profile</returns>
172 public SimProfileData GetProfileByLLUUID(LLUUID uuid)
173 {
174 try
175 {
176 lock (database)
177 {
178 Dictionary<string, string> param = new Dictionary<string, string>();
179 param["?uuid"] = uuid.ToStringHyphenated();
180
181 IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = ?uuid", param);
182 IDataReader reader = result.ExecuteReader();
183
184 SimProfileData row = database.readSimRow(reader);
185 reader.Close();
186 result.Dispose();
187
188 return row;
189 }
190 }
191 catch (Exception e)
192 {
193 database.Reconnect();
194 Console.WriteLine(e.ToString());
195 return null;
196 }
197 }
198
199 /// <summary>
200 /// Adds a new profile to the database
201 /// </summary>
202 /// <param name="profile">The profile to add</param>
203 /// <returns>Successful?</returns>
204 public DataResponse AddProfile(SimProfileData profile)
205 {
206 lock (database)
207 {
208 if (database.insertRegion(profile))
209 {
210 return DataResponse.RESPONSE_OK;
211 }
212 else
213 {
214 return DataResponse.RESPONSE_ERROR;
215 }
216 }
217 }
218
219 /// <summary>
220 /// DEPRECIATED. Attempts to authenticate a region by comparing a shared secret.
221 /// </summary>
222 /// <param name="uuid">The UUID of the challenger</param>
223 /// <param name="handle">The attempted regionHandle of the challenger</param>
224 /// <param name="authkey">The secret</param>
225 /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
226 public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey)
227 {
228 bool throwHissyFit = false; // Should be true by 1.0
229
230 if (throwHissyFit)
231 throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
232
233 SimProfileData data = GetProfileByLLUUID(uuid);
234
235 return (handle == data.regionHandle && authkey == data.regionSecret);
236 }
237
238 /// <summary>
239 /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region
240 /// </summary>
241 /// <remarks>This requires a security audit.</remarks>
242 /// <param name="uuid"></param>
243 /// <param name="handle"></param>
244 /// <param name="authhash"></param>
245 /// <param name="challenge"></param>
246 /// <returns></returns>
247 public bool AuthenticateSim(LLUUID uuid, ulong handle, string authhash, string challenge)
248 {
249 SHA512Managed HashProvider = new SHA512Managed();
250 ASCIIEncoding TextProvider = new ASCIIEncoding();
251
252 byte[] stream = TextProvider.GetBytes(uuid.ToStringHyphenated() + ":" + handle.ToString() + ":" + challenge);
253 byte[] hash = HashProvider.ComputeHash(stream);
254
255 return false;
256 }
257
258 public ReservationData GetReservationAtPoint(uint x, uint y)
259 {
260 try
261 {
262 lock (database)
263 {
264 Dictionary<string, string> param = new Dictionary<string, string>();
265 param["?x"] = x.ToString();
266 param["?y"] = y.ToString();
267 IDbCommand result = database.Query("SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", param);
268 IDataReader reader = result.ExecuteReader();
269
270 ReservationData row = database.readReservationRow(reader);
271 reader.Close();
272 result.Dispose();
273
274 return row;
275 }
276 }
277 catch (Exception e)
278 {
279 database.Reconnect();
280 Console.WriteLine(e.ToString());
281 return null;
282 }
283 }
284 }
285
286
287}
diff --git a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs
new file mode 100644
index 0000000..790759a
--- /dev/null
+++ b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs
@@ -0,0 +1,309 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Data;
31using libsecondlife;
32
33namespace OpenSim.Framework.Data.MySQL
34{
35 /// <summary>
36 /// A MySQL interface for the inventory server
37 /// </summary>
38 class MySQLInventoryData : IInventoryData
39 {
40 /// <summary>
41 /// The database manager
42 /// </summary>
43 public MySQLManager database;
44
45 /// <summary>
46 /// Loads and initialises this database plugin
47 /// </summary>
48 public void Initialise()
49 {
50 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
51 string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
52 string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
53 string settingUsername = GridDataMySqlFile.ParseFileReadValue("username");
54 string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
55 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
56 string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
57
58 database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
59 }
60
61 /// <summary>
62 /// The name of this DB provider
63 /// </summary>
64 /// <returns>Name of DB provider</returns>
65 public string getName()
66 {
67 return "MySQL Inventory Data Interface";
68 }
69
70 /// <summary>
71 /// Closes this DB provider
72 /// </summary>
73 public void Close()
74 {
75 // Do nothing.
76 }
77
78 /// <summary>
79 /// Returns the version of this DB provider
80 /// </summary>
81 /// <returns>A string containing the DB provider</returns>
82 public string getVersion()
83 {
84 return "0.1";
85 }
86
87 /// <summary>
88 /// Returns a list of items in a specified folder
89 /// </summary>
90 /// <param name="folderID">The folder to search</param>
91 /// <returns>A list containing inventory items</returns>
92 public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID)
93 {
94 try
95 {
96 lock (database)
97 {
98 Dictionary<string, string> param = new Dictionary<string, string>();
99 param["?uuid"] = folderID.ToStringHyphenated();
100
101 IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", param);
102 IDataReader reader = result.ExecuteReader();
103
104 List<InventoryItemBase> items = database.readInventoryItems(reader);
105
106 reader.Close();
107 result.Dispose();
108
109 return items;
110 }
111 }
112 catch (Exception e)
113 {
114 database.Reconnect();
115 Console.WriteLine(e.ToString());
116 return null;
117 }
118 }
119
120 /// <summary>
121 /// Returns a list of the root folders within a users inventory
122 /// </summary>
123 /// <param name="user">The user whos inventory is to be searched</param>
124 /// <returns>A list of folder objects</returns>
125 public List<InventoryFolderBase> getUserRootFolders(LLUUID user)
126 {
127 try
128 {
129 lock (database)
130 {
131 Dictionary<string, string> param = new Dictionary<string, string>();
132 param["?uuid"] = user.ToStringHyphenated();
133 param["?zero"] = LLUUID.Zero.ToStringHyphenated();
134
135 IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", param);
136 IDataReader reader = result.ExecuteReader();
137
138 List<InventoryFolderBase> items = database.readInventoryFolders(reader);
139
140 reader.Close();
141 result.Dispose();
142
143 return items;
144 }
145 }
146 catch (Exception e)
147 {
148 database.Reconnect();
149 Console.WriteLine(e.ToString());
150 return null;
151 }
152 }
153
154 /// <summary>
155 /// Returns a list of folders in a users inventory contained within the specified folder
156 /// </summary>
157 /// <param name="parentID">The folder to search</param>
158 /// <returns>A list of inventory folders</returns>
159 public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID)
160 {
161 try
162 {
163 lock (database)
164 {
165 Dictionary<string, string> param = new Dictionary<string, string>();
166 param["?uuid"] = parentID.ToStringHyphenated();
167
168 IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", param);
169 IDataReader reader = result.ExecuteReader();
170
171 List<InventoryFolderBase> items = database.readInventoryFolders(reader);
172
173 reader.Close();
174 result.Dispose();
175
176 return items;
177 }
178 }
179 catch (Exception e)
180 {
181 database.Reconnect();
182 Console.WriteLine(e.ToString());
183 return null;
184 }
185 }
186
187 /// <summary>
188 /// Returns a specified inventory item
189 /// </summary>
190 /// <param name="item">The item to return</param>
191 /// <returns>An inventory item</returns>
192 public InventoryItemBase getInventoryItem(LLUUID item)
193 {
194 try
195 {
196 lock (database)
197 {
198 Dictionary<string, string> param = new Dictionary<string, string>();
199 param["?uuid"] = item.ToStringHyphenated();
200
201 IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", param);
202 IDataReader reader = result.ExecuteReader();
203
204 List<InventoryItemBase> items = database.readInventoryItems(reader);
205
206 reader.Close();
207 result.Dispose();
208
209 if (items.Count > 0)
210 {
211 return items[0];
212 }
213 else
214 {
215 return null;
216 }
217 }
218 }
219 catch (Exception e)
220 {
221 database.Reconnect();
222 Console.WriteLine(e.ToString());
223 return null;
224 }
225 }
226
227 /// <summary>
228 /// Returns a specified inventory folder
229 /// </summary>
230 /// <param name="folder">The folder to return</param>
231 /// <returns>A folder class</returns>
232 public InventoryFolderBase getInventoryFolder(LLUUID folder)
233 {
234 try
235 {
236 lock (database)
237 {
238 Dictionary<string, string> param = new Dictionary<string, string>();
239 param["?uuid"] = folder.ToStringHyphenated();
240
241 IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", param);
242 IDataReader reader = result.ExecuteReader();
243
244 List<InventoryFolderBase> items = database.readInventoryFolders(reader);
245
246 reader.Close();
247 result.Dispose();
248
249 if (items.Count > 0)
250 {
251 return items[0];
252 }
253 else
254 {
255 return null;
256 }
257 }
258 }
259 catch (Exception e)
260 {
261 database.Reconnect();
262 Console.WriteLine(e.ToString());
263 return null;
264 }
265 }
266
267 /// <summary>
268 /// Adds a specified item to the database
269 /// </summary>
270 /// <param name="item">The inventory item</param>
271 public void addInventoryItem(InventoryItemBase item)
272 {
273 lock (database)
274 {
275 database.insertItem(item);
276 }
277 }
278
279 /// <summary>
280 /// Updates the specified inventory item
281 /// </summary>
282 /// <param name="item">Inventory item to update</param>
283 public void updateInventoryItem(InventoryItemBase item)
284 {
285 addInventoryItem(item);
286 }
287
288 /// <summary>
289 /// Creates a new inventory folder
290 /// </summary>
291 /// <param name="folder">Folder to create</param>
292 public void addInventoryFolder(InventoryFolderBase folder)
293 {
294 lock (database)
295 {
296 database.insertFolder(folder);
297 }
298 }
299
300 /// <summary>
301 /// Updates an inventory folder
302 /// </summary>
303 /// <param name="folder">Folder to update</param>
304 public void updateInventoryFolder(InventoryFolderBase folder)
305 {
306 addInventoryFolder(folder);
307 }
308 }
309}
diff --git a/OpenSim/Framework/Data.MySQL/MySQLLogData.cs b/OpenSim/Framework/Data.MySQL/MySQLLogData.cs
new file mode 100644
index 0000000..38f9fd3
--- /dev/null
+++ b/OpenSim/Framework/Data.MySQL/MySQLLogData.cs
@@ -0,0 +1,105 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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;
29
30namespace OpenSim.Framework.Data.MySQL
31{
32 /// <summary>
33 /// An interface to the log database for MySQL
34 /// </summary>
35 class MySQLLogData : ILogData
36 {
37 /// <summary>
38 /// The database manager
39 /// </summary>
40 public MySQLManager database;
41
42 /// <summary>
43 /// Artificial constructor called when the plugin is loaded
44 /// </summary>
45 public void Initialise()
46 {
47 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
48 string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
49 string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
50 string settingUsername = GridDataMySqlFile.ParseFileReadValue("username");
51 string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
52 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
53 string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
54
55 database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
56 }
57
58 /// <summary>
59 /// Saves a log item to the database
60 /// </summary>
61 /// <param name="serverDaemon">The daemon triggering the event</param>
62 /// <param name="target">The target of the action (region / agent UUID, etc)</param>
63 /// <param name="methodCall">The method call where the problem occured</param>
64 /// <param name="arguments">The arguments passed to the method</param>
65 /// <param name="priority">How critical is this?</param>
66 /// <param name="logMessage">The message to log</param>
67 public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage)
68 {
69 try
70 {
71 database.insertLogRow(serverDaemon, target, methodCall, arguments, priority, logMessage);
72 }
73 catch
74 {
75 database.Reconnect();
76 }
77 }
78
79 /// <summary>
80 /// Returns the name of this DB provider
81 /// </summary>
82 /// <returns>A string containing the DB provider name</returns>
83 public string getName()
84 {
85 return "MySQL Logdata Interface";
86 }
87
88 /// <summary>
89 /// Closes the database provider
90 /// </summary>
91 public void Close()
92 {
93 // Do nothing.
94 }
95
96 /// <summary>
97 /// Returns the version of this DB provider
98 /// </summary>
99 /// <returns>A string containing the provider version</returns>
100 public string getVersion()
101 {
102 return "0.1";
103 }
104 }
105}
diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs
new file mode 100644
index 0000000..88365a3
--- /dev/null
+++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs
@@ -0,0 +1,602 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Data;
31using libsecondlife;
32using MySql.Data.MySqlClient;
33
34namespace OpenSim.Framework.Data.MySQL
35{
36 /// <summary>
37 /// A MySQL Database manager
38 /// </summary>
39 class MySQLManager
40 {
41 /// <summary>
42 /// The database connection object
43 /// </summary>
44 IDbConnection dbcon;
45 /// <summary>
46 /// Connection string for ADO.net
47 /// </summary>
48 string connectionString;
49
50 /// <summary>
51 /// Initialises and creates a new MySQL connection and maintains it.
52 /// </summary>
53 /// <param name="hostname">The MySQL server being connected to</param>
54 /// <param name="database">The name of the MySQL database being used</param>
55 /// <param name="username">The username logging into the database</param>
56 /// <param name="password">The password for the user logging in</param>
57 /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param>
58 public MySQLManager(string hostname, string database, string username, string password, string cpooling, string port)
59 {
60 try
61 {
62 connectionString = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";";
63 dbcon = new MySqlConnection(connectionString);
64
65 dbcon.Open();
66
67 Console.WriteLine("MySQL connection established");
68 }
69 catch (Exception e)
70 {
71 throw new Exception("Error initialising MySql Database: " + e.ToString());
72 }
73 }
74
75 /// <summary>
76 /// Shuts down the database connection
77 /// </summary>
78 public void Close()
79 {
80 dbcon.Close();
81 dbcon = null;
82 }
83
84 /// <summary>
85 /// Reconnects to the database
86 /// </summary>
87 public void Reconnect()
88 {
89 lock (dbcon)
90 {
91 try
92 {
93 // Close the DB connection
94 dbcon.Close();
95 // Try reopen it
96 dbcon = new MySqlConnection(connectionString);
97 dbcon.Open();
98 }
99 catch (Exception e)
100 {
101 Console.WriteLine("Unable to reconnect to database " + e.ToString());
102 }
103 }
104 }
105
106 /// <summary>
107 /// Runs a query with protection against SQL Injection by using parameterised input.
108 /// </summary>
109 /// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param>
110 /// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param>
111 /// <returns>A MySQL DB Command</returns>
112 public IDbCommand Query(string sql, Dictionary<string, string> parameters)
113 {
114 try
115 {
116 MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand();
117 dbcommand.CommandText = sql;
118 foreach (KeyValuePair<string, string> param in parameters)
119 {
120 dbcommand.Parameters.Add(param.Key, param.Value);
121 }
122
123 return (IDbCommand)dbcommand;
124 }
125 catch
126 {
127 lock (dbcon)
128 {
129 // Close the DB connection
130 try
131 {
132 dbcon.Close();
133 }
134 catch { }
135
136 // Try reopen it
137 try
138 {
139 dbcon = new MySqlConnection(connectionString);
140 dbcon.Open();
141 }
142 catch (Exception e)
143 {
144 Console.WriteLine("Unable to reconnect to database " + e.ToString());
145 }
146
147 // Run the query again
148 try
149 {
150 MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand();
151 dbcommand.CommandText = sql;
152 foreach (KeyValuePair<string, string> param in parameters)
153 {
154 dbcommand.Parameters.Add(param.Key, param.Value);
155 }
156
157 return (IDbCommand)dbcommand;
158 }
159 catch (Exception e)
160 {
161 // Return null if it fails.
162 Console.WriteLine("Failed during Query generation: " + e.ToString());
163 return null;
164 }
165 }
166 }
167 }
168
169 /// <summary>
170 /// Reads a region row from a database reader
171 /// </summary>
172 /// <param name="reader">An active database reader</param>
173 /// <returns>A region profile</returns>
174 public SimProfileData readSimRow(IDataReader reader)
175 {
176 SimProfileData retval = new SimProfileData();
177
178 if (reader.Read())
179 {
180 // Region Main
181 retval.regionHandle = Convert.ToUInt64(reader["regionHandle"].ToString());
182 retval.regionName = (string)reader["regionName"];
183 retval.UUID = new LLUUID((string)reader["uuid"]);
184
185 // Secrets
186 retval.regionRecvKey = (string)reader["regionRecvKey"];
187 retval.regionSecret = (string)reader["regionSecret"];
188 retval.regionSendKey = (string)reader["regionSendKey"];
189
190 // Region Server
191 retval.regionDataURI = (string)reader["regionDataURI"];
192 retval.regionOnline = false; // Needs to be pinged before this can be set.
193 retval.serverIP = (string)reader["serverIP"];
194 retval.serverPort = (uint)reader["serverPort"];
195 retval.serverURI = (string)reader["serverURI"];
196
197 // Location
198 retval.regionLocX = Convert.ToUInt32(reader["locX"].ToString());
199 retval.regionLocY = Convert.ToUInt32(reader["locY"].ToString());
200 retval.regionLocZ = Convert.ToUInt32(reader["locZ"].ToString());
201
202 // Neighbours - 0 = No Override
203 retval.regionEastOverrideHandle = Convert.ToUInt64(reader["eastOverrideHandle"].ToString());
204 retval.regionWestOverrideHandle = Convert.ToUInt64(reader["westOverrideHandle"].ToString());
205 retval.regionSouthOverrideHandle = Convert.ToUInt64(reader["southOverrideHandle"].ToString());
206 retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString());
207
208 // Assets
209 retval.regionAssetURI = (string)reader["regionAssetURI"];
210 retval.regionAssetRecvKey = (string)reader["regionAssetRecvKey"];
211 retval.regionAssetSendKey = (string)reader["regionAssetSendKey"];
212
213 // Userserver
214 retval.regionUserURI = (string)reader["regionUserURI"];
215 retval.regionUserRecvKey = (string)reader["regionUserRecvKey"];
216 retval.regionUserSendKey = (string)reader["regionUserSendKey"];
217
218 // World Map Addition
219 string tempRegionMap = reader["regionMapTexture"].ToString();
220 if (tempRegionMap != "")
221 {
222 retval.regionMapTextureID = new LLUUID(tempRegionMap);
223 }
224 else
225 {
226 retval.regionMapTextureID = new LLUUID();
227 }
228 }
229 else
230 {
231 return null;
232 }
233 return retval;
234 }
235
236 /// <summary>
237 /// Reads a reservation row from a database reader
238 /// </summary>
239 /// <param name="reader">An active database reader</param>
240 /// <returns>A reservation data object</returns>
241 public ReservationData readReservationRow(IDataReader reader)
242 {
243 ReservationData retval = new ReservationData();
244 if (reader.Read())
245 {
246 retval.gridRecvKey = (string)reader["gridRecvKey"];
247 retval.gridSendKey = (string)reader["gridSendKey"];
248 retval.reservationCompany = (string)reader["resCompany"];
249 retval.reservationMaxX = Convert.ToInt32(reader["resXMax"].ToString());
250 retval.reservationMaxY = Convert.ToInt32(reader["resYMax"].ToString());
251 retval.reservationMinX = Convert.ToInt32(reader["resXMin"].ToString());
252 retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString());
253 retval.reservationName = (string)reader["resName"];
254 retval.status = Convert.ToInt32(reader["status"].ToString()) == 1;
255 retval.userUUID = new LLUUID((string)reader["userUUID"]);
256
257 }
258 else
259 {
260 return null;
261 }
262 return retval;
263 }
264 /// <summary>
265 /// Reads an agent row from a database reader
266 /// </summary>
267 /// <param name="reader">An active database reader</param>
268 /// <returns>A user session agent</returns>
269 public UserAgentData readAgentRow(IDataReader reader)
270 {
271 UserAgentData retval = new UserAgentData();
272
273 if (reader.Read())
274 {
275 // Agent IDs
276 retval.UUID = new LLUUID((string)reader["UUID"]);
277 retval.sessionID = new LLUUID((string)reader["sessionID"]);
278 retval.secureSessionID = new LLUUID((string)reader["secureSessionID"]);
279
280 // Agent Who?
281 retval.agentIP = (string)reader["agentIP"];
282 retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString());
283 retval.agentOnline = Convert.ToBoolean(reader["agentOnline"].ToString());
284
285 // Login/Logout times (UNIX Epoch)
286 retval.loginTime = Convert.ToInt32(reader["loginTime"].ToString());
287 retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString());
288
289 // Current position
290 retval.currentRegion = (string)reader["currentRegion"];
291 retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString());
292 LLVector3.TryParse((string)reader["currentPos"], out retval.currentPos);
293 }
294 else
295 {
296 return null;
297 }
298 return retval;
299 }
300
301 /// <summary>
302 /// Reads a user profile from an active data reader
303 /// </summary>
304 /// <param name="reader">An active database reader</param>
305 /// <returns>A user profile</returns>
306 public UserProfileData readUserRow(IDataReader reader)
307 {
308 UserProfileData retval = new UserProfileData();
309
310 if (reader.Read())
311 {
312 retval.UUID = new LLUUID((string)reader["UUID"]);
313 retval.username = (string)reader["username"];
314 retval.surname = (string)reader["lastname"];
315
316 retval.passwordHash = (string)reader["passwordHash"];
317 retval.passwordSalt = (string)reader["passwordSalt"];
318
319 retval.homeRegion = Convert.ToUInt64(reader["homeRegion"].ToString());
320 retval.homeLocation = new LLVector3(
321 Convert.ToSingle(reader["homeLocationX"].ToString()),
322 Convert.ToSingle(reader["homeLocationY"].ToString()),
323 Convert.ToSingle(reader["homeLocationZ"].ToString()));
324 retval.homeLookAt = new LLVector3(
325 Convert.ToSingle(reader["homeLookAtX"].ToString()),
326 Convert.ToSingle(reader["homeLookAtY"].ToString()),
327 Convert.ToSingle(reader["homeLookAtZ"].ToString()));
328
329 retval.created = Convert.ToInt32(reader["created"].ToString());
330 retval.lastLogin = Convert.ToInt32(reader["lastLogin"].ToString());
331
332 retval.userInventoryURI = (string)reader["userInventoryURI"];
333 retval.userAssetURI = (string)reader["userAssetURI"];
334
335 retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString());
336 retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString());
337
338 retval.profileAboutText = (string)reader["profileAboutText"];
339 retval.profileFirstText = (string)reader["profileFirstText"];
340
341 retval.profileImage = new LLUUID((string)reader["profileImage"]);
342 retval.profileFirstImage = new LLUUID((string)reader["profileFirstImage"]);
343
344 }
345 else
346 {
347 return null;
348 }
349 return retval;
350 }
351
352 /// <summary>
353 /// Reads a list of inventory folders returned by a query.
354 /// </summary>
355 /// <param name="reader">A MySQL Data Reader</param>
356 /// <returns>A List containing inventory folders</returns>
357 public List<InventoryFolderBase> readInventoryFolders(IDataReader reader)
358 {
359 List<InventoryFolderBase> rows = new List<InventoryFolderBase>();
360
361 while(reader.Read())
362 {
363 try
364 {
365 InventoryFolderBase folder = new InventoryFolderBase();
366
367 folder.agentID = new LLUUID((string)reader["agentID"]);
368 folder.parentID = new LLUUID((string)reader["parentFolderID"]);
369 folder.folderID = new LLUUID((string)reader["folderID"]);
370 folder.name = (string)reader["folderName"];
371
372 rows.Add(folder);
373 }
374 catch (Exception e)
375 {
376 Console.WriteLine(e.ToString());
377 }
378 }
379
380 return rows;
381 }
382
383 /// <summary>
384 /// Reads a collection of items from an SQL result
385 /// </summary>
386 /// <param name="reader">The SQL Result</param>
387 /// <returns>A List containing Inventory Items</returns>
388 public List<InventoryItemBase> readInventoryItems(IDataReader reader)
389 {
390 List<InventoryItemBase> rows = new List<InventoryItemBase>();
391
392 while (reader.Read())
393 {
394 try
395 {
396 InventoryItemBase item = new InventoryItemBase();
397
398 item.assetID = new LLUUID((string)reader["assetID"]);
399 item.avatarID = new LLUUID((string)reader["avatarID"]);
400 item.inventoryCurrentPermissions = Convert.ToUInt32(reader["inventoryCurrentPermissions"].ToString());
401 item.inventoryDescription = (string)reader["inventoryDescription"];
402 item.inventoryID = new LLUUID((string)reader["inventoryID"]);
403 item.inventoryName = (string)reader["inventoryName"];
404 item.inventoryNextPermissions = Convert.ToUInt32(reader["inventoryNextPermissions"].ToString());
405 item.parentFolderID = new LLUUID((string)reader["parentFolderID"]);
406 item.type = Convert.ToInt32(reader["type"].ToString());
407
408 rows.Add(item);
409 }
410 catch (Exception e)
411 {
412 Console.WriteLine(e.ToString());
413 }
414 }
415
416 return rows;
417 }
418
419 /// <summary>
420 /// Inserts a new row into the log database
421 /// </summary>
422 /// <param name="serverDaemon">The daemon which triggered this event</param>
423 /// <param name="target">Who were we operating on when this occured (region UUID, user UUID, etc)</param>
424 /// <param name="methodCall">The method call where the problem occured</param>
425 /// <param name="arguments">The arguments passed to the method</param>
426 /// <param name="priority">How critical is this?</param>
427 /// <param name="logMessage">Extra message info</param>
428 /// <returns>Saved successfully?</returns>
429 public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage)
430 {
431 string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES ";
432 sql += "(?target, ?server, ?method, ?arguments, ?priority, ?message)";
433
434 Dictionary<string, string> parameters = new Dictionary<string, string>();
435 parameters["?server"] = serverDaemon;
436 parameters["?target"] = target;
437 parameters["?method"] = methodCall;
438 parameters["?arguments"] = arguments;
439 parameters["?priority"] = priority.ToString();
440 parameters["?message"] = logMessage;
441
442 bool returnval = false;
443
444 try
445 {
446 IDbCommand result = Query(sql, parameters);
447
448 if (result.ExecuteNonQuery() == 1)
449 returnval = true;
450
451 result.Dispose();
452 }
453 catch (Exception e)
454 {
455 Console.WriteLine(e.ToString());
456 return false;
457 }
458
459 return returnval;
460 }
461
462 /// <summary>
463 /// Inserts a new item into the database
464 /// </summary>
465 /// <param name="item">The item</param>
466 /// <returns>Success?</returns>
467 public bool insertItem(InventoryItemBase item)
468 {
469 string sql = "REPLACE INTO inventoryitems (inventoryID, assetID, type, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions) VALUES ";
470 sql += "(?inventoryID, ?assetID, ?type, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription, ?inventoryNextPermissions, ?inventoryCurrentPermissions)";
471
472 Dictionary<string, string> parameters = new Dictionary<string, string>();
473 parameters["?inventoryID"] = item.inventoryID.ToStringHyphenated();
474 parameters["?assetID"] = item.assetID.ToStringHyphenated();
475 parameters["?type"] = item.type.ToString();
476 parameters["?parentFolderID"] = item.parentFolderID.ToStringHyphenated();
477 parameters["?avatarID"] = item.avatarID.ToStringHyphenated();
478 parameters["?inventoryName"] = item.inventoryName;
479 parameters["?inventoryDescription"] = item.inventoryDescription;
480 parameters["?inventoryNextPermissions"] = item.inventoryNextPermissions.ToString();
481 parameters["?inventoryCurrentPermissions"] = item.inventoryCurrentPermissions.ToString();
482
483 bool returnval = false;
484
485 try
486 {
487 IDbCommand result = Query(sql, parameters);
488
489 if (result.ExecuteNonQuery() == 1)
490 returnval = true;
491
492 result.Dispose();
493 }
494 catch (Exception e)
495 {
496 Console.WriteLine(e.ToString());
497 return false;
498 }
499
500 return returnval;
501 }
502
503 /// <summary>
504 /// Inserts a new folder into the database
505 /// </summary>
506 /// <param name="folder">The folder</param>
507 /// <returns>Success?</returns>
508 public bool insertFolder(InventoryFolderBase folder)
509 {
510 string sql = "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName) VALUES ";
511 sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName)";
512
513 Dictionary<string, string> parameters = new Dictionary<string, string>();
514 parameters["?folderID"] = folder.folderID.ToStringHyphenated();
515 parameters["?agentID"] = folder.agentID.ToStringHyphenated();
516 parameters["?parentFolderID"] = folder.parentID.ToStringHyphenated();
517 parameters["?folderName"] = folder.name;
518
519 bool returnval = false;
520 try
521 {
522 IDbCommand result = Query(sql, parameters);
523
524 if (result.ExecuteNonQuery() == 1)
525 returnval = true;
526
527 result.Dispose();
528 }
529 catch (Exception e)
530 {
531 Console.WriteLine(e.ToString());
532 return false;
533 }
534 return returnval;
535 }
536
537 /// <summary>
538 /// Inserts a new region into the database
539 /// </summary>
540 /// <param name="profile">The region to insert</param>
541 /// <returns>Success?</returns>
542 public bool insertRegion(SimProfileData regiondata)
543 {
544 string sql = "REPLACE INTO regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
545 sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
546 sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture) VALUES ";
547
548 sql += "(?regionHandle, ?regionName, ?uuid, ?regionRecvKey, ?regionSecret, ?regionSendKey, ?regionDataURI, ";
549 sql += "?serverIP, ?serverPort, ?serverURI, ?locX, ?locY, ?locZ, ?eastOverrideHandle, ?westOverrideHandle, ?southOverrideHandle, ?northOverrideHandle, ?regionAssetURI, ?regionAssetRecvKey, ";
550 sql += "?regionAssetSendKey, ?regionUserURI, ?regionUserRecvKey, ?regionUserSendKey, ?regionMapTexture);";
551
552 Dictionary<string, string> parameters = new Dictionary<string, string>();
553
554 parameters["?regionHandle"] = regiondata.regionHandle.ToString();
555 parameters["?regionName"] = regiondata.regionName.ToString();
556 parameters["?uuid"] = regiondata.UUID.ToStringHyphenated();
557 parameters["?regionRecvKey"] = regiondata.regionRecvKey.ToString();
558 parameters["?regionSecret"] = regiondata.regionSecret.ToString();
559 parameters["?regionSendKey"] = regiondata.regionSendKey.ToString();
560 parameters["?regionDataURI"] = regiondata.regionDataURI.ToString();
561 parameters["?serverIP"] = regiondata.serverIP.ToString();
562 parameters["?serverPort"] = regiondata.serverPort.ToString();
563 parameters["?serverURI"] = regiondata.serverURI.ToString();
564 parameters["?locX"] = regiondata.regionLocX.ToString();
565 parameters["?locY"] = regiondata.regionLocY.ToString();
566 parameters["?locZ"] = regiondata.regionLocZ.ToString();
567 parameters["?eastOverrideHandle"] = regiondata.regionEastOverrideHandle.ToString();
568 parameters["?westOverrideHandle"] = regiondata.regionWestOverrideHandle.ToString();
569 parameters["?northOverrideHandle"] = regiondata.regionNorthOverrideHandle.ToString();
570 parameters["?southOverrideHandle"] = regiondata.regionSouthOverrideHandle.ToString();
571 parameters["?regionAssetURI"] = regiondata.regionAssetURI.ToString();
572 parameters["?regionAssetRecvKey"] = regiondata.regionAssetRecvKey.ToString();
573 parameters["?regionAssetSendKey"] = regiondata.regionAssetSendKey.ToString();
574 parameters["?regionUserURI"] = regiondata.regionUserURI.ToString();
575 parameters["?regionUserRecvKey"] = regiondata.regionUserRecvKey.ToString();
576 parameters["?regionUserSendKey"] = regiondata.regionUserSendKey.ToString();
577 parameters["?regionMapTexture"] = regiondata.regionMapTextureID.ToStringHyphenated();
578
579 bool returnval = false;
580
581 try
582 {
583
584 IDbCommand result = Query(sql, parameters);
585
586 //Console.WriteLine(result.CommandText);
587
588 if (result.ExecuteNonQuery() == 1)
589 returnval = true;
590
591 result.Dispose();
592 }
593 catch (Exception e)
594 {
595 Console.WriteLine(e.ToString());
596 return false;
597 }
598
599 return returnval;
600 }
601 }
602}
diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
new file mode 100644
index 0000000..c116536
--- /dev/null
+++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
@@ -0,0 +1,256 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Data;
31using libsecondlife;
32
33namespace OpenSim.Framework.Data.MySQL
34{
35 /// <summary>
36 /// A database interface class to a user profile storage system
37 /// </summary>
38 class MySQLUserData : IUserData
39 {
40 /// <summary>
41 /// Database manager for MySQL
42 /// </summary>
43 public MySQLManager database;
44
45 /// <summary>
46 /// Loads and initialises the MySQL storage plugin
47 /// </summary>
48 public void Initialise()
49 {
50 // Load from an INI file connection details
51 // TODO: move this to XML?
52 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
53 string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
54 string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
55 string settingUsername = GridDataMySqlFile.ParseFileReadValue("username");
56 string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
57 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
58 string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
59
60 database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
61 }
62
63 /// <summary>
64 /// Searches the database for a specified user profile
65 /// </summary>
66 /// <param name="name">The account name of the user</param>
67 /// <returns>A user profile</returns>
68 public UserProfileData getUserByName(string name)
69 {
70 return getUserByName(name.Split(' ')[0], name.Split(' ')[1]);
71 }
72
73 /// <summary>
74 /// Searches the database for a specified user profile by name components
75 /// </summary>
76 /// <param name="user">The first part of the account name</param>
77 /// <param name="last">The second part of the account name</param>
78 /// <returns>A user profile</returns>
79 public UserProfileData getUserByName(string user, string last)
80 {
81 try
82 {
83 lock (database)
84 {
85 Dictionary<string, string> param = new Dictionary<string, string>();
86 param["?first"] = user;
87 param["?second"] = last;
88
89 IDbCommand result = database.Query("SELECT * FROM users WHERE username = ?first AND lastname = ?second", param);
90 IDataReader reader = result.ExecuteReader();
91
92 UserProfileData row = database.readUserRow(reader);
93
94 reader.Close();
95 result.Dispose();
96
97 return row;
98 }
99 }
100 catch (Exception e)
101 {
102 database.Reconnect();
103 Console.WriteLine(e.ToString());
104 return null;
105 }
106 }
107
108 /// <summary>
109 /// Searches the database for a specified user profile by UUID
110 /// </summary>
111 /// <param name="uuid">The account ID</param>
112 /// <returns>The users profile</returns>
113 public UserProfileData getUserByUUID(LLUUID uuid)
114 {
115 try
116 {
117 lock (database)
118 {
119 Dictionary<string, string> param = new Dictionary<string, string>();
120 param["?uuid"] = uuid.ToStringHyphenated();
121
122 IDbCommand result = database.Query("SELECT * FROM users WHERE UUID = ?uuid", param);
123 IDataReader reader = result.ExecuteReader();
124
125 UserProfileData row = database.readUserRow(reader);
126
127 reader.Close();
128 result.Dispose();
129
130 return row;
131 }
132 }
133 catch (Exception e)
134 {
135 database.Reconnect();
136 Console.WriteLine(e.ToString());
137 return null;
138 }
139 }
140
141 /// <summary>
142 /// Returns a user session searching by name
143 /// </summary>
144 /// <param name="name">The account name</param>
145 /// <returns>The users session</returns>
146 public UserAgentData getAgentByName(string name)
147 {
148 return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]);
149 }
150
151 /// <summary>
152 /// Returns a user session by account name
153 /// </summary>
154 /// <param name="user">First part of the users account name</param>
155 /// <param name="last">Second part of the users account name</param>
156 /// <returns>The users session</returns>
157 public UserAgentData getAgentByName(string user, string last)
158 {
159 UserProfileData profile = getUserByName(user, last);
160 return getAgentByUUID(profile.UUID);
161 }
162
163 /// <summary>
164 /// Returns an agent session by account UUID
165 /// </summary>
166 /// <param name="uuid">The accounts UUID</param>
167 /// <returns>The users session</returns>
168 public UserAgentData getAgentByUUID(LLUUID uuid)
169 {
170 try
171 {
172 lock (database)
173 {
174 Dictionary<string, string> param = new Dictionary<string, string>();
175 param["?uuid"] = uuid.ToStringHyphenated();
176
177 IDbCommand result = database.Query("SELECT * FROM agents WHERE UUID = ?uuid", param);
178 IDataReader reader = result.ExecuteReader();
179
180 UserAgentData row = database.readAgentRow(reader);
181
182 reader.Close();
183 result.Dispose();
184
185 return row;
186 }
187 }
188 catch (Exception e)
189 {
190 database.Reconnect();
191 Console.WriteLine(e.ToString());
192 return null;
193 }
194 }
195
196 /// <summary>
197 /// Creates a new users profile
198 /// </summary>
199 /// <param name="user">The user profile to create</param>
200 public void addNewUserProfile(UserProfileData user)
201 {
202 }
203
204 /// <summary>
205 /// Creates a new agent
206 /// </summary>
207 /// <param name="agent">The agent to create</param>
208 public void addNewUserAgent(UserAgentData agent)
209 {
210 // Do nothing.
211 }
212
213 /// <summary>
214 /// Performs a money transfer request between two accounts
215 /// </summary>
216 /// <param name="from">The senders account ID</param>
217 /// <param name="to">The recievers account ID</param>
218 /// <param name="amount">The amount to transfer</param>
219 /// <returns>Success?</returns>
220 public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount)
221 {
222 return false;
223 }
224
225 /// <summary>
226 /// Performs an inventory transfer request between two accounts
227 /// </summary>
228 /// <remarks>TODO: Move to inventory server</remarks>
229 /// <param name="from">The senders account ID</param>
230 /// <param name="to">The recievers account ID</param>
231 /// <param name="item">The item to transfer</param>
232 /// <returns>Success?</returns>
233 public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
234 {
235 return false;
236 }
237
238 /// <summary>
239 /// Database provider name
240 /// </summary>
241 /// <returns>Provider name</returns>
242 public string getName()
243 {
244 return "MySQL Userdata Interface";
245 }
246
247 /// <summary>
248 /// Database provider version
249 /// </summary>
250 /// <returns>provider version</returns>
251 public string getVersion()
252 {
253 return "0.1";
254 }
255 }
256}
diff --git a/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..52d6a54
--- /dev/null
+++ b/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Framework.Data.MySQL")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenSim.Framework.Data.MySQL")]
11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("e49826b2-dcef-41be-a5bd-596733fa3304")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..9de5edb
--- /dev/null
+++ b/OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Framework.Data.SQLite")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenSim.Framework.Data.SQLite")]
11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("6113d5ce-4547-49f4-9236-0dcc503457b1")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs b/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs
new file mode 100644
index 0000000..511c5f0
--- /dev/null
+++ b/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs
@@ -0,0 +1,197 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Data;
31using System.Security.Cryptography;
32using System.Text;
33using libsecondlife;
34
35namespace OpenSim.Framework.Data.SQLite
36{
37 /// <summary>
38 /// A Grid Interface to the SQLite database
39 /// </summary>
40 public class SQLiteGridData : IGridData
41 {
42 /// <summary>
43 /// A database manager
44 /// </summary>
45 private SQLiteManager database;
46
47 /// <summary>
48 /// Initialises the Grid Interface
49 /// </summary>
50 public void Initialise()
51 {
52 database = new SQLiteManager("localhost", "db", "user", "password", "false");
53 }
54
55 /// <summary>
56 /// Shuts down the grid interface
57 /// </summary>
58 public void Close()
59 {
60 database.Close();
61 }
62
63 /// <summary>
64 /// Returns the name of this grid interface
65 /// </summary>
66 /// <returns>A string containing the grid interface</returns>
67 public string getName()
68 {
69 return "SQLite OpenGridData";
70 }
71
72 /// <summary>
73 /// Returns the version of this grid interface
74 /// </summary>
75 /// <returns>A string containing the version</returns>
76 public string getVersion()
77 {
78 return "0.1";
79 }
80
81 /// <summary>
82 /// Returns a list of regions within the specified ranges
83 /// </summary>
84 /// <param name="a">minimum X coordinate</param>
85 /// <param name="b">minimum Y coordinate</param>
86 /// <param name="c">maximum X coordinate</param>
87 /// <param name="d">maximum Y coordinate</param>
88 /// <returns>An array of region profiles</returns>
89 public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
90 {
91 return null;
92 }
93
94 /// <summary>
95 /// Returns a sim profile from it's location
96 /// </summary>
97 /// <param name="handle">Region location handle</param>
98 /// <returns>Sim profile</returns>
99 public SimProfileData GetProfileByHandle(ulong handle)
100 {
101 Dictionary<string, string> param = new Dictionary<string, string>();
102 param["handle"] = handle.ToString();
103
104 IDbCommand result = database.Query("SELECT * FROM regions WHERE handle = @handle", param);
105 IDataReader reader = result.ExecuteReader();
106
107 SimProfileData row = database.getRow(reader);
108 reader.Close();
109 result.Dispose();
110
111 return row;
112 }
113
114 /// <summary>
115 /// Returns a sim profile from it's UUID
116 /// </summary>
117 /// <param name="uuid">The region UUID</param>
118 /// <returns>The sim profile</returns>
119 public SimProfileData GetProfileByLLUUID(LLUUID uuid)
120 {
121 Dictionary<string, string> param = new Dictionary<string, string>();
122 param["uuid"] = uuid.ToStringHyphenated();
123
124 IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = @uuid", param);
125 IDataReader reader = result.ExecuteReader();
126
127 SimProfileData row = database.getRow(reader);
128 reader.Close();
129 result.Dispose();
130
131 return row;
132 }
133
134 /// <summary>
135 /// Adds a new specified region to the database
136 /// </summary>
137 /// <param name="profile">The profile to add</param>
138 /// <returns>A dataresponse enum indicating success</returns>
139 public DataResponse AddProfile(SimProfileData profile)
140 {
141 if (database.insertRow(profile))
142 {
143 return DataResponse.RESPONSE_OK;
144 }
145 else
146 {
147 return DataResponse.RESPONSE_ERROR;
148 }
149 }
150
151 /// <summary>
152 /// DEPRECIATED. Attempts to authenticate a region by comparing a shared secret.
153 /// </summary>
154 /// <param name="uuid">The UUID of the challenger</param>
155 /// <param name="handle">The attempted regionHandle of the challenger</param>
156 /// <param name="authkey">The secret</param>
157 /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
158 public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey)
159 {
160 bool throwHissyFit = false; // Should be true by 1.0
161
162 if (throwHissyFit)
163 throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
164
165 SimProfileData data = GetProfileByLLUUID(uuid);
166
167 return (handle == data.regionHandle && authkey == data.regionSecret);
168 }
169
170 /// <summary>
171 /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region
172 /// </summary>
173 /// <remarks>This requires a security audit.</remarks>
174 /// <param name="uuid"></param>
175 /// <param name="handle"></param>
176 /// <param name="authhash"></param>
177 /// <param name="challenge"></param>
178 /// <returns></returns>
179 public bool AuthenticateSim(LLUUID uuid, ulong handle, string authhash, string challenge)
180 {
181 SHA512Managed HashProvider = new SHA512Managed();
182 ASCIIEncoding TextProvider = new ASCIIEncoding();
183
184 byte[] stream = TextProvider.GetBytes(uuid.ToStringHyphenated() + ":" + handle.ToString() + ":" + challenge);
185 byte[] hash = HashProvider.ComputeHash(stream);
186
187 return false;
188 }
189
190 public ReservationData GetReservationAtPoint(uint x, uint y)
191 {
192 return null;
193 }
194 }
195
196
197}
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteManager.cs b/OpenSim/Framework/Data.SQLite/SQLiteManager.cs
new file mode 100644
index 0000000..c9931ab
--- /dev/null
+++ b/OpenSim/Framework/Data.SQLite/SQLiteManager.cs
@@ -0,0 +1,206 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Data;
31using System.Data.SQLite;
32using libsecondlife;
33
34namespace OpenSim.Framework.Data.SQLite
35{
36 class SQLiteManager
37 {
38 IDbConnection dbcon;
39
40 /// <summary>
41 /// Initialises and creates a new SQLite connection and maintains it.
42 /// </summary>
43 /// <param name="hostname">The SQLite server being connected to</param>
44 /// <param name="database">The name of the SQLite database being used</param>
45 /// <param name="username">The username logging into the database</param>
46 /// <param name="password">The password for the user logging in</param>
47 /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param>
48 public SQLiteManager(string hostname, string database, string username, string password, string cpooling)
49 {
50 try
51 {
52 string connectionString = "URI=file:GridServerSqlite.db;";
53 dbcon = new SQLiteConnection(connectionString);
54
55 dbcon.Open();
56 }
57 catch (Exception e)
58 {
59 throw new Exception("Error initialising SQLite Database: " + e.ToString());
60 }
61 }
62
63 /// <summary>
64 /// Shuts down the database connection
65 /// </summary>
66 public void Close()
67 {
68 dbcon.Close();
69 dbcon = null;
70 }
71
72 /// <summary>
73 /// Runs a query with protection against SQL Injection by using parameterised input.
74 /// </summary>
75 /// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param>
76 /// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param>
77 /// <returns>A SQLite DB Command</returns>
78 public IDbCommand Query(string sql, Dictionary<string, string> parameters)
79 {
80 SQLiteCommand dbcommand = (SQLiteCommand)dbcon.CreateCommand();
81 dbcommand.CommandText = sql;
82 foreach (KeyValuePair<string, string> param in parameters)
83 {
84 SQLiteParameter paramx = new SQLiteParameter(param.Key,param.Value);
85 dbcommand.Parameters.Add(paramx);
86 }
87
88 return (IDbCommand)dbcommand;
89 }
90
91 /// <summary>
92 /// Reads a region row from a database reader
93 /// </summary>
94 /// <param name="reader">An active database reader</param>
95 /// <returns>A region profile</returns>
96 public SimProfileData getRow(IDataReader reader)
97 {
98 SimProfileData retval = new SimProfileData();
99
100 if (reader.Read())
101 {
102 // Region Main
103 retval.regionHandle = (ulong)reader["regionHandle"];
104 retval.regionName = (string)reader["regionName"];
105 retval.UUID = new LLUUID((string)reader["uuid"]);
106
107 // Secrets
108 retval.regionRecvKey = (string)reader["regionRecvKey"];
109 retval.regionSecret = (string)reader["regionSecret"];
110 retval.regionSendKey = (string)reader["regionSendKey"];
111
112 // Region Server
113 retval.regionDataURI = (string)reader["regionDataURI"];
114 retval.regionOnline = false; // Needs to be pinged before this can be set.
115 retval.serverIP = (string)reader["serverIP"];
116 retval.serverPort = (uint)reader["serverPort"];
117 retval.serverURI = (string)reader["serverURI"];
118
119 // Location
120 retval.regionLocX = (uint)((int)reader["locX"]);
121 retval.regionLocY = (uint)((int)reader["locY"]);
122 retval.regionLocZ = (uint)((int)reader["locZ"]);
123
124 // Neighbours - 0 = No Override
125 retval.regionEastOverrideHandle = (ulong)reader["eastOverrideHandle"];
126 retval.regionWestOverrideHandle = (ulong)reader["westOverrideHandle"];
127 retval.regionSouthOverrideHandle = (ulong)reader["southOverrideHandle"];
128 retval.regionNorthOverrideHandle = (ulong)reader["northOverrideHandle"];
129
130 // Assets
131 retval.regionAssetURI = (string)reader["regionAssetURI"];
132 retval.regionAssetRecvKey = (string)reader["regionAssetRecvKey"];
133 retval.regionAssetSendKey = (string)reader["regionAssetSendKey"];
134
135 // Userserver
136 retval.regionUserURI = (string)reader["regionUserURI"];
137 retval.regionUserRecvKey = (string)reader["regionUserRecvKey"];
138 retval.regionUserSendKey = (string)reader["regionUserSendKey"];
139 }
140 else
141 {
142 throw new Exception("No rows to return");
143 }
144 return retval;
145 }
146
147 /// <summary>
148 /// Inserts a new region into the database
149 /// </summary>
150 /// <param name="profile">The region to insert</param>
151 /// <returns>Success?</returns>
152 public bool insertRow(SimProfileData profile)
153 {
154 string sql = "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
155 sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
156 sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey) VALUES ";
157
158 sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, ";
159 sql += "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, ";
160 sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);";
161
162 Dictionary<string, string> parameters = new Dictionary<string, string>();
163
164 parameters["regionHandle"] = profile.regionHandle.ToString();
165 parameters["regionName"] = profile.regionName;
166 parameters["uuid"] = profile.UUID.ToString();
167 parameters["regionRecvKey"] = profile.regionRecvKey;
168 parameters["regionSendKey"] = profile.regionSendKey;
169 parameters["regionDataURI"] = profile.regionDataURI;
170 parameters["serverIP"] = profile.serverIP;
171 parameters["serverPort"] = profile.serverPort.ToString();
172 parameters["serverURI"] = profile.serverURI;
173 parameters["locX"] = profile.regionLocX.ToString();
174 parameters["locY"] = profile.regionLocY.ToString();
175 parameters["locZ"] = profile.regionLocZ.ToString();
176 parameters["eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString();
177 parameters["westOverrideHandle"] = profile.regionWestOverrideHandle.ToString();
178 parameters["northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString();
179 parameters["southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString();
180 parameters["regionAssetURI"] = profile.regionAssetURI;
181 parameters["regionAssetRecvKey"] = profile.regionAssetRecvKey;
182 parameters["regionAssetSendKey"] = profile.regionAssetSendKey;
183 parameters["regionUserURI"] = profile.regionUserURI;
184 parameters["regionUserRecvKey"] = profile.regionUserRecvKey;
185 parameters["regionUserSendKey"] = profile.regionUserSendKey;
186
187 bool returnval = false;
188
189 try
190 {
191 IDbCommand result = Query(sql, parameters);
192
193 if (result.ExecuteNonQuery() == 1)
194 returnval = true;
195
196 result.Dispose();
197 }
198 catch (Exception)
199 {
200 return false;
201 }
202
203 return returnval;
204 }
205 }
206}
diff --git a/OpenSim/Framework/Data/GridData.cs b/OpenSim/Framework/Data/GridData.cs
new file mode 100644
index 0000000..5a17d20
--- /dev/null
+++ b/OpenSim/Framework/Data/GridData.cs
@@ -0,0 +1,111 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29
30namespace OpenSim.Framework.Data
31{
32 public enum DataResponse
33 {
34 RESPONSE_OK,
35 RESPONSE_AUTHREQUIRED,
36 RESPONSE_INVALIDCREDENTIALS,
37 RESPONSE_ERROR
38 }
39
40 /// <summary>
41 /// A standard grid interface
42 /// </summary>
43 public interface IGridData
44 {
45 /// <summary>
46 /// Returns a sim profile from a regionHandle
47 /// </summary>
48 /// <param name="regionHandle">A 64bit Region Handle</param>
49 /// <returns>A simprofile</returns>
50 SimProfileData GetProfileByHandle(ulong regionHandle);
51
52 /// <summary>
53 /// Returns a sim profile from a UUID
54 /// </summary>
55 /// <param name="UUID">A 128bit UUID</param>
56 /// <returns>A sim profile</returns>
57 SimProfileData GetProfileByLLUUID(LLUUID UUID);
58
59 /// <summary>
60 /// Returns all profiles within the specified range
61 /// </summary>
62 /// <param name="Xmin">Minimum sim coordinate (X)</param>
63 /// <param name="Ymin">Minimum sim coordinate (Y)</param>
64 /// <param name="Xmax">Maximum sim coordinate (X)</param>
65 /// <param name="Ymin">Maximum sim coordinate (Y)</param>
66 /// <returns>An array containing all the sim profiles in the specified range</returns>
67 SimProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
68
69 /// <summary>
70 /// Authenticates a sim by use of it's recv key.
71 /// WARNING: Insecure
72 /// </summary>
73 /// <param name="UUID">The UUID sent by the sim</param>
74 /// <param name="regionHandle">The regionhandle sent by the sim</param>
75 /// <param name="simrecvkey">The recieving key sent by the sim</param>
76 /// <returns>Whether the sim has been authenticated</returns>
77 bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey);
78
79 /// <summary>
80 /// Initialises the interface
81 /// </summary>
82 void Initialise();
83
84 /// <summary>
85 /// Closes the interface
86 /// </summary>
87 void Close();
88
89 /// <summary>
90 /// The plugin being loaded
91 /// </summary>
92 /// <returns>A string containing the plugin name</returns>
93 string getName();
94
95 /// <summary>
96 /// The plugins version
97 /// </summary>
98 /// <returns>A string containing the plugin version</returns>
99 string getVersion();
100
101 /// <summary>
102 /// Adds a new profile to the database
103 /// </summary>
104 /// <param name="profile">The profile to add</param>
105 /// <returns>RESPONSE_OK if successful, error if not.</returns>
106 DataResponse AddProfile(SimProfileData profile);
107
108 ReservationData GetReservationAtPoint(uint x, uint y);
109
110 }
111}
diff --git a/OpenSim/Framework/Data/ILogData.cs b/OpenSim/Framework/Data/ILogData.cs
new file mode 100644
index 0000000..059fef5
--- /dev/null
+++ b/OpenSim/Framework/Data/ILogData.cs
@@ -0,0 +1,90 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28namespace OpenSim.Framework.Data
29{
30 /// <summary>
31 /// The severity of an individual log message
32 /// </summary>
33 public enum LogSeverity : int
34 {
35 /// <summary>
36 /// Critical: systems failure
37 /// </summary>
38 CRITICAL = 1,
39 /// <summary>
40 /// Major: warning prior to systems failure
41 /// </summary>
42 MAJOR = 2,
43 /// <summary>
44 /// Medium: an individual non-critical task failed
45 /// </summary>
46 MEDIUM = 3,
47 /// <summary>
48 /// Low: Informational warning
49 /// </summary>
50 LOW = 4,
51 /// <summary>
52 /// Info: Information
53 /// </summary>
54 INFO = 5,
55 /// <summary>
56 /// Verbose: Debug Information
57 /// </summary>
58 VERBOSE = 6
59 }
60
61 /// <summary>
62 /// An interface to a LogData storage system
63 /// </summary>
64 public interface ILogData
65 {
66 void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,string logMessage);
67 /// <summary>
68 /// Initialises the interface
69 /// </summary>
70 void Initialise();
71
72 /// <summary>
73 /// Closes the interface
74 /// </summary>
75 void Close();
76
77 /// <summary>
78 /// The plugin being loaded
79 /// </summary>
80 /// <returns>A string containing the plugin name</returns>
81 string getName();
82
83 /// <summary>
84 /// The plugins version
85 /// </summary>
86 /// <returns>A string containing the plugin version</returns>
87 string getVersion();
88 }
89
90}
diff --git a/OpenSim/Framework/Data/IniConfig.cs b/OpenSim/Framework/Data/IniConfig.cs
new file mode 100644
index 0000000..2b52fd1
--- /dev/null
+++ b/OpenSim/Framework/Data/IniConfig.cs
@@ -0,0 +1,96 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.IO;
29using System.Text.RegularExpressions;
30/*
31 Taken from public code listing at by Alex Pinsker
32 http://alexpinsker.blogspot.com/2005/12/reading-ini-file-from-c_113432097333021549.html
33 */
34
35namespace OpenSim.Framework.Data
36{
37 /// <summary>
38 /// Parse settings from ini-like files
39 /// </summary>
40 public class IniFile
41 {
42 static IniFile()
43 {
44 _iniKeyValuePatternRegex = new Regex(
45 @"((\s)*(?<Key>([^\=^\s^\n]+))[\s^\n]*
46 # key part (surrounding whitespace stripped)
47 \=
48 (\s)*(?<Value>([^\n^\s]+(\n){0,1})))
49 # value part (surrounding whitespace stripped)
50 ",
51 RegexOptions.IgnorePatternWhitespace |
52 RegexOptions.Compiled |
53 RegexOptions.CultureInvariant);
54 }
55 static private Regex _iniKeyValuePatternRegex;
56
57 public IniFile(string iniFileName)
58 {
59 _iniFileName = iniFileName;
60 }
61
62 public string ParseFileReadValue(string key)
63 {
64 using (StreamReader reader =
65 new StreamReader(_iniFileName))
66 {
67 do
68 {
69 string line = reader.ReadLine();
70 Match match =
71 _iniKeyValuePatternRegex.Match(line);
72 if (match.Success)
73 {
74 string currentKey =
75 match.Groups["Key"].Value as string;
76 if (currentKey != null &&
77 currentKey.Trim().CompareTo(key) == 0)
78 {
79 string value =
80 match.Groups["Value"].Value as string;
81 return value;
82 }
83 }
84
85 }
86 while (reader.Peek() != -1);
87 }
88 return null;
89 }
90
91 public string IniFileName
92 {
93 get { return _iniFileName; }
94 } private string _iniFileName;
95 }
96}
diff --git a/OpenSim/Framework/Data/InventoryData.cs b/OpenSim/Framework/Data/InventoryData.cs
new file mode 100644
index 0000000..c2a1d06
--- /dev/null
+++ b/OpenSim/Framework/Data/InventoryData.cs
@@ -0,0 +1,185 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
30
31namespace OpenSim.Framework.Data
32{
33 /// <summary>
34 /// Inventory Item - contains all the properties associated with an individual inventory piece.
35 /// </summary>
36 public class InventoryItemBase
37 {
38 /// <summary>
39 /// A UUID containing the ID for the inventory item itself
40 /// </summary>
41 public LLUUID inventoryID;
42 /// <summary>
43 /// The UUID of the associated asset on the asset server
44 /// </summary>
45 public LLUUID assetID;
46 /// <summary>
47 /// This is an enumerated value determining the type of asset (eg Notecard, Sound, Object, etc)
48 /// </summary>
49 public int type;
50 /// <summary>
51 /// The folder this item is contained in (NULL_KEY = Inventory Root)
52 /// </summary>
53 public LLUUID parentFolderID;
54 /// <summary>
55 /// The owner of this inventory item
56 /// </summary>
57 public LLUUID avatarID;
58 /// <summary>
59 /// The name of the inventory item (must be less than 64 characters)
60 /// </summary>
61 public string inventoryName;
62 /// <summary>
63 /// The description of the inventory item (must be less than 64 characters)
64 /// </summary>
65 public string inventoryDescription;
66 /// <summary>
67 /// A mask containing the permissions for the next owner (cannot be enforced)
68 /// </summary>
69 public uint inventoryNextPermissions;
70 /// <summary>
71 /// A mask containing permissions for the current owner (cannot be enforced)
72 /// </summary>
73 public uint inventoryCurrentPermissions;
74 }
75
76 /// <summary>
77 /// A Class for folders which contain users inventory
78 /// </summary>
79 public class InventoryFolderBase
80 {
81 /// <summary>
82 /// The name of the folder (64 characters or less)
83 /// </summary>
84 public string name;
85 /// <summary>
86 /// The agent who's inventory this is contained by
87 /// </summary>
88 public LLUUID agentID;
89 /// <summary>
90 /// The folder this folder is contained in (NULL_KEY for root)
91 /// </summary>
92 public LLUUID parentID;
93 /// <summary>
94 /// The UUID for this folder
95 /// </summary>
96 public LLUUID folderID;
97 }
98
99 /// <summary>
100 /// An interface for accessing inventory data from a storage server
101 /// </summary>
102 public interface IInventoryData
103 {
104 /// <summary>
105 /// Initialises the interface
106 /// </summary>
107 void Initialise();
108
109 /// <summary>
110 /// Closes the interface
111 /// </summary>
112 void Close();
113
114 /// <summary>
115 /// The plugin being loaded
116 /// </summary>
117 /// <returns>A string containing the plugin name</returns>
118 string getName();
119
120 /// <summary>
121 /// The plugins version
122 /// </summary>
123 /// <returns>A string containing the plugin version</returns>
124 string getVersion();
125
126 /// <summary>
127 /// Returns a list of inventory items contained within the specified folder
128 /// </summary>
129 /// <param name="folderID">The UUID of the target folder</param>
130 /// <returns>A List of InventoryItemBase items</returns>
131 List<InventoryItemBase> getInventoryInFolder(LLUUID folderID);
132
133 /// <summary>
134 /// Returns a list of folders in the users inventory root.
135 /// </summary>
136 /// <param name="user">The UUID of the user who is having inventory being returned</param>
137 /// <returns>A list of folders</returns>
138 List<InventoryFolderBase> getUserRootFolders(LLUUID user);
139
140 /// <summary>
141 /// Returns a list of inventory folders contained in the folder 'parentID'
142 /// </summary>
143 /// <param name="parentID">The folder to get subfolders for</param>
144 /// <returns>A list of inventory folders</returns>
145 List<InventoryFolderBase> getInventoryFolders(LLUUID parentID);
146
147 /// <summary>
148 /// Returns an inventory item by its UUID
149 /// </summary>
150 /// <param name="item">The UUID of the item to be returned</param>
151 /// <returns>A class containing item information</returns>
152 InventoryItemBase getInventoryItem(LLUUID item);
153
154 /// <summary>
155 /// Returns a specified inventory folder by its UUID
156 /// </summary>
157 /// <param name="folder">The UUID of the folder to be returned</param>
158 /// <returns>A class containing folder information</returns>
159 InventoryFolderBase getInventoryFolder(LLUUID folder);
160
161 /// <summary>
162 /// Creates a new inventory item based on item
163 /// </summary>
164 /// <param name="item">The item to be created</param>
165 void addInventoryItem(InventoryItemBase item);
166
167 /// <summary>
168 /// Updates an inventory item with item (updates based on ID)
169 /// </summary>
170 /// <param name="item">The updated item</param>
171 void updateInventoryItem(InventoryItemBase item);
172
173 /// <summary>
174 /// Adds a new folder specified by folder
175 /// </summary>
176 /// <param name="folder">The inventory folder</param>
177 void addInventoryFolder(InventoryFolderBase folder);
178
179 /// <summary>
180 /// Updates a folder based on its ID with folder
181 /// </summary>
182 /// <param name="folder">The inventory folder</param>
183 void updateInventoryFolder(InventoryFolderBase folder);
184 }
185}
diff --git a/OpenSim/Framework/Data/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..f9260a1
--- /dev/null
+++ b/OpenSim/Framework/Data/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Framework.Data")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenSim.Framework.Data")]
11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("3a711c34-b0c0-4264-b0fe-f366eabf9d7b")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Framework/Data/ReservationData.cs b/OpenSim/Framework/Data/ReservationData.cs
new file mode 100644
index 0000000..0078df0
--- /dev/null
+++ b/OpenSim/Framework/Data/ReservationData.cs
@@ -0,0 +1,47 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29
30namespace OpenSim.Framework.Data
31{
32 public class ReservationData
33 {
34 public LLUUID userUUID = new LLUUID();
35 public int reservationMinX = 0;
36 public int reservationMinY = 0;
37 public int reservationMaxX = 65536;
38 public int reservationMaxY = 65536;
39
40 public string reservationName = "";
41 public string reservationCompany = "";
42 public bool status = true;
43
44 public string gridSendKey = "";
45 public string gridRecvKey = "";
46 }
47}
diff --git a/OpenSim/Framework/Data/SimProfileData.cs b/OpenSim/Framework/Data/SimProfileData.cs
new file mode 100644
index 0000000..b920cab
--- /dev/null
+++ b/OpenSim/Framework/Data/SimProfileData.cs
@@ -0,0 +1,192 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29using Nwc.XmlRpc;
30
31using System;
32using System.Collections;
33
34namespace OpenSim.Framework.Data
35{
36 /// <summary>
37 /// A class which contains information known to the grid server about a region
38 /// </summary>
39 public class SimProfileData
40 {
41 /// <summary>
42 /// The name of the region
43 /// </summary>
44 public string regionName = "";
45
46 /// <summary>
47 /// A 64-bit number combining map position into a (mostly) unique ID
48 /// </summary>
49 public ulong regionHandle;
50
51 /// <summary>
52 /// OGS/OpenSim Specific ID for a region
53 /// </summary>
54 public LLUUID UUID;
55
56 /// <summary>
57 /// Coordinates of the region
58 /// </summary>
59 public uint regionLocX;
60 public uint regionLocY;
61 public uint regionLocZ; // Reserved (round-robin, layers, etc)
62
63 /// <summary>
64 /// Authentication secrets
65 /// </summary>
66 /// <remarks>Not very secure, needs improvement.</remarks>
67 public string regionSendKey = "";
68 public string regionRecvKey = "";
69 public string regionSecret = "";
70
71 /// <summary>
72 /// Whether the region is online
73 /// </summary>
74 public bool regionOnline;
75
76 /// <summary>
77 /// Information about the server that the region is currently hosted on
78 /// </summary>
79 public string serverIP = "";
80 public uint serverPort;
81 public string serverURI = "";
82
83 public uint httpPort;
84 public uint remotingPort;
85 public string httpServerURI = "";
86
87 /// <summary>
88 /// Set of optional overrides. Can be used to create non-eulicidean spaces.
89 /// </summary>
90 public ulong regionNorthOverrideHandle;
91 public ulong regionSouthOverrideHandle;
92 public ulong regionEastOverrideHandle;
93 public ulong regionWestOverrideHandle;
94
95 /// <summary>
96 /// Optional: URI Location of the region database
97 /// </summary>
98 /// <remarks>Used for floating sim pools where the region data is not nessecarily coupled to a specific server</remarks>
99 public string regionDataURI = "";
100
101 /// <summary>
102 /// Region Asset Details
103 /// </summary>
104 public string regionAssetURI = "";
105 public string regionAssetSendKey = "";
106 public string regionAssetRecvKey = "";
107
108 /// <summary>
109 /// Region Userserver Details
110 /// </summary>
111 public string regionUserURI = "";
112 public string regionUserSendKey = "";
113 public string regionUserRecvKey = "";
114
115 /// <summary>
116 /// Region Map Texture Asset
117 /// </summary>
118 public LLUUID regionMapTextureID = new LLUUID("00000000-0000-0000-9999-000000000006");
119
120 /// <summary>
121 /// Get Sim profile data from grid server when in grid mode
122 /// </summary>
123 /// <param name="region_uuid"></param>
124 /// <param name="gridserver_url"></param>
125 /// <param name="?"></param>
126 /// <returns></returns>
127 public SimProfileData RequestSimProfileData(LLUUID region_uuid, string gridserver_url, string gridserver_sendkey, string gridserver_recvkey)
128 {
129 Hashtable requestData = new Hashtable();
130 requestData["region_uuid"] = region_uuid.UUID.ToString();
131 requestData["authkey"] = gridserver_sendkey;
132 ArrayList SendParams = new ArrayList();
133 SendParams.Add(requestData);
134 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
135 XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
136
137 Hashtable responseData = (Hashtable)GridResp.Value;
138
139 if (responseData.ContainsKey("error"))
140 {
141 return null;
142 }
143
144 SimProfileData simData = new SimProfileData();
145 simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]);
146 simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]);
147 simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * 256), (simData.regionLocY * 256));
148 simData.serverIP = (string)responseData["sim_ip"];
149 simData.serverPort = Convert.ToUInt32((string)responseData["sim_port"]);
150 simData.httpPort = Convert.ToUInt32((string)responseData["http_port"]);
151 simData.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
152 simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/";
153 simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/";
154 simData.UUID = new LLUUID((string)responseData["region_UUID"]);
155 simData.regionName = (string)responseData["region_name"];
156
157 return simData;
158 }
159 public SimProfileData RequestSimProfileData(ulong region_handle, string gridserver_url, string gridserver_sendkey, string gridserver_recvkey)
160 {
161 Hashtable requestData = new Hashtable();
162 requestData["region_handle"] = region_handle.ToString();
163 requestData["authkey"] = gridserver_sendkey;
164 ArrayList SendParams = new ArrayList();
165 SendParams.Add(requestData);
166 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
167 XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
168
169 Hashtable responseData = (Hashtable)GridResp.Value;
170
171 if (responseData.ContainsKey("error"))
172 {
173 return null;
174 }
175
176 SimProfileData simData = new SimProfileData();
177 simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]);
178 simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]);
179 simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * 256), (simData.regionLocY * 256));
180 simData.serverIP = (string)responseData["sim_ip"];
181 simData.serverPort = Convert.ToUInt32((string)responseData["sim_port"]);
182 simData.httpPort = Convert.ToUInt32((string)responseData["http_port"]);
183 simData.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
184 simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/";
185 simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/";
186 simData.UUID = new LLUUID((string)responseData["region_UUID"]);
187 simData.regionName = (string)responseData["region_name"];
188
189 return simData;
190 }
191 }
192}
diff --git a/OpenSim/Framework/Data/UserData.cs b/OpenSim/Framework/Data/UserData.cs
new file mode 100644
index 0000000..c65f9fd
--- /dev/null
+++ b/OpenSim/Framework/Data/UserData.cs
@@ -0,0 +1,128 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29
30namespace OpenSim.Framework.Data
31{
32 /// <summary>
33 /// An interface for connecting to user storage servers.
34 /// </summary>
35 public interface IUserData
36 {
37 /// <summary>
38 /// Returns a user profile from a database via their UUID
39 /// </summary>
40 /// <param name="user">The accounts UUID</param>
41 /// <returns>The user data profile</returns>
42 UserProfileData getUserByUUID(LLUUID user);
43
44 /// <summary>
45 /// Returns a users profile by searching their username
46 /// </summary>
47 /// <param name="name">The users username</param>
48 /// <returns>The user data profile</returns>
49 UserProfileData getUserByName(string name);
50
51 /// <summary>
52 /// Returns a users profile by searching their username parts
53 /// </summary>
54 /// <param name="fname">Account firstname</param>
55 /// <param name="lname">Account lastname</param>
56 /// <returns>The user data profile</returns>
57 UserProfileData getUserByName(string fname, string lname);
58
59 /// <summary>
60 /// Returns the current agent for a user searching by it's UUID
61 /// </summary>
62 /// <param name="user">The users UUID</param>
63 /// <returns>The current agent session</returns>
64 UserAgentData getAgentByUUID(LLUUID user);
65
66 /// <summary>
67 /// Returns the current session agent for a user searching by username
68 /// </summary>
69 /// <param name="name">The users account name</param>
70 /// <returns>The current agent session</returns>
71 UserAgentData getAgentByName(string name);
72
73 /// <summary>
74 /// Returns the current session agent for a user searching by username parts
75 /// </summary>
76 /// <param name="fname">The users first account name</param>
77 /// <param name="lname">The users account surname</param>
78 /// <returns>The current agent session</returns>
79 UserAgentData getAgentByName(string fname, string lname);
80
81 /// <summary>
82 /// Adds a new User profile to the database
83 /// </summary>
84 /// <param name="user">UserProfile to add</param>
85 void addNewUserProfile(UserProfileData user);
86
87 /// <summary>
88 /// Adds a new agent to the database
89 /// </summary>
90 /// <param name="agent">The agent to add</param>
91 void addNewUserAgent(UserAgentData agent);
92
93 /// <summary>
94 /// Attempts to move currency units between accounts (NOT RELIABLE / TRUSTWORTHY. DONT TRY RUN YOUR OWN CURRENCY EXCHANGE WITH REAL VALUES)
95 /// </summary>
96 /// <param name="from">The account to transfer from</param>
97 /// <param name="to">The account to transfer to</param>
98 /// <param name="amount">The amount to transfer</param>
99 /// <returns>Successful?</returns>
100 bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount);
101
102 /// <summary>
103 /// Attempts to move inventory between accounts, if inventory is copyable it will be copied into the target account.
104 /// </summary>
105 /// <param name="from">User to transfer from</param>
106 /// <param name="to">User to transfer to</param>
107 /// <param name="inventory">Specified inventory item</param>
108 /// <returns>Successful?</returns>
109 bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID inventory);
110
111 /// <summary>
112 /// Returns the plugin version
113 /// </summary>
114 /// <returns>Plugin version in MAJOR.MINOR.REVISION.BUILD format</returns>
115 string getVersion();
116
117 /// <summary>
118 /// Returns the plugin name
119 /// </summary>
120 /// <returns>Plugin name, eg MySQL User Provider</returns>
121 string getName();
122
123 /// <summary>
124 /// Initialises the plugin (artificial constructor)
125 /// </summary>
126 void Initialise();
127 }
128}
diff --git a/OpenSim/Framework/Data/UserProfileData.cs b/OpenSim/Framework/Data/UserProfileData.cs
new file mode 100644
index 0000000..bb7d48c
--- /dev/null
+++ b/OpenSim/Framework/Data/UserProfileData.cs
@@ -0,0 +1,180 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
30
31namespace OpenSim.Framework.Data
32{
33 /// <summary>
34 /// Information about a particular user known to the userserver
35 /// </summary>
36 public class UserProfileData
37 {
38 /// <summary>
39 /// The ID value for this user
40 /// </summary>
41 public LLUUID UUID;
42
43 /// <summary>
44 /// The first component of a users account name
45 /// </summary>
46 public string username;
47 /// <summary>
48 /// The second component of a users account name
49 /// </summary>
50 public string surname;
51
52 /// <summary>
53 /// A salted hash containing the users password, in the format md5(md5(password) + ":" + salt)
54 /// </summary>
55 /// <remarks>This is double MD5'd because the client sends an unsalted MD5 to the loginserver</remarks>
56 public string passwordHash;
57 /// <summary>
58 /// The salt used for the users hash, should be 32 bytes or longer
59 /// </summary>
60 public string passwordSalt;
61
62 /// <summary>
63 /// The regionhandle of the users preffered home region. If multiple sims occupy the same spot, the grid may decide which region the user logs into
64 /// </summary>
65 public ulong homeRegion;
66 /// <summary>
67 /// The coordinates inside the region of the home location
68 /// </summary>
69 public LLVector3 homeLocation;
70 /// <summary>
71 /// Where the user will be looking when they rez.
72 /// </summary>
73 public LLVector3 homeLookAt;
74
75 /// <summary>
76 /// A UNIX Timestamp (seconds since epoch) for the users creation
77 /// </summary>
78 public int created;
79 /// <summary>
80 /// A UNIX Timestamp for the users last login date / time
81 /// </summary>
82 public int lastLogin;
83
84 /// <summary>
85 /// A URI to the users inventory server, used for foreigners and large grids
86 /// </summary>
87 public string userInventoryURI;
88 /// <summary>
89 /// A URI to the users asset server, used for foreigners and large grids.
90 /// </summary>
91 public string userAssetURI;
92
93 /// <summary>
94 /// A uint mask containing the "I can do" fields of the users profile
95 /// </summary>
96 public uint profileCanDoMask;
97 /// <summary>
98 /// A uint mask containing the "I want to do" part of the users profile
99 /// </summary>
100 public uint profileWantDoMask; // Profile window "I want to" mask
101
102 /// <summary>
103 /// The about text listed in a users profile.
104 /// </summary>
105 public string profileAboutText;
106 /// <summary>
107 /// The first life about text listed in a users profile
108 /// </summary>
109 public string profileFirstText;
110
111 /// <summary>
112 /// The profile image for an avatar stored on the asset server
113 /// </summary>
114 public LLUUID profileImage;
115 /// <summary>
116 /// The profile image for the users first life tab
117 /// </summary>
118 public LLUUID profileFirstImage;
119 /// <summary>
120 /// The users last registered agent (filled in on the user server)
121 /// </summary>
122 public UserAgentData currentAgent;
123 }
124
125 /// <summary>
126 /// Information about a users session
127 /// </summary>
128 public class UserAgentData
129 {
130 /// <summary>
131 /// The UUID of the users avatar (not the agent!)
132 /// </summary>
133 public LLUUID UUID;
134 /// <summary>
135 /// The IP address of the user
136 /// </summary>
137 public string agentIP = String.Empty;
138 /// <summary>
139 /// The port of the user
140 /// </summary>
141 public uint agentPort;
142 /// <summary>
143 /// Is the user online?
144 /// </summary>
145 public bool agentOnline;
146 /// <summary>
147 /// The session ID for the user (also the agent ID)
148 /// </summary>
149 public LLUUID sessionID;
150 /// <summary>
151 /// The "secure" session ID for the user
152 /// </summary>
153 /// <remarks>Not very secure. Dont rely on it for anything more than Linden Lab does.</remarks>
154 public LLUUID secureSessionID;
155 /// <summary>
156 /// The region the user logged into initially
157 /// </summary>
158 public LLUUID regionID;
159 /// <summary>
160 /// A unix timestamp from when the user logged in
161 /// </summary>
162 public int loginTime;
163 /// <summary>
164 /// When this agent expired and logged out, 0 if still online
165 /// </summary>
166 public int logoutTime;
167 /// <summary>
168 /// Current region the user is logged into
169 /// </summary>
170 public LLUUID currentRegion;
171 /// <summary>
172 /// Region handle of the current region the user is in
173 /// </summary>
174 public ulong currentHandle;
175 /// <summary>
176 /// The position of the user within the region
177 /// </summary>
178 public LLVector3 currentPos;
179 }
180}
diff --git a/OpenSim/Framework/General/AgentInventory.cs b/OpenSim/Framework/General/AgentInventory.cs
new file mode 100644
index 0000000..e45a0cd
--- /dev/null
+++ b/OpenSim/Framework/General/AgentInventory.cs
@@ -0,0 +1,265 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
30using libsecondlife.Packets;
31using OpenSim.Framework.Types;
32using OpenSim.Framework.Utilities;
33
34namespace OpenSim.Framework.Inventory
35{
36 public class AgentInventory
37 {
38 //Holds the local copy of Inventory info for a agent
39 public Dictionary<LLUUID, InventoryFolder> InventoryFolders;
40 public Dictionary<LLUUID, InventoryItem> InventoryItems;
41 public InventoryFolder InventoryRoot;
42 public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server
43 public LLUUID AgentID;
44 public AvatarWearable[] Wearables;
45
46 public AgentInventory()
47 {
48 InventoryFolders = new Dictionary<LLUUID, InventoryFolder>();
49 InventoryItems = new Dictionary<LLUUID, InventoryItem>();
50 this.Initialise();
51 }
52
53 public virtual void Initialise()
54 {
55 Wearables = new AvatarWearable[13]; //should be 12 of these
56 for (int i = 0; i < 13; i++)
57 {
58 Wearables[i] = new AvatarWearable();
59 }
60
61 }
62
63 public bool CreateNewFolder(LLUUID folderID, ushort type)
64 {
65 InventoryFolder Folder = new InventoryFolder();
66 Folder.FolderID = folderID;
67 Folder.OwnerID = this.AgentID;
68 Folder.DefaultType = type;
69 this.InventoryFolders.Add(Folder.FolderID, Folder);
70 return (true);
71 }
72
73 public void CreateRootFolder(LLUUID newAgentID, bool createTextures)
74 {
75 this.AgentID = newAgentID;
76 InventoryRoot = new InventoryFolder();
77 InventoryRoot.FolderID = LLUUID.Random();
78 InventoryRoot.ParentID = new LLUUID();
79 InventoryRoot.Version = 1;
80 InventoryRoot.DefaultType = 8;
81 InventoryRoot.OwnerID = this.AgentID;
82 InventoryRoot.FolderName = "My Inventory";
83 InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot);
84 InventoryRoot.OwnerID = this.AgentID;
85 if (createTextures)
86 {
87 this.CreateNewFolder(LLUUID.Random(), 0, "Textures", InventoryRoot.FolderID);
88 }
89 }
90
91 public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName)
92 {
93 InventoryFolder Folder = new InventoryFolder();
94 Folder.FolderID = folderID;
95 Folder.OwnerID = this.AgentID;
96 Folder.DefaultType = type;
97 Folder.FolderName = folderName;
98 this.InventoryFolders.Add(Folder.FolderID, Folder);
99
100 return (true);
101 }
102
103 public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parent)
104 {
105 if (!this.InventoryFolders.ContainsKey(folderID))
106 {
107 System.Console.WriteLine("creating new folder called " + folderName + " in agents inventory");
108 InventoryFolder Folder = new InventoryFolder();
109 Folder.FolderID = folderID;
110 Folder.OwnerID = this.AgentID;
111 Folder.DefaultType = type;
112 Folder.FolderName = folderName;
113 Folder.ParentID = parent;
114 this.InventoryFolders.Add(Folder.FolderID, Folder);
115 }
116
117 return (true);
118 }
119
120 public bool HasFolder(LLUUID folderID)
121 {
122 if (this.InventoryFolders.ContainsKey(folderID))
123 {
124 return true;
125 }
126 return false;
127 }
128
129 public LLUUID GetFolderID(string folderName)
130 {
131 foreach (InventoryFolder inv in this.InventoryFolders.Values)
132 {
133 if (inv.FolderName == folderName)
134 {
135 return inv.FolderID;
136 }
137 }
138
139 return LLUUID.Zero;
140 }
141
142 public bool UpdateItemAsset(LLUUID itemID, AssetBase asset)
143 {
144 if(this.InventoryItems.ContainsKey(itemID))
145 {
146 InventoryItem Item = this.InventoryItems[itemID];
147 Item.AssetID = asset.FullID;
148 System.Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated() + " so it now is set to asset " + asset.FullID.ToStringHyphenated());
149 //TODO need to update the rest of the info
150 }
151 return true;
152 }
153
154 public bool UpdateItemDetails(LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet)
155 {
156 System.Console.WriteLine("updating inventory item details");
157 if (this.InventoryItems.ContainsKey(itemID))
158 {
159 System.Console.WriteLine("changing name to "+ Util.FieldToString(packet.Name));
160 InventoryItem Item = this.InventoryItems[itemID];
161 Item.Name = Util.FieldToString(packet.Name);
162 System.Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated());
163 //TODO need to update the rest of the info
164 }
165 return true;
166 }
167
168 public LLUUID AddToInventory(LLUUID folderID, AssetBase asset)
169 {
170 if (this.InventoryFolders.ContainsKey(folderID))
171 {
172 LLUUID NewItemID = LLUUID.Random();
173
174 InventoryItem Item = new InventoryItem();
175 Item.FolderID = folderID;
176 Item.OwnerID = AgentID;
177 Item.AssetID = asset.FullID;
178 Item.ItemID = NewItemID;
179 Item.Type = asset.Type;
180 Item.Name = asset.Name;
181 Item.Description = asset.Description;
182 Item.InvType = asset.InvType;
183 this.InventoryItems.Add(Item.ItemID, Item);
184 InventoryFolder Folder = InventoryFolders[Item.FolderID];
185 Folder.Items.Add(Item);
186 return (Item.ItemID);
187 }
188 else
189 {
190 return (null);
191 }
192 }
193
194 public bool DeleteFromInventory(LLUUID itemID)
195 {
196 bool res = false;
197 if (this.InventoryItems.ContainsKey(itemID))
198 {
199 InventoryItem item = this.InventoryItems[itemID];
200 this.InventoryItems.Remove(itemID);
201 foreach (InventoryFolder fold in InventoryFolders.Values)
202 {
203 if (fold.Items.Contains(item))
204 {
205 fold.Items.Remove(item);
206 break;
207 }
208 }
209 res = true;
210
211 }
212 return res;
213 }
214 }
215
216 public class InventoryFolder
217 {
218 public List<InventoryItem> Items;
219 //public List<InventoryFolder> Subfolders;
220 public LLUUID FolderID;
221 public LLUUID OwnerID;
222 public LLUUID ParentID = LLUUID.Zero;
223 public string FolderName;
224 public ushort DefaultType;
225 public ushort Version;
226
227 public InventoryFolder()
228 {
229 Items = new List<InventoryItem>();
230 //Subfolders = new List<InventoryFolder>();
231 }
232
233 }
234
235 public class InventoryItem
236 {
237 public LLUUID FolderID;
238 public LLUUID OwnerID;
239 public LLUUID ItemID;
240 public LLUUID AssetID;
241 public LLUUID CreatorID;
242 public sbyte InvType;
243 public sbyte Type;
244 public string Name ="";
245 public string Description;
246
247 public InventoryItem()
248 {
249 this.CreatorID = LLUUID.Zero;
250 }
251
252 public string ExportString()
253 {
254 string typ = "notecard";
255 string result = "";
256 result += "\tinv_object\t0\n\t{\n";
257 result += "\t\tobj_id\t%s\n";
258 result += "\t\tparent_id\t"+ ItemID.ToString() +"\n";
259 result += "\t\ttype\t"+ typ +"\n";
260 result += "\t\tname\t" + Name+"|\n";
261 result += "\t}\n";
262 return result;
263 }
264 }
265}
diff --git a/OpenSim/Framework/General/AuthenticateSessionBase.cs b/OpenSim/Framework/General/AuthenticateSessionBase.cs
new file mode 100644
index 0000000..71616e3
--- /dev/null
+++ b/OpenSim/Framework/General/AuthenticateSessionBase.cs
@@ -0,0 +1,130 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
30using OpenSim.Framework.Interfaces;
31using OpenSim.Framework.Types;
32
33namespace OpenSim.Framework
34{
35 public class AuthenticateSessionsBase
36 {
37 public Dictionary<uint, AgentCircuitData> AgentCircuits = new Dictionary<uint, AgentCircuitData>();
38
39 public AuthenticateSessionsBase()
40 {
41
42 }
43
44 public virtual AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode)
45 {
46 AgentCircuitData validcircuit = null;
47 if (this.AgentCircuits.ContainsKey(circuitcode))
48 {
49 validcircuit = this.AgentCircuits[circuitcode];
50 }
51 AuthenticateResponse user = new AuthenticateResponse();
52 if (validcircuit == null)
53 {
54 //don't have this circuit code in our list
55 user.Authorised = false;
56 return (user);
57 }
58
59 if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID))
60 {
61 user.Authorised = true;
62 user.LoginInfo = new Login();
63 user.LoginInfo.Agent = agentID;
64 user.LoginInfo.Session = sessionID;
65 user.LoginInfo.SecureSession = validcircuit.SecureSessionID;
66 user.LoginInfo.First = validcircuit.firstname;
67 user.LoginInfo.Last = validcircuit.lastname;
68 user.LoginInfo.InventoryFolder = validcircuit.InventoryFolder;
69 user.LoginInfo.BaseFolder = validcircuit.BaseFolder;
70 }
71 else
72 {
73 // Invalid
74 user.Authorised = false;
75 }
76
77 return (user);
78 }
79
80 public virtual void AddNewCircuit(uint circuitCode, AgentCircuitData agentData)
81 {
82 if (this.AgentCircuits.ContainsKey(circuitCode))
83 {
84 this.AgentCircuits[circuitCode] = agentData;
85 }
86 else
87 {
88 this.AgentCircuits.Add(circuitCode, agentData);
89 }
90 }
91
92 public LLVector3 GetPosition(uint circuitCode)
93 {
94 LLVector3 vec = new LLVector3();
95 if (this.AgentCircuits.ContainsKey(circuitCode))
96 {
97 vec = this.AgentCircuits[circuitCode].startpos;
98 }
99 return vec;
100 }
101
102 public void UpdateAgentData(AgentCircuitData agentData)
103 {
104 if (this.AgentCircuits.ContainsKey((uint)agentData.circuitcode))
105 {
106 this.AgentCircuits[(uint)agentData.circuitcode].firstname = agentData.firstname;
107 this.AgentCircuits[(uint)agentData.circuitcode].lastname = agentData.lastname;
108 this.AgentCircuits[(uint)agentData.circuitcode].startpos = agentData.startpos;
109 // Console.WriteLine("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z);
110 }
111 }
112
113 public void UpdateAgentChildStatus(uint circuitcode, bool childstatus)
114 {
115 if (this.AgentCircuits.ContainsKey(circuitcode))
116 {
117 this.AgentCircuits[circuitcode].child = childstatus;
118 }
119 }
120
121 public bool GetAgentChildStatus(uint circuitcode)
122 {
123 if (this.AgentCircuits.ContainsKey(circuitcode))
124 {
125 return this.AgentCircuits[circuitcode].child;
126 }
127 return false;
128 }
129 }
130} \ No newline at end of file
diff --git a/OpenSim/Framework/General/BlockingQueue.cs b/OpenSim/Framework/General/BlockingQueue.cs
new file mode 100644
index 0000000..0cc8124
--- /dev/null
+++ b/OpenSim/Framework/General/BlockingQueue.cs
@@ -0,0 +1,58 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 System.Threading;
30
31namespace OpenSim.Framework.Utilities
32{
33 public class BlockingQueue<T>
34 {
35 private Queue<T> _queue = new Queue<T>();
36 private object _queueSync = new object();
37
38 public void Enqueue(T value)
39 {
40 lock (_queueSync)
41 {
42 _queue.Enqueue(value);
43 Monitor.Pulse(_queueSync);
44 }
45 }
46
47 public T Dequeue()
48 {
49 lock (_queueSync)
50 {
51 if (_queue.Count < 1)
52 Monitor.Wait(_queueSync);
53
54 return _queue.Dequeue();
55 }
56 }
57 }
58}
diff --git a/OpenSim/Framework/General/ClientManager.cs b/OpenSim/Framework/General/ClientManager.cs
new file mode 100644
index 0000000..b560ca8
--- /dev/null
+++ b/OpenSim/Framework/General/ClientManager.cs
@@ -0,0 +1,36 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Framework.Interfaces;
5
6namespace OpenSim.Framework
7{
8 public delegate void ForEachClientDelegate( IClientAPI client );
9 public class ClientManager
10 {
11 private Dictionary<uint, IClientAPI> m_clients;
12
13 public void ForEachClient(ForEachClientDelegate whatToDo)
14 {
15 foreach (IClientAPI client in m_clients.Values)
16 {
17 whatToDo(client);
18 }
19 }
20
21 public ClientManager()
22 {
23 m_clients = new Dictionary<uint, IClientAPI>();
24 }
25
26 public void Remove(uint id)
27 {
28 m_clients.Remove(id);
29 }
30
31 public void Add(uint id, IClientAPI client )
32 {
33 m_clients.Add( id, client );
34 }
35 }
36}
diff --git a/OpenSim/Framework/General/IRegionCommsListener.cs b/OpenSim/Framework/General/IRegionCommsListener.cs
new file mode 100644
index 0000000..32444f9
--- /dev/null
+++ b/OpenSim/Framework/General/IRegionCommsListener.cs
@@ -0,0 +1,46 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
30using OpenSim.Framework.Interfaces;
31using OpenSim.Framework.Types;
32
33namespace OpenSim.Framework
34{
35 public delegate void ExpectUserDelegate(ulong regionHandle, AgentCircuitData agent);
36 public delegate void UpdateNeighbours(List<RegionInfo> neighbours);
37 public delegate void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position);
38
39 public interface IRegionCommsListener
40 {
41 event ExpectUserDelegate OnExpectUser;
42 event GenericCall2 OnExpectChildAgent;
43 event AgentCrossing OnAvatarCrossingIntoRegion;
44 event UpdateNeighbours OnNeighboursUpdate;
45 }
46}
diff --git a/OpenSim/Framework/General/Interfaces/AuthenticateResponse.cs b/OpenSim/Framework/General/Interfaces/AuthenticateResponse.cs
new file mode 100644
index 0000000..508485b
--- /dev/null
+++ b/OpenSim/Framework/General/Interfaces/AuthenticateResponse.cs
@@ -0,0 +1,43 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Types;
29
30namespace OpenSim.Framework.Interfaces
31{
32 public class AuthenticateResponse
33 {
34 public bool Authorised;
35 public Login LoginInfo;
36
37 public AuthenticateResponse()
38 {
39
40 }
41
42 }
43}
diff --git a/OpenSim/Framework/General/Interfaces/Config/IGenericConfig.cs b/OpenSim/Framework/General/Interfaces/Config/IGenericConfig.cs
new file mode 100644
index 0000000..2c379dd
--- /dev/null
+++ b/OpenSim/Framework/General/Interfaces/Config/IGenericConfig.cs
@@ -0,0 +1,38 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28namespace OpenSim.Framework.Interfaces
29{
30 public interface IGenericConfig
31 {
32 void LoadData();
33 string GetAttribute(string attributeName);
34 bool SetAttribute(string attributeName, string attributeValue);
35 void Commit();
36 void Close();
37 }
38}
diff --git a/OpenSim/Framework/General/Interfaces/Config/IGridConfig.cs b/OpenSim/Framework/General/Interfaces/Config/IGridConfig.cs
new file mode 100644
index 0000000..81dc293
--- /dev/null
+++ b/OpenSim/Framework/General/Interfaces/Config/IGridConfig.cs
@@ -0,0 +1,59 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28
29//using OpenSim.world;
30
31namespace OpenSim.Framework.Interfaces
32{
33 /// <summary>
34 /// </summary>
35
36
37 public abstract class GridConfig
38 {
39 public string GridOwner;
40 public string DefaultStartupMsg;
41 public string DefaultAssetServer;
42 public string AssetSendKey;
43 public string AssetRecvKey;
44 public string DefaultUserServer;
45 public string UserSendKey;
46 public string UserRecvKey;
47 public string SimSendKey;
48 public string SimRecvKey;
49
50
51 public abstract void InitConfig();
52
53 }
54
55 public interface IGridConfig
56 {
57 GridConfig GetConfigObject();
58 }
59}
diff --git a/OpenSim/Framework/General/Interfaces/Config/IUserConfig.cs b/OpenSim/Framework/General/Interfaces/Config/IUserConfig.cs
new file mode 100644
index 0000000..ae6cedb
--- /dev/null
+++ b/OpenSim/Framework/General/Interfaces/Config/IUserConfig.cs
@@ -0,0 +1,53 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28
29//using OpenSim.world;
30
31namespace OpenSim.Framework.Interfaces
32{
33 /// <summary>
34 /// </summary>
35
36
37 public abstract class UserConfig
38 {
39 public string DefaultStartupMsg;
40 public string GridServerURL;
41 public string GridSendKey;
42 public string GridRecvKey;
43
44
45 public abstract void InitConfig();
46
47 }
48
49 public interface IUserConfig
50 {
51 UserConfig GetConfigObject();
52 }
53}
diff --git a/OpenSim/Framework/General/Interfaces/IAssetServer.cs b/OpenSim/Framework/General/Interfaces/IAssetServer.cs
new file mode 100644
index 0000000..ab60dd7
--- /dev/null
+++ b/OpenSim/Framework/General/Interfaces/IAssetServer.cs
@@ -0,0 +1,64 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29using OpenSim.Framework.Types;
30
31namespace OpenSim.Framework.Interfaces
32{
33 /// <summary>
34 /// Description of IAssetServer.
35 /// </summary>
36
37 public interface IAssetServer
38 {
39 void SetReceiver(IAssetReceiver receiver);
40 void RequestAsset(LLUUID assetID, bool isTexture);
41 void UpdateAsset(AssetBase asset);
42 void UploadNewAsset(AssetBase asset);
43 void SetServerInfo(string ServerUrl, string ServerKey);
44 void Close();
45 }
46
47 // could change to delegate?
48 public interface IAssetReceiver
49 {
50 void AssetReceived(AssetBase asset, bool IsTexture);
51 void AssetNotFound(AssetBase asset);
52 }
53
54 public interface IAssetPlugin
55 {
56 IAssetServer GetAssetServer();
57 }
58
59 public struct ARequest
60 {
61 public LLUUID AssetID;
62 public bool IsTexture;
63 }
64}
diff --git a/OpenSim/Framework/General/Interfaces/IClientAPI.cs b/OpenSim/Framework/General/Interfaces/IClientAPI.cs
new file mode 100644
index 0000000..1b0c682
--- /dev/null
+++ b/OpenSim/Framework/General/Interfaces/IClientAPI.cs
@@ -0,0 +1,180 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 System.Net;
30using libsecondlife;
31using libsecondlife.Packets;
32using OpenSim.Framework.Types;
33
34namespace OpenSim.Framework.Interfaces
35{
36 public delegate void ChatFromViewer(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID);
37 public delegate void ImprovedInstantMessage(LLUUID fromAgentID, LLUUID toAgentID, uint timestamp, string fromAgentName, string message); // Cut down from full list
38 public delegate void RezObject(AssetBase primAsset, LLVector3 pos);
39 public delegate void ModifyTerrain(float height, float seconds, byte size, byte action, float north, float west);
40 public delegate void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam);
41 public delegate void StartAnim(LLUUID animID, int seq);
42 public delegate void LinkObjects(uint parent, List<uint> children);
43 public delegate void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY);
44 public delegate void TeleportLocationRequest(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags);
45
46 public delegate void GenericCall(IClientAPI remoteClient);
47 public delegate void GenericCall2();
48 public delegate void GenericCall3(Packet packet); // really don't want to be passing packets in these events, so this is very temporary.
49 public delegate void GenericCall4(Packet packet, IClientAPI remoteClient);
50 public delegate void GenericCall5(IClientAPI remoteClient, bool status);
51 public delegate void GenericCall6(LLUUID uid);
52 public delegate void GenericCall7(uint localID, string message);
53
54 public delegate void UpdateShape(uint localID, ObjectShapePacket.ObjectDataBlock shapeBlock);
55 public delegate void ObjectSelect(uint localID, IClientAPI remoteClient);
56 public delegate void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient);
57 public delegate void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient);
58 public delegate void UpdateVector(uint localID, LLVector3 pos, IClientAPI remoteClient);
59 public delegate void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient);
60 public delegate void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient);
61 public delegate void UpdatePrimGroupRotation(uint localID,LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient);
62 public delegate void ObjectDuplicate(uint localID, LLVector3 offset, uint dupeFlags);
63 public delegate void StatusChange(bool status);
64 public delegate void NewAvatar(IClientAPI remoteClient, LLUUID agentID, bool status);
65 public delegate void UpdateAgent(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation);
66 public delegate void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 grapPos, IClientAPI remoteClient);
67
68 public delegate void ParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client);
69 public delegate void ParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client);
70 public delegate void ParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client);
71 public delegate void ParcelPropertiesUpdateRequest(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client); // NOTETOSELFremove the packet part
72
73 public delegate void EstateOwnerMessageRequest(EstateOwnerMessagePacket packet, IClientAPI remote_client);
74
75 public delegate void UUIDNameRequest(LLUUID id, IClientAPI remote_client);
76
77 public interface IClientAPI
78 {
79 event ImprovedInstantMessage OnInstantMessage;
80 event ChatFromViewer OnChatFromViewer;
81 event RezObject OnRezObject;
82 event ModifyTerrain OnModifyTerrain;
83 event SetAppearance OnSetAppearance;
84 event StartAnim OnStartAnim;
85 event LinkObjects OnLinkObjects;
86 event RequestMapBlocks OnRequestMapBlocks;
87 event TeleportLocationRequest OnTeleportLocationRequest;
88
89 event GenericCall4 OnDeRezObject;
90 event GenericCall OnRegionHandShakeReply;
91 event GenericCall OnRequestWearables;
92 event GenericCall2 OnCompleteMovementToRegion;
93 event UpdateAgent OnAgentUpdate;
94 event GenericCall OnRequestAvatarsData;
95 event GenericCall4 OnAddPrim;
96 event ObjectDuplicate OnObjectDuplicate;
97 event UpdateVector OnGrapObject;
98 event ObjectSelect OnDeGrapObject;
99 event MoveObject OnGrapUpdate;
100
101 event UpdateShape OnUpdatePrimShape;
102 event ObjectSelect OnObjectSelect;
103 event GenericCall7 OnObjectDescription;
104 event GenericCall7 OnObjectName;
105 event UpdatePrimFlags OnUpdatePrimFlags;
106 event UpdatePrimTexture OnUpdatePrimTexture;
107 event UpdateVector OnUpdatePrimGroupPosition;
108 event UpdateVector OnUpdatePrimSinglePosition;
109 event UpdatePrimRotation OnUpdatePrimGroupRotation;
110 event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
111 event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
112 event UpdateVector OnUpdatePrimScale;
113 event StatusChange OnChildAgentStatus;
114 event GenericCall2 OnStopMovement;
115 event NewAvatar OnNewAvatar;
116 event GenericCall6 OnRemoveAvatar;
117
118 event UUIDNameRequest OnNameFromUUIDRequest;
119
120 event ParcelPropertiesRequest OnParcelPropertiesRequest;
121 event ParcelDivideRequest OnParcelDivideRequest;
122 event ParcelJoinRequest OnParcelJoinRequest;
123 event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
124
125 event EstateOwnerMessageRequest OnEstateOwnerMessage;
126
127 LLVector3 StartPos
128 {
129 get;
130 set;
131 }
132
133 LLUUID AgentId
134 {
135 get;
136 }
137
138 string FirstName
139 {
140 get;
141 }
142
143 string LastName
144 {
145 get;
146 }
147
148 void OutPacket(Packet newPack);
149 void SendWearables(AvatarWearable[] wearables);
150 void SendStartPingCheck(byte seq);
151 void SendKillObject(ulong regionHandle, uint avatarLocalID);
152 void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId);
153 void SendRegionHandshake(RegionInfo regionInfo);
154 void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID);
155 void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID);
156 void SendInstantMessage(string message, LLUUID target);
157 void SendLayerData(float[] map);
158 void SendLayerData(int px, int py, float[] map);
159 void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look);
160 void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint );
161 AgentCircuitData RequestClientInfo();
162 void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint newRegionExternalEndPoint );
163 void SendMapBlock(List<MapBlockData> mapBlocks);
164 void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags);
165 void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags);
166 void SendTeleportCancel();
167 void SendTeleportLocationStart();
168 void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance);
169
170 void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry);
171 void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity);
172
173 void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint);
174 void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID textureID , uint flags);
175 void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLUUID textureID, uint flags);
176 void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID);
177 void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID);
178 void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation);
179 }
180}
diff --git a/OpenSim/Framework/General/Interfaces/ILocalStorage.cs b/OpenSim/Framework/General/Interfaces/ILocalStorage.cs
new file mode 100644
index 0000000..dbdb25d
--- /dev/null
+++ b/OpenSim/Framework/General/Interfaces/ILocalStorage.cs
@@ -0,0 +1,68 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28
29using libsecondlife;
30using OpenSim.Framework.Types;
31
32namespace OpenSim.Framework.Interfaces
33{
34 /// <summary>
35 /// ILocalStorage. Really hacked together right now needs cleaning up
36 /// </summary>
37 public interface ILocalStorage
38 {
39 void Initialise(string datastore);
40
41 void StorePrim(PrimData prim);
42 void RemovePrim(LLUUID primID);
43 void LoadPrimitives(ILocalStorageReceiver receiver);
44
45 float[] LoadWorld();
46 void SaveMap(float[] heightmap);
47
48 void SaveParcels(ParcelData[] parcels);
49 void SaveParcel(ParcelData parcel);
50 void RemoveParcel(ParcelData parcel);
51 void RemoveAllParcels();
52 void LoadParcels(ILocalStorageParcelReceiver recv);
53
54 void ShutDown();
55 }
56
57 public interface ILocalStorageReceiver
58 {
59 void PrimFromStorage(PrimData prim);
60 }
61
62 public interface ILocalStorageParcelReceiver
63 {
64 void ParcelFromStorage(ParcelData data);
65 void NoParcelDataFromStorage();
66 }
67}
68
diff --git a/OpenSim/Framework/General/Interfaces/IUserServer.cs b/OpenSim/Framework/General/Interfaces/IUserServer.cs
new file mode 100644
index 0000000..b3700d2
--- /dev/null
+++ b/OpenSim/Framework/General/Interfaces/IUserServer.cs
@@ -0,0 +1,39 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29using OpenSim.Framework.Inventory;
30
31namespace OpenSim.Framework.Interfaces
32{
33 public interface IUserServer
34 {
35 AgentInventory RequestAgentsInventory(LLUUID agentID);
36 void SetServerInfo(string ServerUrl, string SendKey, string RecvKey);
37 bool UpdateAgentsInventory(LLUUID agentID, AgentInventory inventory);
38 }
39}
diff --git a/OpenSim/Framework/General/Interfaces/IWorld.cs b/OpenSim/Framework/General/Interfaces/IWorld.cs
new file mode 100644
index 0000000..204c01b
--- /dev/null
+++ b/OpenSim/Framework/General/Interfaces/IWorld.cs
@@ -0,0 +1,42 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29using OpenSim.Framework.Types;
30
31namespace OpenSim.Framework.Interfaces
32{
33 public interface IWorld
34 {
35 void AddNewClient(IClientAPI client, bool child);
36 void RemoveClient(LLUUID agentID);
37
38 RegionInfo RegionInfo { get; }
39 object SyncRoot { get; }
40 uint NextLocalId { get; }
41 }
42}
diff --git a/OpenSim/Framework/General/LoginService.cs b/OpenSim/Framework/General/LoginService.cs
new file mode 100644
index 0000000..02efcec
--- /dev/null
+++ b/OpenSim/Framework/General/LoginService.cs
@@ -0,0 +1,34 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28namespace OpenSim.Framework.Grid
29{
30 public abstract class LoginService
31 {
32
33 }
34} \ No newline at end of file
diff --git a/OpenSim/Framework/General/Properties/AssemblyInfo.cs b/OpenSim/Framework/General/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..004040b
--- /dev/null
+++ b/OpenSim/Framework/General/Properties/AssemblyInfo.cs
@@ -0,0 +1,31 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.FrameWork")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenSim.FrameWork")]
11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("a08e20c7-f191-4137-b1f0-9291408fa521")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30[assembly: AssemblyVersion("1.0.0.0")]
31[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Framework/General/RegionCommsListener.cs b/OpenSim/Framework/General/RegionCommsListener.cs
new file mode 100644
index 0000000..2b0bc62
--- /dev/null
+++ b/OpenSim/Framework/General/RegionCommsListener.cs
@@ -0,0 +1,68 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29using OpenSim.Framework.Interfaces;
30using OpenSim.Framework.Types;
31
32namespace OpenSim.Framework
33{
34 public class RegionCommsListener :IRegionCommsListener
35 {
36 public event ExpectUserDelegate OnExpectUser;
37 public event GenericCall2 OnExpectChildAgent;
38 public event AgentCrossing OnAvatarCrossingIntoRegion;
39 public event UpdateNeighbours OnNeighboursUpdate;
40
41 /// <summary>
42 ///
43 /// </summary>
44 /// <param name="agent"></param>
45 /// <returns></returns>
46 public virtual bool TriggerExpectUser(ulong regionHandle, AgentCircuitData agent)
47 {
48 if(OnExpectUser != null)
49 {
50
51 OnExpectUser(regionHandle, agent);
52 return true;
53 }
54
55 return false;
56 }
57
58 public virtual bool TriggerExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position)
59 {
60 if (OnAvatarCrossingIntoRegion != null)
61 {
62 OnAvatarCrossingIntoRegion(regionHandle, agentID, position);
63 return true;
64 }
65 return false;
66 }
67 }
68}
diff --git a/OpenSim/Framework/General/Remoting.cs b/OpenSim/Framework/General/Remoting.cs
new file mode 100644
index 0000000..df32db2
--- /dev/null
+++ b/OpenSim/Framework/General/Remoting.cs
@@ -0,0 +1,135 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Security.Cryptography;
30using System.Text;
31
32namespace OpenSim.Framework
33{
34 /// <summary>
35 /// NEEDS AUDIT.
36 /// </summary>
37 /// <remarks>
38 /// Suggested implementation
39 /// <para>Store two digests for each foreign host. A local copy of the local hash using the local challenge (when issued), and a local copy of the remote hash using the remote challenge.</para>
40 /// <para>When sending data to the foreign host - run 'Sign' on the data and affix the returned byte[] to the message.</para>
41 /// <para>When recieving data from the foreign host - run 'Authenticate' against the data and the attached byte[].</para>
42 /// <para>Both hosts should be performing these operations for this to be effective.</para>
43 /// </remarks>
44 class RemoteDigest
45 {
46 private byte[] currentHash;
47 private byte[] secret;
48
49 private SHA512Managed SHA512;
50
51 /// <summary>
52 /// Initialises a new RemoteDigest authentication mechanism
53 /// </summary>
54 /// <remarks>Needs an audit by a cryptographic professional - was not "roll your own"'d by choice but rather a serious lack of decent authentication mechanisms in .NET remoting</remarks>
55 /// <param name="sharedSecret">The shared secret between systems (for inter-sim, this is provided in encrypted form during connection, for grid this is input manually in setup)</param>
56 /// <param name="salt">Binary salt - some common value - to be decided what</param>
57 /// <param name="challenge">The challenge key provided by the third party</param>
58 public RemoteDigest(string sharedSecret, byte[] salt, string challenge)
59 {
60 SHA512 = new SHA512Managed();
61 Rfc2898DeriveBytes RFC2898 = new Rfc2898DeriveBytes(sharedSecret,salt);
62 secret = RFC2898.GetBytes(512);
63 ASCIIEncoding ASCII = new ASCIIEncoding();
64
65 currentHash = SHA512.ComputeHash(AppendArrays(secret, ASCII.GetBytes(challenge)));
66 }
67
68 /// <summary>
69 /// Authenticates a piece of incoming data against the local digest. Upon successful authentication, digest string is incremented.
70 /// </summary>
71 /// <param name="data">The incoming data</param>
72 /// <param name="digest">The remote digest</param>
73 /// <returns></returns>
74 public bool Authenticate(byte[] data, byte[] digest)
75 {
76 byte[] newHash = SHA512.ComputeHash(AppendArrays(AppendArrays(currentHash, secret), data));
77 if (digest == newHash)
78 {
79 currentHash = newHash;
80 return true;
81 }
82 else
83 {
84 throw new Exception("Hash comparison failed. Key resync required.");
85 }
86 }
87
88 /// <summary>
89 /// Signs a new bit of data with the current hash. Returns a byte array which should be affixed to the message.
90 /// Signing a piece of data will automatically increment the hash - if you sign data and do not send it, the
91 /// hashes will get out of sync and throw an exception when validation is attempted.
92 /// </summary>
93 /// <param name="data">The outgoing data</param>
94 /// <returns>The local digest</returns>
95 public byte[] Sign(byte[] data)
96 {
97 currentHash = SHA512.ComputeHash(AppendArrays(AppendArrays(currentHash, secret), data));
98 return currentHash;
99 }
100
101 /// <summary>
102 /// Generates a new challenge string to be issued to a foreign host. Challenges are 1024-bit (effective strength of less than 512-bits) messages generated using the Crytographic Random Number Generator.
103 /// </summary>
104 /// <returns>A 128-character hexadecimal string containing the challenge.</returns>
105 public static string GenerateChallenge()
106 {
107 RNGCryptoServiceProvider RNG = new RNGCryptoServiceProvider();
108 byte[] bytes = new byte[64];
109 RNG.GetBytes(bytes);
110
111 StringBuilder sb = new StringBuilder(bytes.Length * 2);
112 foreach (byte b in bytes)
113 {
114 sb.AppendFormat("{0:x2}", b);
115 }
116 return sb.ToString();
117 }
118
119 /// <summary>
120 /// Helper function, merges two byte arrays
121 /// </summary>
122 /// <remarks>Sourced from MSDN Forum</remarks>
123 /// <param name="a">A</param>
124 /// <param name="b">B</param>
125 /// <returns>C</returns>
126 private byte[] AppendArrays(byte[] a, byte[] b)
127 {
128 byte[] c = new byte[a.Length + b.Length];
129 Buffer.BlockCopy(a, 0, c, 0, a.Length);
130 Buffer.BlockCopy(b, 0, c, a.Length, b.Length);
131 return c;
132 }
133
134 }
135}
diff --git a/OpenSim/Framework/General/Types/AgentCiruitData.cs b/OpenSim/Framework/General/Types/AgentCiruitData.cs
new file mode 100644
index 0000000..ed9ee3c
--- /dev/null
+++ b/OpenSim/Framework/General/Types/AgentCiruitData.cs
@@ -0,0 +1,49 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29using System;
30
31namespace OpenSim.Framework.Types
32{
33 [Serializable]
34 public class AgentCircuitData
35 {
36 public AgentCircuitData() { }
37 public LLUUID AgentID;
38 public LLUUID SessionID;
39 public LLUUID SecureSessionID;
40 public LLVector3 startpos;
41 public string firstname;
42 public string lastname;
43 public uint circuitcode;
44 public bool child;
45 public LLUUID InventoryFolder;
46 public LLUUID BaseFolder;
47 public string CapsPath = "";
48 }
49}
diff --git a/OpenSim/Framework/General/Types/AgentWearable.cs b/OpenSim/Framework/General/Types/AgentWearable.cs
new file mode 100644
index 0000000..6152b7d
--- /dev/null
+++ b/OpenSim/Framework/General/Types/AgentWearable.cs
@@ -0,0 +1,57 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29
30namespace OpenSim.Framework.Types
31{
32 public class AvatarWearable
33 {
34 public LLUUID AssetID = new LLUUID("00000000-0000-0000-0000-000000000000");
35 public LLUUID ItemID = new LLUUID("00000000-0000-0000-0000-000000000000");
36
37 public AvatarWearable()
38 {
39
40 }
41
42 public static AvatarWearable[] DefaultWearables
43 {
44 get
45 {
46 AvatarWearable[] defaultWearables = new AvatarWearable[13]; //should be 13 of these
47 for (int i = 0; i < 13; i++)
48 {
49 defaultWearables[i] = new AvatarWearable();
50 }
51 defaultWearables[0].AssetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
52 defaultWearables[0].ItemID = LLUUID.Random();
53 return defaultWearables;
54 }
55 }
56 }
57}
diff --git a/OpenSim/Framework/General/Types/AssetBase.cs b/OpenSim/Framework/General/Types/AssetBase.cs
new file mode 100644
index 0000000..c203f51
--- /dev/null
+++ b/OpenSim/Framework/General/Types/AssetBase.cs
@@ -0,0 +1,46 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29
30namespace OpenSim.Framework.Types
31{
32 public class AssetBase
33 {
34 public byte[] Data;
35 public LLUUID FullID;
36 public sbyte Type;
37 public sbyte InvType;
38 public string Name;
39 public string Description;
40
41 public AssetBase()
42 {
43
44 }
45 }
46}
diff --git a/OpenSim/Framework/General/Types/AssetLandmark.cs b/OpenSim/Framework/General/Types/AssetLandmark.cs
new file mode 100644
index 0000000..8aa872e
--- /dev/null
+++ b/OpenSim/Framework/General/Types/AssetLandmark.cs
@@ -0,0 +1,59 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
29using libsecondlife;
30
31namespace OpenSim.Framework.Types
32{
33 public class AssetLandmark : AssetBase
34 {
35 public int Version;
36 public LLVector3 Position;
37 public LLUUID RegionID;
38
39 public AssetLandmark(AssetBase a)
40 {
41 this.Data = a.Data;
42 this.FullID = a.FullID;
43 this.Type = a.Type;
44 this.InvType = a.InvType;
45 this.Name = a.Name;
46 this.Description = a.Description;
47 InternData();
48 }
49
50 private void InternData()
51 {
52 string temp = Encoding.UTF8.GetString(Data).Trim();
53 string[] parts = temp.Split('\n');
54 int.TryParse(parts[0].Substring(17, 1), out Version);
55 LLUUID.TryParse(parts[1].Substring(10, 36), out RegionID);
56 LLVector3.TryParse(parts[2].Substring(11, parts[2].Length - 11), out Position);
57 }
58 }
59}
diff --git a/OpenSim/Framework/General/Types/AssetStorage.cs b/OpenSim/Framework/General/Types/AssetStorage.cs
new file mode 100644
index 0000000..3681336
--- /dev/null
+++ b/OpenSim/Framework/General/Types/AssetStorage.cs
@@ -0,0 +1,47 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29
30namespace OpenSim.Framework.Types
31{
32 public class AssetStorage
33 {
34
35 public AssetStorage() {
36 }
37
38 public AssetStorage(LLUUID assetUUID) {
39 UUID=assetUUID;
40 }
41
42 public byte[] Data;
43 public sbyte Type;
44 public string Name;
45 public LLUUID UUID;
46 }
47}
diff --git a/OpenSim/Framework/General/Types/EstateSettings.cs b/OpenSim/Framework/General/Types/EstateSettings.cs
new file mode 100644
index 0000000..436b109
--- /dev/null
+++ b/OpenSim/Framework/General/Types/EstateSettings.cs
@@ -0,0 +1,93 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28
29using libsecondlife;
30
31namespace OpenSim.Framework.Types
32{
33 public class EstateSettings
34 {
35 //Settings to this island
36 public float billableFactor = (float)0.0;
37 public uint estateID = 0;
38 public uint parentEstateID = 0;
39
40 public byte maxAgents = 40;
41 public float objectBonusFactor = (float)1.0;
42
43 public int redirectGridX = 0; //??
44 public int redirectGridY = 0; //??
45 public Simulator.RegionFlags regionFlags = Simulator.RegionFlags.None; //Booleam values of various region settings
46 public Simulator.SimAccess simAccess = Simulator.SimAccess.Mature; //Is sim PG, Mature, etc? Mature by default.
47 public float sunHour = 0;
48
49 public float terrainRaiseLimit = 0;
50 public float terrainLowerLimit = 0;
51
52 public bool useFixedSun = false;
53 public int pricePerMeter = 1;
54
55 public ushort regionWaterHeight = 20;
56 public bool regionAllowTerraform = true;
57
58 // Region Information
59 // Low resolution 'base' textures. No longer used.
60 public LLUUID terrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); // Default
61 public LLUUID terrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); // Default
62 public LLUUID terrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); // Default
63 public LLUUID terrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); // Default
64
65 // Higher resolution terrain textures
66 public LLUUID terrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000");
67 public LLUUID terrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000");
68 public LLUUID terrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000");
69 public LLUUID terrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000");
70
71 // First quad - each point is bilinearly interpolated at each meter of terrain
72 public float terrainStartHeight0 = 10.0f;
73 public float terrainStartHeight1 = 10.0f;
74 public float terrainStartHeight2 = 10.0f;
75 public float terrainStartHeight3 = 10.0f;
76
77 // Second quad - also bilinearly interpolated.
78 // Terrain texturing is done that:
79 // 0..3 (0 = base0, 3 = base3) = (terrain[x,y] - start[x,y]) / range[x,y]
80 public float terrainHeightRange0 = 60.0f; //00
81 public float terrainHeightRange1 = 60.0f; //01
82 public float terrainHeightRange2 = 60.0f; //10
83 public float terrainHeightRange3 = 60.0f; //11
84
85 // Terrain Default (Must be in F32 Format!)
86 public string terrainFile = "default.r32";
87 public double terrainMultiplier = 60.0;
88 public float waterHeight = (float)20.0;
89
90 public LLUUID terrainImageID = LLUUID.Zero; // the assetID that is the current Map image for this region
91
92 }
93}
diff --git a/OpenSim/Framework/General/Types/Login.cs b/OpenSim/Framework/General/Types/Login.cs
new file mode 100644
index 0000000..d54c019
--- /dev/null
+++ b/OpenSim/Framework/General/Types/Login.cs
@@ -0,0 +1,49 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29
30namespace OpenSim.Framework.Types
31{
32 public class Login
33 {
34 public string First = "Test";
35 public string Last = "User";
36 public LLUUID Agent;
37 public LLUUID Session;
38 public LLUUID SecureSession = LLUUID.Zero;
39 public LLUUID InventoryFolder;
40 public LLUUID BaseFolder;
41 public uint CircuitCode;
42 public string CapsPath ="";
43
44 public Login()
45 {
46
47 }
48 }
49}
diff --git a/OpenSim/Framework/General/Types/MapBlockData.cs b/OpenSim/Framework/General/Types/MapBlockData.cs
new file mode 100644
index 0000000..fbb3b73
--- /dev/null
+++ b/OpenSim/Framework/General/Types/MapBlockData.cs
@@ -0,0 +1,23 @@
1using System;
2using libsecondlife;
3
4namespace OpenSim.Framework.Types
5{
6 public class MapBlockData
7 {
8 public uint Flags;
9 public ushort X;
10 public ushort Y;
11 public byte Agents;
12 public byte Access;
13 public byte WaterHeight;
14 public LLUUID MapImageId;
15 public String Name;
16 public uint RegionFlags;
17
18 public MapBlockData()
19 {
20
21 }
22 }
23}
diff --git a/OpenSim/Framework/General/Types/NeighbourInfo.cs b/OpenSim/Framework/General/Types/NeighbourInfo.cs
new file mode 100644
index 0000000..bb67981
--- /dev/null
+++ b/OpenSim/Framework/General/Types/NeighbourInfo.cs
@@ -0,0 +1,42 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28namespace OpenSim.Framework.Types
29{
30 public class NeighbourInfo
31 {
32 public NeighbourInfo()
33 {
34 }
35
36 public ulong regionhandle;
37 public uint RegionLocX;
38 public uint RegionLocY;
39 public string sim_ip;
40 public uint sim_port;
41 }
42}
diff --git a/OpenSim/Framework/General/Types/NetworkServersInfo.cs b/OpenSim/Framework/General/Types/NetworkServersInfo.cs
new file mode 100644
index 0000000..89ebf94
--- /dev/null
+++ b/OpenSim/Framework/General/Types/NetworkServersInfo.cs
@@ -0,0 +1,219 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 OpenSim.Framework.Console;
30using OpenSim.Framework.Interfaces;
31
32namespace OpenSim.Framework.Types
33{
34 public class NetworkServersInfo
35 {
36 public string AssetURL = "http://127.0.0.1:8003/";
37 public string AssetSendKey = "";
38
39 public string GridURL = "";
40 public string GridSendKey = "";
41 public string GridRecvKey = "";
42 public string UserURL = "";
43 public string UserSendKey = "";
44 public string UserRecvKey = "";
45 public bool isSandbox;
46
47 public uint DefaultHomeLocX = 0;
48 public uint DefaultHomeLocY = 0;
49
50 public int HttpListenerPort = 9000;
51 public int RemotingListenerPort = 8895;
52
53 public void InitConfig(bool sandboxMode, IGenericConfig configData)
54 {
55 this.isSandbox = sandboxMode;
56
57 try
58 {
59 string attri = "";
60
61 attri = "";
62 attri = configData.GetAttribute("HttpListenerPort");
63 if (attri == "")
64 {
65 string location = MainLog.Instance.CmdPrompt("Http Listener Port", "9000");
66 configData.SetAttribute("HttpListenerPort", location);
67 this.HttpListenerPort = Convert.ToInt32(location);
68 }
69 else
70 {
71 this.HttpListenerPort = Convert.ToInt32(attri);
72 }
73
74 attri = "";
75 attri = configData.GetAttribute("RemotingListenerPort");
76 if (attri == "")
77 {
78 string location = MainLog.Instance.CmdPrompt("Remoting Listener Port", "8895");
79 configData.SetAttribute("RemotingListenerPort", location);
80 this.RemotingListenerPort = Convert.ToInt32(location);
81 }
82 else
83 {
84 this.RemotingListenerPort = Convert.ToInt32(attri);
85 }
86
87 if (sandboxMode)
88 {
89 // default home location X
90 attri = "";
91 attri = configData.GetAttribute("DefaultLocationX");
92 if (attri == "")
93 {
94 string location = MainLog.Instance.CmdPrompt("Default Home Location X", "1000");
95 configData.SetAttribute("DefaultLocationX", location);
96 this.DefaultHomeLocX = (uint)Convert.ToUInt32(location);
97 }
98 else
99 {
100 this.DefaultHomeLocX = (uint)Convert.ToUInt32(attri);
101 }
102
103 // default home location Y
104 attri = "";
105 attri = configData.GetAttribute("DefaultLocationY");
106 if (attri == "")
107 {
108 string location = MainLog.Instance.CmdPrompt("Default Home Location Y", "1000");
109 configData.SetAttribute("DefaultLocationY", location);
110 this.DefaultHomeLocY = (uint)Convert.ToUInt32(location);
111 }
112 else
113 {
114 this.DefaultHomeLocY = (uint)Convert.ToUInt32(attri);
115 }
116 }
117 if (!isSandbox)
118 {
119 //Grid Server
120 attri = "";
121 attri = configData.GetAttribute("GridServerURL");
122 if (attri == "")
123 {
124 this.GridURL = MainLog.Instance.CmdPrompt("Grid server URL", "http://127.0.0.1:8001/");
125 configData.SetAttribute("GridServerURL", this.GridURL);
126 }
127 else
128 {
129 this.GridURL = attri;
130 }
131
132 //Grid Send Key
133 attri = "";
134 attri = configData.GetAttribute("GridSendKey");
135 if (attri == "")
136 {
137 this.GridSendKey = MainLog.Instance.CmdPrompt("Key to send to grid server", "null");
138 configData.SetAttribute("GridSendKey", this.GridSendKey);
139 }
140 else
141 {
142 this.GridSendKey = attri;
143 }
144
145 //Grid Receive Key
146 attri = "";
147 attri = configData.GetAttribute("GridRecvKey");
148 if (attri == "")
149 {
150 this.GridRecvKey = MainLog.Instance.CmdPrompt("Key to expect from grid server", "null");
151 configData.SetAttribute("GridRecvKey", this.GridRecvKey);
152 }
153 else
154 {
155 this.GridRecvKey = attri;
156 }
157
158 //Grid Server
159 attri = "";
160 attri = configData.GetAttribute("UserServerURL");
161 if (attri == "")
162 {
163 this.UserURL= MainLog.Instance.CmdPrompt("User server URL", "http://127.0.0.1:8002/");
164 configData.SetAttribute("UserServerURL", this.UserURL);
165 }
166 else
167 {
168 this.UserURL = attri;
169 }
170
171 //Grid Send Key
172 attri = "";
173 attri = configData.GetAttribute("UserSendKey");
174 if (attri == "")
175 {
176 this.UserSendKey = MainLog.Instance.CmdPrompt("Key to send to user server", "null");
177 configData.SetAttribute("UserSendKey", this.UserSendKey);
178 }
179 else
180 {
181 this.UserSendKey = attri;
182 }
183
184 //Grid Receive Key
185 attri = "";
186 attri = configData.GetAttribute("UserRecvKey");
187 if (attri == "")
188 {
189 this.UserRecvKey = MainLog.Instance.CmdPrompt("Key to expect from user server", "null");
190 configData.SetAttribute("GridRecvKey", this.UserRecvKey);
191 }
192 else
193 {
194 this.UserRecvKey = attri;
195 }
196
197 attri = "";
198 attri = configData.GetAttribute("AssetServerURL");
199 if (attri == "")
200 {
201 this.AssetURL = MainLog.Instance.CmdPrompt("Asset server URL", "http://127.0.0.1:8003/");
202 configData.SetAttribute("AssetServerURL", this.GridURL);
203 }
204 else
205 {
206 this.AssetURL = attri;
207 }
208
209 }
210 configData.Commit();
211 }
212 catch (Exception e)
213 {
214 MainLog.Instance.Warn("Config.cs:InitConfig() - Exception occured");
215 MainLog.Instance.Warn(e.ToString());
216 }
217 }
218 }
219}
diff --git a/OpenSim/Framework/General/Types/ParcelData.cs b/OpenSim/Framework/General/Types/ParcelData.cs
new file mode 100644
index 0000000..761d55e
--- /dev/null
+++ b/OpenSim/Framework/General/Types/ParcelData.cs
@@ -0,0 +1,112 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29
30namespace OpenSim.Framework.Types
31{
32
33 public class ParcelData
34 {
35 public byte[] parcelBitmapByteArray = new byte[512];
36 public string parcelName = "";
37 public string parcelDesc = "";
38 public LLUUID ownerID = new LLUUID();
39 public bool isGroupOwned = false;
40 public LLVector3 AABBMin = new LLVector3();
41 public LLVector3 AABBMax = new LLVector3();
42 public int area = 0;
43 public uint auctionID = 0; //Unemplemented. If set to 0, not being auctioned
44 public LLUUID authBuyerID = new LLUUID(); //Unemplemented. Authorized Buyer's UUID
45 public Parcel.ParcelCategory category = new Parcel.ParcelCategory(); //Unemplemented. Parcel's chosen category
46 public int claimDate = 0; //Unemplemented
47 public int claimPrice = 0; //Unemplemented
48 public LLUUID groupID = new LLUUID(); //Unemplemented
49 public int groupPrims = 0; //Unemplemented
50 public int salePrice = 0; //Unemeplemented. Parcels price.
51 public Parcel.ParcelStatus parcelStatus = Parcel.ParcelStatus.None;
52 public Parcel.ParcelFlags parcelFlags = Parcel.ParcelFlags.None;
53 public byte landingType = 0;
54 public byte mediaAutoScale = 0;
55 public LLUUID mediaID = LLUUID.Zero;
56 public int localID = 0;
57 public LLUUID globalID = new LLUUID();
58
59 public string mediaURL = "";
60 public string musicURL = "";
61 public float passHours = 0;
62 public int passPrice = 0;
63 public LLUUID snapshotID = LLUUID.Zero;
64 public LLVector3 userLocation = new LLVector3();
65 public LLVector3 userLookAt = new LLVector3();
66
67 public ParcelData()
68 {
69 globalID = LLUUID.Random();
70 }
71
72 public ParcelData Copy()
73 {
74 ParcelData parcelData = new ParcelData();
75
76 parcelData.AABBMax = this.AABBMax;
77 parcelData.AABBMin = this.AABBMin;
78 parcelData.area = this.area;
79 parcelData.auctionID = this.auctionID;
80 parcelData.authBuyerID = this.authBuyerID;
81 parcelData.category = this.category;
82 parcelData.claimDate = this.claimDate;
83 parcelData.claimPrice = this.claimPrice;
84 parcelData.globalID = this.globalID;
85 parcelData.groupID = this.groupID;
86 parcelData.groupPrims = this.groupPrims;
87 parcelData.isGroupOwned = this.isGroupOwned;
88 parcelData.localID = this.localID;
89 parcelData.landingType = this.landingType;
90 parcelData.mediaAutoScale = this.mediaAutoScale;
91 parcelData.mediaID = this.mediaID;
92 parcelData.mediaURL = this.mediaURL;
93 parcelData.musicURL = this.musicURL;
94 parcelData.ownerID = this.ownerID;
95 parcelData.parcelBitmapByteArray = (byte[])this.parcelBitmapByteArray.Clone();
96 parcelData.parcelDesc = this.parcelDesc;
97 parcelData.parcelFlags = this.parcelFlags;
98 parcelData.parcelName = this.parcelName;
99 parcelData.parcelStatus = this.parcelStatus;
100 parcelData.passHours = this.passHours;
101 parcelData.passPrice = this.passPrice;
102 parcelData.salePrice = this.salePrice;
103 parcelData.snapshotID = this.snapshotID;
104 parcelData.userLocation = this.userLocation;
105 parcelData.userLookAt = this.userLookAt;
106
107 return parcelData;
108
109 }
110 }
111
112}
diff --git a/OpenSim/Framework/General/Types/PrimData.cs b/OpenSim/Framework/General/Types/PrimData.cs
new file mode 100644
index 0000000..ff81bcd
--- /dev/null
+++ b/OpenSim/Framework/General/Types/PrimData.cs
@@ -0,0 +1,228 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
30
31namespace OpenSim.Framework.Types
32{
33 public class PrimData
34 {
35 private const uint FULL_MASK_PERMISSIONS = 2147483647;
36
37 public LLUUID OwnerID;
38 public byte PCode;
39 public ushort PathBegin;
40 public ushort PathEnd;
41 public byte PathScaleX;
42 public byte PathScaleY;
43 public byte PathShearX;
44 public byte PathShearY;
45 public sbyte PathSkew;
46 public ushort ProfileBegin;
47 public ushort ProfileEnd;
48 public LLVector3 Scale;
49 public byte PathCurve;
50 public byte ProfileCurve;
51 public uint ParentID = 0;
52 public ushort ProfileHollow;
53 public sbyte PathRadiusOffset;
54 public byte PathRevolutions;
55 public sbyte PathTaperX;
56 public sbyte PathTaperY;
57 public sbyte PathTwist;
58 public sbyte PathTwistBegin;
59 public byte[] TextureEntry; // a LL textureEntry in byte[] format
60
61 public Int32 CreationDate;
62 public uint OwnerMask = FULL_MASK_PERMISSIONS;
63 public uint NextOwnerMask = FULL_MASK_PERMISSIONS;
64 public uint GroupMask = FULL_MASK_PERMISSIONS;
65 public uint EveryoneMask = FULL_MASK_PERMISSIONS;
66 public uint BaseMask = FULL_MASK_PERMISSIONS;
67
68 //following only used during prim storage
69 public LLVector3 Position;
70 public LLQuaternion Rotation = new LLQuaternion(0, 1, 0, 0);
71 public uint LocalID;
72 public LLUUID FullID;
73
74 public PrimData()
75 {
76
77 }
78
79 public PrimData(byte[] data)
80 {
81 int i = 0;
82
83 this.OwnerID = new LLUUID(data, i); i += 16;
84 this.PCode = data[i++];
85 this.PathBegin = (ushort)(data[i++] + (data[i++] << 8));
86 this.PathEnd = (ushort)(data[i++] + (data[i++] << 8));
87 this.PathScaleX = data[i++];
88 this.PathScaleY = data[i++];
89 this.PathShearX = data[i++];
90 this.PathShearY = data[i++];
91 this.PathSkew = (sbyte)data[i++];
92 this.ProfileBegin = (ushort)(data[i++] + (data[i++] << 8));
93 this.ProfileEnd = (ushort)(data[i++] + (data[i++] << 8));
94 this.Scale = new LLVector3(data, i); i += 12;
95 this.PathCurve = data[i++];
96 this.ProfileCurve = data[i++];
97 this.ParentID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
98 this.ProfileHollow = (ushort)(data[i++] + (data[i++] << 8));
99 this.PathRadiusOffset = (sbyte)data[i++];
100 this.PathRevolutions = data[i++];
101 this.PathTaperX = (sbyte)data[i++];
102 this.PathTaperY = (sbyte)data[i++];
103 this.PathTwist = (sbyte)data[i++];
104 this.PathTwistBegin = (sbyte)data[i++];
105 ushort length = (ushort)(data[i++] + (data[i++] << 8));
106 this.TextureEntry = new byte[length];
107 Array.Copy(data, i, TextureEntry, 0, length); i += length;
108 this.CreationDate = (Int32)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
109 this.OwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
110 this.NextOwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
111 this.GroupMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
112 this.EveryoneMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
113 this.BaseMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
114 this.Position = new LLVector3(data, i); i += 12;
115 this.Rotation = new LLQuaternion(data, i, true); i += 12;
116 this.LocalID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
117 this.FullID = new LLUUID(data, i); i += 16;
118
119 }
120
121 public byte[] ToBytes()
122 {
123 int i = 0;
124 byte[] bytes = new byte[126 + TextureEntry.Length];
125 Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16;
126 bytes[i++] = this.PCode;
127 bytes[i++] = (byte)(this.PathBegin % 256);
128 bytes[i++] = (byte)((this.PathBegin >> 8) % 256);
129 bytes[i++] = (byte)(this.PathEnd % 256);
130 bytes[i++] = (byte)((this.PathEnd >> 8) % 256);
131 bytes[i++] = this.PathScaleX;
132 bytes[i++] = this.PathScaleY;
133 bytes[i++] = this.PathShearX;
134 bytes[i++] = this.PathShearY;
135 bytes[i++] = (byte)this.PathSkew;
136 bytes[i++] = (byte)(this.ProfileBegin % 256);
137 bytes[i++] = (byte)((this.ProfileBegin >> 8) % 256);
138 bytes[i++] = (byte)(this.ProfileEnd % 256);
139 bytes[i++] = (byte)((this.ProfileEnd >> 8) % 256);
140 Array.Copy(Scale.GetBytes(), 0, bytes, i, 12); i += 12;
141 bytes[i++] = this.PathCurve;
142 bytes[i++] = this.ProfileCurve;
143 bytes[i++] = (byte)(ParentID % 256);
144 bytes[i++] = (byte)((ParentID >> 8) % 256);
145 bytes[i++] = (byte)((ParentID >> 16) % 256);
146 bytes[i++] = (byte)((ParentID >> 24) % 256);
147 bytes[i++] = (byte)(this.ProfileHollow % 256);
148 bytes[i++] = (byte)((this.ProfileHollow >> 8) % 256);
149 bytes[i++] = ((byte)this.PathRadiusOffset);
150 bytes[i++] = this.PathRevolutions;
151 bytes[i++] = ((byte)this.PathTaperX);
152 bytes[i++] = ((byte)this.PathTaperY);
153 bytes[i++] = ((byte)this.PathTwist);
154 bytes[i++] = ((byte)this.PathTwistBegin);
155 bytes[i++] = (byte)(TextureEntry.Length % 256);
156 bytes[i++] = (byte)((TextureEntry.Length >> 8) % 256);
157 Array.Copy(TextureEntry, 0, bytes, i, TextureEntry.Length); i += TextureEntry.Length;
158 bytes[i++] = (byte)(this.CreationDate % 256);
159 bytes[i++] = (byte)((this.CreationDate >> 8) % 256);
160 bytes[i++] = (byte)((this.CreationDate >> 16) % 256);
161 bytes[i++] = (byte)((this.CreationDate >> 24) % 256);
162 bytes[i++] = (byte)(this.OwnerMask % 256);
163 bytes[i++] = (byte)((this.OwnerMask >> 8) % 256);
164 bytes[i++] = (byte)((this.OwnerMask >> 16) % 256);
165 bytes[i++] = (byte)((this.OwnerMask >> 24) % 256);
166 bytes[i++] = (byte)(this.NextOwnerMask % 256);
167 bytes[i++] = (byte)((this.NextOwnerMask >> 8) % 256);
168 bytes[i++] = (byte)((this.NextOwnerMask >> 16) % 256);
169 bytes[i++] = (byte)((this.NextOwnerMask >> 24) % 256);
170 bytes[i++] = (byte)(this.GroupMask % 256);
171 bytes[i++] = (byte)((this.GroupMask >> 8) % 256);
172 bytes[i++] = (byte)((this.GroupMask >> 16) % 256);
173 bytes[i++] = (byte)((this.GroupMask >> 24) % 256);
174 bytes[i++] = (byte)(this.EveryoneMask % 256);
175 bytes[i++] = (byte)((this.EveryoneMask >> 8) % 256);
176 bytes[i++] = (byte)((this.EveryoneMask >> 16) % 256);
177 bytes[i++] = (byte)((this.EveryoneMask >> 24) % 256);
178 bytes[i++] = (byte)(this.BaseMask % 256);
179 bytes[i++] = (byte)((this.BaseMask >> 8) % 256);
180 bytes[i++] = (byte)((this.BaseMask >> 16) % 256);
181 bytes[i++] = (byte)((this.BaseMask >> 24) % 256);
182 Array.Copy(this.Position.GetBytes(), 0, bytes, i, 12); i += 12;
183 if (this.Rotation == new LLQuaternion(0, 0, 0, 0))
184 {
185 this.Rotation = new LLQuaternion(0, 1, 0, 0);
186 }
187 Array.Copy(this.Rotation.GetBytes(), 0, bytes, i, 12); i += 12;
188 bytes[i++] = (byte)(this.LocalID % 256);
189 bytes[i++] = (byte)((this.LocalID >> 8) % 256);
190 bytes[i++] = (byte)((this.LocalID >> 16) % 256);
191 bytes[i++] = (byte)((this.LocalID >> 24) % 256);
192 Array.Copy(FullID.GetBytes(), 0, bytes, i, 16); i += 16;
193
194 return bytes;
195 }
196
197 public static PrimData DefaultCube()
198 {
199 PrimData primData = new PrimData();
200 primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
201 primData.FullID = LLUUID.Random();
202 primData.Scale = new LLVector3(0.5f, 0.5f, 0.5f);
203 primData.Rotation = new LLQuaternion(0, 0, 0, 1);
204 primData.PCode = 9;
205 primData.ParentID = 0;
206 primData.PathBegin = 0;
207 primData.PathEnd = 0;
208 primData.PathScaleX = 0;
209 primData.PathScaleY = 0;
210 primData.PathShearX = 0;
211 primData.PathShearY = 0;
212 primData.PathSkew = 0;
213 primData.ProfileBegin = 0;
214 primData.ProfileEnd = 0;
215 primData.PathCurve = 16;
216 primData.ProfileCurve = 1;
217 primData.ProfileHollow = 0;
218 primData.PathRadiusOffset = 0;
219 primData.PathRevolutions = 0;
220 primData.PathTaperX = 0;
221 primData.PathTaperY = 0;
222 primData.PathTwist = 0;
223 primData.PathTwistBegin = 0;
224
225 return primData;
226 }
227 }
228}
diff --git a/OpenSim/Framework/General/Types/PrimitiveBaseShape.cs b/OpenSim/Framework/General/Types/PrimitiveBaseShape.cs
new file mode 100644
index 0000000..a6671d1
--- /dev/null
+++ b/OpenSim/Framework/General/Types/PrimitiveBaseShape.cs
@@ -0,0 +1,102 @@
1using libsecondlife;
2
3namespace OpenSim.Framework.Types
4{
5 public enum ShapeType
6 {
7 Box,
8 Sphere,
9 Ring,
10 Tube,
11 Torus,
12 Prism,
13 Scuplted,
14 Cylinder,
15 Foliage,
16 Unknown
17 }
18
19 public class PrimitiveBaseShape
20 {
21 private ShapeType type = ShapeType.Unknown;
22
23 public byte PCode;
24 public ushort PathBegin;
25 public ushort PathEnd;
26 public byte PathScaleX;
27 public byte PathScaleY;
28 public byte PathShearX;
29 public byte PathShearY;
30 public sbyte PathSkew;
31 public ushort ProfileBegin;
32 public ushort ProfileEnd;
33 public LLVector3 Scale;
34 public byte PathCurve;
35 public byte ProfileCurve;
36 public ushort ProfileHollow;
37 public sbyte PathRadiusOffset;
38 public byte PathRevolutions;
39 public sbyte PathTaperX;
40 public sbyte PathTaperY;
41 public sbyte PathTwist;
42 public sbyte PathTwistBegin;
43 public byte[] TextureEntry; // a LL textureEntry in byte[] format
44
45 public ShapeType PrimType
46 {
47 get
48 {
49 return this.type;
50 }
51 }
52
53 public LLVector3 PrimScale
54 {
55 get
56 {
57 return this.Scale;
58 }
59 }
60
61 public PrimitiveBaseShape()
62 {
63
64 }
65
66 //void returns need to change of course
67 public void GetMesh()
68 {
69
70 }
71
72 public static PrimitiveBaseShape DefaultBox()
73 {
74 PrimitiveBaseShape primShape = new PrimitiveBaseShape();
75
76 primShape.type = ShapeType.Box;
77 primShape.Scale = new LLVector3(0.5f, 0.5f, 0.5f);
78 primShape.PCode = 9;
79 primShape.PathBegin = 0;
80 primShape.PathEnd = 0;
81 primShape.PathScaleX = 0;
82 primShape.PathScaleY = 0;
83 primShape.PathShearX = 0;
84 primShape.PathShearY = 0;
85 primShape.PathSkew = 0;
86 primShape.ProfileBegin = 0;
87 primShape.ProfileEnd = 0;
88 primShape.PathCurve = 16;
89 primShape.ProfileCurve = 1;
90 primShape.ProfileHollow = 0;
91 primShape.PathRadiusOffset = 0;
92 primShape.PathRevolutions = 0;
93 primShape.PathTaperX = 0;
94 primShape.PathTaperY = 0;
95 primShape.PathTwist = 0;
96 primShape.PathTwistBegin = 0;
97
98 return primShape;
99 }
100 }
101
102}
diff --git a/OpenSim/Framework/General/Types/RegionHandle.cs b/OpenSim/Framework/General/Types/RegionHandle.cs
new file mode 100644
index 0000000..4a055ad
--- /dev/null
+++ b/OpenSim/Framework/General/Types/RegionHandle.cs
@@ -0,0 +1,121 @@
1using System;
2using System.Net;
3
4namespace OpenSim.Framework.Types
5{
6 /// <summary>
7 /// A class for manipulating RegionHandle coordinates
8 /// </summary>
9 class RegionHandle
10 {
11 private UInt64 handle;
12
13 /// <summary>
14 /// Initialises a new grid-aware RegionHandle
15 /// </summary>
16 /// <param name="ip">IP Address of the Grid Server for this region</param>
17 /// <param name="x">Grid X Coordinate</param>
18 /// <param name="y">Grid Y Coordinate</param>
19 public RegionHandle(string ip, short x, short y)
20 {
21 IPAddress addr = IPAddress.Parse(ip);
22
23 if (addr.AddressFamily != System.Net.Sockets.AddressFamily.InterNetwork)
24 throw new Exception("Bad RegionHandle Parameter - must be an IPv4 address");
25
26 uint baseHandle = BitConverter.ToUInt32(addr.GetAddressBytes(), 0);
27
28 // Split the IP address in half
29 short a = (short)((baseHandle << 16) & 0xFFFF);
30 short b = (short)((baseHandle << 0) & 0xFFFF);
31
32 // Raise the bounds a little
33 uint nx = (uint)x;
34 uint ny = (uint)y;
35
36 // Multiply grid coords to get region coords
37 nx *= 256;
38 ny *= 256;
39
40 // Stuff the IP address in too
41 nx = (uint)a << 16;
42 ny = (uint)b << 16;
43
44 handle = ((UInt64)nx << 32) | (uint)ny;
45 }
46
47 /// <summary>
48 /// Initialises a new RegionHandle that is not inter-grid aware
49 /// </summary>
50 /// <param name="x">Grid X Coordinate</param>
51 /// <param name="y">Grid Y Coordinate</param>
52 public RegionHandle(uint x, uint y)
53 {
54 handle = ((x * 256) << 32) | (y * 256);
55 }
56
57 /// <summary>
58 /// Initialises a new RegionHandle from an existing value
59 /// </summary>
60 /// <param name="Region">A U64 RegionHandle</param>
61 public RegionHandle(UInt64 Region)
62 {
63 handle = Region;
64 }
65
66 /// <summary>
67 /// Returns the Grid Masked RegionHandle - For use in Teleport packets and other packets where sending the grid IP address may be handy.
68 /// </summary>
69 /// <remarks>Do not use for SimulatorEnable packets. The client will choke.</remarks>
70 /// <returns>Region Handle including IP Address encoding</returns>
71 public UInt64 getTeleportHandle()
72 {
73 return handle;
74 }
75
76 /// <summary>
77 /// Returns a RegionHandle which may be used for SimulatorEnable packets. Removes the IP address encoding and returns the lower bounds.
78 /// </summary>
79 /// <returns>A U64 RegionHandle for use in SimulatorEnable packets.</returns>
80 public UInt64 getNeighbourHandle()
81 {
82 UInt64 mask = 0x0000FFFF0000FFFF;
83
84 return handle | mask;
85 }
86
87 /// <summary>
88 /// Returns the IP Address of the GridServer from a Grid-Encoded RegionHandle
89 /// </summary>
90 /// <returns>Grid Server IP Address</returns>
91 public IPAddress getGridIP()
92 {
93 uint a = (uint)((handle >> 16) & 0xFFFF);
94 uint b = (uint)((handle >> 48) & 0xFFFF);
95
96 return new IPAddress((long)(a << 16) | (long)b);
97 }
98
99 /// <summary>
100 /// Returns the X Coordinate from a Grid-Encoded RegionHandle
101 /// </summary>
102 /// <returns>X Coordinate</returns>
103 public uint getGridX()
104 {
105 uint x = (uint)((handle >> 32) & 0xFFFF);
106
107 return x;
108 }
109
110 /// <summary>
111 /// Returns the Y Coordinate from a Grid-Encoded RegionHandle
112 /// </summary>
113 /// <returns>Y Coordinate</returns>
114 public uint getGridY()
115 {
116 uint y = (uint)((handle >> 0) & 0xFFFF);
117
118 return y;
119 }
120 }
121}
diff --git a/OpenSim/Framework/General/Types/RegionInfo.cs b/OpenSim/Framework/General/Types/RegionInfo.cs
new file mode 100644
index 0000000..cfc0925
--- /dev/null
+++ b/OpenSim/Framework/General/Types/RegionInfo.cs
@@ -0,0 +1,342 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Globalization;
30using System.Net;
31using System.Net.Sockets;
32using libsecondlife;
33using OpenSim.Framework.Console;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Utilities;
36
37namespace OpenSim.Framework.Types
38{
39 public class RegionInfo
40 {
41 public LLUUID SimUUID = new LLUUID();
42 public string RegionName = "";
43
44 private IPEndPoint m_internalEndPoint;
45 public IPEndPoint InternalEndPoint
46 {
47 get
48 {
49 return m_internalEndPoint;
50 }
51 }
52
53 public IPEndPoint ExternalEndPoint
54 {
55 get
56 {
57 // Old one defaults to IPv6
58 //return new IPEndPoint( Dns.GetHostAddresses( m_externalHostName )[0], m_internalEndPoint.Port );
59
60 // New method favors IPv4
61 IPAddress ia = null;
62 foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName))
63 {
64 if (ia == null)
65 ia = Adr;
66
67 if (Adr.AddressFamily == AddressFamily.InterNetwork)
68 {
69 ia = Adr;
70 break;
71 }
72
73 }
74
75 return new IPEndPoint(ia, m_internalEndPoint.Port);
76 }
77 }
78
79 private string m_externalHostName;
80 public string ExternalHostName
81 {
82 get
83 {
84 return m_externalHostName;
85 }
86 }
87
88 private uint? m_regionLocX;
89 public uint RegionLocX
90 {
91 get
92 {
93 return m_regionLocX.Value;
94 }
95 }
96
97 private uint? m_regionLocY;
98 public uint RegionLocY
99 {
100 get
101 {
102 return m_regionLocY.Value;
103 }
104 }
105
106 private ulong? m_regionHandle;
107 public ulong RegionHandle
108 {
109 get
110 {
111 if (!m_regionHandle.HasValue)
112 {
113 m_regionHandle = Util.UIntsToLong((RegionLocX * 256), (RegionLocY * 256));
114 }
115
116 return m_regionHandle.Value;
117 }
118 }
119
120 // Only used for remote regions , ie ones not in the current instance
121 private uint m_remotingPort;
122 public uint RemotingPort
123 {
124 get
125 {
126 return m_remotingPort;
127 }
128 set
129 {
130 m_remotingPort = value;
131 }
132 }
133 public string RemotingAddress;
134
135 public string DataStore = "";
136 public bool isSandbox = false;
137
138 public LLUUID MasterAvatarAssignedUUID = new LLUUID();
139 public string MasterAvatarFirstName = "";
140 public string MasterAvatarLastName = "";
141 public string MasterAvatarSandboxPassword = "";
142
143 public EstateSettings estateSettings;
144
145 public RegionInfo()
146 {
147 estateSettings = new EstateSettings();
148 }
149
150 public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri)
151 : this()
152 {
153 m_regionLocX = regionLocX;
154 m_regionLocY = regionLocY;
155
156 m_internalEndPoint = internalEndPoint;
157 m_externalHostName = externalUri;
158 }
159
160 public void InitConfig(bool sandboxMode, IGenericConfig configData)
161 {
162 this.isSandbox = sandboxMode;
163 try
164 {
165 string attri = "";
166
167 // Sim UUID
168 string simId = configData.GetAttribute("SimUUID");
169 if (String.IsNullOrEmpty( simId ))
170 {
171 this.SimUUID = LLUUID.Random();
172 }
173 else
174 {
175 this.SimUUID = new LLUUID(simId);
176 }
177 configData.SetAttribute("SimUUID", this.SimUUID.ToString());
178
179 this.RegionName = GetString(configData, "SimName", "OpenSim test", "Region Name");
180
181 //m_regionLocX = (uint) GetInt(configData, "SimLocationX", 1000, "Grid Location X");
182
183 attri = "";
184 attri = configData.GetAttribute("SimLocationX");
185 if (attri == "")
186 {
187 string location = MainLog.Instance.CmdPrompt("Grid Location X", "1000");
188 configData.SetAttribute("SimLocationX", location);
189 m_regionLocX = (uint)Convert.ToUInt32(location);
190 }
191 else
192 {
193 m_regionLocX = (uint)Convert.ToUInt32(attri);
194 }
195 // Sim/Grid location Y
196 attri = "";
197 attri = configData.GetAttribute("SimLocationY");
198 if (attri == "")
199 {
200 string location = MainLog.Instance.CmdPrompt("Grid Location Y", "1000");
201 configData.SetAttribute("SimLocationY", location);
202 m_regionLocY = (uint)Convert.ToUInt32(location);
203 }
204 else
205 {
206 m_regionLocY = (uint)Convert.ToUInt32(attri);
207 }
208
209 m_regionHandle = null;
210
211 this.DataStore = GetString(configData, "Datastore", "localworld.yap", "Filename for local storage");
212
213 IPAddress internalAddress = GetIPAddress(configData, "InternalIPAddress", "0.0.0.0", "Internal IP Address for UDP client connections");
214 int internalPort = GetIPPort(configData, "InternalIPPort", "9000", "Internal IP Port for UDP client connections");
215 m_internalEndPoint = new IPEndPoint(internalAddress, internalPort);
216
217 m_externalHostName = GetString(configData, "ExternalHostName", "127.0.0.1", "External Host Name");
218
219 estateSettings.terrainFile =
220 GetString(configData, "TerrainFile", "default.r32", "GENERAL SETTING: Default Terrain File");
221
222 attri = "";
223 attri = configData.GetAttribute("TerrainMultiplier");
224 if (attri == "")
225 {
226 string re = MainLog.Instance.CmdPrompt("GENERAL SETTING: Terrain Height Multiplier", "60.0");
227 this.estateSettings.terrainMultiplier = Convert.ToDouble(re, CultureInfo.InvariantCulture);
228 configData.SetAttribute("TerrainMultiplier", this.estateSettings.terrainMultiplier.ToString());
229 }
230 else
231 {
232 this.estateSettings.terrainMultiplier = Convert.ToDouble(attri);
233 }
234
235 attri = "";
236 attri = configData.GetAttribute("MasterAvatarFirstName");
237 if (attri == "")
238 {
239 this.MasterAvatarFirstName = MainLog.Instance.CmdPrompt("First name of Master Avatar (Land and Region Owner)", "Test");
240
241 configData.SetAttribute("MasterAvatarFirstName", this.MasterAvatarFirstName);
242 }
243 else
244 {
245 this.MasterAvatarFirstName = attri;
246 }
247
248 attri = "";
249 attri = configData.GetAttribute("MasterAvatarLastName");
250 if (attri == "")
251 {
252 this.MasterAvatarLastName = MainLog.Instance.CmdPrompt("Last name of Master Avatar (Land and Region Owner)", "User");
253
254 configData.SetAttribute("MasterAvatarLastName", this.MasterAvatarLastName);
255 }
256 else
257 {
258 this.MasterAvatarLastName = attri;
259 }
260
261 if (isSandbox) //Sandbox Mode Specific Settings
262 {
263 attri = "";
264 attri = configData.GetAttribute("MasterAvatarSandboxPassword");
265 if (attri == "")
266 {
267 this.MasterAvatarSandboxPassword = MainLog.Instance.CmdPrompt("Password of Master Avatar (Needed for sandbox mode account creation only)", "test");
268
269 //Should I store this?
270 configData.SetAttribute("MasterAvatarSandboxPassword", this.MasterAvatarSandboxPassword);
271 }
272 else
273 {
274 this.MasterAvatarSandboxPassword = attri;
275 }
276 }
277
278 configData.Commit();
279 }
280 catch (Exception e)
281 {
282 MainLog.Instance.Warn("Config.cs:InitConfig() - Exception occured");
283 MainLog.Instance.Warn(e.ToString());
284 }
285
286 MainLog.Instance.Verbose("Sim settings loaded:");
287 MainLog.Instance.Verbose("UUID: " + this.SimUUID.ToStringHyphenated());
288 MainLog.Instance.Verbose("Name: " + this.RegionName);
289 MainLog.Instance.Verbose("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]");
290 MainLog.Instance.Verbose("Region Handle: " + this.RegionHandle.ToString());
291 MainLog.Instance.Verbose("Listening on IP end point: " + m_internalEndPoint.ToString() );
292 MainLog.Instance.Verbose("Sandbox Mode? " + isSandbox.ToString());
293
294 }
295
296 private uint GetInt(IGenericConfig configData, string p, int p_3, string p_4)
297 {
298 throw new Exception("The method or operation is not implemented.");
299 }
300
301 private string GetString(IGenericConfig configData, string attrName, string defaultvalue, string prompt)
302 {
303 string s = configData.GetAttribute(attrName);
304
305 if (String.IsNullOrEmpty( s ))
306 {
307 s = MainLog.Instance.CmdPrompt(prompt, defaultvalue);
308 configData.SetAttribute(attrName, s );
309 }
310 return s;
311 }
312
313 private IPAddress GetIPAddress(IGenericConfig configData, string attrName, string defaultvalue, string prompt)
314 {
315 string addressStr = configData.GetAttribute(attrName);
316
317 IPAddress address;
318
319 if (!IPAddress.TryParse(addressStr, out address))
320 {
321 address = MainLog.Instance.CmdPromptIPAddress(prompt, defaultvalue);
322 configData.SetAttribute(attrName, address.ToString());
323 }
324 return address;
325 }
326
327 private int GetIPPort(IGenericConfig configData, string attrName, string defaultvalue, string prompt)
328 {
329 string portStr = configData.GetAttribute(attrName);
330
331 int port;
332
333 if (!int.TryParse(portStr, out port))
334 {
335 port = MainLog.Instance.CmdPromptIPPort(prompt, defaultvalue);
336 configData.SetAttribute(attrName, port.ToString());
337 }
338
339 return port;
340 }
341 }
342}
diff --git a/OpenSim/Framework/General/Types/UUID.cs b/OpenSim/Framework/General/Types/UUID.cs
new file mode 100644
index 0000000..9cde18e
--- /dev/null
+++ b/OpenSim/Framework/General/Types/UUID.cs
@@ -0,0 +1,127 @@
1using System;
2using libsecondlife;
3
4namespace OpenSim.Framework.Types
5{
6 class UUID
7 {
8 public LLUUID llUUID;
9
10 public UUID(string uuid)
11 {
12 llUUID = new LLUUID(uuid);
13 }
14
15 public UUID(byte[] uuid)
16 {
17 llUUID = new LLUUID(uuid, 0);
18 }
19
20 public UUID(byte[] uuid, int offset)
21 {
22 llUUID = new LLUUID(uuid, offset);
23 }
24
25 public UUID()
26 {
27 llUUID = LLUUID.Zero;
28 }
29
30 public UUID(ulong uuid)
31 {
32 llUUID = new LLUUID(uuid);
33 }
34
35 public UUID(UInt32 first, UInt32 second, UInt32 third, UInt32 fourth)
36 {
37 byte[] uuid = new byte[16];
38
39 byte[] n = BitConverter.GetBytes(first);
40 n.CopyTo(uuid, 0);
41 n = BitConverter.GetBytes(second);
42 n.CopyTo(uuid, 4);
43 n = BitConverter.GetBytes(third);
44 n.CopyTo(uuid, 8);
45 n = BitConverter.GetBytes(fourth);
46 n.CopyTo(uuid, 12);
47
48 llUUID = new LLUUID(uuid,0);
49 }
50
51 public override string ToString()
52 {
53 return llUUID.ToString();
54 }
55
56 public string ToStringHyphenated()
57 {
58 return llUUID.ToStringHyphenated();
59 }
60
61 public byte[] GetBytes()
62 {
63 return llUUID.GetBytes();
64 }
65
66 public UInt32[] GetInts()
67 {
68 UInt32[] ints = new UInt32[4];
69 ints[0] = BitConverter.ToUInt32(llUUID.Data, 0);
70 ints[1] = BitConverter.ToUInt32(llUUID.Data, 4);
71 ints[2] = BitConverter.ToUInt32(llUUID.Data, 8);
72 ints[3] = BitConverter.ToUInt32(llUUID.Data, 12);
73
74 return ints;
75 }
76
77 public LLUUID GetLLUUID()
78 {
79 return llUUID;
80 }
81
82 public uint CRC()
83 {
84 return llUUID.CRC();
85 }
86
87 public override int GetHashCode()
88 {
89 return llUUID.GetHashCode();
90 }
91
92 public void Combine(UUID other)
93 {
94 llUUID.Combine(other.GetLLUUID());
95 }
96
97 public void Combine(LLUUID other)
98 {
99 llUUID.Combine(other);
100 }
101
102 public override bool Equals(Object other)
103 {
104 return llUUID.Equals(other);
105 }
106
107 public static bool operator ==(UUID a, UUID b)
108 {
109 return a.llUUID.Equals(b.GetLLUUID());
110 }
111
112 public static bool operator !=(UUID a, UUID b)
113 {
114 return !a.llUUID.Equals(b.GetLLUUID());
115 }
116
117 public static bool operator ==(UUID a, LLUUID b)
118 {
119 return a.Equals(b);
120 }
121
122 public static bool operator !=(UUID a, LLUUID b)
123 {
124 return !a.Equals(b);
125 }
126 }
127}
diff --git a/OpenSim/Framework/General/UserProfile.cs b/OpenSim/Framework/General/UserProfile.cs
new file mode 100644
index 0000000..243208a
--- /dev/null
+++ b/OpenSim/Framework/General/UserProfile.cs
@@ -0,0 +1,87 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 System.Security.Cryptography;
30using libsecondlife;
31using OpenSim.Framework.Inventory;
32
33namespace OpenSim.Framework.User
34{
35 public class UserProfile
36 {
37
38 public string firstname;
39 public string lastname;
40 public ulong homeregionhandle;
41 public LLVector3 homepos;
42 public LLVector3 homelookat;
43
44 public bool IsGridGod = false;
45 public bool IsLocal = true; // will be used in future for visitors from foreign grids
46 public string AssetURL;
47 public string MD5passwd;
48
49 public LLUUID CurrentSessionID;
50 public LLUUID CurrentSecureSessionID;
51 public LLUUID UUID;
52 public Dictionary<LLUUID, uint> Circuits = new Dictionary<LLUUID, uint>(); // tracks circuit codes
53
54 public AgentInventory Inventory;
55
56 public UserProfile()
57 {
58 Circuits = new Dictionary<LLUUID, uint>();
59 Inventory = new AgentInventory();
60 homeregionhandle = Helpers.UIntsToLong((1000 * 256), (1000 * 256));
61 homepos = new LLVector3();
62 homelookat = new LLVector3();
63 }
64
65 public void InitSessionData()
66 {
67 RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
68
69 byte[] randDataS = new byte[16];
70 byte[] randDataSS = new byte[16];
71
72 rand.GetBytes(randDataS);
73 rand.GetBytes(randDataSS);
74
75 CurrentSecureSessionID = new LLUUID(randDataSS,0);
76 CurrentSessionID = new LLUUID(randDataS,0);
77
78 }
79
80 public void AddSimCircuit(uint circuitCode, LLUUID regionUUID)
81 {
82 if (this.Circuits.ContainsKey(regionUUID) == false)
83 this.Circuits.Add(regionUUID, circuitCode);
84 }
85
86 }
87}
diff --git a/OpenSim/Framework/General/Util.cs b/OpenSim/Framework/General/Util.cs
new file mode 100644
index 0000000..13e3af2
--- /dev/null
+++ b/OpenSim/Framework/General/Util.cs
@@ -0,0 +1,184 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Security.Cryptography;
30using System.Text;
31using libsecondlife;
32
33namespace OpenSim.Framework.Utilities
34{
35 public class Util
36 {
37 private static Random randomClass = new Random();
38 private static uint nextXferID = 5000;
39 private static object XferLock = new object();
40
41 public static ulong UIntsToLong(uint X, uint Y)
42 {
43 return Helpers.UIntsToLong(X, Y);
44 }
45
46 public static Random RandomClass
47 {
48 get
49 {
50 return randomClass;
51 }
52 }
53
54 public static uint GetNextXferID()
55 {
56 uint id = 0;
57 lock(XferLock)
58 {
59 id = nextXferID;
60 nextXferID++;
61 }
62 return id;
63 }
64
65 public static int UnixTimeSinceEpoch()
66 {
67 TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));
68 int timestamp = (int)t.TotalSeconds;
69 return timestamp;
70 }
71
72 public static string Md5Hash(string pass)
73 {
74 MD5 md5 = MD5CryptoServiceProvider.Create();
75 byte[] dataMd5 = md5.ComputeHash(Encoding.Default.GetBytes(pass));
76 StringBuilder sb = new StringBuilder();
77 for (int i = 0; i < dataMd5.Length; i++)
78 sb.AppendFormat("{0:x2}", dataMd5[i]);
79 return sb.ToString();
80 }
81
82 public static string GetRandomCapsPath()
83 {
84 LLUUID caps = LLUUID.Random();
85 string capsPath = caps.ToStringHyphenated();
86 capsPath = capsPath.Remove(capsPath.Length - 4, 4);
87 return capsPath;
88 }
89
90 //public static int fast_distance2d(int x, int y)
91 //{
92 // x = System.Math.Abs(x);
93 // y = System.Math.Abs(y);
94
95 // int min = System.Math.Min(x, y);
96
97 // return (x + y - (min >> 1) - (min >> 2) + (min >> 4));
98 //}
99
100 public static string FieldToString(byte[] bytes)
101 {
102 return FieldToString(bytes, String.Empty);
103 }
104
105 /// <summary>
106 /// Convert a variable length field (byte array) to a string, with a
107 /// field name prepended to each line of the output
108 /// </summary>
109 /// <remarks>If the byte array has unprintable characters in it, a
110 /// hex dump will be put in the string instead</remarks>
111 /// <param name="bytes">The byte array to convert to a string</param>
112 /// <param name="fieldName">A field name to prepend to each line of output</param>
113 /// <returns>An ASCII string or a string containing a hex dump, minus
114 /// the null terminator</returns>
115 public static string FieldToString(byte[] bytes, string fieldName)
116 {
117 // Check for a common case
118 if (bytes.Length == 0) return String.Empty;
119
120 StringBuilder output = new StringBuilder();
121 bool printable = true;
122
123 for (int i = 0; i < bytes.Length; ++i)
124 {
125 // Check if there are any unprintable characters in the array
126 if ((bytes[i] < 0x20 || bytes[i] > 0x7E) && bytes[i] != 0x09
127 && bytes[i] != 0x0D && bytes[i] != 0x0A && bytes[i] != 0x00)
128 {
129 printable = false;
130 break;
131 }
132 }
133
134 if (printable)
135 {
136 if (fieldName.Length > 0)
137 {
138 output.Append(fieldName);
139 output.Append(": ");
140 }
141
142 if (bytes[bytes.Length - 1] == 0x00)
143 output.Append(UTF8Encoding.UTF8.GetString(bytes, 0, bytes.Length - 1));
144 else
145 output.Append(UTF8Encoding.UTF8.GetString(bytes));
146 }
147 else
148 {
149 for (int i = 0; i < bytes.Length; i += 16)
150 {
151 if (i != 0)
152 output.Append(Environment.NewLine);
153 if (fieldName.Length > 0)
154 {
155 output.Append(fieldName);
156 output.Append(": ");
157 }
158
159 for (int j = 0; j < 16; j++)
160 {
161 if ((i + j) < bytes.Length)
162 output.Append(String.Format("{0:X2} ", bytes[i + j]));
163 else
164 output.Append(" ");
165 }
166
167 for (int j = 0; j < 16 && (i + j) < bytes.Length; j++)
168 {
169 if (bytes[i + j] >= 0x20 && bytes[i + j] < 0x7E)
170 output.Append((char)bytes[i + j]);
171 else
172 output.Append(".");
173 }
174 }
175 }
176
177 return output.ToString();
178 }
179 public Util()
180 {
181
182 }
183 }
184}
diff --git a/OpenSim/Framework/GenericConfig/Xml/Properties/AssemblyInfo.cs b/OpenSim/Framework/GenericConfig/Xml/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..fcffd67
--- /dev/null
+++ b/OpenSim/Framework/GenericConfig/Xml/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.GenericConfig")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenSim.GenericConfig")]
11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("285a3047-f165-46c8-8767-b51428738a09")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Framework/GenericConfig/Xml/XmlConfig.cs b/OpenSim/Framework/GenericConfig/Xml/XmlConfig.cs
new file mode 100644
index 0000000..7fa085d
--- /dev/null
+++ b/OpenSim/Framework/GenericConfig/Xml/XmlConfig.cs
@@ -0,0 +1,122 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.IO;
30using System.Xml;
31using OpenSim.Framework.Interfaces;
32
33namespace OpenSim.GenericConfig
34{
35 public class XmlConfig : IGenericConfig
36 {
37 private XmlDocument doc;
38 private XmlNode rootNode;
39 private XmlNode configNode;
40 private string fileName;
41 private bool createdFile = false;
42
43 public XmlConfig(string filename)
44 {
45 fileName = filename;
46 }
47
48 public void LoadData()
49 {
50 doc = new XmlDocument();
51
52 if (File.Exists(fileName))
53 {
54 XmlTextReader reader = new XmlTextReader(fileName);
55 reader.WhitespaceHandling = WhitespaceHandling.None;
56 doc.Load(reader);
57 reader.Close();
58 }
59 else
60 {
61 createdFile = true;
62 rootNode = doc.CreateNode(XmlNodeType.Element, "Root", "");
63 doc.AppendChild(rootNode);
64 configNode = doc.CreateNode(XmlNodeType.Element, "Config", "");
65 rootNode.AppendChild(configNode);
66 }
67
68
69 rootNode = doc.FirstChild;
70 if (rootNode.Name != "Root")
71 throw new Exception("Error: Invalid .xml File. Missing <Root>");
72
73 configNode = rootNode.FirstChild;
74 if (configNode.Name != "Config")
75 throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>");
76
77 if (createdFile)
78 {
79 this.Commit();
80 }
81 }
82
83 public string GetAttribute(string attributeName)
84 {
85 string result = "";
86 if (configNode.Attributes[attributeName] != null)
87 {
88 result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value;
89 }
90 return result;
91 }
92
93 public bool SetAttribute(string attributeName, string attributeValue)
94 {
95 if (configNode.Attributes[attributeName] != null)
96 {
97 ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue;
98 }
99 else
100 {
101 XmlAttribute attri;
102 attri = doc.CreateAttribute(attributeName);
103 attri.Value = attributeValue;
104 configNode.Attributes.Append(attri);
105 }
106 return true;
107 }
108
109 public void Commit()
110 {
111 doc.Save(fileName);
112 }
113
114 public void Close()
115 {
116 configNode = null;
117 rootNode = null;
118 doc = null;
119 }
120
121 }
122}
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs
new file mode 100644
index 0000000..f790477
--- /dev/null
+++ b/OpenSim/Framework/Servers/BaseHttpServer.cs
@@ -0,0 +1,224 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.IO;
32using System.Net;
33using System.Text;
34using System.Text.RegularExpressions;
35using System.Threading;
36using Nwc.XmlRpc;
37using OpenSim.Framework.Console;
38
39namespace OpenSim.Framework.Servers
40{
41 public class BaseHttpServer
42 {
43 protected Thread m_workerThread;
44 protected HttpListener m_httpListener;
45 protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>();
46 protected Dictionary<string, IStreamHandler> m_streamHandlers = new Dictionary<string, IStreamHandler>();
47 protected int m_port;
48 protected bool m_firstcaps = true;
49
50 public BaseHttpServer(int port)
51 {
52 m_port = port;
53 }
54
55 public void AddStreamHandler( IStreamHandler handler)
56 {
57 string httpMethod = handler.HttpMethod;
58 string path = handler.Path;
59
60 string handlerKey = GetHandlerKey(httpMethod, path);
61 m_streamHandlers.Add(handlerKey, handler);
62 }
63
64 private static string GetHandlerKey(string httpMethod, string path)
65 {
66 return httpMethod + ":" + path;
67 }
68
69 public bool AddXmlRPCHandler(string method, XmlRpcMethod handler)
70 {
71 if (!this.m_rpcHandlers.ContainsKey(method))
72 {
73 this.m_rpcHandlers.Add(method, handler);
74 return true;
75 }
76
77 //must already have a handler for that path so return false
78 return false;
79 }
80
81
82 public virtual void HandleRequest(Object stateinfo)
83 {
84 HttpListenerContext context = (HttpListenerContext)stateinfo;
85
86 HttpListenerRequest request = context.Request;
87 HttpListenerResponse response = context.Response;
88
89 response.KeepAlive = false;
90 response.SendChunked = false;
91
92 string path = request.RawUrl;
93 string handlerKey = GetHandlerKey( request.HttpMethod, path );
94
95 IStreamHandler streamHandler;
96
97 if (TryGetStreamHandler( handlerKey, out streamHandler))
98 {
99 byte[] buffer = streamHandler.Handle(path, request.InputStream);
100 request.InputStream.Close();
101
102 response.ContentType = streamHandler.ContentType;
103 response.ContentLength64 = buffer.LongLength;
104 response.OutputStream.Write(buffer, 0, buffer.Length);
105 response.OutputStream.Close();
106 }
107 else
108 {
109 HandleXmlRpcRequests(request, response);
110 }
111 }
112
113 private bool TryGetStreamHandler(string handlerKey, out IStreamHandler streamHandler)
114 {
115 string bestMatch = null;
116
117 foreach (string pattern in m_streamHandlers.Keys)
118 {
119 if (handlerKey.StartsWith(pattern))
120 {
121 if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length)
122 {
123 bestMatch = pattern;
124 }
125 }
126 }
127
128 if (String.IsNullOrEmpty(bestMatch))
129 {
130 streamHandler = null;
131 return false;
132 }
133 else
134 {
135 streamHandler = m_streamHandlers[bestMatch];
136 return true;
137 }
138 }
139
140 private void HandleXmlRpcRequests(HttpListenerRequest request, HttpListenerResponse response)
141 {
142 Stream requestStream = request.InputStream;
143
144 Encoding encoding = Encoding.UTF8;
145 StreamReader reader = new StreamReader(requestStream, encoding);
146
147 string requestBody = reader.ReadToEnd();
148 reader.Close();
149 requestStream.Close();
150
151 XmlRpcRequest xmlRprcRequest = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody);
152
153 string methodName = xmlRprcRequest.MethodName;
154
155 XmlRpcResponse xmlRpcResponse;
156
157 XmlRpcMethod method;
158 if (this.m_rpcHandlers.TryGetValue(methodName, out method))
159 {
160 xmlRpcResponse = method(xmlRprcRequest);
161 }
162 else
163 {
164 xmlRpcResponse = new XmlRpcResponse();
165 Hashtable unknownMethodError = new Hashtable();
166 unknownMethodError["reason"] = "XmlRequest"; ;
167 unknownMethodError["message"] = "Unknown Rpc Request ["+methodName+"]";
168 unknownMethodError["login"] = "false";
169 xmlRpcResponse.Value = unknownMethodError;
170 }
171
172 response.AddHeader("Content-type", "text/xml");
173
174 string responseString = XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse);
175
176 byte[] buffer = Encoding.UTF8.GetBytes(responseString);
177
178 response.SendChunked = false;
179 response.ContentLength64 = buffer.Length;
180 response.ContentEncoding = Encoding.UTF8;
181
182 response.OutputStream.Write(buffer, 0, buffer.Length);
183 response.OutputStream.Close();
184 }
185
186 public void Start()
187 {
188 MainLog.Instance.WriteLine(LogPriority.LOW, "BaseHttpServer.cs: Starting up HTTP Server");
189
190 m_workerThread = new Thread(new ThreadStart(StartHTTP));
191 m_workerThread.IsBackground = true;
192 m_workerThread.Start();
193 }
194
195 private void StartHTTP()
196 {
197 try
198 {
199 MainLog.Instance.WriteLine(LogPriority.LOW, "BaseHttpServer.cs: StartHTTP() - Spawned main thread OK");
200 m_httpListener = new HttpListener();
201
202 m_httpListener.Prefixes.Add("http://+:" + m_port + "/");
203 m_httpListener.Start();
204
205 HttpListenerContext context;
206 while (true)
207 {
208 context = m_httpListener.GetContext();
209 ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
210 }
211 }
212 catch (Exception e)
213 {
214 MainLog.Instance.WriteLine(LogPriority.MEDIUM, e.Message);
215 }
216 }
217
218
219 public void RemoveStreamHandler(string httpMethod, string path)
220 {
221 m_streamHandlers.Remove(GetHandlerKey(httpMethod, path));
222 }
223 }
224}
diff --git a/OpenSim/Framework/Servers/BaseStreamHandler.cs b/OpenSim/Framework/Servers/BaseStreamHandler.cs
new file mode 100644
index 0000000..0d9c674
--- /dev/null
+++ b/OpenSim/Framework/Servers/BaseStreamHandler.cs
@@ -0,0 +1,40 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.IO;
5
6namespace OpenSim.Framework.Servers
7{
8 public abstract class BaseStreamHandler : IStreamHandler
9 {
10 virtual public string ContentType
11 {
12 get { return "application/xml"; }
13 }
14
15 private string m_httpMethod;
16 virtual public string HttpMethod
17 {
18 get { return m_httpMethod; }
19 }
20
21 private string m_path;
22 virtual public string Path
23 {
24 get { return m_path; }
25 }
26
27 protected string GetParam( string path )
28 {
29 return path.Substring( m_path.Length );
30 }
31
32 public abstract byte[] Handle(string path, Stream request);
33
34 protected BaseStreamHandler(string httpMethod, string path)
35 {
36 m_httpMethod = httpMethod;
37 m_path = path;
38 }
39 }
40}
diff --git a/OpenSim/Framework/Servers/CheckSumServer.cs b/OpenSim/Framework/Servers/CheckSumServer.cs
new file mode 100644
index 0000000..89ec095
--- /dev/null
+++ b/OpenSim/Framework/Servers/CheckSumServer.cs
@@ -0,0 +1,127 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28namespace OpenSim.Framework.Servers
29{/*
30 public class CheckSumServer : UDPServerBase
31 {
32 //protected ConsoleBase m_log;
33
34 public CheckSumServer(int port)
35 : base(port)
36 {
37 }
38
39 protected override void OnReceivedData(IAsyncResult result)
40 {
41 ipeSender = new IPEndPoint(IPAddress.Any, 0);
42 epSender = (EndPoint)ipeSender;
43 Packet packet = null;
44 int numBytes = Server.EndReceiveFrom(result, ref epSender);
45 int packetEnd = numBytes - 1;
46
47 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
48
49 if (packet.Type == PacketType.SecuredTemplateChecksumRequest)
50 {
51 SecuredTemplateChecksumRequestPacket checksum = (SecuredTemplateChecksumRequestPacket)packet;
52 TemplateChecksumReplyPacket checkreply = new TemplateChecksumReplyPacket();
53 checkreply.DataBlock.Checksum = 3220703154;//180572585;
54 checkreply.DataBlock.Flags = 0;
55 checkreply.DataBlock.MajorVersion = 1;
56 checkreply.DataBlock.MinorVersion = 15;
57 checkreply.DataBlock.PatchVersion = 0;
58 checkreply.DataBlock.ServerVersion = 0;
59 checkreply.TokenBlock.Token = checksum.TokenBlock.Token;
60 this.SendPacket(checkreply, epSender);
61
62 /*
63 //if we wanted to echo the the checksum/ version from the client (so that any client worked)
64 SecuredTemplateChecksumRequestPacket checkrequest = new SecuredTemplateChecksumRequestPacket();
65 checkrequest.TokenBlock.Token = checksum.TokenBlock.Token;
66 this.SendPacket(checkrequest, epSender);
67
68 }
69 else if (packet.Type == PacketType.TemplateChecksumReply)
70 {
71 //echo back the client checksum reply (Hegemon's method)
72 TemplateChecksumReplyPacket checksum2 = (TemplateChecksumReplyPacket)packet;
73 TemplateChecksumReplyPacket checkreply2 = new TemplateChecksumReplyPacket();
74 checkreply2.DataBlock.Checksum = checksum2.DataBlock.Checksum;
75 checkreply2.DataBlock.Flags = checksum2.DataBlock.Flags;
76 checkreply2.DataBlock.MajorVersion = checksum2.DataBlock.MajorVersion;
77 checkreply2.DataBlock.MinorVersion = checksum2.DataBlock.MinorVersion;
78 checkreply2.DataBlock.PatchVersion = checksum2.DataBlock.PatchVersion;
79 checkreply2.DataBlock.ServerVersion = checksum2.DataBlock.ServerVersion;
80 checkreply2.TokenBlock.Token = checksum2.TokenBlock.Token;
81 this.SendPacket(checkreply2, epSender);
82 }
83 else
84 {
85 }
86
87 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
88 }
89
90 private void SendPacket(Packet Pack, EndPoint endp)
91 {
92 if (!Pack.Header.Resent)
93 {
94 Pack.Header.Sequence = 1;
95 }
96
97 byte[] ZeroOutBuffer = new byte[4096];
98 byte[] sendbuffer;
99 sendbuffer = Pack.ToBytes();
100
101 try
102 {
103 if (Pack.Header.Zerocoded)
104 {
105 int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
106 this.SendPackTo(ZeroOutBuffer, packetsize, SocketFlags.None, endp);
107 }
108 else
109 {
110 this.SendPackTo(sendbuffer, sendbuffer.Length, SocketFlags.None, endp);
111 }
112 }
113 catch (Exception)
114 {
115 OpenSim.Framework.Console.MainLog.Instance.Warn("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection ");
116
117 }
118 }
119
120 private void SendPackTo(byte[] buffer, int size, SocketFlags flags, EndPoint endp)
121 {
122 this.Server.SendTo(buffer, size, flags, endp);
123 }
124 * }
125 */
126
127} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/IStreamHandler.cs b/OpenSim/Framework/Servers/IStreamHandler.cs
new file mode 100644
index 0000000..6cab40d
--- /dev/null
+++ b/OpenSim/Framework/Servers/IStreamHandler.cs
@@ -0,0 +1,22 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.IO;
5
6namespace OpenSim.Framework.Servers
7{
8 public interface IStreamHandler
9 {
10 // Handle request stream, return byte array
11 byte[] Handle(string path, Stream request );
12
13 // Return response content type
14 string ContentType { get; }
15
16 // Return required http method
17 string HttpMethod { get;}
18
19 // Return path
20 string Path { get; }
21 }
22}
diff --git a/OpenSim/Framework/Servers/RestMethod.cs b/OpenSim/Framework/Servers/RestMethod.cs
new file mode 100644
index 0000000..c6cb230
--- /dev/null
+++ b/OpenSim/Framework/Servers/RestMethod.cs
@@ -0,0 +1,31 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28namespace OpenSim.Framework.Servers
29{
30 public delegate string RestMethod( string request, string path, string param );
31}
diff --git a/OpenSim/Framework/Servers/RestStreamHandler.cs b/OpenSim/Framework/Servers/RestStreamHandler.cs
new file mode 100644
index 0000000..1b3b41c
--- /dev/null
+++ b/OpenSim/Framework/Servers/RestStreamHandler.cs
@@ -0,0 +1,31 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.IO;
5
6namespace OpenSim.Framework.Servers
7{
8 public class RestStreamHandler : BaseStreamHandler
9 {
10 RestMethod m_restMethod;
11
12 override public byte[] Handle(string path, Stream request )
13 {
14 Encoding encoding = Encoding.UTF8;
15 StreamReader streamReader = new StreamReader(request, encoding);
16
17 string requestBody = streamReader.ReadToEnd();
18 streamReader.Close();
19
20 string param = GetParam(path);
21 string responseString = m_restMethod(requestBody, path, param );
22
23 return Encoding.UTF8.GetBytes(responseString);
24 }
25
26 public RestStreamHandler(string httpMethod, string path, RestMethod restMethod) : base( httpMethod, path )
27 {
28 m_restMethod = restMethod;
29 }
30 }
31}
diff --git a/OpenSim/Framework/Servers/UDPServerBase.cs b/OpenSim/Framework/Servers/UDPServerBase.cs
new file mode 100644
index 0000000..508eb9d
--- /dev/null
+++ b/OpenSim/Framework/Servers/UDPServerBase.cs
@@ -0,0 +1,87 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Net;
30using System.Net.Sockets;
31using libsecondlife.Packets;
32
33namespace OpenSim.Framework.Servers
34{
35 public class UDPServerBase
36 {
37 public Socket Server;
38 protected IPEndPoint ServerIncoming;
39 protected byte[] RecvBuffer = new byte[4096];
40 protected byte[] ZeroBuffer = new byte[8192];
41 protected IPEndPoint ipeSender;
42 protected EndPoint epSender;
43 protected AsyncCallback ReceivedData;
44 protected int listenPort;
45
46 public UDPServerBase(int port)
47 {
48 listenPort = port;
49 }
50
51 protected virtual void OnReceivedData(IAsyncResult result)
52 {
53 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
54 epSender = (EndPoint)ipeSender;
55 Packet packet = null;
56 int numBytes = Server.EndReceiveFrom(result, ref epSender);
57 int packetEnd = numBytes - 1;
58
59 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
60
61 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
62 }
63
64 protected virtual void AddNewClient(Packet packet)
65 {
66 }
67
68 public virtual void ServerListener()
69 {
70
71 ServerIncoming = new IPEndPoint(IPAddress.Parse("0.0.0.0"), listenPort);
72 Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
73 Server.Bind(ServerIncoming);
74
75 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
76 epSender = (EndPoint)ipeSender;
77 ReceivedData = new AsyncCallback(this.OnReceivedData);
78 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
79 }
80
81 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
82 {
83
84 }
85 }
86}
87
diff --git a/OpenSim/Framework/Servers/XmlRpcMethod.cs b/OpenSim/Framework/Servers/XmlRpcMethod.cs
new file mode 100644
index 0000000..b76ac51
--- /dev/null
+++ b/OpenSim/Framework/Servers/XmlRpcMethod.cs
@@ -0,0 +1,33 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 Nwc.XmlRpc;
29
30namespace OpenSim.Framework.Servers
31{
32 public delegate XmlRpcResponse XmlRpcMethod( XmlRpcRequest request );
33}
diff --git a/OpenSim/Framework/UserManager/LoginResponse.cs b/OpenSim/Framework/UserManager/LoginResponse.cs
new file mode 100644
index 0000000..abcbd48
--- /dev/null
+++ b/OpenSim/Framework/UserManager/LoginResponse.cs
@@ -0,0 +1,643 @@
1using System;
2using System.Collections;
3using libsecondlife;
4using Nwc.XmlRpc;
5using OpenSim.Framework.Console;
6
7namespace OpenSim.Framework.UserManagement
8{
9
10 /// <summary>
11 /// A temp class to handle login response.
12 /// Should make use of UserProfileManager where possible.
13 /// </summary>
14
15 public class LoginResponse
16 {
17 private Hashtable loginFlagsHash;
18 private Hashtable globalTexturesHash;
19 private Hashtable loginError;
20 private Hashtable eventCategoriesHash;
21 private Hashtable uiConfigHash;
22 private Hashtable classifiedCategoriesHash;
23
24 private ArrayList loginFlags;
25 private ArrayList globalTextures;
26 private ArrayList eventCategories;
27 private ArrayList uiConfig;
28 private ArrayList classifiedCategories;
29 private ArrayList inventoryRoot;
30 private ArrayList initialOutfit;
31 private ArrayList agentInventory;
32
33 private UserInfo userProfile;
34
35 private LLUUID agentID;
36 private LLUUID sessionID;
37 private LLUUID secureSessionID;
38
39 // Login Flags
40 private string dst;
41 private string stipendSinceLogin;
42 private string gendered;
43 private string everLoggedIn;
44 private string login;
45 private int simPort;
46 private string simAddress;
47 private string agentAccess;
48 private Int32 circuitCode;
49 private uint regionX;
50 private uint regionY;
51
52 // Login
53 private string firstname;
54 private string lastname;
55
56 // Global Textures
57 private string sunTexture;
58 private string cloudTexture;
59 private string moonTexture;
60
61 // Error Flags
62 private string errorReason;
63 private string errorMessage;
64
65 // Response
66 private XmlRpcResponse xmlRpcResponse;
67 private XmlRpcResponse defaultXmlRpcResponse;
68
69 private string welcomeMessage;
70 private string startLocation;
71 private string allowFirstLife;
72 private string home;
73 private string seedCapability;
74 private string lookAt;
75
76 public LoginResponse()
77 {
78 this.loginFlags = new ArrayList();
79 this.globalTextures = new ArrayList();
80 this.eventCategories = new ArrayList();
81 this.uiConfig = new ArrayList();
82 this.classifiedCategories = new ArrayList();
83
84 this.loginError = new Hashtable();
85 this.eventCategoriesHash = new Hashtable();
86 this.classifiedCategoriesHash = new Hashtable();
87 this.uiConfigHash = new Hashtable();
88
89 this.defaultXmlRpcResponse = new XmlRpcResponse();
90 this.userProfile = new UserInfo();
91 this.inventoryRoot = new ArrayList();
92 this.initialOutfit = new ArrayList();
93 this.agentInventory = new ArrayList();
94
95 this.xmlRpcResponse = new XmlRpcResponse();
96 this.defaultXmlRpcResponse = new XmlRpcResponse();
97
98 this.SetDefaultValues();
99 } // LoginServer
100
101 public void SetDefaultValues()
102 {
103 this.DST = "N";
104 this.StipendSinceLogin = "N";
105 this.Gendered = "Y";
106 this.EverLoggedIn = "Y";
107 this.login = "false";
108 this.firstname = "Test";
109 this.lastname = "User";
110 this.agentAccess = "M";
111 this.startLocation = "last";
112 this.allowFirstLife = "Y";
113
114 this.SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271";
115 this.CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
116 this.MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
117
118 this.ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock.";
119 this.ErrorReason = "key";
120 this.welcomeMessage = "Welcome to OpenSim!";
121 this.seedCapability = "";
122 this.home = "{'region_handle':[r" + (1000 * 256).ToString() + ",r" + (1000 * 256).ToString() + "], 'position':[r" + this.userProfile.homepos.X.ToString() + ",r" + this.userProfile.homepos.Y.ToString() + ",r" + this.userProfile.homepos.Z.ToString() + "], 'look_at':[r" + this.userProfile.homelookat.X.ToString() + ",r" + this.userProfile.homelookat.Y.ToString() + ",r" + this.userProfile.homelookat.Z.ToString() + "]}";
123 this.lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]";
124 this.RegionX = (uint)255232;
125 this.RegionY = (uint)254976;
126
127 // Classifieds;
128 this.AddClassifiedCategory((Int32)1, "Shopping");
129 this.AddClassifiedCategory((Int32)2, "Land Rental");
130 this.AddClassifiedCategory((Int32)3, "Property Rental");
131 this.AddClassifiedCategory((Int32)4, "Special Attraction");
132 this.AddClassifiedCategory((Int32)5, "New Products");
133 this.AddClassifiedCategory((Int32)6, "Employment");
134 this.AddClassifiedCategory((Int32)7, "Wanted");
135 this.AddClassifiedCategory((Int32)8, "Service");
136 this.AddClassifiedCategory((Int32)9, "Personal");
137
138
139 this.SessionID = LLUUID.Random();
140 this.SecureSessionID = LLUUID.Random();
141 this.AgentID = LLUUID.Random();
142
143 Hashtable InitialOutfitHash = new Hashtable();
144 InitialOutfitHash["folder_name"] = "Nightclub Female";
145 InitialOutfitHash["gender"] = "female";
146 this.initialOutfit.Add(InitialOutfitHash);
147
148
149 } // SetDefaultValues
150
151 #region Login Failure Methods
152 public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login)
153 {
154 // Overwrite any default values;
155 this.xmlRpcResponse = new XmlRpcResponse();
156
157 // Ensure Login Failed message/reason;
158 this.ErrorMessage = message;
159 this.ErrorReason = reason;
160
161 this.loginError["reason"] = this.ErrorReason;
162 this.loginError["message"] = this.ErrorMessage;
163 this.loginError["login"] = login;
164 this.xmlRpcResponse.Value = this.loginError;
165 return (this.xmlRpcResponse);
166 } // GenerateResponse
167
168 public XmlRpcResponse CreateFailedResponse()
169 {
170 return (this.CreateLoginFailedResponse());
171 } // CreateErrorConnectingToGridResponse()
172
173 public XmlRpcResponse CreateLoginFailedResponse()
174 {
175 return (this.GenerateFailureResponse("key", "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", "false"));
176 } // LoginFailedResponse
177
178 public XmlRpcResponse CreateAlreadyLoggedInResponse()
179 {
180 return (this.GenerateFailureResponse("presence", "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner", "false"));
181 } // CreateAlreadyLoggedInResponse()
182
183 public XmlRpcResponse CreateDeadRegionResponse()
184 {
185 return (this.GenerateFailureResponse("key", "The region you are attempting to log into is not responding. Please select another region and try again.", "false"));
186 }
187
188 public XmlRpcResponse CreateGridErrorResponse()
189 {
190 return (this.GenerateFailureResponse("key", "Error connecting to grid. Could not percieve credentials from login XML.", "false"));
191 }
192
193 #endregion
194
195 public XmlRpcResponse ToXmlRpcResponse()
196 {
197 try
198 {
199
200 Hashtable responseData = new Hashtable();
201
202 this.loginFlagsHash = new Hashtable();
203 this.loginFlagsHash["daylight_savings"] = this.DST;
204 this.loginFlagsHash["stipend_since_login"] = this.StipendSinceLogin;
205 this.loginFlagsHash["gendered"] = this.Gendered;
206 this.loginFlagsHash["ever_logged_in"] = this.EverLoggedIn;
207 this.loginFlags.Add(this.loginFlagsHash);
208
209 responseData["first_name"] = this.Firstname;
210 responseData["last_name"] = this.Lastname;
211 responseData["agent_access"] = this.agentAccess;
212
213 this.globalTexturesHash = new Hashtable();
214 this.globalTexturesHash["sun_texture_id"] = this.SunTexture;
215 this.globalTexturesHash["cloud_texture_id"] = this.CloudTexture;
216 this.globalTexturesHash["moon_texture_id"] = this.MoonTexture;
217 this.globalTextures.Add(this.globalTexturesHash);
218 this.eventCategories.Add(this.eventCategoriesHash);
219
220 this.AddToUIConfig("allow_first_life", this.allowFirstLife);
221 this.uiConfig.Add(this.uiConfigHash);
222
223 responseData["sim_port"] =(Int32) this.SimPort;
224 responseData["sim_ip"] = this.SimAddress;
225
226 MainLog.Instance.Warn("SIM IP: " + responseData["sim_ip"] + "; SIM PORT: " + responseData["sim_port"]);
227
228 responseData["agent_id"] = this.AgentID.ToStringHyphenated();
229 responseData["session_id"] = this.SessionID.ToStringHyphenated();
230 responseData["secure_session_id"] = this.SecureSessionID.ToStringHyphenated();
231 responseData["circuit_code"] = this.CircuitCode;
232 responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
233 responseData["login-flags"] = this.loginFlags;
234 responseData["global-textures"] = this.globalTextures;
235 responseData["seed_capability"] = this.seedCapability;
236
237 responseData["event_categories"] = this.eventCategories;
238 responseData["event_notifications"] = new ArrayList(); // todo
239 responseData["classified_categories"] = this.classifiedCategories;
240 responseData["ui-config"] = this.uiConfig;
241
242 responseData["inventory-skeleton"] = this.agentInventory;
243 responseData["inventory-skel-lib"] = new ArrayList(); // todo
244 responseData["inventory-root"] = this.inventoryRoot;
245 responseData["gestures"] = new ArrayList(); // todo
246 responseData["inventory-lib-owner"] = new ArrayList(); // todo
247 responseData["initial-outfit"] = this.initialOutfit;
248 responseData["start_location"] = this.startLocation;
249 responseData["seed_capability"] = this.seedCapability;
250 responseData["home"] = this.home;
251 responseData["look_at"] = this.lookAt;
252 responseData["message"] = this.welcomeMessage;
253 responseData["region_x"] = (Int32)this.RegionX * 256;
254 responseData["region_y"] = (Int32)this.RegionY * 256;
255
256 //responseData["inventory-lib-root"] = new ArrayList(); // todo
257 //responseData["buddy-list"] = new ArrayList(); // todo
258
259 responseData["login"] = "true";
260 this.xmlRpcResponse.Value = responseData;
261
262 return (this.xmlRpcResponse);
263 }
264 catch (Exception e)
265 {
266 MainLog.Instance.WriteLine(
267 LogPriority.LOW,
268 "LoginResponse: Error creating XML-RPC Response: " + e.Message
269 );
270 return (this.GenerateFailureResponse("Internal Error", "Error generating Login Response", "false"));
271
272 }
273
274 } // ToXmlRpcResponse
275
276 public void SetEventCategories(string category, string value)
277 {
278 this.eventCategoriesHash[category] = value;
279 } // SetEventCategories
280
281 public void AddToUIConfig(string itemName, string item)
282 {
283 this.uiConfigHash[itemName] = item;
284 } // SetUIConfig
285
286 public void AddClassifiedCategory(Int32 ID, string categoryName)
287 {
288 this.classifiedCategoriesHash["category_name"] = categoryName;
289 this.classifiedCategoriesHash["category_id"] = ID;
290 this.classifiedCategories.Add(this.classifiedCategoriesHash);
291 // this.classifiedCategoriesHash.Clear();
292 } // SetClassifiedCategory
293
294 #region Properties
295 public string Login
296 {
297 get
298 {
299 return this.login;
300 }
301 set
302 {
303 this.login = value;
304 }
305 } // Login
306
307 public string DST
308 {
309 get
310 {
311 return this.dst;
312 }
313 set
314 {
315 this.dst = value;
316 }
317 } // DST
318
319 public string StipendSinceLogin
320 {
321 get
322 {
323 return this.stipendSinceLogin;
324 }
325 set
326 {
327 this.stipendSinceLogin = value;
328 }
329 } // StipendSinceLogin
330
331 public string Gendered
332 {
333 get
334 {
335 return this.gendered;
336 }
337 set
338 {
339 this.gendered = value;
340 }
341 } // Gendered
342
343 public string EverLoggedIn
344 {
345 get
346 {
347 return this.everLoggedIn;
348 }
349 set
350 {
351 this.everLoggedIn = value;
352 }
353 } // EverLoggedIn
354
355 public int SimPort
356 {
357 get
358 {
359 return this.simPort;
360 }
361 set
362 {
363 this.simPort = value;
364 }
365 } // SimPort
366
367 public string SimAddress
368 {
369 get
370 {
371 return this.simAddress;
372 }
373 set
374 {
375 this.simAddress = value;
376 }
377 } // SimAddress
378
379 public LLUUID AgentID
380 {
381 get
382 {
383 return this.agentID;
384 }
385 set
386 {
387 this.agentID = value;
388 }
389 } // AgentID
390
391 public LLUUID SessionID
392 {
393 get
394 {
395 return this.sessionID;
396 }
397 set
398 {
399 this.sessionID = value;
400 }
401 } // SessionID
402
403 public LLUUID SecureSessionID
404 {
405 get
406 {
407 return this.secureSessionID;
408 }
409 set
410 {
411 this.secureSessionID = value;
412 }
413 } // SecureSessionID
414
415 public Int32 CircuitCode
416 {
417 get
418 {
419 return this.circuitCode;
420 }
421 set
422 {
423 this.circuitCode = value;
424 }
425 } // CircuitCode
426
427 public uint RegionX
428 {
429 get
430 {
431 return this.regionX;
432 }
433 set
434 {
435 this.regionX = value;
436 }
437 } // RegionX
438
439 public uint RegionY
440 {
441 get
442 {
443 return this.regionY;
444 }
445 set
446 {
447 this.regionY = value;
448 }
449 } // RegionY
450
451 public string SunTexture
452 {
453 get
454 {
455 return this.sunTexture;
456 }
457 set
458 {
459 this.sunTexture = value;
460 }
461 } // SunTexture
462
463 public string CloudTexture
464 {
465 get
466 {
467 return this.cloudTexture;
468 }
469 set
470 {
471 this.cloudTexture = value;
472 }
473 } // CloudTexture
474
475 public string MoonTexture
476 {
477 get
478 {
479 return this.moonTexture;
480 }
481 set
482 {
483 this.moonTexture = value;
484 }
485 } // MoonTexture
486
487 public string Firstname
488 {
489 get
490 {
491 return this.firstname;
492 }
493 set
494 {
495 this.firstname = value;
496 }
497 } // Firstname
498
499 public string Lastname
500 {
501 get
502 {
503 return this.lastname;
504 }
505 set
506 {
507 this.lastname = value;
508 }
509 } // Lastname
510
511 public string AgentAccess
512 {
513 get
514 {
515 return this.agentAccess;
516 }
517 set
518 {
519 this.agentAccess = value;
520 }
521 }
522
523 public string StartLocation
524 {
525 get
526 {
527 return this.startLocation;
528 }
529 set
530 {
531 this.startLocation = value;
532 }
533 } // StartLocation
534
535 public string LookAt
536 {
537 get
538 {
539 return this.lookAt;
540 }
541 set
542 {
543 this.lookAt = value;
544 }
545 }
546
547 public string SeedCapability
548 {
549 get
550 {
551 return this.seedCapability;
552 }
553 set
554 {
555 this.seedCapability = value;
556 }
557 } // SeedCapability
558
559 public string ErrorReason
560 {
561 get
562 {
563 return this.errorReason;
564 }
565 set
566 {
567 this.errorReason = value;
568 }
569 } // ErrorReason
570
571 public string ErrorMessage
572 {
573 get
574 {
575 return this.errorMessage;
576 }
577 set
578 {
579 this.errorMessage = value;
580 }
581 } // ErrorMessage
582
583 public ArrayList InventoryRoot
584 {
585 get
586 {
587 return this.inventoryRoot;
588 }
589 set
590 {
591 this.inventoryRoot = value;
592 }
593 }
594
595 public ArrayList InventorySkeleton
596 {
597 get
598 {
599 return this.agentInventory;
600 }
601 set
602 {
603 this.agentInventory = value;
604 }
605 }
606
607 public string Home
608 {
609 get
610 {
611 return this.home;
612 }
613 set
614 {
615 this.home = value;
616 }
617 }
618
619 public string Message
620 {
621 get
622 {
623 return this.welcomeMessage;
624 }
625 set
626 {
627 this.welcomeMessage = value;
628 }
629 }
630 #endregion
631
632
633 public class UserInfo
634 {
635 public string firstname;
636 public string lastname;
637 public ulong homeregionhandle;
638 public LLVector3 homepos;
639 public LLVector3 homelookat;
640 }
641 }
642}
643
diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs
new file mode 100644
index 0000000..df6fbb2
--- /dev/null
+++ b/OpenSim/Framework/UserManager/UserManagerBase.cs
@@ -0,0 +1,630 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Reflection;
32using System.Security.Cryptography;
33using libsecondlife;
34using Nwc.XmlRpc;
35using OpenSim.Framework.Console;
36using OpenSim.Framework.Data;
37using OpenSim.Framework.Interfaces;
38using OpenSim.Framework.Inventory;
39using OpenSim.Framework.Utilities;
40
41namespace OpenSim.Framework.UserManagement
42{
43 public abstract class UserManagerBase
44 {
45 public UserConfig _config;
46 Dictionary<string, IUserData> _plugins = new Dictionary<string, IUserData>();
47
48 /// <summary>
49 /// Adds a new user server plugin - user servers will be requested in the order they were loaded.
50 /// </summary>
51 /// <param name="FileName">The filename to the user server plugin DLL</param>
52 public void AddPlugin(string FileName)
53 {
54 MainLog.Instance.Verbose( "Userstorage: Attempting to load " + FileName);
55 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
56
57 MainLog.Instance.Verbose( "Userstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
58 foreach (Type pluginType in pluginAssembly.GetTypes())
59 {
60 if (!pluginType.IsAbstract)
61 {
62 Type typeInterface = pluginType.GetInterface("IUserData", true);
63
64 if (typeInterface != null)
65 {
66 IUserData plug = (IUserData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
67 plug.Initialise();
68 this._plugins.Add(plug.getName(), plug);
69 MainLog.Instance.Verbose( "Userstorage: Added IUserData Interface");
70 }
71
72 typeInterface = null;
73 }
74 }
75
76 pluginAssembly = null;
77 }
78
79 #region Get UserProfile
80 /// <summary>
81 /// Loads a user profile from a database by UUID
82 /// </summary>
83 /// <param name="uuid">The target UUID</param>
84 /// <returns>A user profile</returns>
85 public UserProfileData getUserProfile(LLUUID uuid)
86 {
87 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
88 {
89 try
90 {
91 UserProfileData profile = plugin.Value.getUserByUUID(uuid);
92 profile.currentAgent = getUserAgent(profile.UUID);
93 return profile;
94 }
95 catch (Exception e)
96 {
97 MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
98 }
99 }
100
101 return null;
102 }
103
104
105 /// <summary>
106 /// Loads a user profile by name
107 /// </summary>
108 /// <param name="name">The target name</param>
109 /// <returns>A user profile</returns>
110 public UserProfileData getUserProfile(string name)
111 {
112 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
113 {
114 try
115 {
116 UserProfileData profile = plugin.Value.getUserByName(name);
117 profile.currentAgent = getUserAgent(profile.UUID);
118 return profile;
119 }
120 catch (Exception e)
121 {
122 MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
123 }
124 }
125
126 return null;
127 }
128
129 /// <summary>
130 /// Loads a user profile by name
131 /// </summary>
132 /// <param name="fname">First name</param>
133 /// <param name="lname">Last name</param>
134 /// <returns>A user profile</returns>
135 public UserProfileData getUserProfile(string fname, string lname)
136 {
137 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
138 {
139 try
140 {
141 UserProfileData profile = plugin.Value.getUserByName(fname,lname);
142
143 profile.currentAgent = getUserAgent(profile.UUID);
144
145 return profile;
146 }
147 catch (Exception e)
148 {
149 MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
150 }
151 }
152
153 return null;
154 }
155 #endregion
156
157 #region Get UserAgent
158 /// <summary>
159 /// Loads a user agent by uuid (not called directly)
160 /// </summary>
161 /// <param name="uuid">The agents UUID</param>
162 /// <returns>Agent profiles</returns>
163 public UserAgentData getUserAgent(LLUUID uuid)
164 {
165 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
166 {
167 try
168 {
169 return plugin.Value.getAgentByUUID(uuid);
170 }
171 catch (Exception e)
172 {
173 MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
174 }
175 }
176
177 return null;
178 }
179
180 /// <summary>
181 /// Loads a user agent by name (not called directly)
182 /// </summary>
183 /// <param name="name">The agents name</param>
184 /// <returns>A user agent</returns>
185 public UserAgentData getUserAgent(string name)
186 {
187 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
188 {
189 try
190 {
191 return plugin.Value.getAgentByName(name);
192 }
193 catch (Exception e)
194 {
195 MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
196 }
197 }
198
199 return null;
200 }
201
202 /// <summary>
203 /// Loads a user agent by name (not called directly)
204 /// </summary>
205 /// <param name="fname">The agents firstname</param>
206 /// <param name="lname">The agents lastname</param>
207 /// <returns>A user agent</returns>
208 public UserAgentData getUserAgent(string fname, string lname)
209 {
210 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
211 {
212 try
213 {
214 return plugin.Value.getAgentByName(fname,lname);
215 }
216 catch (Exception e)
217 {
218 MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
219 }
220 }
221
222 return null;
223 }
224
225 #endregion
226
227 #region CreateAgent
228 /// <summary>
229 /// Creates and initialises a new user agent - make sure to use CommitAgent when done to submit to the DB
230 /// </summary>
231 /// <param name="profile">The users profile</param>
232 /// <param name="request">The users loginrequest</param>
233 public void CreateAgent(UserProfileData profile, XmlRpcRequest request)
234 {
235 Hashtable requestData = (Hashtable)request.Params[0];
236
237 UserAgentData agent = new UserAgentData();
238
239 // User connection
240 agent.agentOnline = true;
241
242 // Generate sessions
243 RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
244 byte[] randDataS = new byte[16];
245 byte[] randDataSS = new byte[16];
246 rand.GetBytes(randDataS);
247 rand.GetBytes(randDataSS);
248
249 agent.secureSessionID = new LLUUID(randDataSS, 0);
250 agent.sessionID = new LLUUID(randDataS, 0);
251
252 // Profile UUID
253 agent.UUID = profile.UUID;
254
255 // Current position (from Home)
256 agent.currentHandle = profile.homeRegion;
257 agent.currentPos = profile.homeLocation;
258
259 // If user specified additional start, use that
260 if (requestData.ContainsKey("start"))
261 {
262 string startLoc = ((string)requestData["start"]).Trim();
263 if (!(startLoc == "last" || startLoc == "home"))
264 {
265 // Format: uri:Ahern&162&213&34
266 try
267 {
268 string[] parts = startLoc.Remove(0, 4).Split('&');
269 string region = parts[0];
270
271 ////////////////////////////////////////////////////
272 //SimProfile SimInfo = new SimProfile();
273 //SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey);
274 }
275 catch (Exception)
276 {
277
278 }
279 }
280 }
281
282 // What time did the user login?
283 agent.loginTime = Util.UnixTimeSinceEpoch();
284 agent.logoutTime = 0;
285
286 // Current location
287 agent.regionID = new LLUUID(); // Fill in later
288 agent.currentRegion = new LLUUID(); // Fill in later
289
290 profile.currentAgent = agent;
291 }
292
293 /// <summary>
294 /// Saves a target agent to the database
295 /// </summary>
296 /// <param name="profile">The users profile</param>
297 /// <returns>Successful?</returns>
298 public bool CommitAgent(ref UserProfileData profile)
299 {
300 // Saves the agent to database
301 return true;
302 }
303
304 #endregion
305
306 /// <summary>
307 /// Checks a user against it's password hash
308 /// </summary>
309 /// <param name="profile">The users profile</param>
310 /// <param name="password">The supplied password</param>
311 /// <returns>Authenticated?</returns>
312 public virtual bool AuthenticateUser(UserProfileData profile, string password)
313 {
314 MainLog.Instance.Verbose(
315 "Authenticating " + profile.username + " " + profile.surname);
316
317 password = password.Remove(0, 3); //remove $1$
318
319 string s = Util.Md5Hash(password + ":" + profile.passwordSalt);
320
321 return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase);
322 }
323
324 #region Xml Response
325
326 /// <summary>
327 ///
328 /// </summary>
329 /// <param name="firstname"></param>
330 /// <param name="lastname"></param>
331 /// <returns></returns>
332 public virtual UserProfileData GetTheUser(string firstname, string lastname)
333 {
334 return getUserProfile(firstname, lastname);
335 }
336
337 /// <summary>
338 ///
339 /// </summary>
340 /// <returns></returns>
341 public virtual string GetMessage()
342 {
343 return _config.DefaultStartupMsg;
344 }
345
346 /// <summary>
347 /// Customises the login response and fills in missing values.
348 /// </summary>
349 /// <param name="response">The existing response</param>
350 /// <param name="theUser">The user profile</param>
351 public abstract void CustomiseResponse( LoginResponse response, UserProfileData theUser);
352
353 /// <summary>
354 /// Main user login function
355 /// </summary>
356 /// <param name="request">The XMLRPC request</param>
357 /// <returns>The response to send</returns>
358 public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
359 {
360
361 System.Console.WriteLine("Attempting login now...");
362 XmlRpcResponse response = new XmlRpcResponse();
363 Hashtable requestData = (Hashtable)request.Params[0];
364
365 bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd"));
366 bool GoodLogin = false;
367 string firstname = "";
368 string lastname = "";
369 string passwd = "";
370
371 UserProfileData userProfile;
372 LoginResponse logResponse = new LoginResponse();
373
374 if (GoodXML)
375 {
376 firstname = (string)requestData["first"];
377 lastname = (string)requestData["last"];
378 passwd = (string)requestData["passwd"];
379
380 userProfile = GetTheUser(firstname, lastname);
381 if (userProfile == null)
382 return logResponse.CreateLoginFailedResponse();
383
384 GoodLogin = AuthenticateUser(userProfile, passwd);
385 }
386 else
387 {
388 return logResponse.CreateGridErrorResponse();
389 }
390
391 if (!GoodLogin)
392 {
393 return logResponse.CreateLoginFailedResponse();
394 }
395 else
396 {
397 // If we already have a session...
398 if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline)
399 {
400 // Reject the login
401 return logResponse.CreateAlreadyLoggedInResponse();
402 }
403 // Otherwise...
404 // Create a new agent session
405 CreateAgent( userProfile, request);
406
407 try
408 {
409
410 LLUUID AgentID = userProfile.UUID;
411
412 // Inventory Library Section
413 ArrayList AgentInventoryArray = new ArrayList();
414 Hashtable TempHash;
415
416 AgentInventory Library = new AgentInventory();
417 Library.CreateRootFolder(AgentID, true);
418
419 foreach (InventoryFolder InvFolder in Library.InventoryFolders.Values)
420 {
421 TempHash = new Hashtable();
422 TempHash["name"] = InvFolder.FolderName;
423 TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
424 TempHash["version"] = (Int32)InvFolder.Version;
425 TempHash["type_default"] = (Int32)InvFolder.DefaultType;
426 TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
427 AgentInventoryArray.Add(TempHash);
428 }
429
430 Hashtable InventoryRootHash = new Hashtable();
431 InventoryRootHash["folder_id"] = Library.InventoryRoot.FolderID.ToStringHyphenated();
432 ArrayList InventoryRoot = new ArrayList();
433 InventoryRoot.Add(InventoryRootHash);
434
435 // Circuit Code
436 uint circode = (uint)(Util.RandomClass.Next());
437
438 logResponse.Lastname = userProfile.surname;
439 logResponse.Firstname = userProfile.username;
440 logResponse.AgentID = AgentID.ToStringHyphenated();
441 logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated();
442 logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated();
443 logResponse.InventoryRoot = InventoryRoot;
444 logResponse.InventorySkeleton = AgentInventoryArray;
445 logResponse.CircuitCode = (Int32)circode;
446 //logResponse.RegionX = 0; //overwritten
447 //logResponse.RegionY = 0; //overwritten
448 logResponse.Home = "!!null temporary value {home}!!"; // Overwritten
449 //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n";
450 //logResponse.SimAddress = "127.0.0.1"; //overwritten
451 //logResponse.SimPort = 0; //overwritten
452 logResponse.Message = this.GetMessage();
453
454 try
455 {
456 this.CustomiseResponse( logResponse, userProfile);
457 }
458 catch (Exception e)
459 {
460 System.Console.WriteLine(e.ToString());
461 return logResponse.CreateDeadRegionResponse();
462 //return logResponse.ToXmlRpcResponse();
463 }
464 CommitAgent(ref userProfile);
465 return logResponse.ToXmlRpcResponse();
466
467 }
468
469 catch (Exception E)
470 {
471 System.Console.WriteLine(E.ToString());
472 }
473 //}
474 }
475 return response;
476
477 }
478
479 #endregion
480
481 /// <summary>
482 /// Deletes an active agent session
483 /// </summary>
484 /// <param name="request">The request</param>
485 /// <param name="path">The path (eg /bork/narf/test)</param>
486 /// <param name="param">Parameters sent</param>
487 /// <returns>Success "OK" else error</returns>
488 public string RestDeleteUserSessionMethod(string request, string path, string param)
489 {
490 // TODO! Important!
491
492 return "OK";
493 }
494
495 /// <summary>
496 ///
497 /// </summary>
498 /// <param name="user"></param>
499 public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY)
500 {
501 UserProfileData user = new UserProfileData();
502 user.homeLocation = new LLVector3(128, 128, 100);
503 user.UUID = LLUUID.Random();
504 user.username = firstName;
505 user.surname = lastName;
506 user.passwordHash = pass;
507 user.passwordSalt = "";
508 user.created = Util.UnixTimeSinceEpoch();
509 user.homeLookAt = new LLVector3(100, 100, 100);
510 user.homeRegion = Util.UIntsToLong((regX * 256), (regY * 256));
511
512 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
513 {
514 try
515 {
516 plugin.Value.addNewUserProfile(user);
517
518 }
519 catch (Exception e)
520 {
521 MainLog.Instance.Verbose("Unable to add user via " + plugin.Key + "(" + e.ToString() + ")");
522 }
523 }
524 }
525
526 /// <summary>
527 /// Returns an error message that the user could not be found in the database
528 /// </summary>
529 /// <returns>XML string consisting of a error element containing individual error(s)</returns>
530 public XmlRpcResponse CreateUnknownUserErrorResponse()
531 {
532 XmlRpcResponse response = new XmlRpcResponse();
533 Hashtable responseData = new Hashtable();
534 responseData["error_type"] = "unknown_user";
535 responseData["error_desc"] = "The user requested is not in the database";
536
537 response.Value = responseData;
538 return response;
539 }
540
541 /// <summary>
542 /// Converts a user profile to an XML element which can be returned
543 /// </summary>
544 /// <param name="profile">The user profile</param>
545 /// <returns>A string containing an XML Document of the user profile</returns>
546 public XmlRpcResponse ProfileToXmlRPCResponse(UserProfileData profile)
547 {
548 XmlRpcResponse response = new XmlRpcResponse();
549 Hashtable responseData = new Hashtable();
550
551 // Account information
552 responseData["firstname"] = profile.username;
553 responseData["lastname"] = profile.surname;
554 responseData["uuid"] = profile.UUID.ToStringHyphenated();
555 // Server Information
556 responseData["server_inventory"] = profile.userInventoryURI;
557 responseData["server_asset"] = profile.userAssetURI;
558 // Profile Information
559 responseData["profile_about"] = profile.profileAboutText;
560 responseData["profile_firstlife_about"] = profile.profileFirstText;
561 responseData["profile_firstlife_image"] = profile.profileFirstImage.ToStringHyphenated();
562 responseData["profile_can_do"] = profile.profileCanDoMask.ToString();
563 responseData["profile_want_do"] = profile.profileWantDoMask.ToString();
564 responseData["profile_image"] = profile.profileImage.ToStringHyphenated();
565 responseData["profile_created"] = profile.created.ToString();
566 responseData["profile_lastlogin"] = profile.lastLogin.ToString();
567 // Home region information
568 responseData["home_coordinates_x"] = profile.homeLocation.X.ToString();
569 responseData["home_coordinates_y"] = profile.homeLocation.Y.ToString();
570 responseData["home_coordinates_z"] = profile.homeLocation.Z.ToString();
571
572 responseData["home_region"] = profile.homeRegion.ToString();
573
574 responseData["home_look_x"] = profile.homeLookAt.X.ToString();
575 responseData["home_look_y"] = profile.homeLookAt.Y.ToString();
576 responseData["home_look_z"] = profile.homeLookAt.Z.ToString();
577 response.Value = responseData;
578 return response;
579 }
580
581 #region XMLRPC User Methods
582 //should most likely move out of here and into the grid's userserver sub class
583 public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request)
584 {
585 XmlRpcResponse response = new XmlRpcResponse();
586 Hashtable requestData = (Hashtable)request.Params[0];
587 UserProfileData userProfile;
588
589 if (requestData.Contains("avatar_name"))
590 {
591 userProfile = getUserProfile((string)requestData["avatar_name"]);
592 if (userProfile == null)
593 {
594 return CreateUnknownUserErrorResponse();
595 }
596 }
597 else
598 {
599 return CreateUnknownUserErrorResponse();
600 }
601
602
603 return ProfileToXmlRPCResponse(userProfile);
604 }
605
606 public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request)
607 {
608 XmlRpcResponse response = new XmlRpcResponse();
609 Hashtable requestData = (Hashtable)request.Params[0];
610 UserProfileData userProfile;
611 if (requestData.Contains("avatar_uuid"))
612 {
613 userProfile = getUserProfile((LLUUID)requestData["avatar_uuid"]);
614 if (userProfile == null)
615 {
616 return CreateUnknownUserErrorResponse();
617 }
618 }
619 else
620 {
621 return CreateUnknownUserErrorResponse();
622 }
623
624
625 return ProfileToXmlRPCResponse(userProfile);
626 }
627 #endregion
628
629 }
630}
diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs
new file mode 100644
index 0000000..3e302d8
--- /dev/null
+++ b/OpenSim/Grid/AssetServer/Main.cs
@@ -0,0 +1,406 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28
29using System;
30using System.IO;
31using System.Text;
32using Db4objects.Db4o;
33using libsecondlife;
34using OpenSim.Framework.Console;
35using OpenSim.Framework.Types;
36using OpenSim.Framework.Servers;
37
38namespace OpenSim.Grid.AssetServer
39{
40 /// <summary>
41 /// An asset server
42 /// </summary>
43 public class OpenAsset_Main : conscmd_callback
44 {
45 private IObjectContainer db;
46
47 public static OpenAsset_Main assetserver;
48
49 private LogBase m_console;
50
51 [STAThread]
52 public static void Main(string[] args)
53 {
54 Console.WriteLine("Starting...\n");
55
56 assetserver = new OpenAsset_Main();
57 assetserver.Startup();
58
59 assetserver.Work();
60 }
61
62 private void Work()
63 {
64 m_console.Notice("Enter help for a list of commands");
65
66 while (true)
67 {
68 m_console.MainLogPrompt();
69 }
70 }
71
72 private OpenAsset_Main()
73 {
74 m_console = new LogBase("opengrid-AssetServer-console.log", "OpenAsset", this, false);
75 MainLog.Instance = m_console;
76 }
77
78 public void Startup()
79 {
80 m_console.Verbose("Main.cs:Startup() - Setting up asset DB");
81 setupDB();
82
83 m_console.Verbose("Main.cs:Startup() - Starting HTTP process");
84 BaseHttpServer httpServer = new BaseHttpServer(8003);
85
86 httpServer.AddStreamHandler( new GetAssetStreamHandler(this));
87 httpServer.AddStreamHandler(new PostAssetStreamHandler( this ));
88
89 //httpServer.AddRestHandler("GET", "/assets/", this.assetGetMethod);
90 //httpServer.AddRestHandler("POST", "/assets/", this.assetPostMethod);
91
92 httpServer.Start();
93
94 }
95
96 //public string AssetPostMethod(string requestBody, string path, string param)
97 //{
98 // AssetBase asset = new AssetBase();
99 // asset.Name = "";
100 // asset.FullID = new LLUUID(param);
101 // Encoding Windows1252Encoding = Encoding.GetEncoding(1252);
102 // byte[] buffer = Windows1252Encoding.GetBytes(requestBody);
103 // asset.Data = buffer;
104 // AssetStorage store = new AssetStorage();
105 // store.Data = asset.Data;
106 // store.Name = asset.Name;
107 // store.UUID = asset.FullID;
108 // db.Set(store);
109 // db.Commit();
110 // return "";
111 //}
112
113 //public string AssetGetMethod(string request, string path, string param)
114 //{
115 // Console.WriteLine("got a request " + param);
116 // byte[] assetdata = GetAssetData(new LLUUID(param), false);
117 // if (assetdata != null)
118 // {
119 // Encoding Windows1252Encoding = Encoding.GetEncoding(1252);
120 // string ret = Windows1252Encoding.GetString(assetdata);
121 // //string ret = System.Text.Encoding.Unicode.GetString(assetdata);
122
123 // return ret;
124
125 // }
126 // else
127 // {
128 // return "";
129 // }
130
131 //}
132
133 public byte[] GetAssetData(LLUUID assetID, bool isTexture)
134 {
135 bool found = false;
136 AssetStorage foundAsset = null;
137
138 IObjectSet result = db.Get(new AssetStorage(assetID));
139 if (result.Count > 0)
140 {
141 foundAsset = (AssetStorage)result.Next();
142 found = true;
143 }
144
145 if (found)
146 {
147 return foundAsset.Data;
148 }
149 else
150 {
151 return null;
152 }
153 }
154
155 public void setupDB()
156 {
157 bool yapfile = File.Exists("assets.yap");
158 try
159 {
160 db = Db4oFactory.OpenFile("assets.yap");
161 MainLog.Instance.Verbose("Main.cs:setupDB() - creation");
162 }
163 catch (Exception e)
164 {
165 db.Close();
166 MainLog.Instance.Warn("Main.cs:setupDB() - Exception occured");
167 MainLog.Instance.Warn(e.ToString());
168 }
169 if (!yapfile)
170 {
171 this.LoadDB();
172 }
173 }
174
175 public void LoadDB()
176 {
177 try
178 {
179
180 Console.WriteLine("setting up Asset database");
181
182 AssetBase Image = new AssetBase();
183 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001");
184 Image.Name = "Bricks";
185 this.LoadAsset(Image, true, "bricks.jp2");
186 AssetStorage store = new AssetStorage();
187 store.Data = Image.Data;
188 store.Name = Image.Name;
189 store.UUID = Image.FullID;
190 db.Set(store);
191 db.Commit();
192
193 Image = new AssetBase();
194 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002");
195 Image.Name = "Plywood";
196 this.LoadAsset(Image, true, "plywood.jp2");
197 store = new AssetStorage();
198 store.Data = Image.Data;
199 store.Name = Image.Name;
200 store.UUID = Image.FullID;
201 db.Set(store);
202 db.Commit();
203
204 Image = new AssetBase();
205 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003");
206 Image.Name = "Rocks";
207 this.LoadAsset(Image, true, "rocks.jp2");
208 store = new AssetStorage();
209 store.Data = Image.Data;
210 store.Name = Image.Name;
211 store.UUID = Image.FullID;
212 db.Set(store);
213 db.Commit();
214
215 Image = new AssetBase();
216 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004");
217 Image.Name = "Granite";
218 this.LoadAsset(Image, true, "granite.jp2");
219 store = new AssetStorage();
220 store.Data = Image.Data;
221 store.Name = Image.Name;
222 store.UUID = Image.FullID;
223 db.Set(store);
224 db.Commit();
225
226 Image = new AssetBase();
227 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005");
228 Image.Name = "Hardwood";
229 this.LoadAsset(Image, true, "hardwood.jp2");
230 store = new AssetStorage();
231 store.Data = Image.Data;
232 store.Name = Image.Name;
233 store.UUID = Image.FullID;
234 db.Set(store);
235 db.Commit();
236
237 Image = new AssetBase();
238 Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005");
239 Image.Name = "Prim Base Texture";
240 this.LoadAsset(Image, true, "plywood.jp2");
241 store = new AssetStorage();
242 store.Data = Image.Data;
243 store.Name = Image.Name;
244 store.UUID = Image.FullID;
245 db.Set(store);
246 db.Commit();
247
248 Image = new AssetBase();
249 Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
250 Image.Name = "Shape";
251 this.LoadAsset(Image, false, "base_shape.dat");
252 store = new AssetStorage();
253 store.Data = Image.Data;
254 store.Name = Image.Name;
255 store.UUID = Image.FullID;
256 db.Set(store);
257 db.Commit();
258 }
259 catch (Exception e)
260 {
261 Console.WriteLine(e.Message);
262 }
263 }
264
265 private void LoadAsset(AssetBase info, bool image, string filename)
266 {
267
268
269 string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder;
270 string fileName = Path.Combine(dataPath, filename);
271 FileInfo fInfo = new FileInfo(fileName);
272 long numBytes = fInfo.Length;
273 FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
274 byte[] idata = new byte[numBytes];
275 BinaryReader br = new BinaryReader(fStream);
276 idata = br.ReadBytes((int)numBytes);
277 br.Close();
278 fStream.Close();
279 info.Data = idata;
280 //info.loaded=true;
281 }
282
283 /*private GridConfig LoadConfigDll(string dllName)
284 {
285 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
286 GridConfig config = null;
287
288 foreach (Type pluginType in pluginAssembly.GetTypes())
289 {
290 if (pluginType.IsPublic)
291 {
292 if (!pluginType.IsAbstract)
293 {
294 Type typeInterface = pluginType.GetInterface("IGridConfig", true);
295
296 if (typeInterface != null)
297 {
298 IGridConfig plug = (IGridConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
299 config = plug.GetConfigObject();
300 break;
301 }
302
303 typeInterface = null;
304 }
305 }
306 }
307 pluginAssembly = null;
308 return config;
309 }*/
310
311 public void CreateAsset(LLUUID assetId, byte[] assetData)
312 {
313 AssetBase asset = new AssetBase();
314 asset.Name = "";
315 asset.FullID = assetId;
316 asset.Data = assetData;
317
318 AssetStorage store = new AssetStorage();
319 store.Data = asset.Data;
320 store.Name = asset.Name;
321 store.UUID = asset.FullID;
322 db.Set(store);
323 db.Commit();
324 }
325
326 public void RunCmd(string cmd, string[] cmdparams)
327 {
328 switch (cmd)
329 {
330 case "help":
331 m_console.Notice("shutdown - shutdown this asset server (USE CAUTION!)");
332 break;
333
334 case "shutdown":
335 m_console.Close();
336 Environment.Exit(0);
337 break;
338 }
339 }
340
341 public void Show(string ShowWhat)
342 {
343 }
344 }
345
346 public class GetAssetStreamHandler : BaseStreamHandler
347 {
348 OpenAsset_Main m_assetManager;
349
350 override public byte[] Handle(string path, Stream request)
351 {
352 string param = GetParam(path);
353
354 byte[] assetdata = m_assetManager.GetAssetData(new LLUUID(param), false);
355 if (assetdata != null)
356 {
357 return assetdata;
358 }
359 else
360 {
361 return new byte[]{};
362 }
363 }
364
365 public GetAssetStreamHandler(OpenAsset_Main assetManager):base( "/assets/", "GET")
366 {
367 m_assetManager = assetManager;
368 }
369 }
370
371 public class PostAssetStreamHandler : BaseStreamHandler
372 {
373 OpenAsset_Main m_assetManager;
374
375 override public byte[] Handle(string path, Stream request)
376 {
377 string param = GetParam(path);
378 LLUUID assetId = new LLUUID(param);
379 byte[] txBuffer = new byte[4096];
380
381 using( BinaryReader binReader = new BinaryReader( request ) )
382 {
383 using (MemoryStream memoryStream = new MemoryStream(4096))
384 {
385 int count;
386 while ((count = binReader.Read(txBuffer, 0, 4096)) > 0)
387 {
388 memoryStream.Write(txBuffer, 0, count);
389 }
390
391 byte[] assetData = memoryStream.ToArray();
392
393 m_assetManager.CreateAsset(assetId, assetData);
394 }
395 }
396
397 return new byte[]{};
398 }
399
400 public PostAssetStreamHandler( OpenAsset_Main assetManager )
401 : base("/assets/", "POST")
402 {
403 m_assetManager = assetManager;
404 }
405 }
406}
diff --git a/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..dc39ce2
--- /dev/null
+++ b/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs
@@ -0,0 +1,58 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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// General Information about an assembly is controlled through the following
31// set of attributes. Change these attribute values to modify the information
32// associated with an assembly.
33[assembly: AssemblyTitle("OGS-AssetServer")]
34[assembly: AssemblyDescription("")]
35[assembly: AssemblyConfiguration("")]
36[assembly: AssemblyCompany("")]
37[assembly: AssemblyProduct("OGS-AssetServer")]
38[assembly: AssemblyCopyright("Copyright © 2007")]
39[assembly: AssemblyTrademark("")]
40[assembly: AssemblyCulture("")]
41
42// Setting ComVisible to false makes the types in this assembly not visible
43// to COM components. If you need to access a type in this assembly from
44// COM, set the ComVisible attribute to true on that type.
45[assembly: ComVisible(false)]
46
47// The following GUID is for the ID of the typelib if this project is exposed to COM
48[assembly: Guid("b541b244-3d1d-4625-9003-bc2a3a6a39a4")]
49
50// Version information for an assembly consists of the following four values:
51//
52// Major Version
53// Minor Version
54// Build Number
55// Revision
56//
57[assembly: AssemblyVersion("1.0.0.0")]
58[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Grid/Framework.Manager/GridManagementAgent.cs b/OpenSim/Grid/Framework.Manager/GridManagementAgent.cs
new file mode 100644
index 0000000..6c916a2
--- /dev/null
+++ b/OpenSim/Grid/Framework.Manager/GridManagementAgent.cs
@@ -0,0 +1,138 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Collections;
29using libsecondlife;
30using Nwc.XmlRpc;
31using OpenSim.Framework.Servers;
32
33namespace OpenSim.Framework.Manager
34{
35 /// <summary>
36 /// Used to pass messages to the gridserver
37 /// </summary>
38 /// <param name="param">Pass this argument</param>
39 public delegate void GridManagerCallback(string param);
40
41 /// <summary>
42 /// Serverside listener for grid commands
43 /// </summary>
44 public class GridManagementAgent
45 {
46 /// <summary>
47 /// Passes grid server messages
48 /// </summary>
49 private GridManagerCallback thecallback;
50
51 /// <summary>
52 /// Security keys
53 /// </summary>
54 private string sendkey;
55 private string recvkey;
56
57 /// <summary>
58 /// Our component type
59 /// </summary>
60 private string component_type;
61
62 /// <summary>
63 /// List of active sessions
64 /// </summary>
65 private static ArrayList Sessions;
66
67 /// <summary>
68 /// Initialises a new GridManagementAgent
69 /// </summary>
70 /// <param name="app_httpd">HTTP Daemon for this server</param>
71 /// <param name="component_type">What component type are we?</param>
72 /// <param name="sendkey">Security send key</param>
73 /// <param name="recvkey">Security recieve key</param>
74 /// <param name="thecallback">Message callback</param>
75 public GridManagementAgent(BaseHttpServer app_httpd, string component_type, string sendkey, string recvkey, GridManagerCallback thecallback)
76 {
77 this.sendkey = sendkey;
78 this.recvkey = recvkey;
79 this.component_type = component_type;
80 this.thecallback = thecallback;
81 Sessions = new ArrayList();
82
83 app_httpd.AddXmlRPCHandler("manager_login", XmlRpcLoginMethod);
84
85 switch (component_type)
86 {
87 case "gridserver":
88 GridServerManager.sendkey = this.sendkey;
89 GridServerManager.recvkey = this.recvkey;
90 GridServerManager.thecallback = thecallback;
91 app_httpd.AddXmlRPCHandler("shutdown", GridServerManager.XmlRpcShutdownMethod);
92 break;
93 }
94 }
95
96 /// <summary>
97 /// Checks if a session exists
98 /// </summary>
99 /// <param name="sessionID">The session ID</param>
100 /// <returns>Exists?</returns>
101 public static bool SessionExists(LLUUID sessionID)
102 {
103 return Sessions.Contains(sessionID);
104 }
105
106 /// <summary>
107 /// Logs a new session to the grid manager
108 /// </summary>
109 /// <param name="request">the XMLRPC request</param>
110 /// <returns>An XMLRPC reply</returns>
111 public static XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
112 {
113 XmlRpcResponse response = new XmlRpcResponse();
114 Hashtable requestData = (Hashtable)request.Params[0];
115 Hashtable responseData = new Hashtable();
116
117 // TODO: Switch this over to using OpenSim.Framework.Data
118 if (requestData["username"].Equals("admin") && requestData["password"].Equals("supersecret"))
119 {
120 response.IsFault = false;
121 LLUUID new_session = LLUUID.Random();
122 Sessions.Add(new_session);
123 responseData["session_id"] = new_session.ToString();
124 responseData["msg"] = "Login OK";
125 }
126 else
127 {
128 response.IsFault = true;
129 responseData["error"] = "Invalid username or password";
130 }
131
132 response.Value = responseData;
133 return response;
134
135 }
136
137 }
138}
diff --git a/OpenSim/Grid/Framework.Manager/GridServerManager.cs b/OpenSim/Grid/Framework.Manager/GridServerManager.cs
new file mode 100644
index 0000000..67cd35d
--- /dev/null
+++ b/OpenSim/Grid/Framework.Manager/GridServerManager.cs
@@ -0,0 +1,93 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28
29using System;
30using System.Collections;
31using System.Threading;
32using libsecondlife;
33using Nwc.XmlRpc;
34
35namespace OpenSim.Framework.Manager {
36
37 /// <summary>
38 /// A remote management system for the grid server
39 /// </summary>
40 public class GridServerManager
41 {
42 /// <summary>
43 /// Triggers events from the grid manager
44 /// </summary>
45 public static GridManagerCallback thecallback;
46
47 /// <summary>
48 /// Security keys
49 /// </summary>
50 public static string sendkey;
51 public static string recvkey;
52
53 /// <summary>
54 /// Disconnects the grid server and shuts it down
55 /// </summary>
56 /// <param name="request">XmlRpc Request</param>
57 /// <returns>An XmlRpc response containing either a "msg" or an "error"</returns>
58 public static XmlRpcResponse XmlRpcShutdownMethod(XmlRpcRequest request)
59 {
60 XmlRpcResponse response = new XmlRpcResponse();
61 Hashtable requestData = (Hashtable)request.Params[0];
62 Hashtable responseData = new Hashtable();
63
64 if(requestData.ContainsKey("session_id")) {
65 if(GridManagementAgent.SessionExists(new LLUUID((string)requestData["session_id"]))) {
66 responseData["msg"]="Shutdown command accepted";
67 (new Thread(new ThreadStart(ShutdownServer))).Start();
68 } else {
69 response.IsFault=true;
70 responseData["error"]="bad session ID";
71 }
72 } else {
73 response.IsFault=true;
74 responseData["error"]="no session ID";
75 }
76
77 response.Value = responseData;
78 return response;
79 }
80
81 /// <summary>
82 /// Shuts down the grid server
83 /// </summary>
84 public static void ShutdownServer()
85 {
86 Console.WriteLine("Shutting down the grid server - recieved a grid manager request");
87 Console.WriteLine("Terminating in three seconds...");
88 Thread.Sleep(3000);
89 thecallback("shutdown");
90 }
91 }
92}
93
diff --git a/OpenSim/Grid/GridServer.Config/AssemblyInfo.cs b/OpenSim/Grid/GridServer.Config/AssemblyInfo.cs
new file mode 100644
index 0000000..39c9e8f
--- /dev/null
+++ b/OpenSim/Grid/GridServer.Config/AssemblyInfo.cs
@@ -0,0 +1,56 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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// Information about this assembly is defined by the following
31// attributes.
32//
33// change them to the information which is associated with the assembly
34// you compile.
35
36[assembly: AssemblyTitle("GridConfig")]
37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("GridConfig")]
41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")]
44
45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)]
48
49// The assembly version has following format :
50//
51// Major.Minor.Build.Revision
52//
53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default):
55
56[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Grid/GridServer.Config/DbGridConfig.cs b/OpenSim/Grid/GridServer.Config/DbGridConfig.cs
new file mode 100644
index 0000000..4acf81d
--- /dev/null
+++ b/OpenSim/Grid/GridServer.Config/DbGridConfig.cs
@@ -0,0 +1,160 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 Db4objects.Db4o;
30using OpenSim.Framework.Console;
31using OpenSim.Framework.Interfaces;
32
33namespace OpenGrid.Config.GridConfigDb4o
34{
35 /// <summary>
36 /// A grid configuration interface for returning the DB4o Config Provider
37 /// </summary>
38 public class Db40ConfigPlugin: IGridConfig
39 {
40 /// <summary>
41 /// Loads and returns a configuration objeect
42 /// </summary>
43 /// <returns>A grid configuration object</returns>
44 public GridConfig GetConfigObject()
45 {
46 MainLog.Instance.Verbose("Loading Db40Config dll");
47 return ( new DbGridConfig());
48 }
49 }
50
51 /// <summary>
52 /// A DB4o based Gridserver configuration object
53 /// </summary>
54 public class DbGridConfig : GridConfig
55 {
56 /// <summary>
57 /// The DB4o Database
58 /// </summary>
59 private IObjectContainer db;
60
61 /// <summary>
62 /// User configuration for the Grid Config interfaces
63 /// </summary>
64 public void LoadDefaults() {
65 MainLog.Instance.Notice("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings");
66
67 // About the grid options
68 this.GridOwner = MainLog.Instance.CmdPrompt("Grid owner", "OGS development team");
69
70 // Asset Options
71 this.DefaultAssetServer = MainLog.Instance.CmdPrompt("Default asset server","http://127.0.0.1:8003/");
72 this.AssetSendKey = MainLog.Instance.CmdPrompt("Key to send to asset server","null");
73 this.AssetRecvKey = MainLog.Instance.CmdPrompt("Key to expect from asset server","null");
74
75 // User Server Options
76 this.DefaultUserServer = MainLog.Instance.CmdPrompt("Default user server","http://127.0.0.1:8002/");
77 this.UserSendKey = MainLog.Instance.CmdPrompt("Key to send to user server","null");
78 this.UserRecvKey = MainLog.Instance.CmdPrompt("Key to expect from user server","null");
79
80 // Region Server Options
81 this.SimSendKey = MainLog.Instance.CmdPrompt("Key to send to sims","null");
82 this.SimRecvKey = MainLog.Instance.CmdPrompt("Key to expect from sims","null");
83 }
84
85 /// <summary>
86 /// Initialises a new configuration object
87 /// </summary>
88 public override void InitConfig() {
89 try {
90 // Perform Db4o initialisation
91 db = Db4oFactory.OpenFile("opengrid.yap");
92
93 // Locate the grid configuration object
94 IObjectSet result = db.Get(typeof(DbGridConfig));
95 // Found?
96 if(result.Count==1) {
97 MainLog.Instance.Verbose("Config.cs:InitConfig() - Found a GridConfig object in the local database, loading");
98 foreach (DbGridConfig cfg in result) {
99 // Import each setting into this class
100 // Grid Settings
101 this.GridOwner=cfg.GridOwner;
102 // Asset Settings
103 this.DefaultAssetServer=cfg.DefaultAssetServer;
104 this.AssetSendKey=cfg.AssetSendKey;
105 this.AssetRecvKey=cfg.AssetRecvKey;
106 // User Settings
107 this.DefaultUserServer=cfg.DefaultUserServer;
108 this.UserSendKey=cfg.UserSendKey;
109 this.UserRecvKey=cfg.UserRecvKey;
110 // Region Settings
111 this.SimSendKey=cfg.SimSendKey;
112 this.SimRecvKey=cfg.SimRecvKey;
113 }
114 // Create a new configuration object from this class
115 } else {
116 MainLog.Instance.Verbose("Config.cs:InitConfig() - Could not find object in database, loading precompiled defaults");
117
118 // Load default settings into this class
119 LoadDefaults();
120
121 // Saves to the database file...
122 MainLog.Instance.Verbose( "Writing out default settings to local database");
123 db.Set(this);
124
125 // Closes file locks
126 db.Close();
127 }
128 } catch(Exception e) {
129 MainLog.Instance.Warn("Config.cs:InitConfig() - Exception occured");
130 MainLog.Instance.Warn(e.ToString());
131 }
132
133 // Grid Settings
134 MainLog.Instance.Verbose("Grid settings loaded:");
135 MainLog.Instance.Verbose("Grid owner: " + this.GridOwner);
136
137 // Asset Settings
138 MainLog.Instance.Verbose("Default asset server: " + this.DefaultAssetServer);
139 MainLog.Instance.Verbose("Key to send to asset server: " + this.AssetSendKey);
140 MainLog.Instance.Verbose("Key to expect from asset server: " + this.AssetRecvKey);
141
142 // User Settings
143 MainLog.Instance.Verbose("Default user server: " + this.DefaultUserServer);
144 MainLog.Instance.Verbose("Key to send to user server: " + this.UserSendKey);
145 MainLog.Instance.Verbose("Key to expect from user server: " + this.UserRecvKey);
146
147 // Region Settings
148 MainLog.Instance.Verbose("Key to send to sims: " + this.SimSendKey);
149 MainLog.Instance.Verbose("Key to expect from sims: " + this.SimRecvKey);
150 }
151
152 /// <summary>
153 /// Closes down the database and releases filesystem locks
154 /// </summary>
155 public void Shutdown() {
156 db.Close();
157 }
158 }
159
160}
diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs
new file mode 100644
index 0000000..1f97f53
--- /dev/null
+++ b/OpenSim/Grid/GridServer/GridManager.cs
@@ -0,0 +1,703 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Reflection;
32using System.Xml;
33using libsecondlife;
34using Nwc.XmlRpc;
35using OpenSim.Framework.Console;
36using OpenSim.Framework.Data;
37using OpenSim.Framework.Interfaces;
38using OpenSim.Framework.Utilities;
39
40namespace OpenSim.Grid.GridServer
41{
42 class GridManager
43 {
44 Dictionary<string, IGridData> _plugins = new Dictionary<string, IGridData>();
45 Dictionary<string, ILogData> _logplugins = new Dictionary<string, ILogData>();
46
47 public GridConfig config;
48
49 /// <summary>
50 /// Adds a new grid server plugin - grid servers will be requested in the order they were loaded.
51 /// </summary>
52 /// <param name="FileName">The filename to the grid server plugin DLL</param>
53 public void AddPlugin(string FileName)
54 {
55 MainLog.Instance.Verbose("Storage: Attempting to load " + FileName);
56 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
57
58 MainLog.Instance.Verbose("Storage: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
59 foreach (Type pluginType in pluginAssembly.GetTypes())
60 {
61 if (!pluginType.IsAbstract)
62 {
63 // Regions go here
64 Type typeInterface = pluginType.GetInterface("IGridData", true);
65
66 if (typeInterface != null)
67 {
68 IGridData plug = (IGridData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
69 plug.Initialise();
70 this._plugins.Add(plug.getName(), plug);
71 MainLog.Instance.Verbose("Storage: Added IGridData Interface");
72 }
73
74 typeInterface = null;
75
76 // Logs go here
77 typeInterface = pluginType.GetInterface("ILogData", true);
78
79 if (typeInterface != null)
80 {
81 ILogData plug = (ILogData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
82 plug.Initialise();
83 this._logplugins.Add(plug.getName(), plug);
84 MainLog.Instance.Verbose( "Storage: Added ILogData Interface");
85 }
86
87 typeInterface = null;
88 }
89 }
90
91 pluginAssembly = null;
92 }
93
94 /// <summary>
95 /// Logs a piece of information to the database
96 /// </summary>
97 /// <param name="target">What you were operating on (in grid server, this will likely be the region UUIDs)</param>
98 /// <param name="method">Which method is being called?</param>
99 /// <param name="args">What arguments are being passed?</param>
100 /// <param name="priority">How high priority is this? 1 = Max, 6 = Verbose</param>
101 /// <param name="message">The message to log</param>
102 private void logToDB(string target, string method, string args, int priority, string message)
103 {
104 foreach (KeyValuePair<string, ILogData> kvp in _logplugins)
105 {
106 try
107 {
108 kvp.Value.saveLog("Gridserver", target, method, args, priority, message);
109 }
110 catch (Exception)
111 {
112 MainLog.Instance.Warn("Storage: unable to write log via " + kvp.Key);
113 }
114 }
115 }
116
117 /// <summary>
118 /// Returns a region by argument
119 /// </summary>
120 /// <param name="uuid">A UUID key of the region to return</param>
121 /// <returns>A SimProfileData for the region</returns>
122 public SimProfileData getRegion(LLUUID uuid)
123 {
124 foreach(KeyValuePair<string,IGridData> kvp in _plugins) {
125 try
126 {
127 return kvp.Value.GetProfileByLLUUID(uuid);
128 }
129 catch (Exception e)
130 {
131 MainLog.Instance.Warn("Message from Storage: " + e.Message);
132 }
133 }
134 return null;
135 }
136
137 /// <summary>
138 /// Returns a region by argument
139 /// </summary>
140 /// <param name="uuid">A regionHandle of the region to return</param>
141 /// <returns>A SimProfileData for the region</returns>
142 public SimProfileData getRegion(ulong handle)
143 {
144 foreach (KeyValuePair<string, IGridData> kvp in _plugins)
145 {
146 try
147 {
148 return kvp.Value.GetProfileByHandle(handle);
149 }
150 catch
151 {
152 MainLog.Instance.Warn("Storage: Unable to find region " + handle.ToString() + " via " + kvp.Key);
153 }
154 }
155 return null;
156 }
157
158 public Dictionary<ulong, SimProfileData> getRegions(uint xmin, uint ymin, uint xmax, uint ymax)
159 {
160 Dictionary<ulong, SimProfileData> regions = new Dictionary<ulong, SimProfileData>();
161
162 SimProfileData[] neighbours;
163
164 foreach (KeyValuePair<string, IGridData> kvp in _plugins)
165 {
166 try
167 {
168 neighbours = kvp.Value.GetProfilesInRange(xmin, ymin, xmax, ymax);
169 foreach (SimProfileData neighbour in neighbours)
170 {
171 regions[neighbour.regionHandle] = neighbour;
172 }
173 }
174 catch
175 {
176 MainLog.Instance.Warn("Storage: Unable to query regionblock via " + kvp.Key);
177 }
178 }
179
180 return regions;
181 }
182
183
184
185 /// <summary>
186 /// Returns a XML String containing a list of the neighbouring regions
187 /// </summary>
188 /// <param name="reqhandle">The regionhandle for the center sim</param>
189 /// <returns>An XML string containing neighbour entities</returns>
190 public string GetXMLNeighbours(ulong reqhandle)
191 {
192 string response = "";
193 SimProfileData central_region = getRegion(reqhandle);
194 SimProfileData neighbour;
195 for (int x = -1; x < 2; x++) for (int y = -1; y < 2; y++)
196 {
197 if (getRegion(Util.UIntsToLong((uint)((central_region.regionLocX + x) * 256), (uint)(central_region.regionLocY + y) * 256)) != null)
198 {
199 neighbour = getRegion(Util.UIntsToLong((uint)((central_region.regionLocX + x) * 256), (uint)(central_region.regionLocY + y) * 256));
200 response += "<neighbour>";
201 response += "<sim_ip>" + neighbour.serverIP + "</sim_ip>";
202 response += "<sim_port>" + neighbour.serverPort.ToString() + "</sim_port>";
203 response += "<locx>" + neighbour.regionLocX.ToString() + "</locx>";
204 response += "<locy>" + neighbour.regionLocY.ToString() + "</locy>";
205 response += "<regionhandle>" + neighbour.regionHandle.ToString() + "</regionhandle>";
206 response += "</neighbour>";
207
208 }
209 }
210 return response;
211 }
212
213 /// <summary>
214 /// Performed when a region connects to the grid server initially.
215 /// </summary>
216 /// <param name="request">The XMLRPC Request</param>
217 /// <returns>Startup parameters</returns>
218 public XmlRpcResponse XmlRpcSimulatorLoginMethod(XmlRpcRequest request)
219 {
220
221 XmlRpcResponse response = new XmlRpcResponse();
222 Hashtable responseData = new Hashtable();
223 response.Value = responseData;
224
225 SimProfileData TheSim = null;
226 Hashtable requestData = (Hashtable)request.Params[0];
227
228 if (requestData.ContainsKey("UUID"))
229 {
230 TheSim = getRegion(new LLUUID((string)requestData["UUID"]));
231
232 logToDB((new LLUUID((string)requestData["UUID"])).ToStringHyphenated(),"XmlRpcSimulatorLoginMethod","", 5,"Region attempting login with UUID.");
233 }
234 else if (requestData.ContainsKey("region_handle"))
235 {
236
237 TheSim = getRegion((ulong)Convert.ToUInt64(requestData["region_handle"]));
238 logToDB((string)requestData["region_handle"], "XmlRpcSimulatorLoginMethod", "", 5, "Region attempting login with regionHandle.");
239 }
240 else
241 {
242 responseData["error"] = "No UUID or region_handle passed to grid server - unable to connect you";
243 return response;
244 }
245
246 if (TheSim == null) // Shouldnt this be in the REST Simulator Set method?
247 {
248 //NEW REGION
249 TheSim = new SimProfileData();
250
251 TheSim.regionRecvKey = config.SimRecvKey;
252 TheSim.regionSendKey = config.SimSendKey;
253 TheSim.regionSecret = config.SimRecvKey;
254 TheSim.regionDataURI = "";
255 TheSim.regionAssetURI = config.DefaultAssetServer;
256 TheSim.regionAssetRecvKey = config.AssetRecvKey;
257 TheSim.regionAssetSendKey = config.AssetSendKey;
258 TheSim.regionUserURI = config.DefaultUserServer;
259 TheSim.regionUserSendKey = config.UserSendKey;
260 TheSim.regionUserRecvKey = config.UserRecvKey;
261
262 TheSim.serverIP = (string)requestData["sim_ip"];
263 TheSim.serverPort = Convert.ToUInt32((string)requestData["sim_port"]);
264 TheSim.httpPort = Convert.ToUInt32((string)requestData["http_port"]);
265 TheSim.remotingPort = Convert.ToUInt32((string)requestData["remoting_port"]);
266 TheSim.regionLocX = Convert.ToUInt32((string)requestData["region_locx"]);
267 TheSim.regionLocY = Convert.ToUInt32((string)requestData["region_locy"]);
268 TheSim.regionLocZ = 0;
269 TheSim.regionMapTextureID = new LLUUID((string)requestData["map-image-id"]);
270
271 TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * 256), (TheSim.regionLocY * 256));
272 System.Console.WriteLine("adding region " + TheSim.regionLocX + " , " + TheSim.regionLocY + " , " + TheSim.regionHandle);
273 TheSim.serverURI = "http://" + TheSim.serverIP + ":" + TheSim.serverPort + "/";
274 TheSim.httpServerURI = "http://" + TheSim.serverIP + ":" + TheSim.httpPort + "/";
275
276 Console.WriteLine("NEW SIM: " + TheSim.serverURI);
277 TheSim.regionName = (string)requestData["sim_name"];
278 TheSim.UUID = new LLUUID((string)requestData["UUID"]);
279
280 foreach (KeyValuePair<string, IGridData> kvp in _plugins)
281 {
282 try
283 {
284 DataResponse insertResponse = kvp.Value.AddProfile(TheSim);
285 switch(insertResponse)
286 {
287 case DataResponse.RESPONSE_OK:
288 OpenSim.Framework.Console.MainLog.Instance.Verbose("New sim creation successful: " + TheSim.regionName);
289 break;
290 case DataResponse.RESPONSE_ERROR:
291 OpenSim.Framework.Console.MainLog.Instance.Warn("New sim creation failed (Error): " + TheSim.regionName);
292 break;
293 case DataResponse.RESPONSE_INVALIDCREDENTIALS:
294 OpenSim.Framework.Console.MainLog.Instance.Warn("New sim creation failed (Invalid Credentials): " + TheSim.regionName);
295 break;
296 case DataResponse.RESPONSE_AUTHREQUIRED:
297 OpenSim.Framework.Console.MainLog.Instance.Warn("New sim creation failed (Authentication Required): " + TheSim.regionName);
298 break;
299 }
300
301 }
302 catch (Exception e)
303 {
304 OpenSim.Framework.Console.MainLog.Instance.Warn("Storage: Unable to add region " + TheSim.UUID.ToStringHyphenated() + " via " + kvp.Key);
305 }
306 }
307
308
309 if (getRegion(TheSim.regionHandle) == null)
310 {
311 responseData["error"] = "Unable to add new region";
312 return response;
313 }
314 }
315
316
317 ArrayList SimNeighboursData = new ArrayList();
318
319 SimProfileData neighbour;
320 Hashtable NeighbourBlock;
321
322 bool fastMode = false; // Only compatible with MySQL right now
323
324 if (fastMode)
325 {
326 Dictionary<ulong, SimProfileData> neighbours = getRegions(TheSim.regionLocX - 1, TheSim.regionLocY - 1, TheSim.regionLocX + 1, TheSim.regionLocY + 1);
327
328 foreach (KeyValuePair<ulong, SimProfileData> aSim in neighbours)
329 {
330 NeighbourBlock = new Hashtable();
331 NeighbourBlock["sim_ip"] = aSim.Value.serverIP.ToString();
332 NeighbourBlock["sim_port"] = aSim.Value.serverPort.ToString();
333 NeighbourBlock["region_locx"] = aSim.Value.regionLocX.ToString();
334 NeighbourBlock["region_locy"] = aSim.Value.regionLocY.ToString();
335 NeighbourBlock["UUID"] = aSim.Value.UUID.ToString();
336
337 if (aSim.Value.UUID != TheSim.UUID)
338 SimNeighboursData.Add(NeighbourBlock);
339 }
340 }
341 else
342 {
343 for (int x = -1; x < 2; x++) for (int y = -1; y < 2; y++)
344 {
345 if (getRegion(Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256), (uint)(TheSim.regionLocY + y) * 256)) != null)
346 {
347 neighbour = getRegion(Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256), (uint)(TheSim.regionLocY + y) * 256));
348
349 NeighbourBlock = new Hashtable();
350 NeighbourBlock["sim_ip"] = neighbour.serverIP;
351 NeighbourBlock["sim_port"] = neighbour.serverPort.ToString();
352 NeighbourBlock["region_locx"] = neighbour.regionLocX.ToString();
353 NeighbourBlock["region_locy"] = neighbour.regionLocY.ToString();
354 NeighbourBlock["UUID"] = neighbour.UUID.ToString();
355
356 if (neighbour.UUID != TheSim.UUID) SimNeighboursData.Add(NeighbourBlock);
357 }
358 }
359 }
360
361 responseData["UUID"] = TheSim.UUID.ToString();
362 responseData["region_locx"] = TheSim.regionLocX.ToString();
363 responseData["region_locy"] = TheSim.regionLocY.ToString();
364 responseData["regionname"] = TheSim.regionName;
365 responseData["estate_id"] = "1";
366 responseData["neighbours"] = SimNeighboursData;
367
368 responseData["sim_ip"] = TheSim.serverIP;
369 responseData["sim_port"] = TheSim.serverPort.ToString();
370 responseData["asset_url"] = TheSim.regionAssetURI;
371 responseData["asset_sendkey"] = TheSim.regionAssetSendKey;
372 responseData["asset_recvkey"] = TheSim.regionAssetRecvKey;
373 responseData["user_url"] = TheSim.regionUserURI;
374 responseData["user_sendkey"] = TheSim.regionUserSendKey;
375 responseData["user_recvkey"] = TheSim.regionUserRecvKey;
376 responseData["authkey"] = TheSim.regionSecret;
377
378 // New! If set, use as URL to local sim storage (ie http://remotehost/region.yap)
379 responseData["data_uri"] = TheSim.regionDataURI;
380
381
382 return response;
383 }
384
385 public XmlRpcResponse XmlRpcSimulatorDataRequestMethod(XmlRpcRequest request)
386 {
387 Hashtable requestData = (Hashtable)request.Params[0];
388 Hashtable responseData = new Hashtable();
389 SimProfileData simData = null;
390 if (requestData.ContainsKey("region_UUID"))
391 {
392 simData = getRegion(new LLUUID((string)requestData["region_UUID"]));
393 }
394 else if (requestData.ContainsKey("region_handle"))
395 {
396 Console.WriteLine("requesting data for region " + (string)requestData["region_handle"]);
397 simData = getRegion(Convert.ToUInt64((string)requestData["region_handle"]));
398 }
399
400 if (simData == null)
401 {
402 //Sim does not exist
403 Console.WriteLine("region not found");
404 responseData["error"] = "Sim does not exist";
405 }
406 else
407 {
408 Console.WriteLine("found region");
409 responseData["sim_ip"] = simData.serverIP;
410 responseData["sim_port"] = simData.serverPort.ToString();
411 responseData["http_port"] = simData.httpPort.ToString();
412 responseData["remoting_port"] = simData.remotingPort.ToString();
413 responseData["region_locx"] = simData.regionLocX.ToString() ;
414 responseData["region_locy"] = simData.regionLocY.ToString();
415 responseData["region_UUID"] = simData.UUID.UUID.ToString();
416 responseData["region_name"] = simData.regionName;
417 }
418
419 XmlRpcResponse response = new XmlRpcResponse();
420 response.Value = responseData;
421 return response;
422 }
423
424 public XmlRpcResponse XmlRpcMapBlockMethod(XmlRpcRequest request)
425 {
426 int xmin=980, ymin=980, xmax=1020, ymax=1020;
427
428 Hashtable requestData = (Hashtable)request.Params[0];
429 if (requestData.ContainsKey("xmin"))
430 {
431 xmin = (Int32)requestData["xmin"];
432 }
433 if (requestData.ContainsKey("ymin"))
434 {
435 ymin = (Int32)requestData["ymin"];
436 }
437 if (requestData.ContainsKey("xmax"))
438 {
439 xmax = (Int32)requestData["xmax"];
440 }
441 if (requestData.ContainsKey("ymax"))
442 {
443 ymax = (Int32)requestData["ymax"];
444 }
445
446 XmlRpcResponse response = new XmlRpcResponse();
447 Hashtable responseData = new Hashtable();
448 response.Value = responseData;
449 IList simProfileList = new ArrayList();
450
451 bool fastMode = false; // MySQL Only
452
453 if (fastMode)
454 {
455 Dictionary<ulong, SimProfileData> neighbours = getRegions((uint)xmin, (uint)ymin, (uint)xmax, (uint)ymax);
456
457 foreach (KeyValuePair<ulong, SimProfileData> aSim in neighbours)
458 {
459 Hashtable simProfileBlock = new Hashtable();
460 simProfileBlock["x"] = aSim.Value.regionLocX.ToString();
461 simProfileBlock["y"] = aSim.Value.regionLocY.ToString();
462 System.Console.WriteLine("send neighbour info for " + aSim.Value.regionLocX.ToString() + " , " + aSim.Value.regionLocY.ToString());
463 simProfileBlock["name"] = aSim.Value.regionName;
464 simProfileBlock["access"] = 21;
465 simProfileBlock["region-flags"] = 512;
466 simProfileBlock["water-height"] = 0;
467 simProfileBlock["agents"] = 1;
468 simProfileBlock["map-image-id"] = aSim.Value.regionMapTextureID.ToString();
469
470 // For Sugilite compatibility
471 simProfileBlock["regionhandle"] = aSim.Value.regionHandle.ToString();
472 simProfileBlock["sim_ip"] = aSim.Value.serverIP.ToString();
473 simProfileBlock["sim_port"] = aSim.Value.serverPort.ToString();
474 simProfileBlock["sim_uri"] = aSim.Value.serverURI.ToString();
475 simProfileBlock["uuid"] = aSim.Value.UUID.ToStringHyphenated();
476
477 simProfileList.Add(simProfileBlock);
478 }
479 MainLog.Instance.Verbose("World map request processed, returned " + simProfileList.Count.ToString() + " region(s) in range via FastMode");
480 }
481 else
482 {
483 SimProfileData simProfile;
484 for (int x = xmin; x < xmax+1; x++)
485 {
486 for (int y = ymin; y < ymax+1; y++)
487 {
488 ulong regHandle = Helpers.UIntsToLong((uint)(x * 256), (uint)(y * 256));
489 simProfile = getRegion(regHandle);
490 if (simProfile != null)
491 {
492 Hashtable simProfileBlock = new Hashtable();
493 simProfileBlock["x"] = x;
494 simProfileBlock["y"] = y;
495 simProfileBlock["name"] = simProfile.regionName;
496 simProfileBlock["access"] = 0;
497 simProfileBlock["region-flags"] = 0;
498 simProfileBlock["water-height"] = 20;
499 simProfileBlock["agents"] = 1;
500 simProfileBlock["map-image-id"] = simProfile.regionMapTextureID.ToStringHyphenated();
501
502 // For Sugilite compatibility
503 simProfileBlock["regionhandle"] = simProfile.regionHandle.ToString();
504 simProfileBlock["sim_ip"] = simProfile.serverIP.ToString();
505 simProfileBlock["sim_port"] = simProfile.serverPort.ToString();
506 simProfileBlock["sim_uri"] = simProfile.serverURI.ToString();
507 simProfileBlock["uuid"] = simProfile.UUID.ToStringHyphenated();
508
509 simProfileList.Add(simProfileBlock);
510 }
511 }
512 }
513 MainLog.Instance.Verbose("World map request processed, returned " + simProfileList.Count.ToString() + " region(s) in range via Standard Mode");
514 }
515
516 responseData["sim-profiles"] = simProfileList;
517
518 return response;
519 }
520
521
522
523 /// <summary>
524 /// Performs a REST Get Operation
525 /// </summary>
526 /// <param name="request"></param>
527 /// <param name="path"></param>
528 /// <param name="param"></param>
529 /// <returns></returns>
530 public string RestGetRegionMethod(string request, string path, string param)
531 {
532 return RestGetSimMethod("", "/sims/", param);
533 }
534
535 /// <summary>
536 /// Performs a REST Set Operation
537 /// </summary>
538 /// <param name="request"></param>
539 /// <param name="path"></param>
540 /// <param name="param"></param>
541 /// <returns></returns>
542 public string RestSetRegionMethod(string request, string path, string param)
543 {
544 return RestSetSimMethod("", "/sims/", param);
545 }
546
547 /// <summary>
548 /// Returns information about a sim via a REST Request
549 /// </summary>
550 /// <param name="request"></param>
551 /// <param name="path"></param>
552 /// <param name="param"></param>
553 /// <returns>Information about the sim in XML</returns>
554 public string RestGetSimMethod(string request, string path, string param)
555 {
556 string respstring = String.Empty;
557
558 SimProfileData TheSim;
559 LLUUID UUID = new LLUUID(param);
560 TheSim = getRegion(UUID);
561
562 if (!(TheSim == null))
563 {
564 respstring = "<Root>";
565 respstring += "<authkey>" + TheSim.regionSendKey + "</authkey>";
566 respstring += "<sim>";
567 respstring += "<uuid>" + TheSim.UUID.ToString() + "</uuid>";
568 respstring += "<regionname>" + TheSim.regionName + "</regionname>";
569 respstring += "<sim_ip>" + TheSim.serverIP + "</sim_ip>";
570 respstring += "<sim_port>" + TheSim.serverPort.ToString() + "</sim_port>";
571 respstring += "<region_locx>" + TheSim.regionLocX.ToString() + "</region_locx>";
572 respstring += "<region_locy>" + TheSim.regionLocY.ToString() + "</region_locy>";
573 respstring += "<estate_id>1</estate_id>";
574 respstring += "</sim>";
575 respstring += "</Root>";
576 }
577
578 return respstring;
579 }
580
581 /// <summary>
582 /// Creates or updates a sim via a REST Method Request
583 /// BROKEN with SQL Update
584 /// </summary>
585 /// <param name="request"></param>
586 /// <param name="path"></param>
587 /// <param name="param"></param>
588 /// <returns>"OK" or an error</returns>
589 public string RestSetSimMethod(string request, string path, string param)
590 {
591 Console.WriteLine("Processing region update via REST method");
592 SimProfileData TheSim;
593 TheSim = getRegion(new LLUUID(param));
594 if ((TheSim) == null)
595 {
596 TheSim = new SimProfileData();
597 LLUUID UUID = new LLUUID(param);
598 TheSim.UUID = UUID;
599 TheSim.regionRecvKey = config.SimRecvKey;
600 }
601
602 XmlDocument doc = new XmlDocument();
603 doc.LoadXml(request);
604 XmlNode rootnode = doc.FirstChild;
605 XmlNode authkeynode = rootnode.ChildNodes[0];
606 if (authkeynode.Name != "authkey")
607 {
608 return "ERROR! bad XML - expected authkey tag";
609 }
610
611 XmlNode simnode = rootnode.ChildNodes[1];
612 if (simnode.Name != "sim")
613 {
614 return "ERROR! bad XML - expected sim tag";
615 }
616
617 //TheSim.regionSendKey = Cfg;
618 TheSim.regionRecvKey = config.SimRecvKey;
619 TheSim.regionSendKey = config.SimSendKey;
620 TheSim.regionSecret = config.SimRecvKey;
621 TheSim.regionDataURI = "";
622 TheSim.regionAssetURI = config.DefaultAssetServer;
623 TheSim.regionAssetRecvKey = config.AssetRecvKey;
624 TheSim.regionAssetSendKey = config.AssetSendKey;
625 TheSim.regionUserURI = config.DefaultUserServer;
626 TheSim.regionUserSendKey = config.UserSendKey;
627 TheSim.regionUserRecvKey = config.UserRecvKey;
628
629
630 for (int i = 0; i < simnode.ChildNodes.Count; i++)
631 {
632 switch (simnode.ChildNodes[i].Name)
633 {
634 case "regionname":
635 TheSim.regionName = simnode.ChildNodes[i].InnerText;
636 break;
637
638 case "sim_ip":
639 TheSim.serverIP = simnode.ChildNodes[i].InnerText;
640 break;
641
642 case "sim_port":
643 TheSim.serverPort = Convert.ToUInt32(simnode.ChildNodes[i].InnerText);
644 break;
645
646 case "region_locx":
647 TheSim.regionLocX = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText);
648 TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * 256), (TheSim.regionLocY * 256));
649 break;
650
651 case "region_locy":
652 TheSim.regionLocY = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText);
653 TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * 256), (TheSim.regionLocY * 256));
654 break;
655 }
656 }
657
658 TheSim.serverURI = "http://" + TheSim.serverIP + ":" + TheSim.serverPort + "/";
659
660 bool requirePublic = false;
661
662 if (requirePublic && (TheSim.serverIP.StartsWith("172.16") || TheSim.serverIP.StartsWith("192.168") || TheSim.serverIP.StartsWith("10.") || TheSim.serverIP.StartsWith("0.") || TheSim.serverIP.StartsWith("255.")))
663 {
664 return "ERROR! Servers must register with public addresses.";
665 }
666
667
668 try
669 {
670 MainLog.Instance.Verbose("Updating / adding via " + _plugins.Count + " storage provider(s) registered.");
671 foreach (KeyValuePair<string, IGridData> kvp in _plugins)
672 {
673 try
674 {
675 //Check reservations
676 ReservationData reserveData = kvp.Value.GetReservationAtPoint(TheSim.regionLocX, TheSim.regionLocY);
677 if ((reserveData != null && reserveData.gridRecvKey == TheSim.regionRecvKey) || (reserveData == null && authkeynode.InnerText != TheSim.regionRecvKey))
678 {
679 kvp.Value.AddProfile(TheSim);
680 MainLog.Instance.Verbose("New sim added to grid (" + TheSim.regionName + ")");
681 logToDB(TheSim.UUID.ToStringHyphenated(), "RestSetSimMethod", "", 5, "Region successfully updated and connected to grid.");
682 }
683 else
684 {
685 MainLog.Instance.Warn("Unable to update region (RestSetSimMethod): Incorrect reservation auth key.");// Wanted: " + reserveData.gridRecvKey + ", Got: " + TheSim.regionRecvKey + ".");
686 return "Unable to update region (RestSetSimMethod): Incorrect auth key.";
687 }
688 }
689 catch (Exception e)
690 {
691 MainLog.Instance.Verbose("getRegionPlugin Handle " + kvp.Key + " unable to add new sim: " + e.ToString());
692 }
693 }
694 return "OK";
695 }
696 catch (Exception e)
697 {
698 return "ERROR! Could not save to database! (" + e.ToString() + ")";
699 }
700 }
701
702 }
703}
diff --git a/OpenSim/Grid/GridServer/Main.cs b/OpenSim/Grid/GridServer/Main.cs
new file mode 100644
index 0000000..dc5e4fa
--- /dev/null
+++ b/OpenSim/Grid/GridServer/Main.cs
@@ -0,0 +1,258 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28
29using System;
30using System.Reflection;
31using System.Threading;
32using System.Timers;
33using OpenSim.Framework.Console;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Servers;
36using OpenSim.GenericConfig;
37using Timer=System.Timers.Timer;
38
39namespace OpenSim.Grid.GridServer
40{
41 /// <summary>
42 /// </summary>
43 public class OpenGrid_Main : conscmd_callback
44 {
45 private string ConfigDll = "OpenSim.Grid.GridServer.Config.dll";
46 private string GridDll = "OpenSim.Framework.Data.MySQL.dll";
47 public GridConfig Cfg;
48
49 public static OpenGrid_Main thegrid;
50 protected IGenericConfig localXMLConfig;
51
52 public static bool setuponly;
53
54 //public LLUUID highestUUID;
55
56 // private SimProfileManager m_simProfileManager;
57
58 private GridManager m_gridManager;
59
60 private LogBase m_console;
61
62 [STAThread]
63 public static void Main(string[] args)
64 {
65 if (args.Length > 0)
66 {
67 if (args[0] == "-setuponly") setuponly = true;
68 }
69 Console.WriteLine("Starting...\n");
70
71 thegrid = new OpenGrid_Main();
72 thegrid.Startup();
73
74 thegrid.Work();
75 }
76
77 private void Work()
78 {
79 m_console.Notice("Enter help for a list of commands\n");
80
81 while (true)
82 {
83 m_console.MainLogPrompt();
84 }
85 }
86
87 private OpenGrid_Main()
88 {
89 m_console = new LogBase("opengrid-gridserver-console.log", "OpenGrid", this, false);
90 MainLog.Instance = m_console;
91
92
93 }
94
95 public void managercallback(string cmd)
96 {
97 switch (cmd)
98 {
99 case "shutdown":
100 RunCmd("shutdown", new string[0]);
101 break;
102 }
103 }
104
105
106 public void Startup()
107 {
108 this.localXMLConfig = new XmlConfig("GridServerConfig.xml");
109 this.localXMLConfig.LoadData();
110 this.ConfigDB(this.localXMLConfig);
111 this.localXMLConfig.Close();
112
113 m_console.Verbose( "Main.cs:Startup() - Loading configuration");
114 Cfg = this.LoadConfigDll(this.ConfigDll);
115 Cfg.InitConfig();
116 if (setuponly) Environment.Exit(0);
117
118 m_console.Verbose( "Main.cs:Startup() - Connecting to Storage Server");
119 m_gridManager = new GridManager();
120 m_gridManager.AddPlugin(GridDll); // Made of win
121 m_gridManager.config = Cfg;
122
123 m_console.Verbose( "Main.cs:Startup() - Starting HTTP process");
124 BaseHttpServer httpServer = new BaseHttpServer(8001);
125 //GridManagementAgent GridManagerAgent = new GridManagementAgent(httpServer, "gridserver", Cfg.SimSendKey, Cfg.SimRecvKey, managercallback);
126
127 httpServer.AddXmlRPCHandler("simulator_login", m_gridManager.XmlRpcSimulatorLoginMethod);
128 httpServer.AddXmlRPCHandler("simulator_data_request", m_gridManager.XmlRpcSimulatorDataRequestMethod);
129 httpServer.AddXmlRPCHandler("map_block", m_gridManager.XmlRpcMapBlockMethod);
130
131 httpServer.AddStreamHandler(new RestStreamHandler("GET", "/sims/", m_gridManager.RestGetSimMethod ));
132 httpServer.AddStreamHandler(new RestStreamHandler("POST", "/sims/", m_gridManager.RestSetSimMethod ));
133
134 httpServer.AddStreamHandler( new RestStreamHandler("GET", "/regions/", m_gridManager.RestGetRegionMethod ));
135 httpServer.AddStreamHandler( new RestStreamHandler("POST","/regions/", m_gridManager.RestSetRegionMethod ));
136
137 //httpServer.AddRestHandler("GET", "/sims/", m_gridManager.RestGetSimMethod);
138 //httpServer.AddRestHandler("POST", "/sims/", m_gridManager.RestSetSimMethod);
139 //httpServer.AddRestHandler("GET", "/regions/", m_gridManager.RestGetRegionMethod);
140 //httpServer.AddRestHandler("POST", "/regions/", m_gridManager.RestSetRegionMethod);
141
142 httpServer.Start();
143
144 m_console.Verbose( "Main.cs:Startup() - Starting sim status checker");
145
146 Timer simCheckTimer = new Timer(3600000 * 3); // 3 Hours between updates.
147 simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims);
148 simCheckTimer.Enabled = true;
149 }
150
151 private GridConfig LoadConfigDll(string dllName)
152 {
153 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
154 GridConfig config = null;
155
156 foreach (Type pluginType in pluginAssembly.GetTypes())
157 {
158 if (pluginType.IsPublic)
159 {
160 if (!pluginType.IsAbstract)
161 {
162 Type typeInterface = pluginType.GetInterface("IGridConfig", true);
163
164 if (typeInterface != null)
165 {
166 IGridConfig plug = (IGridConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
167 config = plug.GetConfigObject();
168 break;
169 }
170
171 typeInterface = null;
172 }
173 }
174 }
175 pluginAssembly = null;
176 return config;
177 }
178
179 public void CheckSims(object sender, ElapsedEventArgs e)
180 {
181 /*
182 foreach (SimProfileBase sim in m_simProfileManager.SimProfiles.Values)
183 {
184 string SimResponse = "";
185 try
186 {
187 WebRequest CheckSim = WebRequest.Create("http://" + sim.sim_ip + ":" + sim.sim_port.ToString() + "/checkstatus/");
188 CheckSim.Method = "GET";
189 CheckSim.ContentType = "text/plaintext";
190 CheckSim.ContentLength = 0;
191
192 StreamWriter stOut = new StreamWriter(CheckSim.GetRequestStream(), System.Text.Encoding.ASCII);
193 stOut.Write("");
194 stOut.Close();
195
196 StreamReader stIn = new StreamReader(CheckSim.GetResponse().GetResponseStream());
197 SimResponse = stIn.ReadToEnd();
198 stIn.Close();
199 }
200 catch
201 {
202 }
203
204 if (SimResponse == "OK")
205 {
206 m_simProfileManager.SimProfiles[sim.UUID].online = true;
207 }
208 else
209 {
210 m_simProfileManager.SimProfiles[sim.UUID].online = false;
211 }
212 }
213 */
214 }
215
216 public void RunCmd(string cmd, string[] cmdparams)
217 {
218 switch (cmd)
219 {
220 case "help":
221 m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
222 break;
223
224 case "shutdown":
225 m_console.Close();
226 Environment.Exit(0);
227 break;
228 }
229 }
230
231 public void Show(string ShowWhat)
232 {
233 }
234
235 private void ConfigDB(IGenericConfig configData)
236 {
237 try
238 {
239 string attri = "";
240 attri = configData.GetAttribute("DataBaseProvider");
241 if (attri == "")
242 {
243 GridDll = "OpenSim.Framework.Data.DB4o.dll";
244 configData.SetAttribute("DataBaseProvider", "OpenSim.Framework.Data.DB4o.dll");
245 }
246 else
247 {
248 GridDll = attri;
249 }
250 configData.Commit();
251 }
252 catch
253 {
254
255 }
256 }
257 }
258}
diff --git a/OpenSim/Grid/GridServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/GridServer/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..62a68a8
--- /dev/null
+++ b/OpenSim/Grid/GridServer/Properties/AssemblyInfo.cs
@@ -0,0 +1,58 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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// General Information about an assembly is controlled through the following
31// set of attributes. Change these attribute values to modify the information
32// associated with an assembly.
33[assembly: AssemblyTitle("OGS-GridServer")]
34[assembly: AssemblyDescription("")]
35[assembly: AssemblyConfiguration("")]
36[assembly: AssemblyCompany("")]
37[assembly: AssemblyProduct("OGS-GridServer")]
38[assembly: AssemblyCopyright("Copyright © 2007")]
39[assembly: AssemblyTrademark("")]
40[assembly: AssemblyCulture("")]
41
42// Setting ComVisible to false makes the types in this assembly not visible
43// to COM components. If you need to access a type in this assembly from
44// COM, set the ComVisible attribute to true on that type.
45[assembly: ComVisible(false)]
46
47// The following GUID is for the ID of the typelib if this project is exposed to COM
48[assembly: Guid("b541b244-3d1d-4625-9003-bc2a3a6a39a4")]
49
50// Version information for an assembly consists of the following four values:
51//
52// Major Version
53// Minor Version
54// Build Number
55// Revision
56//
57[assembly: AssemblyVersion("1.0.0.0")]
58[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Grid/InventoryServer/InventoryManager.cs b/OpenSim/Grid/InventoryServer/InventoryManager.cs
new file mode 100644
index 0000000..9ca9b5e
--- /dev/null
+++ b/OpenSim/Grid/InventoryServer/InventoryManager.cs
@@ -0,0 +1,125 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
32using OpenGrid.Framework.Data;
33using libsecondlife;
34using System.Reflection;
35
36using System.Xml;
37using Nwc.XmlRpc;
38using OpenSim.Framework.Sims;
39using OpenSim.Framework.Inventory;
40using OpenSim.Framework.Utilities;
41
42using System.Security.Cryptography;
43
44namespace OpenGridServices.InventoryServer
45{
46 class InventoryManager
47 {
48 Dictionary<string, IInventoryData> _plugins = new Dictionary<string, IInventoryData>();
49
50 /// <summary>
51 /// Adds a new inventory server plugin - user servers will be requested in the order they were loaded.
52 /// </summary>
53 /// <param name="FileName">The filename to the inventory server plugin DLL</param>
54 public void AddPlugin(string FileName)
55 {
56 OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Invenstorage: Attempting to load " + FileName);
57 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
58
59 OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
60 foreach (Type pluginType in pluginAssembly.GetTypes())
61 {
62 if (!pluginType.IsAbstract)
63 {
64 Type typeInterface = pluginType.GetInterface("IInventoryData", true);
65
66 if (typeInterface != null)
67 {
68 IInventoryData plug = (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
69 plug.Initialise();
70 this._plugins.Add(plug.getName(), plug);
71 OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Invenstorage: Added IUserData Interface");
72 }
73
74 typeInterface = null;
75 }
76 }
77
78 pluginAssembly = null;
79 }
80
81 public List<InventoryFolderBase> getRootFolders(LLUUID user)
82 {
83 foreach (KeyValuePair<string, IInventoryData> kvp in _plugins)
84 {
85 try
86 {
87 return kvp.Value.getUserRootFolders(user);
88 }
89 catch (Exception e)
90 {
91 OpenSim.Framework.Console.MainConsole.Instance.Notice("Unable to get root folders via " + kvp.Key + " (" + e.ToString() + ")");
92 }
93 }
94 return null;
95 }
96
97 public XmlRpcResponse XmlRpcInventoryRequest(XmlRpcRequest request)
98 {
99 XmlRpcResponse response = new XmlRpcResponse();
100 Hashtable requestData = (Hashtable)request.Params[0];
101
102 Hashtable responseData = new Hashtable();
103
104 // Stuff happens here
105
106 if (requestData.ContainsKey("Access-type"))
107 {
108 if (requestData["access-type"] == "rootfolders")
109 {
110// responseData["rootfolders"] =
111 }
112 }
113 else
114 {
115 responseData["error"] = "No access-type specified.";
116 }
117
118
119 // Stuff stops happening here
120
121 response.Value = responseData;
122 return response;
123 }
124 }
125}
diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs
new file mode 100644
index 0000000..f479a79
--- /dev/null
+++ b/OpenSim/Grid/InventoryServer/Main.cs
@@ -0,0 +1,87 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Reflection;
32using System.IO;
33using System.Text;
34using libsecondlife;
35using OpenSim.Framework.User;
36using OpenSim.Framework.Sims;
37using OpenSim.Framework.Inventory;
38using OpenSim.Framework.Interfaces;
39using OpenSim.Framework.Console;
40using OpenSim.Servers;
41using OpenSim.Framework.Utilities;
42
43namespace OpenGridServices.InventoryServer
44{
45 public class OpenInventory_Main : BaseServer, conscmd_callback
46 {
47 ConsoleBase m_console;
48 InventoryManager m_inventoryManager;
49
50 public static void Main(string[] args)
51 {
52 }
53
54 public OpenInventory_Main()
55 {
56 m_console = new ConsoleBase("opengrid-inventory-console.log", "OpenInventory", this, false);
57 MainConsole.Instance = m_console;
58 }
59
60 public void Startup()
61 {
62 MainConsole.Instance.Notice("Initialising inventory manager...");
63 m_inventoryManager = new InventoryManager();
64
65 MainConsole.Instance.Notice("Starting HTTP server");
66 BaseHttpServer httpServer = new BaseHttpServer(8004);
67
68 httpServer.AddXmlRPCHandler("rootfolders", m_inventoryManager.XmlRpcInventoryRequest);
69 //httpServer.AddRestHandler("GET","/rootfolders/",Rest
70 }
71
72 public void RunCmd(string cmd, string[] cmdparams)
73 {
74 switch (cmd)
75 {
76 case "shutdown":
77 m_console.Close();
78 Environment.Exit(0);
79 break;
80 }
81 }
82
83 public void Show(string ShowWhat)
84 {
85 }
86 }
87}
diff --git a/OpenSim/Grid/Manager/OpenGridServices.Manager.mds b/OpenSim/Grid/Manager/OpenGridServices.Manager.mds
new file mode 100644
index 0000000..ed7bc24
--- /dev/null
+++ b/OpenSim/Grid/Manager/OpenGridServices.Manager.mds
@@ -0,0 +1,16 @@
1<Combine name="OpenGridServices.Manager" fileversion="2.0" outputpath="../../mono-1.2.3.1/lib/monodevelop/bin" MakePkgConfig="False" MakeLibPC="True">
2 <Configurations active="Debug">
3 <Configuration name="Debug" ctype="CombineConfiguration">
4 <Entry build="True" name="OpenGridServices.Manager" configuration="Debug" />
5 </Configuration>
6 <Configuration name="Release" ctype="CombineConfiguration">
7 <Entry build="True" name="OpenGridServices.Manager" configuration="Release" />
8 </Configuration>
9 </Configurations>
10 <StartMode startupentry="OpenGridServices.Manager" single="True">
11 <Execute type="None" entry="OpenGridServices.Manager" />
12 </StartMode>
13 <Entries>
14 <Entry filename="./OpenGridServices.Manager/OpenGridServices.Manager.mdp" />
15 </Entries>
16</Combine> \ No newline at end of file
diff --git a/OpenSim/Grid/Manager/OpenGridServices.Manager.userprefs b/OpenSim/Grid/Manager/OpenGridServices.Manager.userprefs
new file mode 100644
index 0000000..f221509
--- /dev/null
+++ b/OpenSim/Grid/Manager/OpenGridServices.Manager.userprefs
@@ -0,0 +1,39 @@
1<?xml version="1.0"?>
2<UserCombinePreferences filename="/home/gareth/OpenGridServices.Manager/OpenGridServices.Manager.mds">
3 <Files>
4 <File filename="Welcome" />
5 <File filename="./OpenGridServices.Manager/MainWindow.cs" />
6 <File filename="./OpenGridServices.Manager/ConnectToGridServerDialog.cs" />
7 <File filename="./OpenGridServices.Manager/Main.cs" />
8 </Files>
9 <Views>
10 <ViewMemento Id="MonoDevelop.Ide.Gui.Pads.ProjectPad">
11 <TreeView>
12 <Node expanded="True">
13 <Node name="OpenGridServices.Manager" expanded="True">
14 <Node name="References" expanded="True" />
15 <Node name="Resources" expanded="True" />
16 <Node name="UserInterface" expanded="True" />
17 <Node name="ConnectToGridServerDialog.cs" expanded="False" selected="True" />
18 </Node>
19 </Node>
20 </TreeView>
21 </ViewMemento>
22 <ViewMemento Id="MonoDevelop.Ide.Gui.Pads.ClassPad">
23 <TreeView>
24 <Node expanded="True" />
25 </TreeView>
26 </ViewMemento>
27 <ViewMemento Id="MonoDevelop.NUnit.TestPad">
28 <TreeView>
29 <Node expanded="False" />
30 </TreeView>
31 </ViewMemento>
32 </Views>
33 <Properties>
34 <Properties>
35 <Property key="ActiveConfiguration" value="Debug" />
36 <Property key="ActiveWindow" value="/home/gareth/OpenGridServices.Manager/OpenGridServices.Manager/ConnectToGridServerDialog.cs" />
37 </Properties>
38 </Properties>
39</UserCombinePreferences> \ No newline at end of file
diff --git a/OpenSim/Grid/Manager/OpenGridServices.Manager.usertasks b/OpenSim/Grid/Manager/OpenGridServices.Manager.usertasks
new file mode 100644
index 0000000..d887d0e
--- /dev/null
+++ b/OpenSim/Grid/Manager/OpenGridServices.Manager.usertasks
@@ -0,0 +1,2 @@
1<?xml version="1.0" encoding="utf-8"?>
2<ArrayOfUserTask xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /> \ No newline at end of file
diff --git a/OpenSim/Grid/Manager/OpenGridServices.Manager/AssemblyInfo.cs b/OpenSim/Grid/Manager/OpenGridServices.Manager/AssemblyInfo.cs
new file mode 100644
index 0000000..af4e275
--- /dev/null
+++ b/OpenSim/Grid/Manager/OpenGridServices.Manager/AssemblyInfo.cs
@@ -0,0 +1,32 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3
4// Information about this assembly is defined by the following
5// attributes.
6//
7// change them to the information which is associated with the assembly
8// you compile.
9
10[assembly: AssemblyTitle("")]
11[assembly: AssemblyDescription("")]
12[assembly: AssemblyConfiguration("")]
13[assembly: AssemblyCompany("")]
14[assembly: AssemblyProduct("")]
15[assembly: AssemblyCopyright("")]
16[assembly: AssemblyTrademark("")]
17[assembly: AssemblyCulture("")]
18
19// The assembly version has following format :
20//
21// Major.Minor.Build.Revision
22//
23// You can specify all values by your own or you can build default build and revision
24// numbers with the '*' character (the default):
25
26[assembly: AssemblyVersion("1.0.*")]
27
28// The following attributes specify the key for the sign of your assembly. See the
29// .NET Framework documentation for more information about signing.
30// This is not required, if you don't want signing let these attributes like they're.
31[assembly: AssemblyDelaySign(false)]
32[assembly: AssemblyKeyFile("")]
diff --git a/OpenSim/Grid/Manager/OpenGridServices.Manager/BlockingQueue.cs b/OpenSim/Grid/Manager/OpenGridServices.Manager/BlockingQueue.cs
new file mode 100644
index 0000000..83685fc
--- /dev/null
+++ b/OpenSim/Grid/Manager/OpenGridServices.Manager/BlockingQueue.cs
@@ -0,0 +1,33 @@
1using System;
2using System.Threading;
3using System.Collections.Generic;
4using System.Text;
5
6namespace OpenGridServices.Manager
7{
8 public class BlockingQueue<T>
9 {
10 private Queue<T> _queue = new Queue<T>();
11 private object _queueSync = new object();
12
13 public void Enqueue(T value)
14 {
15 lock (_queueSync)
16 {
17 _queue.Enqueue(value);
18 Monitor.Pulse(_queueSync);
19 }
20 }
21
22 public T Dequeue()
23 {
24 lock (_queueSync)
25 {
26 if (_queue.Count < 1)
27 Monitor.Wait(_queueSync);
28
29 return _queue.Dequeue();
30 }
31 }
32 }
33}
diff --git a/OpenSim/Grid/Manager/OpenGridServices.Manager/Connect to grid server.cs b/OpenSim/Grid/Manager/OpenGridServices.Manager/Connect to grid server.cs
new file mode 100644
index 0000000..0d509ef
--- /dev/null
+++ b/OpenSim/Grid/Manager/OpenGridServices.Manager/Connect to grid server.cs
@@ -0,0 +1,16 @@
1
2using System;
3
4namespace OpenGridServices.Manager
5{
6
7
8 public partial class Connect to grid server : Gtk.Dialog
9 {
10
11 public Connect to grid server()
12 {
13 this.Build();
14 }
15 }
16}
diff --git a/OpenSim/Grid/Manager/OpenGridServices.Manager/ConnectToGridServerDialog.cs b/OpenSim/Grid/Manager/OpenGridServices.Manager/ConnectToGridServerDialog.cs
new file mode 100644
index 0000000..8a80b1d
--- /dev/null
+++ b/OpenSim/Grid/Manager/OpenGridServices.Manager/ConnectToGridServerDialog.cs
@@ -0,0 +1,29 @@
1using Gtk;
2using System;
3
4namespace OpenGridServices.Manager {
5 public partial class ConnectToGridServerDialog : Gtk.Dialog
6 {
7
8 public ConnectToGridServerDialog()
9 {
10 this.Build();
11 }
12
13 protected virtual void OnResponse(object o, Gtk.ResponseArgs args)
14 {
15 switch(args.ResponseId) {
16 case Gtk.ResponseType.Ok:
17 MainClass.PendingOperations.Enqueue("connect_to_gridserver " + this.entry1.Text + " " + this.entry2.Text + " " + this.entry3.Text);
18 break;
19
20 case Gtk.ResponseType.Cancel:
21 break;
22 }
23 this.Hide();
24
25 }
26
27 }
28
29} \ No newline at end of file
diff --git a/OpenSim/Grid/Manager/OpenGridServices.Manager/GridServerConnectionManager.cs b/OpenSim/Grid/Manager/OpenGridServices.Manager/GridServerConnectionManager.cs
new file mode 100644
index 0000000..6b632d6
--- /dev/null
+++ b/OpenSim/Grid/Manager/OpenGridServices.Manager/GridServerConnectionManager.cs
@@ -0,0 +1,106 @@
1using Nwc.XmlRpc;
2using System;
3using System.Net;
4using System.IO;
5using System.Xml;
6using System.Collections;
7using System.Collections.Generic;
8using libsecondlife;
9
10namespace OpenGridServices.Manager
11{
12 public class GridServerConnectionManager
13 {
14 private string ServerURL;
15 public LLUUID SessionID;
16 public bool connected=false;
17
18 public RegionBlock[][] WorldMap;
19
20 public bool Connect(string GridServerURL, string username, string password)
21 {
22 try {
23 this.ServerURL=GridServerURL;
24 Hashtable LoginParamsHT = new Hashtable();
25 LoginParamsHT["username"]=username;
26 LoginParamsHT["password"]=password;
27 ArrayList LoginParams = new ArrayList();
28 LoginParams.Add(LoginParamsHT);
29 XmlRpcRequest GridLoginReq = new XmlRpcRequest("manager_login",LoginParams);
30 XmlRpcResponse GridResp = GridLoginReq.Send(ServerURL,3000);
31 if(GridResp.IsFault) {
32 connected=false;
33 return false;
34 } else {
35 Hashtable gridrespData = (Hashtable)GridResp.Value;
36 this.SessionID = new LLUUID((string)gridrespData["session_id"]);
37 connected=true;
38 return true;
39 }
40 } catch(Exception e) {
41 Console.WriteLine(e.ToString());
42 connected=false;
43 return false;
44 }
45 }
46
47 public void DownloadMap()
48 {
49 System.Net.WebClient mapdownloader = new WebClient();
50 Stream regionliststream = mapdownloader.OpenRead(ServerURL + "/regionlist");
51
52 RegionBlock TempRegionData;
53
54 XmlDocument doc = new XmlDocument();
55 doc.Load(regionliststream);
56 regionliststream.Close();
57 XmlNode rootnode = doc.FirstChild;
58 if (rootnode.Name != "regions")
59 {
60 // TODO - ERROR!
61 }
62
63 for(int i=0; i<=rootnode.ChildNodes.Count; i++)
64 {
65 if(rootnode.ChildNodes.Item(i).Name != "region") {
66 // TODO - ERROR!
67 } else {
68 TempRegionData = new RegionBlock();
69
70
71 }
72 }
73 }
74
75 public bool RestartServer()
76 {
77 return true;
78 }
79
80 public bool ShutdownServer()
81 {
82 try {
83 Hashtable ShutdownParamsHT = new Hashtable();
84 ArrayList ShutdownParams = new ArrayList();
85 ShutdownParamsHT["session_id"]=this.SessionID.ToString();
86 ShutdownParams.Add(ShutdownParamsHT);
87 XmlRpcRequest GridShutdownReq = new XmlRpcRequest("shutdown",ShutdownParams);
88 XmlRpcResponse GridResp = GridShutdownReq.Send(this.ServerURL,3000);
89 if(GridResp.IsFault) {
90 return false;
91 } else {
92 connected=false;
93 return true;
94 }
95 } catch(Exception e) {
96 Console.WriteLine(e.ToString());
97 return false;
98 }
99 }
100
101 public void DisconnectServer()
102 {
103 this.connected=false;
104 }
105 }
106}
diff --git a/OpenSim/Grid/Manager/OpenGridServices.Manager/Main.cs b/OpenSim/Grid/Manager/OpenGridServices.Manager/Main.cs
new file mode 100644
index 0000000..42e09e0
--- /dev/null
+++ b/OpenSim/Grid/Manager/OpenGridServices.Manager/Main.cs
@@ -0,0 +1,96 @@
1// project created on 5/14/2007 at 2:04 PM
2using System;
3using System.Threading;
4using Gtk;
5
6namespace OpenGridServices.Manager
7{
8 class MainClass
9 {
10
11 public static bool QuitReq=false;
12 public static BlockingQueue<string> PendingOperations = new BlockingQueue<string>();
13
14 private static Thread OperationsRunner;
15
16 private static GridServerConnectionManager gridserverConn;
17
18 private static MainWindow win;
19
20 public static void DoMainLoop()
21 {
22 while(!QuitReq)
23 {
24 Application.RunIteration();
25 }
26 }
27
28 public static void RunOperations()
29 {
30 string operation;
31 string cmd;
32 char[] sep = new char[1];
33 sep[0]=' ';
34 while(!QuitReq)
35 {
36 operation=PendingOperations.Dequeue();
37 Console.WriteLine(operation);
38 cmd = operation.Split(sep)[0];
39 switch(cmd) {
40 case "connect_to_gridserver":
41 win.SetStatus("Connecting to grid server...");
42 if(gridserverConn.Connect(operation.Split(sep)[1],operation.Split(sep)[2],operation.Split(sep)[3])) {
43 win.SetStatus("Connected OK with session ID:" + gridserverConn.SessionID);
44 win.SetGridServerConnected(true);
45 Thread.Sleep(3000);
46 win.SetStatus("Downloading region maps...");
47 gridserverConn.DownloadMap();
48 } else {
49 win.SetStatus("Could not connect");
50 }
51 break;
52
53 case "restart_gridserver":
54 win.SetStatus("Restarting grid server...");
55 if(gridserverConn.RestartServer()) {
56 win.SetStatus("Restarted server OK");
57 Thread.Sleep(3000);
58 win.SetStatus("");
59 } else {
60 win.SetStatus("Error restarting grid server!!!");
61 }
62 break;
63
64 case "shutdown_gridserver":
65 win.SetStatus("Shutting down grid server...");
66 if(gridserverConn.ShutdownServer()) {
67 win.SetStatus("Grid server shutdown");
68 win.SetGridServerConnected(false);
69 Thread.Sleep(3000);
70 win.SetStatus("");
71 } else {
72 win.SetStatus("Could not shutdown grid server!!!");
73 }
74 break;
75
76 case "disconnect_gridserver":
77 gridserverConn.DisconnectServer();
78 win.SetGridServerConnected(false);
79 break;
80 }
81 }
82 }
83
84 public static void Main (string[] args)
85 {
86 gridserverConn = new GridServerConnectionManager();
87 Application.Init ();
88 win = new MainWindow ();
89 win.Show ();
90 OperationsRunner = new Thread(new ThreadStart(RunOperations));
91 OperationsRunner.IsBackground=true;
92 OperationsRunner.Start();
93 DoMainLoop();
94 }
95 }
96} \ No newline at end of file
diff --git a/OpenSim/Grid/Manager/OpenGridServices.Manager/MainWindow.cs b/OpenSim/Grid/Manager/OpenGridServices.Manager/MainWindow.cs
new file mode 100644
index 0000000..1db38f0
--- /dev/null
+++ b/OpenSim/Grid/Manager/OpenGridServices.Manager/MainWindow.cs
@@ -0,0 +1,76 @@
1using System;
2using Gtk;
3
4namespace OpenGridServices.Manager {
5 public partial class MainWindow: Gtk.Window
6 {
7 public MainWindow (): base (Gtk.WindowType.Toplevel)
8 {
9 Build ();
10 }
11
12 public void SetStatus(string statustext)
13 {
14 this.statusbar1.Pop(0);
15 this.statusbar1.Push(0,statustext);
16 }
17
18 public void DrawGrid(RegionBlock[][] regions)
19 {
20 for(int x=0; x<=regions.GetUpperBound(0); x++) {
21 for(int y=0; y<=regions.GetUpperBound(1); y++) {
22 Gdk.Image themap = new Gdk.Image(Gdk.ImageType.Fastest,Gdk.Visual.System,256,256);
23 this.drawingarea1.GdkWindow.DrawImage(new Gdk.GC(this.drawingarea1.GdkWindow),themap,0,0,x*256,y*256,256,256);
24 }
25 }
26 }
27
28 public void SetGridServerConnected(bool connected)
29 {
30 if(connected) {
31 this.ConnectToGridserver.Visible=false;
32 this.DisconnectFromGridServer.Visible=true;
33 } else {
34 this.ConnectToGridserver.Visible=true;
35 this.DisconnectFromGridServer.Visible=false;
36 }
37 }
38
39 protected void OnDeleteEvent (object sender, DeleteEventArgs a)
40 {
41 Application.Quit ();
42 MainClass.QuitReq=true;
43 a.RetVal = true;
44 }
45
46 protected virtual void QuitMenu(object sender, System.EventArgs e)
47 {
48 MainClass.QuitReq=true;
49 Application.Quit();
50 }
51
52 protected virtual void ConnectToGridServerMenu(object sender, System.EventArgs e)
53 {
54 ConnectToGridServerDialog griddialog = new ConnectToGridServerDialog ();
55 griddialog.Show();
56 }
57
58 protected virtual void RestartGridserverMenu(object sender, System.EventArgs e)
59 {
60 MainClass.PendingOperations.Enqueue("restart_gridserver");
61 }
62
63 protected virtual void ShutdownGridserverMenu(object sender, System.EventArgs e)
64 {
65 MainClass.PendingOperations.Enqueue("shutdown_gridserver");
66 }
67
68 protected virtual void DisconnectGridServerMenu(object sender, System.EventArgs e)
69 {
70 MainClass.PendingOperations.Enqueue("disconnect_gridserver");
71 }
72
73 }
74}
75
76 \ No newline at end of file
diff --git a/OpenSim/Grid/Manager/OpenGridServices.Manager/OpenGridServices.Manager.mdp b/OpenSim/Grid/Manager/OpenGridServices.Manager/OpenGridServices.Manager.mdp
new file mode 100644
index 0000000..cfdc085
--- /dev/null
+++ b/OpenSim/Grid/Manager/OpenGridServices.Manager/OpenGridServices.Manager.mdp
@@ -0,0 +1,43 @@
1<Project name="OpenGridServices.Manager" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject">
2 <Configurations active="Debug">
3 <Configuration name="Debug" ctype="DotNetProjectConfiguration">
4 <Output directory="./bin/Debug" assembly="OpenGridServices.Manager" />
5 <Build debugmode="True" target="Exe" />
6 <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" />
7 <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
8 </Configuration>
9 <Configuration name="Release" ctype="DotNetProjectConfiguration">
10 <Output directory="./bin/Release" assembly="OpenGridServices.Manager" />
11 <Build debugmode="False" target="Exe" />
12 <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" />
13 <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
14 </Configuration>
15 </Configurations>
16 <Contents>
17 <File name="./gtk-gui/gui.stetic" subtype="Code" buildaction="EmbedAsResource" />
18 <File name="./gtk-gui/generated.cs" subtype="Code" buildaction="Compile" />
19 <File name="./MainWindow.cs" subtype="Code" buildaction="Compile" />
20 <File name="./Main.cs" subtype="Code" buildaction="Compile" />
21 <File name="./AssemblyInfo.cs" subtype="Code" buildaction="Compile" />
22 <File name="./ConnectToGridServerDialog.cs" subtype="Code" buildaction="Compile" />
23 <File name="./Util.cs" subtype="Code" buildaction="Compile" />
24 <File name="./gtk-gui/OpenGridServices.Manager.MainWindow.cs" subtype="Code" buildaction="Compile" />
25 <File name="./BlockingQueue.cs" subtype="Code" buildaction="Compile" />
26 <File name="./gtk-gui/OpenGridServices.Manager.ConnectToGridServerDialog.cs" subtype="Code" buildaction="Compile" />
27 <File name="./GridServerConnectionManager.cs" subtype="Code" buildaction="Compile" />
28 <File name="./RegionBlock.cs" subtype="Code" buildaction="Compile" />
29 </Contents>
30 <References>
31 <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
32 <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
33 <ProjectReference type="Gac" localcopy="True" refto="glib-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
34 <ProjectReference type="Gac" localcopy="True" refto="glade-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
35 <ProjectReference type="Gac" localcopy="True" refto="pango-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
36 <ProjectReference type="Assembly" localcopy="True" refto="../../bin/libsecondlife.dll" />
37 <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
38 <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
39 <ProjectReference type="Assembly" localcopy="True" refto="../../bin/XMLRPC.dll" />
40 <ProjectReference type="Gac" localcopy="True" refto="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
41 </References>
42 <GtkDesignInfo partialTypes="True" />
43</Project> \ No newline at end of file
diff --git a/OpenSim/Grid/Manager/OpenGridServices.Manager/OpenGridServices.Manager.pidb b/OpenSim/Grid/Manager/OpenGridServices.Manager/OpenGridServices.Manager.pidb
new file mode 100644
index 0000000..44e7a61
--- /dev/null
+++ b/OpenSim/Grid/Manager/OpenGridServices.Manager/OpenGridServices.Manager.pidb
Binary files differ
diff --git a/OpenSim/Grid/Manager/OpenGridServices.Manager/RegionBlock.cs b/OpenSim/Grid/Manager/OpenGridServices.Manager/RegionBlock.cs
new file mode 100644
index 0000000..00f7c65
--- /dev/null
+++ b/OpenSim/Grid/Manager/OpenGridServices.Manager/RegionBlock.cs
@@ -0,0 +1,37 @@
1using System;
2using System.Xml;
3using libsecondlife;
4using OpenSim.Framework.Utilities;
5
6namespace OpenGridServices.Manager
7{
8
9
10 public class RegionBlock
11 {
12 public uint regloc_x;
13 public uint regloc_y;
14
15 public string httpd_url;
16
17 public string region_name;
18
19 public ulong regionhandle {
20 get { return Util.UIntsToLong(regloc_x*256,regloc_y*256); }
21 }
22
23 public Gdk.Pixbuf MiniMap;
24
25 public RegionBlock()
26 {
27 }
28
29 public void LoadFromXmlNode(XmlNode sourcenode)
30 {
31 this.regloc_x=Convert.ToUInt32(sourcenode.Attributes.GetNamedItem("loc_x").Value);
32 this.regloc_y=Convert.ToUInt32(sourcenode.Attributes.GetNamedItem("loc_y").Value);
33 this.region_name=sourcenode.Attributes.GetNamedItem("region_name").Value;
34 this.httpd_url=sourcenode.Attributes.GetNamedItem("httpd_url").Value;
35 }
36 }
37}
diff --git a/OpenSim/Grid/Manager/OpenGridServices.Manager/Util.cs b/OpenSim/Grid/Manager/OpenGridServices.Manager/Util.cs
new file mode 100644
index 0000000..5bf7ff9
--- /dev/null
+++ b/OpenSim/Grid/Manager/OpenGridServices.Manager/Util.cs
@@ -0,0 +1,133 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using libsecondlife.Packets;
6
7namespace OpenSim.Framework.Utilities
8{
9 public class Util
10 {
11 private static Random randomClass = new Random();
12 private static uint nextXferID = 5000;
13 private static object XferLock = new object();
14
15 public static ulong UIntsToLong(uint X, uint Y)
16 {
17 return Helpers.UIntsToLong(X, Y);
18 }
19
20 public static Random RandomClass
21 {
22 get
23 {
24 return randomClass;
25 }
26 }
27
28 public static uint GetNextXferID()
29 {
30 uint id = 0;
31 lock(XferLock)
32 {
33 id = nextXferID;
34 nextXferID++;
35 }
36 return id;
37 }
38
39 //public static int fast_distance2d(int x, int y)
40 //{
41 // x = System.Math.Abs(x);
42 // y = System.Math.Abs(y);
43
44 // int min = System.Math.Min(x, y);
45
46 // return (x + y - (min >> 1) - (min >> 2) + (min >> 4));
47 //}
48
49 public static string FieldToString(byte[] bytes)
50 {
51 return FieldToString(bytes, String.Empty);
52 }
53
54 /// <summary>
55 /// Convert a variable length field (byte array) to a string, with a
56 /// field name prepended to each line of the output
57 /// </summary>
58 /// <remarks>If the byte array has unprintable characters in it, a
59 /// hex dump will be put in the string instead</remarks>
60 /// <param name="bytes">The byte array to convert to a string</param>
61 /// <param name="fieldName">A field name to prepend to each line of output</param>
62 /// <returns>An ASCII string or a string containing a hex dump, minus
63 /// the null terminator</returns>
64 public static string FieldToString(byte[] bytes, string fieldName)
65 {
66 // Check for a common case
67 if (bytes.Length == 0) return String.Empty;
68
69 StringBuilder output = new StringBuilder();
70 bool printable = true;
71
72 for (int i = 0; i < bytes.Length; ++i)
73 {
74 // Check if there are any unprintable characters in the array
75 if ((bytes[i] < 0x20 || bytes[i] > 0x7E) && bytes[i] != 0x09
76 && bytes[i] != 0x0D && bytes[i] != 0x0A && bytes[i] != 0x00)
77 {
78 printable = false;
79 break;
80 }
81 }
82
83 if (printable)
84 {
85 if (fieldName.Length > 0)
86 {
87 output.Append(fieldName);
88 output.Append(": ");
89 }
90
91 if (bytes[bytes.Length - 1] == 0x00)
92 output.Append(UTF8Encoding.UTF8.GetString(bytes, 0, bytes.Length - 1));
93 else
94 output.Append(UTF8Encoding.UTF8.GetString(bytes));
95 }
96 else
97 {
98 for (int i = 0; i < bytes.Length; i += 16)
99 {
100 if (i != 0)
101 output.Append(Environment.NewLine);
102 if (fieldName.Length > 0)
103 {
104 output.Append(fieldName);
105 output.Append(": ");
106 }
107
108 for (int j = 0; j < 16; j++)
109 {
110 if ((i + j) < bytes.Length)
111 output.Append(String.Format("{0:X2} ", bytes[i + j]));
112 else
113 output.Append(" ");
114 }
115
116 for (int j = 0; j < 16 && (i + j) < bytes.Length; j++)
117 {
118 if (bytes[i + j] >= 0x20 && bytes[i + j] < 0x7E)
119 output.Append((char)bytes[i + j]);
120 else
121 output.Append(".");
122 }
123 }
124 }
125
126 return output.ToString();
127 }
128 public Util()
129 {
130
131 }
132 }
133}
diff --git a/OpenSim/Grid/Manager/OpenGridServices.Manager/gtk-gui/OpenGridServices.Manager.ConnectToGridServerDialog.cs b/OpenSim/Grid/Manager/OpenGridServices.Manager/gtk-gui/OpenGridServices.Manager.ConnectToGridServerDialog.cs
new file mode 100644
index 0000000..da6739e
--- /dev/null
+++ b/OpenSim/Grid/Manager/OpenGridServices.Manager/gtk-gui/OpenGridServices.Manager.ConnectToGridServerDialog.cs
@@ -0,0 +1,226 @@
1// ------------------------------------------------------------------------------
2// <autogenerated>
3// This code was generated by a tool.
4// Mono Runtime Version: 2.0.50727.42
5//
6// Changes to this file may cause incorrect behavior and will be lost if
7// the code is regenerated.
8// </autogenerated>
9// ------------------------------------------------------------------------------
10
11namespace OpenGridServices.Manager {
12
13
14 public partial class ConnectToGridServerDialog {
15
16 private Gtk.VBox vbox2;
17
18 private Gtk.VBox vbox3;
19
20 private Gtk.HBox hbox1;
21
22 private Gtk.Label label1;
23
24 private Gtk.Entry entry1;
25
26 private Gtk.HBox hbox2;
27
28 private Gtk.Label label2;
29
30 private Gtk.Entry entry2;
31
32 private Gtk.HBox hbox3;
33
34 private Gtk.Label label3;
35
36 private Gtk.Entry entry3;
37
38 private Gtk.Button button2;
39
40 private Gtk.Button button8;
41
42 protected virtual void Build() {
43 Stetic.Gui.Initialize();
44 // Widget OpenGridServices.Manager.ConnectToGridServerDialog
45 this.Events = ((Gdk.EventMask)(256));
46 this.Name = "OpenGridServices.Manager.ConnectToGridServerDialog";
47 this.Title = Mono.Unix.Catalog.GetString("Connect to Grid server");
48 this.WindowPosition = ((Gtk.WindowPosition)(4));
49 this.HasSeparator = false;
50 // Internal child OpenGridServices.Manager.ConnectToGridServerDialog.VBox
51 Gtk.VBox w1 = this.VBox;
52 w1.Events = ((Gdk.EventMask)(256));
53 w1.Name = "dialog_VBox";
54 w1.BorderWidth = ((uint)(2));
55 // Container child dialog_VBox.Gtk.Box+BoxChild
56 this.vbox2 = new Gtk.VBox();
57 this.vbox2.Name = "vbox2";
58 // Container child vbox2.Gtk.Box+BoxChild
59 this.vbox3 = new Gtk.VBox();
60 this.vbox3.Name = "vbox3";
61 // Container child vbox3.Gtk.Box+BoxChild
62 this.hbox1 = new Gtk.HBox();
63 this.hbox1.Name = "hbox1";
64 // Container child hbox1.Gtk.Box+BoxChild
65 this.label1 = new Gtk.Label();
66 this.label1.Name = "label1";
67 this.label1.Xalign = 1F;
68 this.label1.LabelProp = Mono.Unix.Catalog.GetString("Grid server URL: ");
69 this.label1.Justify = ((Gtk.Justification)(1));
70 this.hbox1.Add(this.label1);
71 Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.hbox1[this.label1]));
72 w2.Position = 0;
73 // Container child hbox1.Gtk.Box+BoxChild
74 this.entry1 = new Gtk.Entry();
75 this.entry1.CanFocus = true;
76 this.entry1.Name = "entry1";
77 this.entry1.Text = Mono.Unix.Catalog.GetString("http://gridserver:8001");
78 this.entry1.IsEditable = true;
79 this.entry1.MaxLength = 255;
80 this.entry1.InvisibleChar = '•';
81 this.hbox1.Add(this.entry1);
82 Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.hbox1[this.entry1]));
83 w3.Position = 1;
84 this.vbox3.Add(this.hbox1);
85 Gtk.Box.BoxChild w4 = ((Gtk.Box.BoxChild)(this.vbox3[this.hbox1]));
86 w4.Position = 0;
87 w4.Expand = false;
88 w4.Fill = false;
89 // Container child vbox3.Gtk.Box+BoxChild
90 this.hbox2 = new Gtk.HBox();
91 this.hbox2.Name = "hbox2";
92 // Container child hbox2.Gtk.Box+BoxChild
93 this.label2 = new Gtk.Label();
94 this.label2.Name = "label2";
95 this.label2.Xalign = 1F;
96 this.label2.LabelProp = Mono.Unix.Catalog.GetString("Username:");
97 this.label2.Justify = ((Gtk.Justification)(1));
98 this.hbox2.Add(this.label2);
99 Gtk.Box.BoxChild w5 = ((Gtk.Box.BoxChild)(this.hbox2[this.label2]));
100 w5.Position = 0;
101 // Container child hbox2.Gtk.Box+BoxChild
102 this.entry2 = new Gtk.Entry();
103 this.entry2.CanFocus = true;
104 this.entry2.Name = "entry2";
105 this.entry2.IsEditable = true;
106 this.entry2.InvisibleChar = '•';
107 this.hbox2.Add(this.entry2);
108 Gtk.Box.BoxChild w6 = ((Gtk.Box.BoxChild)(this.hbox2[this.entry2]));
109 w6.Position = 1;
110 this.vbox3.Add(this.hbox2);
111 Gtk.Box.BoxChild w7 = ((Gtk.Box.BoxChild)(this.vbox3[this.hbox2]));
112 w7.Position = 1;
113 w7.Expand = false;
114 w7.Fill = false;
115 // Container child vbox3.Gtk.Box+BoxChild
116 this.hbox3 = new Gtk.HBox();
117 this.hbox3.Name = "hbox3";
118 // Container child hbox3.Gtk.Box+BoxChild
119 this.label3 = new Gtk.Label();
120 this.label3.Name = "label3";
121 this.label3.Xalign = 1F;
122 this.label3.LabelProp = Mono.Unix.Catalog.GetString("Password:");
123 this.label3.Justify = ((Gtk.Justification)(1));
124 this.hbox3.Add(this.label3);
125 Gtk.Box.BoxChild w8 = ((Gtk.Box.BoxChild)(this.hbox3[this.label3]));
126 w8.Position = 0;
127 // Container child hbox3.Gtk.Box+BoxChild
128 this.entry3 = new Gtk.Entry();
129 this.entry3.CanFocus = true;
130 this.entry3.Name = "entry3";
131 this.entry3.IsEditable = true;
132 this.entry3.InvisibleChar = '•';
133 this.hbox3.Add(this.entry3);
134 Gtk.Box.BoxChild w9 = ((Gtk.Box.BoxChild)(this.hbox3[this.entry3]));
135 w9.Position = 1;
136 this.vbox3.Add(this.hbox3);
137 Gtk.Box.BoxChild w10 = ((Gtk.Box.BoxChild)(this.vbox3[this.hbox3]));
138 w10.Position = 2;
139 w10.Expand = false;
140 w10.Fill = false;
141 this.vbox2.Add(this.vbox3);
142 Gtk.Box.BoxChild w11 = ((Gtk.Box.BoxChild)(this.vbox2[this.vbox3]));
143 w11.Position = 2;
144 w11.Expand = false;
145 w11.Fill = false;
146 w1.Add(this.vbox2);
147 Gtk.Box.BoxChild w12 = ((Gtk.Box.BoxChild)(w1[this.vbox2]));
148 w12.Position = 0;
149 // Internal child OpenGridServices.Manager.ConnectToGridServerDialog.ActionArea
150 Gtk.HButtonBox w13 = this.ActionArea;
151 w13.Events = ((Gdk.EventMask)(256));
152 w13.Name = "OpenGridServices.Manager.ConnectToGridServerDialog_ActionArea";
153 w13.Spacing = 6;
154 w13.BorderWidth = ((uint)(5));
155 w13.LayoutStyle = ((Gtk.ButtonBoxStyle)(4));
156 // Container child OpenGridServices.Manager.ConnectToGridServerDialog_ActionArea.Gtk.ButtonBox+ButtonBoxChild
157 this.button2 = new Gtk.Button();
158 this.button2.CanDefault = true;
159 this.button2.CanFocus = true;
160 this.button2.Name = "button2";
161 this.button2.UseUnderline = true;
162 // Container child button2.Gtk.Container+ContainerChild
163 Gtk.Alignment w14 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
164 w14.Name = "GtkAlignment";
165 // Container child GtkAlignment.Gtk.Container+ContainerChild
166 Gtk.HBox w15 = new Gtk.HBox();
167 w15.Name = "GtkHBox";
168 w15.Spacing = 2;
169 // Container child GtkHBox.Gtk.Container+ContainerChild
170 Gtk.Image w16 = new Gtk.Image();
171 w16.Name = "image1";
172 w16.Pixbuf = Gtk.IconTheme.Default.LoadIcon("gtk-apply", 16, 0);
173 w15.Add(w16);
174 // Container child GtkHBox.Gtk.Container+ContainerChild
175 Gtk.Label w18 = new Gtk.Label();
176 w18.Name = "GtkLabel";
177 w18.LabelProp = Mono.Unix.Catalog.GetString("Connect");
178 w18.UseUnderline = true;
179 w15.Add(w18);
180 w14.Add(w15);
181 this.button2.Add(w14);
182 this.AddActionWidget(this.button2, -5);
183 Gtk.ButtonBox.ButtonBoxChild w22 = ((Gtk.ButtonBox.ButtonBoxChild)(w13[this.button2]));
184 w22.Expand = false;
185 w22.Fill = false;
186 // Container child OpenGridServices.Manager.ConnectToGridServerDialog_ActionArea.Gtk.ButtonBox+ButtonBoxChild
187 this.button8 = new Gtk.Button();
188 this.button8.CanDefault = true;
189 this.button8.CanFocus = true;
190 this.button8.Name = "button8";
191 this.button8.UseUnderline = true;
192 // Container child button8.Gtk.Container+ContainerChild
193 Gtk.Alignment w23 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
194 w23.Name = "GtkAlignment1";
195 // Container child GtkAlignment1.Gtk.Container+ContainerChild
196 Gtk.HBox w24 = new Gtk.HBox();
197 w24.Name = "GtkHBox1";
198 w24.Spacing = 2;
199 // Container child GtkHBox1.Gtk.Container+ContainerChild
200 Gtk.Image w25 = new Gtk.Image();
201 w25.Name = "image2";
202 w25.Pixbuf = Gtk.IconTheme.Default.LoadIcon("gtk-cancel", 16, 0);
203 w24.Add(w25);
204 // Container child GtkHBox1.Gtk.Container+ContainerChild
205 Gtk.Label w27 = new Gtk.Label();
206 w27.Name = "GtkLabel1";
207 w27.LabelProp = Mono.Unix.Catalog.GetString("Cancel");
208 w27.UseUnderline = true;
209 w24.Add(w27);
210 w23.Add(w24);
211 this.button8.Add(w23);
212 this.AddActionWidget(this.button8, -6);
213 Gtk.ButtonBox.ButtonBoxChild w31 = ((Gtk.ButtonBox.ButtonBoxChild)(w13[this.button8]));
214 w31.Position = 1;
215 w31.Expand = false;
216 w31.Fill = false;
217 if ((this.Child != null)) {
218 this.Child.ShowAll();
219 }
220 this.DefaultWidth = 476;
221 this.DefaultHeight = 137;
222 this.Show();
223 this.Response += new Gtk.ResponseHandler(this.OnResponse);
224 }
225 }
226}
diff --git a/OpenSim/Grid/Manager/OpenGridServices.Manager/gtk-gui/OpenGridServices.Manager.MainWindow.cs b/OpenSim/Grid/Manager/OpenGridServices.Manager/gtk-gui/OpenGridServices.Manager.MainWindow.cs
new file mode 100644
index 0000000..8798dac
--- /dev/null
+++ b/OpenSim/Grid/Manager/OpenGridServices.Manager/gtk-gui/OpenGridServices.Manager.MainWindow.cs
@@ -0,0 +1,256 @@
1// ------------------------------------------------------------------------------
2// <autogenerated>
3// This code was generated by a tool.
4// Mono Runtime Version: 2.0.50727.42
5//
6// Changes to this file may cause incorrect behavior and will be lost if
7// the code is regenerated.
8// </autogenerated>
9// ------------------------------------------------------------------------------
10
11namespace OpenGridServices.Manager {
12
13
14 public partial class MainWindow {
15
16 private Gtk.Action Grid;
17
18 private Gtk.Action User;
19
20 private Gtk.Action Asset;
21
22 private Gtk.Action Region;
23
24 private Gtk.Action Services;
25
26 private Gtk.Action ConnectToGridserver;
27
28 private Gtk.Action RestartWholeGrid;
29
30 private Gtk.Action ShutdownWholeGrid;
31
32 private Gtk.Action ExitGridManager;
33
34 private Gtk.Action ConnectToUserserver;
35
36 private Gtk.Action AccountManagment;
37
38 private Gtk.Action GlobalNotice;
39
40 private Gtk.Action DisableAllLogins;
41
42 private Gtk.Action DisableNonGodUsersOnly;
43
44 private Gtk.Action ShutdownUserServer;
45
46 private Gtk.Action ShutdownGridserverOnly;
47
48 private Gtk.Action RestartGridserverOnly;
49
50 private Gtk.Action DefaultLocalGridUserserver;
51
52 private Gtk.Action CustomUserserver;
53
54 private Gtk.Action RemoteGridDefaultUserserver;
55
56 private Gtk.Action DisconnectFromGridServer;
57
58 private Gtk.Action UploadAsset;
59
60 private Gtk.Action AssetManagement;
61
62 private Gtk.Action ConnectToAssetServer;
63
64 private Gtk.Action ConnectToDefaultAssetServerForGrid;
65
66 private Gtk.Action DefaultForLocalGrid;
67
68 private Gtk.Action DefaultForRemoteGrid;
69
70 private Gtk.Action CustomAssetServer;
71
72 private Gtk.VBox vbox1;
73
74 private Gtk.MenuBar menubar2;
75
76 private Gtk.HBox hbox1;
77
78 private Gtk.ScrolledWindow scrolledwindow1;
79
80 private Gtk.DrawingArea drawingarea1;
81
82 private Gtk.TreeView treeview1;
83
84 private Gtk.Statusbar statusbar1;
85
86 protected virtual void Build() {
87 Stetic.Gui.Initialize();
88 // Widget OpenGridServices.Manager.MainWindow
89 Gtk.UIManager w1 = new Gtk.UIManager();
90 Gtk.ActionGroup w2 = new Gtk.ActionGroup("Default");
91 this.Grid = new Gtk.Action("Grid", Mono.Unix.Catalog.GetString("Grid"), null, null);
92 this.Grid.HideIfEmpty = false;
93 this.Grid.ShortLabel = Mono.Unix.Catalog.GetString("Grid");
94 w2.Add(this.Grid, "<Alt><Mod2>g");
95 this.User = new Gtk.Action("User", Mono.Unix.Catalog.GetString("User"), null, null);
96 this.User.HideIfEmpty = false;
97 this.User.ShortLabel = Mono.Unix.Catalog.GetString("User");
98 w2.Add(this.User, null);
99 this.Asset = new Gtk.Action("Asset", Mono.Unix.Catalog.GetString("Asset"), null, null);
100 this.Asset.HideIfEmpty = false;
101 this.Asset.ShortLabel = Mono.Unix.Catalog.GetString("Asset");
102 w2.Add(this.Asset, null);
103 this.Region = new Gtk.Action("Region", Mono.Unix.Catalog.GetString("Region"), null, null);
104 this.Region.ShortLabel = Mono.Unix.Catalog.GetString("Region");
105 w2.Add(this.Region, null);
106 this.Services = new Gtk.Action("Services", Mono.Unix.Catalog.GetString("Services"), null, null);
107 this.Services.ShortLabel = Mono.Unix.Catalog.GetString("Services");
108 w2.Add(this.Services, null);
109 this.ConnectToGridserver = new Gtk.Action("ConnectToGridserver", Mono.Unix.Catalog.GetString("Connect to gridserver..."), null, "gtk-connect");
110 this.ConnectToGridserver.HideIfEmpty = false;
111 this.ConnectToGridserver.ShortLabel = Mono.Unix.Catalog.GetString("Connect to gridserver");
112 w2.Add(this.ConnectToGridserver, null);
113 this.RestartWholeGrid = new Gtk.Action("RestartWholeGrid", Mono.Unix.Catalog.GetString("Restart whole grid"), null, "gtk-refresh");
114 this.RestartWholeGrid.ShortLabel = Mono.Unix.Catalog.GetString("Restart whole grid");
115 w2.Add(this.RestartWholeGrid, null);
116 this.ShutdownWholeGrid = new Gtk.Action("ShutdownWholeGrid", Mono.Unix.Catalog.GetString("Shutdown whole grid"), null, "gtk-stop");
117 this.ShutdownWholeGrid.ShortLabel = Mono.Unix.Catalog.GetString("Shutdown whole grid");
118 w2.Add(this.ShutdownWholeGrid, null);
119 this.ExitGridManager = new Gtk.Action("ExitGridManager", Mono.Unix.Catalog.GetString("Exit grid manager"), null, "gtk-close");
120 this.ExitGridManager.ShortLabel = Mono.Unix.Catalog.GetString("Exit grid manager");
121 w2.Add(this.ExitGridManager, null);
122 this.ConnectToUserserver = new Gtk.Action("ConnectToUserserver", Mono.Unix.Catalog.GetString("Connect to userserver"), null, "gtk-connect");
123 this.ConnectToUserserver.ShortLabel = Mono.Unix.Catalog.GetString("Connect to userserver");
124 w2.Add(this.ConnectToUserserver, null);
125 this.AccountManagment = new Gtk.Action("AccountManagment", Mono.Unix.Catalog.GetString("Account managment"), null, "gtk-properties");
126 this.AccountManagment.ShortLabel = Mono.Unix.Catalog.GetString("Account managment");
127 w2.Add(this.AccountManagment, null);
128 this.GlobalNotice = new Gtk.Action("GlobalNotice", Mono.Unix.Catalog.GetString("Global notice"), null, "gtk-network");
129 this.GlobalNotice.ShortLabel = Mono.Unix.Catalog.GetString("Global notice");
130 w2.Add(this.GlobalNotice, null);
131 this.DisableAllLogins = new Gtk.Action("DisableAllLogins", Mono.Unix.Catalog.GetString("Disable all logins"), null, "gtk-no");
132 this.DisableAllLogins.ShortLabel = Mono.Unix.Catalog.GetString("Disable all logins");
133 w2.Add(this.DisableAllLogins, null);
134 this.DisableNonGodUsersOnly = new Gtk.Action("DisableNonGodUsersOnly", Mono.Unix.Catalog.GetString("Disable non-god users only"), null, "gtk-no");
135 this.DisableNonGodUsersOnly.ShortLabel = Mono.Unix.Catalog.GetString("Disable non-god users only");
136 w2.Add(this.DisableNonGodUsersOnly, null);
137 this.ShutdownUserServer = new Gtk.Action("ShutdownUserServer", Mono.Unix.Catalog.GetString("Shutdown user server"), null, "gtk-stop");
138 this.ShutdownUserServer.ShortLabel = Mono.Unix.Catalog.GetString("Shutdown user server");
139 w2.Add(this.ShutdownUserServer, null);
140 this.ShutdownGridserverOnly = new Gtk.Action("ShutdownGridserverOnly", Mono.Unix.Catalog.GetString("Shutdown gridserver only"), null, "gtk-stop");
141 this.ShutdownGridserverOnly.ShortLabel = Mono.Unix.Catalog.GetString("Shutdown gridserver only");
142 w2.Add(this.ShutdownGridserverOnly, null);
143 this.RestartGridserverOnly = new Gtk.Action("RestartGridserverOnly", Mono.Unix.Catalog.GetString("Restart gridserver only"), null, "gtk-refresh");
144 this.RestartGridserverOnly.ShortLabel = Mono.Unix.Catalog.GetString("Restart gridserver only");
145 w2.Add(this.RestartGridserverOnly, null);
146 this.DefaultLocalGridUserserver = new Gtk.Action("DefaultLocalGridUserserver", Mono.Unix.Catalog.GetString("Default local grid userserver"), null, null);
147 this.DefaultLocalGridUserserver.ShortLabel = Mono.Unix.Catalog.GetString("Default local grid userserver");
148 w2.Add(this.DefaultLocalGridUserserver, null);
149 this.CustomUserserver = new Gtk.Action("CustomUserserver", Mono.Unix.Catalog.GetString("Custom userserver..."), null, null);
150 this.CustomUserserver.ShortLabel = Mono.Unix.Catalog.GetString("Custom userserver");
151 w2.Add(this.CustomUserserver, null);
152 this.RemoteGridDefaultUserserver = new Gtk.Action("RemoteGridDefaultUserserver", Mono.Unix.Catalog.GetString("Remote grid default userserver..."), null, null);
153 this.RemoteGridDefaultUserserver.ShortLabel = Mono.Unix.Catalog.GetString("Remote grid default userserver");
154 w2.Add(this.RemoteGridDefaultUserserver, null);
155 this.DisconnectFromGridServer = new Gtk.Action("DisconnectFromGridServer", Mono.Unix.Catalog.GetString("Disconnect from grid server"), null, "gtk-disconnect");
156 this.DisconnectFromGridServer.ShortLabel = Mono.Unix.Catalog.GetString("Disconnect from grid server");
157 this.DisconnectFromGridServer.Visible = false;
158 w2.Add(this.DisconnectFromGridServer, null);
159 this.UploadAsset = new Gtk.Action("UploadAsset", Mono.Unix.Catalog.GetString("Upload asset"), null, null);
160 this.UploadAsset.ShortLabel = Mono.Unix.Catalog.GetString("Upload asset");
161 w2.Add(this.UploadAsset, null);
162 this.AssetManagement = new Gtk.Action("AssetManagement", Mono.Unix.Catalog.GetString("Asset management"), null, null);
163 this.AssetManagement.ShortLabel = Mono.Unix.Catalog.GetString("Asset management");
164 w2.Add(this.AssetManagement, null);
165 this.ConnectToAssetServer = new Gtk.Action("ConnectToAssetServer", Mono.Unix.Catalog.GetString("Connect to asset server"), null, null);
166 this.ConnectToAssetServer.ShortLabel = Mono.Unix.Catalog.GetString("Connect to asset server");
167 w2.Add(this.ConnectToAssetServer, null);
168 this.ConnectToDefaultAssetServerForGrid = new Gtk.Action("ConnectToDefaultAssetServerForGrid", Mono.Unix.Catalog.GetString("Connect to default asset server for grid"), null, null);
169 this.ConnectToDefaultAssetServerForGrid.ShortLabel = Mono.Unix.Catalog.GetString("Connect to default asset server for grid");
170 w2.Add(this.ConnectToDefaultAssetServerForGrid, null);
171 this.DefaultForLocalGrid = new Gtk.Action("DefaultForLocalGrid", Mono.Unix.Catalog.GetString("Default for local grid"), null, null);
172 this.DefaultForLocalGrid.ShortLabel = Mono.Unix.Catalog.GetString("Default for local grid");
173 w2.Add(this.DefaultForLocalGrid, null);
174 this.DefaultForRemoteGrid = new Gtk.Action("DefaultForRemoteGrid", Mono.Unix.Catalog.GetString("Default for remote grid..."), null, null);
175 this.DefaultForRemoteGrid.ShortLabel = Mono.Unix.Catalog.GetString("Default for remote grid...");
176 w2.Add(this.DefaultForRemoteGrid, null);
177 this.CustomAssetServer = new Gtk.Action("CustomAssetServer", Mono.Unix.Catalog.GetString("Custom asset server..."), null, null);
178 this.CustomAssetServer.ShortLabel = Mono.Unix.Catalog.GetString("Custom asset server...");
179 w2.Add(this.CustomAssetServer, null);
180 w1.InsertActionGroup(w2, 0);
181 this.AddAccelGroup(w1.AccelGroup);
182 this.WidthRequest = 800;
183 this.HeightRequest = 600;
184 this.Name = "OpenGridServices.Manager.MainWindow";
185 this.Title = Mono.Unix.Catalog.GetString("Open Grid Services Manager");
186 this.Icon = Gtk.IconTheme.Default.LoadIcon("gtk-network", 48, 0);
187 // Container child OpenGridServices.Manager.MainWindow.Gtk.Container+ContainerChild
188 this.vbox1 = new Gtk.VBox();
189 this.vbox1.Name = "vbox1";
190 // Container child vbox1.Gtk.Box+BoxChild
191 w1.AddUiFromString("<ui><menubar name='menubar2'><menu action='Grid'><menuitem action='ConnectToGridserver'/><menuitem action='DisconnectFromGridServer'/><separator/><menuitem action='RestartWholeGrid'/><menuitem action='RestartGridserverOnly'/><separator/><menuitem action='ShutdownWholeGrid'/><menuitem action='ShutdownGridserverOnly'/><separator/><menuitem action='ExitGridManager'/></menu><menu action='User'><menu action='ConnectToUserserver'><menuitem action='DefaultLocalGridUserserver'/><menuitem action='CustomUserserver'/><menuitem action='RemoteGridDefaultUserserver'/></menu><separator/><menuitem action='AccountManagment'/><menuitem action='GlobalNotice'/><separator/><menuitem action='DisableAllLogins'/><menuitem action='DisableNonGodUsersOnly'/><separator/><menuitem action='ShutdownUserServer'/></menu><menu action='Asset'><menuitem action='UploadAsset'/><menuitem action='AssetManagement'/><menu action='ConnectToAssetServer'><menuitem action='DefaultForLocalGrid'/><menuitem action='DefaultForRemoteGrid'/><menuitem action='CustomAssetServer'/></menu></menu><menu action='Region'/><menu action='Services'/></menubar></ui>");
192 this.menubar2 = ((Gtk.MenuBar)(w1.GetWidget("/menubar2")));
193 this.menubar2.HeightRequest = 25;
194 this.menubar2.Name = "menubar2";
195 this.vbox1.Add(this.menubar2);
196 Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.vbox1[this.menubar2]));
197 w3.Position = 0;
198 w3.Expand = false;
199 w3.Fill = false;
200 // Container child vbox1.Gtk.Box+BoxChild
201 this.hbox1 = new Gtk.HBox();
202 this.hbox1.Name = "hbox1";
203 // Container child hbox1.Gtk.Box+BoxChild
204 this.scrolledwindow1 = new Gtk.ScrolledWindow();
205 this.scrolledwindow1.CanFocus = true;
206 this.scrolledwindow1.Name = "scrolledwindow1";
207 this.scrolledwindow1.VscrollbarPolicy = ((Gtk.PolicyType)(1));
208 this.scrolledwindow1.HscrollbarPolicy = ((Gtk.PolicyType)(1));
209 // Container child scrolledwindow1.Gtk.Container+ContainerChild
210 Gtk.Viewport w4 = new Gtk.Viewport();
211 w4.Name = "GtkViewport";
212 w4.ShadowType = ((Gtk.ShadowType)(0));
213 // Container child GtkViewport.Gtk.Container+ContainerChild
214 this.drawingarea1 = new Gtk.DrawingArea();
215 this.drawingarea1.Name = "drawingarea1";
216 w4.Add(this.drawingarea1);
217 this.scrolledwindow1.Add(w4);
218 this.hbox1.Add(this.scrolledwindow1);
219 Gtk.Box.BoxChild w7 = ((Gtk.Box.BoxChild)(this.hbox1[this.scrolledwindow1]));
220 w7.Position = 1;
221 // Container child hbox1.Gtk.Box+BoxChild
222 this.treeview1 = new Gtk.TreeView();
223 this.treeview1.CanFocus = true;
224 this.treeview1.Name = "treeview1";
225 this.hbox1.Add(this.treeview1);
226 Gtk.Box.BoxChild w8 = ((Gtk.Box.BoxChild)(this.hbox1[this.treeview1]));
227 w8.Position = 2;
228 this.vbox1.Add(this.hbox1);
229 Gtk.Box.BoxChild w9 = ((Gtk.Box.BoxChild)(this.vbox1[this.hbox1]));
230 w9.Position = 1;
231 // Container child vbox1.Gtk.Box+BoxChild
232 this.statusbar1 = new Gtk.Statusbar();
233 this.statusbar1.Name = "statusbar1";
234 this.statusbar1.Spacing = 5;
235 this.vbox1.Add(this.statusbar1);
236 Gtk.Box.BoxChild w10 = ((Gtk.Box.BoxChild)(this.vbox1[this.statusbar1]));
237 w10.PackType = ((Gtk.PackType)(1));
238 w10.Position = 2;
239 w10.Expand = false;
240 w10.Fill = false;
241 this.Add(this.vbox1);
242 if ((this.Child != null)) {
243 this.Child.ShowAll();
244 }
245 this.DefaultWidth = 800;
246 this.DefaultHeight = 800;
247 this.Show();
248 this.DeleteEvent += new Gtk.DeleteEventHandler(this.OnDeleteEvent);
249 this.ConnectToGridserver.Activated += new System.EventHandler(this.ConnectToGridServerMenu);
250 this.ExitGridManager.Activated += new System.EventHandler(this.QuitMenu);
251 this.ShutdownGridserverOnly.Activated += new System.EventHandler(this.ShutdownGridserverMenu);
252 this.RestartGridserverOnly.Activated += new System.EventHandler(this.RestartGridserverMenu);
253 this.DisconnectFromGridServer.Activated += new System.EventHandler(this.DisconnectGridServerMenu);
254 }
255 }
256}
diff --git a/OpenSim/Grid/Manager/OpenGridServices.Manager/gtk-gui/generated.cs b/OpenSim/Grid/Manager/OpenGridServices.Manager/gtk-gui/generated.cs
new file mode 100644
index 0000000..dd4abdd
--- /dev/null
+++ b/OpenSim/Grid/Manager/OpenGridServices.Manager/gtk-gui/generated.cs
@@ -0,0 +1,35 @@
1// ------------------------------------------------------------------------------
2// <autogenerated>
3// This code was generated by a tool.
4// Mono Runtime Version: 2.0.50727.42
5//
6// Changes to this file may cause incorrect behavior and will be lost if
7// the code is regenerated.
8// </autogenerated>
9// ------------------------------------------------------------------------------
10
11namespace Stetic {
12
13
14 internal class Gui {
15
16 private static bool initialized;
17
18 internal static void Initialize() {
19 if ((Stetic.Gui.initialized == false)) {
20 Stetic.Gui.initialized = true;
21 }
22 }
23 }
24
25 internal class ActionGroups {
26
27 public static Gtk.ActionGroup GetActionGroup(System.Type type) {
28 return Stetic.ActionGroups.GetActionGroup(type.FullName);
29 }
30
31 public static Gtk.ActionGroup GetActionGroup(string name) {
32 return null;
33 }
34 }
35}
diff --git a/OpenSim/Grid/Manager/OpenGridServices.Manager/gtk-gui/gui.stetic b/OpenSim/Grid/Manager/OpenGridServices.Manager/gtk-gui/gui.stetic
new file mode 100644
index 0000000..c883f08
--- /dev/null
+++ b/OpenSim/Grid/Manager/OpenGridServices.Manager/gtk-gui/gui.stetic
@@ -0,0 +1,502 @@
1<?xml version="1.0" encoding="utf-8"?>
2<stetic-interface>
3 <widget class="Gtk.Window" id="OpenGridServices.Manager.MainWindow" design-size="800 800">
4 <action-group name="Default">
5 <action id="Grid">
6 <property name="Type">Action</property>
7 <property name="Accelerator">&lt;Alt&gt;&lt;Mod2&gt;g</property>
8 <property name="HideIfEmpty">False</property>
9 <property name="Label" translatable="yes">Grid</property>
10 <property name="ShortLabel" translatable="yes">Grid</property>
11 </action>
12 <action id="User">
13 <property name="Type">Action</property>
14 <property name="HideIfEmpty">False</property>
15 <property name="Label" translatable="yes">User</property>
16 <property name="ShortLabel" translatable="yes">User</property>
17 </action>
18 <action id="Asset">
19 <property name="Type">Action</property>
20 <property name="HideIfEmpty">False</property>
21 <property name="Label" translatable="yes">Asset</property>
22 <property name="ShortLabel" translatable="yes">Asset</property>
23 </action>
24 <action id="Region">
25 <property name="Type">Action</property>
26 <property name="Label" translatable="yes">Region</property>
27 <property name="ShortLabel" translatable="yes">Region</property>
28 </action>
29 <action id="Services">
30 <property name="Type">Action</property>
31 <property name="Label" translatable="yes">Services</property>
32 <property name="ShortLabel" translatable="yes">Services</property>
33 </action>
34 <action id="ConnectToGridserver">
35 <property name="Type">Action</property>
36 <property name="HideIfEmpty">False</property>
37 <property name="Label" translatable="yes">Connect to gridserver...</property>
38 <property name="ShortLabel" translatable="yes">Connect to gridserver</property>
39 <property name="StockId">gtk-connect</property>
40 <signal name="Activated" handler="ConnectToGridServerMenu" />
41 </action>
42 <action id="RestartWholeGrid">
43 <property name="Type">Action</property>
44 <property name="Label" translatable="yes">Restart whole grid</property>
45 <property name="ShortLabel" translatable="yes">Restart whole grid</property>
46 <property name="StockId">gtk-refresh</property>
47 </action>
48 <action id="ShutdownWholeGrid">
49 <property name="Type">Action</property>
50 <property name="Label" translatable="yes">Shutdown whole grid</property>
51 <property name="ShortLabel" translatable="yes">Shutdown whole grid</property>
52 <property name="StockId">gtk-stop</property>
53 </action>
54 <action id="ExitGridManager">
55 <property name="Type">Action</property>
56 <property name="Label" translatable="yes">Exit grid manager</property>
57 <property name="ShortLabel" translatable="yes">Exit grid manager</property>
58 <property name="StockId">gtk-close</property>
59 <signal name="Activated" handler="QuitMenu" after="yes" />
60 </action>
61 <action id="ConnectToUserserver">
62 <property name="Type">Action</property>
63 <property name="Label" translatable="yes">Connect to userserver</property>
64 <property name="ShortLabel" translatable="yes">Connect to userserver</property>
65 <property name="StockId">gtk-connect</property>
66 </action>
67 <action id="AccountManagment">
68 <property name="Type">Action</property>
69 <property name="Label" translatable="yes">Account managment</property>
70 <property name="ShortLabel" translatable="yes">Account managment</property>
71 <property name="StockId">gtk-properties</property>
72 </action>
73 <action id="GlobalNotice">
74 <property name="Type">Action</property>
75 <property name="Label" translatable="yes">Global notice</property>
76 <property name="ShortLabel" translatable="yes">Global notice</property>
77 <property name="StockId">gtk-network</property>
78 </action>
79 <action id="DisableAllLogins">
80 <property name="Type">Action</property>
81 <property name="Label" translatable="yes">Disable all logins</property>
82 <property name="ShortLabel" translatable="yes">Disable all logins</property>
83 <property name="StockId">gtk-no</property>
84 </action>
85 <action id="DisableNonGodUsersOnly">
86 <property name="Type">Action</property>
87 <property name="Label" translatable="yes">Disable non-god users only</property>
88 <property name="ShortLabel" translatable="yes">Disable non-god users only</property>
89 <property name="StockId">gtk-no</property>
90 </action>
91 <action id="ShutdownUserServer">
92 <property name="Type">Action</property>
93 <property name="Label" translatable="yes">Shutdown user server</property>
94 <property name="ShortLabel" translatable="yes">Shutdown user server</property>
95 <property name="StockId">gtk-stop</property>
96 </action>
97 <action id="ShutdownGridserverOnly">
98 <property name="Type">Action</property>
99 <property name="Label" translatable="yes">Shutdown gridserver only</property>
100 <property name="ShortLabel" translatable="yes">Shutdown gridserver only</property>
101 <property name="StockId">gtk-stop</property>
102 <signal name="Activated" handler="ShutdownGridserverMenu" after="yes" />
103 </action>
104 <action id="RestartGridserverOnly">
105 <property name="Type">Action</property>
106 <property name="Label" translatable="yes">Restart gridserver only</property>
107 <property name="ShortLabel" translatable="yes">Restart gridserver only</property>
108 <property name="StockId">gtk-refresh</property>
109 <signal name="Activated" handler="RestartGridserverMenu" after="yes" />
110 </action>
111 <action id="DefaultLocalGridUserserver">
112 <property name="Type">Action</property>
113 <property name="Label" translatable="yes">Default local grid userserver</property>
114 <property name="ShortLabel" translatable="yes">Default local grid userserver</property>
115 </action>
116 <action id="CustomUserserver">
117 <property name="Type">Action</property>
118 <property name="Label" translatable="yes">Custom userserver...</property>
119 <property name="ShortLabel" translatable="yes">Custom userserver</property>
120 </action>
121 <action id="RemoteGridDefaultUserserver">
122 <property name="Type">Action</property>
123 <property name="Label" translatable="yes">Remote grid default userserver...</property>
124 <property name="ShortLabel" translatable="yes">Remote grid default userserver</property>
125 </action>
126 <action id="DisconnectFromGridServer">
127 <property name="Type">Action</property>
128 <property name="Label" translatable="yes">Disconnect from grid server</property>
129 <property name="ShortLabel" translatable="yes">Disconnect from grid server</property>
130 <property name="StockId">gtk-disconnect</property>
131 <property name="Visible">False</property>
132 <signal name="Activated" handler="DisconnectGridServerMenu" after="yes" />
133 </action>
134 <action id="UploadAsset">
135 <property name="Type">Action</property>
136 <property name="Label" translatable="yes">Upload asset</property>
137 <property name="ShortLabel" translatable="yes">Upload asset</property>
138 </action>
139 <action id="AssetManagement">
140 <property name="Type">Action</property>
141 <property name="Label" translatable="yes">Asset management</property>
142 <property name="ShortLabel" translatable="yes">Asset management</property>
143 </action>
144 <action id="ConnectToAssetServer">
145 <property name="Type">Action</property>
146 <property name="Label" translatable="yes">Connect to asset server</property>
147 <property name="ShortLabel" translatable="yes">Connect to asset server</property>
148 </action>
149 <action id="ConnectToDefaultAssetServerForGrid">
150 <property name="Type">Action</property>
151 <property name="Label" translatable="yes">Connect to default asset server for grid</property>
152 <property name="ShortLabel" translatable="yes">Connect to default asset server for grid</property>
153 </action>
154 <action id="DefaultForLocalGrid">
155 <property name="Type">Action</property>
156 <property name="Label" translatable="yes">Default for local grid</property>
157 <property name="ShortLabel" translatable="yes">Default for local grid</property>
158 </action>
159 <action id="DefaultForRemoteGrid">
160 <property name="Type">Action</property>
161 <property name="Label" translatable="yes">Default for remote grid...</property>
162 <property name="ShortLabel" translatable="yes">Default for remote grid...</property>
163 </action>
164 <action id="CustomAssetServer">
165 <property name="Type">Action</property>
166 <property name="Label" translatable="yes">Custom asset server...</property>
167 <property name="ShortLabel" translatable="yes">Custom asset server...</property>
168 </action>
169 </action-group>
170 <property name="MemberName" />
171 <property name="WidthRequest">800</property>
172 <property name="HeightRequest">600</property>
173 <property name="Title" translatable="yes">Open Grid Services Manager</property>
174 <property name="Icon">stock:gtk-network Dialog</property>
175 <signal name="DeleteEvent" handler="OnDeleteEvent" />
176 <child>
177 <widget class="Gtk.VBox" id="vbox1">
178 <property name="MemberName" />
179 <child>
180 <widget class="Gtk.MenuBar" id="menubar2">
181 <property name="MemberName" />
182 <property name="HeightRequest">25</property>
183 <node name="menubar2" type="Menubar">
184 <node type="Menu" action="Grid">
185 <node type="Menuitem" action="ConnectToGridserver" />
186 <node type="Menuitem" action="DisconnectFromGridServer" />
187 <node type="Separator" />
188 <node type="Menuitem" action="RestartWholeGrid" />
189 <node type="Menuitem" action="RestartGridserverOnly" />
190 <node type="Separator" />
191 <node type="Menuitem" action="ShutdownWholeGrid" />
192 <node type="Menuitem" action="ShutdownGridserverOnly" />
193 <node type="Separator" />
194 <node type="Menuitem" action="ExitGridManager" />
195 </node>
196 <node type="Menu" action="User">
197 <node type="Menu" action="ConnectToUserserver">
198 <node type="Menuitem" action="DefaultLocalGridUserserver" />
199 <node type="Menuitem" action="CustomUserserver" />
200 <node type="Menuitem" action="RemoteGridDefaultUserserver" />
201 </node>
202 <node type="Separator" />
203 <node type="Menuitem" action="AccountManagment" />
204 <node type="Menuitem" action="GlobalNotice" />
205 <node type="Separator" />
206 <node type="Menuitem" action="DisableAllLogins" />
207 <node type="Menuitem" action="DisableNonGodUsersOnly" />
208 <node type="Separator" />
209 <node type="Menuitem" action="ShutdownUserServer" />
210 </node>
211 <node type="Menu" action="Asset">
212 <node type="Menuitem" action="UploadAsset" />
213 <node type="Menuitem" action="AssetManagement" />
214 <node type="Menu" action="ConnectToAssetServer">
215 <node type="Menuitem" action="DefaultForLocalGrid" />
216 <node type="Menuitem" action="DefaultForRemoteGrid" />
217 <node type="Menuitem" action="CustomAssetServer" />
218 </node>
219 </node>
220 <node type="Menu" action="Region" />
221 <node type="Menu" action="Services" />
222 </node>
223 </widget>
224 <packing>
225 <property name="Position">0</property>
226 <property name="AutoSize">False</property>
227 <property name="Expand">False</property>
228 <property name="Fill">False</property>
229 </packing>
230 </child>
231 <child>
232 <widget class="Gtk.HBox" id="hbox1">
233 <property name="MemberName" />
234 <child>
235 <placeholder />
236 </child>
237 <child>
238 <widget class="Gtk.ScrolledWindow" id="scrolledwindow1">
239 <property name="MemberName" />
240 <property name="CanFocus">True</property>
241 <property name="VscrollbarPolicy">Automatic</property>
242 <property name="HscrollbarPolicy">Automatic</property>
243 <child>
244 <widget class="Gtk.Viewport" id="GtkViewport">
245 <property name="MemberName" />
246 <property name="ShadowType">None</property>
247 <child>
248 <widget class="Gtk.DrawingArea" id="drawingarea1">
249 <property name="MemberName" />
250 </widget>
251 </child>
252 </widget>
253 </child>
254 </widget>
255 <packing>
256 <property name="Position">1</property>
257 <property name="AutoSize">True</property>
258 </packing>
259 </child>
260 <child>
261 <widget class="Gtk.TreeView" id="treeview1">
262 <property name="MemberName" />
263 <property name="CanFocus">True</property>
264 </widget>
265 <packing>
266 <property name="Position">2</property>
267 <property name="AutoSize">True</property>
268 </packing>
269 </child>
270 </widget>
271 <packing>
272 <property name="Position">1</property>
273 <property name="AutoSize">True</property>
274 </packing>
275 </child>
276 <child>
277 <widget class="Gtk.Statusbar" id="statusbar1">
278 <property name="MemberName">statusBar1</property>
279 <property name="Spacing">5</property>
280 <child>
281 <placeholder />
282 </child>
283 <child>
284 <placeholder />
285 </child>
286 </widget>
287 <packing>
288 <property name="PackType">End</property>
289 <property name="Position">2</property>
290 <property name="AutoSize">False</property>
291 <property name="Expand">False</property>
292 <property name="Fill">False</property>
293 </packing>
294 </child>
295 </widget>
296 </child>
297 </widget>
298 <widget class="Gtk.Dialog" id="OpenGridServices.Manager.ConnectToGridServerDialog" design-size="476 137">
299 <property name="MemberName" />
300 <property name="Events">ButtonPressMask</property>
301 <property name="Title" translatable="yes">Connect to Grid server</property>
302 <property name="WindowPosition">CenterOnParent</property>
303 <property name="Buttons">2</property>
304 <property name="HelpButton">False</property>
305 <property name="HasSeparator">False</property>
306 <signal name="Response" handler="OnResponse" />
307 <child internal-child="VBox">
308 <widget class="Gtk.VBox" id="dialog_VBox">
309 <property name="MemberName" />
310 <property name="Events">ButtonPressMask</property>
311 <property name="BorderWidth">2</property>
312 <child>
313 <widget class="Gtk.VBox" id="vbox2">
314 <property name="MemberName" />
315 <child>
316 <placeholder />
317 </child>
318 <child>
319 <placeholder />
320 </child>
321 <child>
322 <widget class="Gtk.VBox" id="vbox3">
323 <property name="MemberName" />
324 <child>
325 <widget class="Gtk.HBox" id="hbox1">
326 <property name="MemberName" />
327 <child>
328 <widget class="Gtk.Label" id="label1">
329 <property name="MemberName" />
330 <property name="Xalign">1</property>
331 <property name="LabelProp" translatable="yes">Grid server URL: </property>
332 <property name="Justify">Right</property>
333 </widget>
334 <packing>
335 <property name="Position">0</property>
336 <property name="AutoSize">False</property>
337 </packing>
338 </child>
339 <child>
340 <widget class="Gtk.Entry" id="entry1">
341 <property name="MemberName" />
342 <property name="CanFocus">True</property>
343 <property name="Text" translatable="yes">http://gridserver:8001</property>
344 <property name="IsEditable">True</property>
345 <property name="MaxLength">255</property>
346 <property name="InvisibleChar">•</property>
347 </widget>
348 <packing>
349 <property name="Position">1</property>
350 <property name="AutoSize">False</property>
351 </packing>
352 </child>
353 <child>
354 <placeholder />
355 </child>
356 </widget>
357 <packing>
358 <property name="Position">0</property>
359 <property name="AutoSize">True</property>
360 <property name="Expand">False</property>
361 <property name="Fill">False</property>
362 </packing>
363 </child>
364 <child>
365 <widget class="Gtk.HBox" id="hbox2">
366 <property name="MemberName" />
367 <child>
368 <widget class="Gtk.Label" id="label2">
369 <property name="MemberName" />
370 <property name="Xalign">1</property>
371 <property name="LabelProp" translatable="yes">Username:</property>
372 <property name="Justify">Right</property>
373 </widget>
374 <packing>
375 <property name="Position">0</property>
376 <property name="AutoSize">False</property>
377 </packing>
378 </child>
379 <child>
380 <widget class="Gtk.Entry" id="entry2">
381 <property name="MemberName" />
382 <property name="CanFocus">True</property>
383 <property name="IsEditable">True</property>
384 <property name="InvisibleChar">•</property>
385 </widget>
386 <packing>
387 <property name="Position">1</property>
388 <property name="AutoSize">True</property>
389 </packing>
390 </child>
391 <child>
392 <placeholder />
393 </child>
394 </widget>
395 <packing>
396 <property name="Position">1</property>
397 <property name="AutoSize">False</property>
398 <property name="Expand">False</property>
399 <property name="Fill">False</property>
400 </packing>
401 </child>
402 <child>
403 <widget class="Gtk.HBox" id="hbox3">
404 <property name="MemberName" />
405 <child>
406 <widget class="Gtk.Label" id="label3">
407 <property name="MemberName" />
408 <property name="Xalign">1</property>
409 <property name="LabelProp" translatable="yes">Password:</property>
410 <property name="Justify">Right</property>
411 </widget>
412 <packing>
413 <property name="Position">0</property>
414 <property name="AutoSize">False</property>
415 </packing>
416 </child>
417 <child>
418 <widget class="Gtk.Entry" id="entry3">
419 <property name="MemberName" />
420 <property name="CanFocus">True</property>
421 <property name="IsEditable">True</property>
422 <property name="InvisibleChar">•</property>
423 </widget>
424 <packing>
425 <property name="Position">1</property>
426 <property name="AutoSize">True</property>
427 </packing>
428 </child>
429 <child>
430 <placeholder />
431 </child>
432 </widget>
433 <packing>
434 <property name="Position">2</property>
435 <property name="AutoSize">True</property>
436 <property name="Expand">False</property>
437 <property name="Fill">False</property>
438 </packing>
439 </child>
440 </widget>
441 <packing>
442 <property name="Position">2</property>
443 <property name="AutoSize">True</property>
444 <property name="Expand">False</property>
445 <property name="Fill">False</property>
446 </packing>
447 </child>
448 </widget>
449 <packing>
450 <property name="Position">0</property>
451 <property name="AutoSize">True</property>
452 </packing>
453 </child>
454 </widget>
455 </child>
456 <child internal-child="ActionArea">
457 <widget class="Gtk.HButtonBox" id="OpenGridServices.Manager.ConnectToGridServerDialog_ActionArea">
458 <property name="MemberName" />
459 <property name="Events">ButtonPressMask</property>
460 <property name="Spacing">6</property>
461 <property name="BorderWidth">5</property>
462 <property name="Size">2</property>
463 <property name="LayoutStyle">End</property>
464 <child>
465 <widget class="Gtk.Button" id="button2">
466 <property name="MemberName" />
467 <property name="CanDefault">True</property>
468 <property name="CanFocus">True</property>
469 <property name="Type">TextAndIcon</property>
470 <property name="Icon">stock:gtk-apply Menu</property>
471 <property name="Label" translatable="yes">Connect</property>
472 <property name="UseUnderline">True</property>
473 <property name="IsDialogButton">True</property>
474 <property name="ResponseId">-5</property>
475 </widget>
476 <packing>
477 <property name="Expand">False</property>
478 <property name="Fill">False</property>
479 </packing>
480 </child>
481 <child>
482 <widget class="Gtk.Button" id="button8">
483 <property name="MemberName" />
484 <property name="CanDefault">True</property>
485 <property name="CanFocus">True</property>
486 <property name="Type">TextAndIcon</property>
487 <property name="Icon">stock:gtk-cancel Menu</property>
488 <property name="Label" translatable="yes">Cancel</property>
489 <property name="UseUnderline">True</property>
490 <property name="IsDialogButton">True</property>
491 <property name="ResponseId">-6</property>
492 </widget>
493 <packing>
494 <property name="Position">1</property>
495 <property name="Expand">False</property>
496 <property name="Fill">False</property>
497 </packing>
498 </child>
499 </widget>
500 </child>
501 </widget>
502</stetic-interface> \ No newline at end of file
diff --git a/OpenSim/Grid/UserServer.Config/AssemblyInfo.cs b/OpenSim/Grid/UserServer.Config/AssemblyInfo.cs
new file mode 100644
index 0000000..15298e8
--- /dev/null
+++ b/OpenSim/Grid/UserServer.Config/AssemblyInfo.cs
@@ -0,0 +1,56 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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// Information about this assembly is defined by the following
31// attributes.
32//
33// change them to the information which is associated with the assembly
34// you compile.
35
36[assembly: AssemblyTitle("UserConfig")]
37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("UserConfig")]
41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")]
44
45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)]
48
49// The assembly version has following format :
50//
51// Major.Minor.Build.Revision
52//
53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default):
55
56[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Grid/UserServer.Config/DbUserConfig.cs b/OpenSim/Grid/UserServer.Config/DbUserConfig.cs
new file mode 100644
index 0000000..c7f8255
--- /dev/null
+++ b/OpenSim/Grid/UserServer.Config/DbUserConfig.cs
@@ -0,0 +1,95 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 Db4objects.Db4o;
30using OpenSim.Framework.Console;
31using OpenSim.Framework.Interfaces;
32
33namespace OpenUser.Config.UserConfigDb4o
34{
35 public class Db4oConfigPlugin: IUserConfig
36 {
37 public UserConfig GetConfigObject()
38 {
39 MainLog.Instance.Verbose("Loading Db40Config dll");
40 return ( new DbUserConfig());
41 }
42 }
43
44 public class DbUserConfig : UserConfig
45 {
46 private IObjectContainer db;
47
48 public void LoadDefaults() {
49 MainLog.Instance.Notice("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings");
50
51 this.DefaultStartupMsg = MainLog.Instance.CmdPrompt("Default startup message", "Welcome to OGS");
52
53 this.GridServerURL = MainLog.Instance.CmdPrompt("Grid server URL","http://127.0.0.1:8001/");
54 this.GridSendKey = MainLog.Instance.CmdPrompt("Key to send to grid server","null");
55 this.GridRecvKey = MainLog.Instance.CmdPrompt("Key to expect from grid server","null");
56 }
57
58 public override void InitConfig() {
59 try {
60 db = Db4oFactory.OpenFile("openuser.yap");
61 IObjectSet result = db.Get(typeof(DbUserConfig));
62 if(result.Count==1) {
63 MainLog.Instance.Verbose("Config.cs:InitConfig() - Found a UserConfig object in the local database, loading");
64 foreach (DbUserConfig cfg in result) {
65 this.GridServerURL=cfg.GridServerURL;
66 this.GridSendKey=cfg.GridSendKey;
67 this.GridRecvKey=cfg.GridRecvKey;
68 this.DefaultStartupMsg=cfg.DefaultStartupMsg;
69 }
70 } else {
71 MainLog.Instance.Verbose("Config.cs:InitConfig() - Could not find object in database, loading precompiled defaults");
72 LoadDefaults();
73 MainLog.Instance.Verbose("Writing out default settings to local database");
74 db.Set(this);
75 db.Close();
76 }
77 } catch(Exception e) {
78 MainLog.Instance.Warn("Config.cs:InitConfig() - Exception occured");
79 MainLog.Instance.Warn(e.ToString());
80 }
81
82 MainLog.Instance.Verbose("User settings loaded:");
83 MainLog.Instance.Verbose("Default startup message: " + this.DefaultStartupMsg);
84 MainLog.Instance.Verbose("Grid server URL: " + this.GridServerURL);
85 MainLog.Instance.Verbose("Key to send to grid: " + this.GridSendKey);
86 MainLog.Instance.Verbose("Key to expect from grid: " + this.GridRecvKey);
87 }
88
89
90 public void Shutdown() {
91 db.Close();
92 }
93 }
94
95}
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
new file mode 100644
index 0000000..c792918
--- /dev/null
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -0,0 +1,214 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28
29using System;
30using System.Collections.Generic;
31using System.Reflection;
32using libsecondlife;
33using OpenSim.Framework.Console;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Servers;
36using OpenSim.Framework.User;
37using OpenSim.Framework.Utilities;
38using OpenSim.GenericConfig;
39
40namespace OpenSim.Grid.UserServer
41{
42 /// <summary>
43 /// </summary>
44 public class OpenUser_Main : conscmd_callback
45 {
46 private string ConfigDll = "OpenSim.Grid.UserServer.Config.dll";
47 private string StorageDll = "OpenSim.Framework.Data.MySQL.dll";
48 private UserConfig Cfg;
49 protected IGenericConfig localXMLConfig;
50
51 public UserManager m_userManager;
52
53 public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>();
54
55 LogBase m_console;
56
57 [STAThread]
58 public static void Main(string[] args)
59 {
60 Console.WriteLine("Launching UserServer...");
61
62 OpenUser_Main userserver = new OpenUser_Main();
63
64 userserver.Startup();
65 userserver.Work();
66 }
67
68 private OpenUser_Main()
69 {
70 m_console = new LogBase("opengrid-userserver-console.log", "OpenUser", this , false);
71 MainLog.Instance = m_console;
72 }
73
74 private void Work()
75 {
76 m_console.Notice("Enter help for a list of commands\n");
77
78 while (true)
79 {
80 m_console.MainLogPrompt();
81 }
82 }
83
84 public void Startup()
85 {
86 this.localXMLConfig = new XmlConfig("UserServerConfig.xml");
87 this.localXMLConfig.LoadData();
88 this.ConfigDB(this.localXMLConfig);
89 this.localXMLConfig.Close();
90
91 MainLog.Instance.Verbose("Main.cs:Startup() - Loading configuration");
92 Cfg = this.LoadConfigDll(this.ConfigDll);
93 Cfg.InitConfig();
94
95 MainLog.Instance.Verbose("Main.cs:Startup() - Establishing data connection");
96 m_userManager = new UserManager();
97 m_userManager._config = Cfg;
98 m_userManager.AddPlugin(StorageDll);
99
100 MainLog.Instance.Verbose("Main.cs:Startup() - Starting HTTP process");
101 BaseHttpServer httpServer = new BaseHttpServer(8002);
102
103 httpServer.AddXmlRPCHandler("login_to_simulator", m_userManager.XmlRpcLoginMethod);
104
105 httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName);
106 httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID);
107
108 httpServer.AddStreamHandler( new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod ));
109
110 httpServer.Start();
111 m_console.Status("Userserver 0.3 - Startup complete");
112 }
113
114
115 public void do_create(string what)
116 {
117 switch (what)
118 {
119 case "user":
120 string tempfirstname;
121 string templastname;
122 string tempMD5Passwd;
123 uint regX = 1000;
124 uint regY = 1000;
125
126 tempfirstname = m_console.CmdPrompt("First name");
127 templastname = m_console.CmdPrompt("Last name");
128 tempMD5Passwd = m_console.PasswdPrompt("Password");
129 regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X"));
130 regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y"));
131
132 tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + "");
133
134 m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
135 break;
136 }
137 }
138
139 public void RunCmd(string cmd, string[] cmdparams)
140 {
141 switch (cmd)
142 {
143 case "help":
144 m_console.Notice("create user - create a new user");
145 m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
146 break;
147
148 case "create":
149 do_create(cmdparams[0]);
150 break;
151
152 case "shutdown":
153 m_console.Close();
154 Environment.Exit(0);
155 break;
156 }
157 }
158
159 private void ConfigDB(IGenericConfig configData)
160 {
161 try
162 {
163 string attri = "";
164 attri = configData.GetAttribute("DataBaseProvider");
165 if (attri == "")
166 {
167 StorageDll = "OpenSim.Framework.Data.DB4o.dll";
168 configData.SetAttribute("DataBaseProvider", "OpenSim.Framework.Data.DB4o.dll");
169 }
170 else
171 {
172 StorageDll = attri;
173 }
174 configData.Commit();
175 }
176 catch
177 {
178
179 }
180 }
181
182 private UserConfig LoadConfigDll(string dllName)
183 {
184 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
185 UserConfig config = null;
186
187 foreach (Type pluginType in pluginAssembly.GetTypes())
188 {
189 if (pluginType.IsPublic)
190 {
191 if (!pluginType.IsAbstract)
192 {
193 Type typeInterface = pluginType.GetInterface("IUserConfig", true);
194
195 if (typeInterface != null)
196 {
197 IUserConfig plug = (IUserConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
198 config = plug.GetConfigObject();
199 break;
200 }
201
202 typeInterface = null;
203 }
204 }
205 }
206 pluginAssembly = null;
207 return config;
208 }
209
210 public void Show(string ShowWhat)
211 {
212 }
213 }
214}
diff --git a/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..a0a6f3c
--- /dev/null
+++ b/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs
@@ -0,0 +1,31 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("OGS-UserServer")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OGS-UserServer")]
11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("e266513a-090b-4d38-80f6-8599eef68c8c")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30[assembly: AssemblyVersion("1.0.0.0")]
31[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs
new file mode 100644
index 0000000..04bf64a
--- /dev/null
+++ b/OpenSim/Grid/UserServer/UserManager.cs
@@ -0,0 +1,94 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 Nwc.XmlRpc;
31using OpenSim.Framework.Data;
32using OpenSim.Framework.UserManagement;
33
34namespace OpenSim.Grid.UserServer
35{
36 public class UserManager : UserManagerBase
37 {
38 public UserManager()
39 {
40 }
41
42 /// <summary>
43 /// Customises the login response and fills in missing values.
44 /// </summary>
45 /// <param name="response">The existing response</param>
46 /// <param name="theUser">The user profile</param>
47 public override void CustomiseResponse( LoginResponse response, UserProfileData theUser)
48 {
49 // Load information from the gridserver
50 SimProfileData SimInfo = new SimProfileData();
51 SimInfo = SimInfo.RequestSimProfileData(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey);
52
53 // Customise the response
54 // Home Location
55 response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * 256).ToString() + ",r" + (SimInfo.regionLocY * 256).ToString() + "], " +
56 "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
57 "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
58
59 // Destination
60 Console.WriteLine("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + SimInfo.regionLocY);
61 response.SimAddress = SimInfo.serverIP;
62 response.SimPort = (Int32)SimInfo.serverPort;
63 response.RegionX = SimInfo.regionLocX;
64 response.RegionY = SimInfo.regionLocX;
65
66 // Notify the target of an incoming user
67 Console.WriteLine("Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI+ ")");
68
69 // Prepare notification
70 Hashtable SimParams = new Hashtable();
71 SimParams["session_id"] = theUser.currentAgent.sessionID.ToString();
72 SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString();
73 SimParams["firstname"] = theUser.username;
74 SimParams["lastname"] = theUser.surname;
75 SimParams["agent_id"] = theUser.UUID.ToString();
76 SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode);
77 SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString();
78 SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString();
79 SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString();
80 SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString();
81 ArrayList SendParams = new ArrayList();
82 SendParams.Add(SimParams);
83
84 // Update agent with target sim
85 theUser.currentAgent.currentRegion = SimInfo.UUID;
86 theUser.currentAgent.currentHandle = SimInfo.regionHandle;
87
88 System.Console.WriteLine("sending reply");
89 // Send
90 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
91 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 3000);
92 }
93 }
94}
diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs
new file mode 100644
index 0000000..0428f5a
--- /dev/null
+++ b/OpenSim/Region/Application/Application.cs
@@ -0,0 +1,120 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 OpenSim.Framework.Console;
30using OpenSim.Region.Environment.Scenes;
31
32namespace OpenSim
33{
34 public class Application
35 {
36 //could move our main function into OpenSimMain and kill this class
37 [STAThread]
38 public static void Main(string[] args)
39 {
40 Console.WriteLine("OpenSim " + VersionInfo.Version + "\n");
41 Console.WriteLine("Starting...\n");
42
43 bool sandBoxMode = false;
44 bool startLoginServer = false;
45 string physicsEngine = "basicphysics";
46 bool allowFlying = false;
47 bool userAccounts = false;
48 bool gridLocalAsset = false;
49 bool useConfigFile = false;
50 bool silent = false;
51 string configFile = "simconfig.xml";
52
53 for (int i = 0; i < args.Length; i++)
54 {
55 if (args[i] == "-sandbox")
56 {
57 sandBoxMode = true;
58 startLoginServer = true;
59 }
60 /*
61 if (args[i] == "-loginserver")
62 {
63 startLoginServer = true;
64 }*/
65 if (args[i] == "-accounts")
66 {
67 userAccounts = true;
68 }
69 if (args[i] == "-realphysx")
70 {
71 physicsEngine = "RealPhysX";
72 allowFlying = true;
73 }
74 if (args[i] == "-ode")
75 {
76 physicsEngine = "OpenDynamicsEngine";
77 allowFlying = true;
78 }
79 if (args[i] == "-localasset")
80 {
81 gridLocalAsset = true;
82 }
83 if (args[i] == "-configfile")
84 {
85 useConfigFile = true;
86 }
87 if (args[i] == "-noverbose")
88 {
89 silent = true;
90 }
91 if (args[i] == "-config")
92 {
93 try
94 {
95 i++;
96 configFile = args[i];
97 }
98 catch (Exception e)
99 {
100 Console.WriteLine("-config: Please specify a config file. (" + e.ToString() + ")");
101 }
102 }
103 }
104
105 OpenSimMain sim = new OpenSimMain(sandBoxMode, startLoginServer, physicsEngine, useConfigFile, silent, configFile);
106 // OpenSimRoot.Instance.Application = sim;
107 sim.m_sandbox = sandBoxMode;
108 sim.user_accounts = userAccounts;
109 sim.gridLocalAsset = gridLocalAsset;
110 ScenePresence.PhysicsEngineFlying = allowFlying;
111
112 sim.StartUp();
113
114 while (true)
115 {
116 MainLog.Instance.MainLogPrompt();
117 }
118 }
119 }
120}
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
new file mode 100644
index 0000000..728329e
--- /dev/null
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -0,0 +1,482 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28
29using System;
30using System.IO;
31using libsecondlife;
32using OpenSim.Assets;
33using OpenSim.Framework;
34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Console;
36using OpenSim.Framework.Data;
37using OpenSim.Framework.Interfaces;
38using OpenSim.Framework.Servers;
39using OpenSim.Framework.Types;
40using OpenSim.GenericConfig;
41using OpenSim.Physics.Manager;
42using OpenSim.Region.Caches;
43using OpenSim.Region.ClientStack;
44using OpenSim.Region.Communications.Local;
45using OpenSim.Region.Communications.OGS1;
46using OpenSim.Region.Environment.Scenes;
47using System.Text;
48
49namespace OpenSim
50{
51
52 public class OpenSimMain : RegionApplicationBase, conscmd_callback
53 {
54 protected CommunicationsManager commsManager;
55 // private CheckSumServer checkServer;
56
57 private bool m_silent;
58 private string m_logFilename = "region-console-" + Guid.NewGuid().ToString() + ".log";
59
60 public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile)
61 {
62 this.configFileSetup = useConfigFile;
63 m_sandbox = sandBoxMode;
64 m_loginserver = startLoginServer;
65 m_physicsEngine = physicsEngine;
66 m_config = configFile;
67 m_silent = silent;
68 }
69
70 /// <summary>
71 /// Performs initialisation of the world, such as loading configuration from disk.
72 /// </summary>
73 public override void StartUp()
74 {
75 this.serversData = new NetworkServersInfo();
76
77 this.localConfig = new XmlConfig(m_config);
78 this.localConfig.LoadData();
79
80 if (this.configFileSetup)
81 {
82 this.SetupFromConfigFile(this.localConfig);
83 }
84
85 m_log = new LogBase(m_logFilename, "Region", this, m_silent);
86 MainLog.Instance = m_log;
87
88 m_log.Verbose("Main.cs:Startup() - Loading configuration");
89 this.serversData.InitConfig(this.m_sandbox, this.localConfig);
90 this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change
91
92 ScenePresence.LoadTextureFile("avatar-texture.dat");
93
94 ClientView.TerrainManager = new TerrainManager(new SecondLife());
95
96 this.SetupHttpListener();
97
98 if (m_sandbox)
99 {
100 this.SetupLocalGridServers();
101 // this.checkServer = new CheckSumServer(12036);
102 // this.checkServer.ServerListener();
103 }
104 else
105 {
106 this.SetupRemoteGridServers();
107 }
108
109 startuptime = DateTime.Now;
110
111 this.physManager = new PhysicsManager();
112 this.physManager.LoadPlugins();
113
114 this.SetupWorld();
115
116 m_log.Verbose("Main.cs:Startup() - Initialising HTTP server");
117
118 if (m_sandbox)
119 {
120 httpServer.AddXmlRPCHandler("login_to_simulator", ((CommunicationsLocal)this.commsManager).UserServices.XmlRpcLoginMethod);
121 }
122
123 //Start http server
124 m_log.Verbose("Main.cs:Startup() - Starting HTTP server");
125 httpServer.Start();
126
127 // Start UDP servers
128 for (int i = 0; i < m_udpServer.Count; i++)
129 {
130 this.m_udpServer[i].ServerListener();
131 }
132
133 }
134
135 # region Setup methods
136 protected override void SetupLocalGridServers()
137 {
138 try
139 {
140 AssetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", this.serversData.AssetURL, this.serversData.AssetSendKey);
141 InventoryCache = new InventoryCache();
142 this.commsManager = new CommunicationsLocal(this.serversData, httpServer);
143 }
144 catch (Exception e)
145 {
146 m_log.Error(e.Message + "\nSorry, could not setup local cache");
147 Environment.Exit(1);
148 }
149
150 }
151
152 protected override void SetupRemoteGridServers()
153 {
154 try
155 {
156 AssetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", this.serversData.AssetURL, this.serversData.AssetSendKey);
157 InventoryCache = new InventoryCache();
158 this.commsManager = new CommunicationsOGS1(this.serversData, httpServer);
159 }
160 catch (Exception e)
161 {
162 m_log.Error(e.Message + "\nSorry, could not setup remote cache");
163 Environment.Exit(1);
164 }
165 }
166
167 protected override void SetupWorld()
168 {
169 IGenericConfig regionConfig;
170 Scene LocalWorld;
171 UDPServer udpServer;
172 RegionInfo regionDat = new RegionInfo();
173 AuthenticateSessionsBase authenBase;
174
175 string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Regions");
176 string[] configFiles = Directory.GetFiles(path, "*.xml");
177
178 if (configFiles.Length == 0)
179 {
180 string path2 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Regions");
181 string path3 = Path.Combine(path2, "default.xml");
182 Console.WriteLine("Creating default region config file");
183 //TODO create default region
184 IGenericConfig defaultConfig = new XmlConfig(path3);
185 defaultConfig.LoadData();
186 defaultConfig.Commit();
187 defaultConfig.Close();
188 defaultConfig = null;
189 configFiles = Directory.GetFiles(path, "*.xml");
190 }
191
192 for (int i = 0; i < configFiles.Length; i++)
193 {
194 regionDat = new RegionInfo();
195 if (m_sandbox)
196 {
197 AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); // new AuthenticateSessionsLocal();
198 this.AuthenticateSessionsHandler.Add(authen);
199 authenBase = authen;
200 }
201 else
202 {
203 AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); //new AuthenticateSessionsRemote();
204 this.AuthenticateSessionsHandler.Add(authen);
205 authenBase = authen;
206 }
207 Console.WriteLine("Loading region config file");
208 regionConfig = new XmlConfig(configFiles[i]);
209 regionConfig.LoadData();
210 regionDat.InitConfig(this.m_sandbox, regionConfig);
211 regionConfig.Close();
212
213 udpServer = new UDPServer(regionDat.InternalEndPoint.Port, this.AssetCache, this.InventoryCache, this.m_log, authenBase);
214
215 m_udpServer.Add(udpServer);
216 this.regionData.Add(regionDat);
217
218 LocalWorld = new Scene(udpServer.PacketServer.ClientManager, regionDat, authenBase, commsManager, this.AssetCache, httpServer);
219 this.m_localWorld.Add(LocalWorld);
220 //LocalWorld.InventoryCache = InventoryCache;
221 //LocalWorld.AssetCache = AssetCache;
222
223 udpServer.LocalWorld = LocalWorld;
224
225 LocalWorld.LoadStorageDLL("OpenSim.Region.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded.
226 LocalWorld.LoadWorldMap();
227
228 m_log.Verbose("Main.cs:Startup() - Starting up messaging system");
229 LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine);
230 LocalWorld.PhysScene.SetTerrain(LocalWorld.Terrain.getHeights1D());
231 LocalWorld.LoadPrimsFromStorage();
232
233 //Master Avatar Setup
234 UserProfileData masterAvatar = commsManager.UserServer.SetupMasterUser(LocalWorld.RegionInfo.MasterAvatarFirstName, LocalWorld.RegionInfo.MasterAvatarLastName, LocalWorld.RegionInfo.MasterAvatarSandboxPassword);
235 if (masterAvatar != null)
236 {
237 LocalWorld.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID;
238 LocalWorld.localStorage.LoadParcels((ILocalStorageParcelReceiver)LocalWorld.parcelManager);
239 }
240
241
242 LocalWorld.StartTimer();
243 }
244 }
245
246 private class SimStatusHandler : IStreamHandler
247 {
248 public byte[] Handle(string path, Stream request)
249 {
250 return Encoding.UTF8.GetBytes("OK");
251 }
252
253 public string ContentType
254 {
255 get { return "text/plain"; }
256 }
257
258 public string HttpMethod
259 {
260 get { return "GET"; }
261 }
262
263 public string Path
264 {
265 get { return "/simstatus/"; }
266 }
267 }
268
269 protected override void SetupHttpListener()
270 {
271 httpServer = new BaseHttpServer(this.serversData.HttpListenerPort); //regionData[0].IPListenPort);
272
273 if (!this.m_sandbox)
274 {
275 httpServer.AddStreamHandler( new SimStatusHandler() );
276 }
277 }
278
279 protected override void ConnectToRemoteGridServer()
280 {
281
282 }
283
284 #endregion
285
286 private void SetupFromConfigFile(IGenericConfig configData)
287 {
288 // Log filename
289 string attri = "";
290 attri = configData.GetAttribute("LogFilename");
291 if (String.IsNullOrEmpty(attri))
292 {
293 }
294 else
295 {
296 m_logFilename = attri;
297 }
298
299 // SandBoxMode
300 attri = "";
301 attri = configData.GetAttribute("SandBox");
302 if ((attri == "") || ((attri != "false") && (attri != "true")))
303 {
304 this.m_sandbox = false;
305 configData.SetAttribute("SandBox", "false");
306 }
307 else
308 {
309 this.m_sandbox = Convert.ToBoolean(attri);
310 }
311
312 // LoginServer
313 attri = "";
314 attri = configData.GetAttribute("LoginServer");
315 if ((attri == "") || ((attri != "false") && (attri != "true")))
316 {
317 this.m_loginserver = false;
318 configData.SetAttribute("LoginServer", "false");
319 }
320 else
321 {
322 this.m_loginserver = Convert.ToBoolean(attri);
323 }
324
325 // Sandbox User accounts
326 attri = "";
327 attri = configData.GetAttribute("UserAccount");
328 if ((attri == "") || ((attri != "false") && (attri != "true")))
329 {
330 this.user_accounts = false;
331 configData.SetAttribute("UserAccounts", "false");
332 }
333 else if (attri == "true")
334 {
335 this.user_accounts = Convert.ToBoolean(attri);
336 }
337
338 // Grid mode hack to use local asset server
339 attri = "";
340 attri = configData.GetAttribute("LocalAssets");
341 if ((attri == "") || ((attri != "false") && (attri != "true")))
342 {
343 this.gridLocalAsset = false;
344 configData.SetAttribute("LocalAssets", "false");
345 }
346 else if (attri == "true")
347 {
348 this.gridLocalAsset = Convert.ToBoolean(attri);
349 }
350
351
352 attri = "";
353 attri = configData.GetAttribute("PhysicsEngine");
354 switch (attri)
355 {
356 default:
357 m_log.Warn("Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating");
358 Environment.Exit(1);
359 break;
360
361 case "":
362 this.m_physicsEngine = "basicphysics";
363 configData.SetAttribute("PhysicsEngine", "basicphysics");
364 ScenePresence.PhysicsEngineFlying = false;
365 break;
366
367 case "basicphysics":
368 this.m_physicsEngine = "basicphysics";
369 configData.SetAttribute("PhysicsEngine", "basicphysics");
370 ScenePresence.PhysicsEngineFlying = false;
371 break;
372
373 case "RealPhysX":
374 this.m_physicsEngine = "RealPhysX";
375 ScenePresence.PhysicsEngineFlying = true;
376 break;
377
378 case "OpenDynamicsEngine":
379 this.m_physicsEngine = "OpenDynamicsEngine";
380 ScenePresence.PhysicsEngineFlying = true;
381 break;
382 }
383
384 configData.Commit();
385
386 }
387
388 /// <summary>
389 /// Performs any last-minute sanity checking and shuts down the region server
390 /// </summary>
391 public virtual void Shutdown()
392 {
393 m_log.Verbose("Main.cs:Shutdown() - Closing all threads");
394 m_log.Verbose("Main.cs:Shutdown() - Killing listener thread");
395 m_log.Verbose("Main.cs:Shutdown() - Killing clients");
396 // IMPLEMENT THIS
397 m_log.Verbose("Main.cs:Shutdown() - Closing console and terminating");
398 for (int i = 0; i < m_localWorld.Count; i++)
399 {
400 ((Scene)m_localWorld[i]).Close();
401 }
402 m_log.Close();
403 Environment.Exit(0);
404 }
405
406 #region Console Commands
407 /// <summary>
408 /// Runs commands issued by the server console from the operator
409 /// </summary>
410 /// <param name="command">The first argument of the parameter (the command)</param>
411 /// <param name="cmdparams">Additional arguments passed to the command</param>
412 public void RunCmd(string command, string[] cmdparams)
413 {
414 switch (command)
415 {
416 case "help":
417 m_log.Error("show users - show info about connected users");
418 m_log.Error("shutdown - disconnect all clients and shutdown");
419 break;
420
421 case "show":
422 if (cmdparams.Length > 0)
423 {
424 Show(cmdparams[0]);
425 }
426 break;
427
428 case "terrain":
429 string result = "";
430 for (int i = 0; i < m_localWorld.Count; i++)
431 {
432 if (!((Scene)m_localWorld[i]).Terrain.RunTerrainCmd(cmdparams, ref result, m_localWorld[i].RegionInfo.RegionName))
433 {
434 m_log.Error(result);
435 }
436 }
437 break;
438
439 case "shutdown":
440 Shutdown();
441 break;
442
443 default:
444 m_log.Error("Unknown command");
445 break;
446 }
447 }
448
449 /// <summary>
450 /// Outputs to the console information about the region
451 /// </summary>
452 /// <param name="ShowWhat">What information to display (valid arguments are "uptime", "users")</param>
453 public void Show(string ShowWhat)
454 {
455 switch (ShowWhat)
456 {
457 case "uptime":
458 m_log.Error("OpenSim has been running since " + startuptime.ToString());
459 m_log.Error("That is " + (DateTime.Now - startuptime).ToString());
460 break;
461 case "users":
462 ScenePresence TempAv;
463 m_log.Error(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP", "World"));
464 for (int i = 0; i < m_localWorld.Count; i++)
465 {
466 foreach (libsecondlife.LLUUID UUID in ((Scene)m_localWorld[i]).Entities.Keys)
467 {
468 if (((Scene)m_localWorld[i]).Entities[UUID].ToString() == "OpenSim.world.Avatar")
469 {
470 TempAv = (ScenePresence)((Scene)m_localWorld[i]).Entities[UUID];
471 m_log.Error(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", TempAv.firstname, TempAv.lastname, UUID, TempAv.ControllingClient.AgentId, "Unknown", "Unknown"), ((Scene)m_localWorld[i]).RegionInfo.RegionName);
472 }
473 }
474 }
475 break;
476 }
477 }
478 #endregion
479 }
480
481
482}
diff --git a/OpenSim/Region/Application/VersionInfo.cs b/OpenSim/Region/Application/VersionInfo.cs
new file mode 100644
index 0000000..2c720a3
--- /dev/null
+++ b/OpenSim/Region/Application/VersionInfo.cs
@@ -0,0 +1,36 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28namespace OpenSim
29{
30 /// <summary>
31 /// </summary>
32 public class VersionInfo
33 {
34 public static string Version = "0.3, SVN build ";
35 }
36}
diff --git a/OpenSim/Region/Caches/AssetCache.cs b/OpenSim/Region/Caches/AssetCache.cs
new file mode 100644
index 0000000..453edbe
--- /dev/null
+++ b/OpenSim/Region/Caches/AssetCache.cs
@@ -0,0 +1,669 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28
29using System;
30using System.Collections.Generic;
31using System.Reflection;
32using System.Threading;
33using libsecondlife;
34using libsecondlife.Packets;
35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework.Types;
37
38namespace OpenSim.Region.Caches
39{
40 public delegate void DownloadComplete(AssetCache.TextureSender sender);
41
42 /// <summary>
43 /// Manages local cache of assets and their sending to viewers.
44 /// </summary>
45 public class AssetCache : IAssetReceiver
46 {
47 public Dictionary<LLUUID, AssetInfo> Assets;
48 public Dictionary<LLUUID, TextureImage> Textures;
49
50 public List<AssetRequest> AssetRequests = new List<AssetRequest>(); //assets ready to be sent to viewers
51 public List<AssetRequest> TextureRequests = new List<AssetRequest>(); //textures ready to be sent
52
53 public Dictionary<LLUUID, AssetRequest> RequestedAssets = new Dictionary<LLUUID, AssetRequest>(); //Assets requested from the asset server
54 public Dictionary<LLUUID, AssetRequest> RequestedTextures = new Dictionary<LLUUID, AssetRequest>(); //Textures requested from the asset server
55
56 public Dictionary<LLUUID, TextureSender> SendingTextures = new Dictionary<LLUUID, TextureSender>();
57 private IAssetServer _assetServer;
58 private Thread _assetCacheThread;
59 private LLUUID[] textureList = new LLUUID[5];
60
61 /// <summary>
62 ///
63 /// </summary>
64 public AssetCache(IAssetServer assetServer)
65 {
66 Console.WriteLine("Creating Asset cache");
67 _assetServer = assetServer;
68 _assetServer.SetReceiver(this);
69 Assets = new Dictionary<LLUUID, AssetInfo>();
70 Textures = new Dictionary<LLUUID, TextureImage>();
71 this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager));
72 this._assetCacheThread.IsBackground = true;
73 this._assetCacheThread.Start();
74
75 }
76
77 public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey)
78 {
79 Console.WriteLine("Creating Asset cache");
80 _assetServer = this.LoadAssetDll(assetServerDLLName);
81 _assetServer.SetServerInfo(assetServerURL, assetServerKey);
82 _assetServer.SetReceiver(this);
83 Assets = new Dictionary<LLUUID, AssetInfo>();
84 Textures = new Dictionary<LLUUID, TextureImage>();
85 this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager));
86 this._assetCacheThread.IsBackground = true;
87 this._assetCacheThread.Start();
88
89 }
90
91 /// <summary>
92 ///
93 /// </summary>
94 public void RunAssetManager()
95 {
96 while (true)
97 {
98 try
99 {
100 //Console.WriteLine("Asset cache loop");
101 this.ProcessAssetQueue();
102 this.ProcessTextureQueue();
103 Thread.Sleep(500);
104 }
105 catch (Exception e)
106 {
107 Console.WriteLine(e.Message);
108 }
109 }
110 }
111
112 public void LoadDefaultTextureSet()
113 {
114 //hack: so we can give each user a set of textures
115 textureList[0] = new LLUUID("00000000-0000-0000-9999-000000000001");
116 textureList[1] = new LLUUID("00000000-0000-0000-9999-000000000002");
117 textureList[2] = new LLUUID("00000000-0000-0000-9999-000000000003");
118 textureList[3] = new LLUUID("00000000-0000-0000-9999-000000000004");
119 textureList[4] = new LLUUID("00000000-0000-0000-9999-000000000005");
120
121 for (int i = 0; i < textureList.Length; i++)
122 {
123 this._assetServer.RequestAsset(textureList[i], true);
124 }
125
126 }
127
128 public AssetBase[] CreateNewInventorySet(LLUUID agentID)
129 {
130 AssetBase[] inventorySet = new AssetBase[this.textureList.Length];
131 for (int i = 0; i < textureList.Length; i++)
132 {
133 if (this.Textures.ContainsKey(textureList[i]))
134 {
135 inventorySet[i] = this.CloneImage(agentID, this.Textures[textureList[i]]);
136 TextureImage image = new TextureImage(inventorySet[i]);
137 this.Textures.Add(image.FullID, image);
138 this._assetServer.UploadNewAsset(image); //save the asset to the asset server
139 }
140 }
141 return inventorySet;
142 }
143
144 public AssetBase GetAsset(LLUUID assetID)
145 {
146 AssetBase asset = null;
147 if (this.Textures.ContainsKey(assetID))
148 {
149 asset = this.Textures[assetID];
150 }
151 else if (this.Assets.ContainsKey(assetID))
152 {
153 asset = this.Assets[assetID];
154 }
155 return asset;
156 }
157
158 public void AddAsset(AssetBase asset)
159 {
160 // Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated());
161 if (asset.Type == 0)
162 {
163 //Console.WriteLine("which is a texture");
164 if (!this.Textures.ContainsKey(asset.FullID))
165 { //texture
166 TextureImage textur = new TextureImage(asset);
167 this.Textures.Add(textur.FullID, textur);
168 this._assetServer.UploadNewAsset(asset);
169 }
170 }
171 else
172 {
173 if (!this.Assets.ContainsKey(asset.FullID))
174 {
175 AssetInfo assetInf = new AssetInfo(asset);
176 this.Assets.Add(assetInf.FullID, assetInf);
177 this._assetServer.UploadNewAsset(asset);
178 }
179 }
180 }
181
182 /// <summary>
183 ///
184 /// </summary>
185 private void ProcessTextureQueue()
186 {
187 if (this.TextureRequests.Count == 0)
188 {
189 //no requests waiting
190 return;
191 }
192 int num;
193 num = this.TextureRequests.Count;
194
195 AssetRequest req;
196 for (int i = 0; i < num; i++)
197 {
198 req = (AssetRequest)this.TextureRequests[i];
199 if (!this.SendingTextures.ContainsKey(req.ImageInfo.FullID))
200 {
201 TextureSender sender = new TextureSender(req);
202 sender.OnComplete += this.TextureSent;
203 lock (this.SendingTextures)
204 {
205 this.SendingTextures.Add(req.ImageInfo.FullID, sender);
206 }
207 }
208
209 }
210
211 this.TextureRequests.Clear();
212 }
213
214 /// <summary>
215 /// Event handler, called by a TextureSender object to say that texture has been sent
216 /// </summary>
217 /// <param name="sender"></param>
218 public void TextureSent(TextureSender sender)
219 {
220 if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID))
221 {
222 lock (this.SendingTextures)
223 {
224 this.SendingTextures.Remove(sender.request.ImageInfo.FullID);
225 }
226 }
227 }
228
229 public void AssetReceived(AssetBase asset, bool IsTexture)
230 {
231 if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server
232 {
233 //check if it is a texture or not
234 //then add to the correct cache list
235 //then check for waiting requests for this asset/texture (in the Requested lists)
236 //and move those requests into the Requests list.
237 if (IsTexture)
238 {
239 TextureImage image = new TextureImage(asset);
240 this.Textures.Add(image.FullID, image);
241 if (this.RequestedTextures.ContainsKey(image.FullID))
242 {
243 AssetRequest req = this.RequestedTextures[image.FullID];
244 req.ImageInfo = image;
245 if (image.Data.LongLength > 600)
246 {
247 //over 600 bytes so split up file
248 req.NumPackets = 1 + (int)(image.Data.Length - 600 + 999) / 1000;
249 }
250 else
251 {
252 req.NumPackets = 1;
253 }
254 this.RequestedTextures.Remove(image.FullID);
255 this.TextureRequests.Add(req);
256 }
257 }
258 else
259 {
260 AssetInfo assetInf = new AssetInfo(asset);
261 this.Assets.Add(assetInf.FullID, assetInf);
262 if (this.RequestedAssets.ContainsKey(assetInf.FullID))
263 {
264 AssetRequest req = this.RequestedAssets[assetInf.FullID];
265 req.AssetInf = assetInf;
266 if (assetInf.Data.LongLength > 600)
267 {
268 //over 600 bytes so split up file
269 req.NumPackets = 1 + (int)(assetInf.Data.Length - 600 + 999) / 1000;
270 }
271 else
272 {
273 req.NumPackets = 1;
274 }
275 this.RequestedAssets.Remove(assetInf.FullID);
276 this.AssetRequests.Add(req);
277 }
278 }
279 }
280 }
281
282 public void AssetNotFound(AssetBase asset)
283 {
284 //the asset server had no knowledge of requested asset
285
286 }
287
288 #region Assets
289 /// <summary>
290 ///
291 /// </summary>
292 /// <param name="userInfo"></param>
293 /// <param name="transferRequest"></param>
294 public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest)
295 {
296 LLUUID requestID = new LLUUID(transferRequest.TransferInfo.Params, 0);
297 //check to see if asset is in local cache, if not we need to request it from asset server.
298
299 if (!this.Assets.ContainsKey(requestID))
300 {
301 //not found asset
302 // so request from asset server
303 if (!this.RequestedAssets.ContainsKey(requestID))
304 {
305 AssetRequest request = new AssetRequest();
306 request.RequestUser = userInfo;
307 request.RequestAssetID = requestID;
308 request.TransferRequestID = transferRequest.TransferInfo.TransferID;
309 this.RequestedAssets.Add(requestID, request);
310 this._assetServer.RequestAsset(requestID, false);
311 }
312 return;
313 }
314 //it is in our cache
315 AssetInfo asset = this.Assets[requestID];
316
317 //work out how many packets it should be sent in
318 // and add to the AssetRequests list
319 AssetRequest req = new AssetRequest();
320 req.RequestUser = userInfo;
321 req.RequestAssetID = requestID;
322 req.TransferRequestID = transferRequest.TransferInfo.TransferID;
323 req.AssetInf = asset;
324
325 if (asset.Data.LongLength > 600)
326 {
327 //over 600 bytes so split up file
328 req.NumPackets = 1 + (int)(asset.Data.Length - 600 + 999) / 1000;
329 }
330 else
331 {
332 req.NumPackets = 1;
333 }
334
335 this.AssetRequests.Add(req);
336 }
337
338 /// <summary>
339 ///
340 /// </summary>
341 private void ProcessAssetQueue()
342 {
343 if (this.AssetRequests.Count == 0)
344 {
345 //no requests waiting
346 return;
347 }
348 int num;
349
350 if (this.AssetRequests.Count < 5)
351 {
352 //lower than 5 so do all of them
353 num = this.AssetRequests.Count;
354 }
355 else
356 {
357 num = 5;
358 }
359 AssetRequest req;
360 for (int i = 0; i < num; i++)
361 {
362 req = (AssetRequest)this.AssetRequests[i];
363
364 TransferInfoPacket Transfer = new TransferInfoPacket();
365 Transfer.TransferInfo.ChannelType = 2;
366 Transfer.TransferInfo.Status = 0;
367 Transfer.TransferInfo.TargetType = 0;
368 Transfer.TransferInfo.Params = req.RequestAssetID.GetBytes();
369 Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length;
370 Transfer.TransferInfo.TransferID = req.TransferRequestID;
371 req.RequestUser.OutPacket(Transfer);
372
373 if (req.NumPackets == 1)
374 {
375 TransferPacketPacket TransferPacket = new TransferPacketPacket();
376 TransferPacket.TransferData.Packet = 0;
377 TransferPacket.TransferData.ChannelType = 2;
378 TransferPacket.TransferData.TransferID = req.TransferRequestID;
379 TransferPacket.TransferData.Data = req.AssetInf.Data;
380 TransferPacket.TransferData.Status = 1;
381 req.RequestUser.OutPacket(TransferPacket);
382 }
383 else
384 {
385 //more than one packet so split file up , for now it can't be bigger than 2000 bytes
386 TransferPacketPacket TransferPacket = new TransferPacketPacket();
387 TransferPacket.TransferData.Packet = 0;
388 TransferPacket.TransferData.ChannelType = 2;
389 TransferPacket.TransferData.TransferID = req.TransferRequestID;
390 byte[] chunk = new byte[1000];
391 Array.Copy(req.AssetInf.Data, chunk, 1000);
392 TransferPacket.TransferData.Data = chunk;
393 TransferPacket.TransferData.Status = 0;
394 req.RequestUser.OutPacket(TransferPacket);
395
396 TransferPacket = new TransferPacketPacket();
397 TransferPacket.TransferData.Packet = 1;
398 TransferPacket.TransferData.ChannelType = 2;
399 TransferPacket.TransferData.TransferID = req.TransferRequestID;
400 byte[] chunk1 = new byte[(req.AssetInf.Data.Length - 1000)];
401 Array.Copy(req.AssetInf.Data, 1000, chunk1, 0, chunk1.Length);
402 TransferPacket.TransferData.Data = chunk1;
403 TransferPacket.TransferData.Status = 1;
404 req.RequestUser.OutPacket(TransferPacket);
405 }
406
407 }
408
409 //remove requests that have been completed
410 for (int i = 0; i < num; i++)
411 {
412 this.AssetRequests.RemoveAt(0);
413 }
414
415 }
416
417 public AssetInfo CloneAsset(LLUUID newOwner, AssetInfo sourceAsset)
418 {
419 AssetInfo newAsset = new AssetInfo();
420 newAsset.Data = new byte[sourceAsset.Data.Length];
421 Array.Copy(sourceAsset.Data, newAsset.Data, sourceAsset.Data.Length);
422 newAsset.FullID = LLUUID.Random();
423 newAsset.Type = sourceAsset.Type;
424 newAsset.InvType = sourceAsset.InvType;
425 return (newAsset);
426 }
427 #endregion
428
429 #region Textures
430 /// <summary>
431 ///
432 /// </summary>
433 /// <param name="userInfo"></param>
434 /// <param name="imageID"></param>
435 public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID)
436 {
437 //Console.WriteLine("texture request for " + imageID.ToStringHyphenated());
438 //check to see if texture is in local cache, if not request from asset server
439 if (!this.Textures.ContainsKey(imageID))
440 {
441 if (!this.RequestedTextures.ContainsKey(imageID))
442 {
443 //not is cache so request from asset server
444 AssetRequest request = new AssetRequest();
445 request.RequestUser = userInfo;
446 request.RequestAssetID = imageID;
447 request.IsTextureRequest = true;
448 this.RequestedTextures.Add(imageID, request);
449 this._assetServer.RequestAsset(imageID, true);
450 }
451 return;
452 }
453
454 //Console.WriteLine("texture already in cache");
455 TextureImage imag = this.Textures[imageID];
456 AssetRequest req = new AssetRequest();
457 req.RequestUser = userInfo;
458 req.RequestAssetID = imageID;
459 req.IsTextureRequest = true;
460 req.ImageInfo = imag;
461
462 if (imag.Data.LongLength > 600)
463 {
464 //over 600 bytes so split up file
465 req.NumPackets = 1 + (int)(imag.Data.Length - 600 + 999) / 1000;
466 }
467 else
468 {
469 req.NumPackets = 1;
470 }
471 this.TextureRequests.Add(req);
472 }
473
474 public TextureImage CloneImage(LLUUID newOwner, TextureImage source)
475 {
476 TextureImage newImage = new TextureImage();
477 newImage.Data = new byte[source.Data.Length];
478 Array.Copy(source.Data, newImage.Data, source.Data.Length);
479 //newImage.filename = source.filename;
480 newImage.FullID = LLUUID.Random();
481 newImage.Name = source.Name;
482 return (newImage);
483 }
484 #endregion
485
486 private IAssetServer LoadAssetDll(string dllName)
487 {
488 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
489 IAssetServer server = null;
490
491 foreach (Type pluginType in pluginAssembly.GetTypes())
492 {
493 if (pluginType.IsPublic)
494 {
495 if (!pluginType.IsAbstract)
496 {
497 Type typeInterface = pluginType.GetInterface("IAssetPlugin", true);
498
499 if (typeInterface != null)
500 {
501 IAssetPlugin plug = (IAssetPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
502 server = plug.GetAssetServer();
503 break;
504 }
505
506 typeInterface = null;
507 }
508 }
509 }
510 pluginAssembly = null;
511 return server;
512 }
513
514 public class AssetRequest
515 {
516 public IClientAPI RequestUser;
517 public LLUUID RequestAssetID;
518 public AssetInfo AssetInf;
519 public TextureImage ImageInfo;
520 public LLUUID TransferRequestID;
521 public long DataPointer = 0;
522 public int NumPackets = 0;
523 public int PacketCounter = 0;
524 public bool IsTextureRequest;
525 //public bool AssetInCache;
526 //public int TimeRequested;
527
528 public AssetRequest()
529 {
530
531 }
532 }
533
534 public class AssetInfo : AssetBase
535 {
536 public AssetInfo()
537 {
538
539 }
540
541 public AssetInfo(AssetBase aBase)
542 {
543 Data = aBase.Data;
544 FullID = aBase.FullID;
545 Type = aBase.Type;
546 InvType = aBase.InvType;
547 Name = aBase.Name;
548 Description = aBase.Description;
549 }
550 }
551
552 public class TextureImage : AssetBase
553 {
554 public TextureImage()
555 {
556
557 }
558
559 public TextureImage(AssetBase aBase)
560 {
561 Data = aBase.Data;
562 FullID = aBase.FullID;
563 Type = aBase.Type;
564 InvType = aBase.InvType;
565 Name = aBase.Name;
566 Description = aBase.Description;
567 }
568 }
569
570 public class TextureSender
571 {
572 public AssetRequest request;
573 public event DownloadComplete OnComplete;
574 Thread m_thread;
575 public TextureSender(AssetRequest req)
576 {
577 request = req;
578 //Console.WriteLine("creating worker thread for texture " + req.ImageInfo.FullID.ToStringHyphenated());
579 //Console.WriteLine("texture data length is " + req.ImageInfo.Data.Length);
580 // Console.WriteLine("in " + req.NumPackets + " packets");
581 //ThreadPool.QueueUserWorkItem(new WaitCallback(SendTexture), new object());
582
583 //need some sort of custom threadpool here, as using the .net one, overloads it and stops the handling of incoming packets etc
584 //but don't really want to create a thread for every texture download
585 m_thread = new Thread(new ThreadStart(SendTexture));
586 m_thread.IsBackground = true;
587 m_thread.Start();
588 }
589
590 public void SendTexture()
591 {
592 //Console.WriteLine("starting to send sending texture " + request.ImageInfo.FullID.ToStringHyphenated());
593 while (request.PacketCounter != request.NumPackets)
594 {
595 SendPacket();
596 Thread.Sleep(500);
597 }
598
599 //Console.WriteLine("finished sending texture " + request.ImageInfo.FullID.ToStringHyphenated());
600 if (OnComplete != null)
601 {
602 OnComplete(this);
603 }
604 }
605
606 public void SendPacket()
607 {
608 AssetRequest req = request;
609 // Console.WriteLine("sending " + req.ImageInfo.FullID);
610
611 // if (req.ImageInfo.FullID == new LLUUID("00000000-0000-0000-5005-000000000005"))
612 if (req.PacketCounter == 0)
613 {
614 //first time for this request so send imagedata packet
615 if (req.NumPackets == 1)
616 {
617 //only one packet so send whole file
618 ImageDataPacket im = new ImageDataPacket();
619 im.ImageID.Packets = 1;
620 im.ImageID.ID = req.ImageInfo.FullID;
621 im.ImageID.Size = (uint)req.ImageInfo.Data.Length;
622 im.ImageData.Data = req.ImageInfo.Data;
623 im.ImageID.Codec = 2;
624 req.RequestUser.OutPacket(im);
625 req.PacketCounter++;
626 //req.ImageInfo.l= time;
627 //System.Console.WriteLine("sent texture: " + req.ImageInfo.FullID);
628 // Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated());
629 }
630 else
631 {
632 //more than one packet so split file up
633 ImageDataPacket im = new ImageDataPacket();
634 im.ImageID.Packets = (ushort)req.NumPackets;
635 im.ImageID.ID = req.ImageInfo.FullID;
636 im.ImageID.Size = (uint)req.ImageInfo.Data.Length;
637 im.ImageData.Data = new byte[600];
638 Array.Copy(req.ImageInfo.Data, 0, im.ImageData.Data, 0, 600);
639 im.ImageID.Codec = 2;
640 req.RequestUser.OutPacket(im);
641 req.PacketCounter++;
642 //req.ImageInfo.last_used = time;
643 //System.Console.WriteLine("sent first packet of texture:
644 // Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated());
645 }
646 }
647 else
648 {
649 //Console.WriteLine("sending packet" + req.PacketCounter + "for " + req.ImageInfo.FullID.ToStringHyphenated());
650 //send imagepacket
651 //more than one packet so split file up
652 ImagePacketPacket im = new ImagePacketPacket();
653 im.ImageID.Packet = (ushort)req.PacketCounter;
654 im.ImageID.ID = req.ImageInfo.FullID;
655 int size = req.ImageInfo.Data.Length - 600 - 1000 * (req.PacketCounter - 1);
656 if (size > 1000) size = 1000;
657 im.ImageData.Data = new byte[size];
658 Array.Copy(req.ImageInfo.Data, 600 + 1000 * (req.PacketCounter - 1), im.ImageData.Data, 0, size);
659 req.RequestUser.OutPacket(im);
660 req.PacketCounter++;
661 //req.ImageInfo.last_used = time;
662 //System.Console.WriteLine("sent a packet of texture: "+req.image_info.FullID);
663 }
664
665 }
666 }
667 }
668}
669
diff --git a/OpenSim/Region/Caches/Properties/AssemblyInfo.cs b/OpenSim/Region/Caches/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..8389415
--- /dev/null
+++ b/OpenSim/Region/Caches/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Region.Caches")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenSim.Region.Caches")]
11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("2b15ddbf-0341-49a6-85c0-cece268a4518")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs
new file mode 100644
index 0000000..6068076
--- /dev/null
+++ b/OpenSim/Region/Capabilities/Caps.cs
@@ -0,0 +1,336 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
32using libsecondlife;
33using OpenSim.Framework.Servers;
34using OpenSim.Framework.Types;
35using OpenSim.Framework.Utilities;
36using OpenSim.Region.Caches;
37
38namespace OpenSim.Region.Capabilities
39{
40 public delegate void UpLoadedTexture(LLUUID assetID, LLUUID inventoryItem, byte[] data);
41
42 public class Caps
43 {
44 private string m_httpListenerHostName;
45 private int m_httpListenPort;
46 private string m_capsObjectPath = "00001-";
47 private string m_requestPath = "0000/";
48 private string m_mapLayerPath = "0001/";
49 private string m_newInventory = "0002/";
50 private string m_requestTexture = "0003/";
51 private string eventQueue = "0100/";
52 private BaseHttpServer httpListener;
53 private LLUUID agentID;
54 private AssetCache assetCache;
55 private int eventQueueCount = 1;
56 private Queue<string> CapsEventQueue = new Queue<string>();
57
58 public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent)
59 {
60 assetCache = assetCach;
61 m_capsObjectPath = capsPath;
62 httpListener = httpServer;
63 m_httpListenerHostName = httpListen;
64 m_httpListenPort = httpPort;
65 agentID = agent;
66 }
67
68 /// <summary>
69 ///
70 /// </summary>
71 public void RegisterHandlers()
72 {
73 Console.WriteLine("registering CAPS handlers");
74 string capsBase = "/CAPS/" + m_capsObjectPath;
75
76
77 //AddLegacyCapsHandler( httpListener, m_mapLayerPath, MapLayer);
78
79 httpListener.AddStreamHandler(
80 new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST", capsBase + m_mapLayerPath, this.GetMapLayer ));
81
82 AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest);
83 AddLegacyCapsHandler(httpListener, m_newInventory, NewAgentInventory);
84 AddLegacyCapsHandler( httpListener, eventQueue, ProcessEventQueue);
85 AddLegacyCapsHandler( httpListener, m_requestTexture, RequestTexture);
86
87 }
88
89 [Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")]
90 private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod)
91 {
92 string capsBase = "/CAPS/" + m_capsObjectPath;
93 httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod));
94 }
95
96 /// <summary>
97 ///
98 /// </summary>
99 /// <param name="request"></param>
100 /// <param name="path"></param>
101 /// <param name="param"></param>
102 /// <returns></returns>
103 public string CapsRequest(string request, string path, string param)
104 {
105 // Console.WriteLine("Caps Request " + request);
106 string result = "";
107 result = LLSDHelpers.SerialiseLLSDReply(this.GetCapabilities());
108 return result;
109 }
110
111 /// <summary>
112 ///
113 /// </summary>
114 /// <returns></returns>
115 protected LLSDCapsDetails GetCapabilities()
116 {
117 LLSDCapsDetails caps = new LLSDCapsDetails();
118 string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath;
119
120 caps.MapLayer = capsBaseUrl + m_mapLayerPath;
121 // caps.NewFileAgentInventory = capsBaseUrl + m_newInventory;
122
123 return caps;
124 }
125
126 /// <summary>
127 ///
128 /// </summary>
129 /// <param name="request"></param>
130 /// <param name="path"></param>
131 /// <param name="param"></param>
132 /// <returns></returns>
133 public string MapLayer(string request, string path, string param)
134 {
135 Encoding _enc = Encoding.UTF8;
136 Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(_enc.GetBytes(request));
137 LLSDMapRequest mapReq = new LLSDMapRequest();
138 LLSDHelpers.DeserialiseLLSDMap(hash, mapReq);
139
140 LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
141 mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse());
142 string res = LLSDHelpers.SerialiseLLSDReply(mapResponse);
143
144 return res;
145 }
146
147 public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq)
148 {
149 LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
150 mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse());
151 return mapResponse;
152 }
153
154
155 /// <summary>
156 ///
157 /// </summary>
158 /// <returns></returns>
159 protected LLSDMapLayer BuildLLSDMapLayerResponse()
160 {
161 LLSDMapLayer mapLayer = new LLSDMapLayer();
162 mapLayer.Right = 5000;
163 mapLayer.Top = 5000;
164 mapLayer.ImageID = new LLUUID("00000000-0000-0000-9999-000000000006");
165
166 return mapLayer;
167 }
168
169 /// <summary>
170 ///
171 /// </summary>
172 /// <param name="request"></param>
173 /// <param name="path"></param>
174 /// <param name="param"></param>
175 /// <returns></returns>
176 public string RequestTexture(string request, string path, string param)
177 {
178 // Needs implementing (added to remove compiler warning)
179 return "";
180 }
181
182 /// <summary>
183 ///
184 /// </summary>
185 /// <param name="request"></param>
186 /// <param name="path"></param>
187 /// <param name="param"></param>
188 /// <returns></returns>
189 public string ProcessEventQueue(string request, string path, string param)
190 {
191 string res = "";
192
193 if (this.CapsEventQueue.Count > 0)
194 {
195 lock (this.CapsEventQueue)
196 {
197 string item = CapsEventQueue.Dequeue();
198 res = item;
199 }
200 }
201 else
202 {
203 res = this.CreateEmptyEventResponse();
204 }
205 return res;
206 }
207
208 /// <summary>
209 ///
210 /// </summary>
211 /// <param name="caps"></param>
212 /// <param name="ipAddressPort"></param>
213 /// <returns></returns>
214 public string CreateEstablishAgentComms(string caps, string ipAddressPort)
215 {
216 LLSDCapEvent eventItem = new LLSDCapEvent();
217 eventItem.id = eventQueueCount;
218 //should be creating a EstablishAgentComms item, but there isn't a class for it yet
219 eventItem.events.Array.Add(new LLSDEmpty());
220 string res = LLSDHelpers.SerialiseLLSDReply(eventItem);
221 eventQueueCount++;
222
223 this.CapsEventQueue.Enqueue(res);
224 return res;
225 }
226
227 /// <summary>
228 ///
229 /// </summary>
230 /// <returns></returns>
231 public string CreateEmptyEventResponse()
232 {
233 LLSDCapEvent eventItem = new LLSDCapEvent();
234 eventItem.id = eventQueueCount;
235 eventItem.events.Array.Add(new LLSDEmpty());
236 string res = LLSDHelpers.SerialiseLLSDReply(eventItem);
237 eventQueueCount++;
238 return res;
239 }
240
241 /// <summary>
242 ///
243 /// </summary>
244 /// <param name="request"></param>
245 /// <param name="path"></param>
246 /// <param name="param"></param>
247 /// <returns></returns>
248 public string NewAgentInventory(string request, string path, string param)
249 {
250 //Console.WriteLine("received upload request:"+ request);
251 string res = "";
252 LLUUID newAsset = LLUUID.Random();
253 LLUUID newInvItem = LLUUID.Random();
254 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
255 AssetUploader uploader = new AssetUploader(newAsset, newInvItem, uploaderPath, this.httpListener);
256
257 AddLegacyCapsHandler( httpListener, uploaderPath, uploader.uploaderCaps);
258
259 string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + uploaderPath;
260 //Console.WriteLine("uploader url is " + uploaderURL);
261 res += "<llsd><map>";
262 res += "<key>uploader</key><string>" + uploaderURL + "</string>";
263 //res += "<key>success</key><boolean>true</boolean>";
264 res += "<key>state</key><string>upload</string>";
265 res += "</map></llsd>";
266 uploader.OnUpLoad += this.UploadHandler;
267 return res;
268 }
269
270 /// <summary>
271 ///
272 /// </summary>
273 /// <param name="assetID"></param>
274 /// <param name="inventoryItem"></param>
275 /// <param name="data"></param>
276 public void UploadHandler(LLUUID assetID, LLUUID inventoryItem, byte[] data)
277 {
278 // Console.WriteLine("upload handler called");
279 AssetBase asset;
280 asset = new AssetBase();
281 asset.FullID = assetID;
282 asset.Type = 0;
283 asset.InvType = 0;
284 asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000");
285 asset.Data = data;
286 this.assetCache.AddAsset(asset);
287 }
288
289 public class AssetUploader
290 {
291 public event UpLoadedTexture OnUpLoad;
292
293 private string uploaderPath = "";
294 private LLUUID newAssetID;
295 private LLUUID inventoryItemID;
296 private BaseHttpServer httpListener;
297 public AssetUploader(LLUUID assetID, LLUUID inventoryItem, string path, BaseHttpServer httpServer)
298 {
299 newAssetID = assetID;
300 inventoryItemID = inventoryItem;
301 uploaderPath = path;
302 httpListener = httpServer;
303
304 }
305
306 public string uploaderCaps(string request, string path, string param)
307 {
308 Encoding _enc = Encoding.UTF8;
309 byte[] data = _enc.GetBytes(request);
310 //Console.WriteLine("recieved upload " + Util.FieldToString(data));
311 LLUUID inv = this.inventoryItemID;
312 string res = "";
313 res += "<llsd><map>";
314 res += "<key>new_asset</key><string>" + newAssetID.ToStringHyphenated() + "</string>";
315 res += "<key>new_inventory_item</key><uuid>" + inv.ToStringHyphenated() + "</uuid>";
316 res += "<key>state</key><string>complete</string>";
317 res += "</map></llsd>";
318
319 // Console.WriteLine("asset " + newAssetID.ToStringHyphenated() + " , inventory item " + inv.ToStringHyphenated());
320 httpListener.RemoveStreamHandler("POST", "/CAPS/" + uploaderPath);
321
322 if (OnUpLoad != null)
323 {
324 OnUpLoad(newAssetID, inv, data);
325 }
326
327 /*FileStream fs = File.Create("upload.jp2");
328 BinaryWriter bw = new BinaryWriter(fs);
329 bw.Write(data);
330 bw.Close();
331 fs.Close();*/
332 return res;
333 }
334 }
335 }
336}
diff --git a/OpenSim/Region/Capabilities/LLSDArray.cs b/OpenSim/Region/Capabilities/LLSDArray.cs
new file mode 100644
index 0000000..e04849f
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDArray.cs
@@ -0,0 +1,42 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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;
29
30namespace OpenSim.Region.Capabilities
31{
32 [LLSDType("ARRAY")]
33 public class LLSDArray
34 {
35 public ArrayList Array = new ArrayList();
36
37 public LLSDArray()
38 {
39
40 }
41 }
42}
diff --git a/OpenSim/Region/Capabilities/LLSDCapEvent.cs b/OpenSim/Region/Capabilities/LLSDCapEvent.cs
new file mode 100644
index 0000000..51b4fe0
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDCapEvent.cs
@@ -0,0 +1,41 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28namespace OpenSim.Region.Capabilities
29{
30 [LLSDType("MAP")]
31 public class LLSDCapEvent
32 {
33 public int id = 0;
34 public LLSDArray events = new LLSDArray();
35
36 public LLSDCapEvent()
37 {
38
39 }
40 }
41}
diff --git a/OpenSim/Region/Capabilities/LLSDCapsDetails.cs b/OpenSim/Region/Capabilities/LLSDCapsDetails.cs
new file mode 100644
index 0000000..1f8b242
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDCapsDetails.cs
@@ -0,0 +1,15 @@
1namespace OpenSim.Region.Capabilities
2{
3 [LLSDType("MAP")]
4 public class LLSDCapsDetails
5 {
6 public string MapLayer = "";
7 //public string NewFileAgentInventory = "";
8 //public string EventQueueGet = "";
9
10 public LLSDCapsDetails()
11 {
12
13 }
14 }
15}
diff --git a/OpenSim/Region/Capabilities/LLSDEmpty.cs b/OpenSim/Region/Capabilities/LLSDEmpty.cs
new file mode 100644
index 0000000..d79c09e
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDEmpty.cs
@@ -0,0 +1,38 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28namespace OpenSim.Region.Capabilities
29{
30 [LLSDType("MAP")]
31 public class LLSDEmpty
32 {
33 public LLSDEmpty()
34 {
35
36 }
37 }
38}
diff --git a/OpenSim/Region/Capabilities/LLSDHelpers.cs b/OpenSim/Region/Capabilities/LLSDHelpers.cs
new file mode 100644
index 0000000..19ef0c9
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDHelpers.cs
@@ -0,0 +1,164 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Reflection;
32using System.Xml;
33using libsecondlife;
34
35namespace OpenSim.Region.Capabilities
36{
37 public class LLSDHelpers
38 {
39 public static string SerialiseLLSDReply(object obj)
40 {
41 StringWriter sw = new StringWriter();
42 XmlTextWriter writer = new XmlTextWriter(sw);
43 writer.Formatting = Formatting.None;
44 writer.WriteStartElement(String.Empty, "llsd", String.Empty);
45 SerializeLLSDType(writer, obj);
46 writer.WriteEndElement();
47 writer.Close();
48 return sw.ToString();
49 }
50
51 public static void SerializeLLSDType(XmlTextWriter writer, object obj)
52 {
53 Type myType = obj.GetType();
54 LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false);
55 if (llsdattributes.Length > 0)
56 {
57 switch (llsdattributes[0].ObjectType)
58 {
59 case "MAP":
60 writer.WriteStartElement(String.Empty, "map", String.Empty);
61 FieldInfo[] fields = myType.GetFields();
62 for (int i = 0; i < fields.Length; i++)
63 {
64 object fieldValue = fields[i].GetValue(obj);
65 LLSDType[] fieldAttributes = (LLSDType[])fieldValue.GetType().GetCustomAttributes(typeof(LLSDType), false);
66 if (fieldAttributes.Length > 0)
67 {
68 writer.WriteStartElement(String.Empty, "key", String.Empty);
69 writer.WriteString(fields[i].Name);
70 writer.WriteEndElement();
71 SerializeLLSDType(writer, fieldValue);
72 }
73 else
74 {
75 writer.WriteStartElement(String.Empty, "key", String.Empty);
76 writer.WriteString(fields[i].Name);
77 writer.WriteEndElement();
78 LLSD.LLSDWriteOne(writer, fieldValue);
79 }
80 }
81 writer.WriteEndElement();
82 break;
83 case "ARRAY":
84 // LLSDArray arrayObject = obj as LLSDArray;
85 // ArrayList a = arrayObject.Array;
86 ArrayList a = (ArrayList)obj.GetType().GetField("Array").GetValue(obj);
87 if (a != null)
88 {
89 writer.WriteStartElement(String.Empty, "array", String.Empty);
90 foreach (object item in a)
91 {
92 SerializeLLSDType(writer, item);
93 }
94 writer.WriteEndElement();
95 }
96 break;
97 }
98 }
99 else
100 {
101 LLSD.LLSDWriteOne(writer, obj);
102 }
103 }
104
105 public static object DeserialiseLLSDMap(Hashtable llsd, object obj)
106 {
107 Type myType = obj.GetType();
108 LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false);
109 if (llsdattributes.Length > 0)
110 {
111 switch (llsdattributes[0].ObjectType)
112 {
113 case "MAP":
114 IDictionaryEnumerator enumerator = llsd.GetEnumerator();
115 while (enumerator.MoveNext())
116 {
117 FieldInfo field = myType.GetField((string)enumerator.Key);
118 if (field != null)
119 {
120 if (enumerator.Value is Hashtable)
121 {
122 object fieldValue = field.GetValue(obj);
123 DeserialiseLLSDMap((Hashtable) enumerator.Value, fieldValue);
124 }
125 else if (enumerator.Value is ArrayList)
126 {
127 object fieldValue = field.GetValue(obj);
128 fieldValue.GetType().GetField("Array").SetValue(fieldValue, enumerator.Value);
129 //TODO
130 // the LLSD map/array types in the array need to be deserialised
131 // but first we need to know the right class to deserialise them into.
132 }
133 else
134 {
135 field.SetValue(obj, enumerator.Value);
136 }
137 }
138 }
139 break;
140 }
141 }
142 return obj;
143 }
144 }
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164}
diff --git a/OpenSim/Region/Capabilities/LLSDMapLayer.cs b/OpenSim/Region/Capabilities/LLSDMapLayer.cs
new file mode 100644
index 0000000..566d0e9
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDMapLayer.cs
@@ -0,0 +1,46 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29
30namespace OpenSim.Region.Capabilities
31{
32 [LLSDType("MAP")]
33 public class LLSDMapLayer
34 {
35 public int Left = 0;
36 public int Right = 0;
37 public int Top = 0;
38 public int Bottom = 0;
39 public LLUUID ImageID = LLUUID.Zero;
40
41 public LLSDMapLayer()
42 {
43
44 }
45 }
46}
diff --git a/OpenSim/Region/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Region/Capabilities/LLSDMapLayerResponse.cs
new file mode 100644
index 0000000..ce746ae
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDMapLayerResponse.cs
@@ -0,0 +1,41 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28namespace OpenSim.Region.Capabilities
29{
30 [LLSDType("MAP")]
31 public class LLSDMapLayerResponse
32 {
33 public LLSDMapRequest AgentData = new LLSDMapRequest();
34 public LLSDArray LayerData = new LLSDArray();
35
36 public LLSDMapLayerResponse()
37 {
38
39 }
40 }
41}
diff --git a/OpenSim/Region/Capabilities/LLSDMapRequest.cs b/OpenSim/Region/Capabilities/LLSDMapRequest.cs
new file mode 100644
index 0000000..fb739cd
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDMapRequest.cs
@@ -0,0 +1,13 @@
1namespace OpenSim.Region.Capabilities
2{
3 [LLSDType("MAP")]
4 public class LLSDMapRequest
5 {
6 public int Flags = 0;
7
8 public LLSDMapRequest()
9 {
10
11 }
12 }
13}
diff --git a/OpenSim/Region/Capabilities/LLSDMethod.cs b/OpenSim/Region/Capabilities/LLSDMethod.cs
new file mode 100644
index 0000000..5f42f44
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDMethod.cs
@@ -0,0 +1,8 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Region.Capabilities
6{
7 public delegate TResponse LLSDMethod<TRequest, TResponse>(TRequest request);
8}
diff --git a/OpenSim/Region/Capabilities/LLSDStreamHandler.cs b/OpenSim/Region/Capabilities/LLSDStreamHandler.cs
new file mode 100644
index 0000000..7d99b6e
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDStreamHandler.cs
@@ -0,0 +1,42 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Framework.Servers;
5using System.IO;
6using System.Collections;
7using libsecondlife;
8
9namespace OpenSim.Region.Capabilities
10{
11 public class LLSDStreamhandler<TRequest, TResponse> : BaseStreamHandler
12 where TRequest : new()
13 {
14 private LLSDMethod<TRequest, TResponse> m_method;
15
16 public LLSDStreamhandler(string httpMethod, string path, LLSDMethod<TRequest, TResponse> method)
17 : base(httpMethod, path )
18 {
19 m_method = method;
20 }
21
22 public override byte[] Handle(string path, Stream request)
23 {
24 //Encoding encoding = Encoding.UTF8;
25 //StreamReader streamReader = new StreamReader(request, false);
26
27 //string requestBody = streamReader.ReadToEnd();
28 //streamReader.Close();
29
30 Hashtable hash = (Hashtable)LLSD.LLSDDeserialize( request );
31 TRequest llsdRequest = new TRequest();
32 LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest);
33
34 TResponse response = m_method(llsdRequest);
35
36 Encoding encoding = new UTF8Encoding(false);
37
38 return encoding.GetBytes( LLSDHelpers.SerialiseLLSDReply(response) );
39
40 }
41 }
42}
diff --git a/OpenSim/Region/Capabilities/LLSDTest.cs b/OpenSim/Region/Capabilities/LLSDTest.cs
new file mode 100644
index 0000000..f23e327
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDTest.cs
@@ -0,0 +1,41 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28namespace OpenSim.Region.Capabilities
29{
30 [LLSDType("MAP")]
31 public class LLSDTest
32 {
33 public int Test1 = 20;
34 public int Test2 = 10;
35
36 public LLSDTest()
37 {
38
39 }
40 }
41}
diff --git a/OpenSim/Region/Capabilities/LLSDType.cs b/OpenSim/Region/Capabilities/LLSDType.cs
new file mode 100644
index 0000000..c58a937
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDType.cs
@@ -0,0 +1,59 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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;
29
30namespace OpenSim.Region.Capabilities
31{
32 [AttributeUsage(AttributeTargets.Class)]
33 public class LLSDType : Attribute
34 {
35 protected string myType;
36
37 public LLSDType(string type)
38 {
39 myType = type;
40
41 }
42
43 public string ObjectType
44 {
45 get
46 {
47 return myType;
48 }
49 }
50 }
51
52 [AttributeUsage(AttributeTargets.Class)]
53 public class LLSDMap : LLSDType
54 {
55 public LLSDMap() : base( "MAP" )
56 {
57 }
58 }
59}
diff --git a/OpenSim/Region/Capabilities/LLSDUploadReply.cs b/OpenSim/Region/Capabilities/LLSDUploadReply.cs
new file mode 100644
index 0000000..023a056
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDUploadReply.cs
@@ -0,0 +1,44 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29
30namespace OpenSim.Region.Capabilities
31{
32 [LLSDType("MAP")]
33 public class LLSDUploadReply
34 {
35 public string new_asset = "";
36 public LLUUID new_inventory_item = LLUUID.Zero;
37 public string state = "";
38
39 public LLSDUploadReply()
40 {
41
42 }
43 }
44}
diff --git a/OpenSim/Region/ClientStack/Assets/InventoryCache.cs b/OpenSim/Region/ClientStack/Assets/InventoryCache.cs
new file mode 100644
index 0000000..082c0d0
--- /dev/null
+++ b/OpenSim/Region/ClientStack/Assets/InventoryCache.cs
@@ -0,0 +1,337 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28
29using System;
30using System.Collections.Generic;
31using System.Text;
32using libsecondlife;
33using libsecondlife.Packets;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Inventory;
36using OpenSim.Framework.Types;
37using OpenSim.Region.ClientStack;
38
39namespace OpenSim.Assets
40{
41 /// <summary>
42 /// Description of InventoryManager.
43 /// </summary>
44 public class InventoryCache
45 {
46 private Dictionary<LLUUID, AgentInventory> _agentsInventory;
47 private List<UserServerRequest> _serverRequests; //list of requests made to user server.
48 private Encoding _enc = Encoding.ASCII;
49 private const uint FULL_MASK_PERMISSIONS = 2147483647;
50
51 public InventoryCache()
52 {
53 _agentsInventory = new Dictionary<LLUUID, AgentInventory>();
54 _serverRequests = new List<UserServerRequest>();
55 }
56
57 public void AddNewAgentsInventory(AgentInventory agentInventory)
58 {
59 if (!this._agentsInventory.ContainsKey(agentInventory.AgentID))
60 {
61 this._agentsInventory.Add(agentInventory.AgentID, agentInventory);
62 }
63 }
64
65 public AgentInventory FetchAgentsInventory(LLUUID agentID, IUserServer userserver)
66 {
67 AgentInventory res = null;
68 if (!this._agentsInventory.ContainsKey(agentID))
69 {
70 res = userserver.RequestAgentsInventory(agentID);
71 this._agentsInventory.Add(agentID,res);
72 }
73 return res;
74 }
75
76 public AgentInventory GetAgentsInventory(LLUUID agentID)
77 {
78 if (this._agentsInventory.ContainsKey(agentID))
79 {
80 return this._agentsInventory[agentID];
81 }
82
83 return null;
84 }
85
86 public void ClientLeaving(LLUUID clientID, IUserServer userserver)
87 {
88 if (this._agentsInventory.ContainsKey(clientID))
89 {
90 if (userserver != null)
91 {
92 userserver.UpdateAgentsInventory(clientID, this._agentsInventory[clientID]);
93 }
94 this._agentsInventory.Remove(clientID);
95 }
96 }
97
98 public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID)
99 {
100 return this.CreateNewInventoryFolder(remoteClient, folderID, 0);
101 }
102
103 public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type)
104 {
105 bool res = false;
106 if (folderID != LLUUID.Zero) //don't create a folder with a zero id
107 {
108 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
109 {
110 res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID, type);
111 }
112 }
113 return res;
114 }
115
116 public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type, string folderName, LLUUID parent)
117 {
118 bool res = false;
119 if (folderID != LLUUID.Zero) //don't create a folder with a zero id
120 {
121 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
122 {
123 res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID, type, folderName, parent);
124 }
125 }
126 return res;
127 }
128
129 public LLUUID AddNewInventoryItem(ClientView remoteClient, LLUUID folderID, AssetBase asset)
130 {
131 LLUUID newItem = null;
132 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
133 {
134 newItem = this._agentsInventory[remoteClient.AgentID].AddToInventory(folderID, asset);
135 if (newItem != null)
136 {
137 InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[newItem];
138 this.SendItemUpdateCreate(remoteClient, Item);
139 }
140 }
141
142 return newItem;
143 }
144 public bool DeleteInventoryItem(ClientView remoteClient, LLUUID itemID)
145 {
146 bool res = false;
147 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
148 {
149 res = this._agentsInventory[remoteClient.AgentID].DeleteFromInventory(itemID);
150 if (res)
151 {
152 RemoveInventoryItemPacket remove = new RemoveInventoryItemPacket();
153 remove.AgentData.AgentID = remoteClient.AgentID;
154 remove.AgentData.SessionID = remoteClient.SessionID;
155 remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1];
156 remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock();
157 remove.InventoryData[0].ItemID = itemID;
158 remoteClient.OutPacket(remove);
159 }
160 }
161
162 return res;
163 }
164
165 public bool UpdateInventoryItemAsset(ClientView remoteClient, LLUUID itemID, AssetBase asset)
166 {
167 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
168 {
169 bool res = _agentsInventory[remoteClient.AgentID].UpdateItemAsset(itemID, asset);
170 if (res)
171 {
172 InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID];
173 this.SendItemUpdateCreate(remoteClient, Item);
174 }
175 return res;
176 }
177
178 return false;
179 }
180
181 public bool UpdateInventoryItemDetails(ClientView remoteClient, LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet)
182 {
183 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
184 {
185 bool res = _agentsInventory[remoteClient.AgentID].UpdateItemDetails(itemID, packet);
186 if (res)
187 {
188 InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID];
189 this.SendItemUpdateCreate(remoteClient, Item);
190 }
191 return res;
192 }
193
194 return false;
195 }
196
197 public void FetchInventoryDescendents(ClientView userInfo, FetchInventoryDescendentsPacket FetchDescend)
198 {
199 if (this._agentsInventory.ContainsKey(userInfo.AgentID))
200 {
201 AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID];
202 if (FetchDescend.InventoryData.FetchItems)
203 {
204 if (agentInventory.InventoryFolders.ContainsKey(FetchDescend.InventoryData.FolderID))
205 {
206 InventoryFolder Folder = agentInventory.InventoryFolders[FetchDescend.InventoryData.FolderID];
207 InventoryDescendentsPacket Descend = new InventoryDescendentsPacket();
208 Descend.AgentData.AgentID = userInfo.AgentID;
209 Descend.AgentData.OwnerID = Folder.OwnerID;
210 Descend.AgentData.FolderID = FetchDescend.InventoryData.FolderID;
211 Descend.AgentData.Descendents = Folder.Items.Count;
212 Descend.AgentData.Version = Folder.Items.Count;
213
214
215 Descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[Folder.Items.Count];
216 for (int i = 0; i < Folder.Items.Count; i++)
217 {
218
219 InventoryItem Item = Folder.Items[i];
220 Descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock();
221 Descend.ItemData[i].ItemID = Item.ItemID;
222 Descend.ItemData[i].AssetID = Item.AssetID;
223 Descend.ItemData[i].CreatorID = Item.CreatorID;
224 Descend.ItemData[i].BaseMask = FULL_MASK_PERMISSIONS;
225 Descend.ItemData[i].CreationDate = 1000;
226 Descend.ItemData[i].Description = _enc.GetBytes(Item.Description + "\0");
227 Descend.ItemData[i].EveryoneMask = FULL_MASK_PERMISSIONS;
228 Descend.ItemData[i].Flags = 1;
229 Descend.ItemData[i].FolderID = Item.FolderID;
230 Descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
231 Descend.ItemData[i].GroupMask = FULL_MASK_PERMISSIONS;
232 Descend.ItemData[i].InvType = Item.InvType;
233 Descend.ItemData[i].Name = _enc.GetBytes(Item.Name + "\0");
234 Descend.ItemData[i].NextOwnerMask = FULL_MASK_PERMISSIONS;
235 Descend.ItemData[i].OwnerID = Item.OwnerID;
236 Descend.ItemData[i].OwnerMask = FULL_MASK_PERMISSIONS;
237 Descend.ItemData[i].SalePrice = 100;
238 Descend.ItemData[i].SaleType = 0;
239 Descend.ItemData[i].Type = Item.Type;
240 Descend.ItemData[i].CRC = Helpers.InventoryCRC(1000, 0, Descend.ItemData[i].InvType, Descend.ItemData[i].Type, Descend.ItemData[i].AssetID, Descend.ItemData[i].GroupID, 100, Descend.ItemData[i].OwnerID, Descend.ItemData[i].CreatorID, Descend.ItemData[i].ItemID, Descend.ItemData[i].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS);
241 }
242
243 userInfo.OutPacket(Descend);
244
245 }
246 }
247 else
248 {
249 Console.WriteLine("fetch subfolders");
250 }
251 }
252 }
253
254 public void FetchInventory(ClientView userInfo, FetchInventoryPacket FetchItems)
255 {
256 if (this._agentsInventory.ContainsKey(userInfo.AgentID))
257 {
258 AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID];
259
260 for (int i = 0; i < FetchItems.InventoryData.Length; i++)
261 {
262 if (agentInventory.InventoryItems.ContainsKey(FetchItems.InventoryData[i].ItemID))
263 {
264 InventoryItem Item = agentInventory.InventoryItems[FetchItems.InventoryData[i].ItemID];
265 FetchInventoryReplyPacket InventoryReply = new FetchInventoryReplyPacket();
266 InventoryReply.AgentData.AgentID = userInfo.AgentID;
267 InventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
268 InventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
269 InventoryReply.InventoryData[0].ItemID = Item.ItemID;
270 InventoryReply.InventoryData[0].AssetID = Item.AssetID;
271 InventoryReply.InventoryData[0].CreatorID = Item.CreatorID;
272 InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS;
273 InventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
274 InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0");
275 InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS;
276 InventoryReply.InventoryData[0].Flags = 0;
277 InventoryReply.InventoryData[0].FolderID = Item.FolderID;
278 InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
279 InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS;
280 InventoryReply.InventoryData[0].InvType = Item.InvType;
281 InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0");
282 InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS;
283 InventoryReply.InventoryData[0].OwnerID = Item.OwnerID;
284 InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS;
285 InventoryReply.InventoryData[0].SalePrice = 100;
286 InventoryReply.InventoryData[0].SaleType = 0;
287 InventoryReply.InventoryData[0].Type = Item.Type;
288 InventoryReply.InventoryData[0].CRC = Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS);
289 userInfo.OutPacket(InventoryReply);
290 }
291 }
292 }
293 }
294
295 private void SendItemUpdateCreate(ClientView remoteClient, InventoryItem Item)
296 {
297
298 UpdateCreateInventoryItemPacket InventoryReply = new UpdateCreateInventoryItemPacket();
299 InventoryReply.AgentData.AgentID = remoteClient.AgentID;
300 InventoryReply.AgentData.SimApproved = true;
301 InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1];
302 InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock();
303 InventoryReply.InventoryData[0].ItemID = Item.ItemID;
304 InventoryReply.InventoryData[0].AssetID = Item.AssetID;
305 InventoryReply.InventoryData[0].CreatorID = Item.CreatorID;
306 InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS;
307 InventoryReply.InventoryData[0].CreationDate = 1000;
308 InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0");
309 InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS;
310 InventoryReply.InventoryData[0].Flags = 0;
311 InventoryReply.InventoryData[0].FolderID = Item.FolderID;
312 InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
313 InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS;
314 InventoryReply.InventoryData[0].InvType = Item.InvType;
315 InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0");
316 InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS;
317 InventoryReply.InventoryData[0].OwnerID = Item.OwnerID;
318 InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS;
319 InventoryReply.InventoryData[0].SalePrice = 100;
320 InventoryReply.InventoryData[0].SaleType = 0;
321 InventoryReply.InventoryData[0].Type = Item.Type;
322 InventoryReply.InventoryData[0].CRC = Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS);
323
324 remoteClient.OutPacket(InventoryReply);
325 }
326 }
327
328
329
330 public class UserServerRequest
331 {
332 public UserServerRequest()
333 {
334
335 }
336 }
337}
diff --git a/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs b/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs
new file mode 100644
index 0000000..f4e537c
--- /dev/null
+++ b/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs
@@ -0,0 +1,40 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Net.Sockets;
29
30namespace OpenSim.Region.ClientStack
31{
32
33 public interface ClientStackNetworkHandler
34 {
35 void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode);// EndPoint packetSender);
36 void RemoveClientCircuit(uint circuitcode);
37 void RegisterPacketServer(PacketServer server);
38 }
39
40}
diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs
new file mode 100644
index 0000000..225e906
--- /dev/null
+++ b/OpenSim/Region/ClientStack/ClientView.API.cs
@@ -0,0 +1,1122 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
32using Axiom.Math;
33using libsecondlife;
34using libsecondlife.Packets;
35using OpenSim.Framework.Console;
36using OpenSim.Framework.Interfaces;
37using OpenSim.Framework.Types;
38
39namespace OpenSim.Region.ClientStack
40{
41 partial class ClientView
42 {
43 public event ImprovedInstantMessage OnInstantMessage;
44 public event ChatFromViewer OnChatFromViewer;
45 public event RezObject OnRezObject;
46 public event GenericCall4 OnDeRezObject;
47 public event ModifyTerrain OnModifyTerrain;
48 public event GenericCall OnRegionHandShakeReply;
49 public event GenericCall OnRequestWearables;
50 public event SetAppearance OnSetAppearance;
51 public event GenericCall2 OnCompleteMovementToRegion;
52 public event UpdateAgent OnAgentUpdate;
53 public event StartAnim OnStartAnim;
54 public event GenericCall OnRequestAvatarsData;
55 public event LinkObjects OnLinkObjects;
56 public event UpdateVector OnGrapObject;
57 public event ObjectSelect OnDeGrapObject;
58 public event ObjectDuplicate OnObjectDuplicate;
59 public event MoveObject OnGrapUpdate;
60 public event GenericCall4 OnAddPrim;
61 public event UpdateShape OnUpdatePrimShape;
62 public event ObjectSelect OnObjectSelect;
63 public event GenericCall7 OnObjectDescription;
64 public event GenericCall7 OnObjectName;
65 public event UpdatePrimFlags OnUpdatePrimFlags;
66 public event UpdatePrimTexture OnUpdatePrimTexture;
67 public event UpdateVector OnUpdatePrimGroupPosition;
68 public event UpdateVector OnUpdatePrimSinglePosition;
69 public event UpdatePrimRotation OnUpdatePrimGroupRotation;
70 public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
71 public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
72 public event UpdateVector OnUpdatePrimScale;
73 public event StatusChange OnChildAgentStatus;
74 public event GenericCall2 OnStopMovement;
75 public event NewAvatar OnNewAvatar;
76 public event GenericCall6 OnRemoveAvatar;
77 public event RequestMapBlocks OnRequestMapBlocks;
78 public event TeleportLocationRequest OnTeleportLocationRequest;
79
80 public event UUIDNameRequest OnNameFromUUIDRequest;
81
82 public event ParcelPropertiesRequest OnParcelPropertiesRequest;
83 public event ParcelDivideRequest OnParcelDivideRequest;
84 public event ParcelJoinRequest OnParcelJoinRequest;
85 public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
86
87 public event EstateOwnerMessageRequest OnEstateOwnerMessage;
88 /// <summary>
89 ///
90 /// </summary>
91 public LLVector3 StartPos
92 {
93 get
94 {
95 return startpos;
96 }
97 set
98 {
99 startpos = value;
100 }
101 }
102
103 /// <summary>
104 ///
105 /// </summary>
106 public LLUUID AgentId
107 {
108 get
109 {
110 return this.AgentID;
111 }
112 }
113
114 /// <summary>
115 ///
116 /// </summary>
117 public string FirstName
118 {
119 get
120 {
121 return this.firstName;
122 }
123
124 }
125
126 /// <summary>
127 ///
128 /// </summary>
129 public string LastName
130 {
131 get
132 {
133 return this.lastName;
134 }
135 }
136
137 #region World/Avatar to Client
138
139 /// <summary>
140 ///
141 /// </summary>
142 /// <param name="regionInfo"></param>
143 public void SendRegionHandshake(RegionInfo regionInfo)
144 {
145 Encoding _enc = Encoding.ASCII;
146 RegionHandshakePacket handshake = new RegionHandshakePacket();
147
148 handshake.RegionInfo.BillableFactor = regionInfo.estateSettings.billableFactor;
149 handshake.RegionInfo.IsEstateManager = false;
150 handshake.RegionInfo.TerrainHeightRange00 = regionInfo.estateSettings.terrainHeightRange0;
151 handshake.RegionInfo.TerrainHeightRange01 = regionInfo.estateSettings.terrainHeightRange1;
152 handshake.RegionInfo.TerrainHeightRange10 = regionInfo.estateSettings.terrainHeightRange2;
153 handshake.RegionInfo.TerrainHeightRange11 = regionInfo.estateSettings.terrainHeightRange3;
154 handshake.RegionInfo.TerrainStartHeight00 = regionInfo.estateSettings.terrainStartHeight0;
155 handshake.RegionInfo.TerrainStartHeight01 = regionInfo.estateSettings.terrainStartHeight1;
156 handshake.RegionInfo.TerrainStartHeight10 = regionInfo.estateSettings.terrainStartHeight2;
157 handshake.RegionInfo.TerrainStartHeight11 = regionInfo.estateSettings.terrainStartHeight3;
158 handshake.RegionInfo.SimAccess = (byte)regionInfo.estateSettings.simAccess;
159 handshake.RegionInfo.WaterHeight = regionInfo.estateSettings.waterHeight;
160
161
162 handshake.RegionInfo.RegionFlags = (uint)regionInfo.estateSettings.regionFlags;
163
164 handshake.RegionInfo.SimName = _enc.GetBytes(regionInfo.RegionName + "\0");
165 handshake.RegionInfo.SimOwner = regionInfo.MasterAvatarAssignedUUID;
166 handshake.RegionInfo.TerrainBase0 = regionInfo.estateSettings.terrainBase0;
167 handshake.RegionInfo.TerrainBase1 = regionInfo.estateSettings.terrainBase1;
168 handshake.RegionInfo.TerrainBase2 = regionInfo.estateSettings.terrainBase2;
169 handshake.RegionInfo.TerrainBase3 = regionInfo.estateSettings.terrainBase3;
170 handshake.RegionInfo.TerrainDetail0 = regionInfo.estateSettings.terrainDetail0;
171 handshake.RegionInfo.TerrainDetail1 = regionInfo.estateSettings.terrainDetail1;
172 handshake.RegionInfo.TerrainDetail2 = regionInfo.estateSettings.terrainDetail2;
173 handshake.RegionInfo.TerrainDetail3 = regionInfo.estateSettings.terrainDetail3;
174 handshake.RegionInfo.CacheID = LLUUID.Random(); //I guess this is for the client to remember an old setting?
175
176 this.OutPacket(handshake);
177 }
178
179 /// <summary>
180 ///
181 /// </summary>
182 /// <param name="regInfo"></param>
183 public void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look)
184 {
185 AgentMovementCompletePacket mov = new AgentMovementCompletePacket();
186 mov.AgentData.SessionID = this.SessionID;
187 mov.AgentData.AgentID = this.AgentID;
188 mov.Data.RegionHandle = regInfo.RegionHandle;
189 mov.Data.Timestamp = 1172750370; // TODO - dynamicalise this
190
191 if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0))
192 {
193 mov.Data.Position = this.startpos;
194 }
195 else
196 {
197 mov.Data.Position = pos;
198 }
199 mov.Data.LookAt = look;
200
201 OutPacket(mov);
202 }
203
204 /// <summary>
205 ///
206 /// </summary>
207 /// <param name="message"></param>
208 /// <param name="type"></param>
209 /// <param name="fromPos"></param>
210 /// <param name="fromName"></param>
211 /// <param name="fromAgentID"></param>
212 public void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
213 {
214 SendChatMessage(Helpers.StringToField(message), type, fromPos, fromName, fromAgentID);
215 }
216
217 /// <summary>
218 ///
219 /// </summary>
220 /// <param name="message"></param>
221 /// <param name="type"></param>
222 /// <param name="fromPos"></param>
223 /// <param name="fromName"></param>
224 /// <param name="fromAgentID"></param>
225 public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
226 {
227 Encoding enc = Encoding.ASCII;
228 ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket();
229 reply.ChatData.Audible = 1;
230 reply.ChatData.Message = message;
231 reply.ChatData.ChatType = type;
232 reply.ChatData.SourceType = 1;
233 reply.ChatData.Position = fromPos;
234 reply.ChatData.FromName = enc.GetBytes(fromName + "\0");
235 reply.ChatData.OwnerID = fromAgentID;
236 reply.ChatData.SourceID = fromAgentID;
237
238 this.OutPacket(reply);
239 }
240
241 /// <summary>
242 ///
243 /// </summary>
244 /// <remarks>TODO</remarks>
245 /// <param name="message"></param>
246 /// <param name="target"></param>
247 public void SendInstantMessage(string message, LLUUID target)
248 {
249 ImprovedInstantMessagePacket msg = new ImprovedInstantMessagePacket();
250 msg.AgentData.AgentID = this.AgentID;
251 msg.AgentData.SessionID = this.SessionID;
252
253 msg.MessageBlock.Dialog = 0;
254 msg.MessageBlock.FromGroup = false;
255 msg.MessageBlock.ID = target.Combine(this.AgentID);
256 msg.MessageBlock.Offline = 0;
257 msg.MessageBlock.ParentEstateID = 0;
258 msg.MessageBlock.Position = new LLVector3();
259 msg.MessageBlock.RegionID = new LLUUID();
260 msg.MessageBlock.Timestamp = 0;
261 msg.MessageBlock.ToAgentID = target;
262
263 this.OutPacket(msg);
264 }
265
266 /// <summary>
267 /// Send the region heightmap to the client
268 /// </summary>
269 /// <param name="map">heightmap</param>
270 public virtual void SendLayerData(float[] map)
271 {
272 try
273 {
274 int[] patches = new int[4];
275
276 for (int y = 0; y < 16; y++)
277 {
278 for (int x = 0; x < 16; x = x + 4)
279 {
280 patches[0] = x + 0 + y * 16;
281 patches[1] = x + 1 + y * 16;
282 patches[2] = x + 2 + y * 16;
283 patches[3] = x + 3 + y * 16;
284
285 Packet layerpack = TerrainManager.CreateLandPacket(map, patches);
286 OutPacket(layerpack);
287 }
288 }
289 }
290 catch (Exception e)
291 {
292 MainLog.Instance.Warn("ClientView API.cs: SendLayerData() - Failed with exception " + e.ToString());
293 }
294 }
295
296 /// <summary>
297 /// Sends a specified patch to a client
298 /// </summary>
299 /// <param name="px">Patch coordinate (x) 0..16</param>
300 /// <param name="py">Patch coordinate (y) 0..16</param>
301 /// <param name="map">heightmap</param>
302 public void SendLayerData(int px, int py, float[] map)
303 {
304 try
305 {
306 int[] patches = new int[1];
307 int patchx, patchy;
308 patchx = px / 16;
309 patchy = py / 16;
310
311 patches[0] = patchx + 0 + patchy * 16;
312
313 Packet layerpack = TerrainManager.CreateLandPacket(map, patches);
314 OutPacket(layerpack);
315 }
316 catch (Exception e)
317 {
318 MainLog.Instance.Warn("ClientView API .cs: SendLayerData() - Failed with exception " + e.ToString());
319 }
320 }
321
322 /// <summary>
323 ///
324 /// </summary>
325 /// <param name="neighbourHandle"></param>
326 /// <param name="neighbourIP"></param>
327 /// <param name="neighbourPort"></param>
328 public void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint )
329 {
330 IPAddress neighbourIP = neighbourEndPoint.Address;
331 ushort neighbourPort = (ushort) neighbourEndPoint.Port;
332
333 EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket();
334 enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
335 enablesimpacket.SimulatorInfo.Handle = neighbourHandle;
336
337 byte[] byteIP = neighbourIP.GetAddressBytes();
338 enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
339 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
340 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
341 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
342 enablesimpacket.SimulatorInfo.Port = neighbourPort;
343 OutPacket(enablesimpacket);
344 }
345
346 /// <summary>
347 ///
348 /// </summary>
349 /// <returns></returns>
350 public AgentCircuitData RequestClientInfo()
351 {
352 AgentCircuitData agentData = new AgentCircuitData();
353 agentData.AgentID = this.AgentId;
354 agentData.SessionID = this.SessionID;
355 agentData.SecureSessionID = this.SecureSessionID;
356 agentData.circuitcode = this.CircuitCode;
357 agentData.child = false;
358 agentData.firstname = this.firstName;
359 agentData.lastname = this.lastName;
360
361 return agentData;
362 }
363
364 public void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint externalIPEndPoint)
365 {
366 LLVector3 look = new LLVector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10);
367
368 CrossedRegionPacket newSimPack = new CrossedRegionPacket();
369 newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
370 newSimPack.AgentData.AgentID = this.AgentID;
371 newSimPack.AgentData.SessionID = this.SessionID;
372 newSimPack.Info = new CrossedRegionPacket.InfoBlock();
373 newSimPack.Info.Position = pos;
374 newSimPack.Info.LookAt = look; // new LLVector3(0.0f, 0.0f, 0.0f); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!!
375 newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock();
376 newSimPack.RegionData.RegionHandle = newRegionHandle;
377 byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes();
378 newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
379 newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
380 newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
381 newSimPack.RegionData.SimIP += (uint)byteIP[0];
382 newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port;
383 newSimPack.RegionData.SeedCapability = new byte[0];
384
385 this.OutPacket(newSimPack);
386 //this.DowngradeClient();
387 }
388
389 public void SendMapBlock(List<MapBlockData> mapBlocks)
390 {
391 Encoding _enc = Encoding.ASCII;
392
393 MapBlockReplyPacket mapReply = new MapBlockReplyPacket();
394 mapReply.AgentData.AgentID = this.AgentID;
395 mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks.Count];
396 mapReply.AgentData.Flags = 0;
397
398 for (int i = 0; i < mapBlocks.Count; i++)
399 {
400 mapReply.Data[i] = new MapBlockReplyPacket.DataBlock();
401 mapReply.Data[i].MapImageID = mapBlocks[i].MapImageId;
402 mapReply.Data[i].X = mapBlocks[i].X;
403 mapReply.Data[i].Y = mapBlocks[i].Y;
404 mapReply.Data[i].WaterHeight = mapBlocks[i].WaterHeight;
405 mapReply.Data[i].Name = _enc.GetBytes(mapBlocks[i].Name);
406 mapReply.Data[i].RegionFlags = mapBlocks[i].RegionFlags;
407 mapReply.Data[i].Access = mapBlocks[i].Access;
408 mapReply.Data[i].Agents = mapBlocks[i].Agents;
409 }
410 this.OutPacket(mapReply);
411 }
412
413 public void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags)
414 {
415 TeleportLocalPacket tpLocal = new TeleportLocalPacket();
416 tpLocal.Info.AgentID = this.AgentID;
417 tpLocal.Info.TeleportFlags = flags;
418 tpLocal.Info.LocationID = 2;
419 tpLocal.Info.LookAt = lookAt;
420 tpLocal.Info.Position = position;
421 OutPacket(tpLocal);
422 }
423
424 public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID, uint flags)
425 {
426 TeleportFinishPacket teleport = new TeleportFinishPacket();
427 teleport.Info.AgentID = this.AgentID;
428 teleport.Info.RegionHandle = regionHandle;
429 teleport.Info.SimAccess = simAccess;
430 teleport.Info.SeedCapability = new byte[0];
431
432 IPAddress oIP = newRegionEndPoint.Address;
433 byte[] byteIP = oIP.GetAddressBytes();
434 uint ip = (uint)byteIP[3] << 24;
435 ip += (uint)byteIP[2] << 16;
436 ip += (uint)byteIP[1] << 8;
437 ip += (uint)byteIP[0];
438
439 teleport.Info.SimIP = ip;
440 teleport.Info.SimPort = (ushort)newRegionEndPoint.Port;
441 teleport.Info.LocationID = 4;
442 teleport.Info.TeleportFlags = 1 << 4;
443 OutPacket(teleport);
444 }
445
446 /// <summary>
447 ///
448 /// </summary>
449 public void SendTeleportCancel()
450 {
451 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
452 tpCancel.Info.SessionID = this.SessionID;
453 tpCancel.Info.AgentID = this.AgentID;
454
455 OutPacket(tpCancel);
456 }
457
458 /// <summary>
459 ///
460 /// </summary>
461 public void SendTeleportLocationStart()
462 {
463 TeleportStartPacket tpStart = new TeleportStartPacket();
464 tpStart.Info.TeleportFlags = 16; // Teleport via location
465 OutPacket(tpStart);
466 }
467
468 public void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance)
469 {
470 MoneyBalanceReplyPacket money = new MoneyBalanceReplyPacket();
471 money.MoneyData.AgentID = this.AgentID;
472 money.MoneyData.TransactionID = transaction;
473 money.MoneyData.TransactionSuccess = success;
474 money.MoneyData.Description = description;
475 money.MoneyData.MoneyBalance = balance;
476 OutPacket(money);
477 }
478
479 public void SendStartPingCheck(byte seq)
480 {
481 StartPingCheckPacket pc = new StartPingCheckPacket();
482 pc.PingID.PingID = seq;
483 OutPacket(pc);
484 }
485
486 public void SendKillObject(ulong regionHandle, uint avatarLocalID)
487 {
488 KillObjectPacket kill = new KillObjectPacket();
489 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
490 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
491 kill.ObjectData[0].ID = avatarLocalID;
492 OutPacket(kill);
493 }
494
495
496 #region Appearance/ Wearables Methods
497
498 /// <summary>
499 ///
500 /// </summary>
501 /// <param name="wearables"></param>
502 public void SendWearables(AvatarWearable[] wearables)
503 {
504 AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
505 aw.AgentData.AgentID = this.AgentID;
506 aw.AgentData.SerialNum = 0;
507 aw.AgentData.SessionID = this.SessionID;
508
509 aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
510 AgentWearablesUpdatePacket.WearableDataBlock awb;
511 for (int i = 0; i < wearables.Length; i++)
512 {
513 awb = new AgentWearablesUpdatePacket.WearableDataBlock();
514 awb.WearableType = (byte)i;
515 awb.AssetID = wearables[i].AssetID;
516 awb.ItemID = wearables[i].ItemID;
517 aw.WearableData[i] = awb;
518 }
519
520 this.OutPacket(aw);
521 }
522
523 /// <summary>
524 ///
525 /// </summary>
526 /// <param name="agentID"></param>
527 /// <param name="visualParams"></param>
528 /// <param name="textureEntry"></param>
529 public void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry)
530 {
531 AvatarAppearancePacket avp = new AvatarAppearancePacket();
532 avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
533 avp.ObjectData.TextureEntry = textureEntry;
534
535 AvatarAppearancePacket.VisualParamBlock avblock = null;
536 for (int i = 0; i < visualParams.Length; i++)
537 {
538 avblock = new AvatarAppearancePacket.VisualParamBlock();
539 avblock.ParamValue = visualParams[i];
540 avp.VisualParam[i] = avblock;
541 }
542
543 avp.Sender.IsTrial = false;
544 avp.Sender.ID = agentID;
545 OutPacket(avp);
546 }
547
548 public void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId)
549 {
550 AvatarAnimationPacket ani = new AvatarAnimationPacket();
551 ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1];
552 ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock();
553 ani.AnimationSourceList[0].ObjectID = sourceAgentId;
554 ani.Sender = new AvatarAnimationPacket.SenderBlock();
555 ani.Sender.ID = sourceAgentId;
556 ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1];
557 ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock();
558 ani.AnimationList[0].AnimID = animID;
559 ani.AnimationList[0].AnimSequenceID = seq;
560 this.OutPacket(ani);
561 }
562
563 #endregion
564
565 #region Avatar Packet/data sending Methods
566
567 /// <summary>
568 ///
569 /// </summary>
570 /// <param name="regionInfo"></param>
571 /// <param name="firstName"></param>
572 /// <param name="lastName"></param>
573 /// <param name="avatarID"></param>
574 /// <param name="avatarLocalID"></param>
575 /// <param name="Pos"></param>
576 public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry)
577 {
578 Encoding _enc = Encoding.ASCII;
579 //send a objectupdate packet with information about the clients avatar
580
581 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
582 objupdate.RegionData.RegionHandle = regionHandle;
583 objupdate.RegionData.TimeDilation = 64096;
584 objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
585 objupdate.ObjectData[0] = this.CreateDefaultAvatarPacket(textureEntry);
586 //give this avatar object a local id and assign the user a name
587
588 objupdate.ObjectData[0].ID = avatarLocalID;
589 objupdate.ObjectData[0].FullID = avatarID;
590 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstName + "\nLastName STRING RW SV " + lastName + " \0");
591 LLVector3 pos2 = new LLVector3((float)Pos.X, (float)Pos.Y, (float)Pos.Z);
592 byte[] pb = pos2.GetBytes();
593 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
594
595 OutPacket(objupdate);
596
597 }
598
599 /// <summary>
600 ///
601 /// </summary>
602 /// <param name="regionHandle"></param>
603 /// <param name="timeDilation"></param>
604 /// <param name="localID"></param>
605 /// <param name="position"></param>
606 /// <param name="velocity"></param>
607 public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity)
608 {
609 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = this.CreateAvatarImprovedBlock(localID, position, velocity);
610 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
611 terse.RegionData.RegionHandle = regionHandle;
612 terse.RegionData.TimeDilation = timeDilation;
613 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
614 terse.ObjectData[0] = terseBlock;
615
616 this.OutPacket(terse);
617 }
618
619 #endregion
620
621 #region Primitive Packet/data Sending Methods
622
623 /// <summary>
624 ///
625 /// </summary>
626 /// <param name="localID"></param>
627 /// <param name="rotation"></param>
628 /// <param name="attachPoint"></param>
629 public void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint)
630 {
631 ObjectAttachPacket attach = new ObjectAttachPacket();
632 attach.AgentData.AgentID = this.AgentID;
633 attach.AgentData.SessionID = this.SessionID;
634 attach.AgentData.AttachmentPoint = attachPoint;
635 attach.ObjectData = new ObjectAttachPacket.ObjectDataBlock[1];
636 attach.ObjectData[0] = new ObjectAttachPacket.ObjectDataBlock();
637 attach.ObjectData[0].ObjectLocalID = localID;
638 attach.ObjectData[0].Rotation = rotation;
639
640 this.OutPacket(attach);
641 }
642
643 /// <summary>
644 /// Sends a full ObjectUpdatePacket to a client to inform it of a new primitive
645 /// or big changes to a existing primitive.
646 /// </summary>
647 /// <param name="regionHandle"></param>
648 /// <param name="timeDilation"></param>
649 /// <param name="localID"></param>
650 /// <param name="primData"></param>
651 /// <param name="pos"></param>
652 /// <param name="rotation"></param>
653 /// <param name="textureID"></param>
654 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags)
655 {
656 ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
657 outPacket.RegionData.RegionHandle = regionHandle;
658 outPacket.RegionData.TimeDilation = timeDilation;
659 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
660 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primData, textureID, flags);
661 outPacket.ObjectData[0].ID = localID;
662 outPacket.ObjectData[0].FullID = primData.FullID;
663 byte[] pb = pos.GetBytes();
664 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
665 byte[] rot = rotation.GetBytes();
666 Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 48, rot.Length);
667 OutPacket(outPacket);
668 }
669
670 /// <summary>
671 /// Sends a full ObjectUpdatePacket to a client to inform it of a new primitive
672 /// or big changes to a existing primitive.
673 /// Uses default rotation
674 /// </summary>
675 /// <param name="primData"></param>
676 /// <param name="pos"></param>
677 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLUUID textureID , uint flags)
678 {
679 ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
680 outPacket.RegionData.RegionHandle = regionHandle;
681 outPacket.RegionData.TimeDilation = timeDilation;
682 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
683 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primData, textureID, flags);
684 outPacket.ObjectData[0].ID = localID;
685 outPacket.ObjectData[0].FullID = primData.FullID;
686 byte[] pb = pos.GetBytes();
687 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
688
689 OutPacket(outPacket);
690 }
691
692
693 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID)
694 {
695 ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
696 outPacket.RegionData.RegionHandle = regionHandle;
697 outPacket.RegionData.TimeDilation = timeDilation;
698 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
699 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, textureID, flags);
700 outPacket.ObjectData[0].ID = localID;
701 outPacket.ObjectData[0].FullID = objectID;
702 outPacket.ObjectData[0].OwnerID = ownerID;
703 outPacket.ObjectData[0].Text = enc.GetBytes(text);
704 outPacket.ObjectData[0].ParentID = parentID;
705 byte[] pb = pos.GetBytes();
706 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
707 byte[] rot = rotation.GetBytes();
708 Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 36, rot.Length);
709 OutPacket(outPacket);
710 }
711
712 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID)
713 {
714 ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
715 outPacket.RegionData.RegionHandle = regionHandle;
716 outPacket.RegionData.TimeDilation = timeDilation;
717 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
718 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, textureID, flags);
719 outPacket.ObjectData[0].ID = localID;
720 outPacket.ObjectData[0].FullID = objectID;
721 outPacket.ObjectData[0].OwnerID = ownerID;
722 outPacket.ObjectData[0].Text = enc.GetBytes(text);
723 outPacket.ObjectData[0].ParentID = parentID;
724 byte[] pb = pos.GetBytes();
725 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
726
727 OutPacket(outPacket);
728 }
729 /// <summary>
730 ///
731 /// </summary>
732 /// <param name="regionHandle"></param>
733 /// <param name="timeDilation"></param>
734 /// <param name="localID"></param>
735 /// <param name="position"></param>
736 /// <param name="rotation"></param>
737 public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation)
738 {
739 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
740 terse.RegionData.RegionHandle = regionHandle;
741 terse.RegionData.TimeDilation = timeDilation;
742 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
743 terse.ObjectData[0] = this.CreatePrimImprovedBlock(localID, position, rotation);
744
745 this.OutPacket(terse);
746 }
747
748 #endregion
749
750 #endregion
751
752 #region Helper Methods
753
754 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos, LLVector3 velocity)
755 {
756 byte[] bytes = new byte[60];
757 int i = 0;
758 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
759
760 dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry;
761
762 uint ID = localID;
763
764 bytes[i++] = (byte)(ID % 256);
765 bytes[i++] = (byte)((ID >> 8) % 256);
766 bytes[i++] = (byte)((ID >> 16) % 256);
767 bytes[i++] = (byte)((ID >> 24) % 256);
768 bytes[i++] = 0;
769 bytes[i++] = 1;
770 i += 14;
771 bytes[i++] = 128;
772 bytes[i++] = 63;
773
774 byte[] pb = pos.GetBytes();
775 Array.Copy(pb, 0, bytes, i, pb.Length);
776 i += 12;
777 ushort InternVelocityX;
778 ushort InternVelocityY;
779 ushort InternVelocityZ;
780 Vector3 internDirec = new Vector3(0, 0, 0);
781
782 internDirec = new Vector3(velocity.X, velocity.Y, velocity.Z);
783
784 internDirec = internDirec / 128.0f;
785 internDirec.x += 1;
786 internDirec.y += 1;
787 internDirec.z += 1;
788
789 InternVelocityX = (ushort)(32768 * internDirec.x);
790 InternVelocityY = (ushort)(32768 * internDirec.y);
791 InternVelocityZ = (ushort)(32768 * internDirec.z);
792
793 ushort ac = 32767;
794 bytes[i++] = (byte)(InternVelocityX % 256);
795 bytes[i++] = (byte)((InternVelocityX >> 8) % 256);
796 bytes[i++] = (byte)(InternVelocityY % 256);
797 bytes[i++] = (byte)((InternVelocityY >> 8) % 256);
798 bytes[i++] = (byte)(InternVelocityZ % 256);
799 bytes[i++] = (byte)((InternVelocityZ >> 8) % 256);
800
801 //accel
802 bytes[i++] = (byte)(ac % 256);
803 bytes[i++] = (byte)((ac >> 8) % 256);
804 bytes[i++] = (byte)(ac % 256);
805 bytes[i++] = (byte)((ac >> 8) % 256);
806 bytes[i++] = (byte)(ac % 256);
807 bytes[i++] = (byte)((ac >> 8) % 256);
808
809 //rot
810 bytes[i++] = (byte)(ac % 256);
811 bytes[i++] = (byte)((ac >> 8) % 256);
812 bytes[i++] = (byte)(ac % 256);
813 bytes[i++] = (byte)((ac >> 8) % 256);
814 bytes[i++] = (byte)(ac % 256);
815 bytes[i++] = (byte)((ac >> 8) % 256);
816 bytes[i++] = (byte)(ac % 256);
817 bytes[i++] = (byte)((ac >> 8) % 256);
818
819 //rotation vel
820 bytes[i++] = (byte)(ac % 256);
821 bytes[i++] = (byte)((ac >> 8) % 256);
822 bytes[i++] = (byte)(ac % 256);
823 bytes[i++] = (byte)((ac >> 8) % 256);
824 bytes[i++] = (byte)(ac % 256);
825 bytes[i++] = (byte)((ac >> 8) % 256);
826
827 dat.Data = bytes;
828 return (dat);
829 }
830
831 /// <summary>
832 ///
833 /// </summary>
834 /// <param name="localID"></param>
835 /// <param name="position"></param>
836 /// <param name="rotation"></param>
837 /// <returns></returns>
838 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, LLVector3 position, LLQuaternion rotation)
839 {
840 uint ID = localID;
841 byte[] bytes = new byte[60];
842
843 int i = 0;
844 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
845 dat.TextureEntry = new byte[0];
846 bytes[i++] = (byte)(ID % 256);
847 bytes[i++] = (byte)((ID >> 8) % 256);
848 bytes[i++] = (byte)((ID >> 16) % 256);
849 bytes[i++] = (byte)((ID >> 24) % 256);
850 bytes[i++] = 0;
851 bytes[i++] = 0;
852
853 byte[] pb = position.GetBytes();
854 Array.Copy(pb, 0, bytes, i, pb.Length);
855 i += 12;
856 ushort ac = 32767;
857
858 //vel
859 bytes[i++] = (byte)(ac % 256);
860 bytes[i++] = (byte)((ac >> 8) % 256);
861 bytes[i++] = (byte)(ac % 256);
862 bytes[i++] = (byte)((ac >> 8) % 256);
863 bytes[i++] = (byte)(ac % 256);
864 bytes[i++] = (byte)((ac >> 8) % 256);
865
866 //accel
867 bytes[i++] = (byte)(ac % 256);
868 bytes[i++] = (byte)((ac >> 8) % 256);
869 bytes[i++] = (byte)(ac % 256);
870 bytes[i++] = (byte)((ac >> 8) % 256);
871 bytes[i++] = (byte)(ac % 256);
872 bytes[i++] = (byte)((ac >> 8) % 256);
873
874 ushort rw, rx, ry, rz;
875 rw = (ushort)(32768 * (rotation.W + 1));
876 rx = (ushort)(32768 * (rotation.X + 1));
877 ry = (ushort)(32768 * (rotation.Y + 1));
878 rz = (ushort)(32768 * (rotation.Z + 1));
879
880 //rot
881 bytes[i++] = (byte)(rx % 256);
882 bytes[i++] = (byte)((rx >> 8) % 256);
883 bytes[i++] = (byte)(ry % 256);
884 bytes[i++] = (byte)((ry >> 8) % 256);
885 bytes[i++] = (byte)(rz % 256);
886 bytes[i++] = (byte)((rz >> 8) % 256);
887 bytes[i++] = (byte)(rw % 256);
888 bytes[i++] = (byte)((rw >> 8) % 256);
889
890 //rotation vel
891 bytes[i++] = (byte)(ac % 256);
892 bytes[i++] = (byte)((ac >> 8) % 256);
893 bytes[i++] = (byte)(ac % 256);
894 bytes[i++] = (byte)((ac >> 8) % 256);
895 bytes[i++] = (byte)(ac % 256);
896 bytes[i++] = (byte)((ac >> 8) % 256);
897
898 dat.Data = bytes;
899 return dat;
900 }
901
902
903 /// <summary>
904 /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive)
905 /// </summary>
906 /// <param name="primData"></param>
907 /// <returns></returns>
908 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimData primData, LLUUID textureID, uint flags)
909 {
910 ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock();
911 this.SetDefaultPrimPacketValues(objupdate);
912 objupdate.UpdateFlags = flags;
913 this.SetPrimPacketShapeData(objupdate, primData, textureID);
914
915 return objupdate;
916 }
917
918 /// <summary>
919 /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive)
920 /// </summary>
921 /// <param name="primData"></param>
922 /// <returns></returns>
923 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimitiveBaseShape primShape, LLUUID textureID, uint flags)
924 {
925 ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock();
926 this.SetDefaultPrimPacketValues(objupdate);
927 objupdate.UpdateFlags = flags;
928 this.SetPrimPacketShapeData(objupdate, primShape, textureID);
929
930 return objupdate;
931 }
932
933
934 /// <summary>
935 /// Copy the data from a PrimData object to a ObjectUpdatePacket
936 /// </summary>
937 /// <param name="objectData"></param>
938 /// <param name="primData"></param>
939 protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimData primData, LLUUID textureID)
940 {
941 LLObject.TextureEntry ntex = new LLObject.TextureEntry(textureID);
942 objectData.TextureEntry = ntex.ToBytes();
943 objectData.OwnerID = primData.OwnerID;
944 objectData.ParentID = primData.ParentID;
945 objectData.PCode = primData.PCode;
946 objectData.PathBegin = primData.PathBegin;
947 objectData.PathEnd = primData.PathEnd;
948 objectData.PathScaleX = primData.PathScaleX;
949 objectData.PathScaleY = primData.PathScaleY;
950 objectData.PathShearX = primData.PathShearX;
951 objectData.PathShearY = primData.PathShearY;
952 objectData.PathSkew = primData.PathSkew;
953 objectData.ProfileBegin = primData.ProfileBegin;
954 objectData.ProfileEnd = primData.ProfileEnd;
955 objectData.Scale = primData.Scale;
956 objectData.PathCurve = primData.PathCurve;
957 objectData.ProfileCurve = primData.ProfileCurve;
958 objectData.ProfileHollow = primData.ProfileHollow;
959 objectData.PathRadiusOffset = primData.PathRadiusOffset;
960 objectData.PathRevolutions = primData.PathRevolutions;
961 objectData.PathTaperX = primData.PathTaperX;
962 objectData.PathTaperY = primData.PathTaperY;
963 objectData.PathTwist = primData.PathTwist;
964 objectData.PathTwistBegin = primData.PathTwistBegin;
965 }
966
967 protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimitiveBaseShape primData, LLUUID textureID)
968 {
969 LLObject.TextureEntry ntex = new LLObject.TextureEntry(textureID);
970 objectData.TextureEntry = ntex.ToBytes();
971 objectData.PCode = primData.PCode;
972 objectData.PathBegin = primData.PathBegin;
973 objectData.PathEnd = primData.PathEnd;
974 objectData.PathScaleX = primData.PathScaleX;
975 objectData.PathScaleY = primData.PathScaleY;
976 objectData.PathShearX = primData.PathShearX;
977 objectData.PathShearY = primData.PathShearY;
978 objectData.PathSkew = primData.PathSkew;
979 objectData.ProfileBegin = primData.ProfileBegin;
980 objectData.ProfileEnd = primData.ProfileEnd;
981 objectData.Scale = primData.Scale;
982 objectData.PathCurve = primData.PathCurve;
983 objectData.ProfileCurve = primData.ProfileCurve;
984 objectData.ProfileHollow = primData.ProfileHollow;
985 objectData.PathRadiusOffset = primData.PathRadiusOffset;
986 objectData.PathRevolutions = primData.PathRevolutions;
987 objectData.PathTaperX = primData.PathTaperX;
988 objectData.PathTaperY = primData.PathTaperY;
989 objectData.PathTwist = primData.PathTwist;
990 objectData.PathTwistBegin = primData.PathTwistBegin;
991 }
992
993 /// <summary>
994 /// Set some default values in a ObjectUpdatePacket
995 /// </summary>
996 /// <param name="objdata"></param>
997 protected void SetDefaultPrimPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata)
998 {
999 objdata.PSBlock = new byte[0];
1000 objdata.ExtraParams = new byte[1];
1001 objdata.MediaURL = new byte[0];
1002 objdata.NameValue = new byte[0];
1003 objdata.Text = new byte[0];
1004 objdata.TextColor = new byte[4];
1005 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0);
1006 objdata.JointPivot = new LLVector3(0, 0, 0);
1007 objdata.Material = 3;
1008 objdata.TextureAnim = new byte[0];
1009 objdata.Sound = LLUUID.Zero;
1010 objdata.State = 0;
1011 objdata.Data = new byte[0];
1012
1013 objdata.ObjectData = new byte[60];
1014 objdata.ObjectData[46] = 128;
1015 objdata.ObjectData[47] = 63;
1016 }
1017
1018
1019 /// <summary>
1020 ///
1021 /// </summary>
1022 /// <returns></returns>
1023 protected ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry)
1024 {
1025 ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i);
1026
1027 SetDefaultAvatarPacketValues(ref objdata);
1028 objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24);
1029 objdata.PathCurve = 16;
1030 objdata.ProfileCurve = 1;
1031 objdata.PathScaleX = 100;
1032 objdata.PathScaleY = 100;
1033 objdata.ParentID = 0;
1034 objdata.OwnerID = LLUUID.Zero;
1035 objdata.Scale = new LLVector3(1, 1, 1);
1036 objdata.PCode = 47;
1037 if (textureEntry != null)
1038 {
1039 objdata.TextureEntry = textureEntry;
1040 }
1041 Encoding enc = Encoding.ASCII;
1042 LLVector3 pos = new LLVector3(objdata.ObjectData, 16);
1043 pos.X = 100f;
1044 objdata.ID = 8880000;
1045 objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0");
1046 LLVector3 pos2 = new LLVector3(100f, 100f, 23f);
1047 //objdata.FullID=user.AgentID;
1048 byte[] pb = pos.GetBytes();
1049 Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length);
1050
1051 return objdata;
1052 }
1053
1054 /// <summary>
1055 ///
1056 /// </summary>
1057 /// <param name="objdata"></param>
1058 protected void SetDefaultAvatarPacketValues(ref ObjectUpdatePacket.ObjectDataBlock objdata)
1059 {
1060 objdata.PSBlock = new byte[0];
1061 objdata.ExtraParams = new byte[1];
1062 objdata.MediaURL = new byte[0];
1063 objdata.NameValue = new byte[0];
1064 objdata.Text = new byte[0];
1065 objdata.TextColor = new byte[4];
1066 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0);
1067 objdata.JointPivot = new LLVector3(0, 0, 0);
1068 objdata.Material = 4;
1069 objdata.TextureAnim = new byte[0];
1070 objdata.Sound = LLUUID.Zero;
1071 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
1072 objdata.TextureEntry = ntex.ToBytes();
1073 objdata.State = 0;
1074 objdata.Data = new byte[0];
1075
1076 objdata.ObjectData = new byte[76];
1077 objdata.ObjectData[15] = 128;
1078 objdata.ObjectData[16] = 63;
1079 objdata.ObjectData[56] = 128;
1080 objdata.ObjectData[61] = 102;
1081 objdata.ObjectData[62] = 40;
1082 objdata.ObjectData[63] = 61;
1083 objdata.ObjectData[64] = 189;
1084 }
1085
1086 /// <summary>
1087 ///
1088 /// </summary>
1089 /// <param name="addPacket"></param>
1090 /// <returns></returns>
1091 protected PrimData CreatePrimFromObjectAdd(ObjectAddPacket addPacket)
1092 {
1093 PrimData PData = new PrimData();
1094 PData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
1095 PData.PCode = addPacket.ObjectData.PCode;
1096 PData.PathBegin = addPacket.ObjectData.PathBegin;
1097 PData.PathEnd = addPacket.ObjectData.PathEnd;
1098 PData.PathScaleX = addPacket.ObjectData.PathScaleX;
1099 PData.PathScaleY = addPacket.ObjectData.PathScaleY;
1100 PData.PathShearX = addPacket.ObjectData.PathShearX;
1101 PData.PathShearY = addPacket.ObjectData.PathShearY;
1102 PData.PathSkew = addPacket.ObjectData.PathSkew;
1103 PData.ProfileBegin = addPacket.ObjectData.ProfileBegin;
1104 PData.ProfileEnd = addPacket.ObjectData.ProfileEnd;
1105 PData.Scale = addPacket.ObjectData.Scale;
1106 PData.PathCurve = addPacket.ObjectData.PathCurve;
1107 PData.ProfileCurve = addPacket.ObjectData.ProfileCurve;
1108 PData.ParentID = 0;
1109 PData.ProfileHollow = addPacket.ObjectData.ProfileHollow;
1110 PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
1111 PData.PathRevolutions = addPacket.ObjectData.PathRevolutions;
1112 PData.PathTaperX = addPacket.ObjectData.PathTaperX;
1113 PData.PathTaperY = addPacket.ObjectData.PathTaperY;
1114 PData.PathTwist = addPacket.ObjectData.PathTwist;
1115 PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
1116
1117 return PData;
1118 }
1119 #endregion
1120
1121 }
1122}
diff --git a/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs b/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs
new file mode 100644
index 0000000..60cd33a
--- /dev/null
+++ b/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs
@@ -0,0 +1,357 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
31using libsecondlife.Packets;
32using OpenSim.Assets;
33using OpenSim.Framework.Interfaces;
34using OpenSim.Framework.Types;
35using OpenSim.Framework.Utilities;
36using OpenSim.Region.Caches;
37
38namespace OpenSim.Region.ClientStack
39{
40 partial class ClientView
41 {
42 public class AgentAssetUpload
43 {
44 private Dictionary<LLUUID, AssetTransaction> transactions = new Dictionary<LLUUID, AssetTransaction>();
45 private ClientView ourClient;
46 private AssetCache m_assetCache;
47 private InventoryCache m_inventoryCache;
48
49 public AgentAssetUpload(ClientView client, AssetCache assetCache, InventoryCache inventoryCache)
50 {
51 this.ourClient = client;
52 m_assetCache = assetCache;
53 m_inventoryCache = inventoryCache;
54 }
55
56 public void AddUpload(LLUUID transactionID, AssetBase asset)
57 {
58 AssetTransaction upload = new AssetTransaction();
59 lock (this.transactions)
60 {
61 upload.Asset = asset;
62 upload.TransactionID = transactionID;
63 this.transactions.Add(transactionID, upload);
64 }
65 if (upload.Asset.Data.Length > 2)
66 {
67 //is complete
68 upload.UploadComplete = true;
69 AssetUploadCompletePacket response = new AssetUploadCompletePacket();
70 response.AssetBlock.Type = asset.Type;
71 response.AssetBlock.Success = true;
72 response.AssetBlock.UUID = transactionID.Combine(this.ourClient.SecureSessionID);
73 this.ourClient.OutPacket(response);
74 m_assetCache.AddAsset(asset);
75 }
76 else
77 {
78 upload.UploadComplete = false;
79 upload.XferID = Util.GetNextXferID();
80 RequestXferPacket xfer = new RequestXferPacket();
81 xfer.XferID.ID = upload.XferID;
82 xfer.XferID.VFileType = upload.Asset.Type;
83 xfer.XferID.VFileID = transactionID.Combine(this.ourClient.SecureSessionID);
84 xfer.XferID.FilePath = 0;
85 xfer.XferID.Filename = new byte[0];
86 this.ourClient.OutPacket(xfer);
87 }
88
89 }
90
91 public AssetBase GetUpload(LLUUID transactionID)
92 {
93 if (this.transactions.ContainsKey(transactionID))
94 {
95 return this.transactions[transactionID].Asset;
96 }
97
98 return null;
99 }
100
101 public void HandleUploadPacket(AssetUploadRequestPacket pack, LLUUID assetID)
102 {
103 // Console.Write("asset upload request , type = " + pack.AssetBlock.Type.ToString());
104 AssetBase asset = null;
105 if (pack.AssetBlock.Type == 0)
106 {
107
108 //first packet for transaction
109 asset = new AssetBase();
110 asset.FullID = assetID;
111 asset.Type = pack.AssetBlock.Type;
112 asset.InvType = asset.Type;
113 asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000");
114 asset.Data = pack.AssetBlock.AssetData;
115
116
117 }
118 else if (pack.AssetBlock.Type == 13 | pack.AssetBlock.Type == 5 | pack.AssetBlock.Type == 7)
119 {
120
121 asset = new AssetBase();
122 asset.FullID = assetID;
123 // Console.WriteLine("skin asset id is " + assetID.ToStringHyphenated());
124 asset.Type = pack.AssetBlock.Type;
125 asset.InvType = asset.Type;
126 asset.Name = "NewClothing" + Util.RandomClass.Next(1, 1000).ToString("000");
127 asset.Data = pack.AssetBlock.AssetData;
128
129
130 }
131
132 if (asset != null)
133 {
134 this.AddUpload(pack.AssetBlock.TransactionID, asset);
135 }
136 else
137 {
138
139 //currently we don't support this asset type
140 //so lets just tell the client that the upload is complete
141 AssetUploadCompletePacket response = new AssetUploadCompletePacket();
142 response.AssetBlock.Type = pack.AssetBlock.Type;
143 response.AssetBlock.Success = true;
144 response.AssetBlock.UUID = pack.AssetBlock.TransactionID.Combine(this.ourClient.SecureSessionID);
145 this.ourClient.OutPacket(response);
146 }
147
148 }
149
150 #region Xfer packet system for larger uploads
151
152 public void HandleXferPacket(SendXferPacketPacket xferPacket)
153 {
154 lock (this.transactions)
155 {
156 foreach (AssetTransaction trans in this.transactions.Values)
157 {
158 if (trans.XferID == xferPacket.XferID.ID)
159 {
160 if (trans.Asset.Data.Length > 1)
161 {
162 byte[] newArray = new byte[trans.Asset.Data.Length + xferPacket.DataPacket.Data.Length];
163 Array.Copy(trans.Asset.Data, 0, newArray, 0, trans.Asset.Data.Length);
164 Array.Copy(xferPacket.DataPacket.Data, 0, newArray, trans.Asset.Data.Length, xferPacket.DataPacket.Data.Length);
165 trans.Asset.Data = newArray;
166 }
167 else
168 {
169 byte[] newArray = new byte[xferPacket.DataPacket.Data.Length - 4];
170 Array.Copy(xferPacket.DataPacket.Data, 4, newArray, 0, xferPacket.DataPacket.Data.Length - 4);
171 trans.Asset.Data = newArray;
172 }
173
174 if ((xferPacket.XferID.Packet & 2147483648) != 0)
175 {
176 //end of transfer
177 trans.UploadComplete = true;
178 AssetUploadCompletePacket response = new AssetUploadCompletePacket();
179 response.AssetBlock.Type = trans.Asset.Type;
180 response.AssetBlock.Success = true;
181 response.AssetBlock.UUID = trans.TransactionID.Combine(this.ourClient.SecureSessionID);
182 this.ourClient.OutPacket(response);
183
184 m_assetCache.AddAsset(trans.Asset);
185 //check if we should add it to inventory
186 if (trans.AddToInventory)
187 {
188 // m_assetCache.AddAsset(trans.Asset);
189 m_inventoryCache.AddNewInventoryItem(this.ourClient, trans.InventFolder, trans.Asset);
190 }
191
192
193 }
194 break;
195 }
196
197 }
198 }
199
200 ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket();
201 confirmXfer.XferID.ID = xferPacket.XferID.ID;
202 confirmXfer.XferID.Packet = xferPacket.XferID.Packet;
203 this.ourClient.OutPacket(confirmXfer);
204 }
205
206 #endregion
207
208 public AssetBase AddUploadToAssetCache(LLUUID transactionID)
209 {
210 AssetBase asset = null;
211 if (this.transactions.ContainsKey(transactionID))
212 {
213 AssetTransaction trans = this.transactions[transactionID];
214 if (trans.UploadComplete)
215 {
216 m_assetCache.AddAsset(trans.Asset);
217 asset = trans.Asset;
218 }
219 }
220
221 return asset;
222 }
223
224 public void CreateInventoryItem(CreateInventoryItemPacket packet)
225 {
226 if (this.transactions.ContainsKey(packet.InventoryBlock.TransactionID))
227 {
228 AssetTransaction trans = this.transactions[packet.InventoryBlock.TransactionID];
229 trans.Asset.Description = Util.FieldToString(packet.InventoryBlock.Description);
230 trans.Asset.Name = Util.FieldToString(packet.InventoryBlock.Name);
231 trans.Asset.Type = packet.InventoryBlock.Type;
232 trans.Asset.InvType = packet.InventoryBlock.InvType;
233 if (trans.UploadComplete)
234 {
235 //already complete so we can add it to the inventory
236 //m_assetCache.AddAsset(trans.Asset);
237 m_inventoryCache.AddNewInventoryItem(this.ourClient, packet.InventoryBlock.FolderID, trans.Asset);
238 }
239 else
240 {
241 trans.AddToInventory = true;
242 trans.InventFolder = packet.InventoryBlock.FolderID;
243 }
244 }
245 }
246
247 private class AssetTransaction
248 {
249 public uint XferID;
250 public AssetBase Asset;
251 public bool AddToInventory;
252 public LLUUID InventFolder = LLUUID.Zero;
253 public bool UploadComplete = false;
254 public LLUUID TransactionID = LLUUID.Zero;
255
256 public AssetTransaction()
257 {
258
259 }
260 }
261
262 //new class , not currently used.
263 public class AssetXferUploader
264 {
265 private IClientAPI ourClient;
266
267 public bool UploadComplete = false;
268
269 public bool AddToInventory;
270 public LLUUID InventFolder = LLUUID.Zero;
271
272 public uint XferID;
273 public AssetBase Asset;
274 public LLUUID TransactionID = LLUUID.Zero;
275
276
277 public AssetXferUploader(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data)
278 {
279 ourClient = remoteClient;
280 Asset = new AssetBase();
281 Asset.FullID = assetID;
282 Asset.InvType = type;
283 Asset.Type = type;
284 Asset.Data = data;
285 Asset.Name = "blank";
286 Asset.Description = "empty";
287 TransactionID = transaction;
288
289 if (Asset.Data.Length > 2)
290 {
291 //data block should only have data in it, if there is no more data to be uploaded
292 this.SendCompleteMessage();
293 }
294 else
295 {
296 this.ReqestStartXfer();
297 }
298 }
299
300 protected void SendCompleteMessage()
301 {
302 UploadComplete = true;
303 AssetUploadCompletePacket response = new AssetUploadCompletePacket();
304 response.AssetBlock.Type = Asset.Type;
305 response.AssetBlock.Success = true;
306 response.AssetBlock.UUID = Asset.FullID;
307 this.ourClient.OutPacket(response);
308
309 //TODO trigger event
310 }
311
312 protected void ReqestStartXfer()
313 {
314 UploadComplete = false;
315 XferID = Util.GetNextXferID();
316 RequestXferPacket xfer = new RequestXferPacket();
317 xfer.XferID.ID = XferID;
318 xfer.XferID.VFileType = Asset.Type;
319 xfer.XferID.VFileID = Asset.FullID;
320 xfer.XferID.FilePath = 0;
321 xfer.XferID.Filename = new byte[0];
322 this.ourClient.OutPacket(xfer);
323 }
324
325 public void HandleXferPacket(uint xferID, uint packetID, byte[] data)
326 {
327 if (XferID == xferID)
328 {
329 if (Asset.Data.Length > 1)
330 {
331 byte[] newArray = new byte[Asset.Data.Length + data.Length];
332 Array.Copy(Asset.Data, 0, newArray, 0, Asset.Data.Length);
333 Array.Copy(data, 0, newArray, Asset.Data.Length, data.Length);
334 Asset.Data = newArray;
335 }
336 else
337 {
338 byte[] newArray = new byte[data.Length - 4];
339 Array.Copy(data, 4, newArray, 0, data.Length - 4);
340 Asset.Data = newArray;
341 }
342
343 ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket();
344 confirmXfer.XferID.ID = xferID;
345 confirmXfer.XferID.Packet = packetID;
346 this.ourClient.OutPacket(confirmXfer);
347
348 if ((packetID & 2147483648) != 0)
349 {
350 this.SendCompleteMessage();
351 }
352 }
353 }
354 }
355 }
356 }
357}
diff --git a/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs b/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs
new file mode 100644
index 0000000..e67807e
--- /dev/null
+++ b/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs
@@ -0,0 +1,236 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29using libsecondlife.Packets;
30using OpenSim.Framework.Console;
31
32namespace OpenSim.Region.ClientStack
33{
34 public partial class ClientView
35 {
36 protected virtual void RegisterLocalPacketHandlers()
37 {
38 this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout);
39 this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached);
40 this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate);
41 }
42
43 protected virtual bool Logout(ClientView simClient, Packet packet)
44 {
45 MainLog.Instance.Verbose( "OpenSimClient.cs:ProcessInPacket() - Got a logout request");
46 //send reply to let the client logout
47 LogoutReplyPacket logReply = new LogoutReplyPacket();
48 logReply.AgentData.AgentID = this.AgentID;
49 logReply.AgentData.SessionID = this.SessionID;
50 logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
51 logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
52 logReply.InventoryData[0].ItemID = LLUUID.Zero;
53 OutPacket(logReply);
54 //
55 this.KillClient();
56 return true;
57 }
58
59 protected bool AgentTextureCached(ClientView simclient, Packet packet)
60 {
61 // Console.WriteLine(packet.ToString());
62 AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet;
63 AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket();
64 cachedresp.AgentData.AgentID = this.AgentID;
65 cachedresp.AgentData.SessionID = this.SessionID;
66 cachedresp.AgentData.SerialNum = this.cachedtextureserial;
67 this.cachedtextureserial++;
68 cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length];
69 for (int i = 0; i < chechedtex.WearableData.Length; i++)
70 {
71 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
72 cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex;
73 cachedresp.WearableData[i].TextureID = LLUUID.Zero;
74 cachedresp.WearableData[i].HostName = new byte[0];
75 }
76 this.OutPacket(cachedresp);
77 return true;
78 }
79
80 protected bool MultipleObjUpdate(ClientView simClient, Packet packet)
81 {
82 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
83 //System.Console.WriteLine("new multi update packet " + multipleupdate.ToString());
84 for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
85 {
86 #region position
87 if (multipleupdate.ObjectData[i].Type == 9) //change position
88 {
89 if (OnUpdatePrimGroupPosition != null)
90 {
91 LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
92 OnUpdatePrimGroupPosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this);
93 }
94
95 }
96 else if (multipleupdate.ObjectData[i].Type == 1) //single item of group change position
97 {
98 if (OnUpdatePrimSinglePosition != null)
99 {
100 libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
101 // System.Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
102 OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this);
103 }
104 }
105 #endregion position
106 #region rotation
107 else if (multipleupdate.ObjectData[i].Type == 2)// single item of group rotation from tab
108 {
109 if (OnUpdatePrimSingleRotation != null)
110 {
111 LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true);
112 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W);
113 OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this);
114 }
115 }
116 else if (multipleupdate.ObjectData[i].Type == 3)// single item of group rotation from mouse
117 {
118 if (OnUpdatePrimSingleRotation != null)
119 {
120 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true);
121 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W);
122 OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this);
123 }
124 }
125 else if (multipleupdate.ObjectData[i].Type == 10)//group rotation from object tab
126 {
127 if (OnUpdatePrimGroupRotation != null)
128 {
129 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true);
130 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W);
131 OnUpdatePrimGroupRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this);
132 }
133 }
134 else if (multipleupdate.ObjectData[i].Type == 11)//group rotation from mouse
135 {
136 if (OnUpdatePrimGroupMouseRotation != null)
137 {
138 libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
139 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true);
140 //Console.WriteLine("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
141 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W);
142 OnUpdatePrimGroupMouseRotation(multipleupdate.ObjectData[i].ObjectLocalID, pos, rot, this);
143 }
144 }
145 #endregion
146 #region scale
147 else if (multipleupdate.ObjectData[i].Type == 13)//group scale from object tab
148 {
149 if (OnUpdatePrimScale != null)
150 {
151 LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
152 //Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
153 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
154 }
155 }
156 else if (multipleupdate.ObjectData[i].Type == 29)//group scale from mouse
157 {
158 if (OnUpdatePrimScale != null)
159 {
160 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
161 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z );
162 // OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
163 }
164 }
165 else if (multipleupdate.ObjectData[i].Type == 5)//single prim scale from object tab
166 {
167 if (OnUpdatePrimScale != null)
168 {
169 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
170 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
171 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
172 }
173 }
174 else if (multipleupdate.ObjectData[i].Type == 21)//single prim scale from mouse
175 {
176 if (OnUpdatePrimScale != null)
177 {
178 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
179 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
180 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
181 }
182 }
183 #endregion
184 }
185 return true;
186 }
187
188 public void RequestMapLayer()
189 {
190 //should be getting the map layer from the grid server
191 //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
192 MapLayerReplyPacket mapReply = new MapLayerReplyPacket();
193 mapReply.AgentData.AgentID = this.AgentID;
194 mapReply.AgentData.Flags = 0;
195 mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
196 mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
197 mapReply.LayerData[0].Bottom = 0;
198 mapReply.LayerData[0].Left = 0;
199 mapReply.LayerData[0].Top = 30000;
200 mapReply.LayerData[0].Right = 30000;
201 mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-9999-000000000006");
202 this.OutPacket(mapReply);
203 }
204
205 public void RequestMapBlocks(int minX, int minY, int maxX, int maxY)
206 {
207 /*
208 IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
209 MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
210 mbReply.AgentData.AgentID = this.AgentID;
211 int len;
212 if (simMapProfiles == null)
213 len = 0;
214 else
215 len = simMapProfiles.Count;
216
217 mbReply.Data = new MapBlockReplyPacket.DataBlock[len];
218 int iii;
219 for (iii = 0; iii < len; iii++)
220 {
221 Hashtable mp = (Hashtable)simMapProfiles[iii];
222 mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock();
223 mbReply.Data[iii].Name = System.Text.Encoding.UTF8.GetBytes((string)mp["name"]);
224 mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]);
225 mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]);
226 mbReply.Data[iii].MapImageID = new LLUUID((string)mp["map-image-id"]);
227 mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
228 mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]);
229 mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]);
230 mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]);
231 }
232 this.OutPacket(mbReply);
233 */
234 }
235 }
236}
diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs
new file mode 100644
index 0000000..3265898
--- /dev/null
+++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs
@@ -0,0 +1,596 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
31using libsecondlife;
32using libsecondlife.Packets;
33using OpenSim.Framework.Inventory;
34using OpenSim.Framework.Types;
35using OpenSim.Framework.Utilities;
36
37namespace OpenSim.Region.ClientStack
38{
39 public partial class ClientView
40 {
41 protected override void ProcessInPacket(Packet Pack)
42 {
43 ack_pack(Pack);
44 if (debug)
45 {
46 if (Pack.Type != PacketType.AgentUpdate)
47 {
48 Console.WriteLine(CircuitCode + ":IN: " + Pack.Type.ToString());
49 }
50 }
51
52 if (this.ProcessPacketMethod(Pack))
53 {
54 //there is a handler registered that handled this packet type
55 return;
56 }
57 else
58 {
59 Encoding _enc = Encoding.ASCII;
60
61 switch (Pack.Type)
62 {
63 case PacketType.ViewerEffect:
64 ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
65 foreach (ClientView client in m_clientThreads.Values)
66 {
67 if (client.AgentID != this.AgentID)
68 {
69 viewer.AgentData.AgentID = client.AgentID;
70 viewer.AgentData.SessionID = client.SessionID;
71 client.OutPacket(viewer);
72 }
73 }
74 break;
75
76 #region World/Avatar
77 case PacketType.ChatFromViewer:
78 ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
79 if (Util.FieldToString(inchatpack.ChatData.Message) == "")
80 {
81 //empty message so don't bother with it
82 break;
83 }
84 string fromName = ""; //ClientAvatar.firstname + " " + ClientAvatar.lastname;
85 byte[] message = inchatpack.ChatData.Message;
86 byte type = inchatpack.ChatData.Type;
87 LLVector3 fromPos = new LLVector3(); // ClientAvatar.Pos;
88 LLUUID fromAgentID = AgentID;
89 if (OnChatFromViewer != null)
90 {
91 this.OnChatFromViewer(message, type, fromPos, fromName, fromAgentID);
92 }
93 break;
94 case PacketType.ImprovedInstantMessage:
95 ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack;
96
97 string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName);
98 string IMmessage = Util.FieldToString(msgpack.MessageBlock.Message);
99
100 if (OnInstantMessage != null)
101 {
102 this.OnInstantMessage(msgpack.AgentData.AgentID, msgpack.MessageBlock.ToAgentID,
103 msgpack.MessageBlock.Timestamp, IMfromName, IMmessage);
104 }
105
106 break;
107
108 case PacketType.RezObject:
109 RezObjectPacket rezPacket = (RezObjectPacket)Pack;
110 AgentInventory inven = this.m_inventoryCache.GetAgentsInventory(this.AgentID);
111 if (inven != null)
112 {
113 if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID))
114 {
115 AssetBase asset = this.m_assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID);
116 if (asset != null)
117 {
118 if (OnRezObject != null)
119 {
120 this.OnRezObject(asset, rezPacket.RezData.RayEnd);
121 this.m_inventoryCache.DeleteInventoryItem(this, rezPacket.InventoryData.ItemID);
122 }
123 }
124 }
125 }
126 break;
127 case PacketType.DeRezObject:
128 if (OnDeRezObject != null)
129 {
130 OnDeRezObject(Pack, this);
131 }
132 break;
133 case PacketType.ModifyLand:
134 ModifyLandPacket modify = (ModifyLandPacket)Pack;
135 if (modify.ParcelData.Length > 0)
136 {
137 if (OnModifyTerrain != null)
138 {
139 OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, modify.ModifyBlock.BrushSize,
140 modify.ModifyBlock.Action, modify.ParcelData[0].North, modify.ParcelData[0].West);
141 }
142 }
143 break;
144 case PacketType.RegionHandshakeReply:
145 if (OnRegionHandShakeReply != null)
146 {
147 OnRegionHandShakeReply(this);
148 }
149 break;
150 case PacketType.AgentWearablesRequest:
151 if (OnRequestWearables != null)
152 {
153 OnRequestWearables(this);
154 }
155 if (OnRequestAvatarsData != null)
156 {
157 OnRequestAvatarsData(this);
158 }
159 break;
160 case PacketType.AgentSetAppearance:
161 AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
162 if (OnSetAppearance != null)
163 {
164 OnSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam);
165 }
166 break;
167 case PacketType.CompleteAgentMovement:
168 if (OnCompleteMovementToRegion != null)
169 {
170 OnCompleteMovementToRegion();
171 }
172 break;
173 case PacketType.AgentUpdate:
174 if (OnAgentUpdate != null)
175 {
176 AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack;
177 OnAgentUpdate(this, agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotation);
178 }
179 break;
180 case PacketType.AgentAnimation:
181 if (!m_child)
182 {
183 AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
184 for (int i = 0; i < AgentAni.AnimationList.Length; i++)
185 {
186 if (AgentAni.AnimationList[i].StartAnim)
187 {
188 if (OnStartAnim != null)
189 {
190 OnStartAnim(AgentAni.AnimationList[i].AnimID, 1);
191 }
192 }
193 }
194 }
195 break;
196
197 #endregion
198
199 #region Objects/Prims
200 case PacketType.ObjectLink:
201 // OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString());
202 ObjectLinkPacket link = (ObjectLinkPacket)Pack;
203 uint parentprimid = 0;
204 List<uint> childrenprims = new List<uint>();
205 if (link.ObjectData.Length > 1)
206 {
207 parentprimid = link.ObjectData[0].ObjectLocalID;
208
209 for (int i = 1; i < link.ObjectData.Length; i++)
210 {
211 childrenprims.Add(link.ObjectData[i].ObjectLocalID);
212 }
213 }
214 if (OnLinkObjects != null)
215 {
216 OnLinkObjects(parentprimid, childrenprims);
217 }
218 break;
219 case PacketType.ObjectAdd:
220 if (OnAddPrim != null)
221 {
222 OnAddPrim(Pack, this);
223 }
224 break;
225 case PacketType.ObjectShape:
226 ObjectShapePacket shape = (ObjectShapePacket)Pack;
227 for (int i = 0; i < shape.ObjectData.Length; i++)
228 {
229 if (OnUpdatePrimShape != null)
230 {
231 OnUpdatePrimShape(shape.ObjectData[i].ObjectLocalID, shape.ObjectData[i]);
232 }
233 }
234 break;
235 case PacketType.ObjectDuplicate:
236 ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack;
237 for (int i = 0; i < dupe.ObjectData.Length; i++)
238 {
239 if (OnObjectDuplicate != null)
240 {
241 OnObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, dupe.SharedData.DuplicateFlags);
242 }
243 }
244
245 break;
246
247 case PacketType.ObjectSelect:
248 ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
249 for (int i = 0; i < incomingselect.ObjectData.Length; i++)
250 {
251 if (OnObjectSelect != null)
252 {
253 OnObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this);
254 }
255 }
256 break;
257 case PacketType.ObjectFlagUpdate:
258 ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
259 if (OnUpdatePrimFlags != null)
260 {
261 OnUpdatePrimFlags(flags.AgentData.ObjectLocalID, Pack, this);
262 }
263 break;
264 case PacketType.ObjectImage:
265 ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
266 for (int i = 0; i < imagePack.ObjectData.Length; i++)
267 {
268 if (OnUpdatePrimTexture != null)
269 {
270 OnUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID, imagePack.ObjectData[i].TextureEntry, this);
271 }
272 }
273 break;
274 case PacketType.ObjectGrab:
275 ObjectGrabPacket grap = (ObjectGrabPacket)Pack;
276 if (OnGrapObject != null)
277 {
278 OnGrapObject(grap.ObjectData.LocalID, grap.ObjectData.GrabOffset, this);
279 }
280 break;
281 case PacketType.ObjectGrabUpdate:
282 ObjectGrabUpdatePacket grapUpdate = (ObjectGrabUpdatePacket)Pack;
283 if (OnGrapUpdate != null)
284 {
285 OnGrapUpdate(grapUpdate.ObjectData.ObjectID, grapUpdate.ObjectData.GrabOffsetInitial, grapUpdate.ObjectData.GrabPosition, this);
286 }
287 break;
288 case PacketType.ObjectDeGrab:
289 ObjectDeGrabPacket deGrap = (ObjectDeGrabPacket)Pack;
290 if (OnDeGrapObject != null)
291 {
292 OnDeGrapObject(deGrap.ObjectData.LocalID, this);
293 }
294 break;
295 case PacketType.ObjectDescription:
296 ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack;
297 for (int i = 0; i < objDes.ObjectData.Length; i++)
298 {
299 if (OnObjectDescription != null)
300 {
301 OnObjectDescription(objDes.ObjectData[i].LocalID, enc.GetString(objDes.ObjectData[i].Description));
302 }
303 }
304 break;
305 case PacketType.ObjectName:
306 ObjectNamePacket objName = (ObjectNamePacket)Pack;
307 for (int i = 0; i < objName.ObjectData.Length; i++)
308 {
309 if (OnObjectName != null)
310 {
311 OnObjectName(objName.ObjectData[i].LocalID, enc.GetString(objName.ObjectData[i].Name));
312 }
313 }
314 break;
315 case PacketType.ObjectPermissions:
316 //Console.WriteLine("permissions set " + Pack.ToString());
317 break;
318 #endregion
319
320 #region Inventory/Asset/Other related packets
321 case PacketType.RequestImage:
322 RequestImagePacket imageRequest = (RequestImagePacket)Pack;
323 for (int i = 0; i < imageRequest.RequestImage.Length; i++)
324 {
325 m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image);
326 }
327 break;
328 case PacketType.TransferRequest:
329 //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request");
330 TransferRequestPacket transfer = (TransferRequestPacket)Pack;
331 m_assetCache.AddAssetRequest(this, transfer);
332 break;
333 case PacketType.AssetUploadRequest:
334 AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
335 this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID));
336 break;
337 case PacketType.RequestXfer:
338 //Console.WriteLine(Pack.ToString());
339 break;
340 case PacketType.SendXferPacket:
341 this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack);
342 break;
343 case PacketType.CreateInventoryFolder:
344 CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
345 m_inventoryCache.CreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID);
346 //Console.WriteLine(Pack.ToString());
347 break;
348 case PacketType.CreateInventoryItem:
349 //Console.WriteLine(Pack.ToString());
350 CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
351 if (createItem.InventoryBlock.TransactionID != LLUUID.Zero)
352 {
353 this.UploadAssets.CreateInventoryItem(createItem);
354 }
355 else
356 {
357 // Console.Write(Pack.ToString());
358 this.CreateInventoryItem(createItem);
359 }
360 break;
361 case PacketType.FetchInventory:
362 //Console.WriteLine("fetch item packet");
363 FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack;
364 m_inventoryCache.FetchInventory(this, FetchInventory);
365 break;
366 case PacketType.FetchInventoryDescendents:
367 FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
368 m_inventoryCache.FetchInventoryDescendents(this, Fetch);
369 break;
370 case PacketType.UpdateInventoryItem:
371 UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack;
372 //Console.WriteLine(Pack.ToString());
373 for (int i = 0; i < update.InventoryData.Length; i++)
374 {
375 if (update.InventoryData[i].TransactionID != LLUUID.Zero)
376 {
377 AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID));
378 if (asset != null)
379 {
380 // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache");
381 m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
382 }
383 else
384 {
385 asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID);
386 if (asset != null)
387 {
388 //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache");
389 m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
390 }
391 else
392 {
393 //Console.WriteLine("trying to update inventory item, but asset is null");
394 }
395 }
396 }
397 else
398 {
399 m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ;
400 }
401 }
402 break;
403 case PacketType.RequestTaskInventory:
404 // Console.WriteLine(Pack.ToString());
405 RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
406 ReplyTaskInventoryPacket replytask = new ReplyTaskInventoryPacket();
407 //bool foundent = false;
408 /* foreach (Entity ent in m_world.Entities.Values)
409 {
410 if (ent.localid == requesttask.InventoryData.LocalID)
411 {
412 replytask.InventoryData.TaskID = ent.uuid;
413 replytask.InventoryData.Serial = 0;
414 replytask.InventoryData.Filename = new byte[0];
415 foundent = true;
416 }
417 }
418 if (foundent)
419 {
420 this.OutPacket(replytask);
421 }*/
422 break;
423 case PacketType.UpdateTaskInventory:
424 // Console.WriteLine(Pack.ToString());
425 UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
426 AgentInventory myinventory = this.m_inventoryCache.GetAgentsInventory(this.AgentID);
427 /*if (myinventory != null)
428 {
429 if (updatetask.UpdateData.Key == 0)
430 {
431 if (myinventory.InventoryItems[updatetask.InventoryData.ItemID] != null)
432 {
433 if (myinventory.InventoryItems[updatetask.InventoryData.ItemID].Type == 7)
434 {
435 LLUUID noteaid = myinventory.InventoryItems[updatetask.InventoryData.ItemID].AssetID;
436 AssetBase assBase = this.m_assetCache.GetAsset(noteaid);
437 if (assBase != null)
438 {
439 foreach (Entity ent in m_world.Entities.Values)
440 {
441 if (ent.localid == updatetask.UpdateData.LocalID)
442 {
443 if (ent is OpenSim.world.Primitive)
444 {
445 this.m_world.AddScript(ent, Util.FieldToString(assBase.Data));
446 }
447 }
448 }
449 }
450 }
451 }
452 }
453 }*/
454 break;
455 case PacketType.MapLayerRequest:
456 this.RequestMapLayer();
457 break;
458 case PacketType.MapBlockRequest:
459 MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack;
460 if (OnRequestMapBlocks != null)
461 {
462 OnRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY);
463 }
464 break;
465 case PacketType.TeleportLandmarkRequest:
466 TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
467
468 TeleportStartPacket tpStart = new TeleportStartPacket();
469 tpStart.Info.TeleportFlags = 8; // tp via lm
470 this.OutPacket(tpStart);
471
472 TeleportProgressPacket tpProgress = new TeleportProgressPacket();
473 tpProgress.Info.Message = (new ASCIIEncoding()).GetBytes("sending_landmark");
474 tpProgress.Info.TeleportFlags = 8;
475 tpProgress.AgentData.AgentID = tpReq.Info.AgentID;
476 this.OutPacket(tpProgress);
477
478 // Fetch landmark
479 LLUUID lmid = tpReq.Info.LandmarkID;
480 AssetBase lma = this.m_assetCache.GetAsset(lmid);
481 if (lma != null)
482 {
483 AssetLandmark lm = new AssetLandmark(lma);
484
485 if (lm.RegionID == m_world.RegionInfo.SimUUID)
486 {
487 TeleportLocalPacket tpLocal = new TeleportLocalPacket();
488
489 tpLocal.Info.AgentID = tpReq.Info.AgentID;
490 tpLocal.Info.TeleportFlags = 8; // Teleport via landmark
491 tpLocal.Info.LocationID = 2;
492 tpLocal.Info.Position = lm.Position;
493 OutPacket(tpLocal);
494 }
495 else
496 {
497 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
498 tpCancel.Info.AgentID = tpReq.Info.AgentID;
499 tpCancel.Info.SessionID = tpReq.Info.SessionID;
500 OutPacket(tpCancel);
501 }
502 }
503 else
504 {
505 Console.WriteLine("Cancelling Teleport - fetch asset not yet implemented");
506
507 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
508 tpCancel.Info.AgentID = tpReq.Info.AgentID;
509 tpCancel.Info.SessionID = tpReq.Info.SessionID;
510 OutPacket(tpCancel);
511 }
512 break;
513 case PacketType.TeleportLocationRequest:
514 TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
515 // Console.WriteLine(tpLocReq.ToString());
516
517 if (OnTeleportLocationRequest != null)
518 {
519 OnTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, tpLocReq.Info.LookAt, 16);
520 }
521 else
522 {
523 //no event handler so cancel request
524 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
525 tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
526 tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
527 OutPacket(tpCancel);
528 }
529 break;
530 #endregion
531
532 case PacketType.MoneyBalanceRequest:
533 this.SendMoneyBalance(LLUUID.Zero, true, new byte[0], 1000);
534 break;
535 case PacketType.UUIDNameRequest:
536 UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack;
537 foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock)
538 {
539 OnNameFromUUIDRequest(UUIDBlock.ID, this);
540 }
541 break;
542 #region Parcel related packets
543 case PacketType.ParcelPropertiesRequest:
544 ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack;
545 if (OnParcelPropertiesRequest != null)
546 {
547 OnParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West), (int)Math.Round(propertiesRequest.ParcelData.South), (int)Math.Round(propertiesRequest.ParcelData.East), (int)Math.Round(propertiesRequest.ParcelData.North), propertiesRequest.ParcelData.SequenceID, propertiesRequest.ParcelData.SnapSelection, this);
548 }
549 break;
550 case PacketType.ParcelDivide:
551 ParcelDividePacket parcelDivide = (ParcelDividePacket)Pack;
552 if (OnParcelDivideRequest != null)
553 {
554 OnParcelDivideRequest((int)Math.Round(parcelDivide.ParcelData.West), (int)Math.Round(parcelDivide.ParcelData.South), (int)Math.Round(parcelDivide.ParcelData.East), (int)Math.Round(parcelDivide.ParcelData.North), this);
555 }
556 break;
557 case PacketType.ParcelJoin:
558 ParcelJoinPacket parcelJoin = (ParcelJoinPacket)Pack;
559 if (OnParcelJoinRequest != null)
560 {
561 OnParcelJoinRequest((int)Math.Round(parcelJoin.ParcelData.West), (int)Math.Round(parcelJoin.ParcelData.South), (int)Math.Round(parcelJoin.ParcelData.East), (int)Math.Round(parcelJoin.ParcelData.North), this);
562 }
563 break;
564 case PacketType.ParcelPropertiesUpdate:
565 ParcelPropertiesUpdatePacket updatePacket = (ParcelPropertiesUpdatePacket)Pack;
566 if (OnParcelPropertiesUpdateRequest != null)
567 {
568 OnParcelPropertiesUpdateRequest(updatePacket, this);
569 }
570 break;
571 #endregion
572
573 #region Estate Packets
574 case PacketType.EstateOwnerMessage:
575 EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack;
576 if (OnEstateOwnerMessage != null)
577 {
578 OnEstateOwnerMessage(messagePacket, this);
579 }
580 break;
581 #endregion
582
583 #region unimplemented handlers
584 case PacketType.AgentIsNowWearing:
585 // AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack;
586 //Console.WriteLine(Pack.ToString());
587 break;
588 case PacketType.ObjectScale:
589 //OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString());
590 break;
591 #endregion
592 }
593 }
594 }
595 }
596}
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
new file mode 100644
index 0000000..0fe3884
--- /dev/null
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -0,0 +1,293 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
32using System.Threading;
33using System.Timers;
34using libsecondlife;
35using libsecondlife.Packets;
36using OpenSim.Assets;
37using OpenSim.Framework;
38using OpenSim.Framework.Console;
39using OpenSim.Framework.Interfaces;
40using OpenSim.Framework.Inventory;
41using OpenSim.Framework.Types;
42using OpenSim.Framework.Utilities;
43using OpenSim.Region.Caches;
44using Timer=System.Timers.Timer;
45
46namespace OpenSim.Region.ClientStack
47{
48 public delegate bool PacketMethod(ClientView simClient, Packet packet);
49
50 /// <summary>
51 /// Handles new client connections
52 /// Constructor takes a single Packet and authenticates everything
53 /// </summary>
54 public partial class ClientView : ClientViewBase, IClientAPI
55 {
56 public static TerrainManager TerrainManager;
57
58 protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
59 protected Dictionary<PacketType, PacketMethod> m_packetHandlers = new Dictionary<PacketType, PacketMethod>(); //local handlers for this instance
60
61 public LLUUID AgentID;
62 public LLUUID SessionID;
63 public LLUUID SecureSessionID = LLUUID.Zero;
64 public string firstName;
65 public string lastName;
66 public bool m_child = false;
67 private UseCircuitCodePacket cirpack;
68 public Thread ClientThread;
69 public LLVector3 startpos;
70
71 private AgentAssetUpload UploadAssets;
72 private LLUUID newAssetFolder = LLUUID.Zero;
73 private bool debug = false;
74 protected IWorld m_world;
75 private Dictionary<uint, ClientView> m_clientThreads;
76 private AssetCache m_assetCache;
77 private InventoryCache m_inventoryCache;
78 private int cachedtextureserial = 0;
79 protected AuthenticateSessionsBase m_authenticateSessionsHandler;
80 private Encoding enc = Encoding.ASCII;
81 // Dead client detection vars
82 private Timer clientPingTimer;
83 private int packetsReceived = 0;
84 private int probesWithNoIngressPackets = 0;
85 private int lastPacketsReceived = 0;
86
87 public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions )
88 {
89 m_world = world;
90 m_clientThreads = clientThreads;
91 m_assetCache = assetCache;
92
93 m_networkServer = packServer;
94 m_inventoryCache = inventoryCache;
95 m_authenticateSessionsHandler = authenSessions;
96
97 MainLog.Instance.Verbose( "OpenSimClient.cs - Started up new client thread to handle incoming request");
98 cirpack = initialcirpack;
99 userEP = remoteEP;
100
101 this.startpos = m_authenticateSessionsHandler.GetPosition(initialcirpack.CircuitCode.Code);
102
103 PacketQueue = new BlockingQueue<QueItem>();
104
105 this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache);
106 AckTimer = new Timer(500);
107 AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed);
108 AckTimer.Start();
109
110 this.RegisterLocalPacketHandlers();
111
112 ClientThread = new Thread(new ThreadStart(AuthUser));
113 ClientThread.IsBackground = true;
114 ClientThread.Start();
115 }
116
117 # region Client Methods
118
119 public void KillClient()
120 {
121 clientPingTimer.Stop();
122 this.m_inventoryCache.ClientLeaving(this.AgentID, null);
123 m_world.RemoveClient(this.AgentId);
124
125 m_clientThreads.Remove(this.CircuitCode);
126 m_networkServer.RemoveClientCircuit(this.CircuitCode);
127 this.ClientThread.Abort();
128 }
129 #endregion
130
131 # region Packet Handling
132 public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
133 {
134 bool result = false;
135 lock (PacketHandlers)
136 {
137 if (!PacketHandlers.ContainsKey(packetType))
138 {
139 PacketHandlers.Add(packetType, handler);
140 result = true;
141 }
142 }
143 return result;
144 }
145
146 public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
147 {
148 bool result = false;
149 lock (m_packetHandlers)
150 {
151 if (!m_packetHandlers.ContainsKey(packetType))
152 {
153 m_packetHandlers.Add(packetType, handler);
154 result = true;
155 }
156 }
157 return result;
158 }
159
160 protected virtual bool ProcessPacketMethod(Packet packet)
161 {
162 bool result = false;
163 bool found = false;
164 PacketMethod method;
165 if (m_packetHandlers.TryGetValue(packet.Type, out method))
166 {
167 //there is a local handler for this packet type
168 result = method(this, packet);
169 }
170 else
171 {
172 //there is not a local handler so see if there is a Global handler
173 lock (PacketHandlers)
174 {
175 found = PacketHandlers.TryGetValue(packet.Type, out method);
176 }
177 if (found)
178 {
179 result = method(this, packet);
180 }
181 }
182 return result;
183 }
184
185 protected virtual void ClientLoop()
186 {
187 MainLog.Instance.Verbose( "OpenSimClient.cs:ClientLoop() - Entered loop");
188 while (true)
189 {
190 QueItem nextPacket = PacketQueue.Dequeue();
191 if (nextPacket.Incoming)
192 {
193 //is a incoming packet
194 if (nextPacket.Packet.Type != PacketType.AgentUpdate) {
195 packetsReceived++;
196 }
197 ProcessInPacket(nextPacket.Packet);
198 }
199 else
200 {
201 //is a out going packet
202 ProcessOutPacket(nextPacket.Packet);
203 }
204 }
205 }
206 # endregion
207
208 protected void CheckClientConnectivity(object sender, ElapsedEventArgs e)
209 {
210 if (packetsReceived == lastPacketsReceived) {
211 probesWithNoIngressPackets++;
212 if (probesWithNoIngressPackets > 30) {
213 this.KillClient();
214 } else {
215 // this will normally trigger at least one packet (ping response)
216 SendStartPingCheck(0);
217 }
218 } else {
219 // Something received in the meantime - we can reset the counters
220 probesWithNoIngressPackets = 0;
221 lastPacketsReceived = packetsReceived;
222 }
223 }
224
225 # region Setup
226
227 protected virtual void InitNewClient()
228 {
229 clientPingTimer = new Timer(1000);
230 clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity);
231 clientPingTimer.Enabled = true;
232
233 MainLog.Instance.Verbose( "OpenSimClient.cs:InitNewClient() - Adding viewer agent to world");
234 this.m_world.AddNewClient(this, false);
235 }
236
237 protected virtual void AuthUser()
238 {
239 // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code);
240 AuthenticateResponse sessionInfo = this.m_authenticateSessionsHandler.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code);
241 if (!sessionInfo.Authorised)
242 {
243 //session/circuit not authorised
244 MainLog.Instance.Notice("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString());
245 ClientThread.Abort();
246 }
247 else
248 {
249 MainLog.Instance.Notice("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString());
250 //session is authorised
251 this.AgentID = cirpack.CircuitCode.ID;
252 this.SessionID = cirpack.CircuitCode.SessionID;
253 this.CircuitCode = cirpack.CircuitCode.Code;
254 this.firstName = sessionInfo.LoginInfo.First;
255 this.lastName = sessionInfo.LoginInfo.Last;
256
257 if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero)
258 {
259 this.SecureSessionID = sessionInfo.LoginInfo.SecureSession;
260 }
261 InitNewClient();
262
263 ClientLoop();
264 }
265 }
266 # endregion
267
268
269 protected override void KillThread()
270 {
271 this.ClientThread.Abort();
272 }
273
274 #region Inventory Creation
275 private void SetupInventory(AuthenticateResponse sessionInfo)
276 {
277
278 }
279 private AgentInventory CreateInventory(LLUUID baseFolder)
280 {
281 AgentInventory inventory = null;
282
283 return inventory;
284 }
285
286 private void CreateInventoryItem(CreateInventoryItemPacket packet)
287 {
288
289 }
290 #endregion
291
292 }
293}
diff --git a/OpenSim/Region/ClientStack/ClientViewBase.cs b/OpenSim/Region/ClientStack/ClientViewBase.cs
new file mode 100644
index 0000000..048f4df
--- /dev/null
+++ b/OpenSim/Region/ClientStack/ClientViewBase.cs
@@ -0,0 +1,326 @@
1
2/*
3* Copyright (c) Contributors, http://www.openmetaverse.org/
4* See CONTRIBUTORS.TXT for a full list of copyright holders.
5*
6* Redistribution and use in source and binary forms, with or without
7* modification, are permitted provided that the following conditions are met:
8* * Redistributions of source code must retain the above copyright
9* notice, this list of conditions and the following disclaimer.
10* * Redistributions in binary form must reproduce the above copyright
11* notice, this list of conditions and the following disclaimer in the
12* documentation and/or other materials provided with the distribution.
13* * Neither the name of the OpenSim Project nor the
14* names of its contributors may be used to endorse or promote products
15* derived from this software without specific prior written permission.
16*
17* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
18* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
21* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*
28*/
29using System;
30using System.Collections.Generic;
31using System.Net;
32using System.Net.Sockets;
33using System.Timers;
34using libsecondlife;
35using libsecondlife.Packets;
36using OpenSim.Framework.Console;
37using OpenSim.Framework.Utilities;
38
39namespace OpenSim.Region.ClientStack
40{
41 public class ClientViewBase
42 {
43 protected BlockingQueue<QueItem> PacketQueue;
44 protected Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>();
45 protected Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>();
46
47 protected Timer AckTimer;
48 protected uint Sequence = 0;
49 protected object SequenceLock = new object();
50 protected const int MAX_APPENDED_ACKS = 10;
51 protected const int RESEND_TIMEOUT = 4000;
52 protected const int MAX_SEQUENCE = 0xFFFFFF;
53
54 public uint CircuitCode;
55 public EndPoint userEP;
56
57 protected PacketServer m_networkServer;
58
59 public ClientViewBase()
60 {
61
62 }
63
64 protected virtual void ProcessInPacket(Packet Pack)
65 {
66
67 }
68
69 protected virtual void ProcessOutPacket(Packet Pack)
70 {
71 // Keep track of when this packet was sent out
72 Pack.TickCount = Environment.TickCount;
73
74 Console.WriteLine(CircuitCode + ":OUT: " + Pack.Type.ToString());
75
76 if (!Pack.Header.Resent)
77 {
78 // Set the sequence number
79 lock (SequenceLock)
80 {
81 if (Sequence >= MAX_SEQUENCE)
82 Sequence = 1;
83 else
84 Sequence++;
85 Pack.Header.Sequence = Sequence;
86 }
87
88 if (Pack.Header.Reliable) //DIRTY HACK
89 {
90 lock (NeedAck)
91 {
92 if (!NeedAck.ContainsKey(Pack.Header.Sequence))
93 {
94 try
95 {
96 NeedAck.Add(Pack.Header.Sequence, Pack);
97 }
98 catch (Exception e) // HACKY
99 {
100 e.ToString();
101 // Ignore
102 // Seems to throw a exception here occasionally
103 // of 'duplicate key' despite being locked.
104 // !?!?!?
105 }
106 }
107 else
108 {
109 // Client.Log("Attempted to add a duplicate sequence number (" +
110 // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " +
111 // packet.Type.ToString(), Helpers.LogLevel.Warning);
112 }
113 }
114
115 // Don't append ACKs to resent packets, in case that's what was causing the
116 // delivery to fail
117 if (!Pack.Header.Resent)
118 {
119 // Append any ACKs that need to be sent out to this packet
120 lock (PendingAcks)
121 {
122 if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS &&
123 Pack.Type != PacketType.PacketAck &&
124 Pack.Type != PacketType.LogoutRequest)
125 {
126 Pack.Header.AckList = new uint[PendingAcks.Count];
127 int i = 0;
128
129 foreach (uint ack in PendingAcks.Values)
130 {
131 Pack.Header.AckList[i] = ack;
132 i++;
133 }
134
135 PendingAcks.Clear();
136 Pack.Header.AppendedAcks = true;
137 }
138 }
139 }
140 }
141 }
142
143 byte[] ZeroOutBuffer = new byte[4096];
144 byte[] sendbuffer;
145 sendbuffer = Pack.ToBytes();
146
147 try
148 {
149 if (Pack.Header.Zerocoded)
150 {
151 int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
152 m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, CircuitCode);//userEP);
153 }
154 else
155 {
156 m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, CircuitCode); //userEP);
157 }
158 }
159 catch (Exception)
160 {
161 MainLog.Instance.Warn("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread");
162 this.KillThread();
163 }
164
165 }
166
167 public virtual void InPacket(Packet NewPack)
168 {
169 // Handle appended ACKs
170 if (NewPack.Header.AppendedAcks)
171 {
172 lock (NeedAck)
173 {
174 foreach (uint ack in NewPack.Header.AckList)
175 {
176 NeedAck.Remove(ack);
177 }
178 }
179 }
180
181 // Handle PacketAck packets
182 if (NewPack.Type == PacketType.PacketAck)
183 {
184 PacketAckPacket ackPacket = (PacketAckPacket)NewPack;
185
186 lock (NeedAck)
187 {
188 foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets)
189 {
190 NeedAck.Remove(block.ID);
191 }
192 }
193 }
194 else if ((NewPack.Type == PacketType.StartPingCheck))
195 {
196 //reply to pingcheck
197 StartPingCheckPacket startPing = (StartPingCheckPacket)NewPack;
198 CompletePingCheckPacket endPing = new CompletePingCheckPacket();
199 endPing.PingID.PingID = startPing.PingID.PingID;
200 OutPacket(endPing);
201 }
202 else
203 {
204 QueItem item = new QueItem();
205 item.Packet = NewPack;
206 item.Incoming = true;
207 this.PacketQueue.Enqueue(item);
208 }
209
210 }
211
212 public virtual void OutPacket(Packet NewPack)
213 {
214 QueItem item = new QueItem();
215 item.Packet = NewPack;
216 item.Incoming = false;
217 this.PacketQueue.Enqueue(item);
218 }
219
220 # region Low Level Packet Methods
221
222 protected void ack_pack(Packet Pack)
223 {
224 if (Pack.Header.Reliable)
225 {
226 PacketAckPacket ack_it = new PacketAckPacket();
227 ack_it.Packets = new PacketAckPacket.PacketsBlock[1];
228 ack_it.Packets[0] = new PacketAckPacket.PacketsBlock();
229 ack_it.Packets[0].ID = Pack.Header.Sequence;
230 ack_it.Header.Reliable = false;
231
232 OutPacket(ack_it);
233
234 }
235 /*
236 if (Pack.Header.Reliable)
237 {
238 lock (PendingAcks)
239 {
240 uint sequence = (uint)Pack.Header.Sequence;
241 if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; }
242 }
243 }*/
244 }
245
246 protected void ResendUnacked()
247 {
248 int now = Environment.TickCount;
249
250 lock (NeedAck)
251 {
252 foreach (Packet packet in NeedAck.Values)
253 {
254 if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent))
255 {
256 MainLog.Instance.Verbose( "Resending " + packet.Type.ToString() + " packet, " +
257 (now - packet.TickCount) + "ms have passed");
258
259 packet.Header.Resent = true;
260 OutPacket(packet);
261 }
262 }
263 }
264 }
265
266 protected void SendAcks()
267 {
268 lock (PendingAcks)
269 {
270 if (PendingAcks.Count > 0)
271 {
272 if (PendingAcks.Count > 250)
273 {
274 // FIXME: Handle the odd case where we have too many pending ACKs queued up
275 MainLog.Instance.Verbose( "Too many ACKs queued up!");
276 return;
277 }
278
279 //OpenSim.Framework.Console.MainLog.Instance.WriteLine("Sending PacketAck");
280
281
282 int i = 0;
283 PacketAckPacket acks = new PacketAckPacket();
284 acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count];
285
286 foreach (uint ack in PendingAcks.Values)
287 {
288 acks.Packets[i] = new PacketAckPacket.PacketsBlock();
289 acks.Packets[i].ID = ack;
290 i++;
291 }
292
293 acks.Header.Reliable = false;
294 OutPacket(acks);
295
296 PendingAcks.Clear();
297 }
298 }
299 }
300
301 protected void AckTimer_Elapsed(object sender, ElapsedEventArgs ea)
302 {
303 SendAcks();
304 ResendUnacked();
305 }
306 #endregion
307
308 protected virtual void KillThread()
309 {
310
311 }
312
313 #region Nested Classes
314
315 public class QueItem
316 {
317 public QueItem()
318 {
319 }
320
321 public Packet Packet;
322 public bool Incoming;
323 }
324 #endregion
325 }
326}
diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs
new file mode 100644
index 0000000..a88c682
--- /dev/null
+++ b/OpenSim/Region/ClientStack/PacketServer.cs
@@ -0,0 +1,184 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 System.Net;
30using System.Net.Sockets;
31using libsecondlife.Packets;
32using OpenSim.Assets;
33using OpenSim.Framework;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Region.Caches;
36
37namespace OpenSim.Region.ClientStack
38{
39 public class PacketServer
40 {
41 private ClientStackNetworkHandler _networkHandler;
42 private IWorld _localWorld;
43 public Dictionary<uint, ClientView> ClientThreads = new Dictionary<uint, ClientView>();
44 private ClientManager m_clientManager = new ClientManager();
45 public ClientManager ClientManager
46 {
47 get { return m_clientManager; }
48 }
49
50 public PacketServer(ClientStackNetworkHandler networkHandler)
51 {
52 _networkHandler = networkHandler;
53 _networkHandler.RegisterPacketServer(this);
54 }
55
56 public IWorld LocalWorld
57 {
58 set
59 {
60 this._localWorld = value;
61 }
62 }
63
64 /// <summary>
65 ///
66 /// </summary>
67 /// <param name="circuitCode"></param>
68 /// <param name="packet"></param>
69 public virtual void ClientInPacket(uint circuitCode, Packet packet)
70 {
71 if (this.ClientThreads.ContainsKey(circuitCode))
72 {
73 ClientThreads[circuitCode].InPacket(packet);
74 }
75 }
76
77 /// <summary>
78 ///
79 /// </summary>
80 /// <param name="circuitCode"></param>
81 /// <returns></returns>
82 public virtual bool AddNewCircuitCodeClient(uint circuitCode)
83 {
84 return false;
85 }
86
87 /// <summary>
88 ///
89 /// </summary>
90 /// <param name="packet"></param>
91 public virtual void SendPacketToAllClients(Packet packet)
92 {
93
94 }
95
96 /// <summary>
97 ///
98 /// </summary>
99 /// <param name="packet"></param>
100 /// <param name="simClient"></param>
101 public virtual void SendPacketToAllExcept(Packet packet, ClientView simClient)
102 {
103
104 }
105
106 /// <summary>
107 ///
108 /// </summary>
109 /// <param name="packetType"></param>
110 /// <param name="handler"></param>
111 public virtual void AddClientPacketHandler(PacketType packetType, PacketMethod handler)
112 {
113
114 }
115
116 /// <summary>
117 ///
118 /// </summary>
119 public virtual void RegisterClientPacketHandlers()
120 {
121
122 }
123
124 /// <summary>
125 ///
126 /// </summary>
127 /// <param name="remoteEP"></param>
128 /// <param name="initialcirpack"></param>
129 /// <param name="clientThreads"></param>
130 /// <param name="world"></param>
131 /// <param name="assetCache"></param>
132 /// <param name="packServer"></param>
133 /// <param name="inventoryCache"></param>
134 /// <param name="authenSessions"></param>
135 /// <returns></returns>
136 protected virtual ClientView CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions)
137 {
138 return new ClientView(remoteEP, initialcirpack, clientThreads, world, assetCache, packServer, inventoryCache, authenSessions );
139 }
140
141 /// <summary>
142 ///
143 /// </summary>
144 /// <param name="epSender"></param>
145 /// <param name="useCircuit"></param>
146 /// <param name="assetCache"></param>
147 /// <param name="inventoryCache"></param>
148 /// <param name="authenticateSessionsClass"></param>
149 /// <returns></returns>
150 public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, InventoryCache inventoryCache, AuthenticateSessionsBase authenticateSessionsClass)
151 {
152 ClientView newuser =
153 CreateNewClient(epSender, useCircuit, ClientThreads, _localWorld, assetCache, this, inventoryCache,
154 authenticateSessionsClass);
155
156 this.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser);
157 this.m_clientManager.Add(useCircuit.CircuitCode.Code, (IClientAPI)newuser);
158
159 return true;
160 }
161
162 /// <summary>
163 ///
164 /// </summary>
165 /// <param name="buffer"></param>
166 /// <param name="size"></param>
167 /// <param name="flags"></param>
168 /// <param name="circuitcode"></param>
169 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
170 {
171 this._networkHandler.SendPacketTo(buffer, size, flags, circuitcode);
172 }
173
174 /// <summary>
175 ///
176 /// </summary>
177 /// <param name="circuitcode"></param>
178 public virtual void RemoveClientCircuit(uint circuitcode)
179 {
180 this._networkHandler.RemoveClientCircuit(circuitcode);
181 this.m_clientManager.Remove(circuitcode);
182 }
183 }
184}
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
new file mode 100644
index 0000000..1e99c71
--- /dev/null
+++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
@@ -0,0 +1,117 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 OpenSim.Assets;
32using OpenSim.Framework;
33using OpenSim.Framework.Console;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Servers;
36using OpenSim.Framework.Types;
37using OpenSim.Physics.Manager;
38using OpenSim.Region.Caches;
39
40namespace OpenSim.Region.ClientStack
41{
42 public class RegionApplicationBase
43 {
44 protected IGenericConfig localConfig;
45 protected PhysicsManager physManager;
46 protected AssetCache AssetCache;
47 protected InventoryCache InventoryCache;
48 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
49 protected DateTime startuptime;
50 protected NetworkServersInfo serversData;
51
52 public string m_physicsEngine;
53 public bool m_sandbox = false;
54 public bool m_loginserver;
55 public bool user_accounts = false;
56 public bool gridLocalAsset = false;
57 protected bool configFileSetup = false;
58 public string m_config;
59
60 protected List<UDPServer> m_udpServer = new List<UDPServer>();
61 protected List<RegionInfo> regionData = new List<RegionInfo>();
62 protected List<IWorld> m_localWorld = new List<IWorld>();
63 protected BaseHttpServer httpServer;
64 protected List<AuthenticateSessionsBase> AuthenticateSessionsHandler = new List<AuthenticateSessionsBase>();
65
66 protected LogBase m_log;
67
68 public RegionApplicationBase()
69 {
70
71 }
72
73 public RegionApplicationBase(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile)
74 {
75 this.configFileSetup = useConfigFile;
76 m_sandbox = sandBoxMode;
77 m_loginserver = startLoginServer;
78 m_physicsEngine = physicsEngine;
79 m_config = configFile;
80 }
81
82 /*protected World m_localWorld;
83 public World LocalWorld
84 {
85 get { return m_localWorld; }
86 }*/
87
88 /// <summary>
89 /// Performs initialisation of the world, such as loading configuration from disk.
90 /// </summary>
91 public virtual void StartUp()
92 {
93 }
94
95 protected virtual void SetupLocalGridServers()
96 {
97 }
98
99 protected virtual void SetupRemoteGridServers()
100 {
101
102 }
103
104 protected virtual void SetupWorld()
105 {
106 }
107
108 protected virtual void SetupHttpListener()
109 {
110 }
111
112 protected virtual void ConnectToRemoteGridServer()
113 {
114
115 }
116 }
117}
diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs
new file mode 100644
index 0000000..6eea524
--- /dev/null
+++ b/OpenSim/Region/ClientStack/UDPServer.cs
@@ -0,0 +1,196 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Net.Sockets;
32using libsecondlife.Packets;
33using OpenSim.Assets;
34using OpenSim.Framework;
35using OpenSim.Framework.Console;
36using OpenSim.Framework.Interfaces;
37using OpenSim.Region.Caches;
38
39namespace OpenSim.Region.ClientStack
40{
41
42 public class UDPServer : ClientStackNetworkHandler
43 {
44 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
45 public Socket Server;
46 protected IPEndPoint ServerIncoming;
47 protected byte[] RecvBuffer = new byte[4096];
48 protected byte[] ZeroBuffer = new byte[8192];
49 protected IPEndPoint ipeSender;
50 protected EndPoint epSender;
51 protected AsyncCallback ReceivedData;
52 protected PacketServer _packetServer;
53
54 protected int listenPort;
55 protected IWorld m_localWorld;
56 protected AssetCache m_assetCache;
57 protected InventoryCache m_inventoryCache;
58 protected LogBase m_log;
59 protected AuthenticateSessionsBase m_authenticateSessionsClass;
60
61 public PacketServer PacketServer
62 {
63 get
64 {
65 return _packetServer;
66 }
67 set
68 {
69 _packetServer = value;
70 }
71 }
72
73 public IWorld LocalWorld
74 {
75 set
76 {
77 this.m_localWorld = value;
78 this._packetServer.LocalWorld = this.m_localWorld;
79 }
80 }
81
82 public UDPServer()
83 {
84 }
85
86 public UDPServer(int port, AssetCache assetCache, InventoryCache inventoryCache, LogBase console, AuthenticateSessionsBase authenticateClass)
87 {
88 listenPort = port;
89 this.m_assetCache = assetCache;
90 this.m_inventoryCache = inventoryCache;
91 this.m_log = console;
92 this.m_authenticateSessionsClass = authenticateClass;
93 this.CreatePacketServer();
94
95 }
96
97 protected virtual void CreatePacketServer()
98 {
99 PacketServer packetServer = new PacketServer(this);
100 }
101
102 protected virtual void OnReceivedData(IAsyncResult result)
103 {
104 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
105 epSender = (EndPoint)ipeSender;
106 Packet packet = null;
107 int numBytes = Server.EndReceiveFrom(result, ref epSender);
108 int packetEnd = numBytes - 1;
109
110 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
111
112 // do we already have a circuit for this endpoint
113 if (this.clientCircuits.ContainsKey(epSender))
114 {
115 //if so then send packet to the packetserver
116 this._packetServer.ClientInPacket(this.clientCircuits[epSender], packet);
117 }
118 else if (packet.Type == PacketType.UseCircuitCode)
119 {
120 // new client
121 this.AddNewClient(packet);
122 }
123 else
124 { // invalid client
125 m_log.Warn("UDPServer.cs:OnReceivedData() - WARNING: Got a packet from an invalid client - " + epSender.ToString());
126 }
127
128 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
129 }
130
131 protected virtual void AddNewClient(Packet packet)
132 {
133 UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet;
134 this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code);
135
136 this.PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_inventoryCache, m_authenticateSessionsClass);
137 }
138
139 public void ServerListener()
140 {
141 m_log.Status("UDPServer.cs:ServerListener() - Opening UDP socket on " + listenPort);
142
143 ServerIncoming = new IPEndPoint(IPAddress.Parse("0.0.0.0"), listenPort);
144 Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
145 Server.Bind(ServerIncoming);
146
147 m_log.Verbose("UDPServer.cs:ServerListener() - UDP socket bound, getting ready to listen");
148
149 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
150 epSender = (EndPoint)ipeSender;
151 ReceivedData = new AsyncCallback(this.OnReceivedData);
152 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
153
154 m_log.Verbose("UDPServer.cs:ServerListener() - Listening...");
155
156 }
157
158 public virtual void RegisterPacketServer(PacketServer server)
159 {
160 this._packetServer = server;
161 }
162
163 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender)
164 {
165 // find the endpoint for this circuit
166 EndPoint sendto = null;
167 foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits)
168 {
169 if (p.Value == circuitcode)
170 {
171 sendto = p.Key;
172 break;
173 }
174 }
175 if (sendto != null)
176 {
177 //we found the endpoint so send the packet to it
178 this.Server.SendTo(buffer, size, flags, sendto);
179 }
180 }
181
182 public virtual void RemoveClientCircuit(uint circuitcode)
183 {
184 foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits)
185 {
186 if (p.Value == circuitcode)
187 {
188 this.clientCircuits.Remove(p.Key);
189 break;
190 }
191 }
192 }
193
194
195 }
196} \ No newline at end of file
diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
new file mode 100644
index 0000000..a047843
--- /dev/null
+++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
@@ -0,0 +1,54 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Communications;
29using OpenSim.Framework.Types;
30using OpenSim.Framework.Servers;
31
32namespace OpenSim.Region.Communications.Local
33{
34 public class CommunicationsLocal : CommunicationsManager
35 {
36 public LocalBackEndServices SandBoxServices = new LocalBackEndServices();
37 public LocalUserServices UserServices;
38
39 public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer )
40 : base(serversInfo, httpServer)
41 {
42 UserServices = new LocalUserServices(this, serversInfo);
43 UserServices.AddPlugin("OpenSim.Framework.Data.DB4o.dll");
44 UserServer = UserServices;
45 GridServer = SandBoxServices;
46 InterRegion = SandBoxServices;
47 }
48
49 internal void InformRegionOfLogin(ulong regionHandle, Login login)
50 {
51 this.SandBoxServices.AddNewSession(regionHandle, login);
52 }
53 }
54}
diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
new file mode 100644
index 0000000..d0cd991
--- /dev/null
+++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
@@ -0,0 +1,206 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
30using OpenSim.Framework;
31using OpenSim.Framework.Communications;
32using OpenSim.Framework.Types;
33
34namespace OpenSim.Region.Communications.Local
35{
36
37 public class LocalBackEndServices : IGridServices, IInterRegionCommunications
38 {
39 protected Dictionary<ulong, RegionInfo> regions = new Dictionary<ulong, RegionInfo>();
40 protected Dictionary<ulong, RegionCommsListener> regionHosts = new Dictionary<ulong, RegionCommsListener>();
41
42 public LocalBackEndServices()
43 {
44
45 }
46
47 /// <summary>
48 /// Register a region method with the BackEnd Services.
49 /// </summary>
50 /// <param name="regionInfo"></param>
51 /// <returns></returns>
52 public RegionCommsListener RegisterRegion(RegionInfo regionInfo)
53 {
54 //Console.WriteLine("CommsManager - Region " + regionInfo.RegionHandle + " , " + regionInfo.RegionLocX + " , "+ regionInfo.RegionLocY +" is registering");
55 if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle))
56 {
57 //Console.WriteLine("CommsManager - Adding Region " + regionInfo.RegionHandle );
58 this.regions.Add(regionInfo.RegionHandle, regionInfo);
59 RegionCommsListener regionHost = new RegionCommsListener();
60 this.regionHosts.Add(regionInfo.RegionHandle, regionHost);
61
62 return regionHost;
63 }
64
65 //already in our list of regions so for now lets return null
66 return null;
67 }
68
69 /// <summary>
70 /// </summary>
71 /// <param name="regionInfo"></param>
72 /// <returns></returns>
73 public List<RegionInfo> RequestNeighbours(RegionInfo regionInfo)
74 {
75 // Console.WriteLine("Finding Neighbours to " + regionInfo.RegionHandle);
76 List<RegionInfo> neighbours = new List<RegionInfo>();
77
78 foreach (RegionInfo reg in this.regions.Values)
79 {
80 // Console.WriteLine("CommsManager- RequestNeighbours() checking region " + reg.RegionLocX + " , "+ reg.RegionLocY);
81 if (reg.RegionHandle != regionInfo.RegionHandle)
82 {
83 //Console.WriteLine("CommsManager- RequestNeighbours() - found a different region in list, checking location");
84 if ((reg.RegionLocX > (regionInfo.RegionLocX - 2)) && (reg.RegionLocX < (regionInfo.RegionLocX + 2)))
85 {
86 if ((reg.RegionLocY > (regionInfo.RegionLocY - 2)) && (reg.RegionLocY < (regionInfo.RegionLocY + 2)))
87 {
88 neighbours.Add(reg);
89 }
90 }
91 }
92 }
93 return neighbours;
94 }
95
96 /// <summary>
97 ///
98 /// </summary>
99 /// <param name="regionHandle"></param>
100 /// <returns></returns>
101 public RegionInfo RequestNeighbourInfo(ulong regionHandle)
102 {
103 if (this.regions.ContainsKey(regionHandle))
104 {
105 return this.regions[regionHandle];
106 }
107 return null;
108 }
109
110 /// <summary>
111 ///
112 /// </summary>
113 /// <param name="minX"></param>
114 /// <param name="minY"></param>
115 /// <param name="maxX"></param>
116 /// <param name="maxY"></param>
117 /// <returns></returns>
118 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
119 {
120 List<MapBlockData> mapBlocks = new List<MapBlockData>();
121 foreach(RegionInfo regInfo in this.regions.Values)
122 {
123 if (((regInfo.RegionLocX >= minX) && (regInfo.RegionLocX <= maxX)) && ((regInfo.RegionLocY >= minY) && (regInfo.RegionLocY <= maxY)))
124 {
125 MapBlockData map = new MapBlockData();
126 map.Name = regInfo.RegionName;
127 map.X = (ushort)regInfo.RegionLocX;
128 map.Y = (ushort)regInfo.RegionLocY;
129 map.WaterHeight =(byte) regInfo.estateSettings.waterHeight;
130 map.MapImageId = regInfo.estateSettings.terrainImageID; //new LLUUID("00000000-0000-0000-9999-000000000007");
131 map.Agents = 1;
132 map.RegionFlags = 72458694;
133 map.Access = 13;
134 mapBlocks.Add(map);
135 }
136 }
137 return mapBlocks;
138 }
139
140 /// <summary>
141 /// </summary>
142 /// <param name="regionHandle"></param>
143 /// <param name="agentData"></param>
144 /// <returns></returns>
145 public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) //should change from agentCircuitData
146 {
147 //Console.WriteLine("CommsManager- Trying to Inform a region to expect child agent");
148 if (this.regionHosts.ContainsKey(regionHandle))
149 {
150 // Console.WriteLine("CommsManager- Informing a region to expect child agent");
151 this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agentData);
152 return true;
153 }
154 return false;
155 }
156
157 /// <summary>
158 ///
159 /// </summary>
160 /// <param name="regionHandle"></param>
161 /// <param name="agentID"></param>
162 /// <param name="position"></param>
163 /// <returns></returns>
164 public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position)
165 {
166 if (this.regionHosts.ContainsKey(regionHandle))
167 {
168 // Console.WriteLine("CommsManager- Informing a region to expect avatar crossing");
169 this.regionHosts[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position);
170 return true;
171 }
172 return false;
173 }
174
175 /// <summary>
176 /// Is a Sandbox mode method, used by the local Login server to inform a region of a connection user/session
177 /// </summary>
178 /// <param name="regionHandle"></param>
179 /// <param name="loginData"></param>
180 /// <returns></returns>
181 public bool AddNewSession(ulong regionHandle, Login loginData)
182 {
183 AgentCircuitData agent = new AgentCircuitData();
184 agent.AgentID = loginData.Agent;
185 agent.firstname = loginData.First;
186 agent.lastname = loginData.Last;
187 agent.SessionID = loginData.Session;
188 agent.SecureSessionID = loginData.SecureSession;
189 agent.circuitcode = loginData.CircuitCode;
190 agent.BaseFolder = loginData.BaseFolder;
191 agent.InventoryFolder = loginData.InventoryFolder;
192 agent.startpos = new LLVector3(128, 128, 70);
193 agent.CapsPath = loginData.CapsPath;
194
195 if (this.regionHosts.ContainsKey(regionHandle))
196 {
197 this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agent);
198 return true;
199 }
200
201 // region not found
202 return false;
203 }
204 }
205}
206
diff --git a/OpenSim/Region/Communications/Local/LocalUserServices.cs b/OpenSim/Region/Communications/Local/LocalUserServices.cs
new file mode 100644
index 0000000..592b36c
--- /dev/null
+++ b/OpenSim/Region/Communications/Local/LocalUserServices.cs
@@ -0,0 +1,142 @@
1using System;
2using libsecondlife;
3using OpenSim.Framework.Communications;
4using OpenSim.Framework.Data;
5using OpenSim.Framework.Types;
6using OpenSim.Framework.UserManagement;
7using OpenSim.Framework.Utilities;
8
9namespace OpenSim.Region.Communications.Local
10{
11 public class LocalUserServices : UserManagerBase, IUserServices
12 {
13 private CommunicationsLocal m_Parent;
14
15 private NetworkServersInfo serversInfo;
16 private uint defaultHomeX ;
17 private uint defaultHomeY;
18 public LocalUserServices(CommunicationsLocal parent, NetworkServersInfo serversData)
19 {
20 m_Parent = parent;
21 this.serversInfo = serversData;
22 defaultHomeX = this.serversInfo.DefaultHomeLocX;
23 defaultHomeY = this.serversInfo.DefaultHomeLocY;
24 }
25
26 public UserProfileData GetUserProfile(string firstName, string lastName)
27 {
28 return GetUserProfile(firstName + " " + lastName);
29 }
30
31 public UserProfileData GetUserProfile(string name)
32 {
33 return this.getUserProfile(name);
34 }
35
36 public UserProfileData GetUserProfile(LLUUID avatarID)
37 {
38 return this.getUserProfile(avatarID);
39 }
40
41 /// <summary>
42 ///
43 /// </summary>
44 /// <returns></returns>
45 public override string GetMessage()
46 {
47 return "Welcome to OpenSim";
48 }
49
50 public override UserProfileData GetTheUser(string firstname, string lastname)
51 {
52 UserProfileData profile = getUserProfile(firstname, lastname);
53 if (profile != null)
54 {
55
56 return profile;
57 }
58
59 //no current user account so make one
60 Console.WriteLine("No User account found so creating a new one ");
61 this.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY);
62
63 profile = getUserProfile(firstname, lastname);
64
65 return profile;
66 }
67
68 public override bool AuthenticateUser(UserProfileData profile, string password)
69 {
70 //for now we will accept any password in sandbox mode
71 Console.WriteLine("authorising user");
72 return true;
73 }
74
75 public override void CustomiseResponse(LoginResponse response, UserProfileData theUser)
76 {
77 ulong currentRegion = theUser.currentAgent.currentHandle;
78 RegionInfo reg = m_Parent.GridServer.RequestNeighbourInfo(currentRegion);
79
80 if (reg != null)
81 {
82 response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " +
83 "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
84 "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
85 string capsPath = Util.GetRandomCapsPath();
86 response.SimAddress = reg.ExternalEndPoint.Address.ToString();
87 response.SimPort = (Int32)reg.ExternalEndPoint.Port;
88 response.RegionX = reg.RegionLocX ;
89 response.RegionY = reg.RegionLocY ;
90
91 //following port needs changing as we don't want a http listener for every region (or do we?)
92 response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/";
93 theUser.currentAgent.currentRegion = reg.SimUUID;
94 theUser.currentAgent.currentHandle = reg.RegionHandle;
95
96 Login _login = new Login();
97 //copy data to login object
98 _login.First = response.Firstname;
99 _login.Last = response.Lastname;
100 _login.Agent = response.AgentID;
101 _login.Session = response.SessionID;
102 _login.SecureSession = response.SecureSessionID;
103 _login.CircuitCode = (uint)response.CircuitCode;
104 _login.CapsPath = capsPath;
105
106 m_Parent.InformRegionOfLogin(currentRegion, _login);
107 }
108 else
109 {
110 Console.WriteLine("not found region " + currentRegion);
111 }
112
113 }
114
115 public UserProfileData SetupMasterUser(string firstName, string lastName)
116 {
117 return SetupMasterUser(firstName, lastName, "");
118 }
119
120 public UserProfileData SetupMasterUser(string firstName, string lastName, string password)
121 {
122 UserProfileData profile = getUserProfile(firstName, lastName);
123 if (profile != null)
124 {
125
126 return profile;
127 }
128
129 Console.WriteLine("Unknown Master User. Sandbox Mode: Creating Account");
130 this.AddUserProfile(firstName, lastName, password, defaultHomeX, defaultHomeY);
131
132 profile = getUserProfile(firstName, lastName);
133
134 if (profile == null)
135 {
136 Console.WriteLine("Unknown Master User after creation attempt. No clue what to do here.");
137 }
138
139 return profile;
140 }
141 }
142}
diff --git a/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs b/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..9afb75e
--- /dev/null
+++ b/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Region.Communications.Local")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenSim.Region.Communications.Local")]
11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("fb173926-bd0a-4cd0-bb45-185b2f72ddfb")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs
new file mode 100644
index 0000000..cc05845
--- /dev/null
+++ b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs
@@ -0,0 +1,18 @@
1using OpenSim.Framework.Communications;
2using OpenSim.Framework.Types;
3using OpenSim.Framework.Servers;
4
5namespace OpenSim.Region.Communications.OGS1
6{
7 public class CommunicationsOGS1 : CommunicationsManager
8 {
9
10 public CommunicationsOGS1(NetworkServersInfo serversInfo, BaseHttpServer httpServer ) :base(serversInfo, httpServer)
11 {
12 OGS1GridServices gridInterComms = new OGS1GridServices(serversInfo, httpServer);
13 GridServer = gridInterComms;
14 InterRegion = gridInterComms;
15 UserServer = new OGS1UserServices(this);
16 }
17 }
18}
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
new file mode 100644
index 0000000..66c1739
--- /dev/null
+++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
@@ -0,0 +1,378 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Net;
5using System.Runtime.Remoting;
6using System.Runtime.Remoting.Channels;
7using System.Runtime.Remoting.Channels.Tcp;
8using libsecondlife;
9using Nwc.XmlRpc;
10using OpenSim.Framework;
11using OpenSim.Framework.Communications;
12using OpenSim.Framework.Console;
13using OpenSim.Framework.Servers;
14using OpenSim.Framework.Types;
15
16namespace OpenSim.Region.Communications.OGS1
17{
18 public class OGS1GridServices : IGridServices, IInterRegionCommunications
19 {
20 public Dictionary<ulong, RegionCommsListener> listeners = new Dictionary<ulong, RegionCommsListener>();
21 protected Dictionary<ulong, RegionInfo> regions = new Dictionary<ulong, RegionInfo>();
22
23 public BaseHttpServer httpListener;
24 public NetworkServersInfo serversInfo;
25 public BaseHttpServer httpServer;
26
27 public OGS1GridServices(NetworkServersInfo servers_info, BaseHttpServer httpServe)
28 {
29 serversInfo = servers_info;
30 httpServer = httpServe;
31 httpServer.AddXmlRPCHandler("expect_user", this.ExpectUser);
32 this.StartRemoting();
33 }
34
35 public RegionCommsListener RegisterRegion(RegionInfo regionInfo)
36 {
37 if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle))
38 {
39 this.regions.Add(regionInfo.RegionHandle, regionInfo);
40 }
41
42 Hashtable GridParams = new Hashtable();
43
44
45 // Login / Authentication
46
47 GridParams["authkey"] = serversInfo.GridSendKey;
48 GridParams["UUID"] = regionInfo.SimUUID.ToStringHyphenated();
49 GridParams["sim_ip"] = regionInfo.ExternalHostName;
50 GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString();
51 GridParams["region_locx"] = regionInfo.RegionLocX.ToString();
52 GridParams["region_locy"] = regionInfo.RegionLocY.ToString();
53 GridParams["sim_name"] = regionInfo.RegionName;
54 GridParams["http_port"] = serversInfo.HttpListenerPort.ToString();
55 GridParams["remoting_port"] = serversInfo.RemotingListenerPort.ToString();
56 GridParams["map-image-id"] = regionInfo.estateSettings.terrainImageID.ToStringHyphenated();
57
58 // Package into an XMLRPC Request
59 ArrayList SendParams = new ArrayList();
60 SendParams.Add(GridParams);
61
62 // Send Request
63 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
64 XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000);
65 Hashtable GridRespData = (Hashtable)GridResp.Value;
66
67 Hashtable griddatahash = GridRespData;
68
69 // Process Response
70 if (GridRespData.ContainsKey("error"))
71 {
72 string errorstring = (string)GridRespData["error"];
73 MainLog.Instance.Error("Unable to connect to grid: " + errorstring);
74 return null;
75 }
76
77 /* if (!this.listeners.ContainsKey(regionInfo.RegionHandle))
78 {
79 MainLog.Instance.Verbose("OGS1 - Registering new HTTP listener on port " + regionInfo.InternalEndPoint.Port.ToString());
80 // initialised = true;
81 httpListener = new BaseHttpServer( regionInfo.InternalEndPoint.Port );
82 httpListener.AddXmlRPCHandler("expect_user", this.ExpectUser);
83 httpListener.Start();
84 }*/
85
86 // Initialise the background listeners
87 RegionCommsListener regListener = new RegionCommsListener();
88 if (this.listeners.ContainsKey(regionInfo.RegionHandle))
89 {
90 this.listeners.Add(regionInfo.RegionHandle, regListener);
91 }
92 else
93 {
94 listeners[regionInfo.RegionHandle] = regListener;
95 }
96
97 return regListener;
98 }
99
100 public List<RegionInfo> RequestNeighbours(RegionInfo regionInfo)
101 {
102
103 Hashtable respData = MapBlockQuery((int)regionInfo.RegionLocX - 1, (int)regionInfo.RegionLocY - 1, (int)regionInfo.RegionLocX + 1, (int)regionInfo.RegionLocY + 1);
104
105 List<RegionInfo> neighbours = new List<RegionInfo>();
106
107 foreach (ArrayList a in respData.Values)
108 {
109 foreach (Hashtable n in a)
110 {
111 uint regX = Convert.ToUInt32(n["x"]);
112 uint regY = Convert.ToUInt32(n["y"]);
113 if ((regionInfo.RegionLocX != regX) || (regionInfo.RegionLocY != regY))
114 {
115 string internalIpStr = (string)n["sim_ip"];
116 uint port = Convert.ToUInt32(n["sim_port"]);
117 string externalUri = (string)n["sim_uri"];
118
119 IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int)port);
120 string neighbourExternalUri = externalUri;
121 RegionInfo neighbour = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr);
122
123 //OGS1
124 //neighbour.RegionHandle = (ulong)n["regionhandle"]; is now calculated locally
125
126 neighbour.RegionName = (string)n["name"];
127
128 //OGS1+
129 neighbour.SimUUID = (string)n["uuid"];
130
131 neighbours.Add(neighbour);
132 }
133 }
134 }
135
136 return neighbours;
137 }
138
139 public RegionInfo RequestNeighbourInfo(ulong regionHandle)
140 {
141 if (this.regions.ContainsKey(regionHandle))
142 {
143 return this.regions[regionHandle];
144 }
145 //TODO not a region in this instance so ask remote grid server
146
147 Hashtable requestData = new Hashtable();
148 requestData["region_handle"] = regionHandle.ToString();
149 requestData["authkey"] = this.serversInfo.GridSendKey;
150 ArrayList SendParams = new ArrayList();
151 SendParams.Add(requestData);
152 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
153 XmlRpcResponse GridResp = GridReq.Send(this.serversInfo.GridURL, 3000);
154
155 Hashtable responseData = (Hashtable)GridResp.Value;
156
157 if (responseData.ContainsKey("error"))
158 {
159 Console.WriteLine("error received from grid server" + responseData["error"]);
160 return null;
161 }
162
163 uint regX = Convert.ToUInt32((string)responseData["region_locx"]);
164 uint regY = Convert.ToUInt32((string)responseData["region_locy"]);
165 string internalIpStr = (string)responseData["sim_ip"];
166 uint port = Convert.ToUInt32(responseData["sim_port"]);
167 string externalUri = (string)responseData["sim_uri"];
168
169 IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int)port);
170 string neighbourExternalUri = externalUri;
171 RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr);
172
173 regionInfo.RemotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
174 regionInfo.RemotingAddress = internalIpStr;
175
176 regionInfo.SimUUID = new LLUUID((string)responseData["region_UUID"]);
177 regionInfo.RegionName = (string)responseData["region_name"];
178
179 return regionInfo;
180 }
181
182 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
183 {
184 Hashtable respData = MapBlockQuery(minX, minY, maxX, maxY);
185
186 List<MapBlockData> neighbours = new List<MapBlockData>();
187
188 foreach (ArrayList a in respData.Values)
189 {
190 foreach (Hashtable n in a)
191 {
192 MapBlockData neighbour = new MapBlockData();
193
194 neighbour.X = Convert.ToUInt16(n["x"]);
195 neighbour.Y = Convert.ToUInt16(n["y"]);
196
197 neighbour.Name = (string)n["name"];
198 neighbour.Access = Convert.ToByte(n["access"]);
199 neighbour.RegionFlags = Convert.ToUInt32(n["region-flags"]);
200 neighbour.WaterHeight = Convert.ToByte(n["water-height"]);
201 neighbour.MapImageId = new LLUUID((string)n["map-image-id"]);
202
203 neighbours.Add(neighbour);
204 }
205 }
206
207 return neighbours;
208 }
209
210 /// <summary>
211 /// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates
212 /// </summary>
213 /// <remarks>REDUNDANT - OGS1 is to be phased out in favour of OGS2</remarks>
214 /// <param name="minX">Minimum X value</param>
215 /// <param name="minY">Minimum Y value</param>
216 /// <param name="maxX">Maximum X value</param>
217 /// <param name="maxY">Maximum Y value</param>
218 /// <returns>Hashtable of hashtables containing map data elements</returns>
219 private Hashtable MapBlockQuery(int minX, int minY, int maxX, int maxY)
220 {
221 Hashtable param = new Hashtable();
222 param["xmin"] = minX;
223 param["ymin"] = minY;
224 param["xmax"] = maxX;
225 param["ymax"] = maxY;
226 IList parameters = new ArrayList();
227 parameters.Add(param);
228 XmlRpcRequest req = new XmlRpcRequest("map_block", parameters);
229 XmlRpcResponse resp = req.Send(serversInfo.GridURL, 3000);
230 Hashtable respData = (Hashtable)resp.Value;
231 return respData;
232 }
233
234 // Grid Request Processing
235 public XmlRpcResponse ExpectUser(XmlRpcRequest request)
236 {
237 Console.WriteLine("Expecting User...");
238 Hashtable requestData = (Hashtable)request.Params[0];
239 AgentCircuitData agentData = new AgentCircuitData();
240 agentData.SessionID = new LLUUID((string)requestData["session_id"]);
241 agentData.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]);
242 agentData.firstname = (string)requestData["firstname"];
243 agentData.lastname = (string)requestData["lastname"];
244 agentData.AgentID = new LLUUID((string)requestData["agent_id"]);
245 agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
246 if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
247 {
248 agentData.child = true;
249 }
250 else
251 {
252 agentData.startpos = new LLVector3(Convert.ToUInt32(requestData["startpos_x"]), Convert.ToUInt32(requestData["startpos_y"]), Convert.ToUInt32(requestData["startpos_z"]));
253 agentData.child = false;
254
255 }
256
257 if (listeners.ContainsKey(Convert.ToUInt64((string)requestData["regionhandle"])))
258 {
259 this.listeners[Convert.ToUInt64((string)requestData["regionhandle"])].TriggerExpectUser(Convert.ToUInt64((string)requestData["regionhandle"]), agentData);
260 }
261 else
262 {
263 MainLog.Instance.Error("ExpectUser() - Unknown region " + ((ulong)requestData["regionhandle"]).ToString());
264 }
265
266 MainLog.Instance.Verbose("ExpectUser() - Welcoming new user...");
267
268 return new XmlRpcResponse();
269 }
270
271 #region InterRegion Comms
272 private void StartRemoting()
273 {
274 TcpChannel ch = new TcpChannel(this.serversInfo.RemotingListenerPort);
275 ChannelServices.RegisterChannel(ch, true);
276
277 WellKnownServiceTypeEntry wellType = new WellKnownServiceTypeEntry(typeof(OGS1InterRegionRemoting), "InterRegions", WellKnownObjectMode.Singleton);
278 RemotingConfiguration.RegisterWellKnownServiceType(wellType);
279 InterRegionSingleton.Instance.OnArrival += this.IncomingArrival;
280 InterRegionSingleton.Instance.OnChildAgent += this.IncomingChildAgent;
281 }
282
283 #region Methods called by regions in this instance
284 public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData)
285 {
286 if (this.listeners.ContainsKey(regionHandle))
287 {
288 this.listeners[regionHandle].TriggerExpectUser(regionHandle, agentData);
289 return true;
290 }
291 RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle);
292 if (regInfo != null)
293 {
294 //don't want to be creating a new link to the remote instance every time like we are here
295 bool retValue = false;
296
297
298 OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject(
299 typeof(OGS1InterRegionRemoting),
300 "tcp://"+ regInfo.RemotingAddress+":"+regInfo.RemotingPort+"/InterRegions");
301 if (remObject != null)
302 {
303
304 retValue = remObject.InformRegionOfChildAgent(regionHandle, agentData);
305 }
306 else
307 {
308 Console.WriteLine("remoting object not found");
309 }
310 remObject = null;
311
312
313 return retValue;
314 }
315
316 return false;
317 }
318
319 public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position)
320 {
321 if (this.listeners.ContainsKey(regionHandle))
322 {
323 this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position);
324 return true;
325 }
326 RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle);
327 if (regInfo != null)
328 {
329 bool retValue = false;
330
331
332 OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject(
333 typeof(OGS1InterRegionRemoting),
334 "tcp://" + regInfo.RemotingAddress + ":" + regInfo.RemotingPort + "/InterRegions");
335 if (remObject != null)
336 {
337
338 retValue = remObject.ExpectAvatarCrossing(regionHandle, agentID, position);
339 }
340 else
341 {
342 Console.WriteLine("remoting object not found");
343 }
344 remObject = null;
345
346
347 return retValue;
348 }
349 //TODO need to see if we know about where this region is and use .net remoting
350 // to inform it.
351 return false;
352 }
353 #endregion
354
355 #region Methods triggered by calls from external instances
356 public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData)
357 {
358 if (this.listeners.ContainsKey(regionHandle))
359 {
360 this.listeners[regionHandle].TriggerExpectUser(regionHandle, agentData);
361 return true;
362 }
363 return false;
364 }
365
366 public bool IncomingArrival(ulong regionHandle, LLUUID agentID, LLVector3 position)
367 {
368 if (this.listeners.ContainsKey(regionHandle))
369 {
370 this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position);
371 return true;
372 }
373 return false;
374 }
375 #endregion
376 #endregion
377 }
378}
diff --git a/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs b/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs
new file mode 100644
index 0000000..f514a29
--- /dev/null
+++ b/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs
@@ -0,0 +1,69 @@
1using System;
2using libsecondlife;
3using OpenSim.Framework.Types;
4
5namespace OpenSim.Region.Communications.OGS1
6{
7 public delegate bool InformRegionChild(ulong regionHandle, AgentCircuitData agentData);
8 public delegate bool ExpectArrival(ulong regionHandle, LLUUID agentID, LLVector3 position);
9
10 public sealed class InterRegionSingleton
11 {
12 static readonly InterRegionSingleton instance = new InterRegionSingleton();
13
14 public event InformRegionChild OnChildAgent;
15 public event ExpectArrival OnArrival;
16
17 static InterRegionSingleton()
18 {
19 }
20
21 InterRegionSingleton()
22 {
23 }
24
25 public static InterRegionSingleton Instance
26 {
27 get
28 {
29 return instance;
30 }
31 }
32
33 public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData)
34 {
35 if (OnChildAgent != null)
36 {
37 return OnChildAgent(regionHandle, agentData);
38 }
39 return false;
40 }
41
42 public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position)
43 {
44 if (OnArrival != null)
45 {
46 return OnArrival(regionHandle, agentID, position);
47 }
48 return false;
49 }
50 }
51
52 public class OGS1InterRegionRemoting : MarshalByRefObject
53 {
54
55 public OGS1InterRegionRemoting()
56 {
57 }
58
59 public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData)
60 {
61 return InterRegionSingleton.Instance.InformRegionOfChildAgent(regionHandle, agentData);
62 }
63
64 public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position)
65 {
66 return InterRegionSingleton.Instance.ExpectAvatarCrossing(regionHandle, agentID, position);
67 }
68 }
69}
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
new file mode 100644
index 0000000..2bbaf9d
--- /dev/null
+++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
@@ -0,0 +1,105 @@
1using System;
2using System.Collections;
3using libsecondlife;
4using Nwc.XmlRpc;
5using OpenSim.Framework.Communications;
6using OpenSim.Framework.Data;
7
8namespace OpenSim.Region.Communications.OGS1
9{
10 public class OGS1UserServices :IUserServices
11 {
12 CommunicationsOGS1 m_parent;
13 public OGS1UserServices(CommunicationsOGS1 parent)
14 {
15 m_parent = parent;
16 }
17
18 public UserProfileData ConvertXMLRPCDataToUserProfile(Hashtable data)
19 {
20 if (data.Contains("error_type"))
21 {
22 Console.WriteLine("Error sent by user server when trying to get user profile: (" + data["error_type"] + "): " + data["error_desc"]);
23 return null;
24 }
25
26 UserProfileData userData = new UserProfileData();
27 userData.username = (string)data["firstname"];
28 userData.surname = (string)data["lastname"];
29 userData.UUID = new LLUUID((string)data["uuid"]);
30 userData.userInventoryURI = (string)data["server_inventory"];
31 userData.userAssetURI = (string)data["server_asset"];
32 userData.profileFirstText = (string)data["profile_firstlife_about"];
33 userData.profileFirstImage = new LLUUID((string)data["profile_firstlife_image"]);
34 userData.profileCanDoMask = Convert.ToUInt32((string)data["profile_can_do"]);
35 userData.profileWantDoMask = Convert.ToUInt32(data["profile_want_do"]);
36 userData.profileImage = new LLUUID((string)data["profile_image"]);
37 userData.lastLogin = Convert.ToInt32((string)data["profile_lastlogin"]);
38 userData.homeRegion = Convert.ToUInt64((string)data["home_region"]);
39 userData.homeLocation = new LLVector3((float)Convert.ToDecimal((string)data["home_coordinates_x"]), (float)Convert.ToDecimal((string)data["home_coordinates_y"]), (float)Convert.ToDecimal((string)data["home_coordinates_z"]));
40 userData.homeLookAt = new LLVector3((float)Convert.ToDecimal((string)data["home_look_x"]), (float)Convert.ToDecimal((string)data["home_look_y"]), (float)Convert.ToDecimal((string)data["home_look_z"]));
41
42 return userData;
43 }
44 public UserProfileData GetUserProfile(string firstName, string lastName)
45 {
46 return GetUserProfile(firstName + " " + lastName);
47 }
48 public UserProfileData GetUserProfile(string name)
49 {
50 //try
51 //{
52 Hashtable param = new Hashtable();
53 param["avatar_name"] = name;
54 IList parameters = new ArrayList();
55 parameters.Add(param);
56 XmlRpcRequest req = new XmlRpcRequest("get_user_by_name", parameters);
57 XmlRpcResponse resp = req.Send(m_parent.ServersInfo.UserURL, 3000);
58 Hashtable respData = (Hashtable)resp.Value;
59
60 return ConvertXMLRPCDataToUserProfile(respData);
61 //}
62 //catch (Exception e)
63 //{
64 // Console.WriteLine("Error when trying to fetch profile data by name from remote user server: " + e.Message);
65 //}
66 //return null;
67 }
68 public UserProfileData GetUserProfile(LLUUID avatarID)
69 {
70 try
71 {
72
73 Hashtable param = new Hashtable();
74 param["avatar_uuid"] = avatarID.ToString();
75 IList parameters = new ArrayList();
76 parameters.Add(param);
77 XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", parameters);
78 XmlRpcResponse resp = req.Send(m_parent.ServersInfo.UserURL, 3000);
79 Hashtable respData = (Hashtable)resp.Value;
80
81 return ConvertXMLRPCDataToUserProfile(respData);
82 }
83 catch (Exception e)
84 {
85 Console.WriteLine("Error when trying to fetch profile data by uuid from remote user server: " + e.Message);
86 }
87 return null;
88 }
89
90 public UserProfileData SetupMasterUser(string firstName, string lastName)
91 {
92 return SetupMasterUser(firstName, lastName, "");
93 }
94
95 public UserProfileData SetupMasterUser(string firstName, string lastName, string password)
96 {
97 UserProfileData profile = GetUserProfile(firstName, lastName);
98 if (profile == null)
99 {
100 Console.WriteLine("Unknown Master User. Grid Mode: No clue what I should do. Probably would choose the grid owner UUID when that is implemented");
101 }
102 return null;
103 }
104 }
105}
diff --git a/OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs b/OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..41f811a
--- /dev/null
+++ b/OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("OpenGrid.Framework.Communications.OGS1")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenGrid.Framework.Communications.OGS1")]
11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("a8b2b39b-c83b-41e2-b0b5-7ccfc1fddae7")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Environment/EstateManager.cs b/OpenSim/Region/Environment/EstateManager.cs
new file mode 100644
index 0000000..b5a74ad
--- /dev/null
+++ b/OpenSim/Region/Environment/EstateManager.cs
@@ -0,0 +1,300 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
31using libsecondlife;
32using libsecondlife.Packets;
33using OpenSim.Framework.Console;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types;
36using OpenSim.Region.Environment.Scenes;
37using Avatar = OpenSim.Region.Environment.Scenes.ScenePresence;
38
39
40namespace OpenSim.Region.Environment
41{
42
43 /// <summary>
44 /// Processes requests regarding estates. Refer to EstateSettings.cs in OpenSim.Framework. Types for all of the core settings
45 /// </summary>
46 public class EstateManager
47 {
48 private Scene m_world;
49 private RegionInfo m_regInfo;
50
51 public EstateManager(Scene world,RegionInfo reginfo)
52 {
53 m_world = world; //Estate settings found at world.m_regInfo.estateSettings
54 m_regInfo = reginfo;
55 }
56
57 private bool convertParamStringToBool(byte[] field)
58 {
59 string s = Helpers.FieldToUTF8String(field);
60 if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true")
61 {
62 return true;
63 }
64 return false;
65 }
66
67 public void handleEstateOwnerMessage(EstateOwnerMessagePacket packet, IClientAPI remote_client)
68 {
69 if (remote_client.AgentId == m_regInfo.MasterAvatarAssignedUUID)
70 {
71 switch (Helpers.FieldToUTF8String(packet.MethodData.Method))
72 {
73 case "getinfo":
74 Console.WriteLine("GETINFO Requested");
75 this.sendRegionInfoPacketToAll();
76
77 break;
78 case "setregioninfo":
79 if (packet.ParamList.Length != 9)
80 {
81 MainLog.Instance.Error("EstateOwnerMessage: SetRegionInfo method has a ParamList of invalid length");
82 }
83 else
84 {
85 m_regInfo.estateSettings.regionFlags = Simulator.RegionFlags.None;
86
87 if (convertParamStringToBool(packet.ParamList[0].Parameter))
88 {
89 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.BlockTerraform;
90 }
91
92 if (convertParamStringToBool(packet.ParamList[1].Parameter))
93 {
94 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.NoFly;
95 }
96
97 if (convertParamStringToBool(packet.ParamList[2].Parameter))
98 {
99 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.AllowDamage;
100 }
101
102 if (convertParamStringToBool(packet.ParamList[3].Parameter) == false)
103 {
104 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.BlockLandResell;
105 }
106
107
108 int tempMaxAgents = Convert.ToInt16(Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[4].Parameter)));
109 m_regInfo.estateSettings.maxAgents = (byte)tempMaxAgents;
110
111 float tempObjectBonusFactor = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter));
112 m_regInfo.estateSettings.objectBonusFactor = tempObjectBonusFactor;
113
114 int tempMatureLevel = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[6].Parameter));
115 m_regInfo.estateSettings.simAccess = (Simulator.SimAccess)tempMatureLevel;
116
117
118 if (convertParamStringToBool(packet.ParamList[7].Parameter))
119 {
120 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.RestrictPushObject;
121 }
122
123 if (convertParamStringToBool(packet.ParamList[8].Parameter))
124 {
125 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.AllowParcelChanges;
126 }
127
128 sendRegionInfoPacketToAll();
129
130 }
131 break;
132 case "texturebase":
133 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
134 {
135 string s = Helpers.FieldToUTF8String(block.Parameter);
136 string[] splitField = s.Split(' ');
137 if (splitField.Length == 2)
138 {
139 LLUUID tempUUID = new LLUUID(splitField[1]);
140 switch (Convert.ToInt16(splitField[0]))
141 {
142 case 0:
143 m_regInfo.estateSettings.terrainBase0 = tempUUID;
144 break;
145 case 1:
146 m_regInfo.estateSettings.terrainBase1 = tempUUID;
147 break;
148 case 2:
149 m_regInfo.estateSettings.terrainBase2 = tempUUID;
150 break;
151 case 3:
152 m_regInfo.estateSettings.terrainBase3 = tempUUID;
153 break;
154 }
155 }
156 }
157 break;
158 case "texturedetail":
159 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
160 {
161
162 string s = Helpers.FieldToUTF8String(block.Parameter);
163 string[] splitField = s.Split(' ');
164 if (splitField.Length == 2)
165 {
166 LLUUID tempUUID = new LLUUID(splitField[1]);
167 switch (Convert.ToInt16(splitField[0]))
168 {
169 case 0:
170 m_regInfo.estateSettings.terrainDetail0 = tempUUID;
171 break;
172 case 1:
173 m_regInfo.estateSettings.terrainDetail1 = tempUUID;
174 break;
175 case 2:
176 m_regInfo.estateSettings.terrainDetail2 = tempUUID;
177 break;
178 case 3:
179 m_regInfo.estateSettings.terrainDetail3 = tempUUID;
180 break;
181 }
182 }
183 }
184 break;
185 case "textureheights":
186 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
187 {
188
189 string s = Helpers.FieldToUTF8String(block.Parameter);
190 string[] splitField = s.Split(' ');
191 if (splitField.Length == 3)
192 {
193
194 float tempHeightLow = (float)Convert.ToDecimal(splitField[1]);
195 float tempHeightHigh = (float)Convert.ToDecimal(splitField[2]);
196
197 switch (Convert.ToInt16(splitField[0]))
198 {
199 case 0:
200 m_regInfo.estateSettings.terrainStartHeight0 = tempHeightLow;
201 m_regInfo.estateSettings.terrainHeightRange0 = tempHeightHigh;
202 break;
203 case 1:
204 m_regInfo.estateSettings.terrainStartHeight1 = tempHeightLow;
205 m_regInfo.estateSettings.terrainHeightRange1 = tempHeightHigh;
206 break;
207 case 2:
208 m_regInfo.estateSettings.terrainStartHeight2 = tempHeightLow;
209 m_regInfo.estateSettings.terrainHeightRange2 = tempHeightHigh;
210 break;
211 case 3:
212 m_regInfo.estateSettings.terrainStartHeight3 = tempHeightLow;
213 m_regInfo.estateSettings.terrainHeightRange3 = tempHeightHigh;
214 break;
215 }
216 }
217 }
218 break;
219 case "texturecommit":
220 sendRegionHandshakeToAll();
221 break;
222 case "setregionterrain":
223 if (packet.ParamList.Length != 9)
224 {
225 MainLog.Instance.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
226 }
227 else
228 {
229 m_regInfo.estateSettings.waterHeight = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[0].Parameter));
230 m_regInfo.estateSettings.terrainRaiseLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter));
231 m_regInfo.estateSettings.terrainLowerLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter));
232 m_regInfo.estateSettings.useFixedSun = this.convertParamStringToBool(packet.ParamList[4].Parameter);
233 m_regInfo.estateSettings.sunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter));
234
235 sendRegionInfoPacketToAll();
236 }
237 break;
238 default:
239 MainLog.Instance.Error("EstateOwnerMessage: Unknown method requested\n" + packet.ToString());
240 break;
241 }
242 }
243 }
244
245 public void sendRegionInfoPacketToAll()
246 {
247 List<Avatar> avatars = m_world.RequestAvatarList();
248
249 for (int i = 0; i < avatars.Count; i++)
250 {
251 this.sendRegionInfoPacket(avatars[i].ControllingClient);
252 }
253 }
254
255 public void sendRegionHandshakeToAll()
256 {
257 List<Avatar> avatars = m_world.RequestAvatarList();
258
259 for (int i = 0; i < avatars.Count; i++)
260 {
261 this.sendRegionHandshake(avatars[i].ControllingClient);
262 }
263 }
264
265 public void sendRegionInfoPacket(IClientAPI remote_client)
266 {
267 Encoding _enc = Encoding.ASCII;
268
269 AgentCircuitData circuitData = remote_client.RequestClientInfo();
270
271 RegionInfoPacket regionInfoPacket = new RegionInfoPacket();
272 regionInfoPacket.AgentData.AgentID = circuitData.AgentID;
273 regionInfoPacket.AgentData.SessionID = circuitData.SessionID;
274 regionInfoPacket.RegionInfo.BillableFactor = m_regInfo.estateSettings.billableFactor;
275 regionInfoPacket.RegionInfo.EstateID = m_regInfo.estateSettings.estateID;
276 regionInfoPacket.RegionInfo.MaxAgents = m_regInfo.estateSettings.maxAgents;
277 regionInfoPacket.RegionInfo.ObjectBonusFactor = m_regInfo.estateSettings.objectBonusFactor;
278 regionInfoPacket.RegionInfo.ParentEstateID = m_regInfo.estateSettings.parentEstateID;
279 regionInfoPacket.RegionInfo.PricePerMeter = m_regInfo.estateSettings.pricePerMeter;
280 regionInfoPacket.RegionInfo.RedirectGridX = m_regInfo.estateSettings.redirectGridX;
281 regionInfoPacket.RegionInfo.RedirectGridY = m_regInfo.estateSettings.redirectGridY;
282 regionInfoPacket.RegionInfo.RegionFlags = (uint)m_regInfo.estateSettings.regionFlags;
283 regionInfoPacket.RegionInfo.SimAccess = (byte)m_regInfo.estateSettings.simAccess;
284 regionInfoPacket.RegionInfo.SimName = _enc.GetBytes( m_regInfo.RegionName);
285 regionInfoPacket.RegionInfo.SunHour = m_regInfo.estateSettings.sunHour;
286 regionInfoPacket.RegionInfo.TerrainLowerLimit = m_regInfo.estateSettings.terrainLowerLimit;
287 regionInfoPacket.RegionInfo.TerrainRaiseLimit = m_regInfo.estateSettings.terrainRaiseLimit;
288 regionInfoPacket.RegionInfo.UseEstateSun = !m_regInfo.estateSettings.useFixedSun;
289 regionInfoPacket.RegionInfo.WaterHeight = m_regInfo.estateSettings.waterHeight;
290
291 remote_client.OutPacket(regionInfoPacket);
292 }
293
294 public void sendRegionHandshake(IClientAPI remoteClient)
295 {
296 remoteClient.SendRegionHandshake(m_regInfo);
297 }
298
299 }
300}
diff --git a/OpenSim/Region/Environment/ParcelManager.cs b/OpenSim/Region/Environment/ParcelManager.cs
new file mode 100644
index 0000000..2059b3f
--- /dev/null
+++ b/OpenSim/Region/Environment/ParcelManager.cs
@@ -0,0 +1,891 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
31using libsecondlife.Packets;
32using OpenSim.Framework.Interfaces;
33using OpenSim.Framework.Types;
34using OpenSim.Region.Environment.Scenes;
35using Avatar = OpenSim.Region.Environment.Scenes.ScenePresence;
36
37namespace OpenSim.Region.Environment
38{
39
40
41 #region ParcelManager Class
42 /// <summary>
43 /// Handles Parcel objects and operations requiring information from other Parcel objects (divide, join, etc)
44 /// </summary>
45 public class ParcelManager : ILocalStorageParcelReceiver
46 {
47
48 #region Constants
49 //Parcel types set with flags in ParcelOverlay.
50 //Only one of these can be used.
51 public const byte PARCEL_TYPE_PUBLIC = (byte)0; //Equals 00000000
52 public const byte PARCEL_TYPE_OWNED_BY_OTHER = (byte)1; //Equals 00000001
53 public const byte PARCEL_TYPE_OWNED_BY_GROUP = (byte)2; //Equals 00000010
54 public const byte PARCEL_TYPE_OWNED_BY_REQUESTER = (byte)3; //Equals 00000011
55 public const byte PARCEL_TYPE_IS_FOR_SALE = (byte)4; //Equals 00000100
56 public const byte PARCEL_TYPE_IS_BEING_AUCTIONED = (byte)5; //Equals 00000101
57
58
59 //Flags that when set, a border on the given side will be placed
60 //NOTE: North and East is assumable by the west and south sides (if parcel to east has a west border, then I have an east border; etc)
61 //This took forever to figure out -- jeesh. /blame LL for even having to send these
62 public const byte PARCEL_FLAG_PROPERTY_BORDER_WEST = (byte)64; //Equals 01000000
63 public const byte PARCEL_FLAG_PROPERTY_BORDER_SOUTH = (byte)128; //Equals 10000000
64
65 //RequestResults (I think these are right, they seem to work):
66 public const int PARCEL_RESULT_ONE_PARCEL = 0; // The request they made contained only one parcel
67 public const int PARCEL_RESULT_MULTIPLE_PARCELS = 1; // The request they made contained more than one parcel
68
69 //These are other constants. Yay!
70 public const int START_PARCEL_LOCAL_ID = 1;
71 #endregion
72
73 #region Member Variables
74 public Dictionary<int, Parcel> parcelList = new Dictionary<int, Parcel>();
75 private int lastParcelLocalID = START_PARCEL_LOCAL_ID - 1;
76 private int[,] parcelIDList = new int[64, 64];
77
78 private Scene m_world;
79 private RegionInfo m_regInfo;
80
81 #endregion
82
83 #region Constructors
84 public ParcelManager(Scene world, RegionInfo reginfo)
85 {
86
87 m_world = world;
88 m_regInfo = reginfo;
89 parcelIDList.Initialize();
90
91 }
92 #endregion
93
94 #region Member Functions
95
96 #region Parcel From Storage Functions
97 public void ParcelFromStorage(ParcelData data)
98 {
99 Parcel new_parcel = new Parcel(data.ownerID, data.isGroupOwned, m_world);
100 new_parcel.parcelData = data.Copy();
101 new_parcel.setParcelBitmapFromByteArray();
102 addParcel(new_parcel);
103
104 }
105
106 public void NoParcelDataFromStorage()
107 {
108 resetSimParcels();
109 }
110 #endregion
111
112 #region Parcel Add/Remove/Get/Create
113 /// <summary>
114 /// Creates a basic Parcel object without an owner (a zeroed key)
115 /// </summary>
116 /// <returns></returns>
117 public Parcel createBaseParcel()
118 {
119 return new Parcel(new LLUUID(), false, m_world);
120 }
121
122 /// <summary>
123 /// Adds a parcel to the stored list and adds them to the parcelIDList to what they own
124 /// </summary>
125 /// <param name="new_parcel">The parcel being added</param>
126 public void addParcel(Parcel new_parcel)
127 {
128 lastParcelLocalID++;
129 new_parcel.parcelData.localID = lastParcelLocalID;
130 parcelList.Add(lastParcelLocalID, new_parcel.Copy());
131
132
133 bool[,] parcelBitmap = new_parcel.getParcelBitmap();
134 int x, y;
135 for (x = 0; x < 64; x++)
136 {
137 for (y = 0; y < 64; y++)
138 {
139 if (parcelBitmap[x, y])
140 {
141 parcelIDList[x, y] = lastParcelLocalID;
142 }
143 }
144 }
145 parcelList[lastParcelLocalID].forceUpdateParcelInfo();
146
147
148 }
149 /// <summary>
150 /// Removes a parcel from the list. Will not remove if local_id is still owning an area in parcelIDList
151 /// </summary>
152 /// <param name="local_id">Parcel.localID of the parcel to remove.</param>
153 public void removeParcel(int local_id)
154 {
155 int x, y;
156 for (x = 0; x < 64; x++)
157 {
158 for (y = 0; y < 64; y++)
159 {
160 if (parcelIDList[x, y] == local_id)
161 {
162 throw new Exception("Could not remove parcel. Still being used at " + x + ", " + y);
163 }
164 }
165 }
166 m_world.localStorage.RemoveParcel(parcelList[local_id].parcelData);
167 parcelList.Remove(local_id);
168 }
169
170 private void performFinalParcelJoin(Parcel master, Parcel slave)
171 {
172 int x, y;
173 bool[,] parcelBitmapSlave = slave.getParcelBitmap();
174 for (x = 0; x < 64; x++)
175 {
176 for (y = 0; y < 64; y++)
177 {
178 if (parcelBitmapSlave[x, y])
179 {
180 parcelIDList[x, y] = master.parcelData.localID;
181 }
182 }
183 }
184 removeParcel(slave.parcelData.localID);
185 }
186 /// <summary>
187 /// Get the parcel at the specified point
188 /// </summary>
189 /// <param name="x">Value between 0 - 256 on the x axis of the point</param>
190 /// <param name="y">Value between 0 - 256 on the y axis of the point</param>
191 /// <returns>Parcel at the point supplied</returns>
192 public Parcel getParcel(int x, int y)
193 {
194 if (x > 256 || y > 256 || x < 0 || y < 0)
195 {
196 throw new Exception("Error: Parcel not found at point " + x + ", " + y);
197 }
198 else
199 {
200 return parcelList[parcelIDList[x / 4, y / 4]];
201 }
202
203 }
204 #endregion
205
206 #region Parcel Modification
207 /// <summary>
208 /// Subdivides a parcel
209 /// </summary>
210 /// <param name="start_x">West Point</param>
211 /// <param name="start_y">South Point</param>
212 /// <param name="end_x">East Point</param>
213 /// <param name="end_y">North Point</param>
214 /// <param name="attempting_user_id">LLUUID of user who is trying to subdivide</param>
215 /// <returns>Returns true if successful</returns>
216 private bool subdivide(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id)
217 {
218 //First, lets loop through the points and make sure they are all in the same parcel
219 //Get the parcel at start
220 Parcel startParcel = getParcel(start_x, start_y);
221 if (startParcel == null) return false; //No such parcel at the beginning
222
223 //Loop through the points
224 try
225 {
226 int totalX = end_x - start_x;
227 int totalY = end_y - start_y;
228 int x, y;
229 for (y = 0; y < totalY; y++)
230 {
231 for (x = 0; x < totalX; x++)
232 {
233 Parcel tempParcel = getParcel(start_x + x, start_y + y);
234 if (tempParcel == null) return false; //No such parcel at that point
235 if (tempParcel != startParcel) return false; //Subdividing over 2 parcels; no-no
236 }
237 }
238 }
239 catch (Exception)
240 {
241 return false; //Exception. For now, lets skip subdivision
242 }
243
244 //If we are still here, then they are subdividing within one parcel
245 //Check owner
246 if (startParcel.parcelData.ownerID != attempting_user_id)
247 {
248 return false; //They cant do this!
249 }
250
251 //Lets create a new parcel with bitmap activated at that point (keeping the old parcels info)
252 Parcel newParcel = startParcel.Copy();
253 newParcel.parcelData.parcelName = "Subdivision of " + newParcel.parcelData.parcelName;
254 newParcel.parcelData.globalID = LLUUID.Random();
255
256 newParcel.setParcelBitmap(Parcel.getSquareParcelBitmap(start_x, start_y, end_x, end_y));
257
258 //Now, lets set the subdivision area of the original to false
259 int startParcelIndex = startParcel.parcelData.localID;
260 parcelList[startParcelIndex].setParcelBitmap(Parcel.modifyParcelBitmapSquare(startParcel.getParcelBitmap(), start_x, start_y, end_x, end_y, false));
261 parcelList[startParcelIndex].forceUpdateParcelInfo();
262
263
264 //Now add the new parcel
265 addParcel(newParcel);
266
267
268
269
270
271 return true;
272 }
273 /// <summary>
274 /// Join 2 parcels together
275 /// </summary>
276 /// <param name="start_x">x value in first parcel</param>
277 /// <param name="start_y">y value in first parcel</param>
278 /// <param name="end_x">x value in second parcel</param>
279 /// <param name="end_y">y value in second parcel</param>
280 /// <param name="attempting_user_id">LLUUID of the avatar trying to join the parcels</param>
281 /// <returns>Returns true if successful</returns>
282 private bool join(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id)
283 {
284 end_x -= 4;
285 end_y -= 4;
286
287 //NOTE: The following only connects the parcels in each corner and not all the parcels that are within the selection box!
288 //This should be fixed later -- somewhat "incomplete code" --Ming
289 Parcel startParcel, endParcel;
290
291 try
292 {
293 startParcel = getParcel(start_x, start_y);
294 endParcel = getParcel(end_x, end_y);
295 }
296 catch (Exception)
297 {
298 return false; //Error occured when trying to get the start and end parcels
299 }
300 if (startParcel == endParcel)
301 {
302 return false; //Subdivision of the same parcel is not allowed
303 }
304
305 //Check the parcel owners:
306 if (startParcel.parcelData.ownerID != endParcel.parcelData.ownerID)
307 {
308 return false;
309 }
310 if (startParcel.parcelData.ownerID != attempting_user_id)
311 {
312 //TODO: Group editing stuff. Avatar owner support for now
313 return false;
314 }
315
316 //Same owners! Lets join them
317 //Merge them to startParcel
318 parcelList[startParcel.parcelData.localID].setParcelBitmap(Parcel.mergeParcelBitmaps(startParcel.getParcelBitmap(), endParcel.getParcelBitmap()));
319 performFinalParcelJoin(startParcel, endParcel);
320
321 return true;
322
323
324
325 }
326 #endregion
327
328 #region Parcel Updating
329 /// <summary>
330 /// Where we send the ParcelOverlay packet to the client
331 /// </summary>
332 /// <param name="remote_client">The object representing the client</param>
333 public void sendParcelOverlay(IClientAPI remote_client)
334 {
335 const int PARCEL_BLOCKS_PER_PACKET = 1024;
336 int x, y = 0;
337 byte[] byteArray = new byte[PARCEL_BLOCKS_PER_PACKET];
338 int byteArrayCount = 0;
339 int sequenceID = 0;
340 ParcelOverlayPacket packet;
341
342 for (y = 0; y < 64; y++)
343 {
344 for (x = 0; x < 64; x++)
345 {
346 byte tempByte = (byte)0; //This represents the byte for the current 4x4
347 Parcel currentParcelBlock = getParcel(x * 4, y * 4);
348
349 if (currentParcelBlock.parcelData.ownerID == remote_client.AgentId)
350 {
351 //Owner Flag
352 tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_OWNED_BY_REQUESTER);
353 }
354 else if (currentParcelBlock.parcelData.salePrice > 0 && (currentParcelBlock.parcelData.authBuyerID == LLUUID.Zero || currentParcelBlock.parcelData.authBuyerID == remote_client.AgentId))
355 {
356 //Sale Flag
357 tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_IS_FOR_SALE);
358 }
359 else if (currentParcelBlock.parcelData.ownerID == LLUUID.Zero)
360 {
361 //Public Flag
362 tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_PUBLIC);
363 }
364 else
365 {
366 //Other Flag
367 tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_OWNED_BY_OTHER);
368 }
369
370
371 //Now for border control
372 if (x == 0)
373 {
374 tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_WEST);
375 }
376 else if (getParcel((x - 1) * 4, y * 4) != currentParcelBlock)
377 {
378 tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_WEST);
379 }
380
381 if (y == 0)
382 {
383 tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_SOUTH);
384 }
385 else if (getParcel(x * 4, (y - 1) * 4) != currentParcelBlock)
386 {
387 tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_SOUTH);
388 }
389
390 byteArray[byteArrayCount] = tempByte;
391 byteArrayCount++;
392 if (byteArrayCount >= PARCEL_BLOCKS_PER_PACKET)
393 {
394 byteArrayCount = 0;
395 packet = new ParcelOverlayPacket();
396 packet.ParcelData.Data = byteArray;
397 packet.ParcelData.SequenceID = sequenceID;
398 remote_client.OutPacket((Packet)packet);
399 sequenceID++;
400 byteArray = new byte[PARCEL_BLOCKS_PER_PACKET];
401 }
402 }
403 }
404
405 packet = new ParcelOverlayPacket();
406 packet.ParcelData.Data = byteArray;
407 packet.ParcelData.SequenceID = sequenceID; //Eh?
408 remote_client.OutPacket((Packet)packet);
409 }
410
411 public void handleParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client)
412 {
413 //Get the parcels within the bounds
414 List<Parcel> temp = new List<Parcel>();
415 int x, y, i;
416 int inc_x = end_x - start_x;
417 int inc_y = end_y - start_y;
418 for (x = 0; x < inc_x; x++)
419 {
420 for (y = 0; y < inc_y; y++)
421 {
422 Parcel currentParcel = getParcel(start_x + x, start_y + y);
423 if (!temp.Contains(currentParcel))
424 {
425 currentParcel.forceUpdateParcelInfo();
426 temp.Add(currentParcel);
427 }
428 }
429 }
430
431 int requestResult = PARCEL_RESULT_ONE_PARCEL;
432 if (temp.Count > 1)
433 {
434 requestResult = PARCEL_RESULT_MULTIPLE_PARCELS;
435 }
436
437 for (i = 0; i < temp.Count; i++)
438 {
439 temp[i].sendParcelProperties(sequence_id, snap_selection, requestResult, remote_client);
440 }
441
442
443 sendParcelOverlay(remote_client);
444 }
445
446 public void handleParcelPropertiesUpdateRequest(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client)
447 {
448 if (parcelList.ContainsKey(packet.ParcelData.LocalID))
449 {
450 parcelList[packet.ParcelData.LocalID].updateParcelProperties(packet, remote_client);
451 }
452 }
453 public void handleParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client)
454 {
455 subdivide(west, south, east, north, remote_client.AgentId);
456 }
457 public void handleParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client)
458 {
459 join(west, south, east, north, remote_client.AgentId);
460
461 }
462 #endregion
463
464 /// <summary>
465 /// Resets the sim to the default parcel (full sim parcel owned by the default user)
466 /// </summary>
467 public void resetSimParcels()
468 {
469 //Remove all the parcels in the sim and add a blank, full sim parcel set to public
470 parcelList.Clear();
471 lastParcelLocalID = START_PARCEL_LOCAL_ID - 1;
472 parcelIDList.Initialize();
473
474 Parcel fullSimParcel = new Parcel(LLUUID.Zero, false, m_world);
475
476 fullSimParcel.setParcelBitmap(Parcel.getSquareParcelBitmap(0, 0, 256, 256));
477 fullSimParcel.parcelData.parcelName = "Your Sim Parcel";
478 fullSimParcel.parcelData.parcelDesc = "";
479
480 fullSimParcel.parcelData.ownerID = m_regInfo.MasterAvatarAssignedUUID;
481 fullSimParcel.parcelData.salePrice = 1;
482 fullSimParcel.parcelData.parcelFlags = libsecondlife.Parcel.ParcelFlags.ForSale;
483 fullSimParcel.parcelData.parcelStatus = libsecondlife.Parcel.ParcelStatus.Leased;
484
485 addParcel(fullSimParcel);
486
487 }
488 #endregion
489 }
490 #endregion
491
492
493 #region Parcel Class
494 /// <summary>
495 /// Keeps track of a specific parcel's information
496 /// </summary>
497 public class Parcel
498 {
499 #region Member Variables
500 public ParcelData parcelData = new ParcelData();
501 public Scene m_world;
502
503 private bool[,] parcelBitmap = new bool[64, 64];
504
505 #endregion
506
507
508 #region Constructors
509 public Parcel(LLUUID owner_id, bool is_group_owned, Scene world)
510 {
511 m_world = world;
512 parcelData.ownerID = owner_id;
513 parcelData.isGroupOwned = is_group_owned;
514
515 }
516 #endregion
517
518
519 #region Member Functions
520
521 #region General Functions
522 /// <summary>
523 /// Checks to see if this parcel contains a point
524 /// </summary>
525 /// <param name="x"></param>
526 /// <param name="y"></param>
527 /// <returns>Returns true if the parcel contains the specified point</returns>
528 public bool containsPoint(int x, int y)
529 {
530 if (x >= 0 && y >= 0 && x <= 256 && x <= 256)
531 {
532 return (parcelBitmap[x / 4, y / 4] == true);
533 }
534 else
535 {
536 return false;
537 }
538 }
539
540 public Parcel Copy()
541 {
542 Parcel newParcel = new Parcel(this.parcelData.ownerID, this.parcelData.isGroupOwned, m_world);
543
544 //Place all new variables here!
545 newParcel.parcelBitmap = (bool[,])(this.parcelBitmap.Clone());
546 newParcel.parcelData = parcelData.Copy();
547
548 return newParcel;
549 }
550
551 #endregion
552
553
554 #region Packet Request Handling
555 /// <summary>
556 /// Sends parcel properties as requested
557 /// </summary>
558 /// <param name="sequence_id">ID sent by client for them to keep track of</param>
559 /// <param name="snap_selection">Bool sent by client for them to use</param>
560 /// <param name="remote_client">Object representing the client</param>
561 public void sendParcelProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client)
562 {
563
564 ParcelPropertiesPacket updatePacket = new ParcelPropertiesPacket();
565 updatePacket.ParcelData.AABBMax = parcelData.AABBMax;
566 updatePacket.ParcelData.AABBMin = parcelData.AABBMin;
567 updatePacket.ParcelData.Area = parcelData.area;
568 updatePacket.ParcelData.AuctionID = parcelData.auctionID;
569 updatePacket.ParcelData.AuthBuyerID = parcelData.authBuyerID; //unemplemented
570
571 updatePacket.ParcelData.Bitmap = parcelData.parcelBitmapByteArray;
572
573 updatePacket.ParcelData.Desc = Helpers.StringToField(parcelData.parcelDesc);
574 updatePacket.ParcelData.Category = (byte)parcelData.category;
575 updatePacket.ParcelData.ClaimDate = parcelData.claimDate;
576 updatePacket.ParcelData.ClaimPrice = parcelData.claimPrice;
577 updatePacket.ParcelData.GroupID = parcelData.groupID;
578 updatePacket.ParcelData.GroupPrims = parcelData.groupPrims;
579 updatePacket.ParcelData.IsGroupOwned = parcelData.isGroupOwned;
580 updatePacket.ParcelData.LandingType = (byte)parcelData.landingType;
581 updatePacket.ParcelData.LocalID = parcelData.localID;
582 updatePacket.ParcelData.MaxPrims = 1000; //unemplemented
583 updatePacket.ParcelData.MediaAutoScale = parcelData.mediaAutoScale;
584 updatePacket.ParcelData.MediaID = parcelData.mediaID;
585 updatePacket.ParcelData.MediaURL = Helpers.StringToField(parcelData.mediaURL);
586 updatePacket.ParcelData.MusicURL = Helpers.StringToField(parcelData.musicURL);
587 updatePacket.ParcelData.Name = Helpers.StringToField(parcelData.parcelName);
588 updatePacket.ParcelData.OtherCleanTime = 0; //unemplemented
589 updatePacket.ParcelData.OtherCount = 0; //unemplemented
590 updatePacket.ParcelData.OtherPrims = 0; //unemplented
591 updatePacket.ParcelData.OwnerID = parcelData.ownerID;
592 updatePacket.ParcelData.OwnerPrims = 0; //unemplemented
593 updatePacket.ParcelData.ParcelFlags = (uint)parcelData.parcelFlags; //unemplemented
594 updatePacket.ParcelData.ParcelPrimBonus = (float)1.0; //unemplemented
595 updatePacket.ParcelData.PassHours = parcelData.passHours;
596 updatePacket.ParcelData.PassPrice = parcelData.passPrice;
597 updatePacket.ParcelData.PublicCount = 0; //unemplemented
598 updatePacket.ParcelData.RegionDenyAnonymous = false; //unemplemented
599 updatePacket.ParcelData.RegionDenyIdentified = false; //unemplemented
600 updatePacket.ParcelData.RegionDenyTransacted = false; //unemplemented
601 updatePacket.ParcelData.RegionPushOverride = true; //unemplemented
602 updatePacket.ParcelData.RentPrice = 0; //??
603 updatePacket.ParcelData.RequestResult = request_result;
604 updatePacket.ParcelData.SalePrice = parcelData.salePrice; //unemplemented
605 updatePacket.ParcelData.SelectedPrims = 0; //unemeplemented
606 updatePacket.ParcelData.SelfCount = 0;//unemplemented
607 updatePacket.ParcelData.SequenceID = sequence_id;
608 updatePacket.ParcelData.SimWideMaxPrims = 15000; //unemplemented
609 updatePacket.ParcelData.SimWideTotalPrims = 0; //unemplemented
610 updatePacket.ParcelData.SnapSelection = snap_selection;
611 updatePacket.ParcelData.SnapshotID = parcelData.snapshotID;
612 updatePacket.ParcelData.Status = (byte)parcelData.parcelStatus;
613 updatePacket.ParcelData.TotalPrims = 0; //unemplemented
614 updatePacket.ParcelData.UserLocation = parcelData.userLocation;
615 updatePacket.ParcelData.UserLookAt = parcelData.userLookAt;
616 remote_client.OutPacket((Packet)updatePacket);
617 }
618
619 public void updateParcelProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client)
620 {
621 if (remote_client.AgentId == parcelData.ownerID)
622 {
623 //Needs later group support
624 parcelData.authBuyerID = packet.ParcelData.AuthBuyerID;
625 parcelData.category = (libsecondlife.Parcel.ParcelCategory)packet.ParcelData.Category;
626 parcelData.parcelDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc);
627 parcelData.groupID = packet.ParcelData.GroupID;
628 parcelData.landingType = packet.ParcelData.LandingType;
629 parcelData.mediaAutoScale = packet.ParcelData.MediaAutoScale;
630 parcelData.mediaID = packet.ParcelData.MediaID;
631 parcelData.mediaURL = Helpers.FieldToUTF8String(packet.ParcelData.MediaURL);
632 parcelData.musicURL = Helpers.FieldToUTF8String(packet.ParcelData.MusicURL);
633 parcelData.parcelName = Helpers.FieldToUTF8String(packet.ParcelData.Name);
634 parcelData.parcelFlags = (libsecondlife.Parcel.ParcelFlags)packet.ParcelData.ParcelFlags;
635 parcelData.passHours = packet.ParcelData.PassHours;
636 parcelData.passPrice = packet.ParcelData.PassPrice;
637 parcelData.salePrice = packet.ParcelData.SalePrice;
638 parcelData.snapshotID = packet.ParcelData.SnapshotID;
639 parcelData.userLocation = packet.ParcelData.UserLocation;
640 parcelData.userLookAt = packet.ParcelData.UserLookAt;
641
642 List<Avatar> avatars = m_world.RequestAvatarList();
643
644 for (int i = 0; i < avatars.Count; i++)
645 {
646 Parcel over = m_world.parcelManager.getParcel((int)Math.Round(avatars[i].Pos.X), (int)Math.Round(avatars[i].Pos.Y));
647 if (over == this)
648 {
649 sendParcelProperties(0, false, 0, avatars[i].ControllingClient);
650 }
651 }
652
653 }
654 }
655 #endregion
656
657
658 #region Update Functions
659 /// <summary>
660 /// Updates the AABBMin and AABBMax values after area/shape modification of parcel
661 /// </summary>
662 private void updateAABBAndAreaValues()
663 {
664 int min_x = 64;
665 int min_y = 64;
666 int max_x = 0;
667 int max_y = 0;
668 int tempArea = 0;
669 int x, y;
670 for (x = 0; x < 64; x++)
671 {
672 for (y = 0; y < 64; y++)
673 {
674 if (parcelBitmap[x, y] == true)
675 {
676 if (min_x > x) min_x = x;
677 if (min_y > y) min_y = y;
678 if (max_x < x) max_x = x;
679 if (max_y < y) max_y = y;
680 tempArea += 16; //16sqm parcel
681 }
682 }
683 }
684 parcelData.AABBMin = new LLVector3((float)(min_x * 4), (float)(min_y * 4), (float)m_world.Terrain.get((min_x * 4), (min_y * 4)));
685 parcelData.AABBMax = new LLVector3((float)(max_x * 4), (float)(max_y * 4), (float)m_world.Terrain.get((max_x * 4), (max_y * 4)));
686 parcelData.area = tempArea;
687 }
688
689 public void updateParcelBitmapByteArray()
690 {
691 parcelData.parcelBitmapByteArray = convertParcelBitmapToBytes();
692 }
693
694 /// <summary>
695 /// Update all settings in parcel such as area, bitmap byte array, etc
696 /// </summary>
697 public void forceUpdateParcelInfo()
698 {
699 this.updateAABBAndAreaValues();
700 this.updateParcelBitmapByteArray();
701 }
702
703 public void setParcelBitmapFromByteArray()
704 {
705 parcelBitmap = convertBytesToParcelBitmap();
706 }
707 #endregion
708
709
710 #region Parcel Bitmap Functions
711 /// <summary>
712 /// Sets the parcel's bitmap manually
713 /// </summary>
714 /// <param name="bitmap">64x64 block representing where this parcel is on a map</param>
715 public void setParcelBitmap(bool[,] bitmap)
716 {
717 if (bitmap.GetLength(0) != 64 || bitmap.GetLength(1) != 64 || bitmap.Rank != 2)
718 {
719 //Throw an exception - The bitmap is not 64x64
720 throw new Exception("Error: Invalid Parcel Bitmap");
721 }
722 else
723 {
724 //Valid: Lets set it
725 parcelBitmap = bitmap;
726 forceUpdateParcelInfo();
727
728 }
729 }
730 /// <summary>
731 /// Gets the parcels bitmap manually
732 /// </summary>
733 /// <returns></returns>
734 public bool[,] getParcelBitmap()
735 {
736 return parcelBitmap;
737 }
738 /// <summary>
739 /// Converts the parcel bitmap to a packet friendly byte array
740 /// </summary>
741 /// <returns></returns>
742 private byte[] convertParcelBitmapToBytes()
743 {
744 byte[] tempConvertArr = new byte[512];
745 byte tempByte = 0;
746 int x, y, i, byteNum = 0;
747 i = 0;
748 for (y = 0; y < 64; y++)
749 {
750 for (x = 0; x < 64; x++)
751 {
752 tempByte = Convert.ToByte(tempByte | Convert.ToByte(parcelBitmap[x, y]) << (i++ % 8));
753 if (i % 8 == 0)
754 {
755 tempConvertArr[byteNum] = tempByte;
756 tempByte = (byte)0;
757 i = 0;
758 byteNum++;
759 }
760 }
761 }
762 return tempConvertArr;
763 }
764
765 private bool[,] convertBytesToParcelBitmap()
766 {
767 bool[,] tempConvertMap = new bool[64, 64];
768 tempConvertMap.Initialize();
769 byte tempByte = 0;
770 int x = 0, y = 0, i = 0, bitNum = 0;
771 for (i = 0; i < 512; i++)
772 {
773 tempByte = parcelData.parcelBitmapByteArray[i];
774 for (bitNum = 0; bitNum < 8; bitNum++)
775 {
776 bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte)1);
777 tempConvertMap[x, y] = bit;
778 x++;
779 if (x > 63)
780 {
781 x = 0;
782 y++;
783 }
784
785 }
786
787 }
788 return tempConvertMap;
789 }
790 /// <summary>
791 /// Full sim parcel creation
792 /// </summary>
793 /// <returns></returns>
794 public static bool[,] basicFullRegionParcelBitmap()
795 {
796 return getSquareParcelBitmap(0, 0, 256, 256);
797 }
798
799 /// <summary>
800 /// Used to modify the bitmap between the x and y points. Points use 64 scale
801 /// </summary>
802 /// <param name="start_x"></param>
803 /// <param name="start_y"></param>
804 /// <param name="end_x"></param>
805 /// <param name="end_y"></param>
806 /// <returns></returns>
807 public static bool[,] getSquareParcelBitmap(int start_x, int start_y, int end_x, int end_y)
808 {
809
810 bool[,] tempBitmap = new bool[64, 64];
811 tempBitmap.Initialize();
812
813 tempBitmap = modifyParcelBitmapSquare(tempBitmap, start_x, start_y, end_x, end_y, true);
814 return tempBitmap;
815 }
816
817 /// <summary>
818 /// Change a parcel's bitmap at within a square and set those points to a specific value
819 /// </summary>
820 /// <param name="parcel_bitmap"></param>
821 /// <param name="start_x"></param>
822 /// <param name="start_y"></param>
823 /// <param name="end_x"></param>
824 /// <param name="end_y"></param>
825 /// <param name="set_value"></param>
826 /// <returns></returns>
827 public static bool[,] modifyParcelBitmapSquare(bool[,] parcel_bitmap, int start_x, int start_y, int end_x, int end_y, bool set_value)
828 {
829 if (parcel_bitmap.GetLength(0) != 64 || parcel_bitmap.GetLength(1) != 64 || parcel_bitmap.Rank != 2)
830 {
831 //Throw an exception - The bitmap is not 64x64
832 throw new Exception("Error: Invalid Parcel Bitmap in modifyParcelBitmapSquare()");
833 }
834
835 int x, y;
836 for (y = 0; y < 64; y++)
837 {
838 for (x = 0; x < 64; x++)
839 {
840 if (x >= start_x / 4 && x < end_x / 4
841 && y >= start_y / 4 && y < end_y / 4)
842 {
843 parcel_bitmap[x, y] = set_value;
844 }
845 }
846 }
847 return parcel_bitmap;
848 }
849 /// <summary>
850 /// Join the true values of 2 bitmaps together
851 /// </summary>
852 /// <param name="bitmap_base"></param>
853 /// <param name="bitmap_add"></param>
854 /// <returns></returns>
855 public static bool[,] mergeParcelBitmaps(bool[,] bitmap_base, bool[,] bitmap_add)
856 {
857 if (bitmap_base.GetLength(0) != 64 || bitmap_base.GetLength(1) != 64 || bitmap_base.Rank != 2)
858 {
859 //Throw an exception - The bitmap is not 64x64
860 throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_base in mergeParcelBitmaps");
861 }
862 if (bitmap_add.GetLength(0) != 64 || bitmap_add.GetLength(1) != 64 || bitmap_add.Rank != 2)
863 {
864 //Throw an exception - The bitmap is not 64x64
865 throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_add in mergeParcelBitmaps");
866
867 }
868
869 int x, y;
870 for (y = 0; y < 64; y++)
871 {
872 for (x = 0; x < 64; x++)
873 {
874 if (bitmap_add[x, y])
875 {
876 bitmap_base[x, y] = true;
877 }
878 }
879 }
880 return bitmap_base;
881 }
882 #endregion
883
884 #endregion
885
886
887 }
888 #endregion
889
890
891}
diff --git a/OpenSim/Region/Environment/RegionManager.cs b/OpenSim/Region/Environment/RegionManager.cs
new file mode 100644
index 0000000..cd67e97
--- /dev/null
+++ b/OpenSim/Region/Environment/RegionManager.cs
@@ -0,0 +1,29 @@
1using System.Collections.Generic;
2using OpenSim.Framework;
3using OpenSim.Framework.Communications;
4using OpenSim.Framework.Servers;
5using OpenSim.Region.Capabilities;
6using OpenSim.Region.Environment.Scenes;
7
8namespace OpenSim.Region.Environment
9{
10 public class RegionManager //needs renaming , but first we need to rename the namespace
11 {
12 protected AuthenticateSessionsBase authenticateHandler;
13 protected RegionCommsListener regionCommsHost;
14 protected CommunicationsManager commsManager;
15 protected List<Caps> capsHandlers = new List<Caps>();
16 protected BaseHttpServer httpListener;
17
18 protected Scene m_Scene;
19
20 public ParcelManager parcelManager;
21 public EstateManager estateManager;
22
23 public RegionManager()
24 {
25
26 }
27
28 }
29}
diff --git a/OpenSim/Region/Environment/Scenes/Entity.cs b/OpenSim/Region/Environment/Scenes/Entity.cs
new file mode 100644
index 0000000..084c9ab
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/Entity.cs
@@ -0,0 +1,115 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
30using OpenSim.Physics.Manager;
31
32namespace OpenSim.Region.Environment.Scenes
33{
34 public abstract class Entity :EntityBase //this class (Entity) will be phased out
35 {
36 protected PhysicsActor _physActor;
37
38 /// <summary>
39 ///
40 /// </summary>
41 public override LLVector3 Pos
42 {
43 get
44 {
45 if (this._physActor != null)
46 {
47 m_pos.X = _physActor.Position.X;
48 m_pos.Y = _physActor.Position.Y;
49 m_pos.Z = _physActor.Position.Z;
50 }
51
52 return m_pos;
53 }
54 set
55 {
56 if (this._physActor != null)
57 {
58 try
59 {
60 lock (this.m_world.SyncRoot)
61 {
62
63 this._physActor.Position = new PhysicsVector(value.X, value.Y, value.Z);
64 }
65 }
66 catch (Exception e)
67 {
68 Console.WriteLine(e.Message);
69 }
70 }
71
72 m_pos = value;
73 }
74 }
75
76
77 /// <summary>
78 ///
79 /// </summary>
80 public override LLVector3 Velocity
81 {
82 get
83 {
84 if (this._physActor != null)
85 {
86 m_velocity.X = _physActor.Velocity.X;
87 m_velocity.Y = _physActor.Velocity.Y;
88 m_velocity.Z = _physActor.Velocity.Z;
89 }
90
91 return m_velocity;
92 }
93 set
94 {
95 if (this._physActor != null)
96 {
97 try
98 {
99 lock (this.m_world.SyncRoot)
100 {
101
102 this._physActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z);
103 }
104 }
105 catch (Exception e)
106 {
107 Console.WriteLine(e.Message);
108 }
109 }
110
111 m_velocity = value;
112 }
113 }
114 }
115}
diff --git a/OpenSim/Region/Environment/Scenes/EntityBase.cs b/OpenSim/Region/Environment/Scenes/EntityBase.cs
new file mode 100644
index 0000000..65a0395
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/EntityBase.cs
@@ -0,0 +1,142 @@
1using System.Collections.Generic;
2using Axiom.Math;
3using libsecondlife;
4
5namespace OpenSim.Region.Environment.Scenes
6{
7 public abstract class EntityBase
8 {
9 public LLUUID uuid;
10
11 protected List<EntityBase> children;
12
13 protected Scene m_world;
14 protected string m_name;
15
16 /// <summary>
17 ///
18 /// </summary>
19 public virtual string Name
20 {
21 get { return m_name; }
22 set { m_name = value; }
23 }
24
25 protected LLVector3 m_pos;
26 /// <summary>
27 ///
28 /// </summary>
29 public virtual LLVector3 Pos
30 {
31 get
32 {
33 return m_pos;
34 }
35 set
36 {
37 m_pos = value;
38 }
39 }
40
41 public LLVector3 m_velocity;
42
43 /// <summary>
44 ///
45 /// </summary>
46 public virtual LLVector3 Velocity
47 {
48 get
49 {
50 return m_velocity;
51 }
52 set
53 {
54 m_velocity = value;
55 }
56 }
57
58 protected Quaternion m_rotation = new Quaternion(0,0,1,0);
59
60 public virtual Quaternion Rotation
61 {
62 get
63 {
64 return m_rotation;
65 }
66 set
67 {
68 m_rotation = value;
69 }
70 }
71
72 protected uint m_localId;
73
74 public uint LocalId
75 {
76 get { return m_localId; }
77 set { m_localId = value; }
78 }
79
80 /// <summary>
81 /// Creates a new Entity (should not occur on it's own)
82 /// </summary>
83 public EntityBase()
84 {
85 uuid = new LLUUID();
86
87 m_pos = new LLVector3();
88 m_velocity = new LLVector3();
89 Rotation = new Quaternion();
90 m_name = "(basic entity)";
91 children = new List<EntityBase>();
92 }
93
94 /// <summary>
95 ///
96 /// </summary>
97 public virtual void updateMovement()
98 {
99 foreach (EntityBase child in children)
100 {
101 child.updateMovement();
102 }
103 }
104
105 /// <summary>
106 /// Performs any updates that need to be done at each frame. This function is overridable from it's children.
107 /// </summary>
108 public virtual void update()
109 {
110 // Do any per-frame updates needed that are applicable to every type of entity
111 foreach (EntityBase child in children)
112 {
113 child.update();
114 }
115 }
116
117 /// <summary>
118 /// Called at a set interval to inform entities that they should back themsleves up to the DB
119 /// </summary>
120 public virtual void BackUp()
121 {
122
123 }
124
125 /// <summary>
126 /// Copies the entity
127 /// </summary>
128 /// <returns></returns>
129 public virtual EntityBase Copy()
130 {
131 return (EntityBase)this.MemberwiseClone();
132 }
133
134 /// <summary>
135 /// Infoms the entity that the land (heightmap) has changed
136 /// </summary>
137 public virtual void LandRenegerated()
138 {
139
140 }
141 }
142}
diff --git a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs
new file mode 100644
index 0000000..7c3a033
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs
@@ -0,0 +1,14 @@
1using libsecondlife;
2using libsecondlife.Packets;
3using OpenSim.Framework.Interfaces;
4
5namespace OpenSim.Region.Environment.Scenes
6{
7 public interface IScenePresenceBody
8 {
9 void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation);
10 void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam);
11 void SendOurAppearance(IClientAPI OurClient);
12 void SendAppearanceToOtherAgent(ScenePresence avatarInfo);
13 }
14}
diff --git a/OpenSim/Region/Environment/Scenes/Primitive.cs b/OpenSim/Region/Environment/Scenes/Primitive.cs
new file mode 100644
index 0000000..d23a569
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/Primitive.cs
@@ -0,0 +1,594 @@
1using System;
2using System.Collections.Generic;
3using Axiom.Math;
4using libsecondlife;
5using libsecondlife.Packets;
6using OpenSim.Framework.Interfaces;
7using OpenSim.Framework.Inventory;
8using OpenSim.Framework.Types;
9
10namespace OpenSim.Region.Environment.Scenes
11{
12 public class Primitive : EntityBase
13 {
14 private const uint FULL_MASK_PERMISSIONS = 2147483647;
15
16 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
17 private ulong m_regionHandle;
18 private byte updateFlag = 0;
19 private uint m_flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128;
20
21 private Dictionary<LLUUID, InventoryItem> inventoryItems;
22
23 private string m_description = "";
24
25 public string SitName = "";
26 public string TouchName = "";
27 public string Text = "";
28
29 public LLUUID CreatorID;
30 public LLUUID OwnerID;
31 public LLUUID LastOwnerID;
32 public Int32 CreationDate;
33
34 public uint ParentID = 0;
35
36 public uint OwnerMask = FULL_MASK_PERMISSIONS;
37 public uint NextOwnerMask = FULL_MASK_PERMISSIONS;
38 public uint GroupMask = FULL_MASK_PERMISSIONS;
39 public uint EveryoneMask = FULL_MASK_PERMISSIONS;
40 public uint BaseMask = FULL_MASK_PERMISSIONS;
41
42 private PrimitiveBaseShape m_Shape;
43
44 public SceneObject m_RootParent;
45 public bool m_isRootPrim;
46 public EntityBase m_Parent;
47
48 #region Properties
49 /// <summary>
50 /// If rootprim, will return world position
51 /// otherwise will return local offset from rootprim
52 /// </summary>
53 public override LLVector3 Pos
54 {
55 get
56 {
57 if (m_isRootPrim)
58 {
59 //if we are rootprim then our offset should be zero
60 return this.m_pos + m_Parent.Pos;
61 }
62 else
63 {
64 return this.m_pos;
65 }
66 }
67 set
68 {
69 if (m_isRootPrim)
70 {
71 m_Parent.Pos = value;
72 }
73 this.m_pos = value - m_Parent.Pos;
74 }
75
76 }
77
78 public LLVector3 WorldPos
79 {
80 get
81 {
82 if (!this.m_isRootPrim)
83 {
84 Primitive parentPrim = (Primitive)this.m_Parent;
85 Axiom.Math.Vector3 offsetPos = new Vector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z);
86 offsetPos = parentPrim.Rotation * offsetPos;
87 return parentPrim.WorldPos + new LLVector3(offsetPos.x, offsetPos.y, offsetPos.z);
88 }
89 else
90 {
91 return this.Pos;
92 }
93 }
94 }
95
96 public string Description
97 {
98 get
99 {
100 return this.m_description;
101 }
102 set
103 {
104 this.m_description = value;
105 }
106 }
107
108 public LLVector3 Scale
109 {
110 set
111 {
112 this.m_Shape.Scale = value;
113 }
114 get
115 {
116 return this.m_Shape.Scale;
117 }
118 }
119 #endregion
120
121 #region Constructors
122 /// <summary>
123 ///
124 /// </summary>
125 /// <param name="regionHandle"></param>
126 /// <param name="world"></param>
127 /// <param name="addPacket"></param>
128 /// <param name="ownerID"></param>
129 /// <param name="localID"></param>
130 /// <param name="isRoot"></param>
131 /// <param name="parent"></param>
132 /// <param name="rootObject"></param>
133 public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject)
134 {
135 m_regionHandle = regionHandle;
136 m_world = world;
137 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
138 this.m_Parent = parent;
139 this.m_isRootPrim = isRoot;
140 this.m_RootParent = rootObject;
141 this.CreateFromPacket(addPacket, ownerID, localID);
142 this.Rotation = Axiom.Math.Quaternion.Identity;
143 }
144
145 /// <summary>
146 ///
147 /// </summary>
148 /// <remarks>Empty constructor for duplication</remarks>
149 public Primitive()
150 {
151
152 }
153
154 #endregion
155
156 #region Duplication
157
158 public Primitive Copy(EntityBase parent, SceneObject rootParent)
159 {
160 Primitive dupe = (Primitive)this.MemberwiseClone();
161 // TODO: Copy this properly.
162 dupe.inventoryItems = this.inventoryItems;
163 dupe.m_Parent = parent;
164 dupe.m_RootParent = rootParent;
165 // TODO: Copy this properly.
166 dupe.m_Shape = this.m_Shape;
167
168 uint newLocalID = this.m_world.PrimIDAllocate();
169 dupe.LocalId = newLocalID;
170
171 dupe.Scale = new LLVector3(this.Scale.X, this.Scale.Y, this.Scale.Z);
172 dupe.Rotation = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z);
173 dupe.Pos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z);
174
175 return dupe;
176 }
177
178 #endregion
179
180
181 #region Override from EntityBase
182 /// <summary>
183 ///
184 /// </summary>
185 public override void update()
186 {
187 if (this.updateFlag == 1) // is a new prim just been created/reloaded or has major changes
188 {
189 this.SendFullUpdateToAllClients();
190 this.updateFlag = 0;
191 }
192 if (this.updateFlag == 2) //some change has been made so update the clients
193 {
194 this.SendTerseUpdateToALLClients();
195 this.updateFlag = 0;
196 }
197
198 foreach (EntityBase child in children)
199 {
200 child.update();
201 }
202 }
203 #endregion
204
205 #region Setup
206 /// <summary>
207 ///
208 /// </summary>
209 /// <param name="addPacket"></param>
210 /// <param name="ownerID"></param>
211 /// <param name="localID"></param>
212 public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
213 {
214 this.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
215 this.OwnerID = ownerID;
216 this.CreatorID = this.OwnerID;
217 this.LastOwnerID = LLUUID.Zero;
218 this.Pos = addPacket.ObjectData.RayEnd;
219 this.uuid = LLUUID.Random();
220 this.m_localId = (uint)(localID);
221
222 PrimitiveBaseShape pShape = new PrimitiveBaseShape();
223 this.m_Shape = pShape;
224
225 pShape.PCode = addPacket.ObjectData.PCode;
226 pShape.PathBegin = addPacket.ObjectData.PathBegin;
227 pShape.PathEnd = addPacket.ObjectData.PathEnd;
228 pShape.PathScaleX = addPacket.ObjectData.PathScaleX;
229 pShape.PathScaleY = addPacket.ObjectData.PathScaleY;
230 pShape.PathShearX = addPacket.ObjectData.PathShearX;
231 pShape.PathShearY = addPacket.ObjectData.PathShearY;
232 pShape.PathSkew = addPacket.ObjectData.PathSkew;
233 pShape.ProfileBegin = addPacket.ObjectData.ProfileBegin;
234 pShape.ProfileEnd = addPacket.ObjectData.ProfileEnd;
235 pShape.Scale = addPacket.ObjectData.Scale;
236 pShape.PathCurve = addPacket.ObjectData.PathCurve;
237 pShape.ProfileCurve = addPacket.ObjectData.ProfileCurve;
238 pShape.ProfileHollow = addPacket.ObjectData.ProfileHollow;
239 pShape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
240 pShape.PathRevolutions = addPacket.ObjectData.PathRevolutions;
241 pShape.PathTaperX = addPacket.ObjectData.PathTaperX;
242 pShape.PathTaperY = addPacket.ObjectData.PathTaperY;
243 pShape.PathTwist = addPacket.ObjectData.PathTwist;
244 pShape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
245
246 this.updateFlag = 1;
247 }
248 #endregion
249
250 #region Linking / unlinking
251 /// <summary>
252 ///
253 /// </summary>
254 /// <param name="linkObject"></param>
255 public void AddNewChildren(SceneObject linkObject)
256 {
257 // Console.WriteLine("linking new prims " + linkObject.rootLocalID + " to me (" + this.LocalId + ")");
258 //TODO check permissions
259 this.children.Add(linkObject.rootPrimitive);
260 linkObject.rootPrimitive.SetNewParent(this, this.m_RootParent);
261
262 this.m_world.DeleteEntity(linkObject.rootUUID);
263 linkObject.DeleteAllChildren();
264 }
265
266 /// <summary>
267 ///
268 /// </summary>
269 /// <param name="newParent"></param>
270 /// <param name="rootParent"></param>
271 public void SetNewParent(Primitive newParent, SceneObject rootParent)
272 {
273 LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z);
274 this.m_isRootPrim = false;
275 this.m_Parent = newParent;
276 this.ParentID = newParent.LocalId;
277 this.m_RootParent = rootParent;
278 this.m_RootParent.AddChildToList(this);
279 this.Pos = oldPos;
280 Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z);
281 axPos = this.m_Parent.Rotation.Inverse() * axPos;
282 this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
283 Axiom.Math.Quaternion oldRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z);
284 this.Rotation = this.m_Parent.Rotation.Inverse() * this.Rotation;
285 this.updateFlag = 1;
286
287 foreach (Primitive child in children)
288 {
289 child.SetRootParent(rootParent, newParent, oldPos, oldRot);
290 }
291 children.Clear();
292
293
294 }
295
296 /// <summary>
297 ///
298 /// </summary>
299 /// <param name="newRoot"></param>
300 public void SetRootParent(SceneObject newRoot , Primitive newParent, LLVector3 oldParentPosition, Axiom.Math.Quaternion oldParentRotation)
301 {
302 LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z);
303 Axiom.Math.Vector3 axOldPos = new Vector3(oldPos.X, oldPos.Y, oldPos.Z);
304 axOldPos = oldParentRotation * axOldPos;
305 oldPos = new LLVector3(axOldPos.x, axOldPos.y, axOldPos.z);
306 oldPos += oldParentPosition;
307 Axiom.Math.Quaternion oldRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z);
308 this.m_isRootPrim = false;
309 this.m_Parent = newParent;
310 this.ParentID = newParent.LocalId;
311 newParent.AddToChildrenList(this);
312 this.m_RootParent = newRoot;
313 this.m_RootParent.AddChildToList(this);
314 this.Pos = oldPos;
315 Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z);
316 axPos = this.m_Parent.Rotation.Inverse() * axPos;
317 this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
318 this.Rotation = oldParentRotation * this.Rotation;
319 this.Rotation = this.m_Parent.Rotation.Inverse()* this.Rotation ;
320 this.updateFlag = 1;
321 foreach (Primitive child in children)
322 {
323 child.SetRootParent(newRoot, newParent, oldPos, oldRot);
324 }
325 children.Clear();
326 }
327
328 /// <summary>
329 ///
330 /// </summary>
331 /// <param name="offset"></param>
332 public void AddOffsetToChildren(LLVector3 offset)
333 {
334 foreach (Primitive prim in this.children)
335 {
336 prim.m_pos += offset;
337 prim.updateFlag = 2;
338 }
339 }
340
341 /// <summary>
342 ///
343 /// </summary>
344 /// <param name="prim"></param>
345 public void AddToChildrenList(Primitive prim)
346 {
347 this.children.Add(prim);
348 }
349 #endregion
350
351 #region Resizing/Scale
352 /// <summary>
353 ///
354 /// </summary>
355 /// <param name="scale"></param>
356 public void ResizeGoup(LLVector3 scale)
357 {
358 LLVector3 offset = (scale - this.m_Shape.Scale);
359 offset.X /= 2;
360 offset.Y /= 2;
361 offset.Z /= 2;
362 if (this.m_isRootPrim)
363 {
364 this.m_Parent.Pos += offset;
365 }
366 else
367 {
368 this.m_pos += offset;
369 }
370
371 this.AddOffsetToChildren(new LLVector3(-offset.X, -offset.Y, -offset.Z));
372 this.m_Shape.Scale = scale;
373
374 this.updateFlag = 1;
375 }
376 #endregion
377
378 #region Position
379 /// <summary>
380 ///
381 /// </summary>
382 /// <param name="pos"></param>
383 public void UpdateGroupPosition(LLVector3 pos)
384 {
385 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
386
387 this.Pos = newPos;
388 this.updateFlag = 2;
389 }
390
391 /// <summary>
392 ///
393 /// </summary>
394 /// <param name="pos"></param>
395 public void UpdateSinglePosition(LLVector3 pos)
396 {
397 // Console.WriteLine("updating single prim position");
398 if (this.m_isRootPrim)
399 {
400 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
401 LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z);
402 LLVector3 diff = oldPos - newPos;
403 Axiom.Math.Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z);
404 axDiff = this.Rotation.Inverse() * axDiff;
405 diff.X = axDiff.x;
406 diff.Y = axDiff.y;
407 diff.Z = axDiff.z;
408 this.Pos = newPos;
409
410 foreach (Primitive prim in this.children)
411 {
412 prim.m_pos += diff;
413 prim.updateFlag = 2;
414 }
415 this.updateFlag = 2;
416 }
417 else
418 {
419 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
420 this.m_pos = newPos;
421 this.updateFlag = 2;
422 }
423 }
424
425 #endregion
426
427 #region Rotation
428 /// <summary>
429 ///
430 /// </summary>
431 /// <param name="rot"></param>
432 public void UpdateGroupRotation(LLQuaternion rot)
433 {
434 this.Rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
435 this.updateFlag = 2;
436
437 }
438
439 /// <summary>
440 ///
441 /// </summary>
442 /// <param name="pos"></param>
443 /// <param name="rot"></param>
444 public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot)
445 {
446 this.Rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
447 this.Pos = pos;
448 this.updateFlag = 2;
449 }
450
451 /// <summary>
452 ///
453 /// </summary>
454 /// <param name="rot"></param>
455 public void UpdateSingleRotation(LLQuaternion rot)
456 {
457 //Console.WriteLine("updating single prim rotation");
458 Axiom.Math.Quaternion axRot = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
459 Axiom.Math.Quaternion oldParentRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z);
460 this.Rotation = axRot;
461 foreach (Primitive prim in this.children)
462 {
463 Axiom.Math.Vector3 axPos = new Vector3(prim.m_pos.X, prim.m_pos.Y, prim.m_pos.Z);
464 axPos = oldParentRot * axPos;
465 axPos = axRot.Inverse() * axPos;
466 prim.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
467 prim.Rotation = oldParentRot * prim.Rotation ;
468 prim.Rotation = axRot.Inverse()* prim.Rotation;
469 prim.updateFlag = 2;
470 }
471 this.updateFlag = 2;
472 }
473 #endregion
474
475 #region Shape
476 /// <summary>
477 ///
478 /// </summary>
479 /// <param name="shapeBlock"></param>
480 public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock)
481 {
482 this.m_Shape.PathBegin = shapeBlock.PathBegin;
483 this.m_Shape.PathEnd = shapeBlock.PathEnd;
484 this.m_Shape.PathScaleX = shapeBlock.PathScaleX;
485 this.m_Shape.PathScaleY = shapeBlock.PathScaleY;
486 this.m_Shape.PathShearX = shapeBlock.PathShearX;
487 this.m_Shape.PathShearY = shapeBlock.PathShearY;
488 this.m_Shape.PathSkew = shapeBlock.PathSkew;
489 this.m_Shape.ProfileBegin = shapeBlock.ProfileBegin;
490 this.m_Shape.ProfileEnd = shapeBlock.ProfileEnd;
491 this.m_Shape.PathCurve = shapeBlock.PathCurve;
492 this.m_Shape.ProfileCurve = shapeBlock.ProfileCurve;
493 this.m_Shape.ProfileHollow = shapeBlock.ProfileHollow;
494 this.m_Shape.PathRadiusOffset = shapeBlock.PathRadiusOffset;
495 this.m_Shape.PathRevolutions = shapeBlock.PathRevolutions;
496 this.m_Shape.PathTaperX = shapeBlock.PathTaperX;
497 this.m_Shape.PathTaperY = shapeBlock.PathTaperY;
498 this.m_Shape.PathTwist = shapeBlock.PathTwist;
499 this.m_Shape.PathTwistBegin = shapeBlock.PathTwistBegin;
500 this.updateFlag = 1;
501 }
502 #endregion
503
504 #region Client Update Methods
505
506 /// <summary>
507 ///
508 /// </summary>
509 /// <param name="remoteClient"></param>
510 public void SendFullUpdateForAllChildren(IClientAPI remoteClient)
511 {
512 this.SendFullUpdateToClient(remoteClient);
513 for (int i = 0; i < this.children.Count; i++)
514 {
515 if (this.children[i] is Primitive)
516 {
517 ((Primitive)this.children[i]).SendFullUpdateForAllChildren(remoteClient);
518 }
519 }
520 }
521
522 /// <summary>
523 ///
524 /// </summary>
525 /// <param name="remoteClient"></param>
526 public void SendFullUpdateToClient(IClientAPI remoteClient)
527 {
528 LLVector3 lPos;
529 lPos = this.Pos;
530 LLQuaternion lRot;
531 lRot = new LLQuaternion(this.Rotation.x, this.Rotation.y, this.Rotation.z, this.Rotation.w);
532
533 remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.m_Shape, lPos, lRot, new LLUUID("00000000-0000-0000-9999-000000000005"), this.m_flags, this.uuid, this.OwnerID, this.Text, this.ParentID);
534 }
535
536 /// <summary>
537 ///
538 /// </summary>
539 public void SendFullUpdateToAllClients()
540 {
541 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
542 for (int i = 0; i < avatars.Count; i++)
543 {
544 this.SendFullUpdateToClient(avatars[i].ControllingClient);
545 }
546 }
547
548 /// <summary>
549 ///
550 /// </summary>
551 /// <param name="remoteClient"></param>
552 public void SendTerseUpdateForAllChildren(IClientAPI remoteClient)
553 {
554 this.SendTerseUpdateToClient(remoteClient);
555 for (int i = 0; i < this.children.Count; i++)
556 {
557 if (this.children[i] is Primitive)
558 {
559 ((Primitive)this.children[i]).SendTerseUpdateForAllChildren(remoteClient);
560 }
561 }
562 }
563
564 /// <summary>
565 ///
566 /// </summary>
567 /// <param name="RemoteClient"></param>
568 public void SendTerseUpdateToClient(IClientAPI RemoteClient)
569 {
570 LLVector3 lPos;
571 Quaternion lRot;
572
573 lPos = this.Pos;
574 lRot = this.Rotation;
575
576 LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w);
577 RemoteClient.SendPrimTerseUpdate(this.m_regionHandle, 64096, this.LocalId, lPos, mRot);
578 }
579
580 /// <summary>
581 ///
582 /// </summary>
583 public void SendTerseUpdateToALLClients()
584 {
585 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
586 for (int i = 0; i < avatars.Count; i++)
587 {
588 this.SendTerseUpdateToClient(avatars[i].ControllingClient);
589 }
590 }
591
592 #endregion
593 }
594}
diff --git a/OpenSim/Region/Environment/Scenes/PrimitiveOld.cs b/OpenSim/Region/Environment/Scenes/PrimitiveOld.cs
new file mode 100644
index 0000000..91a4162
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/PrimitiveOld.cs
@@ -0,0 +1,583 @@
1
2/*
3* Copyright (c) Contributors, http://www.openmetaverse.org/
4* See CONTRIBUTORS.TXT for a full list of copyright holders.
5*
6* Redistribution and use in source and binary forms, with or without
7* modification, are permitted provided that the following conditions are met:
8* * Redistributions of source code must retain the above copyright
9* notice, this list of conditions and the following disclaimer.
10* * Redistributions in binary form must reproduce the above copyright
11* notice, this list of conditions and the following disclaimer in the
12* documentation and/or other materials provided with the distribution.
13* * Neither the name of the OpenSim Project nor the
14* names of its contributors may be used to endorse or promote products
15* derived from this software without specific prior written permission.
16*
17* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
18* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
21* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*
28*/
29using System;
30using System.Collections.Generic;
31using System.Text;
32using Axiom.Math;
33using libsecondlife;
34using libsecondlife.Packets;
35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework.Inventory;
37using OpenSim.Framework.Types;
38using OpenSim.Physics.Manager;
39
40namespace OpenSim.Region.Environment.Scenes
41{
42 public class PrimitiveOld : Entity
43 {
44 internal PrimData primData;
45 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
46 // private ClientManager m_clientThreads;
47 private ulong m_regionHandle;
48 private const uint FULL_MASK_PERMISSIONS = 2147483647;
49 private bool physicsEnabled = false;
50 private byte updateFlag = 0;
51 private uint flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128;
52
53 private Dictionary<LLUUID, InventoryItem> inventoryItems;
54
55 #region Properties
56
57 public LLVector3 Scale
58 {
59 set
60 {
61 this.primData.Scale = value;
62 //this.dirtyFlag = true;
63 }
64 get
65 {
66 return this.primData.Scale;
67 }
68 }
69
70 public PhysicsActor PhysActor
71 {
72 set
73 {
74 this._physActor = value;
75 }
76 }
77
78 public override LLVector3 Pos
79 {
80 get
81 {
82 return base.Pos;
83 }
84 set
85 {
86 base.Pos = value;
87 }
88 }
89 #endregion
90
91 /// <summary>
92 ///
93 /// </summary>
94 /// <param name="clientThreads"></param>
95 /// <param name="regionHandle"></param>
96 /// <param name="world"></param>
97 public PrimitiveOld( ulong regionHandle, Scene world)
98 {
99 // m_clientThreads = clientThreads;
100 m_regionHandle = regionHandle;
101 m_world = world;
102 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
103 }
104
105 /// <summary>
106 ///
107 /// </summary>
108 /// <param name="regionHandle"></param>
109 /// <param name="world"></param>
110 /// <param name="addPacket"></param>
111 /// <param name="ownerID"></param>
112 /// <param name="localID"></param>
113 public PrimitiveOld(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
114 {
115 // m_clientThreads = clientThreads;
116 m_regionHandle = regionHandle;
117 m_world = world;
118 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
119 this.CreateFromPacket(addPacket, ownerID, localID);
120 }
121
122 /// <summary>
123 ///
124 /// </summary>
125 /// <param name="clientThreads"></param>
126 /// <param name="regionHandle"></param>
127 /// <param name="world"></param>
128 /// <param name="owner"></param>
129 /// <param name="fullID"></param>
130 /// <param name="localID"></param>
131 public PrimitiveOld( ulong regionHandle, Scene world, LLUUID owner, LLUUID fullID, uint localID)
132 {
133 // m_clientThreads = clientThreads;
134 m_regionHandle = regionHandle;
135 m_world = world;
136 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
137 this.primData = new PrimData();
138 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
139 this.primData.OwnerID = owner;
140 this.primData.FullID = this.uuid = fullID;
141 this.primData.LocalID = m_localId = localID;
142 }
143
144 /// <summary>
145 /// Constructor to create a default cube
146 /// </summary>
147 /// <param name="clientThreads"></param>
148 /// <param name="regionHandle"></param>
149 /// <param name="world"></param>
150 /// <param name="owner"></param>
151 /// <param name="localID"></param>
152 /// <param name="position"></param>
153 public PrimitiveOld( ulong regionHandle, Scene world, LLUUID owner, uint localID, LLVector3 position)
154 {
155 //m_clientThreads = clientThreads;
156 m_regionHandle = regionHandle;
157 m_world = world;
158 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
159 this.primData = PrimData.DefaultCube();
160 this.primData.OwnerID = owner;
161 this.primData.LocalID = m_localId = localID;
162 this.Pos = this.primData.Position = position;
163
164 this.updateFlag = 1;
165 }
166
167 /// <summary>
168 ///
169 /// </summary>
170 /// <returns></returns>
171 public byte[] GetByteArray()
172 {
173 byte[] result = null;
174 List<byte[]> dataArrays = new List<byte[]>();
175 dataArrays.Add(primData.ToBytes());
176 foreach (Entity child in children)
177 {
178 if (child is PrimitiveOld)
179 {
180 dataArrays.Add(((PrimitiveOld)child).GetByteArray());
181 }
182 }
183 byte[] primstart = Helpers.StringToField("<Prim>");
184 byte[] primend = Helpers.StringToField("</Prim>");
185 int totalLength = primstart.Length + primend.Length;
186 for (int i = 0; i < dataArrays.Count; i++)
187 {
188 totalLength += dataArrays[i].Length;
189 }
190
191 result = new byte[totalLength];
192 int arraypos = 0;
193 Array.Copy(primstart, 0, result, 0, primstart.Length);
194 arraypos += primstart.Length;
195 for (int i = 0; i < dataArrays.Count; i++)
196 {
197 Array.Copy(dataArrays[i], 0, result, arraypos, dataArrays[i].Length);
198 arraypos += dataArrays[i].Length;
199 }
200 Array.Copy(primend, 0, result, arraypos, primend.Length);
201
202 return result;
203 }
204
205 #region Overridden Methods
206
207 /// <summary>
208 ///
209 /// </summary>
210 public override void update()
211 {
212 if (this.updateFlag == 1) // is a new prim just been created/reloaded
213 {
214 this.SendFullUpdateToAllClients();
215 this.updateFlag = 0;
216 }
217 if (this.updateFlag == 2) //some change has been made so update the clients
218 {
219 this.SendTerseUpdateToALLClients();
220 this.updateFlag = 0;
221 }
222 }
223
224 /// <summary>
225 ///
226 /// </summary>
227 public override void BackUp()
228 {
229
230 }
231
232 #endregion
233
234 #region Packet handlers
235
236 /// <summary>
237 ///
238 /// </summary>
239 /// <param name="pos"></param>
240 public void UpdatePosition(LLVector3 pos)
241 {
242 this.Pos = new LLVector3(pos.X, pos.Y, pos.Z);
243 this.updateFlag = 2;
244 }
245
246 /// <summary>
247 ///
248 /// </summary>
249 /// <param name="addPacket"></param>
250 public void UpdateShape(ObjectShapePacket.ObjectDataBlock updatePacket)
251 {
252 this.primData.PathBegin = updatePacket.PathBegin;
253 this.primData.PathEnd = updatePacket.PathEnd;
254 this.primData.PathScaleX = updatePacket.PathScaleX;
255 this.primData.PathScaleY = updatePacket.PathScaleY;
256 this.primData.PathShearX = updatePacket.PathShearX;
257 this.primData.PathShearY = updatePacket.PathShearY;
258 this.primData.PathSkew = updatePacket.PathSkew;
259 this.primData.ProfileBegin = updatePacket.ProfileBegin;
260 this.primData.ProfileEnd = updatePacket.ProfileEnd;
261 this.primData.PathCurve = updatePacket.PathCurve;
262 this.primData.ProfileCurve = updatePacket.ProfileCurve;
263 this.primData.ProfileHollow = updatePacket.ProfileHollow;
264 this.primData.PathRadiusOffset = updatePacket.PathRadiusOffset;
265 this.primData.PathRevolutions = updatePacket.PathRevolutions;
266 this.primData.PathTaperX = updatePacket.PathTaperX;
267 this.primData.PathTaperY = updatePacket.PathTaperY;
268 this.primData.PathTwist = updatePacket.PathTwist;
269 this.primData.PathTwistBegin = updatePacket.PathTwistBegin;
270 }
271
272 /// <summary>
273 ///
274 /// </summary>
275 /// <param name="tex"></param>
276 public void UpdateTexture(byte[] tex)
277 {
278 this.primData.TextureEntry = tex;
279 }
280
281 /// <summary>
282 ///
283 /// </summary>
284 /// <param name="pack"></param>
285 public void UpdateObjectFlags(ObjectFlagUpdatePacket pack)
286 {
287
288 }
289
290 /// <summary>
291 ///
292 /// </summary>
293 /// <param name="prim"></param>
294 public void AssignToParent(PrimitiveOld prim)
295 {
296
297 }
298
299 #endregion
300
301 # region Inventory Methods
302 /// <summary>
303 ///
304 /// </summary>
305 /// <param name="item"></param>
306 /// <returns></returns>
307 public bool AddToInventory(InventoryItem item)
308 {
309 return false;
310 }
311
312 /// <summary>
313 ///
314 /// </summary>
315 /// <param name="itemID"></param>
316 /// <returns></returns>
317 public InventoryItem RemoveFromInventory(LLUUID itemID)
318 {
319 return null;
320 }
321
322 /// <summary>
323 ///
324 /// </summary>
325 /// <param name="simClient"></param>
326 /// <param name="packet"></param>
327 public void RequestInventoryInfo(IClientAPI simClient, RequestTaskInventoryPacket packet)
328 {
329
330 }
331
332 /// <summary>
333 ///
334 /// </summary>
335 /// <param name="simClient"></param>
336 /// <param name="xferID"></param>
337 public void RequestXferInventory(IClientAPI simClient, ulong xferID)
338 {
339 //will only currently work if the total size of the inventory data array is under about 1000 bytes
340 SendXferPacketPacket send = new SendXferPacketPacket();
341
342 send.XferID.ID = xferID;
343 send.XferID.Packet = 1 + 2147483648;
344 send.DataPacket.Data = this.ConvertInventoryToBytes();
345
346 simClient.OutPacket(send);
347 }
348
349 /// <summary>
350 ///
351 /// </summary>
352 /// <returns></returns>
353 public byte[] ConvertInventoryToBytes()
354 {
355 Encoding enc = Encoding.ASCII;
356 byte[] result = new byte[0];
357 List<byte[]> inventoryData = new List<byte[]>();
358 int totallength = 0;
359 foreach (InventoryItem invItem in inventoryItems.Values)
360 {
361 byte[] data = enc.GetBytes(invItem.ExportString());
362 inventoryData.Add(data);
363 totallength += data.Length;
364 }
365 //TODO: copy arrays into the single result array
366
367 return result;
368 }
369
370 /// <summary>
371 ///
372 /// </summary>
373 /// <param name="data"></param>
374 public void CreateInventoryFromBytes(byte[] data)
375 {
376
377 }
378
379 #endregion
380
381 #region Update viewers Methods
382
383 /// <summary>
384 ///
385 /// </summary>
386 /// <param name="remoteClient"></param>
387 public void SendFullUpdateForAllChildren(IClientAPI remoteClient)
388 {
389 this.SendFullUpdateToClient(remoteClient);
390 for (int i = 0; i < this.children.Count; i++)
391 {
392 if (this.children[i] is PrimitiveOld)
393 {
394 ((PrimitiveOld)this.children[i]).SendFullUpdateForAllChildren(remoteClient);
395 }
396 }
397 }
398
399 /// <summary>
400 ///
401 /// </summary>
402 /// <param name="remoteClient"></param>
403 public void SendFullUpdateToClient(IClientAPI remoteClient)
404 {
405 LLVector3 lPos;
406 if (this._physActor != null && this.physicsEnabled)
407 {
408 PhysicsVector pPos = this._physActor.Position;
409 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
410 }
411 else
412 {
413 lPos = this.Pos;
414 }
415
416 remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.primData, lPos, new LLUUID("00000000-0000-0000-9999-000000000005"), this.flags);
417 }
418
419 /// <summary>
420 ///
421 /// </summary>
422 public void SendFullUpdateToAllClients()
423 {
424 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
425 for (int i = 0; i < avatars.Count; i++)
426 {
427 this.SendFullUpdateToClient(avatars[i].ControllingClient);
428 }
429 }
430
431 /// <summary>
432 ///
433 /// </summary>
434 /// <param name="RemoteClient"></param>
435 public void SendTerseUpdateToClient(IClientAPI RemoteClient)
436 {
437 LLVector3 lPos;
438 Quaternion lRot;
439 if (this._physActor != null && this.physicsEnabled) //is this needed ? doesn't the property fields do this for us?
440 {
441 PhysicsVector pPos = this._physActor.Position;
442 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
443 lRot = this._physActor.Orientation;
444 }
445 else
446 {
447 lPos = this.Pos;
448 lRot = this.Rotation;
449 }
450 LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w);
451 RemoteClient.SendPrimTerseUpdate(this.m_regionHandle, 64096, this.LocalId, lPos, mRot);
452 }
453
454 /// <summary>
455 ///
456 /// </summary>
457 public void SendTerseUpdateToALLClients()
458 {
459 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
460 for (int i = 0; i < avatars.Count; i++)
461 {
462 this.SendTerseUpdateToClient(avatars[i].ControllingClient);
463 }
464 }
465
466 #endregion
467
468 #region Create Methods
469
470 /// <summary>
471 ///
472 /// </summary>
473 /// <param name="addPacket"></param>
474 /// <param name="ownerID"></param>
475 /// <param name="localID"></param>
476 public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
477 {
478 PrimData PData = new PrimData();
479 this.primData = PData;
480 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
481
482 PData.OwnerID = ownerID;
483 PData.PCode = addPacket.ObjectData.PCode;
484 PData.PathBegin = addPacket.ObjectData.PathBegin;
485 PData.PathEnd = addPacket.ObjectData.PathEnd;
486 PData.PathScaleX = addPacket.ObjectData.PathScaleX;
487 PData.PathScaleY = addPacket.ObjectData.PathScaleY;
488 PData.PathShearX = addPacket.ObjectData.PathShearX;
489 PData.PathShearY = addPacket.ObjectData.PathShearY;
490 PData.PathSkew = addPacket.ObjectData.PathSkew;
491 PData.ProfileBegin = addPacket.ObjectData.ProfileBegin;
492 PData.ProfileEnd = addPacket.ObjectData.ProfileEnd;
493 PData.Scale = addPacket.ObjectData.Scale;
494 PData.PathCurve = addPacket.ObjectData.PathCurve;
495 PData.ProfileCurve = addPacket.ObjectData.ProfileCurve;
496 PData.ParentID = 0;
497 PData.ProfileHollow = addPacket.ObjectData.ProfileHollow;
498 PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
499 PData.PathRevolutions = addPacket.ObjectData.PathRevolutions;
500 PData.PathTaperX = addPacket.ObjectData.PathTaperX;
501 PData.PathTaperY = addPacket.ObjectData.PathTaperY;
502 PData.PathTwist = addPacket.ObjectData.PathTwist;
503 PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
504 LLVector3 pos1 = addPacket.ObjectData.RayEnd;
505 this.primData.FullID = this.uuid = LLUUID.Random();
506 this.primData.LocalID = m_localId = (uint)(localID);
507 this.primData.Position = this.Pos = pos1;
508
509 this.updateFlag = 1;
510 }
511
512 /// <summary>
513 ///
514 /// </summary>
515 /// <param name="data"></param>
516 public void CreateFromBytes(byte[] data)
517 {
518
519 }
520
521 /// <summary>
522 ///
523 /// </summary>
524 /// <param name="primData"></param>
525 public void CreateFromPrimData(PrimData primData)
526 {
527 this.CreateFromPrimData(primData, primData.Position, primData.LocalID, false);
528 }
529
530 /// <summary>
531 ///
532 /// </summary>
533 /// <param name="primData"></param>
534 /// <param name="posi"></param>
535 /// <param name="localID"></param>
536 /// <param name="newprim"></param>
537 public void CreateFromPrimData(PrimData primData, LLVector3 posi, uint localID, bool newprim)
538 {
539
540 }
541
542 public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
543 {
544 // Console.WriteLine("moving prim to new location " + pos.X + " , " + pos.Y + " , " + pos.Z);
545 this.Pos = pos;
546 this.SendTerseUpdateToALLClients();
547 }
548
549 public void GetProperites(IClientAPI client)
550 {
551 //needs changing
552 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
553 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
554 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
555 proper.ObjectData[0].ItemID = LLUUID.Zero;
556 proper.ObjectData[0].CreationDate = (ulong)primData.CreationDate;
557 proper.ObjectData[0].CreatorID = primData.OwnerID;
558 proper.ObjectData[0].FolderID = LLUUID.Zero;
559 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
560 proper.ObjectData[0].GroupID = LLUUID.Zero;
561 proper.ObjectData[0].InventorySerial = 0;
562 proper.ObjectData[0].LastOwnerID = LLUUID.Zero;
563 proper.ObjectData[0].ObjectID = this.uuid;
564 proper.ObjectData[0].OwnerID = primData.OwnerID;
565 proper.ObjectData[0].TouchName = new byte[0];
566 proper.ObjectData[0].TextureID = new byte[0];
567 proper.ObjectData[0].SitName = new byte[0];
568 proper.ObjectData[0].Name = new byte[0];
569 proper.ObjectData[0].Description = new byte[0];
570 proper.ObjectData[0].OwnerMask = primData.OwnerMask;
571 proper.ObjectData[0].NextOwnerMask = primData.NextOwnerMask;
572 proper.ObjectData[0].GroupMask = primData.GroupMask;
573 proper.ObjectData[0].EveryoneMask = primData.EveryoneMask;
574 proper.ObjectData[0].BaseMask = primData.BaseMask;
575
576 client.OutPacket(proper);
577
578 }
579
580 #endregion
581
582 }
583}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
new file mode 100644
index 0000000..69eaa75
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
@@ -0,0 +1,570 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
31using libsecondlife.Packets;
32using OpenSim.Framework.Interfaces;
33using OpenSim.Framework.Types;
34
35namespace OpenSim.Region.Environment.Scenes
36{
37 public partial class Scene
38 {
39 /// <summary>
40 /// Modifies terrain using the specified information
41 /// </summary>
42 /// <param name="height">The height at which the user started modifying the terrain</param>
43 /// <param name="seconds">The number of seconds the modify button was pressed</param>
44 /// <param name="brushsize">The size of the brush used</param>
45 /// <param name="action">The action to be performed</param>
46 /// <param name="north">Distance from the north border where the cursor is located</param>
47 /// <param name="west">Distance from the west border where the cursor is located</param>
48 public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west)
49 {
50 // Shiny.
51 double size = (double)(1 << brushsize);
52
53 switch (action)
54 {
55 case 0:
56 // flatten terrain
57 Terrain.flatten(north, west, size, (double)seconds / 100.0);
58 RegenerateTerrain(true, (int)north, (int)west);
59 break;
60 case 1:
61 // raise terrain
62 Terrain.raise(north, west, size, (double)seconds / 100.0);
63 RegenerateTerrain(true, (int)north, (int)west);
64 break;
65 case 2:
66 //lower terrain
67 Terrain.lower(north, west, size, (double)seconds / 100.0);
68 RegenerateTerrain(true, (int)north, (int)west);
69 break;
70 case 3:
71 // smooth terrain
72 Terrain.smooth(north, west, size, (double)seconds / 100.0);
73 RegenerateTerrain(true, (int)north, (int)west);
74 break;
75 case 4:
76 // noise
77 Terrain.noise(north, west, size, (double)seconds / 100.0);
78 RegenerateTerrain(true, (int)north, (int)west);
79 break;
80 case 5:
81 // revert
82 Terrain.revert(north, west, size, (double)seconds / 100.0);
83 RegenerateTerrain(true, (int)north, (int)west);
84 break;
85
86 // CLIENT EXTENSIONS GO HERE
87 case 128:
88 // erode-thermal
89 break;
90 case 129:
91 // erode-aerobic
92 break;
93 case 130:
94 // erode-hydraulic
95 break;
96 }
97 return;
98 }
99
100 /// <summary>
101 ///
102 /// </summary>
103 /// <remarks>Inefficient. TODO: Fixme</remarks>
104 /// <param name="fromAgentID"></param>
105 /// <param name="toAgentID"></param>
106 /// <param name="timestamp"></param>
107 /// <param name="fromAgentName"></param>
108 /// <param name="message"></param>
109 public void InstantMessage(LLUUID fromAgentID, LLUUID toAgentID, uint timestamp, string fromAgentName, string message)
110 {
111 if (this.Avatars.ContainsKey(toAgentID))
112 {
113 if (this.Avatars.ContainsKey(fromAgentID))
114 {
115 // Local sim message
116 ScenePresence avatar = this.Avatars[fromAgentID];
117 avatar.ControllingClient.SendInstantMessage(message, toAgentID);
118 }
119 else
120 {
121 // Message came from a user outside the sim, ignore?
122 }
123 }
124 else
125 {
126 // Grid message
127 }
128 }
129
130 /// <summary>
131 ///
132 /// </summary>
133 /// <param name="message"></param>
134 /// <param name="type"></param>
135 /// <param name="fromPos"></param>
136 /// <param name="fromName"></param>
137 /// <param name="fromAgentID"></param>
138 public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
139 {
140 // Console.WriteLine("Chat message");
141 ScenePresence avatar = null;
142
143 m_clientManager.ForEachClient(delegate(IClientAPI client)
144 {
145 int dis = -1000;
146 if (this.Avatars.ContainsKey(client.AgentId))
147 {
148 avatar = this.Avatars[client.AgentId];
149 // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y));
150 dis = (int) avatar.Pos.GetDistanceTo(fromPos);
151 //Console.WriteLine("found avatar at " +dis);
152 }
153
154 switch (type)
155 {
156 case 0: // Whisper
157 if ((dis < 10) && (dis > -10))
158 {
159 //should change so the message is sent through the avatar rather than direct to the ClientView
160 client.SendChatMessage(message, type, fromPos, fromName,
161 fromAgentID);
162 }
163 break;
164 case 1: // Say
165 if ((dis < 30) && (dis > -30))
166 {
167 //Console.WriteLine("sending chat");
168 client.SendChatMessage(message, type, fromPos, fromName,
169 fromAgentID);
170 }
171 break;
172 case 2: // Shout
173 if ((dis < 100) && (dis > -100))
174 {
175 client.SendChatMessage(message, type, fromPos, fromName,
176 fromAgentID);
177 }
178 break;
179
180 case 0xff: // Broadcast
181 client.SendChatMessage(message, type, fromPos, fromName,
182 fromAgentID);
183 break;
184 }
185 });
186 }
187
188 /// <summary>
189 ///
190 /// </summary>
191 /// <param name="primAsset"></param>
192 /// <param name="pos"></param>
193 public void RezObject(AssetBase primAsset, LLVector3 pos)
194 {
195
196 }
197
198 /// <summary>
199 ///
200 /// </summary>
201 /// <param name="packet"></param>
202 /// <param name="simClient"></param>
203 public void DeRezObject(Packet packet, IClientAPI simClient)
204 {
205
206 }
207
208 /// <summary>
209 ///
210 /// </summary>
211 /// <param name="remoteClient"></param>
212 public void SendAvatarsToClient(IClientAPI remoteClient)
213 {
214
215 }
216
217 /// <summary>
218 ///
219 /// </summary>
220 /// <param name="originalPrim"></param>
221 /// <param name="offset"></param>
222 /// <param name="flags"></param>
223 public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags)
224 {
225 SceneObject originPrim = null;
226 foreach (EntityBase ent in Entities.Values)
227 {
228 if (ent is SceneObject)
229 {
230 if (((SceneObject)ent).rootLocalID == originalPrim)
231 {
232 originPrim = (SceneObject)ent;
233 break;
234 }
235 }
236 }
237
238 if (originPrim != null)
239 {
240 //SceneObject copy = originPrim.Copy();
241
242 }
243 else
244 {
245 OpenSim.Framework.Console.MainLog.Instance.Warn("Attempted to duplicate nonexistant prim");
246 }
247
248 }
249
250 /// <summary>
251 ///
252 /// </summary>
253 /// <param name="parentPrim"></param>
254 /// <param name="childPrims"></param>
255 public void LinkObjects(uint parentPrim, List<uint> childPrims)
256 {
257 SceneObject parenPrim = null;
258 foreach (EntityBase ent in Entities.Values)
259 {
260 if (ent is SceneObject)
261 {
262 if (((SceneObject)ent).rootLocalID == parentPrim)
263 {
264 parenPrim = (SceneObject)ent;
265 break;
266 }
267 }
268 }
269
270 List<SceneObject> children = new List<SceneObject>();
271 if (parenPrim != null)
272 {
273 for (int i = 0; i < childPrims.Count; i++)
274 {
275 foreach (EntityBase ent in Entities.Values)
276 {
277 if (ent is SceneObject)
278 {
279 if (((SceneObject)ent).rootLocalID == childPrims[i])
280 {
281 children.Add((SceneObject)ent);
282 }
283 }
284 }
285 }
286 }
287
288 foreach (SceneObject sceneObj in children)
289 {
290 parenPrim.AddNewChildPrims(sceneObj);
291 }
292 }
293
294 /// <summary>
295 ///
296 /// </summary>
297 /// <param name="primLocalID"></param>
298 /// <param name="shapeBlock"></param>
299 public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock)
300 {
301 Primitive prim = null;
302 foreach (EntityBase ent in Entities.Values)
303 {
304 if (ent is SceneObject)
305 {
306 prim = ((SceneObject)ent).HasChildPrim(primLocalID);
307 if (prim != null)
308 {
309 prim.UpdateShape(shapeBlock);
310 break;
311 }
312 }
313 }
314 }
315
316 /// <summary>
317 ///
318 /// </summary>
319 /// <param name="primLocalID"></param>
320 /// <param name="remoteClient"></param>
321 public void SelectPrim(uint primLocalID, IClientAPI remoteClient)
322 {
323 foreach (EntityBase ent in Entities.Values)
324 {
325 if (ent is SceneObject)
326 {
327 if (((SceneObject)ent).rootLocalID == primLocalID)
328 {
329 ((SceneObject)ent).GetProperites(remoteClient);
330 break;
331 }
332 }
333 }
334 }
335
336 /// <summary>
337 ///
338 /// </summary>
339 /// <param name="primLocalID"></param>
340 /// <param name="description"></param>
341 public void PrimDescription(uint primLocalID, string description)
342 {
343 Primitive prim = null;
344 foreach (EntityBase ent in Entities.Values)
345 {
346 if (ent is SceneObject)
347 {
348 prim = ((SceneObject)ent).HasChildPrim(primLocalID);
349 if (prim != null)
350 {
351 prim.Description = description;
352 break;
353 }
354 }
355 }
356 }
357
358 /// <summary>
359 ///
360 /// </summary>
361 /// <param name="primLocalID"></param>
362 /// <param name="description"></param>
363 public void PrimName(uint primLocalID, string name)
364 {
365 Primitive prim = null;
366 foreach (EntityBase ent in Entities.Values)
367 {
368 if (ent is SceneObject)
369 {
370 prim = ((SceneObject)ent).HasChildPrim(primLocalID);
371 if (prim != null)
372 {
373 prim.Name = name;
374 break;
375 }
376 }
377 }
378 }
379
380 public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
381 {
382 Primitive prim = null;
383 foreach (EntityBase ent in Entities.Values)
384 {
385 if (ent is SceneObject)
386 {
387 prim = ((SceneObject)ent).HasChildPrim(objectID);
388 if (prim != null)
389 {
390 ((SceneObject)ent).GrapMovement(offset, pos, remoteClient);
391 break;
392 }
393 }
394 }
395 /*
396 if (this.Entities.ContainsKey(objectID))
397 {
398 if (this.Entities[objectID] is SceneObject)
399 {
400 ((SceneObject)this.Entities[objectID]).GrapMovement(offset, pos, remoteClient);
401 }
402 }*/
403 }
404
405 /// <summary>
406 ///
407 /// </summary>
408 /// <param name="localID"></param>
409 /// <param name="packet"></param>
410 /// <param name="remoteClient"></param>
411 public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient)
412 {
413
414 }
415
416 /// <summary>
417 ///
418 /// </summary>
419 /// <param name="localID"></param>
420 /// <param name="texture"></param>
421 /// <param name="remoteClient"></param>
422 public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient)
423 {
424
425 }
426
427 /// <summary>
428 ///
429 /// </summary>
430 /// <param name="localID"></param>
431 /// <param name="pos"></param>
432 /// <param name="remoteClient"></param>
433 public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient)
434 {
435 Primitive prim = null;
436 foreach (EntityBase ent in Entities.Values)
437 {
438 if (ent is SceneObject)
439 {
440 prim = ((SceneObject)ent).HasChildPrim(localID);
441 if (prim != null)
442 {
443 prim.UpdateGroupPosition(pos);
444 break;
445 }
446 }
447 }
448 }
449
450 public void UpdatePrimSinglePosition(uint localID, LLVector3 pos, IClientAPI remoteClient)
451 {
452 Primitive prim = null;
453 foreach (EntityBase ent in Entities.Values)
454 {
455 if (ent is SceneObject)
456 {
457 prim = ((SceneObject)ent).HasChildPrim(localID);
458 if (prim != null)
459 {
460 prim.UpdateSinglePosition(pos);
461 break;
462 }
463 }
464 }
465 }
466
467 /// <summary>
468 ///
469 /// </summary>
470 /// <param name="localID"></param>
471 /// <param name="pos"></param>
472 /// <param name="rot"></param>
473 /// <param name="remoteClient"></param>
474 public void UpdatePrimRotation(uint localID, LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient)
475 {
476 Primitive prim = null;
477 foreach (EntityBase ent in Entities.Values)
478 {
479 if (ent is SceneObject)
480 {
481 prim = ((SceneObject)ent).HasChildPrim(localID);
482 if (prim != null)
483 {
484 prim.UpdateGroupMouseRotation( pos, rot);
485 break;
486 }
487 }
488 }
489 }
490
491 /// <summary>
492 ///
493 /// </summary>
494 /// <param name="localID"></param>
495 /// <param name="rot"></param>
496 /// <param name="remoteClient"></param>
497 public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient)
498 {
499 Primitive prim = null;
500 foreach (EntityBase ent in Entities.Values)
501 {
502 if (ent is SceneObject)
503 {
504 prim = ((SceneObject)ent).HasChildPrim(localID);
505 if (prim != null)
506 {
507 prim.UpdateGroupRotation(rot);
508 break;
509 }
510 }
511 }
512 }
513
514 /// <summary>
515 ///
516 /// </summary>
517 /// <param name="localID"></param>
518 /// <param name="rot"></param>
519 /// <param name="remoteClient"></param>
520 public void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient)
521 {
522 //Console.WriteLine("trying to update single prim rotation");
523 Primitive prim = null;
524 foreach (EntityBase ent in Entities.Values)
525 {
526 if (ent is SceneObject)
527 {
528 prim = ((SceneObject)ent).HasChildPrim(localID);
529 if (prim != null)
530 {
531 prim.UpdateSingleRotation(rot);
532 break;
533 }
534 }
535 }
536 }
537
538 /// <summary>
539 ///
540 /// </summary>
541 /// <param name="localID"></param>
542 /// <param name="scale"></param>
543 /// <param name="remoteClient"></param>
544 public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient)
545 {
546 Primitive prim = null;
547 foreach (EntityBase ent in Entities.Values)
548 {
549 if (ent is SceneObject)
550 {
551 prim = ((SceneObject)ent).HasChildPrim(localID);
552 if (prim != null)
553 {
554 prim.ResizeGoup(scale);
555 break;
556 }
557 }
558 }
559 }
560
561 /// <summary>
562 /// Sends prims to a client
563 /// </summary>
564 /// <param name="RemoteClient">Client to send to</param>
565 public void GetInitialPrims(IClientAPI RemoteClient)
566 {
567
568 }
569 }
570}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
new file mode 100644
index 0000000..d1f6038
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -0,0 +1,806 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Threading;
31using System.Timers;
32using libsecondlife;
33using libsecondlife.Packets;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Console;
37using OpenSim.Framework.Interfaces;
38using OpenSim.Framework.Servers;
39using OpenSim.Framework.Types;
40using OpenSim.Physics.Manager;
41using OpenSim.Region.Caches;
42using OpenSim.Region.Environment.Scripting;
43using OpenSim.Region.Terrain;
44using Caps=OpenSim.Region.Capabilities.Caps;
45using Timer=System.Timers.Timer;
46
47namespace OpenSim.Region.Environment.Scenes
48{
49 public delegate bool FilterAvatarList(ScenePresence avatar);
50
51 public partial class Scene : SceneBase, ILocalStorageReceiver
52 {
53 protected Timer m_heartbeatTimer = new Timer();
54 protected Dictionary<LLUUID, ScenePresence> Avatars;
55 protected Dictionary<LLUUID, SceneObject> Prims;
56 private PhysicsScene phyScene;
57 private float timeStep = 0.1f;
58 private Random Rand = new Random();
59 private uint _primCount = 702000;
60 private System.Threading.Mutex _primAllocateMutex = new Mutex(false);
61 private int storageCount;
62 private Mutex updateLock;
63
64 protected AuthenticateSessionsBase authenticateHandler;
65 protected RegionCommsListener regionCommsHost;
66 protected CommunicationsManager commsManager;
67
68 protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>();
69 protected BaseHttpServer httpListener;
70
71 public ParcelManager parcelManager;
72 public EstateManager estateManager;
73 public EventManager eventManager;
74 public ScriptManager scriptManager;
75
76 #region Properties
77 /// <summary>
78 ///
79 /// </summary>
80 public PhysicsScene PhysScene
81 {
82 set
83 {
84 this.phyScene = value;
85 }
86 get
87 {
88 return (this.phyScene);
89 }
90 }
91
92 #endregion
93
94 #region Constructors
95 /// <summary>
96 /// Creates a new World class, and a region to go with it.
97 /// </summary>
98 /// <param name="clientThreads">Dictionary to contain client threads</param>
99 /// <param name="regionHandle">Region Handle for this region</param>
100 /// <param name="regionName">Region Name for this region</param>
101 public Scene(ClientManager clientManager, RegionInfo regInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer)
102 {
103 updateLock = new Mutex(false);
104 this.authenticateHandler = authen;
105 this.commsManager = commsMan;
106 this.assetCache = assetCach;
107 m_clientManager = clientManager;
108 m_regInfo = regInfo;
109 m_regionHandle = m_regInfo.RegionHandle;
110 m_regionName = m_regInfo.RegionName;
111 this.m_datastore = m_regInfo.DataStore;
112 this.RegisterRegionWithComms();
113
114 parcelManager = new ParcelManager(this, this.m_regInfo);
115 estateManager = new EstateManager(this, this.m_regInfo);
116 scriptManager = new ScriptManager(this);
117 eventManager = new EventManager();
118
119 MainLog.Instance.Verbose("World.cs - creating new entitities instance");
120 Entities = new Dictionary<LLUUID, EntityBase>();
121 Avatars = new Dictionary<LLUUID, ScenePresence>();
122 Prims = new Dictionary<LLUUID, SceneObject>();
123
124 MainLog.Instance.Verbose("World.cs - creating LandMap");
125 Terrain = new TerrainEngine();
126
127 ScenePresence.LoadAnims();
128 this.httpListener = httpServer;
129 }
130 #endregion
131
132 /// <summary>
133 ///
134 /// </summary>
135 public void StartTimer()
136 {
137 m_heartbeatTimer.Enabled = true;
138 m_heartbeatTimer.Interval = 100;
139 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
140 }
141
142
143 #region Update Methods
144
145
146 /// <summary>
147 /// Performs per-frame updates regularly
148 /// </summary>
149 /// <param name="sender"></param>
150 /// <param name="e"></param>
151 void Heartbeat(object sender, EventArgs e)
152 {
153 this.Update();
154 }
155
156 /// <summary>
157 /// Performs per-frame updates on the world, this should be the central world loop
158 /// </summary>
159 public override void Update()
160 {
161 updateLock.WaitOne();
162 try
163 {
164 if (this.phyScene.IsThreaded)
165 {
166 this.phyScene.GetResults();
167
168 }
169
170 foreach (LLUUID UUID in Entities.Keys)
171 {
172 Entities[UUID].updateMovement();
173 }
174
175 lock (this.m_syncRoot)
176 {
177 this.phyScene.Simulate(timeStep);
178 }
179
180 foreach (LLUUID UUID in Entities.Keys)
181 {
182 Entities[UUID].update();
183 }
184
185 // General purpose event manager
186 eventManager.TriggerOnFrame();
187
188 //backup world data
189 this.storageCount++;
190 if (storageCount > 1200) //set to how often you want to backup
191 {
192 this.Backup();
193 storageCount = 0;
194 }
195 }
196 catch (Exception e)
197 {
198 MainLog.Instance.Warn("World.cs: Update() - Failed with exception " + e.ToString());
199 }
200 updateLock.ReleaseMutex();
201
202 }
203
204 /// <summary>
205 ///
206 /// </summary>
207 /// <returns></returns>
208 public bool Backup()
209 {
210
211 return true;
212 }
213 #endregion
214
215 #region Regenerate Terrain
216
217 /// <summary>
218 /// Rebuilds the terrain using a procedural algorithm
219 /// </summary>
220 public void RegenerateTerrain()
221 {
222 try
223 {
224 Terrain.hills();
225
226 lock (this.m_syncRoot)
227 {
228 this.phyScene.SetTerrain(Terrain.getHeights1D());
229 }
230 this.localStorage.SaveMap(this.Terrain.getHeights1D());
231
232 m_clientManager.ForEachClient(delegate(IClientAPI client)
233 {
234 this.SendLayerData(client);
235 });
236
237 foreach (LLUUID UUID in Entities.Keys)
238 {
239 Entities[UUID].LandRenegerated();
240 }
241 }
242 catch (Exception e)
243 {
244 MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
245 }
246 }
247
248 /// <summary>
249 /// Rebuilds the terrain using a 2D float array
250 /// </summary>
251 /// <param name="newMap">256,256 float array containing heights</param>
252 public void RegenerateTerrain(float[,] newMap)
253 {
254 try
255 {
256 this.Terrain.setHeights2D(newMap);
257 lock (this.m_syncRoot)
258 {
259 this.phyScene.SetTerrain(this.Terrain.getHeights1D());
260 }
261 this.localStorage.SaveMap(this.Terrain.getHeights1D());
262
263 m_clientManager.ForEachClient(delegate(IClientAPI client)
264 {
265 this.SendLayerData(client);
266 });
267
268 foreach (LLUUID UUID in Entities.Keys)
269 {
270 Entities[UUID].LandRenegerated();
271 }
272 }
273 catch (Exception e)
274 {
275 MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
276 }
277 }
278
279 /// <summary>
280 /// Rebuilds the terrain assuming changes occured at a specified point[?]
281 /// </summary>
282 /// <param name="changes">???</param>
283 /// <param name="pointx">???</param>
284 /// <param name="pointy">???</param>
285 public void RegenerateTerrain(bool changes, int pointx, int pointy)
286 {
287 try
288 {
289 if (changes)
290 {
291 /* Dont save here, rely on tainting system instead */
292
293 m_clientManager.ForEachClient(delegate(IClientAPI client)
294 {
295 this.SendLayerData(pointx, pointy, client);
296 });
297 }
298 }
299 catch (Exception e)
300 {
301 MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
302 }
303 }
304
305 #endregion
306
307 #region Load Terrain
308 /// <summary>
309 /// Loads the World heightmap
310 /// </summary>
311 ///
312 public override void LoadWorldMap()
313 {
314 try
315 {
316 float[] map = this.localStorage.LoadWorld();
317 if (map == null)
318 {
319 if (string.IsNullOrEmpty(this.m_regInfo.estateSettings.terrainFile))
320 {
321 Console.WriteLine("No default terrain, procedurally generating...");
322 this.Terrain.hills();
323
324 this.localStorage.SaveMap(this.Terrain.getHeights1D());
325 }
326 else
327 {
328 try
329 {
330 this.Terrain.loadFromFileF32(this.m_regInfo.estateSettings.terrainFile);
331 this.Terrain *= this.m_regInfo.estateSettings.terrainMultiplier;
332 }
333 catch
334 {
335 Console.WriteLine("Unable to load default terrain, procedurally generating instead...");
336 Terrain.hills();
337 }
338 this.localStorage.SaveMap(this.Terrain.getHeights1D());
339 }
340 }
341 else
342 {
343 this.Terrain.setHeights1D(map);
344 }
345
346 CreateTerrainTexture();
347
348 }
349 catch (Exception e)
350 {
351 MainLog.Instance.Warn("World.cs: LoadWorldMap() - Failed with exception " + e.ToString());
352 }
353 }
354
355 /// <summary>
356 ///
357 /// </summary>
358 private void CreateTerrainTexture()
359 {
360 //create a texture asset of the terrain
361 byte[] data = this.Terrain.exportJpegImage("defaultstripe.png");
362 this.m_regInfo.estateSettings.terrainImageID = LLUUID.Random();
363 AssetBase asset = new AssetBase();
364 asset.FullID = this.m_regInfo.estateSettings.terrainImageID;
365 asset.Data = data;
366 asset.Name = "terrainImage";
367 asset.Type = 0;
368 this.assetCache.AddAsset(asset);
369 }
370 #endregion
371
372 #region Primitives Methods
373
374
375 /// <summary>
376 /// Loads the World's objects
377 /// </summary>
378 public void LoadPrimsFromStorage()
379 {
380 try
381 {
382 MainLog.Instance.Verbose("World.cs: LoadPrimsFromStorage() - Loading primitives");
383 this.localStorage.LoadPrimitives(this);
384 }
385 catch (Exception e)
386 {
387 MainLog.Instance.Warn("World.cs: LoadPrimsFromStorage() - Failed with exception " + e.ToString());
388 }
389 }
390
391 /// <summary>
392 /// Loads a specific object from storage
393 /// </summary>
394 /// <param name="prim">The object to load</param>
395 public void PrimFromStorage(PrimData prim)
396 {
397
398 }
399
400 /// <summary>
401 /// Returns a new unallocated primitive ID
402 /// </summary>
403 /// <returns>A brand new primitive ID</returns>
404 public uint PrimIDAllocate()
405 {
406 uint myID;
407
408 _primAllocateMutex.WaitOne();
409 ++_primCount;
410 myID = _primCount;
411 _primAllocateMutex.ReleaseMutex();
412
413 return myID;
414 }
415
416 /// <summary>
417 ///
418 /// </summary>
419 /// <param name="addPacket"></param>
420 /// <param name="agentClient"></param>
421 public void AddNewPrim(Packet addPacket, IClientAPI agentClient)
422 {
423 AddNewPrim((ObjectAddPacket)addPacket, agentClient.AgentId);
424 }
425
426 /// <summary>
427 ///
428 /// </summary>
429 /// <param name="addPacket"></param>
430 /// <param name="ownerID"></param>
431 public void AddNewPrim(ObjectAddPacket addPacket, LLUUID ownerID)
432 {
433 try
434 {
435 SceneObject sceneOb = new SceneObject(m_regionHandle, this, addPacket, ownerID, this.PrimIDAllocate());
436 this.Entities.Add(sceneOb.rootUUID, sceneOb);
437
438 // Trigger event for listeners
439 // eventManager.TriggerOnNewPrimitive(prim);
440 }
441 catch (Exception e)
442 {
443 MainLog.Instance.Warn("World.cs: AddNewPrim() - Failed with exception " + e.ToString());
444 }
445 }
446
447 public override uint AddNewPrim(LLUUID ownerId, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID texture, int flags)
448 {
449 uint id = NextLocalId;
450
451 throw new NotImplementedException("Not implemented yet.");
452 }
453
454 #endregion
455
456 #region Add/Remove Avatar Methods
457
458 /// <summary>
459 ///
460 /// </summary>
461 /// <param name="remoteClient"></param
462 /// <param name="agentID"></param>
463 /// <param name="child"></param>
464 public override void AddNewClient(IClientAPI client, bool child)
465 {
466 client.OnRegionHandShakeReply += this.SendLayerData;
467 //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims);
468 client.OnChatFromViewer += this.SimChat;
469 client.OnInstantMessage += this.InstantMessage;
470 client.OnRequestWearables += this.InformClientOfNeighbours;
471 client.OnAddPrim += this.AddNewPrim;
472 client.OnUpdatePrimGroupPosition += this.UpdatePrimPosition;
473 client.OnUpdatePrimSinglePosition += this.UpdatePrimSinglePosition;
474 client.OnUpdatePrimGroupRotation += this.UpdatePrimRotation;
475 client.OnUpdatePrimGroupMouseRotation += this.UpdatePrimRotation;
476 client.OnUpdatePrimSingleRotation += this.UpdatePrimSingleRotation;
477 client.OnUpdatePrimScale += this.UpdatePrimScale;
478 client.OnUpdatePrimShape += this.UpdatePrimShape;
479 client.OnRequestMapBlocks += this.RequestMapBlocks;
480 client.OnTeleportLocationRequest += this.RequestTeleportLocation;
481 client.OnObjectSelect += this.SelectPrim;
482 client.OnGrapUpdate += this.MoveObject;
483 client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest;
484 client.OnObjectDescription += this.PrimDescription;
485 client.OnObjectName += this.PrimName;
486 client.OnLinkObjects += this.LinkObjects;
487 client.OnObjectDuplicate += this.DuplicateObject;
488
489 /* remoteClient.OnParcelPropertiesRequest += new ParcelPropertiesRequest(parcelManager.handleParcelPropertiesRequest);
490 remoteClient.OnParcelDivideRequest += new ParcelDivideRequest(parcelManager.handleParcelDivideRequest);
491 remoteClient.OnParcelJoinRequest += new ParcelJoinRequest(parcelManager.handleParcelJoinRequest);
492 remoteClient.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(parcelManager.handleParcelPropertiesUpdateRequest);
493 remoteClient.OnEstateOwnerMessage += new EstateOwnerMessageRequest(estateManager.handleEstateOwnerMessage);
494 */
495 this.estateManager.sendRegionHandshake(client);
496
497 CreateAndAddScenePresence(client);
498 return;
499 }
500
501 protected void CreateAndAddScenePresence(IClientAPI client)
502 {
503 ScenePresence newAvatar = null;
504
505 MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
506 newAvatar = new ScenePresence(client, this, this.m_regInfo);
507 MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Adding new avatar to world");
508 MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Starting RegionHandshake ");
509
510 PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z);
511 lock (this.m_syncRoot)
512 {
513 newAvatar.PhysActor = this.phyScene.AddAvatar(pVec);
514 }
515
516 lock (Entities)
517 {
518 if (!Entities.ContainsKey(client.AgentId))
519 {
520 this.Entities.Add(client.AgentId, newAvatar);
521 }
522 else
523 {
524 Entities[client.AgentId] = newAvatar;
525 }
526 }
527 lock (Avatars)
528 {
529 if (Avatars.ContainsKey(client.AgentId))
530 {
531 Avatars[client.AgentId] = newAvatar;
532 }
533 else
534 {
535 this.Avatars.Add(client.AgentId, newAvatar);
536 }
537 }
538 }
539
540
541 /// <summary>
542 ///
543 /// </summary>
544 /// <param name="agentID"></param>
545 public override void RemoveClient(LLUUID agentID)
546 {
547 eventManager.TriggerOnRemovePresence(agentID);
548
549 ScenePresence avatar = this.RequestAvatar(agentID);
550
551 m_clientManager.ForEachClient(
552 delegate(IClientAPI client)
553 {
554 client.SendKillObject(avatar.RegionHandle, avatar.LocalId);
555 });
556
557 lock (Avatars) {
558 if (Avatars.ContainsKey(agentID)) {
559 Avatars.Remove(agentID);
560 }
561 }
562 lock (Entities) {
563 if (Entities.ContainsKey(agentID)) {
564 Entities.Remove(agentID);
565 }
566 }
567 // TODO: Add the removal from physics ?
568
569
570
571 return;
572 }
573 #endregion
574
575 #region Request Avatars List Methods
576 //The idea is to have a group of method that return a list of avatars meeting some requirement
577 // ie it could be all Avatars within a certain range of the calling prim/avatar.
578
579 /// <summary>
580 /// Request a List of all Avatars in this World
581 /// </summary>
582 /// <returns></returns>
583 public List<ScenePresence> RequestAvatarList()
584 {
585 List<ScenePresence> result = new List<ScenePresence>();
586
587 foreach (ScenePresence avatar in Avatars.Values)
588 {
589 result.Add(avatar);
590 }
591
592 return result;
593 }
594
595 /// <summary>
596 /// Request a filtered list of Avatars in this World
597 /// </summary>
598 /// <returns></returns>
599 public List<ScenePresence> RequestAvatarList(FilterAvatarList filter)
600 {
601 List<ScenePresence> result = new List<ScenePresence>();
602
603 foreach (ScenePresence avatar in Avatars.Values)
604 {
605 if (filter(avatar))
606 {
607 result.Add(avatar);
608 }
609 }
610
611 return result;
612 }
613
614 /// <summary>
615 /// Request a Avatar by UUID
616 /// </summary>
617 /// <param name="avatarID"></param>
618 /// <returns></returns>
619 public ScenePresence RequestAvatar(LLUUID avatarID)
620 {
621 if (this.Avatars.ContainsKey(avatarID))
622 {
623 return Avatars[avatarID];
624 }
625 return null;
626 }
627 #endregion
628
629
630 /// <summary>
631 ///
632 /// </summary>
633 /// <param name="entID"></param>
634 /// <returns></returns>
635 public bool DeleteEntity(LLUUID entID)
636 {
637 if (this.Entities.ContainsKey(entID))
638 {
639 this.Entities.Remove(entID);
640 return true;
641 }
642 return false;
643 }
644
645 public void SendAllSceneObjectsToClient(IClientAPI client)
646 {
647 foreach (EntityBase ent in Entities.Values)
648 {
649 if (ent is SceneObject)
650 {
651 ((SceneObject)ent).SendAllChildPrimsToClient(client);
652 }
653 }
654 }
655
656 #region RegionCommsHost
657
658 /// <summary>
659 ///
660 /// </summary>
661 public void RegisterRegionWithComms()
662 {
663
664 this.regionCommsHost = this.commsManager.GridServer.RegisterRegion(this.m_regInfo);
665 if (this.regionCommsHost != null)
666 {
667 this.regionCommsHost.OnExpectUser += this.NewUserConnection;
668 this.regionCommsHost.OnAvatarCrossingIntoRegion += this.AgentCrossing;
669 }
670 }
671
672 /// <summary>
673 ///
674 /// </summary>
675 /// <param name="regionHandle"></param>
676 /// <param name="agent"></param>
677 public void NewUserConnection(ulong regionHandle, AgentCircuitData agent)
678 {
679 // Console.WriteLine("World.cs - add new user connection");
680 //should just check that its meant for this region
681 if (regionHandle == this.m_regInfo.RegionHandle)
682 {
683 if (agent.CapsPath != "")
684 {
685 //Console.WriteLine("new user, so creating caps handler for it");
686 Caps cap = new Caps(this.assetCache, httpListener, this.m_regInfo.ExternalHostName, this.m_regInfo.ExternalEndPoint.Port, agent.CapsPath, agent.AgentID);
687 cap.RegisterHandlers();
688 this.capsHandlers.Add(agent.AgentID, cap);
689 }
690 this.authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
691 }
692 }
693
694 public void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position)
695 {
696 if (regionHandle == this.m_regInfo.RegionHandle)
697 {
698 if (this.Avatars.ContainsKey(agentID))
699 {
700 this.Avatars[agentID].MakeAvatar(position);
701 }
702 }
703 }
704
705 /// <summary>
706 ///
707 /// </summary>
708 public void InformClientOfNeighbours(IClientAPI remoteClient)
709 {
710 List<RegionInfo> neighbours = this.commsManager.GridServer.RequestNeighbours(this.m_regInfo);
711
712 if (neighbours != null)
713 {
714 for (int i = 0; i < neighbours.Count; i++)
715 {
716 AgentCircuitData agent = remoteClient.RequestClientInfo();
717 agent.BaseFolder = LLUUID.Zero;
718 agent.InventoryFolder = LLUUID.Zero;
719 agent.startpos = new LLVector3(128, 128, 70);
720 agent.child = true;
721 this.commsManager.InterRegion.InformRegionOfChildAgent(neighbours[i].RegionHandle, agent);
722 remoteClient.InformClientOfNeighbour(neighbours[i].RegionHandle, neighbours[i].ExternalEndPoint);
723 //this.capsHandlers[remoteClient.AgentId].CreateEstablishAgentComms("", System.Net.IPAddress.Parse(neighbours[i].CommsIPListenAddr) + ":" + neighbours[i].CommsIPListenPort);
724 }
725 }
726 }
727
728 /// <summary>
729 ///
730 /// </summary>
731 /// <param name="regionHandle"></param>
732 /// <returns></returns>
733 public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
734 {
735 return this.commsManager.GridServer.RequestNeighbourInfo(regionHandle);
736 }
737
738 /// <summary>
739 ///
740 /// </summary>
741 /// <param name="minX"></param>
742 /// <param name="minY"></param>
743 /// <param name="maxX"></param>
744 /// <param name="maxY"></param>
745 public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
746 {
747 List<MapBlockData> mapBlocks;
748 mapBlocks = this.commsManager.GridServer.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
749 remoteClient.SendMapBlock(mapBlocks);
750 }
751
752 /// <summary>
753 ///
754 /// </summary>
755 /// <param name="remoteClient"></param>
756 /// <param name="RegionHandle"></param>
757 /// <param name="position"></param>
758 /// <param name="lookAt"></param>
759 /// <param name="flags"></param>
760 public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags)
761 {
762 if (regionHandle == this.m_regionHandle)
763 {
764 if (this.Avatars.ContainsKey(remoteClient.AgentId))
765 {
766 remoteClient.SendTeleportLocationStart();
767 remoteClient.SendLocalTeleport(position, lookAt, flags);
768 this.Avatars[remoteClient.AgentId].Teleport(position);
769 }
770 }
771 else
772 {
773 RegionInfo reg = this.RequestNeighbouringRegionInfo(regionHandle);
774 if (reg != null)
775 {
776 remoteClient.SendTeleportLocationStart();
777 AgentCircuitData agent = remoteClient.RequestClientInfo();
778 agent.BaseFolder = LLUUID.Zero;
779 agent.InventoryFolder = LLUUID.Zero;
780 agent.startpos = new LLVector3(128, 128, 70);
781 agent.child = true;
782 this.commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent);
783 this.commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position);
784
785 remoteClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4));
786
787 }
788 //remoteClient.SendTeleportCancel();
789 }
790 }
791
792 /// <summary>
793 ///
794 /// </summary>
795 /// <param name="regionhandle"></param>
796 /// <param name="agentID"></param>
797 /// <param name="position"></param>
798 public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position)
799 {
800 return this.commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position);
801 }
802
803 #endregion
804
805 }
806}
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs
new file mode 100644
index 0000000..811f54c
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs
@@ -0,0 +1,198 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
32using OpenSim.Framework.Console;
33using OpenSim.Framework.Interfaces;
34using OpenSim.Framework.Types;
35using OpenSim.Region.Caches;
36using OpenSim.Region.Terrain;
37using OpenSim.Framework;
38
39namespace OpenSim.Region.Environment.Scenes
40{
41 public abstract class SceneBase : IWorld
42 {
43 public Dictionary<LLUUID, EntityBase> Entities;
44 protected ClientManager m_clientManager;
45 protected ulong m_regionHandle;
46 protected string m_regionName;
47 protected RegionInfo m_regInfo;
48
49 public TerrainEngine Terrain;
50
51 public string m_datastore;
52 public ILocalStorage localStorage;
53
54 protected object m_syncRoot = new object();
55 private uint m_nextLocalId = 8880000;
56 protected AssetCache assetCache;
57
58 #region Update Methods
59 /// <summary>
60 /// Normally called once every frame/tick to let the world preform anything required (like running the physics simulation)
61 /// </summary>
62 public abstract void Update();
63
64 #endregion
65
66 #region Terrain Methods
67
68 /// <summary>
69 /// Loads the World heightmap
70 /// </summary>
71 public abstract void LoadWorldMap();
72
73 /// <summary>
74 /// Loads a new storage subsystem from a named library
75 /// </summary>
76 /// <param name="dllName">Storage Library</param>
77 /// <returns>Successful or not</returns>
78 public bool LoadStorageDLL(string dllName)
79 {
80 try
81 {
82 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
83 ILocalStorage store = null;
84
85 foreach (Type pluginType in pluginAssembly.GetTypes())
86 {
87 if (pluginType.IsPublic)
88 {
89 if (!pluginType.IsAbstract)
90 {
91 Type typeInterface = pluginType.GetInterface("ILocalStorage", true);
92
93 if (typeInterface != null)
94 {
95 ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
96 store = plug;
97
98 store.Initialise(this.m_datastore);
99 break;
100 }
101
102 typeInterface = null;
103 }
104 }
105 }
106 pluginAssembly = null;
107 this.localStorage = store;
108 return (store == null);
109 }
110 catch (Exception e)
111 {
112 MainLog.Instance.Warn("World.cs: LoadStorageDLL() - Failed with exception " + e.ToString());
113 return false;
114 }
115 }
116
117
118 /// <summary>
119 /// Send the region heightmap to the client
120 /// </summary>
121 /// <param name="RemoteClient">Client to send to</param>
122 public virtual void SendLayerData(IClientAPI RemoteClient)
123 {
124 RemoteClient.SendLayerData(Terrain.getHeights1D());
125 }
126
127 /// <summary>
128 /// Sends a specified patch to a client
129 /// </summary>
130 /// <param name="px">Patch coordinate (x) 0..16</param>
131 /// <param name="py">Patch coordinate (y) 0..16</param>
132 /// <param name="RemoteClient">The client to send to</param>
133 public virtual void SendLayerData(int px, int py, IClientAPI RemoteClient)
134 {
135 RemoteClient.SendLayerData(px, py, Terrain.getHeights1D());
136 }
137
138 #endregion
139
140 #region Add/Remove Agent/Avatar
141 /// <summary>
142 ///
143 /// </summary>
144 /// <param name="remoteClient"></param>
145 /// <param name="agentID"></param>
146 /// <param name="child"></param>
147 public abstract void AddNewClient(IClientAPI client, bool child);
148
149 public abstract uint AddNewPrim(LLUUID ownerId, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID texture, int flags);
150
151 /// <summary>
152 ///
153 /// </summary>
154 /// <param name="agentID"></param>
155 public abstract void RemoveClient(LLUUID agentID);
156
157 #endregion
158
159 /// <summary>
160 ///
161 /// </summary>
162 /// <returns></returns>
163 public virtual RegionInfo RegionInfo
164 {
165 get { return this.m_regInfo; }
166 }
167
168 public object SyncRoot
169 {
170 get { return m_syncRoot; }
171 }
172
173 public uint NextLocalId
174 {
175 get { return m_nextLocalId++; }
176 }
177
178 #region Shutdown
179 /// <summary>
180 /// Tidy before shutdown
181 /// </summary>
182 public virtual void Close()
183 {
184 try
185 {
186 this.localStorage.ShutDown();
187 }
188 catch (Exception e)
189 {
190 MainLog.Instance.WriteLine(LogPriority.HIGH, "World.cs: Close() - Failed with exception " + e.ToString());
191 }
192 }
193
194 #endregion
195
196
197 }
198}
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
new file mode 100644
index 0000000..9e383c6
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
@@ -0,0 +1,50 @@
1using libsecondlife;
2
3namespace OpenSim.Region.Environment.Scenes
4{
5 /// <summary>
6 /// A class for triggering remote scene events.
7 /// </summary>
8 public class EventManager
9 {
10 public delegate void OnFrameDelegate();
11 public event OnFrameDelegate OnFrame;
12
13 public delegate void OnNewPresenceDelegate(ScenePresence presence);
14 public event OnNewPresenceDelegate OnNewPresence;
15
16 public delegate void OnNewPrimitiveDelegate(PrimitiveOld prim);
17 public event OnNewPrimitiveDelegate OnNewPrimitive;
18
19 public delegate void OnRemovePresenceDelegate(LLUUID uuid);
20 public event OnRemovePresenceDelegate OnRemovePresence;
21
22 public void TriggerOnFrame()
23 {
24 if (OnFrame != null)
25 {
26 OnFrame();
27 }
28 }
29
30 public void TriggerOnNewPrimitive(PrimitiveOld prim)
31 {
32 if (OnNewPrimitive != null)
33 OnNewPrimitive(prim);
34 }
35
36 public void TriggerOnNewPresence(ScenePresence presence)
37 {
38 if (OnNewPresence != null)
39 OnNewPresence(presence);
40 }
41
42 public void TriggerOnRemovePresence(LLUUID uuid)
43 {
44 if (OnRemovePresence != null)
45 {
46 OnRemovePresence(uuid);
47 }
48 }
49 }
50}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObject.cs b/OpenSim/Region/Environment/Scenes/SceneObject.cs
new file mode 100644
index 0000000..ecd2dee
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/SceneObject.cs
@@ -0,0 +1,246 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 System.Text;
30using libsecondlife;
31using libsecondlife.Packets;
32using OpenSim.Framework.Interfaces;
33using OpenSim.Physics.Manager;
34
35namespace OpenSim.Region.Environment.Scenes
36{
37 public class SceneObject : EntityBase
38 {
39 private Encoding enc = Encoding.ASCII;
40 private Dictionary<LLUUID, Primitive> ChildPrimitives = new Dictionary<LLUUID, Primitive>(); //list of all primitive id's that are part of this group
41 public Primitive rootPrimitive;
42 private new Scene m_world;
43 protected ulong m_regionHandle;
44
45 private bool physicsEnabled = false;
46 private PhysicsScene m_PhysScene;
47 private PhysicsActor m_PhysActor;
48
49 public LLUUID rootUUID
50 {
51 get
52 {
53 this.uuid = this.rootPrimitive.uuid;
54 return this.uuid;
55 }
56 }
57
58 public uint rootLocalID
59 {
60 get
61 {
62 this.m_localId = this.rootPrimitive.LocalId;
63 return this.LocalId;
64 }
65 }
66
67 /// <summary>
68 ///
69 /// </summary>
70 public SceneObject(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
71 {
72 m_regionHandle = regionHandle;
73 m_world = world;
74 this.Pos = addPacket.ObjectData.RayEnd;
75 this.CreateRootFromPacket(addPacket, ownerID, localID);
76 }
77
78 /// <summary>
79 ///
80 /// </summary>
81 /// <remarks>Need a null constructor for duplication</remarks>
82 public SceneObject()
83 {
84
85 }
86
87 /// <summary>
88 ///
89 /// </summary>
90 /// <param name="addPacket"></param>
91 /// <param name="agentID"></param>
92 /// <param name="localID"></param>
93 public void CreateRootFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID)
94 {
95 this.rootPrimitive = new Primitive( this.m_regionHandle, this.m_world, addPacket, agentID, localID, true, this, this);
96 this.children.Add(rootPrimitive);
97 this.ChildPrimitives.Add(this.rootUUID, this.rootPrimitive);
98 }
99
100 /// <summary>
101 ///
102 /// </summary>
103 /// <param name="data"></param>
104 public void CreateFromBytes(byte[] data)
105 {
106
107 }
108
109 /// <summary>
110 ///
111 /// </summary>
112 /// <returns>A complete copy of the object</returns>
113 public SceneObject Copy()
114 {
115 SceneObject dupe = new SceneObject();
116
117 Primitive newRoot = this.rootPrimitive.Copy((EntityBase)dupe, dupe);
118
119 foreach (EntityBase child in this.children)
120 {
121 EntityBase newChild = child.Copy();
122 dupe.children.Add(newChild);
123 }
124
125 return dupe;
126 }
127
128 /// <summary>
129 ///
130 /// </summary>
131 public void DeleteAllChildren()
132 {
133 this.children.Clear();
134 this.ChildPrimitives.Clear();
135 this.rootPrimitive = null;
136 }
137
138 /// <summary>
139 ///
140 /// </summary>
141 /// <param name="primObject"></param>
142 public void AddNewChildPrims(SceneObject primObject)
143 {
144 this.rootPrimitive.AddNewChildren(primObject);
145 }
146
147 public void AddChildToList(Primitive prim)
148 {
149 if (!this.ChildPrimitives.ContainsKey(prim.uuid))
150 {
151 this.ChildPrimitives.Add(prim.uuid, prim);
152 }
153 }
154 /// <summary>
155 ///
156 /// </summary>
157 /// <param name="primID"></param>
158 /// <returns></returns>
159 public Primitive HasChildPrim(LLUUID primID)
160 {
161 if (this.ChildPrimitives.ContainsKey(primID))
162 {
163 return this.ChildPrimitives[primID];
164 }
165
166 return null;
167 }
168
169 /// <summary>
170 ///
171 /// </summary>
172 /// <param name="localID"></param>
173 /// <returns></returns>
174 public Primitive HasChildPrim(uint localID)
175 {
176 Primitive returnPrim = null;
177 foreach (Primitive prim in this.ChildPrimitives.Values)
178 {
179 if (prim.LocalId == localID)
180 {
181 returnPrim = prim;
182 break;
183 }
184 }
185 return returnPrim;
186 }
187
188 public void SendAllChildPrimsToClient(IClientAPI client)
189 {
190 this.rootPrimitive.SendFullUpdateForAllChildren(client);
191 }
192
193 /// <summary>
194 ///
195 /// </summary>
196 public override void BackUp()
197 {
198
199 }
200
201 /// <summary>
202 ///
203 /// </summary>
204 /// <param name="offset"></param>
205 /// <param name="pos"></param>
206 /// <param name="remoteClient"></param>
207 public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
208 {
209 this.rootPrimitive.Pos = pos ;
210 this.rootPrimitive.SendTerseUpdateForAllChildren(remoteClient);
211 }
212
213 /// <summary>
214 ///
215 /// </summary>
216 /// <param name="client"></param>
217 public void GetProperites(IClientAPI client)
218 {
219 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
220 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
221 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
222 proper.ObjectData[0].ItemID = LLUUID.Zero;
223 proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.CreationDate;
224 proper.ObjectData[0].CreatorID = this.rootPrimitive.CreatorID;
225 proper.ObjectData[0].FolderID = LLUUID.Zero;
226 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
227 proper.ObjectData[0].GroupID = LLUUID.Zero;
228 proper.ObjectData[0].InventorySerial = 0;
229 proper.ObjectData[0].LastOwnerID = this.rootPrimitive.LastOwnerID;
230 proper.ObjectData[0].ObjectID = this.rootUUID;
231 proper.ObjectData[0].OwnerID = this.rootPrimitive.OwnerID;
232 proper.ObjectData[0].TouchName = enc.GetBytes(this.rootPrimitive.TouchName + "\0");
233 proper.ObjectData[0].TextureID = new byte[0];
234 proper.ObjectData[0].SitName = enc.GetBytes(this.rootPrimitive.SitName +"\0") ;
235 proper.ObjectData[0].Name = enc.GetBytes(this.rootPrimitive.Name +"\0");
236 proper.ObjectData[0].Description = enc.GetBytes(this.rootPrimitive.Description +"\0");
237 proper.ObjectData[0].OwnerMask = this.rootPrimitive.OwnerMask;
238 proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.NextOwnerMask;
239 proper.ObjectData[0].GroupMask = this.rootPrimitive.GroupMask;
240 proper.ObjectData[0].EveryoneMask = this.rootPrimitive.EveryoneMask;
241 proper.ObjectData[0].BaseMask = this.rootPrimitive.BaseMask;
242
243 client.OutPacket(proper);
244 }
245 }
246}
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs
new file mode 100644
index 0000000..d1f75ed
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs
@@ -0,0 +1,74 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 System.Xml;
30using libsecondlife;
31
32namespace OpenSim.Region.Environment.Scenes
33{
34 partial class ScenePresence
35 {
36 public class AvatarAnimations
37 {
38
39 public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>();
40 public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>();
41
42 public AvatarAnimations()
43 {
44 }
45
46 public void LoadAnims()
47 {
48 //OpenSim.Framework.Console.MainLog.Instance.Verbose("Avatar.cs:LoadAnims() - Loading avatar animations");
49 XmlTextReader reader = new XmlTextReader("data/avataranimations.xml");
50
51 XmlDocument doc = new XmlDocument();
52 doc.Load(reader);
53 foreach (XmlNode nod in doc.DocumentElement.ChildNodes)
54 {
55
56 if (nod.Attributes["name"] != null)
57 {
58 AnimsLLUUID.Add(nod.Attributes["name"].Value, nod.InnerText);
59 }
60
61 }
62
63 reader.Close();
64
65 // OpenSim.Framework.Console.MainLog.Instance.Verbose("Loaded " + AnimsLLUUID.Count.ToString() + " animation(s)");
66
67 foreach (KeyValuePair<string, LLUUID> kp in Animations.AnimsLLUUID)
68 {
69 AnimsNames.Add(kp.Value, kp.Key);
70 }
71 }
72 }
73 }
74}
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs
new file mode 100644
index 0000000..dbb5d3f
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs
@@ -0,0 +1,85 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
29using libsecondlife.Packets;
30using OpenSim.Framework.Interfaces;
31
32namespace OpenSim.Region.Environment.Scenes
33{
34 partial class ScenePresence
35 {
36 public class Avatar : IScenePresenceBody
37 {
38 public Avatar()
39 {
40
41 }
42
43 public void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation)
44 {
45 }
46
47 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
48 {
49 }
50
51 public void SendOurAppearance(IClientAPI OurClient)
52 {
53 }
54
55 public void SendAppearanceToOtherAgent(ScenePresence avatarInfo)
56 {
57 }
58 }
59
60 public class ChildAgent : IScenePresenceBody //is a ghost
61 {
62 public ChildAgent()
63 {
64
65 }
66
67 public void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation)
68 {
69 }
70
71 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
72 {
73 }
74
75 public void SendOurAppearance(IClientAPI OurClient)
76 {
77 }
78
79 public void SendAppearanceToOtherAgent(ScenePresence avatarInfo)
80 {
81 }
82 }
83 }
84
85}
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
new file mode 100644
index 0000000..e65ab7c
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -0,0 +1,597 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 Axiom.Math;
32using libsecondlife;
33using libsecondlife.Packets;
34using OpenSim.Framework.Console;
35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework.Types;
37using OpenSim.Physics.Manager;
38
39namespace OpenSim.Region.Environment.Scenes
40{
41 public partial class ScenePresence : Entity
42 {
43 public static bool PhysicsEngineFlying = false;
44 public static AvatarAnimations Animations;
45 public static byte[] DefaultTexture;
46 public string firstname;
47 public string lastname;
48 public IClientAPI ControllingClient;
49 public LLUUID current_anim;
50 public int anim_seq;
51 private bool updateflag = false;
52 private byte movementflag = 0;
53 private List<NewForce> forcesList = new List<NewForce>();
54 private short _updateCount = 0;
55 private Quaternion bodyRot;
56 private LLObject.TextureEntry avatarAppearanceTexture = null;
57 private byte[] visualParams;
58 private AvatarWearable[] Wearables;
59 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
60 private ulong m_regionHandle;
61 private bool childAgent = false;
62 private bool newForce = false;
63 private bool newAvatar = false;
64 private IScenePresenceBody m_body;
65
66 protected RegionInfo m_regionInfo;
67
68 private Vector3[] Dir_Vectors = new Vector3[6];
69 private enum Dir_ControlFlags
70 {
71 DIR_CONTROL_FLAG_FOWARD = MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS,
72 DIR_CONTROL_FLAG_BACK = MainAvatar.ControlFlags.AGENT_CONTROL_AT_NEG,
73 DIR_CONTROL_FLAG_LEFT = MainAvatar.ControlFlags.AGENT_CONTROL_LEFT_POS,
74 DIR_CONTROL_FLAG_RIGHT = MainAvatar.ControlFlags.AGENT_CONTROL_LEFT_NEG,
75 DIR_CONTROL_FLAG_UP = MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS,
76 DIR_CONTROL_FLAG_DOWN = MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG
77 }
78
79 #region Properties
80 /// <summary>
81 ///
82 /// </summary>
83 public PhysicsActor PhysActor
84 {
85 set
86 {
87 this._physActor = value;
88 }
89 get
90 {
91 return _physActor;
92 }
93 }
94
95 public ulong RegionHandle
96 {
97 get { return m_regionHandle; }
98 }
99
100 #endregion
101
102 #region Constructor(s)
103 /// <summary>
104 ///
105 /// </summary>
106 /// <param name="theClient"></param>
107 /// <param name="world"></param>
108 /// <param name="clientThreads"></param>
109 /// <param name="regionDat"></param>
110 public ScenePresence(IClientAPI theClient, Scene world, RegionInfo reginfo)
111 {
112
113 m_world = world;
114 this.uuid = theClient.AgentId;
115
116 m_regionInfo = reginfo;
117 m_regionHandle = reginfo.RegionHandle;
118 MainLog.Instance.Verbose("Avatar.cs ");
119 ControllingClient = theClient;
120 this.firstname = ControllingClient.FirstName;
121 this.lastname = ControllingClient.LastName;
122 m_localId = m_world.NextLocalId;
123 Pos = ControllingClient.StartPos;
124 visualParams = new byte[218];
125 for (int i = 0; i < 218; i++)
126 {
127 visualParams[i] = 100;
128 }
129
130 Wearables = AvatarWearable.DefaultWearables;
131 Animations = new ScenePresence.AvatarAnimations();
132 Animations.LoadAnims();
133
134 this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
135
136 //register for events
137 ControllingClient.OnRequestWearables += this.SendOurAppearance;
138 //ControllingClient.OnSetAppearance += new SetAppearance(this.SetAppearance);
139 ControllingClient.OnCompleteMovementToRegion += this.CompleteMovement;
140 ControllingClient.OnCompleteMovementToRegion += this.SendInitialData;
141 ControllingClient.OnAgentUpdate += this.HandleAgentUpdate;
142 // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack);
143 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
144 //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
145
146 Dir_Vectors[0] = new Vector3(1, 0, 0); //FOWARD
147 Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK
148 Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT
149 Dir_Vectors[3] = new Vector3(0, -1, 0); //RIGHT
150 Dir_Vectors[4] = new Vector3(0, 0, 1); //UP
151 Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN
152
153 }
154 #endregion
155
156 #region Status Methods
157 /// <summary>
158 /// Not Used, most likely can be deleted
159 /// </summary>
160 /// <param name="status"></param>
161 public void ChildStatusChange(bool status)
162 {
163 this.childAgent = status;
164
165 if (this.childAgent == true)
166 {
167 this.Velocity = new LLVector3(0, 0, 0);
168 this.Pos = new LLVector3(128, 128, 70);
169
170 }
171 }
172
173 /// <summary>
174 ///
175 /// </summary>
176 /// <param name="pos"></param>
177 public void MakeAvatar(LLVector3 pos)
178 {
179 //this.childAvatar = false;
180 this.Pos = pos;
181 this.newAvatar = true;
182 this.childAgent = false;
183 }
184
185 protected void MakeChildAgent()
186 {
187 this.Velocity = new LLVector3(0, 0, 0);
188 this.Pos = new LLVector3(128, 128, 70);
189 this.childAgent = true;
190 }
191
192 /// <summary>
193 ///
194 /// </summary>
195 /// <param name="pos"></param>
196 public void Teleport(LLVector3 pos)
197 {
198 this.Pos = pos;
199 this.SendTerseUpdateToALLClients();
200 }
201
202 /// <summary>
203 ///
204 /// </summary>
205 public void StopMovement()
206 {
207
208 }
209 #endregion
210
211 #region Event Handlers
212 /// <summary>
213 ///
214 /// </summary>
215 /// <param name="texture"></param>
216 /// <param name="visualParam"></param>
217 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
218 {
219
220 }
221
222 /// <summary>
223 /// Complete Avatar's movement into the region
224 /// </summary>
225 public void CompleteMovement()
226 {
227 LLVector3 look = this.Velocity;
228 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
229 {
230 look = new LLVector3(0.99f, 0.042f, 0);
231 }
232 this.ControllingClient.MoveAgentIntoRegion(m_regionInfo, Pos, look);
233 if (this.childAgent)
234 {
235 this.childAgent = false;
236 }
237 }
238
239 /// <summary>
240 ///
241 /// </summary>
242 /// <param name="pack"></param>
243 public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation)
244 {
245 int i = 0;
246 bool update_movementflag = false;
247 bool update_rotation = false;
248 bool DCFlagKeyPressed = false;
249 Vector3 agent_control_v3 = new Vector3(0, 0, 0);
250 Quaternion q = new Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z);
251
252 this.PhysActor.Flying = ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0);
253
254 if (q != this.bodyRot)
255 {
256 this.bodyRot = q;
257 update_rotation = true;
258 }
259 foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof(Dir_ControlFlags)))
260 {
261 if ((flags & (uint)DCF) != 0)
262 {
263 DCFlagKeyPressed = true;
264 agent_control_v3 += Dir_Vectors[i];
265 if ((movementflag & (uint)DCF) == 0)
266 {
267 movementflag += (byte)(uint)DCF;
268 update_movementflag = true;
269 }
270 }
271 else
272 {
273 if ((movementflag & (uint)DCF) != 0)
274 {
275 movementflag -= (byte)(uint)DCF;
276 update_movementflag = true;
277 }
278 }
279 i++;
280 }
281 if ((update_movementflag) || (update_rotation && DCFlagKeyPressed))
282 {
283 this.AddNewMovement(agent_control_v3, q);
284 }
285 UpdateMovementAnimations(update_movementflag);
286 }
287
288 protected void UpdateMovementAnimations(bool update_movementflag)
289 {
290 if (update_movementflag)
291 {
292 if (movementflag != 0)
293 {
294 if (this._physActor.Flying)
295 {
296 this.SendAnimPack(Animations.AnimsLLUUID["FLY"], 1);
297 }
298 else
299 {
300 this.SendAnimPack(Animations.AnimsLLUUID["WALK"], 1);
301 }
302 }
303 else
304 {
305 this.SendAnimPack(Animations.AnimsLLUUID["STAND"], 1);
306 }
307 }
308
309 }
310
311
312 protected void AddNewMovement(Vector3 vec, Quaternion rotation)
313 {
314 NewForce newVelocity = new NewForce();
315 Vector3 direc = rotation * vec;
316 direc.Normalize();
317
318 direc = direc * ((0.03f) * 128f);
319 if (this._physActor.Flying)
320 direc *= 4;
321
322 newVelocity.X = direc.x;
323 newVelocity.Y = direc.y;
324 newVelocity.Z = direc.z;
325 this.forcesList.Add(newVelocity);
326 }
327
328 #endregion
329
330 #region Overridden Methods
331 /// <summary>
332 ///
333 /// </summary>
334 public override void LandRenegerated()
335 {
336
337 }
338
339 /// <summary>
340 ///
341 /// </summary>
342 public override void update()
343 {
344 if (this.childAgent == false)
345 {
346 if (this.newForce)
347 {
348 this.SendTerseUpdateToALLClients();
349 _updateCount = 0;
350 }
351 else if (movementflag != 0)
352 {
353 _updateCount++;
354 if (_updateCount > 3)
355 {
356 this.SendTerseUpdateToALLClients();
357 _updateCount = 0;
358 }
359 }
360
361 this.CheckForBorderCrossing();
362 }
363 }
364 #endregion
365
366 #region Update Client(s)
367 /// <summary>
368 ///
369 /// </summary>
370 /// <param name="RemoteClient"></param>
371 public void SendTerseUpdateToClient(IClientAPI RemoteClient)
372 {
373 LLVector3 pos = this.Pos;
374 LLVector3 vel = this.Velocity;
375 RemoteClient.SendAvatarTerseUpdate(this.m_regionHandle, 64096, this.LocalId, new LLVector3(pos.X, pos.Y, pos.Z), new LLVector3(vel.X, vel.Y, vel.Z));
376 }
377
378 /// <summary>
379 ///
380 /// </summary>
381 public void SendTerseUpdateToALLClients()
382 {
383 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
384 for (int i = 0; i < avatars.Count; i++)
385 {
386 this.SendTerseUpdateToClient(avatars[i].ControllingClient);
387 }
388 }
389
390 /// <summary>
391 ///
392 /// </summary>
393 /// <param name="remoteAvatar"></param>
394 public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar)
395 {
396 remoteAvatar.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture);
397 }
398
399 public void SendFullUpdateToALLClients()
400 {
401 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
402 foreach (ScenePresence avatar in this.m_world.RequestAvatarList())
403 {
404 this.SendFullUpdateToOtherClient(avatar);
405 avatar.SendFullUpdateToOtherClient(this);
406 }
407 }
408
409 /// <summary>
410 ///
411 /// </summary>
412 public void SendInitialData()
413 {
414 this.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture);
415 if (this.newAvatar)
416 {
417 this.m_world.InformClientOfNeighbours(this.ControllingClient);
418 this.newAvatar = false;
419 }
420 }
421
422 /// <summary>
423 ///
424 /// </summary>
425 /// <param name="OurClient"></param>
426 public void SendOurAppearance(IClientAPI OurClient)
427 {
428 this.ControllingClient.SendWearables(this.Wearables);
429 this.SendFullUpdateToALLClients();
430 this.m_world.SendAllSceneObjectsToClient(this.ControllingClient);
431 }
432
433 /// <summary>
434 ///
435 /// </summary>
436 /// <param name="avatarInfo"></param>
437 public void SendAppearanceToOtherAgent(ScenePresence avatarInfo)
438 {
439
440 }
441
442 /// <summary>
443 ///
444 /// </summary>
445 /// <param name="animID"></param>
446 /// <param name="seq"></param>
447 public void SendAnimPack(LLUUID animID, int seq)
448 {
449 this.current_anim = animID;
450 this.anim_seq = seq;
451 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
452 for (int i = 0; i < avatars.Count; i++)
453 {
454 avatars[i].ControllingClient.SendAnimation(animID, seq, this.ControllingClient.AgentId);
455 }
456 }
457
458 /// <summary>
459 ///
460 /// </summary>
461 public void SendAnimPack()
462 {
463 this.SendAnimPack(this.current_anim, this.anim_seq);
464 }
465 #endregion
466
467 #region Border Crossing Methods
468 /// <summary>
469 ///
470 /// </summary>
471 protected void CheckForBorderCrossing()
472 {
473 LLVector3 pos2 = this.Pos;
474 LLVector3 vel = this.Velocity;
475
476 float timeStep = 0.2f;
477 pos2.X = pos2.X + (vel.X * timeStep);
478 pos2.Y = pos2.Y + (vel.Y * timeStep);
479 pos2.Z = pos2.Z + (vel.Z * timeStep);
480
481 if ((pos2.X < 0) || (pos2.X > 256))
482 {
483 this.CrossToNewRegion();
484 }
485
486 if ((pos2.Y < 0) || (pos2.Y > 256))
487 {
488 this.CrossToNewRegion();
489 }
490 }
491
492 /// <summary>
493 ///
494 /// </summary>
495 protected void CrossToNewRegion()
496 {
497 LLVector3 pos = this.Pos;
498 LLVector3 newpos = new LLVector3(pos.X, pos.Y, pos.Z);
499 uint neighbourx = this.m_regionInfo.RegionLocX;
500 uint neighboury = this.m_regionInfo.RegionLocY;
501
502 if (pos.X < 2)
503 {
504 neighbourx -= 1;
505 newpos.X = 254;
506 }
507 if (pos.X > 253)
508 {
509 neighbourx += 1;
510 newpos.X = 1;
511 }
512 if (pos.Y < 2)
513 {
514 neighboury -= 1;
515 newpos.Y = 254;
516 }
517 if (pos.Y > 253)
518 {
519 neighboury += 1;
520 newpos.Y = 1;
521 }
522
523 LLVector3 vel = this.m_velocity;
524 ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * 256), (uint)(neighboury * 256));
525 RegionInfo neighbourRegion = this.m_world.RequestNeighbouringRegionInfo(neighbourHandle);
526 if (neighbourRegion != null)
527 {
528 bool res = this.m_world.InformNeighbourOfCrossing(neighbourHandle, this.ControllingClient.AgentId, newpos);
529 if (res)
530 {
531 this.MakeChildAgent();
532 this.ControllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.InternalEndPoint);
533 }
534 }
535 }
536 #endregion
537
538 /// <summary>
539 ///
540 /// </summary>
541 public static void LoadAnims()
542 {
543
544 }
545
546 /// <summary>
547 ///
548 /// </summary>
549 public override void updateMovement()
550 {
551 newForce = false;
552 lock (this.forcesList)
553 {
554 if (this.forcesList.Count > 0)
555 {
556 for (int i = 0; i < this.forcesList.Count; i++)
557 {
558 NewForce force = this.forcesList[i];
559
560 this.updateflag = true;
561 this.Velocity = new LLVector3(force.X, force.Y, force.Z);
562 this.newForce = true;
563 }
564 for (int i = 0; i < this.forcesList.Count; i++)
565 {
566 this.forcesList.RemoveAt(0);
567 }
568 }
569 }
570 }
571
572 public static void LoadTextureFile(string name)
573 {
574 FileInfo fInfo = new FileInfo(name);
575 long numBytes = fInfo.Length;
576 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read);
577 BinaryReader br = new BinaryReader(fStream);
578 byte[] data1 = br.ReadBytes((int)numBytes);
579 br.Close();
580 fStream.Close();
581 DefaultTexture = data1;
582 }
583
584 public class NewForce
585 {
586 public float X;
587 public float Y;
588 public float Z;
589
590 public NewForce()
591 {
592
593 }
594 }
595 }
596
597}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs
new file mode 100644
index 0000000..9cb881a
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs
@@ -0,0 +1,102 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.CodeDom.Compiler;
30using System.Collections.Generic;
31using Microsoft.CSharp;
32using OpenSim.Framework.Console;
33
34namespace OpenSim.Region.Environment.Scripting
35{
36 public class CSharpScriptEngine : IScriptCompiler
37 {
38 public string FileExt()
39 {
40 return ".cs";
41 }
42
43 private Dictionary<string,IScript> LoadDotNetScript(CodeDomProvider compiler, string filename)
44 {
45 CompilerParameters compilerParams = new CompilerParameters();
46 CompilerResults compilerResults;
47 compilerParams.GenerateExecutable = false;
48 compilerParams.GenerateInMemory = true;
49 compilerParams.IncludeDebugInformation = false;
50 compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll");
51 compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Enviroment.dll");
52 compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
53 compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
54 compilerParams.ReferencedAssemblies.Add("System.dll");
55
56 compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
57
58 if (compilerResults.Errors.Count > 0)
59 {
60 MainLog.Instance.Error("Compile errors");
61 foreach (CompilerError error in compilerResults.Errors)
62 {
63 MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString());
64 }
65 }
66 else
67 {
68 Dictionary<string,IScript> scripts = new Dictionary<string,IScript>();
69
70 foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
71 {
72 Type testInterface = pluginType.GetInterface("IScript", true);
73
74 if (testInterface != null)
75 {
76 IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
77
78 string scriptName = "C#/" + script.getName();
79 Console.WriteLine("Script: " + scriptName + " loaded.");
80
81 if (!scripts.ContainsKey(scriptName))
82 {
83 scripts.Add(scriptName, script);
84 }
85 else
86 {
87 scripts[scriptName] = script;
88 }
89 }
90 }
91 return scripts;
92 }
93 return null;
94 }
95
96 public Dictionary<string,IScript> compile(string filename)
97 {
98 CSharpCodeProvider csharpProvider = new CSharpCodeProvider();
99 return LoadDotNetScript(csharpProvider, filename);
100 }
101 }
102}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs
new file mode 100644
index 0000000..be1fe56
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs
@@ -0,0 +1,102 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.CodeDom.Compiler;
30using System.Collections.Generic;
31using Microsoft.JScript;
32using OpenSim.Framework.Console;
33
34namespace OpenSim.Region.Environment.Scripting
35{
36 public class JScriptEngine : IScriptCompiler
37 {
38 public string FileExt()
39 {
40 return ".js";
41 }
42
43 private Dictionary<string, IScript> LoadDotNetScript(CodeDomProvider compiler, string filename)
44 {
45 CompilerParameters compilerParams = new CompilerParameters();
46 CompilerResults compilerResults;
47 compilerParams.GenerateExecutable = false;
48 compilerParams.GenerateInMemory = true;
49 compilerParams.IncludeDebugInformation = false;
50 compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll");
51 compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Enviroment.dll");
52 compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
53 compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
54 compilerParams.ReferencedAssemblies.Add("System.dll");
55
56 compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
57
58 if (compilerResults.Errors.Count > 0)
59 {
60 MainLog.Instance.Error("Compile errors");
61 foreach (CompilerError error in compilerResults.Errors)
62 {
63 MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString());
64 }
65 }
66 else
67 {
68 Dictionary<string, IScript> scripts = new Dictionary<string, IScript>();
69
70 foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
71 {
72 Type testInterface = pluginType.GetInterface("IScript", true);
73
74 if (testInterface != null)
75 {
76 IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
77
78 string scriptName = "JS.NET/" + script.getName();
79 Console.WriteLine("Script: " + scriptName + " loaded.");
80
81 if (!scripts.ContainsKey(scriptName))
82 {
83 scripts.Add(scriptName, script);
84 }
85 else
86 {
87 scripts[scriptName] = script;
88 }
89 }
90 }
91 return scripts;
92 }
93 return null;
94 }
95
96 public Dictionary<string, IScript> compile(string filename)
97 {
98 JScriptCodeProvider jscriptProvider = new JScriptCodeProvider();
99 return LoadDotNetScript(jscriptProvider, filename);
100 }
101 }
102}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/ClassInstance.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/ClassInstance.cs
new file mode 100644
index 0000000..1d93197
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/ClassInstance.cs
@@ -0,0 +1,45 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
31using OpenSim.Scripting.EmbeddedJVM.Types;
32
33namespace OpenSim.Scripting.EmbeddedJVM
34{
35 public class ClassInstance : Object
36 {
37 public int size;
38 public Dictionary<string, BaseType> Fields = new Dictionary<string, BaseType>();
39
40 public ClassInstance()
41 {
42
43 }
44 }
45}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/ClassRecord.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/ClassRecord.cs
new file mode 100644
index 0000000..f4ab1a2
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/ClassRecord.cs
@@ -0,0 +1,503 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.IO;
30using System.Collections.Generic;
31using System.Text;
32using OpenSim.Scripting.EmbeddedJVM.Types;
33
34namespace OpenSim.Scripting.EmbeddedJVM
35{
36 public class ClassRecord
37 {
38 private ushort _majorVersion;
39 private ushort _minorVersion;
40 private ushort _constantPoolCount;
41 private ushort _accessFlags;
42 private ushort _thisClass;
43 private ushort _supperClass;
44 private ushort _interfaceCount;
45 private ushort _fieldCount;
46 private ushort _methodCount;
47 //private ushort _attributeCount;
48 //private string _name;
49 public Dictionary<string, BaseType> StaticFields = new Dictionary<string, BaseType>();
50 public PoolClass mClass;
51
52 public List<PoolItem> _constantsPool = new List<PoolItem>();
53 private List<MethodInfo> _methodsList = new List<MethodInfo>();
54 private List<FieldInfo> _fieldList = new List<FieldInfo>();
55
56 public ClassRecord()
57 {
58
59 }
60
61 public ClassInstance CreateNewInstance()
62 {
63 return new ClassInstance();
64 }
65
66 public void LoadClassFromFile(string fileName)
67 {
68 Console.WriteLine("loading script " + fileName);
69 FileStream fs = File.OpenRead(fileName);
70 this.LoadClassFromBytes(ReadFully(fs));
71 fs.Close();
72 }
73
74 public void LoadClassFromBytes(byte[] data)
75 {
76 int i = 0;
77 i += 4;
78 _minorVersion = (ushort)((data[i++] << 8) + data[i++] );
79 _majorVersion = (ushort)((data[i++] << 8) + data[i++] );
80 _constantPoolCount = (ushort)((data[i++] << 8) + data[i++] );
81 // Console.WriteLine("there should be " + _constantPoolCount + " items in the pool");
82 for (int count = 0; count < _constantPoolCount -1 ; count++)
83 {
84 //read in the constant pool
85 byte pooltype = data[i++];
86 //Console.WriteLine("#" +count +": new constant type = " +pooltype);
87 //Console.WriteLine("start position is: " + i);
88 switch (pooltype)
89 {
90 case 1: //Utf8
91 ushort uLength = (ushort)((data[i++] << 8) + data[i++] );
92
93 // Console.WriteLine("new utf8 type, length is " + uLength);
94 PoolUtf8 utf8 = new PoolUtf8();
95 utf8.readValue(data, ref i, uLength);
96 this._constantsPool.Add(utf8);
97 break;
98 case 3: //Int
99 break;
100 case 7: //Class
101 PoolClass pClass = new PoolClass(this);
102 pClass.readValue(data, ref i);
103 this._constantsPool.Add(pClass);
104 break;
105 case 10: //Method
106 PoolMethodRef pMeth = new PoolMethodRef(this);
107 pMeth.readValue(data, ref i);
108 this._constantsPool.Add(pMeth);
109 break;
110 case 12: //NamedType
111 PoolNamedType pNamed = new PoolNamedType(this);
112 pNamed.readValue(data, ref i);
113 this._constantsPool.Add(pNamed);
114 break;
115 }
116 }
117
118 _accessFlags = (ushort)((data[i++] << 8) + data[i++] );
119 _thisClass = (ushort)((data[i++] << 8) + data[i++] );
120 _supperClass = (ushort)((data[i++] << 8) + data[i++] );
121
122 if (this._constantsPool[this._thisClass - 1] is PoolClass)
123 {
124 this.mClass = ((PoolClass)this._constantsPool[this._thisClass - 1]);
125 }
126
127 _interfaceCount = (ushort)((data[i++] << 8) + data[i++]);
128 //should now read in the info for each interface
129 _fieldCount = (ushort)((data[i++] << 8) + data[i++]);
130 //should now read in the info for each field
131 _methodCount = (ushort)((data[i++] << 8) + data[i++]);
132 for (int count = 0; count < _methodCount; count++)
133 {
134 MethodInfo methInf = new MethodInfo(this);
135 methInf.ReadData(data, ref i);
136 this._methodsList.Add(methInf);
137 }
138 }
139
140 public void AddMethodsToMemory(MethodMemory memory)
141 {
142 for (int count = 0; count < _methodCount; count++)
143 {
144 this._methodsList[count].AddMethodCode(memory);
145 }
146 }
147
148 public bool StartMethod(Thread thread, string methodName)
149 {
150 for (int count = 0; count < _methodCount; count++)
151 {
152 if (this._constantsPool[this._methodsList[count].NameIndex-1] is PoolUtf8)
153 {
154 if (((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex-1]).Value == methodName)
155 {
156 //Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value);
157 thread.SetPC(this._methodsList[count].CodePointer);
158 return true;
159 }
160 }
161 }
162 return false;
163 }
164
165 public void PrintToConsole()
166 {
167 Console.WriteLine("Class File:");
168 Console.WriteLine("Major version: " + _majorVersion);
169 Console.WriteLine("Minor version: " + _minorVersion);
170 Console.WriteLine("Pool size: " + _constantPoolCount);
171
172 for (int i = 0; i < _constantsPool.Count; i++)
173 {
174 this._constantsPool[i].Print();
175 }
176
177 Console.WriteLine("Access flags: " + _accessFlags);
178 Console.WriteLine("This class: " + _thisClass );
179 Console.WriteLine("Super class: " + _supperClass);
180
181 for (int count = 0; count < _methodCount; count++)
182 {
183 Console.WriteLine();
184 this._methodsList[count].Print();
185 }
186
187 Console.WriteLine("class name is " + this.mClass.Name.Value);
188 }
189
190 public static byte[] ReadFully(Stream stream)
191 {
192 byte[] buffer = new byte[1024];
193 using (MemoryStream ms = new MemoryStream())
194 {
195 while (true)
196 {
197 int read = stream.Read(buffer, 0, buffer.Length);
198 if (read <= 0)
199 return ms.ToArray();
200 ms.Write(buffer, 0, read);
201 }
202 }
203 }
204
205 #region nested classes
206 public class PoolItem
207 {
208 public virtual void Print()
209 {
210
211 }
212 }
213
214 public class PoolUtf8 : PoolItem
215 {
216 public string Value = "";
217
218 public void readValue(byte[] data,ref int pointer , int length)
219 {
220 for (int i = 0; i < length; i++)
221 {
222 int a =(int) data[pointer++];
223 if ((a & 0x80) == 0)
224 {
225 Value = Value + (char)a;
226 }
227 else if ((a & 0x20) == 0)
228 {
229 int b = (int) data[pointer++];
230 Value = Value + (char)(((a & 0x1f) << 6) + (b & 0x3f));
231 }
232 else
233 {
234 int b = (int)data[pointer++];
235 int c = (int)data[pointer++];
236 Value = Value + (char)(((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f));
237 }
238 }
239 }
240
241 public override void Print()
242 {
243 Console.WriteLine("Utf8 type: " + Value);
244 }
245 }
246
247 private class PoolInt : PoolItem
248 {
249
250 }
251
252 public class PoolClass : PoolItem
253 {
254 //public string name = "";
255 public ushort namePointer = 0;
256 private ClassRecord parent;
257 public PoolUtf8 Name;
258
259 public PoolClass(ClassRecord paren)
260 {
261 parent = paren;
262 }
263
264 public void readValue(byte[] data, ref int pointer)
265 {
266 namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] );
267 }
268
269 public override void Print()
270 {
271 this.Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]);
272 Console.Write("Class type: " + namePointer);
273 Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value);
274
275 }
276 }
277
278 public class PoolMethodRef : PoolItem
279 {
280 public ushort classPointer = 0;
281 public ushort nameTypePointer = 0;
282 public PoolNamedType mNameType;
283 public PoolClass mClass;
284 private ClassRecord parent;
285
286 public PoolMethodRef(ClassRecord paren)
287 {
288 parent = paren;
289 }
290
291 public void readValue(byte[] data, ref int pointer)
292 {
293 classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]);
294 nameTypePointer = (ushort)((data[pointer++] << 8) + data[pointer++]);
295 }
296
297 public override void Print()
298 {
299 this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]);
300 this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]);
301 Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer);
302 }
303 }
304
305 public class PoolNamedType : PoolItem
306 {
307 public ushort namePointer = 0;
308 public ushort typePointer = 0;
309 private ClassRecord parent;
310 public PoolUtf8 Name;
311 public PoolUtf8 Type;
312
313 public PoolNamedType(ClassRecord paren)
314 {
315 parent = paren;
316 }
317
318 public void readValue(byte[] data, ref int pointer)
319 {
320 namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] );
321 typePointer = (ushort)((data[pointer++] << 8) + data[pointer++] );
322 }
323
324 public override void Print()
325 {
326 Name = ((PoolUtf8)this.parent._constantsPool[namePointer-1]);
327 Type = ((PoolUtf8)this.parent._constantsPool[typePointer-1]);
328 Console.Write("Named type: " + namePointer + " , " + typePointer );
329 Console.WriteLine(" // "+ ((PoolUtf8)this.parent._constantsPool[namePointer-1]).Value);
330 }
331 }
332
333 //***********************
334 public class MethodInfo
335 {
336 public ushort AccessFlags = 0;
337 public ushort NameIndex = 0;
338 public string Name = "";
339 public ushort DescriptorIndex = 0;
340 public ushort AttributeCount = 0;
341 public List<MethodAttribute> Attributes = new List<MethodAttribute>();
342 private ClassRecord parent;
343 public int CodePointer = 0;
344
345 public MethodInfo(ClassRecord paren)
346 {
347 parent = paren;
348 }
349
350 public void AddMethodCode(MethodMemory memory)
351 {
352 Array.Copy(this.Attributes[0].Code, 0, memory.MethodBuffer, memory.NextMethodPC, this.Attributes[0].Code.Length);
353 memory.Methodcount++;
354 this.CodePointer = memory.NextMethodPC;
355 memory.NextMethodPC += this.Attributes[0].Code.Length;
356 }
357
358 public void ReadData(byte[] data, ref int pointer)
359 {
360 AccessFlags = (ushort)((data[pointer++] << 8) + data[pointer++]);
361 NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
362 DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
363 AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]);
364 for(int i =0; i< AttributeCount; i++)
365 {
366 MethodAttribute attri = new MethodAttribute(this.parent);
367 attri.ReadData(data, ref pointer);
368 this.Attributes.Add(attri);
369 }
370 }
371
372 public void Print()
373 {
374 Console.WriteLine("Method Info Struct: ");
375 Console.WriteLine("AccessFlags: " + AccessFlags);
376 Console.WriteLine("NameIndex: " + NameIndex +" // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value);
377 Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[DescriptorIndex-1]).Value);
378 Console.WriteLine("Attribute Count:" + AttributeCount);
379 for (int i = 0; i < AttributeCount; i++)
380 {
381 this.Attributes[i].Print();
382 }
383 }
384
385 public class MethodAttribute
386 {
387 public ushort NameIndex = 0;
388 public string Name = "";
389 public Int32 Length = 0;
390 //for now only support code attribute
391 public ushort MaxStack = 0;
392 public ushort MaxLocals = 0;
393 public Int32 CodeLength = 0;
394 public byte[] Code;
395 public ushort ExceptionTableLength = 0;
396 public ushort SubAttributeCount = 0;
397 public List<SubAttribute> SubAttributes = new List<SubAttribute>();
398 private ClassRecord parent;
399
400 public MethodAttribute(ClassRecord paren)
401 {
402 parent = paren;
403 }
404
405 public void ReadData(byte[] data, ref int pointer)
406 {
407 NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
408 Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]);
409 MaxStack = (ushort)((data[pointer++] << 8) + data[pointer++]);
410 MaxLocals = (ushort)((data[pointer++] << 8) + data[pointer++]);
411 CodeLength = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]);
412 Code = new byte[CodeLength];
413 for (int i = 0; i < CodeLength; i++)
414 {
415 Code[i] = data[pointer++];
416 }
417 ExceptionTableLength = (ushort)((data[pointer++] << 8) + data[pointer++]);
418 SubAttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]);
419 for (int i = 0; i < SubAttributeCount; i++)
420 {
421 SubAttribute subAttri = new SubAttribute(this.parent);
422 subAttri.ReadData(data, ref pointer);
423 this.SubAttributes.Add(subAttri);
424 }
425 }
426
427 public void Print()
428 {
429 Console.WriteLine("Method Attribute: ");
430 Console.WriteLine("Name Index: " + NameIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value);
431 Console.WriteLine("Length: " + Length);
432 Console.WriteLine("MaxStack: " + MaxStack);
433 Console.WriteLine("MaxLocals: " + MaxLocals);
434 Console.WriteLine("CodeLength: " + CodeLength);
435 for (int i = 0; i < Code.Length; i++)
436 {
437 Console.WriteLine("OpCode #" + i + " is: " + Code[i]);
438 }
439 Console.WriteLine("SubAttributes: " + SubAttributeCount);
440 for (int i = 0; i < SubAttributeCount; i++)
441 {
442 this.SubAttributes[i].Print();
443 }
444 }
445
446 public class SubAttribute
447 {
448 public ushort NameIndex = 0;
449 public string Name = "";
450 public Int32 Length = 0;
451 public byte[] Data;
452 private ClassRecord parent;
453
454 public SubAttribute(ClassRecord paren)
455 {
456 parent = paren;
457 }
458
459 public void ReadData(byte[] data, ref int pointer)
460 {
461 NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
462 Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]);
463 Data = new byte[Length];
464 for (int i = 0; i < Length; i++)
465 {
466 Data[i] = data[pointer++];
467 }
468 }
469
470 public void Print()
471 {
472 Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value);
473 }
474
475 }
476 }
477
478 }
479 private class InterfaceInfo
480 {
481 public void ReadData(byte[] data, ref int i)
482 {
483
484 }
485 }
486 private class FieldInfo
487 {
488 public void ReadData(byte[] data, ref int i)
489 {
490
491 }
492 }
493 private class AttributeInfo
494 {
495 public void ReadData(byte[] data, ref int i)
496 {
497
498 }
499 }
500 #endregion
501
502 }
503}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Heap.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Heap.cs
new file mode 100644
index 0000000..f213c36
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Heap.cs
@@ -0,0 +1,43 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
31
32namespace OpenSim.Scripting.EmbeddedJVM
33{
34 public class Heap
35 {
36 public List<ClassInstance> ClassObjects = new List<ClassInstance>();
37
38 public Heap()
39 {
40
41 }
42 }
43}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Interpreter.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Interpreter.cs
new file mode 100644
index 0000000..c5995b2
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Interpreter.cs
@@ -0,0 +1,135 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
31using OpenSim.Scripting.EmbeddedJVM.Types;
32using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
33
34namespace OpenSim.Scripting.EmbeddedJVM
35{
36 partial class Thread
37 {
38 private partial class Interpreter
39 {
40 private Thread _mThread;
41
42 public Interpreter(Thread parentThread)
43 {
44 _mThread = parentThread;
45 }
46
47 public bool Excute()
48 {
49 bool run = true;
50 byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC++];
51 // Console.WriteLine("opCode is: " + currentOpCode);
52 bool handled = false;
53
54 handled = this.IsLogicOpCode(currentOpCode);
55 if (!handled)
56 {
57 handled = this.IsMethodOpCode(currentOpCode);
58 }
59 if (!handled)
60 {
61 if (currentOpCode == 172)
62 {
63 if (this._mThread.stack.StackFrames.Count > 1)
64 {
65 Console.WriteLine("returning int from function");
66 int retPC1 = this._mThread.currentFrame.ReturnPC;
67 BaseType bas1 = this._mThread.currentFrame.OpStack.Pop();
68 this._mThread.stack.StackFrames.Pop();
69 this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
70 this._mThread.PC = retPC1;
71 if (bas1 is Int)
72 {
73 this._mThread.currentFrame.OpStack.Push((Int)bas1);
74 }
75 }
76 else
77 {
78 // Console.WriteLine("No parent function so ending program");
79 this._mThread.stack.StackFrames.Pop();
80 run = false;
81 }
82 handled = true;
83 }
84 if (currentOpCode == 174)
85 {
86 if (this._mThread.stack.StackFrames.Count > 1)
87 {
88 Console.WriteLine("returning float from function");
89 int retPC1 = this._mThread.currentFrame.ReturnPC;
90 BaseType bas1 = this._mThread.currentFrame.OpStack.Pop();
91 this._mThread.stack.StackFrames.Pop();
92 this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
93 this._mThread.PC = retPC1;
94 if (bas1 is Float)
95 {
96 this._mThread.currentFrame.OpStack.Push((Float)bas1);
97 }
98 }
99 else
100 {
101 // Console.WriteLine("No parent function so ending program");
102 this._mThread.stack.StackFrames.Pop();
103 run = false;
104 }
105 handled = true;
106 }
107 if (currentOpCode == 177)
108 {
109 if (this._mThread.stack.StackFrames.Count > 1)
110 {
111 Console.WriteLine("returning from function");
112 int retPC = this._mThread.currentFrame.ReturnPC;
113 this._mThread.stack.StackFrames.Pop();
114 this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
115 this._mThread.PC = retPC;
116 }
117 else
118 {
119 // Console.WriteLine("No parent function so ending program");
120 this._mThread.stack.StackFrames.Pop();
121 run = false;
122 }
123 handled = true;
124 }
125 }
126 if (!handled)
127 {
128 Console.WriteLine("opcode " + currentOpCode + " not been handled ");
129 }
130 return run;
131
132 }
133 }
134 }
135}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterLogic.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterLogic.cs
new file mode 100644
index 0000000..2a11afd
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterLogic.cs
@@ -0,0 +1,427 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
31using OpenSim.Scripting.EmbeddedJVM.Types;
32using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
33
34namespace OpenSim.Scripting.EmbeddedJVM
35{
36 partial class Thread
37 {
38 private partial class Interpreter
39 {
40 private bool IsLogicOpCode(byte opcode)
41 {
42 bool result = false;
43 switch (opcode)
44 {
45 case 2:
46 Int m_int= new Int();
47 m_int.mValue = -1;
48 this._mThread.currentFrame.OpStack.Push(m_int);
49 result = true;
50 break;
51 case 3:
52 m_int= new Int();
53 m_int.mValue = 0;
54 this._mThread.currentFrame.OpStack.Push(m_int);
55 result = true;
56 break;
57 case 4:
58 m_int = new Int();
59 m_int.mValue = 1;
60 this._mThread.currentFrame.OpStack.Push(m_int);
61 result = true;
62 break;
63 case 5:
64 m_int = new Int();
65 m_int.mValue = 2;
66 this._mThread.currentFrame.OpStack.Push(m_int);
67 result = true;
68 break;
69 case 6:
70 m_int = new Int();
71 m_int.mValue = 3;
72 this._mThread.currentFrame.OpStack.Push(m_int);
73 break;
74 case 7:
75 m_int = new Int();
76 m_int.mValue = 4;
77 this._mThread.currentFrame.OpStack.Push(m_int);
78 result = true;
79 break;
80 case 8:
81 m_int = new Int();
82 m_int.mValue = 5;
83 this._mThread.currentFrame.OpStack.Push(m_int);
84 result = true;
85 break;
86 case 11:
87 Float m_float = new Float();
88 m_float.mValue = 0.0f;
89 this._mThread.currentFrame.OpStack.Push(m_float);
90 result = true;
91 break;
92 case 12:
93 m_float = new Float();
94 m_float.mValue = 1.0f;
95 this._mThread.currentFrame.OpStack.Push(m_float);
96 result = true;
97 break;
98 case 13:
99 m_float = new Float();
100 m_float.mValue = 2.0f;
101 this._mThread.currentFrame.OpStack.Push(m_float);
102 result = true;
103 break;
104 case 16:
105 int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC];
106 Int pushInt = new Int();
107 pushInt.mValue = pushvalue;
108 this._mThread.currentFrame.OpStack.Push(pushInt);
109 this._mThread.PC++;
110 result = true;
111 break;
112 case 17:
113 short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
114 Int pushInt2 = new Int();
115 pushInt2.mValue = pushvalue2;
116 this._mThread.currentFrame.OpStack.Push(pushInt2);
117 this._mThread.PC += 2;
118 result = true;
119 break;
120 case 23:
121 short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]));
122 Float fload = new Float();
123 if (this._mThread.currentFrame.LocalVariables[findex1] != null)
124 {
125 if (this._mThread.currentFrame.LocalVariables[findex1] is Float)
126 {
127 fload.mValue = ((Float)this._mThread.currentFrame.LocalVariables[findex1]).mValue;
128 this._mThread.currentFrame.OpStack.Push(fload);
129 }
130 }
131 this._mThread.PC++;
132 result = true;
133 break;
134 case 26:
135 if (this._mThread.currentFrame.LocalVariables[0] != null)
136 {
137 if (this._mThread.currentFrame.LocalVariables[0] is Int)
138 {
139 Int newInt = new Int();
140 newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[0]).mValue;
141 this._mThread.currentFrame.OpStack.Push(newInt);
142 }
143 }
144 result = true;
145 break;
146 case 27:
147 if (this._mThread.currentFrame.LocalVariables[1] != null)
148 {
149 if (this._mThread.currentFrame.LocalVariables[1] is Int)
150 {
151 Int newInt = new Int();
152 newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[1]).mValue;
153 this._mThread.currentFrame.OpStack.Push(newInt);
154 }
155 }
156 result = true;
157 break;
158 case 34:
159 if (this._mThread.currentFrame.LocalVariables[0] != null)
160 {
161 if (this._mThread.currentFrame.LocalVariables[0] is Float)
162 {
163 Float newfloat = new Float();
164 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[0]).mValue;
165 this._mThread.currentFrame.OpStack.Push(newfloat);
166 }
167 }
168 result = true;
169 break;
170 case 35:
171 if (this._mThread.currentFrame.LocalVariables[1] != null)
172 {
173 if (this._mThread.currentFrame.LocalVariables[1] is Float)
174 {
175 Float newfloat = new Float();
176 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[1]).mValue;
177 this._mThread.currentFrame.OpStack.Push(newfloat);
178 }
179 }
180 result = true;
181 break;
182 case 36:
183 if (this._mThread.currentFrame.LocalVariables[2] != null)
184 {
185 if (this._mThread.currentFrame.LocalVariables[2] is Float)
186 {
187 Float newfloat = new Float();
188 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[2]).mValue;
189 this._mThread.currentFrame.OpStack.Push(newfloat);
190 }
191 }
192 result = true;
193 break;
194 case 37:
195 if (this._mThread.currentFrame.LocalVariables[3] != null)
196 {
197 if (this._mThread.currentFrame.LocalVariables[3] is Float)
198 {
199 Float newfloat = new Float();
200 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[3]).mValue;
201 this._mThread.currentFrame.OpStack.Push(newfloat);
202 }
203 }
204 result = true;
205 break;
206 case 56:
207 short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] ));
208 BaseType fstor = this._mThread.currentFrame.OpStack.Pop();
209 if (fstor is Float)
210 {
211 this._mThread.currentFrame.LocalVariables[findex] = (Float)fstor;
212 }
213 this._mThread.PC++;
214 result = true;
215 break;
216 case 59:
217 BaseType baset = this._mThread.currentFrame.OpStack.Pop();
218 if (baset is Int)
219 {
220 this._mThread.currentFrame.LocalVariables[0] = (Int)baset;
221 }
222 result = true;
223 break;
224 case 60:
225 baset = this._mThread.currentFrame.OpStack.Pop();
226 if (baset is Int)
227 {
228 this._mThread.currentFrame.LocalVariables[1] = (Int)baset;
229 }
230 result = true;
231 break;
232 case 67:
233 baset = this._mThread.currentFrame.OpStack.Pop();
234 if (baset is Float)
235 {
236 this._mThread.currentFrame.LocalVariables[0] = (Float)baset;
237 }
238 result = true;
239 break;
240 case 68:
241 baset = this._mThread.currentFrame.OpStack.Pop();
242 if (baset is Float)
243 {
244 this._mThread.currentFrame.LocalVariables[1] = (Float)baset;
245 }
246 result = true;
247 break;
248 case 69:
249 baset = this._mThread.currentFrame.OpStack.Pop();
250 if (baset is Float)
251 {
252 this._mThread.currentFrame.LocalVariables[2] = (Float)baset;
253 }
254 result = true;
255 break;
256 case 70:
257 baset = this._mThread.currentFrame.OpStack.Pop();
258 if (baset is Float)
259 {
260 this._mThread.currentFrame.LocalVariables[3] = (Float)baset;
261 }
262 result = true;
263 break;
264 case 87:
265 this._mThread.currentFrame.OpStack.Pop();
266 result = true;
267 break;
268 case 98:
269 BaseType bf2 = this._mThread.currentFrame.OpStack.Pop();
270 BaseType bf1 = this._mThread.currentFrame.OpStack.Pop();
271 if (bf1 is Float && bf2 is Float)
272 {
273 Float nflt = new Float();
274 nflt.mValue = ((Float)bf1).mValue + ((Float)bf2).mValue;
275 this._mThread.currentFrame.OpStack.Push(nflt);
276 }
277 result = true;
278 break;
279 case 102:
280 BaseType bsf2 = this._mThread.currentFrame.OpStack.Pop();
281 BaseType bsf1 = this._mThread.currentFrame.OpStack.Pop();
282 if (bsf1 is Float && bsf2 is Float)
283 {
284 Float resf = new Float();
285 resf.mValue = ((Float)bsf1).mValue - ((Float)bsf2).mValue;
286 this._mThread.currentFrame.OpStack.Push(resf);
287 }
288 result = true;
289 break;
290 case 104: //check the order of the two values off the stack is correct
291 BaseType bs2 = this._mThread.currentFrame.OpStack.Pop();
292 BaseType bs1 = this._mThread.currentFrame.OpStack.Pop();
293 if (bs1 is Int && bs2 is Int)
294 {
295 Int nInt = new Int();
296 nInt.mValue = ((Int)bs1).mValue * ((Int)bs2).mValue;
297 this._mThread.currentFrame.OpStack.Push(nInt);
298 }
299 result = true;
300 break;
301 case 132:
302 if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] != null)
303 {
304 if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] is Int)
305 {
306 ((Int)this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]]).mValue += (sbyte) GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1];
307 }
308 }
309 this._mThread.PC += 2;
310 result = true;
311 break;
312 case 139:
313 BaseType conv1 = this._mThread.currentFrame.OpStack.Pop();
314 if (conv1 is Float)
315 {
316 Int newconv = new Int();
317 newconv.mValue = (int)((Float)conv1).mValue;
318 this._mThread.currentFrame.OpStack.Push(newconv);
319 }
320 result = true;
321 break;
322 case 149:
323 BaseType flcom2 = this._mThread.currentFrame.OpStack.Pop();
324 BaseType flcom1 = this._mThread.currentFrame.OpStack.Pop();
325 if (flcom1 is Float && flcom2 is Float)
326 {
327 Int compres = new Int();
328 if (((Float)flcom1).mValue < ((Float)flcom2).mValue)
329 {
330 compres.mValue = -1;
331 }
332 else if (((Float)flcom1).mValue > ((Float)flcom2).mValue)
333 {
334 compres.mValue = 1;
335 }
336 else
337 {
338 compres.mValue = 0;
339 }
340 this._mThread.currentFrame.OpStack.Push(compres);
341 }
342 result = true;
343 break;
344 case 158:
345 short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
346 BaseType comp1 = this._mThread.currentFrame.OpStack.Pop();
347 if (comp1 is Int)
348 {
349 if (((Int)comp1).mValue <= 0)
350 {
351 this._mThread.PC += -1 + compareoffset1;
352 }
353 else
354 {
355 this._mThread.PC += 2;
356 }
357 }
358 else
359 {
360 this._mThread.PC += 2;
361 }
362 result = true;
363 break;
364 case 162:
365 short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
366 BaseType bc2 = this._mThread.currentFrame.OpStack.Pop();
367 BaseType bc1 = this._mThread.currentFrame.OpStack.Pop();
368 if (bc1 is Int && bc2 is Int)
369 {
370 //Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue);
371 if (((Int)bc1).mValue >= ((Int)bc2).mValue)
372 {
373 // Console.WriteLine("branch compare true , offset is " +compareoffset);
374 // Console.WriteLine("current PC is " + this._mThread.PC);
375 this._mThread.PC += -1 + compareoffset;
376 //Console.WriteLine("new PC is " + this._mThread.PC);
377 }
378 else
379 {
380 //Console.WriteLine("branch compare false");
381 this._mThread.PC += 2;
382 }
383 }
384 else
385 {
386 this._mThread.PC += 2;
387 }
388 result = true;
389 break;
390 case 164:
391 short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
392 BaseType bcl2 = this._mThread.currentFrame.OpStack.Pop();
393 BaseType bcl1 = this._mThread.currentFrame.OpStack.Pop();
394 if (bcl1 is Int && bcl2 is Int)
395 {
396 //Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue);
397 if (((Int)bcl1).mValue <= ((Int)bcl2).mValue)
398 {
399 // Console.WriteLine("branch compare true , offset is " + compareloffset);
400 // Console.WriteLine("current PC is " + this._mThread.PC);
401 this._mThread.PC += -1 + compareloffset;
402 // Console.WriteLine("new PC is " + this._mThread.PC);
403 }
404 else
405 {
406 //Console.WriteLine("branch compare false");
407 this._mThread.PC += 2;
408 }
409 }
410 else
411 {
412 this._mThread.PC += 2;
413 }
414 result = true;
415 break;
416 case 167:
417 short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]);
418 this._mThread.PC += -1 + offset;
419 result = true;
420 break;
421 }
422
423 return result;
424 }
425 }
426 }
427}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterMethods.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterMethods.cs
new file mode 100644
index 0000000..4d60559
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterMethods.cs
@@ -0,0 +1,96 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
31using OpenSim.Scripting.EmbeddedJVM.Types;
32using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
33using OpenSim.Framework.Interfaces;
34using OpenSim.Framework;
35using OpenSim.Framework.Types;
36
37namespace OpenSim.Scripting.EmbeddedJVM
38{
39 partial class Thread
40 {
41 private partial class Interpreter
42 {
43 private bool IsMethodOpCode(byte opcode)
44 {
45 bool result = false;
46 switch (opcode)
47 {
48 case 184:
49 short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]);
50 if (this._mThread.currentClass._constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef)
51 {
52 string typ = ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Type.Value;
53 string typeparam = "";
54 string typereturn = "";
55 int firstbrak = 0;
56 int secondbrak = 0;
57 firstbrak = typ.LastIndexOf('(');
58 secondbrak = typ.LastIndexOf(')');
59 typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1);
60 typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1);
61 if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value)
62 {
63 //calling a method in this class
64 if (typeparam.Length == 0)
65 {
66 this._mThread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, (this._mThread.PC + 2));
67 }
68 else
69 {
70 this._mThread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this._mThread.PC + 2));
71 }
72 }
73 else
74 {
75 //calling a method of a different class
76
77 // OpenSimAPI Class
78 if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI")
79 {
80 this._mThread.scriptInfo.api.CallMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, null);
81 }
82 }
83 }
84 else
85 {
86 this._mThread.PC += 2;
87 }
88 result = true;
89 break;
90 }
91
92 return result;
93 }
94 }
95 }
96}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterReturn.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterReturn.cs
new file mode 100644
index 0000000..cbedb71
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterReturn.cs
@@ -0,0 +1,40 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
31
32namespace OpenSim.Scripting.EmbeddedJVM
33{
34 partial class Thread
35 {
36 private partial class Interpreter
37 {
38 }
39 }
40}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JavaEngine.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JavaEngine.cs
new file mode 100644
index 0000000..1773156
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JavaEngine.cs
@@ -0,0 +1,29 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5using OpenSim.Region.Environment.Scripting;
6using OpenSim.Scripting.EmbeddedJVM;
7
8namespace OpenSim.Region.Environment.Scripting
9{
10 public class JavaEngine : IScriptCompiler
11 {
12 public string FileExt()
13 {
14 return ".java";
15 }
16
17 public Dictionary<string, IScript> compile(string filename)
18 {
19 JVMScript script = new JVMScript();
20 Dictionary<string, IScript> returns = new Dictionary<string, IScript>();
21
22 script.LoadScript(filename);
23
24 returns.Add(filename, script);
25
26 return returns;
27 }
28 }
29}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/MainMemory.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/MainMemory.cs
new file mode 100644
index 0000000..97d9fb6
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/MainMemory.cs
@@ -0,0 +1,45 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
31
32namespace OpenSim.Scripting.EmbeddedJVM
33{
34 public class MainMemory
35 {
36 public Heap HeapArea;
37 public MethodMemory MethodArea;
38
39 public MainMemory()
40 {
41 MethodArea = new MethodMemory();
42 HeapArea = new Heap();
43 }
44 }
45}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/MethodMemory.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/MethodMemory.cs
new file mode 100644
index 0000000..7e938b4
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/MethodMemory.cs
@@ -0,0 +1,46 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
31
32namespace OpenSim.Scripting.EmbeddedJVM
33{
34 public class MethodMemory
35 {
36 public byte[] MethodBuffer;
37 public List<ClassRecord> Classes = new List<ClassRecord>();
38 public int NextMethodPC = 0;
39 public int Methodcount = 0;
40
41 public MethodMemory()
42 {
43 MethodBuffer = new byte[20000];
44 }
45 }
46}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Object.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Object.cs
new file mode 100644
index 0000000..2c3bedd
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Object.cs
@@ -0,0 +1,37 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
31
32namespace OpenSim.Scripting.EmbeddedJVM
33{
34 public class Object
35 {
36 }
37}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/OpenSimJVM.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/OpenSimJVM.cs
new file mode 100644
index 0000000..3e083cc
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/OpenSimJVM.cs
@@ -0,0 +1,171 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
31using System.IO;
32using System.Threading;
33using OpenSim.Framework;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Utilities;
36using OpenSim.Region.Environment.Scripting;
37using OpenSim.Region.Environment.Scenes;
38
39namespace OpenSim.Scripting.EmbeddedJVM
40{
41 public class JVMScript : IScript
42 {
43 private List<Thread> _threads = new List<Thread>();
44 private BlockingQueue<CompileInfo> CompileScripts = new BlockingQueue<CompileInfo>();
45 private MainMemory _mainMemory;
46 private System.Threading.Thread compileThread;
47
48 ScriptInfo scriptInfo;
49
50 public void Initialise(ScriptInfo info)
51 {
52 scriptInfo = info;
53
54 _mainMemory = new MainMemory();
55 Thread.GlobalMemory = this._mainMemory;
56 Thread.World = info.world;
57 CompileScript();
58
59 scriptInfo.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame);
60 scriptInfo.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence);
61 }
62
63 void events_OnNewPresence(ScenePresence presence)
64 {
65 for (int i = 0; i < this._threads.Count; i++)
66 {
67 if (!this._threads[i].running)
68 {
69 this._threads[i].StartMethod("OnNewPresence");
70 bool run = true;
71 while (run)
72 {
73 run = this._threads[i].Excute();
74 }
75 }
76 }
77 }
78
79 void events_OnFrame()
80 {
81 for (int i = 0; i < this._threads.Count; i++)
82 {
83 if (!this._threads[i].running)
84 {
85 this._threads[i].StartMethod("OnFrame");
86 bool run = true;
87 while (run)
88 {
89 run = this._threads[i].Excute();
90 }
91 }
92 }
93 }
94
95 public string getName()
96 {
97 return "JVM Scripting Engine";
98 }
99
100 public void LoadScript(string script)
101 {
102 Console.WriteLine("OpenSimJVM - loading new script: " + script);
103 CompileInfo comp = new CompileInfo();
104 comp.script = script;
105 comp.scriptName = script;
106 this.CompileScripts.Enqueue(comp);
107 }
108
109 public void CompileScript()
110 {
111 CompileInfo comp = this.CompileScripts.Dequeue();
112 string script = comp.script;
113 string scriptName = comp.scriptName;
114 try
115 {
116 //need to compile the script into a java class file
117
118 //first save it to a java source file
119 TextWriter tw = new StreamWriter(scriptName + ".java");
120 tw.WriteLine(script);
121 tw.Close();
122
123 //now compile
124 System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("javac.exe", "*.java");
125 // psi.RedirectStandardOutput = true;
126 psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
127 psi.UseShellExecute = false;
128
129 System.Diagnostics.Process javacomp;
130 javacomp = System.Diagnostics.Process.Start(psi);
131 javacomp.WaitForExit();
132
133
134 //now load in class file
135 ClassRecord class1 = new ClassRecord();
136 class1.LoadClassFromFile(scriptName + ".class");
137 class1.PrintToConsole();
138 //Console.WriteLine();
139 this._mainMemory.MethodArea.Classes.Add(class1);
140 class1.AddMethodsToMemory(this._mainMemory.MethodArea);
141
142 Thread newThread = new Thread();
143 this._threads.Add(newThread);
144 newThread.currentClass = class1;
145 newThread.scriptInfo = scriptInfo;
146
147 //now delete the created files
148 System.IO.File.Delete(scriptName + ".java");
149 System.IO.File.Delete(scriptName + ".class");
150 //this.OnFrame();
151 }
152 catch (Exception e)
153 {
154 Console.WriteLine("exception");
155 Console.WriteLine(e.StackTrace);
156 Console.WriteLine(e.Message);
157 }
158 }
159
160 private class CompileInfo
161 {
162 public string script;
163 public string scriptName;
164
165 public CompileInfo()
166 {
167
168 }
169 }
170 }
171}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Stack.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Stack.cs
new file mode 100644
index 0000000..69a274c
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Stack.cs
@@ -0,0 +1,42 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
31
32namespace OpenSim.Scripting.EmbeddedJVM
33{
34 public class Stack
35 {
36 public Stack<StackFrame> StackFrames = new Stack<StackFrame>();
37
38 public Stack()
39 {
40 }
41 }
42}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/StackFrame.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/StackFrame.cs
new file mode 100644
index 0000000..3a2b58a
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/StackFrame.cs
@@ -0,0 +1,49 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
31using OpenSim.Scripting.EmbeddedJVM.Types;
32
33namespace OpenSim.Scripting.EmbeddedJVM
34{
35 public class StackFrame
36 {
37 public BaseType[] LocalVariables;
38 public Stack<BaseType> OpStack = new Stack<BaseType>();
39
40 public int ReturnPC = 0;
41 public ClassRecord CallingClass = null;
42
43 public StackFrame()
44 {
45 LocalVariables = new BaseType[20];
46 }
47
48 }
49}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Thread.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Thread.cs
new file mode 100644
index 0000000..3993436
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Thread.cs
@@ -0,0 +1,119 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
31using OpenSim.Scripting.EmbeddedJVM.Types;
32using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
33using OpenSim.Framework;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Region.Environment.Scenes;
36using OpenSim.Region.Environment.Scripting;
37
38namespace OpenSim.Scripting.EmbeddedJVM
39{
40 public partial class Thread
41 {
42 // Is this smart?
43 public static MainMemory GlobalMemory;
44 public static Scene World;
45 private int PC = 0;
46 private Stack stack;
47 private Interpreter mInterpreter;
48 public ClassRecord currentClass;
49 public ClassInstance currentInstance;
50 private StackFrame currentFrame;
51 public int excutionCounter = 0;
52 public bool running = false;
53
54 public ScriptInfo scriptInfo;
55
56 public Thread()
57 {
58 this.mInterpreter = new Interpreter(this);
59 this.stack = new Stack();
60 }
61
62 public void SetPC(int methodpointer)
63 {
64 //Console.WriteLine("Thread PC has been set to " + methodpointer);
65 PC = methodpointer;
66 }
67
68 public void StartMethod(ClassRecord rec, string methName)
69 {
70 currentFrame = new StackFrame();
71 this.stack.StackFrames.Push(currentFrame);
72 this.currentClass = rec;
73 currentClass.StartMethod(this, methName);
74 }
75
76 public void StartMethod( string methName)
77 {
78 currentFrame = new StackFrame();
79 this.stack.StackFrames.Push(currentFrame);
80 currentClass.StartMethod(this, methName);
81 }
82
83 public void JumpToStaticVoidMethod(string methName, int returnPC)
84 {
85 currentFrame = new StackFrame();
86 currentFrame.ReturnPC = returnPC;
87 this.stack.StackFrames.Push(currentFrame);
88 currentClass.StartMethod(this, methName);
89 }
90
91 public void JumpToStaticParamMethod(string methName, string param, int returnPC)
92 {
93 if (param == "I")
94 {
95 BaseType bs1 = currentFrame.OpStack.Pop();
96 currentFrame = new StackFrame();
97 currentFrame.ReturnPC = returnPC;
98 this.stack.StackFrames.Push(currentFrame);
99 currentFrame.LocalVariables[0] = ((Int)bs1);
100 currentClass.StartMethod(this, methName);
101 }
102 if (param == "F")
103 {
104
105 }
106 }
107
108 public void JumpToClassStaticVoidMethod(string className, string methName, int returnPC)
109 {
110
111 }
112
113 public bool Excute()
114 {
115 excutionCounter++;
116 return this.mInterpreter.Excute();
117 }
118 }
119}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ArrayReference.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ArrayReference.cs
new file mode 100644
index 0000000..2854eab
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ArrayReference.cs
@@ -0,0 +1,10 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM.Types
6{
7 public class ArrayReference :BaseType
8 {
9 }
10}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/BaseType.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/BaseType.cs
new file mode 100644
index 0000000..270aa7b
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/BaseType.cs
@@ -0,0 +1,10 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM.Types
6{
7 public class BaseType : Object
8 {
9 }
10}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ObjectReference.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ObjectReference.cs
new file mode 100644
index 0000000..da28eaa
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ObjectReference.cs
@@ -0,0 +1,16 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM.Types
6{
7 public class ObjectReference : BaseType
8 {
9 public ushort Reference;
10
11 public ObjectReference()
12 {
13
14 }
15 }
16}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs
new file mode 100644
index 0000000..1a3ecff
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs
@@ -0,0 +1,10 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes
6{
7 public class Byte : BaseType
8 {
9 }
10}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs
new file mode 100644
index 0000000..19002d4
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs
@@ -0,0 +1,10 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes
6{
7 public class Char : BaseType
8 {
9 }
10}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs
new file mode 100644
index 0000000..91f1679
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs
@@ -0,0 +1,16 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes
6{
7 public class Float : BaseType
8 {
9 public float mValue = 0;
10
11 public Float()
12 {
13
14 }
15 }
16}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs
new file mode 100644
index 0000000..4ecd325
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs
@@ -0,0 +1,16 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes
6{
7 public class Int : BaseType
8 {
9 public int mValue = 0;
10
11 public Int()
12 {
13
14 }
15 }
16}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Script.cs b/OpenSim/Region/Environment/Scenes/scripting/Script.cs
new file mode 100644
index 0000000..139bdf1
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Script.cs
@@ -0,0 +1,64 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Region.Environment.Scenes;
29
30namespace OpenSim.Region.Environment.Scripting
31{
32 public interface IScript
33 {
34 void Initialise(ScriptInfo scriptInfo);
35 string getName();
36 }
37
38 public class TestScript : IScript
39 {
40 ScriptInfo script;
41
42 public string getName()
43 {
44 return "TestScript 0.1";
45 }
46
47 public void Initialise(ScriptInfo scriptInfo)
48 {
49 script = scriptInfo;
50 script.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame);
51 script.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence);
52 }
53
54 void events_OnNewPresence(ScenePresence presence)
55 {
56 script.logger.Verbose("Hello " + presence.firstname.ToString() + "!");
57 }
58
59 void events_OnFrame()
60 {
61 //script.logger.Verbose("Hello World!");
62 }
63 }
64}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs
new file mode 100644
index 0000000..fd601cb
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs
@@ -0,0 +1,25 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5using OpenSim.Region.Environment.Scenes;
6
7namespace OpenSim.Region.Environment.Scripting
8{
9 // This class is to be used for engines which may not be able to access the Scene directly.
10 // Scene access is preffered, but obviously not possible on some non-.NET languages.
11 public class ScriptAPI
12 {
13 Scene scene;
14
15 public ScriptAPI(Scene world)
16 {
17 scene = world;
18 }
19
20 public Object CallMethod(String method, Object[] args)
21 {
22 return null;
23 }
24 }
25}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs
new file mode 100644
index 0000000..ed6f033
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs
@@ -0,0 +1,58 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Console;
29using OpenSim.Region.Environment.Scenes;
30
31namespace OpenSim.Region.Environment.Scripting
32{
33 /// <summary>
34 /// Class which provides access to the world
35 /// </summary>
36 public class ScriptInfo
37 {
38 // Reference to world.eventsManager provided for convenience
39 public EventManager events;
40
41 // The main world
42 public Scene world;
43
44 // The console
45 public LogBase logger;
46
47 // API Access
48 public ScriptAPI api;
49
50 public ScriptInfo(Scene scene)
51 {
52 world = scene;
53 events = world.eventManager;
54 logger = MainLog.Instance;
55 api = new ScriptAPI(scene);
56 }
57 }
58}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs
new file mode 100644
index 0000000..153f4d7
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs
@@ -0,0 +1,99 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Collections.Generic;
29using OpenSim.Framework.Console;
30using OpenSim.Region.Environment.Scenes;
31
32namespace OpenSim.Region.Environment.Scripting
33{
34 public class ScriptManager
35 {
36 List<IScript> scripts = new List<IScript>();
37 Scene scene;
38 Dictionary<string, IScriptCompiler> compilers = new Dictionary<string, IScriptCompiler>();
39
40 private void LoadFromCompiler(Dictionary<string, IScript> compiledscripts)
41 {
42 foreach (KeyValuePair<string, IScript> script in compiledscripts)
43 {
44 ScriptInfo scriptInfo = new ScriptInfo(scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script.
45 MainLog.Instance.Verbose("Loading " + script.Key);
46 script.Value.Initialise(scriptInfo);
47 scripts.Add(script.Value);
48 }
49 MainLog.Instance.Verbose("Finished loading " + compiledscripts.Count.ToString() + " script(s)");
50 }
51
52 public ScriptManager(Scene world)
53 {
54 scene = world;
55
56 // Default Engines
57 CSharpScriptEngine csharpCompiler = new CSharpScriptEngine();
58 compilers.Add(csharpCompiler.FileExt(),csharpCompiler);
59
60 JScriptEngine jscriptCompiler = new JScriptEngine();
61 compilers.Add(jscriptCompiler.FileExt(), jscriptCompiler);
62
63 JavaEngine javaCompiler = new JavaEngine();
64 compilers.Add(javaCompiler.FileExt(), javaCompiler);
65 }
66
67 public void Compile(string filename)
68 {
69 foreach (KeyValuePair<string, IScriptCompiler> compiler in compilers)
70 {
71 if (filename.EndsWith(compiler.Key))
72 {
73 LoadFromCompiler(compiler.Value.compile(filename));
74 break;
75 }
76 }
77 }
78
79 public void RunScriptCmd(string[] args)
80 {
81 switch (args[0])
82 {
83 case "load":
84 Compile(args[1]);
85 break;
86
87 default:
88 MainLog.Instance.Error("Unknown script command");
89 break;
90 }
91 }
92 }
93
94 interface IScriptCompiler
95 {
96 Dictionary<string,IScript> compile(string filename);
97 string FileExt();
98 }
99}
diff --git a/OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs b/OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs
new file mode 100644
index 0000000..d0ef2af
--- /dev/null
+++ b/OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs
@@ -0,0 +1,10 @@
1using System.Collections;
2using System.Text;
3using libsecondlife;
4using OpenSim.Region.Capabilities;
5using System.IO;
6
7namespace OpenSim.Framework.Servers
8{
9
10}
diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
new file mode 100644
index 0000000..3c69420
--- /dev/null
+++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
@@ -0,0 +1,93 @@
1using System.Collections.Generic;
2using libsecondlife;
3using OpenSim.Framework;
4using OpenSim.Framework.Communications;
5using OpenSim.Framework.Interfaces;
6using OpenSim.Framework.Servers;
7using OpenSim.Framework.Types;
8using OpenSim.Region.Caches;
9using OpenSim.Region.Environment.Scenes;
10using Avatar=OpenSim.Region.Environment.Scenes.ScenePresence;
11
12namespace SimpleApp
13{
14 public class MyWorld : Scene
15 {
16 private List<ScenePresence> m_avatars;
17
18 public MyWorld(ClientManager clientManager, RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer)
19 : base(clientManager, regionInfo, authen, commsMan, assetCach, httpServer)
20 {
21 m_avatars = new List<Avatar>();
22 }
23
24 public override void SendLayerData(IClientAPI remoteClient)
25 {
26 float[] map = new float[65536];
27
28 for (int i = 0; i < 65536; i++)
29 {
30 int x = i % 256;
31 int y = i / 256;
32
33 map[i] = (float)(x + y / 2);
34 }
35
36 remoteClient.SendLayerData(map);
37 }
38
39 #region IWorld Members
40
41 override public void AddNewClient(IClientAPI client, bool child)
42
43 {
44 LLVector3 pos = new LLVector3(128, 128, 128);
45
46 client.OnRegionHandShakeReply += SendLayerData;
47 client.OnChatFromViewer +=
48 delegate(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
49 {
50 // Echo it (so you know what you typed)
51 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
52 client.SendChatMessage("Ready.", 1, pos, "System", LLUUID.Zero );
53 };
54
55 client.OnRequestWearables += SendWearables;
56 client.OnAddPrim += AddNewPrim;
57 client.OnUpdatePrimGroupPosition += this.UpdatePrimPosition;
58 client.OnRequestMapBlocks += this.RequestMapBlocks;
59 client.OnTeleportLocationRequest += this.RequestTeleportLocation;
60 client.OnGrapUpdate += this.MoveObject;
61 client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest;
62
63 client.OnCompleteMovementToRegion += delegate()
64 {
65 client.MoveAgentIntoRegion(m_regInfo, pos, LLVector3.Zero );
66 };
67
68 client.OnCompleteMovementToRegion += delegate()
69 {
70 client.SendAvatarData(m_regInfo.RegionHandle, client.FirstName,
71 client.LastName, client.AgentId, 0,
72 pos, null);
73
74 client.SendChatMessage("Welcome to My World.", 1, pos, "System", LLUUID.Zero );
75
76
77
78 };
79
80 client.SendRegionHandshake(m_regInfo);
81
82 CreateAndAddScenePresence(client);
83
84 }
85
86 private void SendWearables( IClientAPI client )
87 {
88 client.SendWearables( AvatarWearable.DefaultWearables );
89 }
90
91 #endregion
92 }
93}
diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs
new file mode 100644
index 0000000..87e877c
--- /dev/null
+++ b/OpenSim/Region/Examples/SimpleApp/Program.cs
@@ -0,0 +1,130 @@
1using System;
2using System.Net;
3using libsecondlife;
4using OpenSim.Assets;
5using OpenSim.Framework;
6using OpenSim.Framework.Console;
7using OpenSim.Framework.Interfaces;
8using OpenSim.Framework.Servers;
9using OpenSim.Framework.Types;
10using OpenSim.Physics.Manager;
11using OpenSim.Region.Caches;
12using OpenSim.Region.Capabilities;
13using OpenSim.Region.ClientStack;
14using OpenSim.Region.Communications.Local;
15using OpenSim.Region.GridInterfaces.Local;
16
17namespace SimpleApp
18{
19 class Program : IAssetReceiver, conscmd_callback
20 {
21 private LogBase m_log;
22 AuthenticateSessionsBase m_circuitManager;
23 uint m_localId;
24
25 private void Run()
26 {
27 m_log = new LogBase(null, "SimpleApp", this, false);
28 MainLog.Instance = m_log;
29
30 // CheckSumServer checksumServer = new CheckSumServer(12036);
31 // checksumServer.ServerListener();
32
33 IPEndPoint internalEndPoint = new IPEndPoint( IPAddress.Parse( "127.0.0.1" ), 9000 );
34
35 m_circuitManager = new AuthenticateSessionsBase();
36
37 InventoryCache inventoryCache = new InventoryCache();
38
39 LocalAssetServer assetServer = new LocalAssetServer();
40 assetServer.SetServerInfo("http://127.0.0.1:8003/", "");
41 assetServer.SetReceiver(this);
42
43 AssetCache assetCache = new AssetCache(assetServer);
44
45 UDPServer udpServer = new UDPServer( internalEndPoint.Port, assetCache, inventoryCache, m_log, m_circuitManager );
46 PacketServer packetServer = new PacketServer(udpServer);
47 udpServer.ServerListener();
48
49 ClientView.TerrainManager = new TerrainManager(new SecondLife());
50 BaseHttpServer httpServer = new BaseHttpServer(internalEndPoint.Port);
51
52 NetworkServersInfo serverInfo = new NetworkServersInfo();
53 CommunicationsLocal communicationsManager = new CommunicationsLocal(serverInfo, httpServer);
54
55 RegionInfo regionInfo = new RegionInfo( 1000, 1000, internalEndPoint, "127.0.0.1" );
56
57 MyWorld world = new MyWorld(packetServer.ClientManager, regionInfo, m_circuitManager, communicationsManager, assetCache, httpServer);
58 world.PhysScene = PhysicsScene.Null;
59 udpServer.LocalWorld = world;
60
61 httpServer.AddXmlRPCHandler("login_to_simulator", communicationsManager.UserServices.XmlRpcLoginMethod );
62
63 httpServer.Start();
64
65 m_log.WriteLine( LogPriority.NORMAL, "Press enter to quit.");
66 m_log.ReadLine();
67
68 PrimData primData = new PrimData();
69 primData.Scale = new LLVector3(1, 1, 1);
70
71 m_localId = world.AddNewPrim( LLUUID.Zero, primData, LLVector3.Zero, new LLQuaternion(0, 0, 0, 0), LLUUID.Zero, 0);
72
73 }
74
75 private bool AddNewSessionHandler(ulong regionHandle, Login loginData)
76 {
77 m_log.WriteLine(LogPriority.NORMAL, "Region [{0}] recieved Login from [{1}] [{2}]", regionHandle, loginData.First, loginData.Last);
78
79 AgentCircuitData agent = new AgentCircuitData();
80 agent.AgentID = loginData.Agent;
81 agent.firstname = loginData.First;
82 agent.lastname = loginData.Last;
83 agent.SessionID = loginData.Session;
84 agent.SecureSessionID = loginData.SecureSession;
85 agent.circuitcode = loginData.CircuitCode;
86 agent.BaseFolder = loginData.BaseFolder;
87 agent.InventoryFolder = loginData.InventoryFolder;
88 agent.startpos = new LLVector3(128, 128, 70);
89
90 m_circuitManager.AddNewCircuit(agent.circuitcode, agent);
91
92 return true;
93 }
94
95 #region IAssetReceiver Members
96
97 public void AssetReceived( AssetBase asset, bool IsTexture)
98 {
99 throw new Exception("The method or operation is not implemented.");
100 }
101
102 public void AssetNotFound( AssetBase asset)
103 {
104 throw new Exception("The method or operation is not implemented.");
105 }
106
107 #endregion
108
109 #region conscmd_callback Members
110
111 public void RunCmd(string cmd, string[] cmdparams)
112 {
113 throw new Exception("The method or operation is not implemented.");
114 }
115
116 public void Show(string ShowWhat)
117 {
118 throw new Exception("The method or operation is not implemented.");
119 }
120
121 #endregion
122
123 static void Main(string[] args)
124 {
125 Program app = new Program();
126
127 app.Run();
128 }
129 }
130}
diff --git a/OpenSim/Region/Examples/SimpleApp/Properties/AssemblyInfo.cs b/OpenSim/Region/Examples/SimpleApp/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..3b0de8a
--- /dev/null
+++ b/OpenSim/Region/Examples/SimpleApp/Properties/AssemblyInfo.cs
@@ -0,0 +1,31 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("SimpleApp")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("Playahead AB")]
10[assembly: AssemblyProduct("SimpleApp")]
11[assembly: AssemblyCopyright("Copyright © Playahead AB 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("a5cfa45f-5acf-4b2e-9c50-1dd1fd7608ee")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30[assembly: AssemblyVersion("1.0.0.0")]
31[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/GridInterfaces/Local/AssemblyInfo.cs b/OpenSim/Region/GridInterfaces/Local/AssemblyInfo.cs
new file mode 100644
index 0000000..b5fc1ef
--- /dev/null
+++ b/OpenSim/Region/GridInterfaces/Local/AssemblyInfo.cs
@@ -0,0 +1,56 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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// Information about this assembly is defined by the following
31// attributes.
32//
33// change them to the information which is associated with the assembly
34// you compile.
35
36[assembly: AssemblyTitle("LocalGridServers")]
37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("LocalGridServers")]
41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")]
44
45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)]
48
49// The assembly version has following format :
50//
51// Major.Minor.Build.Revision
52//
53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default):
55
56[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs b/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs
new file mode 100644
index 0000000..54d43a1
--- /dev/null
+++ b/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs
@@ -0,0 +1,311 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.IO;
30using System.Threading;
31using Db4objects.Db4o;
32using Db4objects.Db4o.Query;
33using libsecondlife;
34using OpenSim.Framework.Console;
35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework.Types;
37using OpenSim.Framework.Utilities;
38
39namespace OpenSim.Region.GridInterfaces.Local
40{
41 public class LocalAssetPlugin : IAssetPlugin
42 {
43 public LocalAssetPlugin()
44 {
45
46 }
47
48 public IAssetServer GetAssetServer()
49 {
50 return (new LocalAssetServer());
51 }
52 }
53
54 public class LocalAssetServer : IAssetServer
55 {
56 private IAssetReceiver _receiver;
57 private BlockingQueue<ARequest> _assetRequests;
58 private IObjectContainer db;
59 private Thread _localAssetServerThread;
60
61 public LocalAssetServer()
62 {
63 bool yapfile;
64 this._assetRequests = new BlockingQueue<ARequest>();
65 yapfile = File.Exists("assets.yap");
66
67 MainLog.Instance.Verbose( "Local Asset Server class created");
68 try
69 {
70 db = Db4oFactory.OpenFile("assets.yap");
71 MainLog.Instance.Verbose( "Db4 Asset database creation");
72 }
73 catch (Exception e)
74 {
75 db.Close();
76 MainLog.Instance.WriteLine(LogPriority.MEDIUM, "Db4 Asset server :Constructor - Exception occured");
77 MainLog.Instance.Warn(e.ToString());
78 }
79 if (!yapfile)
80 {
81 this.SetUpAssetDatabase();
82 }
83 this._localAssetServerThread = new Thread(new ThreadStart(RunRequests));
84 this._localAssetServerThread.IsBackground = true;
85 this._localAssetServerThread.Start();
86
87 }
88
89 public void SetReceiver(IAssetReceiver receiver)
90 {
91 this._receiver = receiver;
92 }
93
94 public void RequestAsset(LLUUID assetID, bool isTexture)
95 {
96 ARequest req = new ARequest();
97 req.AssetID = assetID;
98 req.IsTexture = isTexture;
99 this._assetRequests.Enqueue(req);
100 }
101
102 public void UpdateAsset(AssetBase asset)
103 {
104
105 }
106
107 public void UploadNewAsset(AssetBase asset)
108 {
109 AssetStorage store = new AssetStorage();
110 store.Data = asset.Data;
111 store.Name = asset.Name;
112 store.UUID = asset.FullID;
113 db.Set(store);
114 db.Commit();
115 }
116
117 public void SetServerInfo(string ServerUrl, string ServerKey)
118 {
119
120 }
121 public void Close()
122 {
123 if (db != null)
124 {
125 MainLog.Instance.Verbose( "Closing local asset server database");
126 db.Close();
127 }
128 }
129
130 private void RunRequests()
131 {
132 while (true)
133 {
134 byte[] idata = null;
135 bool found = false;
136 AssetStorage foundAsset = null;
137 ARequest req = this._assetRequests.Dequeue();
138 IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID));
139 if (result.Count > 0)
140 {
141 foundAsset = (AssetStorage)result.Next();
142 found = true;
143 }
144
145 AssetBase asset = new AssetBase();
146 if (found)
147 {
148 asset.FullID = foundAsset.UUID;
149 asset.Type = foundAsset.Type;
150 asset.InvType = foundAsset.Type;
151 asset.Name = foundAsset.Name;
152 idata = foundAsset.Data;
153 }
154 else
155 {
156 asset.FullID = LLUUID.Zero;
157 }
158 asset.Data = idata;
159 _receiver.AssetReceived(asset, req.IsTexture);
160 }
161
162 }
163
164 private void SetUpAssetDatabase()
165 {
166 try
167 {
168
169 MainLog.Instance.Verbose( "Setting up asset database");
170
171 AssetBase Image = new AssetBase();
172 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001");
173 Image.Name = "Bricks";
174 this.LoadAsset(Image, true, "bricks.jp2");
175 AssetStorage store = new AssetStorage();
176 store.Data = Image.Data;
177 store.Name = Image.Name;
178 store.UUID = Image.FullID;
179 db.Set(store);
180 db.Commit();
181
182 Image = new AssetBase();
183 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002");
184 Image.Name = "Plywood";
185 this.LoadAsset(Image, true, "plywood.jp2");
186 store = new AssetStorage();
187 store.Data = Image.Data;
188 store.Name = Image.Name;
189 store.UUID = Image.FullID;
190 db.Set(store);
191 db.Commit();
192
193 Image = new AssetBase();
194 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003");
195 Image.Name = "Rocks";
196 this.LoadAsset(Image, true, "rocks.jp2");
197 store = new AssetStorage();
198 store.Data = Image.Data;
199 store.Name = Image.Name;
200 store.UUID = Image.FullID;
201 db.Set(store);
202 db.Commit();
203
204 Image = new AssetBase();
205 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004");
206 Image.Name = "Granite";
207 this.LoadAsset(Image, true, "granite.jp2");
208 store = new AssetStorage();
209 store.Data = Image.Data;
210 store.Name = Image.Name;
211 store.UUID = Image.FullID;
212 db.Set(store);
213 db.Commit();
214
215 Image = new AssetBase();
216 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005");
217 Image.Name = "Hardwood";
218 this.LoadAsset(Image, true, "hardwood.jp2");
219 store = new AssetStorage();
220 store.Data = Image.Data;
221 store.Name = Image.Name;
222 store.UUID = Image.FullID;
223 db.Set(store);
224 db.Commit();
225
226 Image = new AssetBase();
227 Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005");
228 Image.Name = "Prim Base Texture";
229 this.LoadAsset(Image, true, "plywood.jp2");
230 store = new AssetStorage();
231 store.Data = Image.Data;
232 store.Name = Image.Name;
233 store.UUID = Image.FullID;
234 db.Set(store);
235 db.Commit();
236
237 Image = new AssetBase();
238 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006");
239 Image.Name = "Map Base Texture";
240 this.LoadAsset(Image, true, "map_base.jp2");
241 store = new AssetStorage();
242 store.Data = Image.Data;
243 store.Name = Image.Name;
244 store.UUID = Image.FullID;
245 db.Set(store);
246 db.Commit();
247
248 Image = new AssetBase();
249 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007");
250 Image.Name = "Map Texture";
251 this.LoadAsset(Image, true, "map1.jp2");
252 store = new AssetStorage();
253 store.Data = Image.Data;
254 store.Name = Image.Name;
255 store.UUID = Image.FullID;
256 db.Set(store);
257 db.Commit();
258
259 Image = new AssetBase();
260 Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
261 Image.Name = "Shape";
262 this.LoadAsset(Image, false, "base_shape.dat");
263 store = new AssetStorage();
264 store.Data = Image.Data;
265 store.Name = Image.Name;
266 store.UUID = Image.FullID;
267 db.Set(store);
268 db.Commit();
269 }
270 catch (Exception e)
271 {
272 Console.WriteLine("exception loading default assets into database");
273 Console.WriteLine(e.Message);
274 }
275
276 }
277
278 private void LoadAsset(AssetBase info, bool image, string filename)
279 {
280 //should request Asset from storage manager
281 //but for now read from file
282
283 string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder;
284 string fileName = Path.Combine(dataPath, filename);
285 FileInfo fInfo = new FileInfo(fileName);
286 long numBytes = fInfo.Length;
287 FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
288 byte[] idata = new byte[numBytes];
289 BinaryReader br = new BinaryReader(fStream);
290 idata = br.ReadBytes((int)numBytes);
291 br.Close();
292 fStream.Close();
293 info.Data = idata;
294 //info.loaded=true;
295 }
296 }
297 public class AssetUUIDQuery : Predicate
298 {
299 private LLUUID _findID;
300
301 public AssetUUIDQuery(LLUUID find)
302 {
303 _findID = find;
304 }
305 public bool Match(AssetStorage asset)
306 {
307 return (asset.UUID == _findID);
308 }
309 }
310
311}
diff --git a/OpenSim/Region/GridInterfaces/Remote/AssemblyInfo.cs b/OpenSim/Region/GridInterfaces/Remote/AssemblyInfo.cs
new file mode 100644
index 0000000..1e15c5e
--- /dev/null
+++ b/OpenSim/Region/GridInterfaces/Remote/AssemblyInfo.cs
@@ -0,0 +1,56 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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// Information about this assembly is defined by the following
31// attributes.
32//
33// change them to the information which is associated with the assembly
34// you compile.
35
36[assembly: AssemblyTitle("RemoteGridServers")]
37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("RemoteGridServers")]
41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")]
44
45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)]
48
49// The assembly version has following format :
50//
51// Major.Minor.Build.Revision
52//
53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default):
55
56[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs b/OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs
new file mode 100644
index 0000000..8643736
--- /dev/null
+++ b/OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs
@@ -0,0 +1,133 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.IO;
29using System.Net;
30using System.Text;
31using System.Threading;
32using libsecondlife;
33using OpenSim.Framework.Console;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types;
36using OpenSim.Framework.Utilities;
37
38namespace OpenSim.Region.GridInterfaces.Remote
39{
40 public class RemoteAssetServer : IAssetServer
41 {
42 private IAssetReceiver _receiver;
43 private BlockingQueue<ARequest> _assetRequests;
44 private Thread _remoteAssetServerThread;
45 private string AssetServerUrl;
46 private string AssetSendKey;
47
48 public RemoteAssetServer()
49 {
50 this._assetRequests = new BlockingQueue<ARequest>();
51 this._remoteAssetServerThread = new Thread(new ThreadStart(RunRequests));
52 this._remoteAssetServerThread.IsBackground = true;
53 this._remoteAssetServerThread.Start();
54 MainLog.Instance.Verbose("Remote Asset Server class created");
55 }
56
57 public void SetReceiver(IAssetReceiver receiver)
58 {
59 this._receiver = receiver;
60 }
61
62 public void RequestAsset(LLUUID assetID, bool isTexture)
63 {
64 ARequest req = new ARequest();
65 req.AssetID = assetID;
66 req.IsTexture = isTexture;
67 this._assetRequests.Enqueue(req);
68 }
69
70 public void UpdateAsset(AssetBase asset)
71 {
72
73 }
74
75 public void UploadNewAsset(AssetBase asset)
76 {
77 Encoding Windows1252Encoding = Encoding.GetEncoding(1252);
78 string ret = Windows1252Encoding.GetString(asset.Data);
79 byte[] buffer = Windows1252Encoding.GetBytes(ret);
80 WebClient client = new WebClient();
81 client.UploadData(this.AssetServerUrl + "assets/" + asset.FullID, buffer);
82
83 }
84
85 public void SetServerInfo(string ServerUrl, string ServerKey)
86 {
87 this.AssetServerUrl = ServerUrl;
88 this.AssetSendKey = ServerKey;
89 }
90
91 private void RunRequests()
92 {
93 while (true)
94 {
95 //we need to add support for the asset server not knowing about a requested asset
96 // 404... THE MAGIC FILE NOT FOUND ERROR, very useful for telling you things such as a file (or asset ;) ) not being found!!!!!!!!!!! it's 2:22AM
97 ARequest req = this._assetRequests.Dequeue();
98 LLUUID assetID = req.AssetID;
99 // OpenSim.Framework.Console.MainLog.Instance.Verbose(" RemoteAssetServer- Got a AssetServer request, processing it - " + this.AssetServerUrl + "assets/" + assetID);
100 WebRequest AssetLoad = WebRequest.Create(this.AssetServerUrl + "assets/" + assetID);
101 WebResponse AssetResponse = AssetLoad.GetResponse();
102 byte[] idata = new byte[(int)AssetResponse.ContentLength];
103 BinaryReader br = new BinaryReader(AssetResponse.GetResponseStream());
104 idata = br.ReadBytes((int)AssetResponse.ContentLength);
105 br.Close();
106
107 AssetBase asset = new AssetBase();
108 asset.FullID = assetID;
109 asset.Data = idata;
110 _receiver.AssetReceived(asset, req.IsTexture);
111 }
112 }
113
114 public void Close()
115 {
116
117 }
118 }
119
120 public class RemoteAssetPlugin : IAssetPlugin
121 {
122 public RemoteAssetPlugin()
123 {
124
125 }
126
127 public IAssetServer GetAssetServer()
128 {
129 return (new RemoteAssetServer());
130 }
131 }
132
133}
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
new file mode 100644
index 0000000..ce567a9
--- /dev/null
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
@@ -0,0 +1,56 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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// Information about this assembly is defined by the following
31// attributes.
32//
33// change them to the information which is associated with the assembly
34// you compile.
35
36[assembly: AssemblyTitle("PhysXplugin")]
37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("PhysXplugin")]
41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")]
44
45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)]
48
49// The assembly version has following format :
50//
51// Major.Minor.Build.Revision
52//
53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default):
55
56[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
new file mode 100644
index 0000000..f133045
--- /dev/null
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
@@ -0,0 +1,301 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 Axiom.Math;
30using OpenSim.Physics.Manager;
31
32namespace OpenSim.Region.Physics.BasicPhysicsPlugin
33{
34 /// <summary>
35 /// Will be the PhysX plugin but for now will be a very basic physics engine
36 /// </summary>
37 public class BasicPhysicsPlugin : IPhysicsPlugin
38 {
39 private BasicScene _mScene;
40
41 public BasicPhysicsPlugin()
42 {
43
44 }
45
46 public bool Init()
47 {
48 return true;
49 }
50
51 public PhysicsScene GetScene()
52 {
53 return new BasicScene();
54 }
55
56 public string GetName()
57 {
58 return("basicphysics");
59 }
60
61 public void Dispose()
62 {
63
64 }
65 }
66
67 public class BasicScene :PhysicsScene
68 {
69 private List<BasicActor> _actors = new List<BasicActor>();
70 private float[] _heightMap;
71
72 public BasicScene()
73 {
74
75 }
76
77 public override PhysicsActor AddAvatar(PhysicsVector position)
78 {
79 BasicActor act = new BasicActor();
80 act.Position = position;
81 _actors.Add(act);
82 return act;
83 }
84
85 public override void RemoveAvatar(PhysicsActor actor)
86 {
87 BasicActor act = (BasicActor)actor;
88 if(_actors.Contains(act))
89 {
90 _actors.Remove(act);
91 }
92
93 }
94
95 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
96 {
97 return null;
98 }
99
100 public override void Simulate(float timeStep)
101 {
102 foreach (BasicActor actor in _actors)
103 {
104 if ((actor.Position.Y > 0 && actor.Position.Y < 256) && (actor.Position.X > 0 && actor.Position.X < 256))
105 {
106 float height = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 1.2f;
107 actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep);
108 actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep);
109 if (actor.Flying)
110 {
111 if (actor.Position.Z + (actor.Velocity.Z * timeStep) <
112 _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 2)
113 {
114 actor.Position.Z = height;
115 actor.Velocity.Z = 0;
116 }
117 else
118 {
119 actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep);
120 }
121 }
122 else
123 {
124 actor.Position.Z = height;
125 actor.Velocity.Z = 0;
126 }
127 }
128 else
129 {
130 if (actor.Position.Y < 0)
131 {
132 actor.Position.Y = 0;
133 }
134 else if (actor.Position.Y > 256)
135 {
136 actor.Position.Y = 256;
137 }
138
139 if (actor.Position.X < 0)
140 {
141 actor.Position.X = 0;
142 }
143 if (actor.Position.X > 256)
144 {
145 actor.Position.X = 256;
146 }
147 }
148 //}
149
150
151
152 // This code needs sorting out - border crossings etc
153/* if(actor.Position.X<0)
154 {
155 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
156 actor.Position.X = 0;
157 actor.Velocity.X = 0;
158 }
159 if(actor.Position.Y < 0)
160 {
161 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
162 actor.Position.Y = 0;
163 actor.Velocity.Y = 0;
164 }
165 if(actor.Position.X > 255)
166 {
167 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
168 actor.Position.X = 255;
169 actor.Velocity.X = 0;
170 }
171 if(actor.Position.Y > 255)
172 {
173 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
174 actor.Position.Y = 255;
175 actor.Velocity.X = 0;
176 }*/
177 }
178 }
179
180 public override void GetResults()
181 {
182
183 }
184
185 public override bool IsThreaded
186 {
187 get
188 {
189 return(false); // for now we won't be multithreaded
190 }
191 }
192
193 public override void SetTerrain(float[] heightMap)
194 {
195 this._heightMap = heightMap;
196 }
197
198 public override void DeleteTerrain()
199 {
200
201 }
202 }
203
204 public class BasicActor : PhysicsActor
205 {
206 private PhysicsVector _position;
207 private PhysicsVector _velocity;
208 private PhysicsVector _acceleration;
209 private bool flying;
210 public BasicActor()
211 {
212 _velocity = new PhysicsVector();
213 _position = new PhysicsVector();
214 _acceleration = new PhysicsVector();
215 }
216
217 public override bool Flying
218 {
219 get
220 {
221 return flying;
222 }
223 set
224 {
225 flying= value;
226 }
227 }
228
229 public override PhysicsVector Position
230 {
231 get
232 {
233 return _position;
234 }
235 set
236 {
237 _position = value;
238 }
239 }
240
241 public override PhysicsVector Velocity
242 {
243 get
244 {
245 return _velocity;
246 }
247 set
248 {
249 _velocity = value;
250 }
251 }
252
253 public override Quaternion Orientation
254 {
255 get
256 {
257 return Quaternion.Identity;
258 }
259 set
260 {
261
262 }
263 }
264
265 public override PhysicsVector Acceleration
266 {
267 get
268 {
269 return _acceleration;
270 }
271
272 }
273
274 public override bool Kinematic
275 {
276 get
277 {
278 return true;
279 }
280 set
281 {
282
283 }
284 }
285 public void SetAcceleration (PhysicsVector accel)
286 {
287 this._acceleration = accel;
288 }
289
290 public override void AddForce(PhysicsVector force)
291 {
292
293 }
294
295 public override void SetMomentum(PhysicsVector momentum)
296 {
297
298 }
299 }
300
301}
diff --git a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs
new file mode 100644
index 0000000..9415db9
--- /dev/null
+++ b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs
@@ -0,0 +1,56 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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// Information about this assembly is defined by the following
31// attributes.
32//
33// change them to the information which is associated with the assembly
34// you compile.
35
36[assembly: AssemblyTitle("PhysicsManager")]
37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("PhysicsManager")]
41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")]
44
45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)]
48
49// The assembly version has following format :
50//
51// Major.Minor.Build.Revision
52//
53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default):
55
56[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
new file mode 100644
index 0000000..da3b560
--- /dev/null
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -0,0 +1,167 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 Axiom.Math;
29
30namespace OpenSim.Physics.Manager
31{
32 public delegate void PositionUpdate(PhysicsVector position);
33 public delegate void VelocityUpdate(PhysicsVector velocity);
34 public delegate void OrientationUpdate(Quaternion orientation);
35
36 public abstract class PhysicsActor
37 {
38 public event PositionUpdate OnPositionUpdate;
39 public event VelocityUpdate OnVelocityUpdate;
40 public event OrientationUpdate OnOrientationUpdate;
41
42 public static PhysicsActor Null
43 {
44 get
45 {
46 return new NullPhysicsActor();
47 }
48 }
49
50 public abstract PhysicsVector Position
51 {
52 get;
53 set;
54 }
55
56 public abstract PhysicsVector Velocity
57 {
58 get;
59 set;
60 }
61
62 public abstract PhysicsVector Acceleration
63 {
64 get;
65 }
66
67 public abstract Quaternion Orientation
68 {
69 get;
70 set;
71 }
72
73 public abstract bool Flying
74 {
75 get;
76 set;
77 }
78
79 public abstract bool Kinematic
80 {
81 get;
82 set;
83 }
84
85 public abstract void AddForce(PhysicsVector force);
86
87 public abstract void SetMomentum(PhysicsVector momentum);
88 }
89
90 public class NullPhysicsActor : PhysicsActor
91 {
92 public override PhysicsVector Position
93 {
94 get
95 {
96 return PhysicsVector.Zero;
97 }
98 set
99 {
100 return;
101 }
102 }
103
104 public override PhysicsVector Velocity
105 {
106 get
107 {
108 return PhysicsVector.Zero;
109 }
110 set
111 {
112 return;
113 }
114 }
115
116 public override Quaternion Orientation
117 {
118 get
119 {
120 return Quaternion.Identity;
121 }
122 set
123 {
124
125 }
126 }
127
128 public override PhysicsVector Acceleration
129 {
130 get { return PhysicsVector.Zero; }
131 }
132
133 public override bool Flying
134 {
135 get
136 {
137 return false;
138 }
139 set
140 {
141 return;
142 }
143 }
144
145 public override bool Kinematic
146 {
147 get
148 {
149 return true;
150 }
151 set
152 {
153 return;
154 }
155 }
156
157 public override void AddForce(PhysicsVector force)
158 {
159 return;
160 }
161
162 public override void SetMomentum(PhysicsVector momentum)
163 {
164 return;
165 }
166 }
167}
diff --git a/OpenSim/Region/Physics/Manager/PhysicsManager.cs b/OpenSim/Region/Physics/Manager/PhysicsManager.cs
new file mode 100644
index 0000000..265bce6
--- /dev/null
+++ b/OpenSim/Region/Physics/Manager/PhysicsManager.cs
@@ -0,0 +1,115 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 OpenSim.Framework.Console;
33
34namespace OpenSim.Physics.Manager
35{
36 /// <summary>
37 /// Description of MyClass.
38 /// </summary>
39 public class PhysicsManager
40 {
41 private Dictionary<string, IPhysicsPlugin> _plugins=new Dictionary<string, IPhysicsPlugin>();
42
43 public PhysicsManager()
44 {
45
46 }
47
48 public PhysicsScene GetPhysicsScene(string engineName)
49 {
50 if (String.IsNullOrEmpty(engineName))
51 {
52 return PhysicsScene.Null;
53 }
54
55 if(_plugins.ContainsKey(engineName))
56 {
57 MainLog.Instance.WriteLine(LogPriority.LOW,"creating "+engineName);
58 return _plugins[engineName].GetScene();
59 }
60 else
61 {
62 MainLog.Instance.WriteLine(LogPriority.MEDIUM,"couldn't find physicsEngine: {0}",engineName);
63 throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}",engineName));
64 }
65 }
66
67 public void LoadPlugins()
68 {
69 string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory ,"Physics");
70 string[] pluginFiles = Directory.GetFiles(path, "*.dll");
71
72
73 for(int i= 0; i<pluginFiles.Length; i++)
74 {
75 this.AddPlugin(pluginFiles[i]);
76 }
77 }
78
79 private void AddPlugin(string FileName)
80 {
81 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
82
83 foreach (Type pluginType in pluginAssembly.GetTypes())
84 {
85 if (pluginType.IsPublic)
86 {
87 if (!pluginType.IsAbstract)
88 {
89 Type typeInterface = pluginType.GetInterface("IPhysicsPlugin", true);
90
91 if (typeInterface != null)
92 {
93 IPhysicsPlugin plug = (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
94 plug.Init();
95 this._plugins.Add(plug.GetName(),plug);
96
97 }
98
99 typeInterface = null;
100 }
101 }
102 }
103
104 pluginAssembly = null;
105 }
106 }
107
108 public interface IPhysicsPlugin
109 {
110 bool Init();
111 PhysicsScene GetScene();
112 string GetName();
113 void Dispose();
114 }
115}
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
new file mode 100644
index 0000000..d44da00
--- /dev/null
+++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
@@ -0,0 +1,110 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Console;
29
30namespace OpenSim.Physics.Manager
31{
32 public abstract class PhysicsScene
33 {
34 public static PhysicsScene Null
35 {
36 get
37 {
38 return new NullPhysicsScene();
39 }
40 }
41
42 public abstract PhysicsActor AddAvatar(PhysicsVector position);
43
44 public abstract void RemoveAvatar(PhysicsActor actor);
45
46 public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size);
47
48 public abstract void Simulate(float timeStep);
49
50 public abstract void GetResults();
51
52 public abstract void SetTerrain(float[] heightMap);
53
54 public abstract void DeleteTerrain();
55
56 public abstract bool IsThreaded
57 {
58 get;
59 }
60
61 private class NullPhysicsScene : PhysicsScene
62 {
63 private static int m_workIndicator;
64
65 public override PhysicsActor AddAvatar(PhysicsVector position)
66 {
67 MainLog.Instance.Verbose("NullPhysicsScene : AddAvatar({0})", position);
68 return PhysicsActor.Null;
69 }
70
71 public override void RemoveAvatar(PhysicsActor actor)
72 {
73
74 }
75
76 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
77 {
78 MainLog.Instance.Verbose("NullPhysicsScene : AddPrim({0},{1})", position, size);
79 return PhysicsActor.Null;
80 }
81
82 public override void Simulate(float timeStep)
83 {
84 m_workIndicator = (m_workIndicator + 1) % 10;
85
86 //OpenSim.Framework.Console.MainLog.Instance.SetStatus(m_workIndicator.ToString());
87 }
88
89 public override void GetResults()
90 {
91 MainLog.Instance.Verbose("NullPhysicsScene : GetResults()");
92 }
93
94 public override void SetTerrain(float[] heightMap)
95 {
96 MainLog.Instance.Verbose("NullPhysicsScene : SetTerrain({0} items)", heightMap.Length);
97 }
98
99 public override void DeleteTerrain()
100 {
101
102 }
103
104 public override bool IsThreaded
105 {
106 get { return false; }
107 }
108 }
109 }
110}
diff --git a/OpenSim/Region/Physics/Manager/PhysicsVector.cs b/OpenSim/Region/Physics/Manager/PhysicsVector.cs
new file mode 100644
index 0000000..e75f29b
--- /dev/null
+++ b/OpenSim/Region/Physics/Manager/PhysicsVector.cs
@@ -0,0 +1,55 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28namespace OpenSim.Physics.Manager
29{
30 public class PhysicsVector
31 {
32 public float X;
33 public float Y;
34 public float Z;
35
36 public PhysicsVector()
37 {
38
39 }
40
41 public PhysicsVector(float x, float y, float z)
42 {
43 X = x;
44 Y = y;
45 Z = z;
46 }
47
48 public static readonly PhysicsVector Zero = new PhysicsVector(0f, 0f, 0f);
49
50 public override string ToString()
51 {
52 return "<" + this.X + "," + this.Y + "," + this.Z + ">";
53 }
54 }
55}
diff --git a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs
new file mode 100644
index 0000000..ee10430
--- /dev/null
+++ b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs
@@ -0,0 +1,56 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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// Information about this assembly is defined by the following
31// attributes.
32//
33// change them to the information which is associated with the assembly
34// you compile.
35
36[assembly: AssemblyTitle("RealPhysXplugin")]
37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("RealPhysXplugin")]
41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")]
44
45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)]
48
49// The assembly version has following format :
50//
51// Major.Minor.Build.Revision
52//
53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default):
55
56[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
new file mode 100644
index 0000000..2780188
--- /dev/null
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -0,0 +1,457 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 Axiom.Math;
31using Ode.NET;
32using OpenSim.Physics.Manager;
33
34namespace OpenSim.Region.Physics.OdePlugin
35{
36 /// <summary>
37 /// ODE plugin
38 /// </summary>
39 public class OdePlugin : IPhysicsPlugin
40 {
41 private OdeScene _mScene;
42
43 public OdePlugin()
44 {
45
46 }
47
48 public bool Init()
49 {
50 return true;
51 }
52
53 public PhysicsScene GetScene()
54 {
55 if (_mScene == null)
56 {
57 _mScene = new OdeScene();
58 }
59 return (_mScene);
60 }
61
62 public string GetName()
63 {
64 return ("OpenDynamicsEngine");
65 }
66
67 public void Dispose()
68 {
69
70 }
71 }
72
73 public class OdeScene : PhysicsScene
74 {
75 static public IntPtr world;
76 static public IntPtr space;
77 static private IntPtr contactgroup;
78 static private IntPtr LandGeom;
79 //static private IntPtr Land;
80 private double[] _heightmap;
81 static private d.NearCallback nearCallback = near;
82 private List<OdeCharacter> _characters = new List<OdeCharacter>();
83 private static d.ContactGeom[] contacts = new d.ContactGeom[30];
84 private static d.Contact contact;
85
86 public OdeScene()
87 {
88 contact.surface.mode = d.ContactFlags.Bounce | d.ContactFlags.SoftCFM;
89 contact.surface.mu = d.Infinity;
90 contact.surface.mu2 = 0.0f;
91 contact.surface.bounce = 0.1f;
92 contact.surface.bounce_vel = 0.1f;
93 contact.surface.soft_cfm = 0.01f;
94
95 world = d.WorldCreate();
96 space = d.HashSpaceCreate(IntPtr.Zero);
97 contactgroup = d.JointGroupCreate(0);
98 d.WorldSetGravity(world, 0.0f, 0.0f, -0.5f);
99 //d.WorldSetCFM(world, 1e-5f);
100 d.WorldSetAutoDisableFlag(world, false);
101 d.WorldSetContactSurfaceLayer(world, 0.001f);
102 // d.CreatePlane(space, 0, 0, 1, 0);
103 this._heightmap = new double[65536];
104 }
105
106 // This function blatantly ripped off from BoxStack.cs
107 static private void near(IntPtr space, IntPtr g1, IntPtr g2)
108 {
109 IntPtr b1 = d.GeomGetBody(g1);
110 IntPtr b2 = d.GeomGetBody(g2);
111 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
112 return;
113
114 int count = d.Collide(g1, g2, 500, contacts, d.ContactGeom.SizeOf);
115 for (int i = 0; i < count; ++i)
116 {
117 contact.geom = contacts[i];
118 IntPtr joint = d.JointCreateContact(world, contactgroup, ref contact);
119 d.JointAttach(joint, b1, b2);
120 }
121
122 }
123
124 public override PhysicsActor AddAvatar(PhysicsVector position)
125 {
126 PhysicsVector pos = new PhysicsVector();
127 pos.X = position.X;
128 pos.Y = position.Y;
129 pos.Z = position.Z + 20;
130 OdeCharacter newAv = new OdeCharacter(this, pos);
131 this._characters.Add(newAv);
132 return newAv;
133 }
134
135 public override void RemoveAvatar(PhysicsActor actor)
136 {
137
138 }
139
140 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
141 {
142 PhysicsVector pos = new PhysicsVector();
143 pos.X = position.X;
144 pos.Y = position.Y;
145 pos.Z = position.Z;
146 PhysicsVector siz = new PhysicsVector();
147 siz.X = size.X;
148 siz.Y = size.Y;
149 siz.Z = size.Z;
150 return new OdePrim();
151 }
152
153 public override void Simulate(float timeStep)
154 {
155 foreach (OdeCharacter actor in _characters)
156 {
157 actor.Move(timeStep * 5f);
158 }
159 d.SpaceCollide(space, IntPtr.Zero, nearCallback);
160 d.WorldQuickStep(world, timeStep * 5f);
161 d.JointGroupEmpty(contactgroup);
162 foreach (OdeCharacter actor in _characters)
163 {
164 actor.UpdatePosition();
165 }
166
167 }
168
169 public override void GetResults()
170 {
171
172 }
173
174 public override bool IsThreaded
175 {
176 get
177 {
178 return (false); // for now we won't be multithreaded
179 }
180 }
181
182 public override void SetTerrain(float[] heightMap)
183 {
184 for (int i = 0; i < 65536; i++)
185 {
186 // this._heightmap[i] = (double)heightMap[i];
187 // dbm (danx0r) -- heightmap x,y must be swapped for Ode (should fix ODE, but for now...)
188 int x = i & 0xff;
189 int y = i >> 8;
190 this._heightmap[i] = (double)heightMap[x * 256 + y];
191 }
192 IntPtr HeightmapData = d.GeomHeightfieldDataCreate();
193 d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0);
194 d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256);
195 LandGeom = d.CreateHeightfield(space, HeightmapData, 1);
196 d.Matrix3 R = new d.Matrix3();
197
198 Quaternion q1 =Quaternion.FromAngleAxis(1.5707f, new Vector3(1,0,0));
199 Quaternion q2 =Quaternion.FromAngleAxis(1.5707f, new Vector3(0,1,0));
200 //Axiom.Math.Quaternion q3 = Axiom.Math.Quaternion.FromAngleAxis(3.14f, new Axiom.Math.Vector3(0, 0, 1));
201
202 q1 = q1 * q2;
203 //q1 = q1 * q3;
204 Vector3 v3 = new Vector3();
205 float angle = 0;
206 q1.ToAngleAxis(ref angle, ref v3);
207
208 d.RFromAxisAndAngle(out R, v3.x, v3.y, v3.z, angle);
209 d.GeomSetRotation(LandGeom, ref R);
210 d.GeomSetPosition(LandGeom, 128, 128, 0);
211 }
212
213 public override void DeleteTerrain()
214 {
215
216 }
217 }
218
219 public class OdeCharacter : PhysicsActor
220 {
221 private PhysicsVector _position;
222 private PhysicsVector _velocity;
223 private PhysicsVector _acceleration;
224 private bool flying;
225 //private float gravityAccel;
226 private IntPtr BoundingCapsule;
227 IntPtr capsule_geom;
228 d.Mass capsule_mass;
229
230 public OdeCharacter(OdeScene parent_scene, PhysicsVector pos)
231 {
232 _velocity = new PhysicsVector();
233 _position = pos;
234 _acceleration = new PhysicsVector();
235 d.MassSetCapsule(out capsule_mass, 5.0f, 3, 0.5f, 2f);
236 capsule_geom = d.CreateCapsule(OdeScene.space, 0.5f, 2f);
237 this.BoundingCapsule = d.BodyCreate(OdeScene.world);
238 d.BodySetMass(BoundingCapsule, ref capsule_mass);
239 d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z);
240 d.GeomSetBody(capsule_geom, BoundingCapsule);
241 }
242
243 public override bool Flying
244 {
245 get
246 {
247 return flying;
248 }
249 set
250 {
251 flying = value;
252 }
253 }
254
255 public override PhysicsVector Position
256 {
257 get
258 {
259 return _position;
260 }
261 set
262 {
263 _position = value;
264 }
265 }
266
267 public override PhysicsVector Velocity
268 {
269 get
270 {
271 return _velocity;
272 }
273 set
274 {
275 _velocity = value;
276 }
277 }
278
279 public override bool Kinematic
280 {
281 get
282 {
283 return false;
284 }
285 set
286 {
287
288 }
289 }
290
291 public override Quaternion Orientation
292 {
293 get
294 {
295 return Quaternion.Identity;
296 }
297 set
298 {
299
300 }
301 }
302
303 public override PhysicsVector Acceleration
304 {
305 get
306 {
307 return _acceleration;
308 }
309
310 }
311 public void SetAcceleration(PhysicsVector accel)
312 {
313 this._acceleration = accel;
314 }
315
316 public override void AddForce(PhysicsVector force)
317 {
318
319 }
320
321 public override void SetMomentum(PhysicsVector momentum)
322 {
323
324 }
325
326 public void Move(float timeStep)
327 {
328 PhysicsVector vec = new PhysicsVector();
329 vec.X = this._velocity.X * timeStep;
330 vec.Y = this._velocity.Y * timeStep;
331 if (flying)
332 {
333 vec.Z = (this._velocity.Z + 0.5f) * timeStep;
334 }
335 d.BodySetLinearVel(this.BoundingCapsule, vec.X, vec.Y, vec.Z);
336 }
337
338 public void UpdatePosition()
339 {
340 d.Vector3 vec = d.BodyGetPosition(BoundingCapsule);
341 this._position.X = vec.X;
342 this._position.Y = vec.Y;
343 this._position.Z = vec.Z+1.0f;
344 }
345 }
346
347 public class OdePrim : PhysicsActor
348 {
349 private PhysicsVector _position;
350 private PhysicsVector _velocity;
351 private PhysicsVector _acceleration;
352
353 public OdePrim()
354 {
355 _velocity = new PhysicsVector();
356 _position = new PhysicsVector();
357 _acceleration = new PhysicsVector();
358 }
359 public override bool Flying
360 {
361 get
362 {
363 return false; //no flying prims for you
364 }
365 set
366 {
367
368 }
369 }
370 public override PhysicsVector Position
371 {
372 get
373 {
374 PhysicsVector pos = new PhysicsVector();
375 // PhysicsVector vec = this._prim.Position;
376 //pos.X = vec.X;
377 //pos.Y = vec.Y;
378 //pos.Z = vec.Z;
379 return pos;
380
381 }
382 set
383 {
384 /*PhysicsVector vec = value;
385 PhysicsVector pos = new PhysicsVector();
386 pos.X = vec.X;
387 pos.Y = vec.Y;
388 pos.Z = vec.Z;
389 this._prim.Position = pos;*/
390 }
391 }
392
393 public override PhysicsVector Velocity
394 {
395 get
396 {
397 return _velocity;
398 }
399 set
400 {
401 _velocity = value;
402 }
403 }
404
405 public override bool Kinematic
406 {
407 get
408 {
409 return false;
410 //return this._prim.Kinematic;
411 }
412 set
413 {
414 //this._prim.Kinematic = value;
415 }
416 }
417
418 public override Quaternion Orientation
419 {
420 get
421 {
422 Quaternion res = new Quaternion();
423 return res;
424 }
425 set
426 {
427
428 }
429 }
430
431 public override PhysicsVector Acceleration
432 {
433 get
434 {
435 return _acceleration;
436 }
437
438 }
439 public void SetAcceleration(PhysicsVector accel)
440 {
441 this._acceleration = accel;
442 }
443
444 public override void AddForce(PhysicsVector force)
445 {
446
447 }
448
449 public override void SetMomentum(PhysicsVector momentum)
450 {
451
452 }
453
454
455 }
456
457}
diff --git a/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs
new file mode 100644
index 0000000..ee10430
--- /dev/null
+++ b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs
@@ -0,0 +1,56 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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// Information about this assembly is defined by the following
31// attributes.
32//
33// change them to the information which is associated with the assembly
34// you compile.
35
36[assembly: AssemblyTitle("RealPhysXplugin")]
37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("RealPhysXplugin")]
41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")]
44
45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)]
48
49// The assembly version has following format :
50//
51// Major.Minor.Build.Revision
52//
53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default):
55
56[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
new file mode 100644
index 0000000..4c82549
--- /dev/null
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
@@ -0,0 +1,425 @@
1/*/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 OpenSim.Physics.Manager;
31using PhysXWrapper;
32using Quaternion=Axiom.Math.Quaternion;
33
34namespace OpenSim.Region.Physics.PhysXPlugin
35{
36 /// <summary>
37 /// Will be the PhysX plugin but for now will be a very basic physics engine
38 /// </summary>
39 public class PhysXPlugin : IPhysicsPlugin
40 {
41 private PhysXScene _mScene;
42
43 public PhysXPlugin()
44 {
45
46 }
47
48 public bool Init()
49 {
50 return true;
51 }
52
53 public PhysicsScene GetScene()
54 {
55 if(_mScene == null)
56 {
57 _mScene = new PhysXScene();
58 }
59 return(_mScene);
60 }
61
62 public string GetName()
63 {
64 return("RealPhysX");
65 }
66
67 public void Dispose()
68 {
69
70 }
71 }
72
73 public class PhysXScene :PhysicsScene
74 {
75 private List<PhysXCharacter> _characters = new List<PhysXCharacter>();
76 private List<PhysXPrim> _prims = new List<PhysXPrim>();
77 private float[] _heightMap = null;
78 private NxPhysicsSDK mySdk;
79 private NxScene scene;
80
81 public PhysXScene()
82 {
83 mySdk = NxPhysicsSDK.CreateSDK();
84 Console.WriteLine("Sdk created - now creating scene");
85 scene = mySdk.CreateScene();
86
87 }
88
89 public override PhysicsActor AddAvatar(PhysicsVector position)
90 {
91 Vec3 pos = new Vec3();
92 pos.X = position.X;
93 pos.Y = position.Y;
94 pos.Z = position.Z;
95 PhysXCharacter act = new PhysXCharacter( scene.AddCharacter(pos));
96 act.Position = position;
97 _characters.Add(act);
98 return act;
99 }
100
101 public override void RemoveAvatar(PhysicsActor actor)
102 {
103
104 }
105
106 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
107 {
108 Vec3 pos = new Vec3();
109 pos.X = position.X;
110 pos.Y = position.Y;
111 pos.Z = position.Z;
112 Vec3 siz = new Vec3();
113 siz.X = size.X;
114 siz.Y = size.Y;
115 siz.Z = size.Z;
116 PhysXPrim act = new PhysXPrim( scene.AddNewBox(pos, siz));
117 _prims.Add(act);
118 return act;
119 }
120 public override void Simulate(float timeStep)
121 {
122 try
123 {
124 foreach (PhysXCharacter actor in _characters)
125 {
126 actor.Move(timeStep);
127 }
128 scene.Simulate(timeStep);
129 scene.FetchResults();
130 scene.UpdateControllers();
131
132 foreach (PhysXCharacter actor in _characters)
133 {
134 actor.UpdatePosition();
135 }
136 }
137 catch (Exception e)
138 {
139 Console.WriteLine(e.Message);
140 }
141
142 }
143
144 public override void GetResults()
145 {
146
147 }
148
149 public override bool IsThreaded
150 {
151 get
152 {
153 return(false); // for now we won't be multithreaded
154 }
155 }
156
157 public override void SetTerrain(float[] heightMap)
158 {
159 if (this._heightMap != null)
160 {
161 Console.WriteLine("PhysX - deleting old terrain");
162 this.scene.DeleteTerrain();
163 }
164 this._heightMap = heightMap;
165 this.scene.AddTerrain(heightMap);
166 }
167
168 public override void DeleteTerrain()
169 {
170 this.scene.DeleteTerrain();
171 }
172 }
173
174 public class PhysXCharacter : PhysicsActor
175 {
176 private PhysicsVector _position;
177 private PhysicsVector _velocity;
178 private PhysicsVector _acceleration;
179 private NxCharacter _character;
180 private bool flying;
181 private float gravityAccel;
182
183 public PhysXCharacter(NxCharacter character)
184 {
185 _velocity = new PhysicsVector();
186 _position = new PhysicsVector();
187 _acceleration = new PhysicsVector();
188 _character = character;
189 }
190
191 public override bool Flying
192 {
193 get
194 {
195 return flying;
196 }
197 set
198 {
199 flying = value;
200 }
201 }
202
203 public override PhysicsVector Position
204 {
205 get
206 {
207 return _position;
208 }
209 set
210 {
211 _position = value;
212 Vec3 ps = new Vec3();
213 ps.X = value.X;
214 ps.Y = value.Y;
215 ps.Z = value.Z;
216 this._character.Position = ps;
217 }
218 }
219
220 public override PhysicsVector Velocity
221 {
222 get
223 {
224 return _velocity;
225 }
226 set
227 {
228 _velocity = value;
229 }
230 }
231
232 public override bool Kinematic
233 {
234 get
235 {
236 return false;
237 }
238 set
239 {
240
241 }
242 }
243
244 public override Quaternion Orientation
245 {
246 get
247 {
248 return Quaternion.Identity;
249 }
250 set
251 {
252
253 }
254 }
255
256 public override PhysicsVector Acceleration
257 {
258 get
259 {
260 return _acceleration;
261 }
262
263 }
264 public void SetAcceleration (PhysicsVector accel)
265 {
266 this._acceleration = accel;
267 }
268
269 public override void AddForce(PhysicsVector force)
270 {
271
272 }
273
274 public override void SetMomentum(PhysicsVector momentum)
275 {
276
277 }
278
279 public void Move(float timeStep)
280 {
281 Vec3 vec = new Vec3();
282 vec.X = this._velocity.X * timeStep;
283 vec.Y = this._velocity.Y * timeStep;
284 if(flying)
285 {
286 vec.Z = ( this._velocity.Z) * timeStep;
287 }
288 else
289 {
290 gravityAccel+= -9.8f;
291 vec.Z = (gravityAccel + this._velocity.Z) * timeStep;
292 }
293 int res = this._character.Move(vec);
294 if(res == 1)
295 {
296 gravityAccel = 0;
297 }
298 }
299
300 public void UpdatePosition()
301 {
302 Vec3 vec = this._character.Position;
303 this._position.X = vec.X;
304 this._position.Y = vec.Y;
305 this._position.Z = vec.Z;
306 }
307 }
308
309 public class PhysXPrim : PhysicsActor
310 {
311 private PhysicsVector _position;
312 private PhysicsVector _velocity;
313 private PhysicsVector _acceleration;
314 private NxActor _prim;
315
316 public PhysXPrim(NxActor prim)
317 {
318 _velocity = new PhysicsVector();
319 _position = new PhysicsVector();
320 _acceleration = new PhysicsVector();
321 _prim = prim;
322 }
323 public override bool Flying
324 {
325 get
326 {
327 return false; //no flying prims for you
328 }
329 set
330 {
331
332 }
333 }
334 public override PhysicsVector Position
335 {
336 get
337 {
338 PhysicsVector pos = new PhysicsVector();
339 Vec3 vec = this._prim.Position;
340 pos.X = vec.X;
341 pos.Y = vec.Y;
342 pos.Z = vec.Z;
343 return pos;
344
345 }
346 set
347 {
348 PhysicsVector vec = value;
349 Vec3 pos = new Vec3();
350 pos.X = vec.X;
351 pos.Y = vec.Y;
352 pos.Z = vec.Z;
353 this._prim.Position = pos;
354 }
355 }
356
357 public override PhysicsVector Velocity
358 {
359 get
360 {
361 return _velocity;
362 }
363 set
364 {
365 _velocity = value;
366 }
367 }
368
369 public override bool Kinematic
370 {
371 get
372 {
373 return this._prim.Kinematic;
374 }
375 set
376 {
377 this._prim.Kinematic = value;
378 }
379 }
380
381 public override Quaternion Orientation
382 {
383 get
384 {
385 Quaternion res = new Quaternion();
386 PhysXWrapper.Quaternion quat = this._prim.GetOrientation();
387 res.w = quat.W;
388 res.x = quat.X;
389 res.y = quat.Y;
390 res.z = quat.Z;
391 return res;
392 }
393 set
394 {
395
396 }
397 }
398
399 public override PhysicsVector Acceleration
400 {
401 get
402 {
403 return _acceleration;
404 }
405
406 }
407 public void SetAcceleration (PhysicsVector accel)
408 {
409 this._acceleration = accel;
410 }
411
412 public override void AddForce(PhysicsVector force)
413 {
414
415 }
416
417 public override void SetMomentum(PhysicsVector momentum)
418 {
419
420 }
421
422
423 }
424
425}
diff --git a/OpenSim/Region/Scripting/Properties/AssemblyInfo.cs b/OpenSim/Region/Scripting/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..f5da4c0
--- /dev/null
+++ b/OpenSim/Region/Scripting/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Scripting")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("")]
12[assembly: AssemblyProduct("OpenSim.Scripting")]
13[assembly: AssemblyCopyright("Copyright © 2007")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("61eae1ad-82aa-4c77-8bc5-b5a8c9522b18")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32// You can specify all the values or you can default the Revision and Build Numbers
33// by using the '*' as shown below:
34[assembly: AssemblyVersion("1.0.0.0")]
35[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Scripting/Script.cs b/OpenSim/Region/Scripting/Script.cs
new file mode 100644
index 0000000..0f4af00
--- /dev/null
+++ b/OpenSim/Region/Scripting/Script.cs
@@ -0,0 +1,32 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5using OpenSim.Framework.Console;
6using OpenSim.Framework;
7using OpenSim.Region;
8using OpenSim.Region.Scenes;
9
10namespace OpenSim.Scripting
11{
12 public interface IScript
13 {
14 void Initialise(ScriptInfo scriptInfo);
15 }
16
17 public class TestScript : IScript
18 {
19 ScriptInfo script;
20
21 public void Initialise(ScriptInfo scriptInfo)
22 {
23 script = scriptInfo;
24 script.events.OnFrame += new OpenSim.Region.Scenes.EventManager.OnFrameDelegate(events_OnFrame);
25 }
26
27 void events_OnFrame()
28 {
29 script.logger.Verbose("Hello World!");
30 }
31 }
32}
diff --git a/OpenSim/Region/Scripting/ScriptAccess.cs b/OpenSim/Region/Scripting/ScriptAccess.cs
new file mode 100644
index 0000000..a9fede5
--- /dev/null
+++ b/OpenSim/Region/Scripting/ScriptAccess.cs
@@ -0,0 +1,31 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5using OpenSim.Region.Scenes;
6using OpenSim.Framework.Console;
7
8namespace OpenSim.Scripting
9{
10 /// <summary>
11 /// Class which provides access to the world
12 /// </summary>
13 public class ScriptInfo
14 {
15 // Reference to world.eventsManager provided for convenience
16 public EventManager events;
17
18 // The main world
19 public Scene world;
20
21 // The console
22 public LogBase logger;
23
24 public ScriptInfo(Scene scene)
25 {
26 world = scene;
27 events = world.eventManager;
28 logger = OpenSim.Framework.Console.MainLog.Instance;
29 }
30 }
31}
diff --git a/OpenSim/Region/Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs b/OpenSim/Region/Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs
new file mode 100644
index 0000000..39ba6e4
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs
@@ -0,0 +1,112 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28
29// BDB Support
30// Apparently broken on Mono
31
32using BerkeleyDb;
33using libsecondlife;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types;
36
37namespace OpenSim.Region.Storage.LocalStorageBDB
38{
39 public class BDBLocalStorage : ILocalStorage
40 {
41 const string simDbName = "localsim.db";
42
43 DbHash sim;
44 Db DB;
45 //BEFormatter formatter;
46
47 public BDBLocalStorage()
48 {
49 DB = new Db(DbCreateFlags.None);
50 sim = (DbHash)DB.Open(null, simDbName, null, DbType.Hash, Db.OpenFlags.Create, 0);
51 //vendorDb = (DbBTree)db.Open(null, VendorDbName, null, DbType.BTree, Db.OpenFlags.Create, 0);
52 }
53
54 public void Initialise(string file)
55 {
56 // Blank
57 }
58
59 public void StorePrim(PrimData prim)
60 {
61 DbEntry key = new DbEntry();
62 DbEntry data = new DbEntry();
63 lock (sim)
64 {
65 sim.PutUnique(null, ref key, ref data, DbFile.WriteFlags.AutoCommit);
66 }
67 }
68 public void RemovePrim(LLUUID primID)
69 {
70
71 }
72 public void LoadPrimitives(ILocalStorageReceiver receiver)
73 {
74
75 }
76 public float[] LoadWorld()
77 {
78 return new float[65536];
79 }
80 public void SaveMap(float[] heightmap)
81 {
82
83 }
84
85 public void SaveParcels(ParcelData[] parcel_data)
86 {
87 }
88
89 public void SaveParcel(ParcelData parcel)
90 {
91 }
92
93 public void RemoveParcel(ParcelData parcel)
94 {
95 }
96
97 public void RemoveAllParcels()
98 {
99 }
100
101 public void LoadParcels(ILocalStorageParcelReceiver recv)
102 {
103 recv.NoParcelDataFromStorage();
104 }
105
106 public void ShutDown()
107 {
108 sim.GetDb().Close();
109 DB.Close();
110 }
111 }
112} \ No newline at end of file
diff --git a/OpenSim/Region/Storage/LocalStorageDb4o/AssemblyInfo.cs b/OpenSim/Region/Storage/LocalStorageDb4o/AssemblyInfo.cs
new file mode 100644
index 0000000..4463ac9
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageDb4o/AssemblyInfo.cs
@@ -0,0 +1,56 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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// Information about this assembly is defined by the following
31// attributes.
32//
33// change them to the information which is associated with the assembly
34// you compile.
35
36[assembly: AssemblyTitle("Db4LocalStorage")]
37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("Db4LocalStorage")]
41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")]
44
45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)]
48
49// The assembly version has following format :
50//
51// Major.Minor.Build.Revision
52//
53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default):
55
56[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Storage/LocalStorageDb4o/Db4LocalStorage.cs b/OpenSim/Region/Storage/LocalStorageDb4o/Db4LocalStorage.cs
new file mode 100644
index 0000000..8214bc8
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageDb4o/Db4LocalStorage.cs
@@ -0,0 +1,267 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 Db4objects.Db4o;
30using libsecondlife;
31using OpenSim.Framework.Console;
32using OpenSim.Framework.Interfaces;
33using OpenSim.Framework.Types;
34
35namespace OpenSim.Region.Storage.LocalStorageDb4o
36{
37 /// <summary>
38 ///
39 /// </summary>
40 public class Db4LocalStorage : ILocalStorage
41 {
42 private IObjectContainer db;
43 private string datastore;
44
45 public Db4LocalStorage()
46 {
47
48 }
49
50 public void Initialise(string dfile)
51 {
52 MainLog.Instance.Warn("Db4LocalStorage Opening " + dfile);
53 datastore = dfile;
54 try
55 {
56 db = Db4oFactory.OpenFile(datastore);
57 MainLog.Instance.Verbose("Db4LocalStorage creation");
58 }
59 catch (Exception e)
60 {
61 db.Close();
62 MainLog.Instance.Warn("Db4LocalStorage :Constructor - Exception occured");
63 MainLog.Instance.Warn(e.ToString());
64 }
65 }
66
67 public void StorePrim(PrimData prim)
68 {
69 IObjectSet result = db.Query(new UUIDPrimQuery(prim.FullID));
70 if (result.Count > 0)
71 {
72 //prim already in storage
73 //so update it
74 PrimData found = (PrimData)result.Next();
75 found.PathBegin = prim.PathBegin;
76 found.PathCurve = prim.PathCurve;
77 found.PathEnd = prim.PathEnd;
78 found.PathRadiusOffset = prim.PathRadiusOffset;
79 found.PathRevolutions = prim.PathRevolutions;
80 found.PathScaleX = prim.PathScaleX;
81 found.PathScaleY = prim.PathScaleY;
82 found.PathShearX = prim.PathShearX;
83 found.PathShearY = prim.PathShearY;
84 found.PathSkew = prim.PathSkew;
85 found.PathTaperX = prim.PathTaperX;
86 found.PathTaperY = prim.PathTaperY;
87 found.PathTwist = prim.PathTwist;
88 found.PathTwistBegin = prim.PathTwistBegin;
89 found.PCode = prim.PCode;
90 found.ProfileBegin = prim.ProfileBegin;
91 found.ProfileCurve = prim.ProfileCurve;
92 found.ProfileEnd = prim.ProfileEnd;
93 found.ProfileHollow = prim.ProfileHollow;
94 found.Position = prim.Position;
95 found.Rotation = prim.Rotation;
96 found.TextureEntry = prim.TextureEntry;
97 db.Set(found);
98 db.Commit();
99 }
100 else
101 {
102 //not in storage
103 db.Set(prim);
104 db.Commit();
105 }
106 }
107
108 public void RemovePrim(LLUUID primID)
109 {
110 IObjectSet result = db.Query(new UUIDPrimQuery(primID));
111 if (result.Count > 0)
112 {
113 PrimData found = (PrimData)result.Next();
114 db.Delete(found);
115 }
116 }
117
118
119 public void LoadPrimitives(ILocalStorageReceiver receiver)
120 {
121 IObjectSet result = db.Get(typeof(PrimData));
122 MainLog.Instance.Verbose("Db4LocalStorage.cs: LoadPrimitives() - number of prims in storages is " + result.Count);
123 foreach (PrimData prim in result)
124 {
125 receiver.PrimFromStorage(prim);
126 }
127 }
128
129 public float[] LoadWorld()
130 {
131 MainLog.Instance.Verbose("LoadWorld() - Loading world....");
132 float[] heightmap = null;
133 MainLog.Instance.Verbose("LoadWorld() - Looking for a heightmap in local DB");
134 IObjectSet world_result = db.Get(typeof(MapStorage));
135 if (world_result.Count > 0)
136 {
137 MainLog.Instance.Verbose("LoadWorld() - Found a heightmap in local database, loading");
138 MapStorage map = (MapStorage)world_result.Next();
139 //blank.LandMap = map.Map;
140 heightmap = map.Map;
141 }
142 return heightmap;
143 }
144
145 public void SaveMap(float[] heightmap)
146 {
147 IObjectSet world_result = db.Get(typeof(MapStorage));
148 if (world_result.Count > 0)
149 {
150 MainLog.Instance.Verbose("SaveWorld() - updating saved copy of heightmap in local database");
151 MapStorage map = (MapStorage)world_result.Next();
152 db.Delete(map);
153 }
154 MapStorage map1 = new MapStorage();
155 map1.Map = heightmap; //OpenSim_Main.local_world.LandMap;
156 db.Set(map1);
157 db.Commit();
158 }
159
160 public void SaveParcel(ParcelData parcel)
161 {
162 IObjectSet result = db.Query(new UUIDParcelQuery(parcel.globalID));
163 if (result.Count > 0)
164 {
165 //Old Parcel
166 ParcelData updateParcel = (ParcelData)result.Next();
167 updateParcel.AABBMax = parcel.AABBMax;
168 updateParcel.AABBMin = parcel.AABBMin;
169 updateParcel.area = parcel.area;
170 updateParcel.auctionID = parcel.auctionID;
171 updateParcel.authBuyerID = parcel.authBuyerID;
172 updateParcel.category = parcel.category;
173 updateParcel.claimDate = parcel.claimDate;
174 updateParcel.claimPrice = parcel.claimPrice;
175 updateParcel.groupID = parcel.groupID;
176 updateParcel.groupPrims = parcel.groupPrims;
177 updateParcel.isGroupOwned = parcel.isGroupOwned;
178 updateParcel.landingType = parcel.landingType;
179 updateParcel.mediaAutoScale = parcel.mediaAutoScale;
180 updateParcel.mediaID = parcel.mediaID;
181 updateParcel.mediaURL = parcel.mediaURL;
182 updateParcel.musicURL = parcel.musicURL;
183 updateParcel.localID = parcel.localID;
184 updateParcel.ownerID = parcel.ownerID;
185 updateParcel.passHours = parcel.passHours;
186 updateParcel.passPrice = parcel.passPrice;
187 updateParcel.parcelBitmapByteArray = (byte[])parcel.parcelBitmapByteArray.Clone();
188 updateParcel.parcelDesc = parcel.parcelDesc;
189 updateParcel.parcelFlags = parcel.parcelFlags;
190 updateParcel.parcelName = parcel.parcelName;
191 updateParcel.parcelStatus = parcel.parcelStatus;
192 updateParcel.salePrice = parcel.salePrice;
193 updateParcel.snapshotID = parcel.snapshotID;
194 updateParcel.userLocation = parcel.userLocation;
195 updateParcel.userLookAt = parcel.userLookAt;
196
197 db.Set(updateParcel);
198 }
199 else
200 {
201 db.Set(parcel);
202 }
203 db.Commit();
204 }
205
206 public void SaveParcels(ParcelData[] parcel_data)
207 {
208 MainLog.Instance.Notice("Parcel Backup: Saving Parcels...");
209 int i;
210 for (i = 0; i < parcel_data.GetLength(0); i++)
211 {
212
213 SaveParcel(parcel_data[i]);
214
215 }
216 MainLog.Instance.Notice("Parcel Backup: Parcel Save Complete");
217 }
218
219 public void RemoveParcel(ParcelData parcel)
220 {
221 IObjectSet result = db.Query(new UUIDParcelQuery(parcel.globalID));
222 if (result.Count > 0)
223 {
224 db.Delete(result[0]);
225 }
226 db.Commit();
227 }
228 public void RemoveAllParcels()
229 {
230 MainLog.Instance.Notice("Parcel Backup: Removing all parcels...");
231 IObjectSet result = db.Get(typeof(ParcelData));
232 if (result.Count > 0)
233 {
234 foreach (ParcelData parcelData in result)
235 {
236 RemoveParcel(parcelData);
237 }
238 }
239 }
240
241 public void LoadParcels(ILocalStorageParcelReceiver recv)
242 {
243 MainLog.Instance.Notice("Parcel Backup: Loading Parcels...");
244 IObjectSet result = db.Get(typeof(ParcelData));
245 if (result.Count > 0)
246 {
247 MainLog.Instance.Notice("Parcel Backup: Parcels exist in database.");
248 foreach (ParcelData parcelData in result)
249 {
250
251 recv.ParcelFromStorage(parcelData);
252 }
253 }
254 else
255 {
256 MainLog.Instance.Notice("Parcel Backup: No parcels exist. Creating basic parcel.");
257 recv.NoParcelDataFromStorage();
258 }
259 MainLog.Instance.Notice("Parcel Backup: Parcels Restored");
260 }
261 public void ShutDown()
262 {
263 db.Commit();
264 db.Close();
265 }
266 }
267} \ No newline at end of file
diff --git a/OpenSim/Region/Storage/LocalStorageDb4o/MapStorage.cs b/OpenSim/Region/Storage/LocalStorageDb4o/MapStorage.cs
new file mode 100644
index 0000000..ec82d02
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageDb4o/MapStorage.cs
@@ -0,0 +1,39 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28namespace OpenSim.Region.Storage.LocalStorageDb4o
29{
30 public class MapStorage
31 {
32 public float[] Map;
33
34 public MapStorage()
35 {
36
37 }
38 }
39} \ No newline at end of file
diff --git a/OpenSim/Region/Storage/LocalStorageDb4o/UUIDParcelQuery.cs b/OpenSim/Region/Storage/LocalStorageDb4o/UUIDParcelQuery.cs
new file mode 100644
index 0000000..6e6768c
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageDb4o/UUIDParcelQuery.cs
@@ -0,0 +1,47 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 Db4objects.Db4o.Query;
29using libsecondlife;
30using OpenSim.Framework.Types;
31
32namespace OpenSim.Region.Storage.LocalStorageDb4o
33{
34 public class UUIDParcelQuery : Predicate
35 {
36 private LLUUID globalIDSearch;
37
38 public UUIDParcelQuery(LLUUID find)
39 {
40 globalIDSearch = find;
41 }
42 public bool Match(ParcelData parcel)
43 {
44 return (parcel.globalID == globalIDSearch);
45 }
46 }
47}
diff --git a/OpenSim/Region/Storage/LocalStorageDb4o/UUIDPrimQuery.cs b/OpenSim/Region/Storage/LocalStorageDb4o/UUIDPrimQuery.cs
new file mode 100644
index 0000000..eb309cb
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageDb4o/UUIDPrimQuery.cs
@@ -0,0 +1,47 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 Db4objects.Db4o.Query;
29using libsecondlife;
30using OpenSim.Framework.Types;
31
32namespace OpenSim.Region.Storage.LocalStorageDb4o
33{
34 public class UUIDPrimQuery : Predicate
35 {
36 private LLUUID _findID;
37
38 public UUIDPrimQuery(LLUUID find)
39 {
40 _findID = find;
41 }
42 public bool Match(PrimData prim)
43 {
44 return (prim.FullID == _findID);
45 }
46 }
47}
diff --git a/OpenSim/Region/Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs b/OpenSim/Region/Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..ea9cda8
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs
@@ -0,0 +1,60 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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// General Information about an assembly is controlled through the following
31// set of attributes. Change these attribute values to modify the information
32// associated with an assembly.
33[assembly: AssemblyTitle("OpenSim.Region.Storage.LocalStorageSQLite")]
34[assembly: AssemblyDescription("")]
35[assembly: AssemblyConfiguration("")]
36[assembly: AssemblyCompany("")]
37[assembly: AssemblyProduct("OpenSim.Region.Storage.LocalStorageSQLite")]
38[assembly: AssemblyCopyright("Copyright © 2007")]
39[assembly: AssemblyTrademark("")]
40[assembly: AssemblyCulture("")]
41
42// Setting ComVisible to false makes the types in this assembly not visible
43// to COM components. If you need to access a type in this assembly from
44// COM, set the ComVisible attribute to true on that type.
45[assembly: ComVisible(false)]
46
47// The following GUID is for the ID of the typelib if this project is exposed to COM
48[assembly: Guid("ecd6e0c1-7909-413e-9e3f-659678ac3bc3")]
49
50// Version information for an assembly consists of the following four values:
51//
52// Major Version
53// Minor Version
54// Build Number
55// Revision
56//
57// You can specify all the values or you can default the Revision and Build Numbers
58// by using the '*' as shown below:
59[assembly: AssemblyVersion("1.0.0.*")]
60[assembly: AssemblyFileVersion("1.0.0.*")]
diff --git a/OpenSim/Region/Storage/LocalStorageSQLite/SQLiteLocalStorage.cs b/OpenSim/Region/Storage/LocalStorageSQLite/SQLiteLocalStorage.cs
new file mode 100644
index 0000000..9900a98
--- /dev/null
+++ b/OpenSim/Region/Storage/LocalStorageSQLite/SQLiteLocalStorage.cs
@@ -0,0 +1,198 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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*/
28
29// SQLite Support
30// A bad idea, but the IRC people told me to!
31
32using System;
33using System.Data;
34using System.Data.SQLite;
35using libsecondlife;
36using OpenSim.Framework.Console;
37using OpenSim.Framework.Interfaces;
38using OpenSim.Framework.Types;
39
40namespace OpenSim.Region.Storage.LocalStorageSQLite
41{
42 public class SQLiteLocalStorage : ILocalStorage
43 {
44 IDbConnection db;
45
46 public SQLiteLocalStorage()
47 {
48 try
49 {
50 string connectionstring = "URI=file:localsim.sdb";
51 db = (IDbConnection)new SQLiteConnection(connectionstring);
52 db.Open();
53 }
54 catch (Exception e)
55 {
56 db.Close();
57 MainLog.Instance.Warn("SQLiteLocalStorage :Constructor - Exception occured");
58 MainLog.Instance.Warn(e.ToString());
59 }
60 }
61
62 public void Initialise(string file)
63 {
64 // Blank
65 }
66
67 public void StorePrim(PrimData prim)
68 {
69 IDbCommand cmd = db.CreateCommand();
70
71 //SECURITY WARNING:
72 // These parameters wont produce SQL injections since they are all integer based, however.
73 // if inserting strings such as name or description, you will need to use appropriate
74 // measures to prevent SQL injection (although the value of SQL injection in this is limited).
75
76 string sql = "REPLACE INTO prim (OwnerID,PCode,PathBegin,PathEnd,PathScaleX,PathScaleY,PathShearX,PathShearY,PathSkew,ProfileBegin,ProfileEnd,Scale,PathCurve,ProfileCurve,ParentID,ProfileHollow,PathRadiusOffset,PathRevolutions,PathTaperX,PathTaperY,PathTwist,PathTwistBegin,Texture,CreationDate,OwnerMask,NextOwnerMask,GroupMask,EveryoneMask,BaseMask,Position,Rotation,LocalID,FullID) ";
77 sql += "VALUES (";
78 sql += "\"" + prim.OwnerID.ToStringHyphenated() + "\","; // KILL ME NOW!
79 sql += "\"" + prim.PCode.ToString() + "\",";
80 sql += "\"" + prim.PathBegin.ToString() + "\",";
81 sql += "\"" + prim.PathEnd.ToString() + "\",";
82 sql += "\"" + prim.PathScaleX.ToString() + "\",";
83 sql += "\"" + prim.PathScaleY.ToString() + "\",";
84 sql += "\"" + prim.PathShearX.ToString() + "\",";
85 sql += "\"" + prim.PathShearY.ToString() + "\",";
86 sql += "\"" + prim.PathSkew.ToString() + "\",";
87 sql += "\"" + prim.ProfileBegin.ToString() + "\",";
88 sql += "\"" + prim.ProfileEnd.ToString() + "\",";
89 sql += "\"" + prim.Scale.ToString() + "\",";
90 sql += "\"" + prim.PathCurve.ToString() + "\",";
91 sql += "\"" + prim.ProfileCurve.ToString() + "\",";
92 sql += "\"" + prim.ParentID.ToString() + "\",";
93 sql += "\"" + prim.ProfileHollow.ToString() + "\",";
94 sql += "\"" + prim.PathRadiusOffset.ToString() + "\",";
95 sql += "\"" + prim.PathRevolutions.ToString() + "\",";
96 sql += "\"" + prim.PathTaperX.ToString() + "\",";
97 sql += "\"" + prim.PathTaperY.ToString() + "\",";
98 sql += "\"" + prim.PathTwist.ToString() + "\",";
99 sql += "\"" + prim.PathTwistBegin.ToString() + "\",";
100 sql += "\"" + prim.TextureEntry.ToString() + "\",";
101 sql += "\"" + prim.CreationDate.ToString() + "\",";
102 sql += "\"" + prim.OwnerMask.ToString() + "\",";
103 sql += "\"" + prim.NextOwnerMask.ToString() + "\",";
104 sql += "\"" + prim.GroupMask.ToString() + "\",";
105 sql += "\"" + prim.EveryoneMask.ToString() + "\",";
106 sql += "\"" + prim.BaseMask.ToString() + "\",";
107 sql += "\"" + prim.Position.ToString() + "\",";
108 sql += "\"" + prim.Rotation.ToString() + "\",";
109 sql += "\"" + prim.LocalID.ToString() + "\",";
110 sql += "\"" + prim.FullID.ToString() + "\")";
111
112 cmd.CommandText = sql;
113
114 try
115 {
116 cmd.ExecuteNonQuery();
117 }
118 catch (Exception e)
119 {
120 MainLog.Instance.Warn("SQLiteLocalStorage :StorePrim - Exception occured");
121 MainLog.Instance.Warn(e.ToString());
122 }
123
124 cmd.Dispose();
125 cmd = null;
126 }
127
128 public void RemovePrim(LLUUID primID)
129 {
130 IDbCommand cmd = db.CreateCommand();
131
132 //SECURITY WARNING:
133 // These parameters wont produce SQL injections since they are all integer based, however.
134 // if inserting strings such as name or description, you will need to use appropriate
135 // measures to prevent SQL injection (although the value of SQL injection in this is limited).
136
137 string sql = "DELETE FROM prim WHERE FullID = \"" + primID.ToStringHyphenated() + "\"";
138
139 cmd.CommandText = sql;
140
141 try
142 {
143 cmd.ExecuteNonQuery();
144 }
145 catch (Exception e)
146 {
147 MainLog.Instance.Warn("SQLiteLocalStorage :RemovePrim - Exception occured");
148 MainLog.Instance.Warn(e.ToString());
149 }
150
151 cmd.Dispose();
152 cmd = null;
153 }
154
155 public void LoadPrimitives(ILocalStorageReceiver receiver)
156 {
157
158 }
159
160 public float[] LoadWorld()
161 {
162 return new float[65536];
163 }
164
165 public void SaveMap(float[] heightmap)
166 {
167
168 }
169
170 public void SaveParcels(ParcelData[] parcel_manager)
171 {
172
173 }
174
175 public void SaveParcel(ParcelData parcel)
176 {
177 }
178
179 public void RemoveParcel(ParcelData parcel)
180 {
181 }
182
183 public void RemoveAllParcels()
184 {
185 }
186
187 public void LoadParcels(ILocalStorageParcelReceiver recv)
188 {
189 recv.NoParcelDataFromStorage();
190 }
191
192 public void ShutDown()
193 {
194 db.Close();
195 db = null;
196 }
197 }
198} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs b/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..9c721d1
--- /dev/null
+++ b/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs
@@ -0,0 +1,60 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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// General Information about an assembly is controlled through the following
31// set of attributes. Change these attribute values to modify the information
32// associated with an assembly.
33[assembly: AssemblyTitle("OpenSim.Region.Terrain.BasicTerrain")]
34[assembly: AssemblyDescription("")]
35[assembly: AssemblyConfiguration("")]
36[assembly: AssemblyCompany("")]
37[assembly: AssemblyProduct("OpenSim.Region.Terrain.BasicTerrain")]
38[assembly: AssemblyCopyright("Copyright © 2007")]
39[assembly: AssemblyTrademark("")]
40[assembly: AssemblyCulture("")]
41
42// Setting ComVisible to false makes the types in this assembly not visible
43// to COM components. If you need to access a type in this assembly from
44// COM, set the ComVisible attribute to true on that type.
45[assembly: ComVisible(false)]
46
47// The following GUID is for the ID of the typelib if this project is exposed to COM
48[assembly: Guid("3263f5b5-0a41-4ed5-91a2-9baaaeecc849")]
49
50// Version information for an assembly consists of the following four values:
51//
52// Major Version
53// Minor Version
54// Build Number
55// Revision
56//
57// You can specify all the values or you can default the Revision and Build Numbers
58// by using the '*' as shown below:
59[assembly: AssemblyVersion("1.0.0.0")]
60[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
new file mode 100644
index 0000000..6c9ec26
--- /dev/null
+++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
@@ -0,0 +1,928 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Drawing;
31using System.Drawing.Imaging;
32using System.IO;
33using libTerrain;
34using OpenJPEGNet;
35
36namespace OpenSim.Region.Terrain
37{
38 public class TerrainCommand
39 {
40 public virtual bool run(string[] cmdargs, ref string output)
41 {
42 return false;
43 }
44
45 public string args;
46 public string help;
47 }
48
49 public class TerrainEngine
50 {
51 /// <summary>
52 /// Plugin library for scripts
53 /// </summary>
54 public FilterHost customFilters = new FilterHost();
55
56 /// <summary>
57 /// A [normally] 256x256 heightmap
58 /// </summary>
59 public Channel heightmap;
60
61 /// <summary>
62 /// A copy of heightmap at the last save point (for reverting)
63 /// </summary>
64 public Channel revertmap;
65
66 /// <summary>
67 /// Water heightmap (needs clientside mods to work)
68 /// </summary>
69 public Channel watermap;
70
71 /// <summary>
72 /// Whether or not the terrain has been modified since it was last saved and sent to the Physics engine.
73 /// Counts the number of modifications since the last save. (0 = Untainted)
74 /// </summary>
75 public int tainted;
76
77 int w, h;
78
79 /// <summary>
80 /// Generate a new TerrainEngine instance and creates a new heightmap
81 /// </summary>
82 public TerrainEngine()
83 {
84 w = 256;
85 h = 256;
86 heightmap = new Channel(w, h);
87
88 tainted++;
89 }
90
91 /// <summary>
92 /// Converts the heightmap to a 65536 value 1D floating point array
93 /// </summary>
94 /// <returns>A float[65536] array containing the heightmap</returns>
95 public float[] getHeights1D()
96 {
97 float[] heights = new float[w * h];
98 int i;
99
100 for (i = 0; i < w * h; i++)
101 {
102 heights[i] = (float)heightmap.map[i / w, i % w];
103 }
104
105 return heights;
106 }
107
108 /// <summary>
109 /// Converts the heightmap to a 256x256 value 2D floating point array.
110 /// </summary>
111 /// <returns>An array of 256,256 values containing the heightmap</returns>
112 public float[,] getHeights2D()
113 {
114 float[,] heights = new float[w, h];
115 int x, y;
116 for (x = 0; x < w; x++)
117 {
118 for (y = 0; y < h; y++)
119 {
120 heights[x, y] = (float)heightmap.map[x, y];
121 }
122 }
123 return heights;
124 }
125
126 /// <summary>
127 /// Imports a 1D floating point array into the 2D heightmap array
128 /// </summary>
129 /// <param name="heights">The array to import (must have 65536 members)</param>
130 public void setHeights1D(float[] heights)
131 {
132 int i;
133 for (i = 0; i < w * h; i++)
134 {
135 heightmap.map[i / w, i % w] = heights[i];
136 }
137
138 tainted++;
139 }
140
141 /// <summary>
142 /// Loads a 2D array of values into the heightmap
143 /// </summary>
144 /// <param name="heights">An array of 256,256 float values</param>
145 public void setHeights2D(float[,] heights)
146 {
147 int x, y;
148 for (x = 0; x < w; x++)
149 {
150 for (y = 0; y < h; y++)
151 {
152 heightmap.set(x, y, (double)heights[x, y]);
153 }
154 }
155 tainted++;
156 }
157
158 /// <summary>
159 /// Swaps the two heightmap buffers (the 'revert map' and the heightmap)
160 /// </summary>
161 public void swapRevertMaps()
162 {
163 Channel backup = heightmap.copy();
164 heightmap = revertmap;
165 revertmap = backup;
166 }
167
168 /// <summary>
169 /// Saves the current heightmap into the revertmap
170 /// </summary>
171 public void saveRevertMap()
172 {
173 revertmap = heightmap.copy();
174 }
175
176 /// <summary>
177 /// Processes a terrain-specific command
178 /// </summary>
179 /// <param name="args">Commandline arguments (space seperated)</param>
180 /// <param name="resultText">Reference that returns error or help text if returning false</param>
181 /// <returns>If the operation was successful (if not, the error is placed into resultText)</returns>
182 public bool RunTerrainCmd(string[] args, ref string resultText, string simName)
183 {
184 string command = args[0];
185
186 try
187 {
188
189 switch (command)
190 {
191 case "help":
192 resultText += "terrain regenerate - rebuilds the sims terrain using a default algorithm\n";
193 resultText += "terrain voronoi <points> <blocksize> - generates a worley fractal with X points per block";
194 resultText += "terrain seed <seed> - sets the random seed value to <seed>\n";
195 resultText += "terrain load <type> <filename> - loads a terrain from disk, type can be 'F32', 'F64', 'RAW' or 'IMG'\n";
196 resultText += "terrain save <type> <filename> - saves a terrain to disk, type can be 'F32', 'F64', 'PNG', 'RAW' or 'HIRAW'\n";
197 resultText += "terrain save grdmap <filename> <gradient map> - creates a PNG snapshot of the region using a named gradient map\n";
198 resultText += "terrain rescale <min> <max> - rescales a terrain to be between <min> and <max> meters high\n";
199 resultText += "terrain erode aerobic <windspeed> <pickupmin> <dropmin> <carry> <rounds> <lowest>\n";
200 resultText += "terrain erode thermal <talus> <rounds> <carry>\n";
201 resultText += "terrain multiply <val> - multiplies a terrain by <val>\n";
202 resultText += "terrain revert - reverts the terrain to the stored original\n";
203 resultText += "terrain bake - saves the current terrain into the revert map\n";
204 resultText += "terrain csfilter <filename.cs> - loads a new filter from the specified .cs file\n";
205 resultText += "terrain jsfilter <filename.js> - loads a new filter from the specified .js file\n";
206 foreach (KeyValuePair<string, ITerrainFilter> filter in customFilters.filters)
207 {
208 resultText += filter.Value.Help();
209 }
210
211 return false;
212
213 case "revert":
214 swapRevertMaps();
215 saveRevertMap();
216 break;
217
218 case "bake":
219 saveRevertMap();
220 break;
221
222 case "seed":
223 setSeed(Convert.ToInt32(args[1]));
224 break;
225
226 case "erode":
227 return consoleErosion(args, ref resultText);
228
229 case "voronoi":
230 double[] c = new double[2];
231 c[0] = -1;
232 c[1] = 1;
233 heightmap.voronoiDiagram(Convert.ToInt32(args[1]), Convert.ToInt32(args[2]), c);
234 break;
235
236 case "hills":
237 return consoleHills(args, ref resultText);
238
239 case "regenerate":
240 hills();
241 break;
242
243 case "rescale":
244 setRange(Convert.ToSingle(args[1]), Convert.ToSingle(args[2]));
245 break;
246
247 case "multiply":
248 heightmap *= Convert.ToDouble(args[1]);
249 break;
250
251 case "load":
252 args[2].Replace("%name%", simName);
253 switch (args[1].ToLower())
254 {
255 case "f32":
256 loadFromFileF32(args[2]);
257 break;
258
259 case "f64":
260 loadFromFileF64(args[2]);
261 break;
262
263 case "raw":
264 loadFromFileSLRAW(args[2]);
265 break;
266
267 case "img":
268 heightmap.loadImage(args[2]);
269 return false;
270
271 default:
272 resultText = "Unknown image or data format";
273 return false;
274 }
275 break;
276
277 case "save":
278 args[2].Replace("%name%", simName);
279 switch (args[1].ToLower())
280 {
281 case "f32":
282 writeToFileF32(args[2]);
283 break;
284
285 case "f64":
286 writeToFileF64(args[2]);
287 break;
288
289 case "grdmap":
290 exportImage(args[2], args[3]);
291 break;
292
293 case "png":
294 heightmap.saveImage(args[2]);
295 break;
296
297 case "raw":
298 writeToFileRAW(args[2]);
299 break;
300
301 case "hiraw":
302 writeToFileHiRAW(args[2]);
303 break;
304
305 default:
306 resultText = "Unknown image or data format";
307 return false;
308 }
309 break;
310
311 case "csfilter":
312 customFilters.LoadFilterCSharp(args[1]);
313 break;
314 case "jsfilter":
315 customFilters.LoadFilterJScript(args[1]);
316 break;
317
318 default:
319 // Run any custom registered filters
320 if (customFilters.filters.ContainsKey(command))
321 {
322 customFilters.filters[command].Filter(heightmap, args);
323 break;
324 }
325 else
326 {
327 resultText = "Unknown terrain command";
328 return false;
329 }
330 }
331 return true;
332 }
333 catch (Exception e)
334 {
335 resultText = "Error running terrain command: " + e.ToString();
336 return false;
337 }
338 }
339
340 private bool consoleErosion(string[] args, ref string resultText)
341 {
342 switch (args[1].ToLower())
343 {
344 case "aerobic":
345 // WindSpeed, PickupMinimum,DropMinimum,Carry,Rounds,Lowest
346 heightmap.AerobicErosion(Convert.ToDouble(args[2]), Convert.ToDouble(args[3]), Convert.ToDouble(args[4]), Convert.ToDouble(args[5]), Convert.ToInt32(args[6]), Convert.ToBoolean(args[7]));
347 break;
348 case "thermal":
349 heightmap.thermalWeathering(Convert.ToDouble(args[2]), Convert.ToInt32(args[3]), Convert.ToDouble(args[4]));
350 break;
351 default:
352 resultText = "Unknown erosion type";
353 return false;
354 }
355 return true;
356 }
357
358 private bool consoleHills(string[] args, ref string resultText)
359 {
360 int count;
361 double sizeMin;
362 double sizeRange;
363 bool island;
364 bool additive;
365 bool noisy;
366
367 if (args.GetLength(0) > 2)
368 {
369 count = Convert.ToInt32(args[2]);
370 sizeMin = Convert.ToDouble(args[3]);
371 sizeRange = Convert.ToDouble(args[4]);
372 island = Convert.ToBoolean(args[5]);
373 additive = Convert.ToBoolean(args[6]);
374 noisy = Convert.ToBoolean(args[7]);
375 }
376 else
377 {
378 count = 200;
379 sizeMin = 20;
380 sizeRange = 40;
381 island = true;
382 additive = true;
383 noisy = false;
384 }
385
386 switch (args[1].ToLower())
387 {
388 case "blocks":
389 heightmap.hillsBlocks(count, sizeMin, sizeRange, island, additive, noisy);
390 break;
391 case "cones":
392 heightmap.hillsCones(count, sizeMin, sizeRange, island, additive, noisy);
393 break;
394 case "spheres":
395 heightmap.hillsSpheres(count, sizeMin, sizeRange, island, additive, noisy);
396 break;
397 case "squared":
398 heightmap.hillsSquared(count, sizeMin, sizeRange, island, additive, noisy);
399 break;
400 default:
401 resultText = "Unknown hills type";
402 return false;
403 }
404 return true;
405 }
406
407 /// <summary>
408 /// Renormalises the array between min and max
409 /// </summary>
410 /// <param name="min">Minimum value of the new array</param>
411 /// <param name="max">Maximum value of the new array</param>
412 public void setRange(float min, float max)
413 {
414 heightmap.normalise((double)min, (double)max);
415 tainted++;
416 }
417
418 /// <summary>
419 /// Loads a file consisting of 256x256 doubles and imports it as an array into the map.
420 /// </summary>
421 /// <remarks>TODO: Move this to libTerrain itself</remarks>
422 /// <param name="filename">The filename of the double array to import</param>
423 public void loadFromFileF64(string filename)
424 {
425 FileInfo file = new FileInfo(filename);
426 FileStream s = file.Open(FileMode.Open, FileAccess.Read);
427 BinaryReader bs = new BinaryReader(s);
428 int x, y;
429 for (x = 0; x < w; x++)
430 {
431 for (y = 0; y < h; y++)
432 {
433 heightmap.map[x, y] = bs.ReadDouble();
434 }
435 }
436
437 bs.Close();
438 s.Close();
439
440 tainted++;
441 }
442
443 /// <summary>
444 /// Loads a file consisting of 256x256 floats and imports it as an array into the map.
445 /// </summary>
446 /// <remarks>TODO: Move this to libTerrain itself</remarks>
447 /// <param name="filename">The filename of the float array to import</param>
448 public void loadFromFileF32(string filename)
449 {
450 FileInfo file = new FileInfo(filename);
451 FileStream s = file.Open(FileMode.Open, FileAccess.Read);
452 BinaryReader bs = new BinaryReader(s);
453 int x, y;
454 for (x = 0; x < w; x++)
455 {
456 for (y = 0; y < h; y++)
457 {
458 heightmap.map[x, y] = (double)bs.ReadSingle();
459 }
460 }
461
462 bs.Close();
463 s.Close();
464
465 tainted++;
466 }
467
468 /// <summary>
469 /// Loads a file formatted in the SL .RAW Format used on the main grid
470 /// </summary>
471 /// <remarks>This file format stinks and is best avoided.</remarks>
472 /// <param name="filename">A path to the .RAW format</param>
473 public void loadFromFileSLRAW(string filename)
474 {
475 FileInfo file = new FileInfo(filename);
476 FileStream s = file.Open(FileMode.Open, FileAccess.Read);
477 BinaryReader bs = new BinaryReader(s);
478 int x, y;
479 for (x = 0; x < w; x++)
480 {
481 for (y = 0; y < h; y++)
482 {
483 heightmap.map[x, y] = (double)bs.ReadByte() * ((double)bs.ReadByte() / 127.0);
484 bs.ReadBytes(11); // Advance the stream to next bytes.
485 }
486 }
487
488 bs.Close();
489 s.Close();
490
491 tainted++;
492 }
493
494 /// <summary>
495 /// Writes the current terrain heightmap to disk, in the format of a 65536 entry double[] array.
496 /// </summary>
497 /// <param name="filename">The desired output filename</param>
498 public void writeToFileF64(string filename)
499 {
500 FileInfo file = new FileInfo(filename);
501 FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write);
502 BinaryWriter bs = new BinaryWriter(s);
503
504 int x, y;
505 for (x = 0; x < w; x++)
506 {
507 for (y = 0; y < h; y++)
508 {
509 bs.Write(heightmap.get(x, y));
510 }
511 }
512
513 bs.Close();
514 s.Close();
515 }
516
517 /// <summary>
518 /// Writes the current terrain heightmap to disk, in the format of a 65536 entry float[] array
519 /// </summary>
520 /// <param name="filename">The desired output filename</param>
521 public void writeToFileF32(string filename)
522 {
523 FileInfo file = new FileInfo(filename);
524 FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write);
525 BinaryWriter bs = new BinaryWriter(s);
526
527 int x, y;
528 for (x = 0; x < w; x++)
529 {
530 for (y = 0; y < h; y++)
531 {
532 bs.Write((float)heightmap.get(x, y));
533 }
534 }
535
536 bs.Close();
537 s.Close();
538 }
539
540 /// <summary>
541 /// A very fast LL-RAW file output mechanism - lower precision mechanism but wont take 5 minutes to run either.
542 /// (is also editable in an image application)
543 /// </summary>
544 /// <param name="filename">Filename to write to</param>
545 public void writeToFileRAW(string filename)
546 {
547 FileInfo file = new FileInfo(filename);
548 FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write);
549 BinaryWriter bs = new BinaryWriter(s);
550
551 int x, y;
552
553 // Used for the 'green' channel.
554 byte avgMultiplier = (byte)heightmap.avg();
555 byte backupMultiplier = (byte)revertmap.avg();
556
557 // Limit the multiplier so it can represent points >64m.
558 if (avgMultiplier > 196)
559 avgMultiplier = 196;
560 if(backupMultiplier > 196)
561 backupMultiplier = 196;
562 // Make sure it's at least one to prevent a div by zero
563 if (avgMultiplier < 1)
564 avgMultiplier = 1;
565 if(backupMultiplier < 1)
566 backupMultiplier = 1;
567
568 for (x = 0; x < w; x++)
569 {
570 for (y = 0; y < h; y++)
571 {
572 byte red = (byte)(heightmap.get(x, y) / ((double)avgMultiplier / 128.0));
573 byte green = avgMultiplier;
574 byte blue = (byte)watermap.get(x, y);
575 byte alpha1 = 0; // Land Parcels
576 byte alpha2 = 0; // For Sale Land
577 byte alpha3 = 0; // Public Edit Object
578 byte alpha4 = 0; // Public Edit Land
579 byte alpha5 = 255; // Safe Land
580 byte alpha6 = 255; // Flying Allowed
581 byte alpha7 = 255; // Create Landmark
582 byte alpha8 = 255; // Outside Scripts
583 byte alpha9 = (byte)(revertmap.get(x, y) / ((double)backupMultiplier / 128.0));
584 byte alpha10 = backupMultiplier;
585
586 bs.Write(red);
587 bs.Write(green);
588 bs.Write(blue);
589 bs.Write(alpha1);
590 bs.Write(alpha2);
591 bs.Write(alpha3);
592 bs.Write(alpha4);
593 bs.Write(alpha5);
594 bs.Write(alpha6);
595 bs.Write(alpha7);
596 bs.Write(alpha8);
597 bs.Write(alpha9);
598 bs.Write(alpha10);
599 }
600 }
601 bs.Close();
602 s.Close();
603 }
604
605 /// <summary>
606 /// Outputs to a LL compatible RAW in the most efficient manner possible
607 /// </summary>
608 /// <remarks>Does not calculate the revert map</remarks>
609 /// <param name="filename">The filename to output to</param>
610 public void writeToFileHiRAW(string filename)
611 {
612 FileInfo file = new FileInfo(filename);
613 FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write);
614 BinaryWriter bs = new BinaryWriter(s);
615
616 // Generate a smegging big lookup table to speed the operation up (it needs it)
617 double[] lookupTable = new double[65536];
618 int i, j, x, y;
619 for (i = 0; i < 256; i++)
620 {
621 for (j = 0; j < 256; j++)
622 {
623 lookupTable[i + (j * 256)] = ((double)i * ((double)j / 127.0));
624 }
625 }
626
627 // Output the calculated raw
628 for (x = 0; x < w; x++)
629 {
630 for (y = 0; y < h; y++)
631 {
632 double t = heightmap.get(x, y);
633 double min = double.MaxValue;
634 int index = 0;
635
636 for (i = 0; i < 65536; i++)
637 {
638 if (Math.Abs(t - lookupTable[i]) < min)
639 {
640 min = Math.Abs(t - lookupTable[i]);
641 index = i;
642 }
643 }
644
645 byte red = (byte)(index & 0xFF);
646 byte green = (byte)((index >> 8) & 0xFF);
647 byte blue = (byte)watermap.get(x, y);
648 byte alpha1 = 0; // Land Parcels
649 byte alpha2 = 0; // For Sale Land
650 byte alpha3 = 0; // Public Edit Object
651 byte alpha4 = 0; // Public Edit Land
652 byte alpha5 = 255; // Safe Land
653 byte alpha6 = 255; // Flying Allowed
654 byte alpha7 = 255; // Create Landmark
655 byte alpha8 = 255; // Outside Scripts
656 byte alpha9 = red;
657 byte alpha10 = green;
658
659 bs.Write(red);
660 bs.Write(green);
661 bs.Write(blue);
662 bs.Write(alpha1);
663 bs.Write(alpha2);
664 bs.Write(alpha3);
665 bs.Write(alpha4);
666 bs.Write(alpha5);
667 bs.Write(alpha6);
668 bs.Write(alpha7);
669 bs.Write(alpha8);
670 bs.Write(alpha9);
671 bs.Write(alpha10);
672 }
673 }
674
675 bs.Close();
676 s.Close();
677 }
678
679 /// <summary>
680 /// Sets the random seed to be used by procedural functions which involve random numbers.
681 /// </summary>
682 /// <param name="val">The desired seed</param>
683 public void setSeed(int val)
684 {
685 heightmap.seed = val;
686 }
687
688 /// <summary>
689 /// Raises land in a sphere around the specified coordinates
690 /// </summary>
691 /// <param name="rx">Center of the sphere on the X axis</param>
692 /// <param name="ry">Center of the sphere on the Y axis</param>
693 /// <param name="size">The radius of the sphere</param>
694 /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param>
695 public void raise(double rx, double ry, double size, double amount)
696 {
697 lock (heightmap)
698 {
699 heightmap.raise(rx, ry, size, amount);
700 }
701
702 tainted++;
703 }
704
705 /// <summary>
706 /// Lowers the land in a sphere around the specified coordinates
707 /// </summary>
708 /// <param name="rx">The center of the sphere at the X axis</param>
709 /// <param name="ry">The center of the sphere at the Y axis</param>
710 /// <param name="size">The radius of the sphere in meters</param>
711 /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param>
712 public void lower(double rx, double ry, double size, double amount)
713 {
714 lock (heightmap)
715 {
716 heightmap.lower(rx, ry, size, amount);
717 }
718
719 tainted++;
720 }
721
722 /// <summary>
723 /// Flattens the land under the brush of specified coordinates (spherical mask)
724 /// </summary>
725 /// <param name="rx">Center of sphere</param>
726 /// <param name="ry">Center of sphere</param>
727 /// <param name="size">Radius of the sphere</param>
728 /// <param name="amount">Thickness of the mask (0..2 recommended)</param>
729 public void flatten(double rx, double ry, double size, double amount)
730 {
731 lock (heightmap)
732 {
733 heightmap.flatten(rx, ry, size, amount);
734 }
735
736 tainted++;
737 }
738
739 /// <summary>
740 /// Creates noise within the specified bounds
741 /// </summary>
742 /// <param name="rx">Center of the bounding sphere</param>
743 /// <param name="ry">Center of the bounding sphere</param>
744 /// <param name="size">The radius of the sphere</param>
745 /// <param name="amount">Strength of the mask (0..2) recommended</param>
746 public void noise(double rx, double ry, double size, double amount)
747 {
748 lock (heightmap)
749 {
750 Channel smoothed = new Channel();
751 smoothed.noise();
752
753 Channel mask = new Channel();
754 mask.raise(rx, ry, size, amount);
755
756 heightmap.blend(smoothed, mask);
757 }
758
759 tainted++;
760 }
761
762 /// <summary>
763 /// Reverts land within the specified bounds
764 /// </summary>
765 /// <param name="rx">Center of the bounding sphere</param>
766 /// <param name="ry">Center of the bounding sphere</param>
767 /// <param name="size">The radius of the sphere</param>
768 /// <param name="amount">Strength of the mask (0..2) recommended</param>
769 public void revert(double rx, double ry, double size, double amount)
770 {
771 lock (heightmap)
772 {
773 Channel mask = new Channel();
774 mask.raise(rx, ry, size, amount);
775
776 heightmap.blend(revertmap, mask);
777 }
778
779 tainted++;
780 }
781
782 /// <summary>
783 /// Smooths land under the brush of specified coordinates (spherical mask)
784 /// </summary>
785 /// <param name="rx">Center of the sphere</param>
786 /// <param name="ry">Center of the sphere</param>
787 /// <param name="size">Radius of the sphere</param>
788 /// <param name="amount">Thickness of the mask (0..2 recommended)</param>
789 public void smooth(double rx, double ry, double size, double amount)
790 {
791 lock (heightmap)
792 {
793 Channel smoothed = heightmap.copy();
794 smoothed.smooth(amount);
795
796 Channel mask = new Channel();
797 mask.raise(rx,ry,size,amount);
798
799 heightmap.blend(smoothed, mask);
800 }
801
802 tainted++;
803 }
804
805 /// <summary>
806 /// Generates a simple set of hills in the shape of an island
807 /// </summary>
808 public void hills()
809 {
810 lock (heightmap)
811 {
812 heightmap.hillsSpheres(200, 20, 40, true, true, false);
813 heightmap.normalise();
814 heightmap *= 60.0; // Raise to 60m
815 }
816
817 tainted++;
818 }
819
820 /// <summary>
821 /// Wrapper to heightmap.get()
822 /// </summary>
823 /// <param name="x">X coord</param>
824 /// <param name="y">Y coord</param>
825 /// <returns>Height at specified coordinates</returns>
826 public double get(int x, int y)
827 {
828 return heightmap.get(x, y);
829 }
830
831 /// <summary>
832 /// Multiplies the heightfield by val
833 /// </summary>
834 /// <param name="meep">The heightfield</param>
835 /// <param name="val">The multiplier</param>
836 /// <returns></returns>
837 public static TerrainEngine operator *(TerrainEngine meep, Double val)
838 {
839 meep.heightmap *= val;
840 meep.tainted++;
841 return meep;
842 }
843
844 /// <summary>
845 /// Exports the current heightmap to a PNG file
846 /// </summary>
847 /// <param name="filename">The destination filename for the image</param>
848 /// <param name="gradientmap">A 1x*height* image which contains the colour gradient to export with. Must be at least 1x2 pixels, 1x256 or more is ideal.</param>
849 public void exportImage(string filename, string gradientmap)
850 {
851 try
852 {
853 Bitmap gradientmapLd = new Bitmap(gradientmap);
854
855 int pallete = gradientmapLd.Height;
856
857 Bitmap bmp = new Bitmap(heightmap.w, heightmap.h);
858 Color[] colours = new Color[pallete];
859
860 for (int i = 0; i < pallete; i++)
861 {
862 colours[i] = gradientmapLd.GetPixel(0, i);
863 }
864
865 Channel copy = heightmap.copy();
866 for (int x = 0; x < copy.w; x++)
867 {
868 for (int y = 0; y < copy.h; y++)
869 {
870 // 512 is the largest possible height before colours clamp
871 int colorindex = (int)(Math.Max(Math.Min(1.0, copy.get(x, y) / 512.0), 0.0) * pallete);
872 bmp.SetPixel(x, y, colours[colorindex]);
873 }
874 }
875
876 bmp.Save(filename, ImageFormat.Png);
877 }
878 catch (Exception e)
879 {
880 Console.WriteLine("Failed generating terrain map: " + e.ToString());
881 }
882 }
883
884 /// <summary>
885 /// Exports the current heightmap in Jpeg2000 format to a byte[]
886 /// </summary>
887 /// <param name="gradientmap">A 1x*height* image which contains the colour gradient to export with. Must be at least 1x2 pixels, 1x256 or more is ideal.</param>
888 public byte[] exportJpegImage(string gradientmap)
889 {
890 byte[] imageData = null;
891 try
892 {
893 Bitmap gradientmapLd = new Bitmap(gradientmap);
894
895 int pallete = gradientmapLd.Height;
896
897 Bitmap bmp = new Bitmap(heightmap.w, heightmap.h);
898 Color[] colours = new Color[pallete];
899
900 for (int i = 0; i < pallete; i++)
901 {
902 colours[i] = gradientmapLd.GetPixel(0, i);
903 }
904
905 Channel copy = heightmap.copy();
906 for (int x = 0; x < copy.w; x++)
907 {
908 for (int y = 0; y < copy.h; y++)
909 {
910 // 512 is the largest possible height before colours clamp
911 int colorindex = (int)(Math.Max(Math.Min(1.0, copy.get(copy.h - y, x) / 512.0), 0.0) * pallete);
912 bmp.SetPixel(x, y, colours[colorindex]);
913 }
914 }
915
916 //bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Png);
917 imageData = OpenJPEG.EncodeFromImage(bmp, "map");
918
919 }
920 catch (Exception e)
921 {
922 Console.WriteLine("Failed generating terrain map: " + e.ToString());
923 }
924
925 return imageData;
926 }
927 }
928} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs
new file mode 100644
index 0000000..a38be07
--- /dev/null
+++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs
@@ -0,0 +1,126 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.CodeDom.Compiler;
30using System.Collections.Generic;
31using libTerrain;
32using Microsoft.CSharp;
33using Microsoft.JScript;
34
35namespace OpenSim.Region.Terrain
36{
37 public interface ITerrainFilter
38 {
39 void Filter(Channel heightmap, string[] args);
40 string Register();
41 string Help();
42 }
43
44 public class TestFilter : ITerrainFilter
45 {
46 public void Filter(Channel heightmap, string[] args)
47 {
48 Console.WriteLine("Hello world");
49 }
50
51 public string Register()
52 {
53 return "demofilter";
54 }
55
56 public string Help()
57 {
58 return "demofilter - Does nothing";
59 }
60 }
61
62 public class FilterHost
63 {
64 public Dictionary<string, ITerrainFilter> filters = new Dictionary<string, ITerrainFilter>();
65
66 private void LoadFilter(CodeDomProvider compiler, string filename)
67 {
68 CompilerParameters compilerParams = new CompilerParameters();
69 CompilerResults compilerResults;
70 compilerParams.GenerateExecutable = false;
71 compilerParams.GenerateInMemory = true;
72 compilerParams.IncludeDebugInformation = false;
73 compilerParams.ReferencedAssemblies.Add("libTerrain-BSD.dll");
74 compilerParams.ReferencedAssemblies.Add("OpenSim.Terrain.BasicTerrain.dll");
75 compilerParams.ReferencedAssemblies.Add("System.dll");
76
77 compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
78
79 if (compilerResults.Errors.Count > 0)
80 {
81 Console.WriteLine("Compile errors:");
82 foreach (CompilerError error in compilerResults.Errors)
83 {
84 Console.WriteLine(error.Line.ToString() + ": " + error.ErrorText.ToString());
85 }
86 }
87 else
88 {
89 foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
90 {
91 Type testInterface = pluginType.GetInterface("ITerrainFilter",true);
92
93 if (testInterface != null)
94 {
95 ITerrainFilter filter = (ITerrainFilter)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
96
97 string filterName = filter.Register();
98 Console.WriteLine("Plugin: " + filterName + " loaded.");
99
100 if (!filters.ContainsKey(filterName))
101 {
102 filters.Add(filterName, filter);
103 }
104 else
105 {
106 filters[filterName] = filter;
107 }
108 }
109 }
110 }
111
112 }
113
114 public void LoadFilterCSharp(string filename)
115 {
116 CSharpCodeProvider compiler = new CSharpCodeProvider();
117 LoadFilter(compiler, filename);
118 }
119
120 public void LoadFilterJScript(string filename)
121 {
122 JScriptCodeProvider compiler = new JScriptCodeProvider();
123 LoadFilter(compiler, filename);
124 }
125 }
126}