From 7daa3955bc3a1918e40962851f9e8d38597a245e Mon Sep 17 00:00:00 2001 From: gareth Date: Thu, 22 Mar 2007 10:11:15 +0000 Subject: [PATCH] brought zircon branch into trunk --- OGS.sql | 134 --- ogs/OGS-UserServer.sln => OGS/OGS.sln | 16 +- .../ServerConsole/Properties/AssemblyInfo.cs | 0 {ogs => OGS}/ServerConsole/ServerConsole.cs | 0 .../ServerConsole/ServerConsole.csproj | 9 - {ogs => OGS}/ServerConsole/default.build | 0 .../common/VersionInfo/VersionInfo.cs | 0 OGS/common/bin/ServerConsole.dll | Bin 0 -> 16384 bytes OGS/common/bin/ServerConsole.pdb | Bin 0 -> 11776 bytes {ogs => OGS}/common/bin/libsecondlife.dll | Bin {ogs => OGS}/common/src/OGS-Console.cs | 0 .../common/src/VersionInfo.cs.template | 0 {ogs => OGS}/gridserver/default.build | 0 {ogs => OGS}/gridserver/src/ConsoleCmds.cs | 0 {ogs => OGS}/gridserver/src/GridHttp.cs | 3 +- {ogs => OGS}/gridserver/src/Main.cs | 0 .../gridserver/src/OGS-GridServer.csproj | 14 +- .../gridserver/src/Properties/AssemblyInfo.cs | 0 {ogs => OGS}/gridserver/src/SimProfiles.cs | 21 +- {ogs => OGS}/userserver/src/ConsoleCmds.cs | 0 {ogs => OGS}/userserver/src/Main.cs | 10 +- .../userserver/src/OGS-UserServer.csproj | 13 +- .../userserver/src/OGS-UserServer.csproj.user | 8 - .../userserver/src/Properties/AssemblyInfo.cs | 0 OGS/userserver/src/UserHttp.cs | 146 +++ OpenSim.Config/SimConfigDb4o/AssemblyInfo.cs | 31 + OpenSim.Config/SimConfigDb4o/DbSimConfig.cs | 176 ++++ OpenSim.Config/SimConfigDb4o/MapStorage.cs | 16 + .../OpenSim.Config.SimConfigDb4o.csproj | 107 ++ .../OpenSim.Config.SimConfigDb4o.dll.build | 47 + OpenSim.Framework.Console/AssemblyInfo.cs | 31 + OpenSim.Framework.Console/ConsoleBase.cs | 45 + .../MainConsole.cs | 29 +- .../OpenSim.Framework.Console.csproj | 85 ++ .../OpenSim.Framework.Console.dll.build | 41 + OpenSim.Framework/AgentCiruitData.cs | 18 + OpenSim.Framework/AssetBase.cs | 22 + OpenSim.Framework/BlockingQueue.cs | 33 + .../HeightMapGenHills.cs | 2 +- .../IAssetServer.cs | 80 +- src/Config.cs => OpenSim.Framework/IConfig.cs | 83 +- OpenSim.Framework/IGridServer.cs | 78 ++ .../ILocalStorage.cs | 73 +- OpenSim.Framework/IUserServer.cs | 14 + OpenSim.Framework/Inventory.cs | 127 +++ OpenSim.Framework/LocalGridBase.cs | 21 + OpenSim.Framework/Login.cs | 22 + .../LoginService.cs | 5 +- OpenSim.Framework/NeighbourInfo.cs | 19 + OpenSim.Framework/OpenSim.Framework.csproj | 151 +++ OpenSim.Framework/OpenSim.Framework.dll.build | 63 ++ OpenSim.Framework/PrimData.cs | 45 + .../Properties/AssemblyInfo.cs | 10 +- OpenSim.Framework/RemoteGridBase.cs | 25 + OpenSim.Framework/SimProfile.cs | 51 + OpenSim.Framework/SimProfileBase.cs | 25 + OpenSim.Framework/UserProfile.cs | 50 + OpenSim.Framework/UserProfileManager.cs | 223 +++++ OpenSim.Framework/UserProfileManagerBase.cs | 91 ++ OpenSim.Framework/Util.cs | 32 + OpenSim.GridInterfaces/Local/AssemblyInfo.cs | 31 + .../Local/LocalAssetServer.cs | 208 ++++ .../Local/LocalGridServer.cs | 135 +-- .../Local/OpenSim.GridInterfaces.Local.csproj | 104 ++ .../OpenSim.GridInterfaces.Local.dll.build | 46 + OpenSim.GridInterfaces/Remote/AssemblyInfo.cs | 31 + .../OpenSim.GridInterfaces.Remote.csproj | 101 ++ .../OpenSim.GridInterfaces.Remote.dll.build | 45 + .../Remote/RemoteAssetServer.cs | 102 ++ .../Remote/RemoteGridServer.cs | 156 +++ .../BasicPhysicsPlugin/AssemblyInfo.cs | 31 + .../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 52 +- .../OpenSim.Physics.BasicPhysicsPlugin.csproj | 90 ++ ...Sim.Physics.BasicPhysicsPlugin.csproj.user | 12 + ...enSim.Physics.BasicPhysicsPlugin.dll.build | 42 + OpenSim.Physics/Manager/AssemblyInfo.cs | 31 + .../Manager/OpenSim.Physics.Manager.csproj | 102 ++ .../Manager/OpenSim.Physics.Manager.dll.build | 46 + OpenSim.Physics/Manager/PhysicsActor.cs | 161 +++ OpenSim.Physics/Manager/PhysicsManager.cs | 116 +++ OpenSim.Physics/Manager/PhysicsScene.cs | 98 ++ OpenSim.Physics/Manager/PhysicsVector.cs | 54 + .../PhysXPlugin}/AssemblyInfo.cs | 0 .../OpenSim.Physics.PhysXPlugin.csproj | 93 ++ .../OpenSim.Physics.PhysXPlugin.dll.build | 43 + .../PhysXPlugin/PhysXPlugin.cs | 69 +- OpenSim.RegionServer/Assets/AssetCache.cs | 589 +++++++++++ OpenSim.RegionServer/Assets/InventoryCache.cs | 199 ++++ OpenSim.RegionServer/CAPS/SimHttp.cs | 175 ++++ OpenSim.RegionServer/Grid.cs | 89 ++ .../OpenSim.RegionServer.csproj | 169 ++++ .../OpenSim.RegionServer.exe.build | 67 ++ OpenSim.RegionServer/OpenSimApplication.cs | 16 + OpenSim.RegionServer/OpenSimMain.cs | 320 ++++++ OpenSim.RegionServer/OpenSimRoot.cs | 63 ++ OpenSim.RegionServer/QueItem.cs | 18 + OpenSim.RegionServer/SimClient.cs | 621 ++++++++++++ .../SimConsole.cs | 22 +- .../UserServer/LocalUserProfileManager.cs | 76 ++ .../UserServer/LoginServer.cs | 414 ++++++++ {src => OpenSim.RegionServer}/VersionInfo.cs | 12 +- {src => OpenSim.RegionServer}/types/Mesh.cs | 0 .../types/Triangle.cs | 0 OpenSim.RegionServer/world/Avatar.cs | 501 ++++++++++ {src => OpenSim.RegionServer}/world/Entity.cs | 2 +- OpenSim.RegionServer/world/Primitive.cs | 485 +++++++++ .../world/ScriptEngine.cs | 0 .../world/SurfacePatch.cs | 0 {src => OpenSim.RegionServer}/world/World.cs | 47 +- .../world/scripting/IScript.cs | 0 .../LocalStorageDb4o/AssemblyInfo.cs | 31 + .../LocalStorageDb4o}/Db4LocalStorage.cs | 29 +- .../OpenSim.Storage.LocalStorageDb4o.csproj | 104 ++ ...OpenSim.Storage.LocalStorageDb4o.dll.build | 46 + OpenSim.Storage/LocalStorageDb4o/UUIDQuery.cs | 25 + OpenSim.build | 94 ++ OpenSim.sln | 89 ++ Prebuild/Prebuild.build | 67 ++ Prebuild/Prebuild.sln | 25 + Prebuild/README | 230 +++++ Prebuild/TODO | 21 + Prebuild/doc/prebuild-example1.xml | 300 ++++++ Prebuild/doc/prebuild-example2.xml | 72 ++ Prebuild/doc/prebuild-example3.xml | 113 +++ Prebuild/doc/prebuild-example4.xml | 715 ++++++++++++++ Prebuild/doc/prebuild-example5.xml | 187 ++++ Prebuild/prebuild | 2 + Prebuild/prebuild.xml | 57 ++ Prebuild/scripts/Clean.bat | 2 + Prebuild/scripts/Help.bat | 2 + Prebuild/scripts/MonoDevelop.sh | 2 + Prebuild/scripts/Prebuild.nsi | 231 +++++ Prebuild/scripts/SharpDevelop.bat | 4 + Prebuild/scripts/SharpDevelop2.bat | 4 + Prebuild/scripts/VS2002.bat | 4 + Prebuild/scripts/VS2003.bat | 4 + Prebuild/scripts/VS2005.bat | 4 + Prebuild/scripts/autotools.bat | 4 + Prebuild/scripts/autotools.sh | 2 + Prebuild/scripts/nant.bat | 4 + Prebuild/scripts/nant.sh | 2 + Prebuild/src/App.ico | Bin 0 -> 4286 bytes .../src/Core/Attributes/DataNodeAttribute.cs | 81 ++ .../Core/Attributes/OptionNodeAttribute.cs | 80 ++ .../src/Core/Attributes/TargetAttribute.cs | 80 ++ Prebuild/src/Core/FatalException.cs | 94 ++ Prebuild/src/Core/Interfaces/IDataNode.cs | 56 ++ Prebuild/src/Core/Interfaces/ITarget.cs | 60 ++ Prebuild/src/Core/Kernel.cs | 758 ++++++++++++++ Prebuild/src/Core/Nodes/ConfigurationNode.cs | 177 ++++ Prebuild/src/Core/Nodes/DataNode.cs | 82 ++ Prebuild/src/Core/Nodes/ExcludeNode.cs | 85 ++ Prebuild/src/Core/Nodes/FileNode.cs | 238 +++++ Prebuild/src/Core/Nodes/FilesNode.cs | 222 +++++ Prebuild/src/Core/Nodes/MatchNode.cs | 299 ++++++ Prebuild/src/Core/Nodes/OptionsNode.cs | 655 +++++++++++++ Prebuild/src/Core/Nodes/ProcessNode.cs | 119 +++ Prebuild/src/Core/Nodes/ProjectNode.cs | 490 +++++++++ Prebuild/src/Core/Nodes/ReferenceNode.cs | 143 +++ Prebuild/src/Core/Nodes/ReferencePathNode.cs | 98 ++ Prebuild/src/Core/Nodes/SolutionNode.cs | 284 ++++++ Prebuild/src/Core/Parse/IfContext.cs | 163 +++ Prebuild/src/Core/Parse/Preprocessor.cs | 519 ++++++++++ Prebuild/src/Core/Targets/AutotoolsTarget.cs | 926 ++++++++++++++++++ Prebuild/src/Core/Targets/DebugTarget.cs | 102 ++ .../src/Core/Targets/MonoDevelopTarget.cs | 458 +++++++++ Prebuild/src/Core/Targets/NAntTarget.cs | 621 ++++++++++++ .../src/Core/Targets/SharpDevelop2Target.cs | 90 ++ .../src/Core/Targets/SharpDevelopTarget.cs | 437 +++++++++ Prebuild/src/Core/Targets/VS2002Target.cs | 96 ++ Prebuild/src/Core/Targets/VS2003Target.cs | 633 ++++++++++++ Prebuild/src/Core/Targets/VS2005Target.cs | 869 ++++++++++++++++ Prebuild/src/Core/UnknownLanguageException.cs | 63 ++ .../Core/Utilities/CommandLineCollection.cs | 162 +++ .../src/Core/Utilities/CurrentDirectory.cs | 89 ++ Prebuild/src/Core/Utilities/Helper.cs | 661 +++++++++++++ Prebuild/src/Core/Utilities/Log.cs | 279 ++++++ Prebuild/src/Core/WarningException.cs | 93 ++ Prebuild/src/Prebuild.cs | 165 ++++ Prebuild/src/Prebuild.csproj | 199 ++++ Prebuild/src/Prebuild.exe.build | 80 ++ Prebuild/src/Prebuild.snk | Bin 0 -> 596 bytes Prebuild/src/Properties/AssemblyInfo.cs | 101 ++ Prebuild/src/data/dnpb-1.0.xsd | 183 ++++ Prebuild/src/data/dnpb-1.1.xsd | 184 ++++ Prebuild/src/data/dnpb-1.2.xsd | 198 ++++ Prebuild/src/data/dnpb-1.3.xsd | 206 ++++ Prebuild/src/data/dnpb-1.4.xsd | 212 ++++ Prebuild/src/data/dnpb-1.5.xsd | 215 ++++ Prebuild/src/data/prebuild-1.6.xsd | 231 +++++ Prebuild/src/data/prebuild-1.7.xsd | 261 +++++ README.txt | 33 +- STATE_OF_PREBUILD.txt | 15 + VERSION | 1 - genvers.sh | 9 - .../00000000000000005005000000000005/data | Bin 291 -> 0 bytes .../00000000000000007007000000000006/data | Bin 153 -> 0 bytes .../00000000000000007009000000000008/data | Bin 570 -> 0 bytes .../66c41e3938f9f75a024e585989bfab73/data | 105 -- .../e0ee49b5a4184df8d3c9a65361fe7f49/data | 52 - ogs/common/src/Util.cs | 87 -- ogs/genvers.sh | 9 - ogs/ogs.build | 38 - ogs/userserver/default.build | 63 -- ogs/userserver/src/UserHttp.cs | 287 ------ ogs/userserver/src/UserProfiles.cs | 223 ----- ogs/userserver/src/Util.cs | 87 -- opensim.build | 82 -- prebuild.xml | 326 ++++++ src/AssemblyInfo.cs | 21 - src/Assets/AssetCache.cs | 436 --------- src/CAPS/SimHttp.cs | 165 ---- src/Config/SimConfig/AssemblyInfo.cs | 21 - src/Config/SimConfig/Db4SimConfig.cs | 177 ---- src/Config/SimConfig/SimConfig.csproj | 52 - src/Config/default.build | 53 - src/GridInterfaces/AssemblyInfo.cs | 21 - src/GridInterfaces/GridInterfaces.csproj | 40 - src/GridInterfaces/IGridServer.cs | 145 --- src/GridInterfaces/default.build | 50 - src/GridServers/LoginServer.cs | 350 ------- .../LocalGridServers/AssemblyInfo.cs | 21 - .../LocalGridServers/LocalGridServers.csproj | 48 - src/LocalServers/default.build | 51 - .../Db4LocalStorage/AssemblyInfo.cs | 21 - .../Db4LocalStorage/Db4LocalStorage.csproj | 52 - src/LocalStorage/default.build | 53 - src/Main.cs | 338 ------- src/OpenSim.Framework/AssemblyInfo.cs | 21 - .../OpenSim.Framework.csproj | 49 - .../Properties/AssemblyInfo.cs | 35 - src/OpenSim.Framework/default.build | 50 - src/OpenSimClient.cs | 471 --------- .../RemoteGridServers/AssemblyInfo.cs | 21 - .../RemoteGridServers/RemoteGrid.cs | 279 ------ .../RemoteGridServers.csproj | 48 - src/RemoteServers/default.build | 51 - src/Second-server.csproj | 110 --- .../ServerConsole/AssemblyInfo.cs | 21 - .../ServerConsole/ServerConsole.cs | 87 -- .../ServerConsole/ServerConsole.csproj | 34 - src/ServerConsole/default.build | 48 - src/Util.cs | 99 -- src/opensim.sln | 80 -- src/physics/AssemblyInfo.cs | 21 - src/physics/PhysicsManager.cs | 285 ------ src/physics/PhysicsManager.csproj | 40 - .../RealPhysXplugin/RealPhysXplugin.csproj | 46 - src/physics/default.build | 49 - src/physics/plugins/AssemblyInfo.cs | 21 - src/physics/plugins/BasicPhysicsplugin.csproj | 51 - src/physics/plugins/default.build | 51 - src/world/Avatar.cs | 487 --------- src/world/Primitive.cs | 429 -------- 254 files changed, 23148 insertions(+), 6670 deletions(-) delete mode 100644 OGS.sql rename ogs/OGS-UserServer.sln => OGS/OGS.sln (77%) rename {ogs => OGS}/ServerConsole/Properties/AssemblyInfo.cs (100%) rename {ogs => OGS}/ServerConsole/ServerConsole.cs (100%) rename {ogs => OGS}/ServerConsole/ServerConsole.csproj (82%) rename {ogs => OGS}/ServerConsole/default.build (100%) rename {ogs => OGS}/common/VersionInfo/VersionInfo.cs (100%) create mode 100644 OGS/common/bin/ServerConsole.dll create mode 100644 OGS/common/bin/ServerConsole.pdb rename {ogs => OGS}/common/bin/libsecondlife.dll (100%) mode change 100755 => 100644 rename {ogs => OGS}/common/src/OGS-Console.cs (100%) rename {ogs => OGS}/common/src/VersionInfo.cs.template (100%) rename {ogs => OGS}/gridserver/default.build (100%) rename {ogs => OGS}/gridserver/src/ConsoleCmds.cs (100%) rename {ogs => OGS}/gridserver/src/GridHttp.cs (95%) rename {ogs => OGS}/gridserver/src/Main.cs (100%) rename {ogs => OGS}/gridserver/src/OGS-GridServer.csproj (85%) rename {ogs => OGS}/gridserver/src/Properties/AssemblyInfo.cs (100%) rename {ogs => OGS}/gridserver/src/SimProfiles.cs (79%) rename {ogs => OGS}/userserver/src/ConsoleCmds.cs (100%) rename {ogs => OGS}/userserver/src/Main.cs (91%) rename {ogs => OGS}/userserver/src/OGS-UserServer.csproj (85%) rename {ogs => OGS}/userserver/src/OGS-UserServer.csproj.user (59%) rename {ogs => OGS}/userserver/src/Properties/AssemblyInfo.cs (100%) create mode 100644 OGS/userserver/src/UserHttp.cs create mode 100644 OpenSim.Config/SimConfigDb4o/AssemblyInfo.cs create mode 100644 OpenSim.Config/SimConfigDb4o/DbSimConfig.cs create mode 100644 OpenSim.Config/SimConfigDb4o/MapStorage.cs create mode 100644 OpenSim.Config/SimConfigDb4o/OpenSim.Config.SimConfigDb4o.csproj create mode 100644 OpenSim.Config/SimConfigDb4o/OpenSim.Config.SimConfigDb4o.dll.build create mode 100644 OpenSim.Framework.Console/AssemblyInfo.cs create mode 100644 OpenSim.Framework.Console/ConsoleBase.cs rename src/VersionInfo.cs.template => OpenSim.Framework.Console/MainConsole.cs (80%) create mode 100644 OpenSim.Framework.Console/OpenSim.Framework.Console.csproj create mode 100644 OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build create mode 100644 OpenSim.Framework/AgentCiruitData.cs create mode 100644 OpenSim.Framework/AssetBase.cs create mode 100644 OpenSim.Framework/BlockingQueue.cs rename {src => OpenSim.Framework}/HeightMapGenHills.cs (96%) rename {src/GridInterfaces => OpenSim.Framework}/IAssetServer.cs (63%) rename src/Config.cs => OpenSim.Framework/IConfig.cs (55%) create mode 100644 OpenSim.Framework/IGridServer.cs rename {src/GridInterfaces => OpenSim.Framework}/ILocalStorage.cs (54%) create mode 100644 OpenSim.Framework/IUserServer.cs create mode 100644 OpenSim.Framework/Inventory.cs create mode 100644 OpenSim.Framework/LocalGridBase.cs create mode 100644 OpenSim.Framework/Login.cs rename {src/OpenSim.Framework => OpenSim.Framework}/LoginService.cs (72%) create mode 100644 OpenSim.Framework/NeighbourInfo.cs create mode 100644 OpenSim.Framework/OpenSim.Framework.csproj create mode 100644 OpenSim.Framework/OpenSim.Framework.dll.build create mode 100644 OpenSim.Framework/PrimData.cs rename {src => OpenSim.Framework}/Properties/AssemblyInfo.cs (78%) create mode 100644 OpenSim.Framework/RemoteGridBase.cs create mode 100644 OpenSim.Framework/SimProfile.cs create mode 100644 OpenSim.Framework/SimProfileBase.cs create mode 100644 OpenSim.Framework/UserProfile.cs create mode 100644 OpenSim.Framework/UserProfileManager.cs create mode 100644 OpenSim.Framework/UserProfileManagerBase.cs create mode 100644 OpenSim.Framework/Util.cs create mode 100644 OpenSim.GridInterfaces/Local/AssemblyInfo.cs create mode 100644 OpenSim.GridInterfaces/Local/LocalAssetServer.cs rename src/LocalServers/LocalGridServers/LocalGrid.cs => OpenSim.GridInterfaces/Local/LocalGridServer.cs (59%) create mode 100644 OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj create mode 100644 OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.dll.build create mode 100644 OpenSim.GridInterfaces/Remote/AssemblyInfo.cs create mode 100644 OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj create mode 100644 OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.dll.build create mode 100644 OpenSim.GridInterfaces/Remote/RemoteAssetServer.cs create mode 100644 OpenSim.GridInterfaces/Remote/RemoteGridServer.cs create mode 100644 OpenSim.Physics/BasicPhysicsPlugin/AssemblyInfo.cs rename src/physics/plugins/PhysXplugin.cs => OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs (81%) create mode 100644 OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj create mode 100644 OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj.user create mode 100644 OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.dll.build create mode 100644 OpenSim.Physics/Manager/AssemblyInfo.cs create mode 100644 OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj create mode 100644 OpenSim.Physics/Manager/OpenSim.Physics.Manager.dll.build create mode 100644 OpenSim.Physics/Manager/PhysicsActor.cs create mode 100644 OpenSim.Physics/Manager/PhysicsManager.cs create mode 100644 OpenSim.Physics/Manager/PhysicsScene.cs create mode 100644 OpenSim.Physics/Manager/PhysicsVector.cs rename {src/physics/RealPhysX/RealPhysXplugin => OpenSim.Physics/PhysXPlugin}/AssemblyInfo.cs (100%) create mode 100644 OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj create mode 100644 OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.dll.build rename src/physics/RealPhysX/RealPhysXplugin/RealPhysX.cs => OpenSim.Physics/PhysXPlugin/PhysXPlugin.cs (84%) create mode 100644 OpenSim.RegionServer/Assets/AssetCache.cs create mode 100644 OpenSim.RegionServer/Assets/InventoryCache.cs create mode 100644 OpenSim.RegionServer/CAPS/SimHttp.cs create mode 100644 OpenSim.RegionServer/Grid.cs create mode 100644 OpenSim.RegionServer/OpenSim.RegionServer.csproj create mode 100644 OpenSim.RegionServer/OpenSim.RegionServer.exe.build create mode 100644 OpenSim.RegionServer/OpenSimApplication.cs create mode 100644 OpenSim.RegionServer/OpenSimMain.cs create mode 100644 OpenSim.RegionServer/OpenSimRoot.cs create mode 100644 OpenSim.RegionServer/QueItem.cs create mode 100644 OpenSim.RegionServer/SimClient.cs rename src/OpenSimConsole.cs => OpenSim.RegionServer/SimConsole.cs (86%) create mode 100644 OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs create mode 100644 OpenSim.RegionServer/UserServer/LoginServer.cs rename {src => OpenSim.RegionServer}/VersionInfo.cs (88%) rename {src => OpenSim.RegionServer}/types/Mesh.cs (100%) rename {src => OpenSim.RegionServer}/types/Triangle.cs (100%) create mode 100644 OpenSim.RegionServer/world/Avatar.cs rename {src => OpenSim.RegionServer}/world/Entity.cs (90%) create mode 100644 OpenSim.RegionServer/world/Primitive.cs rename {src => OpenSim.RegionServer}/world/ScriptEngine.cs (100%) rename {src => OpenSim.RegionServer}/world/SurfacePatch.cs (100%) rename {src => OpenSim.RegionServer}/world/World.cs (69%) rename {src => OpenSim.RegionServer}/world/scripting/IScript.cs (100%) create mode 100644 OpenSim.Storage/LocalStorageDb4o/AssemblyInfo.cs rename {src/LocalStorage/Db4LocalStorage => OpenSim.Storage/LocalStorageDb4o}/Db4LocalStorage.cs (82%) create mode 100644 OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj create mode 100644 OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.dll.build create mode 100644 OpenSim.Storage/LocalStorageDb4o/UUIDQuery.cs create mode 100644 OpenSim.build create mode 100644 OpenSim.sln create mode 100644 Prebuild/Prebuild.build create mode 100644 Prebuild/Prebuild.sln create mode 100644 Prebuild/README create mode 100644 Prebuild/TODO create mode 100644 Prebuild/doc/prebuild-example1.xml create mode 100644 Prebuild/doc/prebuild-example2.xml create mode 100644 Prebuild/doc/prebuild-example3.xml create mode 100644 Prebuild/doc/prebuild-example4.xml create mode 100644 Prebuild/doc/prebuild-example5.xml create mode 100644 Prebuild/prebuild create mode 100644 Prebuild/prebuild.xml create mode 100644 Prebuild/scripts/Clean.bat create mode 100644 Prebuild/scripts/Help.bat create mode 100644 Prebuild/scripts/MonoDevelop.sh create mode 100644 Prebuild/scripts/Prebuild.nsi create mode 100644 Prebuild/scripts/SharpDevelop.bat create mode 100644 Prebuild/scripts/SharpDevelop2.bat create mode 100644 Prebuild/scripts/VS2002.bat create mode 100644 Prebuild/scripts/VS2003.bat create mode 100644 Prebuild/scripts/VS2005.bat create mode 100644 Prebuild/scripts/autotools.bat create mode 100644 Prebuild/scripts/autotools.sh create mode 100644 Prebuild/scripts/nant.bat create mode 100644 Prebuild/scripts/nant.sh create mode 100644 Prebuild/src/App.ico create mode 100644 Prebuild/src/Core/Attributes/DataNodeAttribute.cs create mode 100644 Prebuild/src/Core/Attributes/OptionNodeAttribute.cs create mode 100644 Prebuild/src/Core/Attributes/TargetAttribute.cs create mode 100644 Prebuild/src/Core/FatalException.cs create mode 100644 Prebuild/src/Core/Interfaces/IDataNode.cs create mode 100644 Prebuild/src/Core/Interfaces/ITarget.cs create mode 100644 Prebuild/src/Core/Kernel.cs create mode 100644 Prebuild/src/Core/Nodes/ConfigurationNode.cs create mode 100644 Prebuild/src/Core/Nodes/DataNode.cs create mode 100644 Prebuild/src/Core/Nodes/ExcludeNode.cs create mode 100644 Prebuild/src/Core/Nodes/FileNode.cs create mode 100644 Prebuild/src/Core/Nodes/FilesNode.cs create mode 100644 Prebuild/src/Core/Nodes/MatchNode.cs create mode 100644 Prebuild/src/Core/Nodes/OptionsNode.cs create mode 100644 Prebuild/src/Core/Nodes/ProcessNode.cs create mode 100644 Prebuild/src/Core/Nodes/ProjectNode.cs create mode 100644 Prebuild/src/Core/Nodes/ReferenceNode.cs create mode 100644 Prebuild/src/Core/Nodes/ReferencePathNode.cs create mode 100644 Prebuild/src/Core/Nodes/SolutionNode.cs create mode 100644 Prebuild/src/Core/Parse/IfContext.cs create mode 100644 Prebuild/src/Core/Parse/Preprocessor.cs create mode 100644 Prebuild/src/Core/Targets/AutotoolsTarget.cs create mode 100644 Prebuild/src/Core/Targets/DebugTarget.cs create mode 100644 Prebuild/src/Core/Targets/MonoDevelopTarget.cs create mode 100644 Prebuild/src/Core/Targets/NAntTarget.cs create mode 100644 Prebuild/src/Core/Targets/SharpDevelop2Target.cs create mode 100644 Prebuild/src/Core/Targets/SharpDevelopTarget.cs create mode 100644 Prebuild/src/Core/Targets/VS2002Target.cs create mode 100644 Prebuild/src/Core/Targets/VS2003Target.cs create mode 100644 Prebuild/src/Core/Targets/VS2005Target.cs create mode 100644 Prebuild/src/Core/UnknownLanguageException.cs create mode 100644 Prebuild/src/Core/Utilities/CommandLineCollection.cs create mode 100644 Prebuild/src/Core/Utilities/CurrentDirectory.cs create mode 100644 Prebuild/src/Core/Utilities/Helper.cs create mode 100644 Prebuild/src/Core/Utilities/Log.cs create mode 100644 Prebuild/src/Core/WarningException.cs create mode 100644 Prebuild/src/Prebuild.cs create mode 100644 Prebuild/src/Prebuild.csproj create mode 100644 Prebuild/src/Prebuild.exe.build create mode 100644 Prebuild/src/Prebuild.snk create mode 100644 Prebuild/src/Properties/AssemblyInfo.cs create mode 100644 Prebuild/src/data/dnpb-1.0.xsd create mode 100644 Prebuild/src/data/dnpb-1.1.xsd create mode 100644 Prebuild/src/data/dnpb-1.2.xsd create mode 100644 Prebuild/src/data/dnpb-1.3.xsd create mode 100644 Prebuild/src/data/dnpb-1.4.xsd create mode 100644 Prebuild/src/data/dnpb-1.5.xsd create mode 100644 Prebuild/src/data/prebuild-1.6.xsd create mode 100644 Prebuild/src/data/prebuild-1.7.xsd create mode 100644 STATE_OF_PREBUILD.txt delete mode 100644 VERSION delete mode 100755 genvers.sh delete mode 100644 ogs/assetserver/assets/00000000000000005005000000000005/data delete mode 100644 ogs/assetserver/assets/00000000000000007007000000000006/data delete mode 100644 ogs/assetserver/assets/00000000000000007009000000000008/data delete mode 100644 ogs/assetserver/assets/66c41e3938f9f75a024e585989bfab73/data delete mode 100644 ogs/assetserver/assets/e0ee49b5a4184df8d3c9a65361fe7f49/data delete mode 100644 ogs/common/src/Util.cs delete mode 100644 ogs/genvers.sh delete mode 100644 ogs/ogs.build delete mode 100644 ogs/userserver/default.build delete mode 100644 ogs/userserver/src/UserHttp.cs delete mode 100644 ogs/userserver/src/UserProfiles.cs delete mode 100644 ogs/userserver/src/Util.cs delete mode 100644 opensim.build create mode 100644 prebuild.xml delete mode 100644 src/AssemblyInfo.cs delete mode 100644 src/Assets/AssetCache.cs delete mode 100644 src/CAPS/SimHttp.cs delete mode 100644 src/Config/SimConfig/AssemblyInfo.cs delete mode 100644 src/Config/SimConfig/Db4SimConfig.cs delete mode 100644 src/Config/SimConfig/SimConfig.csproj delete mode 100644 src/Config/default.build delete mode 100644 src/GridInterfaces/AssemblyInfo.cs delete mode 100644 src/GridInterfaces/GridInterfaces.csproj delete mode 100644 src/GridInterfaces/IGridServer.cs delete mode 100644 src/GridInterfaces/default.build delete mode 100644 src/GridServers/LoginServer.cs delete mode 100644 src/LocalServers/LocalGridServers/AssemblyInfo.cs delete mode 100644 src/LocalServers/LocalGridServers/LocalGridServers.csproj delete mode 100644 src/LocalServers/default.build delete mode 100644 src/LocalStorage/Db4LocalStorage/AssemblyInfo.cs delete mode 100644 src/LocalStorage/Db4LocalStorage/Db4LocalStorage.csproj delete mode 100644 src/LocalStorage/default.build delete mode 100644 src/Main.cs delete mode 100644 src/OpenSim.Framework/AssemblyInfo.cs delete mode 100644 src/OpenSim.Framework/OpenSim.Framework.csproj delete mode 100644 src/OpenSim.Framework/Properties/AssemblyInfo.cs delete mode 100644 src/OpenSim.Framework/default.build delete mode 100644 src/OpenSimClient.cs delete mode 100644 src/RemoteServers/RemoteGridServers/AssemblyInfo.cs delete mode 100644 src/RemoteServers/RemoteGridServers/RemoteGrid.cs delete mode 100644 src/RemoteServers/RemoteGridServers/RemoteGridServers.csproj delete mode 100644 src/RemoteServers/default.build delete mode 100644 src/Second-server.csproj delete mode 100644 src/ServerConsole/ServerConsole/AssemblyInfo.cs delete mode 100644 src/ServerConsole/ServerConsole/ServerConsole.cs delete mode 100644 src/ServerConsole/ServerConsole/ServerConsole.csproj delete mode 100644 src/ServerConsole/default.build delete mode 100644 src/Util.cs delete mode 100644 src/opensim.sln delete mode 100644 src/physics/AssemblyInfo.cs delete mode 100644 src/physics/PhysicsManager.cs delete mode 100644 src/physics/PhysicsManager.csproj delete mode 100644 src/physics/RealPhysX/RealPhysXplugin/RealPhysXplugin.csproj delete mode 100644 src/physics/default.build delete mode 100644 src/physics/plugins/AssemblyInfo.cs delete mode 100644 src/physics/plugins/BasicPhysicsplugin.csproj delete mode 100644 src/physics/plugins/default.build delete mode 100644 src/world/Avatar.cs delete mode 100644 src/world/Primitive.cs diff --git a/OGS.sql b/OGS.sql deleted file mode 100644 index 5efaf97ef4..0000000000 --- a/OGS.sql +++ /dev/null @@ -1,134 +0,0 @@ --- phpMyAdmin SQL Dump --- version 2.6.3-pl1 --- http://www.phpmyadmin.net --- --- Host: 127.0.0.1 --- Generation Time: Feb 16, 2007 at 09:54 PM --- Server version: 4.0.23 --- PHP Version: 4.4.0 --- --- Database: `OGS` --- - --- -------------------------------------------------------- - --- --- Table structure for table `Grid_settings` --- - -DROP TABLE IF EXISTS `Grid_settings`; -CREATE TABLE IF NOT EXISTS `Grid_settings` ( - `Setting` text NOT NULL, - `value` text NOT NULL -) TYPE=MyISAM; - --- --- Dumping data for table `Grid_settings` --- - -INSERT INTO `Grid_settings` (`Setting`, `value`) VALUES ('highest_LLUUID', '51AEFF430000000000000000000002fd'); - --- -------------------------------------------------------- - --- --- Table structure for table `foreign_profiles` --- - -DROP TABLE IF EXISTS `foreign_profiles`; -CREATE TABLE IF NOT EXISTS `foreign_profiles` ( - `userprofile_LLUUID` varchar(32) NOT NULL default '', - `foreigngrid` text NOT NULL, - `profile_firstname` text NOT NULL, - `profile_lastname` text NOT NULL, - `profile_passwdmd5` text NOT NULL, - `homesim_ip` text NOT NULL, - `homesim_port` int(11) NOT NULL default '0', - `homeasset_url` text NOT NULL, - `homeuser_url` text NOT NULL, - `look_at` text NOT NULL, - `region_handle` text NOT NULL, - `position` text NOT NULL, - PRIMARY KEY (`userprofile_LLUUID`) -) TYPE=MyISAM; - --- --- Dumping data for table `foreign_profiles` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `local_user_profiles` --- - -DROP TABLE IF EXISTS `local_user_profiles`; -CREATE TABLE IF NOT EXISTS `local_user_profiles` ( - `userprofile_LLUUID` varchar(32) NOT NULL default '', - `profile_firstname` text NOT NULL, - `profile_lastname` text NOT NULL, - `profile_passwdmd5` text NOT NULL, - `homesim_ip` text NOT NULL, - `homesim_port` int(11) NOT NULL default '0', - `homeasset_url` text NOT NULL, - `look_at` text NOT NULL, - `region_handle` text NOT NULL, - `position` text NOT NULL, - PRIMARY KEY (`userprofile_LLUUID`) -) TYPE=MyISAM; - --- --- Dumping data for table `local_user_profiles` --- - -INSERT INTO `local_user_profiles` (`userprofile_LLUUID`, `profile_firstname`, `profile_lastname`, `profile_passwdmd5`, `homesim_ip`, `homesim_port`, `homeasset_url`, `look_at`, `region_handle`, `position`) VALUES ('51AEFF43000000000000000000000100', 'Test', 'User', '$1$098f6bcd4621d373cade4e832627b4f6', '127.0.0.1', 1000, 'http://dummyassetserver.net/', 'r-0.57343, r-0.819255,r0', 'r255232,254976', 'r41.6589, r100.8374, r22.5072'); - --- -------------------------------------------------------- - --- --- Table structure for table `region_profiles` --- - -DROP TABLE IF EXISTS `region_profiles`; -CREATE TABLE IF NOT EXISTS `region_profiles` ( - `RegionID` varchar(32) NOT NULL default '', - `Name` text NOT NULL, - `GridLocX` bigint(20) NOT NULL default '0', - `GridLocY` bigint(20) NOT NULL default '0', - `region_handle` text NOT NULL, - `ip_addr` text NOT NULL, - `port` text NOT NULL, - PRIMARY KEY (`RegionID`) -) TYPE=MyISAM; - --- --- Dumping data for table `region_profiles` --- - -INSERT INTO `region_profiles` (`RegionID`, `Name`, `GridLocX`, `GridLocY`, `region_handle`, `ip_addr`, `port`) VALUES ('51AEFF43000000000000000000000200', 'Test sandbox', 997, 996, 'r255232,254976', '127.0.0.1', '1000'); - --- -------------------------------------------------------- - --- --- Table structure for table `sessions` --- - -DROP TABLE IF EXISTS `sessions`; -CREATE TABLE IF NOT EXISTS `sessions` ( - `session_id` varchar(32) NOT NULL default '', - `secure_session_id` text NOT NULL, - `agent_id` text NOT NULL, - `session_start` datetime NOT NULL default '0000-00-00 00:00:00', - `session_end` datetime NOT NULL default '0000-00-00 00:00:00', - `session_active` tinyint(4) NOT NULL default '0', - `current_location` text NOT NULL, - `remote_ip` text NOT NULL, - `circuit_code` int(11) NOT NULL default '0', - PRIMARY KEY (`session_id`) -) TYPE=MyISAM; - --- --- Dumping data for table `sessions` --- - -INSERT INTO `sessions` (`session_id`, `secure_session_id`, `agent_id`, `session_start`, `session_end`, `session_active`, `current_location`, `remote_ip`, `circuit_code`) VALUES ('51AEFF430000000000000000000002fc', '51AEFF430000000000000000000002fd', '51AEFF43000000000000000000000100', '2007-02-16 21:13:19', '0000-00-00 00:00:00', 1, 'r255232,254976', '81.174.255.70', 0); diff --git a/ogs/OGS-UserServer.sln b/OGS/OGS.sln similarity index 77% rename from ogs/OGS-UserServer.sln rename to OGS/OGS.sln index 6c98af1115..20eb03a786 100644 --- a/ogs/OGS-UserServer.sln +++ b/OGS/OGS.sln @@ -3,9 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 9.00 # Visual C# Express 2005 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OGS-UserServer", "userserver\src\OGS-UserServer.csproj", "{D45B6E48-5668-478D-B9CB-6D46E665FACF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OGS-GridServer", "gridserver\src\OGS-GridServer.csproj", "{FE50A574-C8ED-433B-95F0-213A5EED2AB2}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerConsole", "ServerConsole\ServerConsole.csproj", "{7667E6E2-F227-41A2-B1B2-315613E1BAFC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OGS-GridServer", "gridserver\src\OGS-GridServer.csproj", "{FE50A574-C8ED-433B-95F0-213A5EED2AB2}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Framework", "..\OpenSim.FrameWork\OpenSim.Framework.csproj", "{2E46A825-3168-492F-93BC-637126B5B72B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -17,14 +19,18 @@ Global {D45B6E48-5668-478D-B9CB-6D46E665FACF}.Debug|Any CPU.Build.0 = Debug|Any CPU {D45B6E48-5668-478D-B9CB-6D46E665FACF}.Release|Any CPU.ActiveCfg = Release|Any CPU {D45B6E48-5668-478D-B9CB-6D46E665FACF}.Release|Any CPU.Build.0 = Release|Any CPU - {7667E6E2-F227-41A2-B1B2-315613E1BAFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7667E6E2-F227-41A2-B1B2-315613E1BAFC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7667E6E2-F227-41A2-B1B2-315613E1BAFC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7667E6E2-F227-41A2-B1B2-315613E1BAFC}.Release|Any CPU.Build.0 = Release|Any CPU {FE50A574-C8ED-433B-95F0-213A5EED2AB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FE50A574-C8ED-433B-95F0-213A5EED2AB2}.Debug|Any CPU.Build.0 = Debug|Any CPU {FE50A574-C8ED-433B-95F0-213A5EED2AB2}.Release|Any CPU.ActiveCfg = Release|Any CPU {FE50A574-C8ED-433B-95F0-213A5EED2AB2}.Release|Any CPU.Build.0 = Release|Any CPU + {7667E6E2-F227-41A2-B1B2-315613E1BAFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7667E6E2-F227-41A2-B1B2-315613E1BAFC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7667E6E2-F227-41A2-B1B2-315613E1BAFC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7667E6E2-F227-41A2-B1B2-315613E1BAFC}.Release|Any CPU.Build.0 = Release|Any CPU + {2E46A825-3168-492F-93BC-637126B5B72B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2E46A825-3168-492F-93BC-637126B5B72B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2E46A825-3168-492F-93BC-637126B5B72B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2E46A825-3168-492F-93BC-637126B5B72B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ogs/ServerConsole/Properties/AssemblyInfo.cs b/OGS/ServerConsole/Properties/AssemblyInfo.cs similarity index 100% rename from ogs/ServerConsole/Properties/AssemblyInfo.cs rename to OGS/ServerConsole/Properties/AssemblyInfo.cs diff --git a/ogs/ServerConsole/ServerConsole.cs b/OGS/ServerConsole/ServerConsole.cs similarity index 100% rename from ogs/ServerConsole/ServerConsole.cs rename to OGS/ServerConsole/ServerConsole.cs diff --git a/ogs/ServerConsole/ServerConsole.csproj b/OGS/ServerConsole/ServerConsole.csproj similarity index 82% rename from ogs/ServerConsole/ServerConsole.csproj rename to OGS/ServerConsole/ServerConsole.csproj index 7f3005e6a5..d23ca524e1 100644 --- a/ogs/ServerConsole/ServerConsole.csproj +++ b/OGS/ServerConsole/ServerConsole.csproj @@ -9,8 +9,6 @@ Properties ServerConsole ServerConsole - - true @@ -39,11 +37,4 @@ - \ No newline at end of file diff --git a/ogs/ServerConsole/default.build b/OGS/ServerConsole/default.build similarity index 100% rename from ogs/ServerConsole/default.build rename to OGS/ServerConsole/default.build diff --git a/ogs/common/VersionInfo/VersionInfo.cs b/OGS/common/VersionInfo/VersionInfo.cs similarity index 100% rename from ogs/common/VersionInfo/VersionInfo.cs rename to OGS/common/VersionInfo/VersionInfo.cs diff --git a/OGS/common/bin/ServerConsole.dll b/OGS/common/bin/ServerConsole.dll new file mode 100644 index 0000000000000000000000000000000000000000..842e0d0ee5a69eb58ee45a029ece10bdb8b8ea9c GIT binary patch literal 16384 zcmeHNU2Ggz6+W}xU2p!ji4&EYCT5INDT(CO#@;k;QxV&{iR0qL#_QVrtmMqjUazN_ zo!QRJ+A&3y3lUP0kf>TAUMMZfOCKTut@5eyFfIf_0UUy z{S;DI?ofJgpOzvz2we|t1E(T+oOOVX1KK%mF3lrtLg9WW$O~pDQg0qx&C=&LCy9zI zjT4<T!9t?BrgPMryVH^*k@>rOT4xlm*T)A6Q z<|C4dqEC`btCXZQiRZOpElDMbFKZ3RKbQEHwERxuU5SYpdk#oED{)bxFY%|bAH>en zFEMSB?!<1#k_hQG2NBK6+-ZpPD4jt3EI$wJQK`l7+Jm*JNb98-Lgu#|dyvNwPN_+%3r}Hd7PTin1MqP@u7wIsxWvPAtp;xG1GQyr)iCgsL4(&}k ziTSJ2^M>?fez|NV-bKH*_C7q@+HWa?T*I=J_ydh}Xn%xfyY0`&6Q@{~t;Ahu%{MKq zokN!Gwh7wT(r(c-Jwl zmPAw9uhC!7>eJtV&(g=pgs+F2bWBP;&|4JTi#P;u2=r@ZZA zt|iY3#Ej(#nioc;C4_dGGkkx&GUvIqdO+wIN!&m0)@p`R@jH`@n%4}wA(oeE#zlIx zke{QXRm-m$L6k&hUaZ*2!g3v&@O@D$+Zz`xTPzCChixLj-Ll*WM5}Q}Lr6vj=>%3y zWTu@!cy66ffMp7wrW#hIJqjXSw0x^6?Enlky5aXs^j{BW%^VQ zv&5@GuC{u(xGG}Bz`5{*U&o~(Xg16_I!^N9!?o6<^A$%Q{_55GKlPtn zdTrmS+|N>UC)vjj-M)i(v}kXL6mQ3{|4;_)0cbsn$@fZU-#}a@;6D+3oYt(xh4}bg-oy5J? z%vHwDAd%smIU_S}Udb1@Lsf=tYefvNSz;Zg z*}8Cit2SIQEPKN*xuJUc%y4$J?BO=FDqyVorLO2pZu#jF){Ve@t-B>tuaq$@eT=x8 zCEfg1(lm4)qu+aN({kSR3bxHR+3+?g!n-be+s$t2pm|8sG)q^YPXjMP=JM;L~x!g?0Wv>Oa8nF6kHzKA5_?M%y{G?uxJLBfe1?>+`yp*r6a$I@#eiZ! zF`yVw3@8Q^1BwB~z~`F*J^Y_>{qfIt8Y+6lfMP%~pcqgLCe&DY%q}R}$OsJ3g^e8khL64V+o(2xb!>~noV3xxf}2xUnIDQ88Ua^BN2h|j5dzbp zsCM$=KYKN9n7bT!I=OxJ@lTpBo&EImFUO@WWMD;&hd{0MADd$3`j0XqUz#=^8XGU7 zYhwoo=bF#^Pb6sez}royzuNo6sY@5n`A-ara_d{KKI_k(_s?__UGt929Ddi>^F!wN zzK^dw_S4J7_fFy10J@T${_w&pkB+~z|DBWHf4OZ^)T-xtK|p@f%XGc?t^E9d2wb1P zK99Zq9L&UbC->`9fnl?d(Thn-Pn$+2SjcDf;ACE(;;I8jb;HU}1T(38;h2>)MKKx+ zMtaAJDI=ZJxpLe}CiLQ@UW}WDWft`6QYdW^rFSO{?kKx#M~>wic4XNdv7dHFRV8$U zT`bRx2%l#LsS~fjK|JsIEuxh<+jpj8=HKzJwbh>U(4MadZG@#RkiMT8wtq}7%pY>( z7zxO9W<~XZ0N#*(>h{B%HyoEdPKt!b)Gpd%JFb_W8!@aBzv&pmc5?Zlf0$Y7pj`{? z@IRF}W|i~_o*N!|h}`aP1~1Q@edgzpFLwHxK7aossL&`4v5d&gO0a{ogq%yzlYT)C zY8Hw82d&#HcOC4t%7I9&QWygSJjPW4LKiPxxC~FYM?s_GK5} z?7LX=FSg@lcETs=PZ!tqF+a(iV}5~IQR5(hZ@Nxj_$uaF7f-H(oMH~V=%jM@-0qYi z1IH@LoL!dWd|I}_QUNA-1+7}YLid(r-L&VH*j?vFv6f=Zz}kel^a!(}`bVIXcG`PC z_Fs*vH~4mXph6bukAR{?Qs+%ur+V|1Izr~?@J6%M>Bq}2v_@hRm2E|x)3&$%F>53b zx2zD1+#6PCqD1Q)0gUmKFKU1HwGh45O1tJZQ#WNeu0zaxwxm);jP0Di+b;hxE33ur zaOM55lpys{!P&$=;1aSOu`YS^rK+2P&}b@eIJXAWJ22EAkHv%#1YvcR79h zP9&MJ9!xXi7HumtAP4k5W OGS-Console.cs - - Util.cs - VersionInfo.cs @@ -53,17 +50,14 @@ + + {2E46A825-3168-492F-93BC-637126B5B72B} + OpenSim.Framework + {7667E6E2-F227-41A2-B1B2-315613E1BAFC} ServerConsole - \ No newline at end of file diff --git a/ogs/gridserver/src/Properties/AssemblyInfo.cs b/OGS/gridserver/src/Properties/AssemblyInfo.cs similarity index 100% rename from ogs/gridserver/src/Properties/AssemblyInfo.cs rename to OGS/gridserver/src/Properties/AssemblyInfo.cs diff --git a/ogs/gridserver/src/SimProfiles.cs b/OGS/gridserver/src/SimProfiles.cs similarity index 79% rename from ogs/gridserver/src/SimProfiles.cs rename to OGS/gridserver/src/SimProfiles.cs index 91a92ea6a2..6db8331fd8 100644 --- a/ogs/gridserver/src/SimProfiles.cs +++ b/OGS/gridserver/src/SimProfiles.cs @@ -33,6 +33,8 @@ using System.Collections; using System.Collections.Generic; using libsecondlife; using ServerConsole; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Sims; namespace OpenGridServices { @@ -40,7 +42,7 @@ namespace OpenGridServices /// public class SimProfileManager { - public Dictionary SimProfiles = new Dictionary(); + public Dictionary SimProfiles = new Dictionary(); public SimProfileManager() { } @@ -49,19 +51,19 @@ namespace OpenGridServices // TODO: need to load from database } - public SimProfile GetProfileByHandle(ulong reqhandle) { + public SimProfileBase GetProfileByHandle(ulong reqhandle) { foreach (libsecondlife.LLUUID UUID in SimProfiles.Keys) { if(SimProfiles[UUID].regionhandle==reqhandle) return SimProfiles[UUID]; } return null; } - public SimProfile GetProfileByLLUUID(LLUUID ProfileLLUUID) { + public SimProfileBase GetProfileByLLUUID(LLUUID ProfileLLUUID) { return SimProfiles[ProfileLLUUID]; } public bool AuthenticateSim(LLUUID RegionUUID, uint regionhandle, string simrecvkey) { - SimProfile TheSim=GetProfileByHandle(regionhandle); + SimProfileBase TheSim=GetProfileByHandle(regionhandle); if(TheSim != null) if(TheSim.recvkey==simrecvkey) { return true; @@ -71,8 +73,8 @@ namespace OpenGridServices } - public SimProfile CreateNewProfile(string regionname, string caps_url, string sim_ip, uint sim_port, uint RegionLocX, uint RegionLocY, string sendkey, string recvkey) { - SimProfile newprofile = new SimProfile(); + public SimProfileBase CreateNewProfile(string regionname, string caps_url, string sim_ip, uint sim_port, uint RegionLocX, uint RegionLocY, string sendkey, string recvkey) { + SimProfileBase newprofile = new SimProfileBase(); newprofile.regionname=regionname; newprofile.sim_ip=sim_ip; newprofile.sim_port=sim_port; @@ -89,7 +91,8 @@ namespace OpenGridServices } - public class SimProfile { + /* is in OpenSim.Framework + public class SimProfileBase { public LLUUID UUID; public ulong regionhandle; public string regionname; @@ -102,10 +105,10 @@ namespace OpenGridServices public string recvkey; - public SimProfile() { + public SimProfileBase() { } - } + }*/ } diff --git a/ogs/userserver/src/ConsoleCmds.cs b/OGS/userserver/src/ConsoleCmds.cs similarity index 100% rename from ogs/userserver/src/ConsoleCmds.cs rename to OGS/userserver/src/ConsoleCmds.cs diff --git a/ogs/userserver/src/Main.cs b/OGS/userserver/src/Main.cs similarity index 91% rename from ogs/userserver/src/Main.cs rename to OGS/userserver/src/Main.cs index 40ef916a76..7e5308e33d 100644 --- a/ogs/userserver/src/Main.cs +++ b/OGS/userserver/src/Main.cs @@ -33,6 +33,9 @@ using System.Collections.Generic; using System.Text; using libsecondlife; using ServerConsole; +using OpenSim.Framework.User; +using OpenSim.Framework.Sims; +using OpenSim.Framework.Inventory; namespace OpenGridServices { @@ -73,16 +76,17 @@ namespace OpenGridServices public void Startup() { ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Please press enter to retain default settings"); - this.GridURL=ServerConsole.MainConsole.Instance.CmdPrompt("Grid URL: "); + this.GridURL=ServerConsole.MainConsole.Instance.CmdPrompt("Grid URL: "); this.GridSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to grid: "); this.GridRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from grid: "); this.DefaultStartupMsg=ServerConsole.MainConsole.Instance.CmdPrompt("Default startup message for clients [Welcome to OGS!] :","Welcome to OGS!"); - + ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Creating user profile manager"); _profilemanager = new UserProfileManager(); _profilemanager.InitUserProfiles(); - + _profilemanager.SetKeys(GridSendKey, GridRecvKey, GridURL, DefaultStartupMsg); + string tempfirstname; string templastname; diff --git a/ogs/userserver/src/OGS-UserServer.csproj b/OGS/userserver/src/OGS-UserServer.csproj similarity index 85% rename from ogs/userserver/src/OGS-UserServer.csproj rename to OGS/userserver/src/OGS-UserServer.csproj index f6737c86c8..f4fa8b6403 100644 --- a/ogs/userserver/src/OGS-UserServer.csproj +++ b/OGS/userserver/src/OGS-UserServer.csproj @@ -48,21 +48,16 @@ - - + + {2E46A825-3168-492F-93BC-637126B5B72B} + OpenSim.Framework + {7667E6E2-F227-41A2-B1B2-315613E1BAFC} ServerConsole - \ No newline at end of file diff --git a/ogs/userserver/src/OGS-UserServer.csproj.user b/OGS/userserver/src/OGS-UserServer.csproj.user similarity index 59% rename from ogs/userserver/src/OGS-UserServer.csproj.user rename to OGS/userserver/src/OGS-UserServer.csproj.user index 9c0b2d97ec..aa75a3df42 100644 --- a/ogs/userserver/src/OGS-UserServer.csproj.user +++ b/OGS/userserver/src/OGS-UserServer.csproj.user @@ -1,14 +1,6 @@  publish\ - - - - - - - - 0 en-US false diff --git a/ogs/userserver/src/Properties/AssemblyInfo.cs b/OGS/userserver/src/Properties/AssemblyInfo.cs similarity index 100% rename from ogs/userserver/src/Properties/AssemblyInfo.cs rename to OGS/userserver/src/Properties/AssemblyInfo.cs diff --git a/OGS/userserver/src/UserHttp.cs b/OGS/userserver/src/UserHttp.cs new file mode 100644 index 0000000000..ce3cfcdc74 --- /dev/null +++ b/OGS/userserver/src/UserHttp.cs @@ -0,0 +1,146 @@ +/* +Copyright (c) OpenGrid project, http://osgrid.org/ + + +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Text; +using Nwc.XmlRpc; +using System.Threading; +using System.Text.RegularExpressions; +using System.Net; +using System.IO; +using System.Collections; +using System.Collections.Generic; +using libsecondlife; +using ServerConsole; +using OpenSim.Framework.User; +using OpenSim.Framework.Sims; +using OpenSim.Framework.Inventory; + +namespace OpenGridServices +{ + public class UserHTTPServer { + public Thread HTTPD; + public HttpListener Listener; + + public UserHTTPServer() { + ServerConsole.MainConsole.Instance.WriteLine("Starting up HTTP Server"); + HTTPD = new Thread(new ThreadStart(StartHTTP)); + HTTPD.Start(); + } + + public void StartHTTP() { + ServerConsole.MainConsole.Instance.WriteLine("UserHttp.cs:StartHTTP() - Spawned main thread OK"); + Listener = new HttpListener(); + + Listener.Prefixes.Add("http://+:8002/userserver/"); + Listener.Prefixes.Add("http://+:8002/usersessions/"); + Listener.Start(); + + HttpListenerContext context; + while(true) { + context = Listener.GetContext(); + ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context); + } + } + + static string ParseXMLRPC(string requestBody) { + return OpenGridServices.OpenUser_Main.userserver._profilemanager.ParseXMLRPC(requestBody); + } + + static string ParseREST(HttpListenerRequest www_req) { + Console.WriteLine("INCOMING REST - " + www_req.RawUrl); + + char[] splitter = {'/'}; + string[] rest_params = www_req.RawUrl.Split(splitter); + string req_type = rest_params[1]; // First part of the URL is the type of request - usersessions/userprofiles/inventory/blabla + switch(req_type) { + case "usersessions": + LLUUID sessionid = new LLUUID(rest_params[2]); // get usersessions/sessionid + if(www_req.HttpMethod=="DELETE") { + foreach (libsecondlife.LLUUID UUID in OpenUser_Main.userserver._profilemanager.UserProfiles.Keys) { + if(OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID==sessionid) { + OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID=null; + OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSecureSessionID=null; + OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].Circuits.Clear(); + } + } + + } + return "OK"; + break; + } + + return ""; + } + + + static void HandleRequest(Object stateinfo) { + HttpListenerContext context=(HttpListenerContext)stateinfo; + + HttpListenerRequest request = context.Request; + HttpListenerResponse response = context.Response; + + response.KeepAlive=false; + response.SendChunked=false; + + System.IO.Stream body = request.InputStream; + System.Text.Encoding encoding = System.Text.Encoding.UTF8; + System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding); + + string requestBody = reader.ReadToEnd(); + body.Close(); + reader.Close(); + + string responseString=""; + switch(request.ContentType) { + case "text/xml": + // must be XML-RPC, so pass to the XML-RPC parser + + responseString=ParseXMLRPC(requestBody); + response.AddHeader("Content-type","text/xml"); + break; + + case "text/plaintext": + responseString=ParseREST(request); + response.AddHeader("Content-type","text/plaintext"); + break; + } + + + byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString); + System.IO.Stream output = response.OutputStream; + response.SendChunked=false; + response.ContentLength64=buffer.Length; + output.Write(buffer,0,buffer.Length); + output.Close(); + } + } + + +} diff --git a/OpenSim.Config/SimConfigDb4o/AssemblyInfo.cs b/OpenSim.Config/SimConfigDb4o/AssemblyInfo.cs new file mode 100644 index 0000000000..96c3e7383d --- /dev/null +++ b/OpenSim.Config/SimConfigDb4o/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("SimConfig")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SimConfig")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] diff --git a/OpenSim.Config/SimConfigDb4o/DbSimConfig.cs b/OpenSim.Config/SimConfigDb4o/DbSimConfig.cs new file mode 100644 index 0000000000..250f3fd044 --- /dev/null +++ b/OpenSim.Config/SimConfigDb4o/DbSimConfig.cs @@ -0,0 +1,176 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using OpenSim; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Terrain; +//using OpenSim.world; +using Db4objects.Db4o; + +namespace OpenSim.Config.SimConfigDb4o +{ + public class Db40ConfigPlugin: ISimConfig + { + public SimConfig GetConfigObject() + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Loading Db40Config dll"); + return ( new DbSimConfig()); + } + } + + public class DbSimConfig : SimConfig + { + private bool isSandbox; + private IObjectContainer db; + + public void LoadDefaults() { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings"); + + this.RegionName=OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Name [OpenSim test]: ","OpenSim test"); + this.RegionLocX=(uint)Convert.ToInt32(OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid Location X [997]: ","997")); + this.RegionLocY=(uint)Convert.ToInt32(OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid Location Y [996]: ","996")); + this.IPListenPort=Convert.ToInt32(OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("UDP port for client connections [9000]: ","9000")); + this.IPListenAddr=OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("IP Address to listen on for client connections [127.0.0.1]: ","127.0.0.1"); + + if(!isSandbox) + { + this.AssetURL=OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Asset server URL: "); + this.AssetSendKey=OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Asset server key: "); + this.GridURL=OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid server URL: "); + this.GridSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to grid server: "); + this.GridRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from grid server: "); + this.UserURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("User server URL: "); + this.UserSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to user server: "); + this.UserRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from user server: "); + } + this.RegionHandle = Util.UIntsToLong((RegionLocX*256), (RegionLocY*256)); + } + + public override void InitConfig(bool sandboxMode) { + this.isSandbox = sandboxMode; + try { + db = Db4oFactory.OpenFile("opensim.yap"); + IObjectSet result = db.Get(typeof(DbSimConfig)); + if(result.Count==1) { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Found a SimConfig object in the local database, loading"); + foreach (DbSimConfig cfg in result) { + this.RegionName = cfg.RegionName; + this.RegionLocX = cfg.RegionLocX; + this.RegionLocY = cfg.RegionLocY; + this.RegionHandle = Util.UIntsToLong((RegionLocX*256), (RegionLocY*256)); + this.IPListenPort = cfg.IPListenPort; + this.IPListenAddr = cfg.IPListenAddr; + this.AssetURL = cfg.AssetURL; + this.AssetSendKey = cfg.AssetSendKey; + this.GridURL = cfg.GridURL; + this.GridSendKey = cfg.GridSendKey; + } + } else { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Could not find object in database, loading precompiled defaults"); + LoadDefaults(); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Writing out default settings to local database"); + db.Set(this); + } + } catch(Exception e) { + db.Close(); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Exception occured"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString()); + } + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sim settings loaded:"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Name: " + this.RegionName); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Region Handle: " + this.RegionHandle.ToString()); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sandbox Mode? " + isSandbox.ToString()); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Asset URL: " + this.AssetURL); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Asset key: " + this.AssetSendKey); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid URL: " + this.GridURL); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid key: " + this.GridSendKey); + } + + public override float[] LoadWorld() + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Loading world...."); + //World blank = new World(); + float[] heightmap = null; + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Looking for a heightmap in local DB"); + IObjectSet world_result = db.Get(typeof(MapStorage)); + if(world_result.Count>0) { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Found a heightmap in local database, loading"); + MapStorage map=(MapStorage)world_result.Next(); + //blank.LandMap = map.Map; + heightmap = map.Map; + } else { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - No heightmap found, generating new one"); + HeightmapGenHills hills = new HeightmapGenHills(); + // blank.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); + heightmap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Saving heightmap to local database"); + MapStorage map= new MapStorage(); + map.Map = heightmap; //blank.LandMap; + db.Set(map); + db.Commit(); + } + return heightmap; + } + + public override void SaveMap(float[] heightmap) + { + IObjectSet world_result = db.Get(typeof(MapStorage)); + if(world_result.Count>0) { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - updating saved copy of heightmap in local database"); + MapStorage map=(MapStorage)world_result.Next(); + db.Delete(map); + } + MapStorage map1= new MapStorage(); + map1.Map = heightmap; //OpenSim_Main.local_world.LandMap; + db.Set(map1); + db.Commit(); + } + + public override void LoadFromGrid() { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:LoadFromGrid() - dummy function, DOING ABSOLUTELY NOTHING AT ALL!!!"); + // TODO: Make this crap work + /* WebRequest GridLogin = WebRequest.Create(this.GridURL + "regions/" + this.RegionHandle.ToString() + "/login"); + WebResponse GridResponse = GridLogin.GetResponse(); + byte[] idata = new byte[(int)GridResponse.ContentLength]; + BinaryReader br = new BinaryReader(GridResponse.GetResponseStream()); + + br.Close(); + GridResponse.Close(); + */ + } + + public void Shutdown() { + db.Close(); + } + } + +} diff --git a/OpenSim.Config/SimConfigDb4o/MapStorage.cs b/OpenSim.Config/SimConfigDb4o/MapStorage.cs new file mode 100644 index 0000000000..eb68a94fbb --- /dev/null +++ b/OpenSim.Config/SimConfigDb4o/MapStorage.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Config.SimConfigDb4o +{ + public class MapStorage + { + public float[] Map; + + public MapStorage() + { + + } + } +} diff --git a/OpenSim.Config/SimConfigDb4o/OpenSim.Config.SimConfigDb4o.csproj b/OpenSim.Config/SimConfigDb4o/OpenSim.Config.SimConfigDb4o.csproj new file mode 100644 index 0000000000..02f626ff4b --- /dev/null +++ b/OpenSim.Config/SimConfigDb4o/OpenSim.Config.SimConfigDb4o.csproj @@ -0,0 +1,107 @@ + + + Local + 8.0.50727 + 2.0 + {C077B28B-2F8D-4BD9-8E47-84C51B3A7358} + Debug + AnyCPU + + + + OpenSim.Config.SimConfigDb4o + JScript + Grid + IE50 + false + Library + + OpenSim.Config.SimConfigDb4o + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\ + False + False + False + 4 + + + + + \System.dll + + + \System.Data.dll.dll + + + \System.Xml.dll.dll + + + \libsecondlife.dll.dll + + + \Db4objects.Db4o.dll.dll + + + + + OpenSim.Framework + {1D2865A9-CF8E-45F7-B96D-91ED128A32CF} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + OpenSim.Framework.Console + {C8405E1A-EC19-48B6-9C8C-CA03624B9916} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.Config/SimConfigDb4o/OpenSim.Config.SimConfigDb4o.dll.build b/OpenSim.Config/SimConfigDb4o/OpenSim.Config.SimConfigDb4o.dll.build new file mode 100644 index 0000000000..288e877f42 --- /dev/null +++ b/OpenSim.Config/SimConfigDb4o/OpenSim.Config.SimConfigDb4o.dll.build @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.Framework.Console/AssemblyInfo.cs b/OpenSim.Framework.Console/AssemblyInfo.cs new file mode 100644 index 0000000000..00a9b7d748 --- /dev/null +++ b/OpenSim.Framework.Console/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("ServerConsole")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ServerConsole")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] diff --git a/OpenSim.Framework.Console/ConsoleBase.cs b/OpenSim.Framework.Console/ConsoleBase.cs new file mode 100644 index 0000000000..5343e7142f --- /dev/null +++ b/OpenSim.Framework.Console/ConsoleBase.cs @@ -0,0 +1,45 @@ +using System; + +namespace OpenSim.Framework.Console +{ + public abstract class ConsoleBase + { + + public enum ConsoleType + { + Local, // Use stdio + TCP, // Use TCP/telnet + SimChat // Use in-world chat (for gods) + } + + public abstract void Close(); + + public abstract void Write(string format, params object[] args); + + public abstract void WriteLine(string format, params object[] args); + + public abstract string ReadLine(); + + public abstract int Read(); + + // Displays a command prompt and waits for the user to enter a string, then returns that string + public abstract string CmdPrompt(string prompt); + + // Displays a command prompt and returns a default value if the user simply presses enter + public abstract string CmdPrompt(string prompt, string defaultresponse); + + // Displays a command prompt and returns a default value, user may only enter 1 of 2 options + public abstract string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB); + + // Runs a command with a number of parameters + public abstract Object RunCmd(string Cmd, string[] cmdparams); + + // Shows data about something + public abstract void ShowCommands(string ShowWhat); + + // Displays a prompt to the user and then runs the command they entered + public abstract void MainConsolePrompt(); + + public abstract void SetStatus(string status); + } +} diff --git a/src/VersionInfo.cs.template b/OpenSim.Framework.Console/MainConsole.cs similarity index 80% rename from src/VersionInfo.cs.template rename to OpenSim.Framework.Console/MainConsole.cs index e4e1b95ae3..02c4ae89f0 100644 --- a/src/VersionInfo.cs.template +++ b/OpenSim.Framework.Console/MainConsole.cs @@ -1,5 +1,5 @@ /* -Copyright (c) OpenSim project, http://osgrid.org/ +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -22,16 +22,27 @@ Copyright (c) OpenSim project, http://osgrid.org/ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* */ - using System; -namespace OpenSim +namespace OpenSim.Framework.Console { - /// - /// - public class VersionInfo - { - public static string Version = "@@VERSION"; - } + public class MainConsole { + + private static ConsoleBase instance; + + public static ConsoleBase Instance + { + get + { + return instance; + } + set + { + instance = value; + } + } + } + } diff --git a/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj b/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj new file mode 100644 index 0000000000..1f0da5619c --- /dev/null +++ b/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj @@ -0,0 +1,85 @@ + + + Local + 8.0.50727 + 2.0 + {C8405E1A-EC19-48B6-9C8C-CA03624B9916} + Debug + AnyCPU + + + + OpenSim.Framework.Console + JScript + Grid + IE50 + false + Library + + OpenSim.Framework.Console + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\bin\ + False + False + False + 4 + + + + + \System.dll + + + + + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build b/OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build new file mode 100644 index 0000000000..9ceaea6277 --- /dev/null +++ b/OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.Framework/AgentCiruitData.cs b/OpenSim.Framework/AgentCiruitData.cs new file mode 100644 index 0000000000..3ab8a804a1 --- /dev/null +++ b/OpenSim.Framework/AgentCiruitData.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Interfaces +{ + public class AgentCircuitData + { + public AgentCircuitData() { } + public LLUUID AgentID; + public LLUUID SessionID; + public LLUUID SecureSessionID; + public string firstname; + public string lastname; + public uint circuitcode; + } +} diff --git a/OpenSim.Framework/AssetBase.cs b/OpenSim.Framework/AssetBase.cs new file mode 100644 index 0000000000..8206b307e0 --- /dev/null +++ b/OpenSim.Framework/AssetBase.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Assets +{ + public class AssetBase + { + public byte[] Data; + public LLUUID FullID; + public sbyte Type; + public sbyte InvType; + public string Name; + public string Description; + + public AssetBase() + { + + } + } +} diff --git a/OpenSim.Framework/BlockingQueue.cs b/OpenSim.Framework/BlockingQueue.cs new file mode 100644 index 0000000000..f840354295 --- /dev/null +++ b/OpenSim.Framework/BlockingQueue.cs @@ -0,0 +1,33 @@ +using System; +using System.Threading; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Utilities +{ + public class BlockingQueue + { + private Queue _queue = new Queue(); + private object _queueSync = new object(); + + public void Enqueue(T value) + { + lock (_queueSync) + { + _queue.Enqueue(value); + Monitor.Pulse(_queueSync); + } + } + + public T Dequeue() + { + lock (_queueSync) + { + if (_queue.Count < 1) + Monitor.Wait(_queueSync); + + return _queue.Dequeue(); + } + } + } +} diff --git a/src/HeightMapGenHills.cs b/OpenSim.Framework/HeightMapGenHills.cs similarity index 96% rename from src/HeightMapGenHills.cs rename to OpenSim.Framework/HeightMapGenHills.cs index e7589aff00..6a729da553 100644 --- a/src/HeightMapGenHills.cs +++ b/OpenSim.Framework/HeightMapGenHills.cs @@ -27,7 +27,7 @@ using System; -namespace OpenSim +namespace OpenSim.Framework.Terrain { public class HeightmapGenHills { diff --git a/src/GridInterfaces/IAssetServer.cs b/OpenSim.Framework/IAssetServer.cs similarity index 63% rename from src/GridInterfaces/IAssetServer.cs rename to OpenSim.Framework/IAssetServer.cs index 6050a6c679..a0de548a0e 100644 --- a/src/GridInterfaces/IAssetServer.cs +++ b/OpenSim.Framework/IAssetServer.cs @@ -30,53 +30,39 @@ using System.Net.Sockets; using System.IO; using System.Threading; using libsecondlife; +using OpenSim.Framework.Assets; - -namespace OpenSim.GridServers +namespace OpenSim.Framework.Interfaces { - /// - /// Description of IAssetServer. - /// - - public interface IAssetServer - { - void SetReceiver(IAssetReceiver receiver); - void RequestAsset(LLUUID assetID, bool isTexture); - void UpdateAsset(AssetBase asset); - void UploadNewAsset(AssetBase asset); - void SetServerInfo(string ServerUrl, string ServerKey); - } - - // could change to delegate? - public interface IAssetReceiver - { - void AssetReceived(AssetBase asset, bool IsTexture); - void AssetNotFound(AssetBase asset); - } - - public struct ARequest - { - public LLUUID AssetID; - public bool IsTexture; - } - - public class AssetBase - { - public byte[] Data; - public LLUUID FullID; - public sbyte Type; - public sbyte InvType; - public string Name; - public string Description; - - public AssetBase() - { - - } - } - - public interface IAssetPlugin - { - IAssetServer GetAssetServer(); - } + /// + /// Description of IAssetServer. + /// + + public interface IAssetServer + { + void SetReceiver(IAssetReceiver receiver); + void RequestAsset(LLUUID assetID, bool isTexture); + void UpdateAsset(AssetBase asset); + void UploadNewAsset(AssetBase asset); + void SetServerInfo(string ServerUrl, string ServerKey); + void Close(); + } + + // could change to delegate? + public interface IAssetReceiver + { + void AssetReceived(AssetBase asset, bool IsTexture); + void AssetNotFound(AssetBase asset); + } + + public interface IAssetPlugin + { + IAssetServer GetAssetServer(); + } + + public struct ARequest + { + public LLUUID AssetID; + public bool IsTexture; + } } diff --git a/src/Config.cs b/OpenSim.Framework/IConfig.cs similarity index 55% rename from src/Config.cs rename to OpenSim.Framework/IConfig.cs index 1c0a6cc97e..ca7f6451b2 100644 --- a/src/Config.cs +++ b/OpenSim.Framework/IConfig.cs @@ -31,49 +31,48 @@ using System; using System.Collections.Generic; using System.IO; using libsecondlife; -using OpenSim.world; +//using OpenSim.world; -namespace OpenSim +namespace OpenSim.Framework.Interfaces { - /// - /// This class handles connection to the underlying database used for configuration of the region. - /// Region content is also stored by this class. The main entry point is InitConfig() which attempts to locate - /// opensim.yap in the current working directory. If opensim.yap can not be found, default settings are loaded from - /// what is hardcoded here and then saved into opensim.yap for future startups. - /// - - - public abstract class SimConfig - { - public string RegionName; - - public uint RegionLocX; - public uint RegionLocY; - public ulong RegionHandle; - - public int IPListenPort; - public string IPListenAddr; - - public string AssetURL; - public string AssetSendKey; - - public string GridURL; - public string GridSendKey; - public string GridRecvKey; - public string UserURL; - public string UserSendKey; - public string UserRecvKey; + /// + /// This class handles connection to the underlying database used for configuration of the region. + /// Region content is also stored by this class. The main entry point is InitConfig() which attempts to locate + /// opensim.yap in the current working directory. If opensim.yap can not be found, default settings are loaded from + /// what is hardcoded here and then saved into opensim.yap for future startups. + /// - - public abstract void InitConfig(); - public abstract void LoadFromGrid(); - public abstract World LoadWorld(); - public abstract void SaveMap(); - - } - - public interface ISimConfig - { - SimConfig GetConfigObject(); - } + + public abstract class SimConfig + { + public string RegionName; + + public uint RegionLocX; + public uint RegionLocY; + public ulong RegionHandle; + + public int IPListenPort; + public string IPListenAddr; + + public string AssetURL; + public string AssetSendKey; + + public string GridURL; + public string GridSendKey; + public string GridRecvKey; + public string UserURL; + public string UserSendKey; + public string UserRecvKey; + + public abstract void InitConfig(bool sandboxMode); + public abstract void LoadFromGrid(); + public abstract float[] LoadWorld(); + public abstract void SaveMap(float[] heightmap); + + } + + public interface ISimConfig + { + SimConfig GetConfigObject(); + } } diff --git a/OpenSim.Framework/IGridServer.cs b/OpenSim.Framework/IGridServer.cs new file mode 100644 index 0000000000..026dfab491 --- /dev/null +++ b/OpenSim.Framework/IGridServer.cs @@ -0,0 +1,78 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + + +using System; +using System.Collections.Generic; +using System.Net; +using System.Net.Sockets; +using System.IO; +using libsecondlife; +using OpenSim; + +namespace OpenSim.Framework.Interfaces +{ + /// + /// Handles connection to Grid Servers. + /// also Sim to Sim connections? + /// + + public interface IGridServer + { + UUIDBlock RequestUUIDBlock(); + NeighbourInfo[] RequestNeighbours(); //should return a array of neighbouring regions + AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + string GetName(); + bool RequestConnection(); + void SetServerInfo(string ServerUrl, string SendKey, string RecvKey); + void Close(); + } + + public struct UUIDBlock + { + public LLUUID BlockStart; + public LLUUID BlockEnd; + } + + public class AuthenticateResponse + { + public bool Authorised; + public Login LoginInfo; + + public AuthenticateResponse() + { + + } + + } + + public interface IGridPlugin + { + IGridServer GetGridServer(); + } +} diff --git a/src/GridInterfaces/ILocalStorage.cs b/OpenSim.Framework/ILocalStorage.cs similarity index 54% rename from src/GridInterfaces/ILocalStorage.cs rename to OpenSim.Framework/ILocalStorage.cs index 6b7ded69e8..e9aa1a2cc3 100644 --- a/src/GridInterfaces/ILocalStorage.cs +++ b/OpenSim.Framework/ILocalStorage.cs @@ -27,60 +27,25 @@ using System; using libsecondlife; +using OpenSim.Framework.Assets; -namespace GridInterfaces +namespace OpenSim.Framework.Interfaces { - /// - /// ILocalStorage. Really hacked together right now needs cleaning up - /// - public interface ILocalStorage - { - void StorePrim(PrimData prim); - void RemovePrim(LLUUID primID); - void LoadPrimitives(ILocalStorageReceiver receiver); - void ShutDown(); - } - - public interface ILocalStorageReceiver - { - void PrimFromStorage(PrimData prim); - } - - - public class PrimData - { - public LLUUID OwnerID; - public byte PCode; - public byte PathBegin; - public byte PathEnd; - public byte PathScaleX; - public byte PathScaleY; - public byte PathShearX; - public byte PathShearY; - public sbyte PathSkew; - public byte ProfileBegin; - public byte ProfileEnd; - public LLVector3 Scale; - public byte PathCurve; - public byte ProfileCurve; - public uint ParentID=0; - public byte ProfileHollow; - public sbyte PathRadiusOffset; - public byte PathRevolutions; - public sbyte PathTaperX; - public sbyte PathTaperY; - public sbyte PathTwist; - public sbyte PathTwistBegin; - - //following only used during prim storage - public LLVector3 Position; - public LLQuaternion Rotation; - public uint LocalID; - public LLUUID FullID; - - public PrimData() - { - - } - } + /// + /// ILocalStorage. Really hacked together right now needs cleaning up + /// + public interface ILocalStorage + { + void StorePrim(PrimData prim); + void RemovePrim(LLUUID primID); + void LoadPrimitives(ILocalStorageReceiver receiver); + void ShutDown(); + } + + public interface ILocalStorageReceiver + { + void PrimFromStorage(PrimData prim); + } + } + diff --git a/OpenSim.Framework/IUserServer.cs b/OpenSim.Framework/IUserServer.cs new file mode 100644 index 0000000000..bb2b668d7c --- /dev/null +++ b/OpenSim.Framework/IUserServer.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Inventory; +using libsecondlife; + +namespace OpenSim.Framework.Interfaces +{ + public interface IUserServer + { + AgentInventory RequestAgentsInventory(LLUUID agentID); + void SetServerInfo(string ServerUrl, string SendKey, string RecvKey); + } +} diff --git a/OpenSim.Framework/Inventory.cs b/OpenSim.Framework/Inventory.cs new file mode 100644 index 0000000000..e34ea756cb --- /dev/null +++ b/OpenSim.Framework/Inventory.cs @@ -0,0 +1,127 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Assets; + +namespace OpenSim.Framework.Inventory +{ + public class AgentInventory + { + //Holds the local copy of Inventory info for a agent + public Dictionary InventoryFolders; + public Dictionary InventoryItems; + public InventoryFolder InventoryRoot; + public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server + public LLUUID AgentID; + public AvatarWearable[] Wearables; + + public AgentInventory() + { + InventoryFolders = new Dictionary(); + InventoryItems = new Dictionary(); + this.Initialise(); + } + + public virtual void Initialise() + { + Wearables = new AvatarWearable[2]; //should be 12 of these + for (int i = 0; i < 2; i++) + { + Wearables[i] = new AvatarWearable(); + } + + InventoryRoot = new InventoryFolder(); + InventoryRoot.FolderID = LLUUID.Random(); + InventoryRoot.ParentID = new LLUUID(); + InventoryRoot.Version = 1; + InventoryRoot.DefaultType = 8; + InventoryRoot.FolderName = "My Inventory"; + InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot); + } + + public bool CreateNewFolder(LLUUID folderID) + { + InventoryFolder Folder = new InventoryFolder(); + Folder.FolderID = folderID; + Folder.OwnerID = this.AgentID; + this.InventoryFolders.Add(Folder.FolderID, Folder); + + return (true); + } + + public LLUUID AddToInventory(LLUUID folderID, AssetBase asset) + { + if (this.InventoryFolders.ContainsKey(folderID)) + { + LLUUID NewItemID = LLUUID.Random(); + + InventoryItem Item = new InventoryItem(); + Item.FolderID = folderID; + Item.OwnerID = AgentID; + Item.AssetID = asset.FullID; + Item.ItemID = NewItemID; + Item.Type = asset.Type; + Item.Name = asset.Name; + Item.Description = asset.Description; + Item.InvType = asset.InvType; + this.InventoryItems.Add(Item.ItemID, Item); + InventoryFolder Folder = InventoryFolders[Item.FolderID]; + Folder.Items.Add(Item); + return (Item.ItemID); + } + else + { + return (null); + } + } + } + + public class InventoryFolder + { + public List Items; + //public List Subfolders; + public LLUUID FolderID; + public LLUUID OwnerID; + public LLUUID ParentID; + public string FolderName; + public ushort DefaultType; + public ushort Version; + + public InventoryFolder() + { + Items = new List(); + //Subfolders = new List(); + } + + } + + public class InventoryItem + { + public LLUUID FolderID; + public LLUUID OwnerID; + public LLUUID ItemID; + public LLUUID AssetID; + public LLUUID CreatorID; + public sbyte InvType; + public sbyte Type; + public string Name; + public string Description; + + public InventoryItem() + { + this.CreatorID = LLUUID.Zero; + } + } + + public class AvatarWearable + { + public LLUUID AssetID = new LLUUID("00000000-0000-0000-0000-000000000000"); + public LLUUID ItemID = new LLUUID("00000000-0000-0000-0000-000000000000"); + + public AvatarWearable() + { + + } + } +} diff --git a/OpenSim.Framework/LocalGridBase.cs b/OpenSim.Framework/LocalGridBase.cs new file mode 100644 index 0000000000..c9b278a846 --- /dev/null +++ b/OpenSim.Framework/LocalGridBase.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Interfaces +{ + public abstract class LocalGridBase : IGridServer + { + public abstract UUIDBlock RequestUUIDBlock(); + public abstract NeighbourInfo[] RequestNeighbours(); + public abstract AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + public abstract bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + public abstract string GetName(); + public abstract bool RequestConnection(); + public abstract void SetServerInfo(string ServerUrl, string SendKey, string RecvKey); + public abstract void AddNewSession(Login session); + public abstract void Close(); + } + +} diff --git a/OpenSim.Framework/Login.cs b/OpenSim.Framework/Login.cs new file mode 100644 index 0000000000..8a67853c44 --- /dev/null +++ b/OpenSim.Framework/Login.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Interfaces +{ + public class Login + { + public string First = "Test"; + public string Last = "User"; + public LLUUID Agent; + public LLUUID Session; + public LLUUID SecureSession = LLUUID.Zero; + public LLUUID InventoryFolder; + public LLUUID BaseFolder; + public Login() + { + + } + } +} diff --git a/src/OpenSim.Framework/LoginService.cs b/OpenSim.Framework/LoginService.cs similarity index 72% rename from src/OpenSim.Framework/LoginService.cs rename to OpenSim.Framework/LoginService.cs index 85fe761225..eba0281729 100644 --- a/src/OpenSim.Framework/LoginService.cs +++ b/OpenSim.Framework/LoginService.cs @@ -3,13 +3,12 @@ using System.Collections; using System.Collections.Generic; using System.Text; using Nwc.XmlRpc; -using OpenSim.GridServers; using libsecondlife; -namespace OpenSim.Framework +namespace OpenSim.Framework.Grid { public abstract class LoginService { } -} +} \ No newline at end of file diff --git a/OpenSim.Framework/NeighbourInfo.cs b/OpenSim.Framework/NeighbourInfo.cs new file mode 100644 index 0000000000..8b4fa64e1f --- /dev/null +++ b/OpenSim.Framework/NeighbourInfo.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Interfaces +{ + public class NeighbourInfo + { + public NeighbourInfo() + { + } + + public ulong regionhandle; + public uint RegionLocX; + public uint RegionLocY; + public string sim_ip; + public uint sim_port; + } +} diff --git a/OpenSim.Framework/OpenSim.Framework.csproj b/OpenSim.Framework/OpenSim.Framework.csproj new file mode 100644 index 0000000000..7a10319261 --- /dev/null +++ b/OpenSim.Framework/OpenSim.Framework.csproj @@ -0,0 +1,151 @@ + + + Local + 8.0.50727 + 2.0 + {1D2865A9-CF8E-45F7-B96D-91ED128A32CF} + Debug + AnyCPU + + + + OpenSim.Framework + JScript + Grid + IE50 + false + Library + + OpenSim.Framework + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\bin\ + False + False + False + 4 + + + + + \System.dll.dll + + + \System.Xml.dll.dll + + + \libsecondlife.dll.dll + + + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.Framework/OpenSim.Framework.dll.build b/OpenSim.Framework/OpenSim.Framework.dll.build new file mode 100644 index 0000000000..1418947bb2 --- /dev/null +++ b/OpenSim.Framework/OpenSim.Framework.dll.build @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.Framework/PrimData.cs b/OpenSim.Framework/PrimData.cs new file mode 100644 index 0000000000..175a014df3 --- /dev/null +++ b/OpenSim.Framework/PrimData.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Assets +{ + public class PrimData + { + public LLUUID OwnerID; + public byte PCode; + public byte PathBegin; + public byte PathEnd; + public byte PathScaleX; + public byte PathScaleY; + public byte PathShearX; + public byte PathShearY; + public sbyte PathSkew; + public byte ProfileBegin; + public byte ProfileEnd; + public LLVector3 Scale; + public byte PathCurve; + public byte ProfileCurve; + public uint ParentID = 0; + public byte ProfileHollow; + public sbyte PathRadiusOffset; + public byte PathRevolutions; + public sbyte PathTaperX; + public sbyte PathTaperY; + public sbyte PathTwist; + public sbyte PathTwistBegin; + public byte[] Texture; + + //following only used during prim storage + public LLVector3 Position; + public LLQuaternion Rotation; + public uint LocalID; + public LLUUID FullID; + + public PrimData() + { + + } + } +} diff --git a/src/Properties/AssemblyInfo.cs b/OpenSim.Framework/Properties/AssemblyInfo.cs similarity index 78% rename from src/Properties/AssemblyInfo.cs rename to OpenSim.Framework/Properties/AssemblyInfo.cs index 90fc127795..86f5cdbd10 100644 --- a/src/Properties/AssemblyInfo.cs +++ b/OpenSim.Framework/Properties/AssemblyInfo.cs @@ -5,12 +5,12 @@ using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("opensim")] +[assembly: AssemblyTitle("OpenSim.FrameWork")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Playahead AB")] -[assembly: AssemblyProduct("opensim")] -[assembly: AssemblyCopyright("Copyright © Playahead AB 2007")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OpenSim.FrameWork")] +[assembly: AssemblyCopyright("Copyright © 2007")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -20,7 +20,7 @@ using System.Runtime.InteropServices; [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("1d09756b-a461-4302-b6fe-15c455317909")] +[assembly: Guid("a08e20c7-f191-4137-b1f0-9291408fa521")] // Version information for an assembly consists of the following four values: // diff --git a/OpenSim.Framework/RemoteGridBase.cs b/OpenSim.Framework/RemoteGridBase.cs new file mode 100644 index 0000000000..6ca57dfffe --- /dev/null +++ b/OpenSim.Framework/RemoteGridBase.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Interfaces +{ + public abstract class RemoteGridBase : IGridServer + { + public abstract Dictionary agentcircuits + { + get; + set; + } + + public abstract UUIDBlock RequestUUIDBlock(); + public abstract NeighbourInfo[] RequestNeighbours(); + public abstract AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + public abstract bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + public abstract string GetName(); + public abstract bool RequestConnection(); + public abstract void SetServerInfo(string ServerUrl, string SendKey, string RecvKey); + public abstract void Close(); + } +} diff --git a/OpenSim.Framework/SimProfile.cs b/OpenSim.Framework/SimProfile.cs new file mode 100644 index 0000000000..ac4cf9e327 --- /dev/null +++ b/OpenSim.Framework/SimProfile.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Collections; +using System.Xml; +using System.Text; +using libsecondlife; +using Nwc.XmlRpc; + +namespace OpenSim.Framework.Sims +{ + public class SimProfile : SimProfileBase + { + public SimProfile LoadFromGrid(ulong region_handle, string GridURL, string SendKey, string RecvKey) + { + try + { + Hashtable GridReqParams = new Hashtable(); + GridReqParams["region_handle"] = region_handle.ToString(); + GridReqParams["caller"] = "userserver"; + GridReqParams["authkey"] = SendKey; + ArrayList SendParams = new ArrayList(); + SendParams.Add(GridReqParams); + XmlRpcRequest GridReq = new XmlRpcRequest("get_sim_info", SendParams); + + XmlRpcResponse GridResp = GridReq.Send(GridURL, 3000); + + Hashtable RespData = (Hashtable)GridResp.Value; + this.UUID = new LLUUID((string)RespData["UUID"]); + this.regionhandle = (ulong)Convert.ToUInt64(RespData["regionhandle"]); + this.regionname = (string)RespData["regionname"]; + this.sim_ip = (string)RespData["sim_ip"]; + this.sim_port = (uint)Convert.ToUInt16(RespData["sim_port"]); + this.caps_url = (string)RespData["caps_url"]; + this.RegionLocX = (uint)Convert.ToUInt32(RespData["RegionLocX"]); + this.RegionLocY = (uint)Convert.ToUInt32(RespData["RegionLocY"]); + this.sendkey = (string)RespData["sendkey"]; + this.recvkey = (string)RespData["recvkey"]; + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + } + return this; + } + + public SimProfile() + { + } + } + +} diff --git a/OpenSim.Framework/SimProfileBase.cs b/OpenSim.Framework/SimProfileBase.cs new file mode 100644 index 0000000000..5fe2734650 --- /dev/null +++ b/OpenSim.Framework/SimProfileBase.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Sims +{ + public class SimProfileBase + { + public LLUUID UUID; + public ulong regionhandle; + public string regionname; + public string sim_ip; + public uint sim_port; + public string caps_url; + public uint RegionLocX; + public uint RegionLocY; + public string sendkey; + public string recvkey; + + public SimProfileBase() + { + } + } +} diff --git a/OpenSim.Framework/UserProfile.cs b/OpenSim.Framework/UserProfile.cs new file mode 100644 index 0000000000..2c264c52e1 --- /dev/null +++ b/OpenSim.Framework/UserProfile.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Inventory; + +namespace OpenSim.Framework.User +{ + public class UserProfile + { + + public string firstname; + public string lastname; + public ulong homeregionhandle; + public LLVector3 homepos; + public LLVector3 homelookat; + + public bool IsGridGod = false; + public bool IsLocal = true; // will be used in future for visitors from foreign grids + public string AssetURL; + public string MD5passwd; + + public LLUUID CurrentSessionID; + public LLUUID CurrentSecureSessionID; + public LLUUID UUID; + public Dictionary Circuits = new Dictionary(); // tracks circuit codes + + public AgentInventory Inventory; + + public UserProfile() + { + Circuits = new Dictionary(); + Inventory = new AgentInventory(); + homeregionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256)); ; + } + + public void InitSessionData() + { + CurrentSessionID = LLUUID.Random(); + CurrentSecureSessionID = LLUUID.Random(); + } + + public void AddSimCircuit(uint circuitCode, LLUUID regionUUID) + { + if (this.Circuits.ContainsKey(regionUUID) == false) + this.Circuits.Add(regionUUID, circuitCode); + } + + } +} diff --git a/OpenSim.Framework/UserProfileManager.cs b/OpenSim.Framework/UserProfileManager.cs new file mode 100644 index 0000000000..f77ca4ca78 --- /dev/null +++ b/OpenSim.Framework/UserProfileManager.cs @@ -0,0 +1,223 @@ +using System; +using System.Collections.Generic; +using System.Collections; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; +using libsecondlife; +using Nwc.XmlRpc; +using OpenSim.Framework.Sims; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.User +{ + public class UserProfileManager : UserProfileManagerBase + { + public string GridURL; + public string GridSendKey; + public string GridRecvKey; + public string DefaultStartupMsg; + + public UserProfileManager() + { + + } + + public void SetKeys(string sendKey, string recvKey, string url, string message) + { + GridRecvKey = recvKey; + GridSendKey = sendKey; + GridURL = url; + DefaultStartupMsg = message; + } + + public virtual string ParseXMLRPC(string requestBody) + { + XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); + + Hashtable requestData = (Hashtable)request.Params[0]; + switch (request.MethodName) + { + case "login_to_simulator": + bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); + bool GoodLogin = false; + string firstname = ""; + string lastname = ""; + string passwd = ""; + + if (GoodXML) + { + firstname = (string)requestData["first"]; + lastname = (string)requestData["last"]; + passwd = (string)requestData["passwd"]; + GoodLogin = AuthenticateUser(firstname, lastname, passwd); + } + + + if (!(GoodXML && GoodLogin)) + { + XmlRpcResponse LoginErrorResp = new XmlRpcResponse(); + Hashtable ErrorRespData = new Hashtable(); + ErrorRespData["reason"] = "key"; + ErrorRespData["message"] = "Error connecting to grid. Please double check your login details and check with the grid owner if you are sure these are correct"; + ErrorRespData["login"] = "false"; + LoginErrorResp.Value = ErrorRespData; + return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(LoginErrorResp), " encoding=\"utf-16\"", "")); + } + + UserProfile TheUser = GetProfileByName(firstname, lastname); + + if (!((TheUser.CurrentSessionID == null) && (TheUser.CurrentSecureSessionID == null))) + { + XmlRpcResponse PresenceErrorResp = new XmlRpcResponse(); + Hashtable PresenceErrorRespData = new Hashtable(); + PresenceErrorRespData["reason"] = "presence"; + PresenceErrorRespData["message"] = "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"; + PresenceErrorRespData["login"] = "false"; + PresenceErrorResp.Value = PresenceErrorRespData; + return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", "")); + + } + + try + { + LLUUID AgentID = TheUser.UUID; + TheUser.InitSessionData(); + // SimProfile SimInfo = new SimProfile(); + // SimInfo = SimInfo.LoadFromGrid(TheUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey); + + XmlRpcResponse LoginGoodResp = new XmlRpcResponse(); + Hashtable LoginGoodData = new Hashtable(); + + Hashtable GlobalT = new Hashtable(); + GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271"; + GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; + GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; + ArrayList GlobalTextures = new ArrayList(); + GlobalTextures.Add(GlobalT); + + Hashtable LoginFlagsHash = new Hashtable(); + LoginFlagsHash["daylight_savings"] = "N"; + LoginFlagsHash["stipend_since_login"] = "N"; + LoginFlagsHash["gendered"] = "Y"; + LoginFlagsHash["ever_logged_in"] = "Y"; + ArrayList LoginFlags = new ArrayList(); + LoginFlags.Add(LoginFlagsHash); + + Hashtable uiconfig = new Hashtable(); + uiconfig["allow_first_life"] = "Y"; + ArrayList ui_config = new ArrayList(); + ui_config.Add(uiconfig); + + Hashtable ClassifiedCategoriesHash = new Hashtable(); + ClassifiedCategoriesHash["category_name"] = "bla bla"; + ClassifiedCategoriesHash["category_id"] = (Int32)1; + ArrayList ClassifiedCategories = new ArrayList(); + ClassifiedCategories.Add(ClassifiedCategoriesHash); + + ArrayList AgentInventory = new ArrayList(); + foreach (InventoryFolder InvFolder in TheUser.Inventory.InventoryFolders.Values) + { + Hashtable TempHash = new Hashtable(); + TempHash["name"] = InvFolder.FolderName; + TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); + TempHash["version"] = (Int32)InvFolder.Version; + TempHash["type_default"] = (Int32)InvFolder.DefaultType; + TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); + AgentInventory.Add(TempHash); + } + + Hashtable InventoryRootHash = new Hashtable(); + InventoryRootHash["folder_id"] = TheUser.Inventory.InventoryRoot.FolderID.ToStringHyphenated(); + ArrayList InventoryRoot = new ArrayList(); + InventoryRoot.Add(InventoryRootHash); + + Hashtable InitialOutfitHash = new Hashtable(); + InitialOutfitHash["folder_name"] = "Nightclub Female"; + InitialOutfitHash["gender"] = "female"; + ArrayList InitialOutfit = new ArrayList(); + InitialOutfit.Add(InitialOutfitHash); + + uint circode = (uint)(Util.RandomClass.Next()); + //TheUser.AddSimCircuit(circode, SimInfo.UUID); + + LoginGoodData["last_name"] = "\"" + TheUser.firstname + "\""; + LoginGoodData["ui-config"] = ui_config; + LoginGoodData["sim_ip"] = "127.0.0.1"; //SimInfo.sim_ip.ToString(); + LoginGoodData["login-flags"] = LoginFlags; + LoginGoodData["global-textures"] = GlobalTextures; + LoginGoodData["classified_categories"] = ClassifiedCategories; + LoginGoodData["event_categories"] = new ArrayList(); + LoginGoodData["inventory-skeleton"] = AgentInventory; + LoginGoodData["inventory-skel-lib"] = new ArrayList(); + LoginGoodData["inventory-root"] = InventoryRoot; + LoginGoodData["event_notifications"] = new ArrayList(); + LoginGoodData["gestures"] = new ArrayList(); + LoginGoodData["inventory-lib-owner"] = new ArrayList(); + LoginGoodData["initial-outfit"] = InitialOutfit; + LoginGoodData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + LoginGoodData["start_location"] = "last"; + LoginGoodData["home"] = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + TheUser.homepos.X.ToString() + ",r" + TheUser.homepos.Y.ToString() + ",r" + TheUser.homepos.Z.ToString() + "], 'look_at':[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]}"; + LoginGoodData["message"] = DefaultStartupMsg; + LoginGoodData["first_name"] = "\"" + firstname + "\""; + LoginGoodData["circuit_code"] = (Int32)circode; + LoginGoodData["sim_port"] = 9000; //(Int32)SimInfo.sim_port; + LoginGoodData["secure_session_id"] = TheUser.CurrentSecureSessionID.ToStringHyphenated(); + LoginGoodData["look_at"] = "\n[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]\n"; + LoginGoodData["agent_id"] = AgentID.ToStringHyphenated(); + LoginGoodData["region_y"] = (Int32) 996 * 256; // (Int32)SimInfo.RegionLocY * 256; + LoginGoodData["region_x"] = (Int32) 997 * 256; //SimInfo.RegionLocX * 256; + LoginGoodData["seed_capability"] = null; + LoginGoodData["agent_access"] = "M"; + LoginGoodData["session_id"] = TheUser.CurrentSessionID.ToStringHyphenated(); + LoginGoodData["login"] = "true"; + + this.CustomiseResponse(ref LoginGoodData, TheUser); + LoginGoodResp.Value = LoginGoodData; + //TheUser.SendDataToSim(SimInfo); + return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(LoginGoodResp), "utf-16", "utf-8")); + + } + catch (Exception E) + { + Console.WriteLine(E.ToString()); + } + + break; + } + + return ""; + } + + public virtual void CustomiseResponse(ref Hashtable response, UserProfile theUser) + { + //default method set up to act as ogs user server + SimProfile SimInfo = new SimProfile(); + //get siminfo from grid server + SimInfo = SimInfo.LoadFromGrid(theUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey); + uint circode = (uint)response["circuit_code"]; + theUser.AddSimCircuit(circode, SimInfo.UUID); + response["home"] = "{'region_handle':[r" + (SimInfo.RegionLocX * 256).ToString() + ",r" + (SimInfo.RegionLocY * 256).ToString() + "], 'position':[r" + theUser.homepos.X.ToString() + ",r" + theUser.homepos.Y.ToString() + ",r" + theUser.homepos.Z.ToString() + "], 'look_at':[r" + theUser.homelookat.X.ToString() + ",r" + theUser.homelookat.Y.ToString() + ",r" + theUser.homelookat.Z.ToString() + "]}"; + response["sim_ip"] = SimInfo.sim_ip.ToString(); + response["sim_port"] = (Int32)SimInfo.sim_port; + response["region_y"] = (Int32) SimInfo.RegionLocY * 256; + response["region_x"] = (Int32) SimInfo.RegionLocX * 256; + + //default is ogs user server, so let the sim know about the user via a XmlRpcRequest + Console.WriteLine(SimInfo.caps_url); + Hashtable SimParams = new Hashtable(); + SimParams["session_id"] = theUser.CurrentSessionID.ToString(); + SimParams["secure_session_id"] = theUser.CurrentSecureSessionID.ToString(); + SimParams["firstname"] = theUser.firstname; + SimParams["lastname"] = theUser.lastname; + SimParams["agent_id"] = theUser.UUID.ToString(); + SimParams["circuit_code"] = (Int32)theUser.Circuits[SimInfo.UUID]; + ArrayList SendParams = new ArrayList(); + SendParams.Add(SimParams); + + XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); + XmlRpcResponse GridResp = GridReq.Send(SimInfo.caps_url, 3000); + } + } +} diff --git a/OpenSim.Framework/UserProfileManagerBase.cs b/OpenSim.Framework/UserProfileManagerBase.cs new file mode 100644 index 0000000000..ad03bc23d2 --- /dev/null +++ b/OpenSim.Framework/UserProfileManagerBase.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Inventory; + +namespace OpenSim.Framework.User +{ + public class UserProfileManagerBase + { + + public Dictionary UserProfiles = new Dictionary(); + + public UserProfileManagerBase() + { + } + + public virtual void InitUserProfiles() + { + // TODO: need to load from database + } + + public UserProfile GetProfileByName(string firstname, string lastname) + { + foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys) + { + if ((UserProfiles[UUID].firstname == firstname) && (UserProfiles[UUID].lastname == lastname)) + { + return UserProfiles[UUID]; + } + } + return null; + } + + public UserProfile GetProfileByLLUUID(LLUUID ProfileLLUUID) + { + return UserProfiles[ProfileLLUUID]; + } + + public virtual bool AuthenticateUser(string firstname, string lastname, string passwd) + { + UserProfile TheUser = GetProfileByName(firstname, lastname); + if (TheUser != null) + { + if (TheUser.MD5passwd == passwd) + { + return true; + } + else + { + return false; + } + } + else + { + return false; + } + + } + + public void SetGod(LLUUID GodID) + { + this.UserProfiles[GodID].IsGridGod = true; + } + + public virtual UserProfile CreateNewProfile(string firstname, string lastname, string MD5passwd) + { + UserProfile newprofile = new UserProfile(); + newprofile.homeregionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256)); + newprofile.firstname = firstname; + newprofile.lastname = lastname; + newprofile.MD5passwd = MD5passwd; + newprofile.UUID = LLUUID.Random(); + this.UserProfiles.Add(newprofile.UUID, newprofile); + return newprofile; + } + + public virtual AgentInventory GetUsersInventory(LLUUID agentID) + { + UserProfile user = this.GetProfileByLLUUID(agentID); + if (user != null) + { + return user.Inventory; + } + + return null; + } + + } +} diff --git a/OpenSim.Framework/Util.cs b/OpenSim.Framework/Util.cs new file mode 100644 index 0000000000..042360d094 --- /dev/null +++ b/OpenSim.Framework/Util.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace OpenSim.Framework.Utilities +{ + public class Util + { + private static Random randomClass = new Random(); + + public static ulong UIntsToLong(uint X, uint Y) + { + return Helpers.UIntsToLong(X, Y); + } + + public static Random RandomClass + { + get + { + return randomClass; + } + } + + public Util() + { + + } + } + +} diff --git a/OpenSim.GridInterfaces/Local/AssemblyInfo.cs b/OpenSim.GridInterfaces/Local/AssemblyInfo.cs new file mode 100644 index 0000000000..103b49a207 --- /dev/null +++ b/OpenSim.GridInterfaces/Local/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("LocalGridServers")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("LocalGridServers")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] diff --git a/OpenSim.GridInterfaces/Local/LocalAssetServer.cs b/OpenSim.GridInterfaces/Local/LocalAssetServer.cs new file mode 100644 index 0000000000..6cd954a037 --- /dev/null +++ b/OpenSim.GridInterfaces/Local/LocalAssetServer.cs @@ -0,0 +1,208 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; +using System.IO; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; +using OpenSim.Framework.Utilities; +using libsecondlife; +using Db4objects.Db4o; +using Db4objects.Db4o.Query; + +namespace OpenSim.GridInterfaces.Local +{ + public class LocalAssetPlugin : IAssetPlugin + { + public LocalAssetPlugin() + { + + } + + public IAssetServer GetAssetServer() + { + return (new LocalAssetServer()); + } + } + + public class LocalAssetServer : IAssetServer + { + private IAssetReceiver _receiver; + private BlockingQueue _assetRequests; + private IObjectContainer db; + private Thread _localAssetServerThread; + + public LocalAssetServer() + { + bool yapfile; + this._assetRequests = new BlockingQueue(); + yapfile = System.IO.File.Exists("assets.yap"); + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Local Asset Server class created"); + try + { + db = Db4oFactory.OpenFile("assets.yap"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Db4 Asset database creation"); + } + catch (Exception e) + { + db.Close(); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Db4 Asset server :Constructor - Exception occured"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString()); + } + if (!yapfile) + { + this.SetUpAssetDatabase(); + } + this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); + this._localAssetServerThread.IsBackground = true; + this._localAssetServerThread.Start(); + + } + + public void SetReceiver(IAssetReceiver receiver) + { + this._receiver = receiver; + } + + public void RequestAsset(LLUUID assetID, bool isTexture) + { + ARequest req = new ARequest(); + req.AssetID = assetID; + req.IsTexture = isTexture; + this._assetRequests.Enqueue(req); + } + + public void UpdateAsset(AssetBase asset) + { + + } + + public void UploadNewAsset(AssetBase asset) + { + AssetStorage store = new AssetStorage(); + store.Data = asset.Data; + store.Name = asset.Name; + store.UUID = asset.FullID; + db.Set(store); + db.Commit(); + } + + public void SetServerInfo(string ServerUrl, string ServerKey) + { + + } + public void Close() + { + if (db != null) + { + Console.WriteLine("Closing local Asset server database"); + db.Close(); + } + } + + private void RunRequests() + { + while (true) + { + byte[] idata = null; + bool found = false; + AssetStorage foundAsset = null; + ARequest req = this._assetRequests.Dequeue(); + IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); + if (result.Count > 0) + { + foundAsset = (AssetStorage)result.Next(); + found = true; + } + + AssetBase asset = new AssetBase(); + if (found) + { + asset.FullID = foundAsset.UUID; + asset.Type = foundAsset.Type; + asset.InvType = foundAsset.Type; + asset.Name = foundAsset.Name; + idata = foundAsset.Data; + } + else + { + asset.FullID = LLUUID.Zero; + } + asset.Data = idata; + _receiver.AssetReceived(asset, req.IsTexture); + } + + } + + private void SetUpAssetDatabase() + { + Console.WriteLine("setting up Asset database"); + + AssetBase Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); + Image.Name = "test Texture"; + this.LoadAsset(Image, true, "testpic2.jp2"); + AssetStorage store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); + Image.Name = "test Texture2"; + this.LoadAsset(Image, true, "map_base.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); + Image.Name = "Prim Base Texture"; + this.LoadAsset(Image, true, "testpic2.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); + Image.Name = "Shape"; + this.LoadAsset(Image, false, "base_shape.dat"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + + } + + private void LoadAsset(AssetBase info, bool image, string filename) + { + //should request Asset from storage manager + //but for now read from file + + string dataPath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; + string fileName = Path.Combine(dataPath, filename); + FileInfo fInfo = new FileInfo(fileName); + long numBytes = fInfo.Length; + FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); + byte[] idata = new byte[numBytes]; + BinaryReader br = new BinaryReader(fStream); + idata = br.ReadBytes((int)numBytes); + br.Close(); + fStream.Close(); + info.Data = idata; + //info.loaded=true; + } + } +} diff --git a/src/LocalServers/LocalGridServers/LocalGrid.cs b/OpenSim.GridInterfaces/Local/LocalGridServer.cs similarity index 59% rename from src/LocalServers/LocalGridServers/LocalGrid.cs rename to OpenSim.GridInterfaces/Local/LocalGridServer.cs index bd377d3431..d70e989573 100644 --- a/src/LocalServers/LocalGridServers/LocalGrid.cs +++ b/OpenSim.GridInterfaces/Local/LocalGridServer.cs @@ -27,10 +27,14 @@ using System; using System.Collections.Generic; using System.Threading; -using OpenSim.GridServers; +using System.IO; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; using libsecondlife; +using Db4objects.Db4o; +using Db4objects.Db4o.Query; -namespace LocalGridServers +namespace OpenSim.GridInterfaces.Local { /// /// @@ -49,86 +53,26 @@ namespace LocalGridServers } } - public class LocalAssetPlugin : IAssetPlugin - { - public LocalAssetPlugin() - { - - } - - public IAssetServer GetAssetServer() - { - return(new LocalAssetServer()); - } - } - - public class LocalAssetServer : IAssetServer - { - private IAssetReceiver _receiver; - private BlockingQueue _assetRequests; - - public LocalAssetServer() - { - this._assetRequests = new BlockingQueue(); - ServerConsole.MainConsole.Instance.WriteLine("Local Asset Server class created"); - } - - public void SetReceiver(IAssetReceiver receiver) - { - this._receiver = receiver; - } - - public void RequestAsset(LLUUID assetID, bool isTexture) - { - ARequest req = new ARequest(); - req.AssetID = assetID; - req.IsTexture = isTexture; - //this._assetRequests.Enqueue(req); - } - - public void UpdateAsset(AssetBase asset) - { - - } - - public void UploadNewAsset(AssetBase asset) - { - - } - - public void SetServerInfo(string ServerUrl, string SendKey) - { - - } - - private void RunRequests() - { - while(true) - { - Thread.Sleep(1000); - } - } - } - public class LocalGridServer : LocalGridBase { public List Sessions = new List(); - + public LocalGridServer() { Sessions = new List(); - ServerConsole.MainConsole.Instance.WriteLine("Local Grid Server class created"); - } - - public override string GetName() - { - return "Local"; + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Local Grid Server class created"); } public override bool RequestConnection() { return true; } + + public override string GetName() + { + return "Local"; + } + public override AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) { //we are running local @@ -159,17 +103,22 @@ namespace LocalGridServers UUIDBlock uuidBlock = new UUIDBlock(); return(uuidBlock); } - - public override neighbourinfo[] RequestNeighbours(ulong regionhandle) + + public override NeighbourInfo[] RequestNeighbours() { - return new neighbourinfo[8]; + return null; } - - public override void SetServerInfo(string GridServerUrl, string GridSendKey, string GridRecvKey, string UserServerUrl, string UserSendKey, string UserRecvKey) + + public override void SetServerInfo(string ServerUrl, string SendKey, string RecvKey) { } + public override void Close() + { + + } + /// /// used by the local login server to inform us of new sessions /// @@ -182,30 +131,26 @@ namespace LocalGridServers } } } - - public class BlockingQueue< T > { - private Queue< T > _queue = new Queue< T >(); - private object _queueSync = new object(); - public void Enqueue(T value) + public class AssetUUIDQuery : Predicate + { + private LLUUID _findID; + + public AssetUUIDQuery(LLUUID find) { - lock(_queueSync) - { - _queue.Enqueue(value); - Monitor.Pulse(_queueSync); - } + _findID = find; } - - public T Dequeue() + public bool Match(AssetStorage asset) { - lock(_queueSync) - { - if( _queue.Count < 1) - Monitor.Wait(_queueSync); - - return _queue.Dequeue(); - } + return (asset.UUID == _findID); } } - + + public class AssetStorage + { + public byte[] Data; + public sbyte Type; + public string Name; + public LLUUID UUID; + } } diff --git a/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj b/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj new file mode 100644 index 0000000000..b3318afa75 --- /dev/null +++ b/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj @@ -0,0 +1,104 @@ + + + Local + 8.0.50727 + 2.0 + {FBF3DA4B-5176-4602-AA52-482D077EEC88} + Debug + AnyCPU + + + + OpenSim.GridInterfaces.Local + JScript + Grid + IE50 + false + Library + + OpenSim.GridInterfaces.Local + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\ + False + False + False + 4 + + + + + \System.dll + + + \System.Xml.dll.dll + + + \Db4objects.Db4o.dll.dll + + + \libsecondlife.dll.dll + + + + + OpenSim.Framework + {1D2865A9-CF8E-45F7-B96D-91ED128A32CF} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + OpenSim.Framework.Console + {C8405E1A-EC19-48B6-9C8C-CA03624B9916} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.dll.build b/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.dll.build new file mode 100644 index 0000000000..eff1fac7ae --- /dev/null +++ b/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.dll.build @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.GridInterfaces/Remote/AssemblyInfo.cs b/OpenSim.GridInterfaces/Remote/AssemblyInfo.cs new file mode 100644 index 0000000000..0fa7d6ea66 --- /dev/null +++ b/OpenSim.GridInterfaces/Remote/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("RemoteGridServers")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("RemoteGridServers")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] diff --git a/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj b/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj new file mode 100644 index 0000000000..37d1d12f2c --- /dev/null +++ b/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj @@ -0,0 +1,101 @@ + + + Local + 8.0.50727 + 2.0 + {2AF1E37E-064D-4590-8D7E-B6390F721BAE} + Debug + AnyCPU + + + + OpenSim.GridInterfaces.Remote + JScript + Grid + IE50 + false + Library + + OpenSim.GridInterfaces.Remote + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\ + False + False + False + 4 + + + + + \System.dll + + + \System.Xml.dll.dll + + + \libsecondlife.dll.dll + + + + + OpenSim.Framework + {1D2865A9-CF8E-45F7-B96D-91ED128A32CF} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + OpenSim.Framework.Console + {C8405E1A-EC19-48B6-9C8C-CA03624B9916} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.dll.build b/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.dll.build new file mode 100644 index 0000000000..e0d24ffc22 --- /dev/null +++ b/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.dll.build @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.GridInterfaces/Remote/RemoteAssetServer.cs b/OpenSim.GridInterfaces/Remote/RemoteAssetServer.cs new file mode 100644 index 0000000000..528e9fa680 --- /dev/null +++ b/OpenSim.GridInterfaces/Remote/RemoteAssetServer.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; +using System.Net; +using System.Net.Sockets; +using System.IO; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; +using OpenSim.Framework.Utilities; + +namespace OpenSim.GridInterfaces.Remote +{ + public class RemoteAssetServer : IAssetServer + { + private IAssetReceiver _receiver; + private BlockingQueue _assetRequests; + private Thread _remoteAssetServerThread; + private string AssetServerUrl; + private string AssetSendKey; + + public RemoteAssetServer() + { + this._assetRequests = new BlockingQueue(); + this._remoteAssetServerThread = new Thread(new ThreadStart(RunRequests)); + this._remoteAssetServerThread.IsBackground = true; + this._remoteAssetServerThread.Start(); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Remote Asset Server class created"); + } + + public void SetReceiver(IAssetReceiver receiver) + { + this._receiver = receiver; + } + + public void RequestAsset(LLUUID assetID, bool isTexture) + { + ARequest req = new ARequest(); + req.AssetID = assetID; + req.IsTexture = isTexture; + this._assetRequests.Enqueue(req); + } + + public void UpdateAsset(AssetBase asset) + { + + } + + public void UploadNewAsset(AssetBase asset) + { + + } + + public void SetServerInfo(string ServerUrl, string ServerKey) + { + this.AssetServerUrl = ServerUrl; + this.AssetSendKey = ServerKey; + } + + private void RunRequests() + { + while (true) + { + //we need to add support for the asset server not knowing about a requested asset + ARequest req = this._assetRequests.Dequeue(); + LLUUID assetID = req.AssetID; + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(" RemoteAssetServer- Got a AssetServer request, processing it"); + WebRequest AssetLoad = WebRequest.Create(this.AssetServerUrl + "getasset/" + AssetSendKey + "/" + assetID + "/data"); + WebResponse AssetResponse = AssetLoad.GetResponse(); + byte[] idata = new byte[(int)AssetResponse.ContentLength]; + BinaryReader br = new BinaryReader(AssetResponse.GetResponseStream()); + idata = br.ReadBytes((int)AssetResponse.ContentLength); + br.Close(); + + AssetBase asset = new AssetBase(); + asset.FullID = assetID; + asset.Data = idata; + _receiver.AssetReceived(asset, req.IsTexture); + } + } + + public void Close() + { + + } + } + + public class RemoteAssetPlugin : IAssetPlugin + { + public RemoteAssetPlugin() + { + + } + + public IAssetServer GetAssetServer() + { + return (new RemoteAssetServer()); + } + } + +} diff --git a/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs b/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs new file mode 100644 index 0000000000..5f4891638a --- /dev/null +++ b/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs @@ -0,0 +1,156 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Net; +using System.Net.Sockets; +using System.IO; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; + +namespace OpenSim.GridInterfaces.Remote +{ + public class RemoteGridServer : RemoteGridBase + { + private string GridServerUrl; + private string GridSendKey; + private string GridRecvKey; + private Dictionary AgentCircuits = new Dictionary(); + + public override Dictionary agentcircuits + { + get { return AgentCircuits; } + set { AgentCircuits = value; } + } + + public RemoteGridServer() + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Remote Grid Server class created"); + } + + public override bool RequestConnection() + { + return true; + } + + public override AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode) + { + AgentCircuitData validcircuit = null; + if (this.AgentCircuits.ContainsKey(circuitcode)) + { + validcircuit = this.AgentCircuits[circuitcode]; + } + AuthenticateResponse user = new AuthenticateResponse(); + if (validcircuit == null) + { + //don't have this circuit code in our list + user.Authorised = false; + return (user); + } + + if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID)) + { + // YAY! Valid login + user.Authorised = true; + user.LoginInfo = new Login(); + user.LoginInfo.Agent = agentID; + user.LoginInfo.Session = sessionID; + user.LoginInfo.SecureSession = validcircuit.SecureSessionID; + user.LoginInfo.First = validcircuit.firstname; + user.LoginInfo.Last = validcircuit.lastname; + } + else + { + // Invalid + user.Authorised = false; + } + + return (user); + } + + public override bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) + { + WebRequest DeleteSession = WebRequest.Create(GridServerUrl + "/usersessions/" + sessionID.ToString()); + DeleteSession.Method = "DELETE"; + DeleteSession.ContentType = "text/plaintext"; + DeleteSession.ContentLength = 0; + + StreamWriter stOut = new StreamWriter(DeleteSession.GetRequestStream(), System.Text.Encoding.ASCII); + stOut.Write(""); + stOut.Close(); + + StreamReader stIn = new StreamReader(DeleteSession.GetResponse().GetResponseStream()); + string GridResponse = stIn.ReadToEnd(); + stIn.Close(); + return (true); + } + + public override UUIDBlock RequestUUIDBlock() + { + UUIDBlock uuidBlock = new UUIDBlock(); + return (uuidBlock); + } + + public override NeighbourInfo[] RequestNeighbours() + { + return null; + } + + public override void SetServerInfo(string ServerUrl, string SendKey, string RecvKey) + { + this.GridServerUrl = ServerUrl; + this.GridSendKey = SendKey; + this.GridRecvKey = RecvKey; + } + + public override string GetName() + { + return "Remote"; + } + + public override void Close() + { + + } + } + + public class RemoteGridPlugin : IGridPlugin + { + public RemoteGridPlugin() + { + + } + + public IGridServer GetGridServer() + { + return (new RemoteGridServer()); + } + } + +} diff --git a/OpenSim.Physics/BasicPhysicsPlugin/AssemblyInfo.cs b/OpenSim.Physics/BasicPhysicsPlugin/AssemblyInfo.cs new file mode 100644 index 0000000000..0c9c06c43d --- /dev/null +++ b/OpenSim.Physics/BasicPhysicsPlugin/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("PhysXplugin")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PhysXplugin")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] diff --git a/src/physics/plugins/PhysXplugin.cs b/OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs similarity index 81% rename from src/physics/plugins/PhysXplugin.cs rename to OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index 8c09dc8a89..deff80349c 100644 --- a/src/physics/plugins/PhysXplugin.cs +++ b/OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs @@ -26,18 +26,18 @@ */ using System; using System.Collections.Generic; -using PhysicsSystem; +using OpenSim.Physics.Manager; -namespace PhysXplugin +namespace OpenSim.Physics.BasicPhysicsPlugin { /// /// Will be the PhysX plugin but for now will be a very basic physics engine /// - public class PhysXPlugin : IPhysicsPlugin + public class BasicPhysicsPlugin : IPhysicsPlugin { - private PhysXScene _mScene; + private BasicScene _mScene; - public PhysXPlugin() + public BasicPhysicsPlugin() { } @@ -51,14 +51,14 @@ namespace PhysXplugin { if(_mScene == null) { - _mScene = new PhysXScene(); + _mScene = new BasicScene(); } return(_mScene); } public string GetName() { - return("PhysX"); + return("basicphysics"); } public void Dispose() @@ -67,19 +67,19 @@ namespace PhysXplugin } } - public class PhysXScene :PhysicsScene + public class BasicScene :PhysicsScene { - private List _actors = new List(); + private List _actors = new List(); private float[] _heightMap; - public PhysXScene() + public BasicScene() { } public override PhysicsActor AddAvatar(PhysicsVector position) { - PhysXActor act = new PhysXActor(); + BasicActor act = new BasicActor(); act.Position = position; _actors.Add(act); return act; @@ -92,7 +92,7 @@ namespace PhysXplugin public override void Simulate(float timeStep) { - foreach (PhysXActor actor in _actors) + foreach (BasicActor actor in _actors) { actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep); actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep); @@ -151,13 +151,13 @@ namespace PhysXplugin } } - public class PhysXActor : PhysicsActor + public class BasicActor : PhysicsActor { private PhysicsVector _position; private PhysicsVector _velocity; private PhysicsVector _acceleration; private bool flying; - public PhysXActor() + public BasicActor() { _velocity = new PhysicsVector(); _position = new PhysicsVector(); @@ -200,6 +200,18 @@ namespace PhysXplugin } } + public override Axiom.MathLib.Quaternion Orientation + { + get + { + return Axiom.MathLib.Quaternion.Identity; + } + set + { + + } + } + public override PhysicsVector Acceleration { get @@ -208,6 +220,18 @@ namespace PhysXplugin } } + + public override bool Kinematic + { + get + { + return true; + } + set + { + + } + } public void SetAcceleration (PhysicsVector accel) { this._acceleration = accel; diff --git a/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj b/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj new file mode 100644 index 0000000000..dbfebd3523 --- /dev/null +++ b/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj @@ -0,0 +1,90 @@ + + + Local + 8.0.50727 + 2.0 + {00594B9E-29A5-4B9C-AEBD-0AD08C73CFE8} + Debug + AnyCPU + + + + OpenSim.Physics.BasicPhysicsPlugin + JScript + Grid + IE50 + false + Library + + OpenSim.Physics.BasicPhysicsPlugin + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\Physics\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\Physics\ + False + False + False + 4 + + + + + \System.dll + + + \Axiom.MathLib.dll.dll + + + + + OpenSim.Physics.Manager + {58360A80-9333-4E0F-8F83-3CF937E51633} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj.user b/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj.user new file mode 100644 index 0000000000..13e65a84bd --- /dev/null +++ b/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\Documents and Settings\Stefan\My Documents\Projects\source\opensim\branches\zircon\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.dll.build b/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.dll.build new file mode 100644 index 0000000000..f14673337a --- /dev/null +++ b/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.dll.build @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.Physics/Manager/AssemblyInfo.cs b/OpenSim.Physics/Manager/AssemblyInfo.cs new file mode 100644 index 0000000000..57a8913d33 --- /dev/null +++ b/OpenSim.Physics/Manager/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("PhysicsManager")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PhysicsManager")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] diff --git a/OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj b/OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj new file mode 100644 index 0000000000..728686e85d --- /dev/null +++ b/OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj @@ -0,0 +1,102 @@ + + + Local + 8.0.50727 + 2.0 + {58360A80-9333-4E0F-8F83-3CF937E51633} + Debug + AnyCPU + + + + OpenSim.Physics.Manager + JScript + Grid + IE50 + false + Library + + OpenSim.Physics.Manager + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\ + False + False + False + 4 + + + + + \System.dll + + + \System.Xml.dll.dll + + + \Axiom.MathLib.dll.dll + + + + + OpenSim.Framework.Console + {C8405E1A-EC19-48B6-9C8C-CA03624B9916} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.Physics/Manager/OpenSim.Physics.Manager.dll.build b/OpenSim.Physics/Manager/OpenSim.Physics.Manager.dll.build new file mode 100644 index 0000000000..0f6565bf50 --- /dev/null +++ b/OpenSim.Physics/Manager/OpenSim.Physics.Manager.dll.build @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.Physics/Manager/PhysicsActor.cs b/OpenSim.Physics/Manager/PhysicsActor.cs new file mode 100644 index 0000000000..a0b6c21b56 --- /dev/null +++ b/OpenSim.Physics/Manager/PhysicsActor.cs @@ -0,0 +1,161 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Physics.Manager +{ + public abstract class PhysicsActor + { + public static PhysicsActor Null + { + get + { + return new NullPhysicsActor(); + } + } + + public abstract PhysicsVector Position + { + get; + set; + } + + public abstract PhysicsVector Velocity + { + get; + set; + } + + public abstract PhysicsVector Acceleration + { + get; + } + + public abstract Axiom.MathLib.Quaternion Orientation + { + get; + set; + } + + public abstract bool Flying + { + get; + set; + } + + public abstract bool Kinematic + { + get; + set; + } + + public abstract void AddForce(PhysicsVector force); + + public abstract void SetMomentum(PhysicsVector momentum); + } + + public class NullPhysicsActor : PhysicsActor + { + public override PhysicsVector Position + { + get + { + return PhysicsVector.Zero; + } + set + { + return; + } + } + + public override PhysicsVector Velocity + { + get + { + return PhysicsVector.Zero; + } + set + { + return; + } + } + + public override Axiom.MathLib.Quaternion Orientation + { + get + { + return Axiom.MathLib.Quaternion.Identity; + } + set + { + + } + } + + public override PhysicsVector Acceleration + { + get { return PhysicsVector.Zero; } + } + + public override bool Flying + { + get + { + return false; + } + set + { + return; + } + } + + public override bool Kinematic + { + get + { + return true; + } + set + { + return; + } + } + + public override void AddForce(PhysicsVector force) + { + return; + } + + public override void SetMomentum(PhysicsVector momentum) + { + return; + } + } +} diff --git a/OpenSim.Physics/Manager/PhysicsManager.cs b/OpenSim.Physics/Manager/PhysicsManager.cs new file mode 100644 index 0000000000..616682b0da --- /dev/null +++ b/OpenSim.Physics/Manager/PhysicsManager.cs @@ -0,0 +1,116 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Collections; +using System.IO; +using System.Reflection; +using Axiom.MathLib; + +namespace OpenSim.Physics.Manager +{ + /// + /// Description of MyClass. + /// + public class PhysicsManager + { + private Dictionary _plugins=new Dictionary(); + + public PhysicsManager() + { + + } + + public PhysicsScene GetPhysicsScene(string engineName) + { + if (String.IsNullOrEmpty(engineName)) + { + return new NullPhysicsScene(); + } + + if(_plugins.ContainsKey(engineName)) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("creating "+engineName); + return _plugins[engineName].GetScene(); + } + else + { + string error = String.Format("couldn't find physicsEngine: {0}", engineName); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(error); + throw new ArgumentException(error); + } + } + + public void LoadPlugins() + { + string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory ,"Physics"); + string[] pluginFiles = Directory.GetFiles(path, "*.dll"); + + + for(int i= 0; i nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Physics.Manager +{ + public abstract class PhysicsScene + { + public static PhysicsScene Null + { + get + { + return new NullPhysicsScene(); + } + } + + public abstract PhysicsActor AddAvatar(PhysicsVector position); + + public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size); + + public abstract void Simulate(float timeStep); + + public abstract void GetResults(); + + public abstract void SetTerrain(float[] heightMap); + + public abstract bool IsThreaded + { + get; + } + } + + public class NullPhysicsScene : PhysicsScene + { + private static int m_workIndicator; + + public override PhysicsActor AddAvatar(PhysicsVector position) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("NullPhysicsScene : AddAvatar({0})", position); + return PhysicsActor.Null; + } + + public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("NullPhysicsScene : AddPrim({0},{1})", position, size); + return PhysicsActor.Null; + } + + public override void Simulate(float timeStep) + { + m_workIndicator = (m_workIndicator + 1) % 10; + + OpenSim.Framework.Console.MainConsole.Instance.SetStatus(m_workIndicator.ToString()); + } + + public override void GetResults() + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("NullPhysicsScene : GetResults()"); + } + + public override void SetTerrain(float[] heightMap) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("NullPhysicsScene : SetTerrain({0} items)", heightMap.Length); + } + + public override bool IsThreaded + { + get { return false; } + } + } +} diff --git a/OpenSim.Physics/Manager/PhysicsVector.cs b/OpenSim.Physics/Manager/PhysicsVector.cs new file mode 100644 index 0000000000..3c824d010d --- /dev/null +++ b/OpenSim.Physics/Manager/PhysicsVector.cs @@ -0,0 +1,54 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Physics.Manager +{ + public class PhysicsVector + { + public float X; + public float Y; + public float Z; + + public PhysicsVector() + { + + } + + public PhysicsVector(float x, float y, float z) + { + X = x; + Y = y; + Z = z; + } + + public static readonly PhysicsVector Zero = new PhysicsVector(0f, 0f, 0f); + } +} diff --git a/src/physics/RealPhysX/RealPhysXplugin/AssemblyInfo.cs b/OpenSim.Physics/PhysXPlugin/AssemblyInfo.cs similarity index 100% rename from src/physics/RealPhysX/RealPhysXplugin/AssemblyInfo.cs rename to OpenSim.Physics/PhysXPlugin/AssemblyInfo.cs diff --git a/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj b/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj new file mode 100644 index 0000000000..e1e8eea913 --- /dev/null +++ b/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj @@ -0,0 +1,93 @@ + + + Local + 8.0.50727 + 2.0 + {CBE1E31D-D7E3-4791-A616-F00173BBC26A} + Debug + AnyCPU + + + + OpenSim.Physics.PhysXPlugin + JScript + Grid + IE50 + false + Library + + OpenSim.Physics.PhysXPlugin + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\Physics\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\Physics\ + False + False + False + 4 + + + + + \System.dll + + + \Axiom.MathLib.dll.dll + + + \PhysX_Wrapper_Dotnet.dll.dll + + + + + OpenSim.Physics.Manager + {58360A80-9333-4E0F-8F83-3CF937E51633} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.dll.build b/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.dll.build new file mode 100644 index 0000000000..8f9e7dc80f --- /dev/null +++ b/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.dll.build @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/physics/RealPhysX/RealPhysXplugin/RealPhysX.cs b/OpenSim.Physics/PhysXPlugin/PhysXPlugin.cs similarity index 84% rename from src/physics/RealPhysX/RealPhysXplugin/RealPhysX.cs rename to OpenSim.Physics/PhysXPlugin/PhysXPlugin.cs index 9576a40e91..043c2f1ec0 100644 --- a/src/physics/RealPhysX/RealPhysXplugin/RealPhysX.cs +++ b/OpenSim.Physics/PhysXPlugin/PhysXPlugin.cs @@ -52,10 +52,10 @@ */ using System; using System.Collections.Generic; -using PhysicsSystem; +using OpenSim.Physics.Manager; using PhysXWrapper; -namespace PhysXplugin +namespace OpenSim.Physics.PhysXPlugin { /// /// Will be the PhysX plugin but for now will be a very basic physics engine @@ -105,6 +105,7 @@ namespace PhysXplugin public PhysXScene() { mySdk = NxPhysicsSDK.CreateSDK(); + Console.WriteLine("Sdk created - now creating scene"); scene = mySdk.CreateScene(); } @@ -179,6 +180,7 @@ namespace PhysXplugin private PhysicsVector _acceleration; private NxCharacter _character; private bool flying; + private float gravityAccel; public PhysXCharacter(NxCharacter character) { @@ -224,6 +226,30 @@ namespace PhysXplugin } } + public override bool Kinematic + { + get + { + return false; + } + set + { + + } + } + + public override Axiom.MathLib.Quaternion Orientation + { + get + { + return Axiom.MathLib.Quaternion.Identity; + } + set + { + + } + } + public override PhysicsVector Acceleration { get @@ -258,9 +284,14 @@ namespace PhysXplugin } else { - vec.Z = (-9.8f + this._velocity.Z) * timeStep; + gravityAccel+= -9.8f; + vec.Z = (gravityAccel + this._velocity.Z) * timeStep; + } + int res = this._character.Move(vec); + if(res == 1) + { + gravityAccel = 0; } - this._character.Move(vec); } public void UpdatePosition() @@ -332,6 +363,36 @@ namespace PhysXplugin } } + public override bool Kinematic + { + get + { + return this._prim.Kinematic; + } + set + { + this._prim.Kinematic = value; + } + } + + public override Axiom.MathLib.Quaternion Orientation + { + get + { + Axiom.MathLib.Quaternion res = new Axiom.MathLib.Quaternion(); + PhysXWrapper.Quaternion quat = this._prim.GetOrientation(); + res.w = quat.W; + res.x = quat.X; + res.y = quat.Y; + res.z = quat.Z; + return res; + } + set + { + + } + } + public override PhysicsVector Acceleration { get diff --git a/OpenSim.RegionServer/Assets/AssetCache.cs b/OpenSim.RegionServer/Assets/AssetCache.cs new file mode 100644 index 0000000000..f7f2e10dc3 --- /dev/null +++ b/OpenSim.RegionServer/Assets/AssetCache.cs @@ -0,0 +1,589 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using System.Collections.Generic; +using System.Threading; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Assets +{ + /// + /// Manages local cache of assets and their sending to viewers. + /// + public class AssetCache : IAssetReceiver + { + public Dictionary Assets; + public Dictionary Textures; + + public List AssetRequests = new List(); //assets ready to be sent to viewers + public List TextureRequests = new List(); //textures ready to be sent + + public Dictionary RequestedAssets = new Dictionary(); //Assets requested from the asset server + public Dictionary RequestedTextures = new Dictionary(); //Textures requested from the asset server + + //private Dictionary IncomingAssets; + + private IAssetServer _assetServer; + private Thread _assetCacheThread; + private LLUUID[] textureList = new LLUUID[2]; + + /// + /// + /// + public AssetCache(IAssetServer assetServer) + { + Console.WriteLine("Creating Asset cache"); + _assetServer = assetServer; + _assetServer.SetReceiver(this); + Assets = new Dictionary(); + Textures = new Dictionary(); + //IncomingAssets = new Dictionary(); + this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); + this._assetCacheThread.IsBackground = true; + this._assetCacheThread.Start(); + + } + + /// + /// + /// + public void RunAssetManager() + { + while (true) + { + try + { + //Console.WriteLine("Asset cache loop"); + this.ProcessAssetQueue(); + this.ProcessTextureQueue(); + Thread.Sleep(500); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + } + } + + public void LoadDefaultTextureSet() + { + //hack: so we can give each user a set of textures + textureList[0] = new LLUUID("00000000-0000-0000-9999-000000000001"); + textureList[1] = new LLUUID("00000000-0000-0000-9999-000000000002"); + for (int i = 0; i < textureList.Length; i++) + { + this._assetServer.RequestAsset(textureList[i], true); + } + + } + + public AssetBase[] CreateNewInventorySet(LLUUID agentID) + { + AssetBase[] inventorySet = new AssetBase[this.textureList.Length]; + for (int i = 0; i < textureList.Length; i++) + { + if (this.Textures.ContainsKey(textureList[i])) + { + inventorySet[i] = this.CloneImage(agentID, this.Textures[textureList[i]]); + TextureImage image = new TextureImage(inventorySet[i]); + this.Textures.Add(image.FullID, image); + this._assetServer.UploadNewAsset(image); //save the asset to the asset server + } + } + return inventorySet; + } + + /// + /// + /// + private void ProcessTextureQueue() + { + if (this.TextureRequests.Count == 0) + { + //no requests waiting + return; + } + int num; + + if (this.TextureRequests.Count < 5) + { + //lower than 5 so do all of them + num = this.TextureRequests.Count; + } + else + { + num = 5; + } + AssetRequest req; + Console.WriteLine("processing texture requests ( " + num + " )"); + for (int i = 0; i < num; i++) + { + req = (AssetRequest)this.TextureRequests[i]; + if (req.PacketCounter != req.NumPackets) + { + // if (req.ImageInfo.FullID == new LLUUID("00000000-0000-0000-5005-000000000005")) + Console.WriteLine("sending base texture ( " + req.ImageInfo.FullID + " ) in " + req.NumPackets + "number of packets"); + + if (req.PacketCounter == 0) + { + //first time for this request so send imagedata packet + if (req.NumPackets == 1) + { + //only one packet so send whole file + ImageDataPacket im = new ImageDataPacket(); + im.ImageID.Packets = 1; + im.ImageID.ID = req.ImageInfo.FullID; + im.ImageID.Size = (uint)req.ImageInfo.Data.Length; + im.ImageData.Data = req.ImageInfo.Data; + im.ImageID.Codec = 2; + req.RequestUser.OutPacket(im); + req.PacketCounter++; + //req.ImageInfo.l= time; + //System.Console.WriteLine("sent texture: "+req.image_info.FullID); + } + else + { + //more than one packet so split file up + ImageDataPacket im = new ImageDataPacket(); + im.ImageID.Packets = (ushort)req.NumPackets; + im.ImageID.ID = req.ImageInfo.FullID; + im.ImageID.Size = (uint)req.ImageInfo.Data.Length; + im.ImageData.Data = new byte[600]; + Array.Copy(req.ImageInfo.Data, 0, im.ImageData.Data, 0, 600); + im.ImageID.Codec = 2; + req.RequestUser.OutPacket(im); + req.PacketCounter++; + //req.ImageInfo.last_used = time; + //System.Console.WriteLine("sent first packet of texture: + } + } + else + { + //send imagepacket + //more than one packet so split file up + ImagePacketPacket im = new ImagePacketPacket(); + im.ImageID.Packet = (ushort)req.PacketCounter; + im.ImageID.ID = req.ImageInfo.FullID; + int size = req.ImageInfo.Data.Length - 600 - 1000 * (req.PacketCounter - 1); + if (size > 1000) size = 1000; + im.ImageData.Data = new byte[size]; + Array.Copy(req.ImageInfo.Data, 600 + 1000 * (req.PacketCounter - 1), im.ImageData.Data, 0, size); + req.RequestUser.OutPacket(im); + req.PacketCounter++; + //req.ImageInfo.last_used = time; + //System.Console.WriteLine("sent a packet of texture: "+req.image_info.FullID); + } + } + } + + //remove requests that have been completed + int count = 0; + for (int i = 0; i < num; i++) + { + if (this.TextureRequests.Count > count) + { + req = (AssetRequest)this.TextureRequests[count]; + if (req.PacketCounter == req.NumPackets) + { + this.TextureRequests.Remove(req); + } + else + { + count++; + } + } + } + + } + public void AssetReceived(AssetBase asset, bool IsTexture) + { + Console.WriteLine("received asset from asset server ( " + asset.FullID + " )"); + if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server + { + //check if it is a texture or not + //then add to the correct cache list + //then check for waiting requests for this asset/texture (in the Requested lists) + //and move those requests into the Requests list. + if (IsTexture) + { + TextureImage image = new TextureImage(asset); + this.Textures.Add(image.FullID, image); + if (this.RequestedTextures.ContainsKey(image.FullID)) + { + AssetRequest req = this.RequestedTextures[image.FullID]; + req.ImageInfo = image; + if (image.Data.LongLength > 600) + { + //over 600 bytes so split up file + req.NumPackets = 1 + (int)(image.Data.Length - 600 + 999) / 1000; + } + else + { + req.NumPackets = 1; + } + this.RequestedTextures.Remove(image.FullID); + this.TextureRequests.Add(req); + } + } + else + { + AssetInfo assetInf = new AssetInfo(asset); + this.Assets.Add(assetInf.FullID, assetInf); + if (this.RequestedAssets.ContainsKey(assetInf.FullID)) + { + AssetRequest req = this.RequestedAssets[assetInf.FullID]; + req.AssetInf = assetInf; + if (assetInf.Data.LongLength > 600) + { + //over 600 bytes so split up file + req.NumPackets = 1 + (int)(assetInf.Data.Length - 600 + 999) / 1000; + } + else + { + req.NumPackets = 1; + } + this.RequestedAssets.Remove(assetInf.FullID); + this.AssetRequests.Add(req); + } + } + } + } + + public void AssetNotFound(AssetBase asset) + { + //the asset server had no knowledge of requested asset + + } + + #region Assets + /// + /// + /// + /// + /// + public void AddAssetRequest(SimClient userInfo, TransferRequestPacket transferRequest) + { + LLUUID requestID = new LLUUID(transferRequest.TransferInfo.Params, 0); + //check to see if asset is in local cache, if not we need to request it from asset server. + if (!this.Assets.ContainsKey(requestID)) + { + //not found asset + // so request from asset server + if (!this.RequestedAssets.ContainsKey(requestID)) + { + AssetRequest request = new AssetRequest(); + request.RequestUser = userInfo; + request.RequestAssetID = requestID; + request.TransferRequestID = transferRequest.TransferInfo.TransferID; + this.RequestedAssets.Add(requestID, request); + this._assetServer.RequestAsset(requestID, false); + } + return; + } + //it is in our cache + AssetInfo asset = this.Assets[requestID]; + + //work out how many packets it should be sent in + // and add to the AssetRequests list + AssetRequest req = new AssetRequest(); + req.RequestUser = userInfo; + req.RequestAssetID = requestID; + req.TransferRequestID = transferRequest.TransferInfo.TransferID; + req.AssetInf = asset; + + if (asset.Data.LongLength > 600) + { + //over 600 bytes so split up file + req.NumPackets = 1 + (int)(asset.Data.Length - 600 + 999) / 1000; + } + else + { + req.NumPackets = 1; + } + + this.AssetRequests.Add(req); + } + + /// + /// + /// + private void ProcessAssetQueue() + { + if (this.AssetRequests.Count == 0) + { + //no requests waiting + return; + } + int num; + + if (this.AssetRequests.Count < 5) + { + //lower than 5 so do all of them + num = this.AssetRequests.Count; + } + else + { + num = 5; + } + AssetRequest req; + for (int i = 0; i < num; i++) + { + req = (AssetRequest)this.AssetRequests[i]; + + TransferInfoPacket Transfer = new TransferInfoPacket(); + Transfer.TransferInfo.ChannelType = 2; + Transfer.TransferInfo.Status = 0; + Transfer.TransferInfo.TargetType = 0; + Transfer.TransferInfo.Params = req.RequestAssetID.GetBytes(); + Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; + Transfer.TransferInfo.TransferID = req.TransferRequestID; + req.RequestUser.OutPacket(Transfer); + + if (req.NumPackets == 1) + { + TransferPacketPacket TransferPacket = new TransferPacketPacket(); + TransferPacket.TransferData.Packet = 0; + TransferPacket.TransferData.ChannelType = 2; + TransferPacket.TransferData.TransferID = req.TransferRequestID; + TransferPacket.TransferData.Data = req.AssetInf.Data; + TransferPacket.TransferData.Status = 1; + req.RequestUser.OutPacket(TransferPacket); + } + else + { + //more than one packet so split file up , for now it can't be bigger than 2000 bytes + TransferPacketPacket TransferPacket = new TransferPacketPacket(); + TransferPacket.TransferData.Packet = 0; + TransferPacket.TransferData.ChannelType = 2; + TransferPacket.TransferData.TransferID = req.TransferRequestID; + byte[] chunk = new byte[1000]; + Array.Copy(req.AssetInf.Data, chunk, 1000); + TransferPacket.TransferData.Data = chunk; + TransferPacket.TransferData.Status = 0; + req.RequestUser.OutPacket(TransferPacket); + + TransferPacket = new TransferPacketPacket(); + TransferPacket.TransferData.Packet = 1; + TransferPacket.TransferData.ChannelType = 2; + TransferPacket.TransferData.TransferID = req.TransferRequestID; + byte[] chunk1 = new byte[(req.AssetInf.Data.Length - 1000)]; + Array.Copy(req.AssetInf.Data, 1000, chunk1, 0, chunk1.Length); + TransferPacket.TransferData.Data = chunk1; + TransferPacket.TransferData.Status = 1; + req.RequestUser.OutPacket(TransferPacket); + } + + } + + //remove requests that have been completed + for (int i = 0; i < num; i++) + { + this.AssetRequests.RemoveAt(0); + } + + } + + public AssetInfo CloneAsset(LLUUID newOwner, AssetInfo sourceAsset) + { + AssetInfo newAsset = new AssetInfo(); + newAsset.Data = new byte[sourceAsset.Data.Length]; + Array.Copy(sourceAsset.Data, newAsset.Data, sourceAsset.Data.Length); + newAsset.FullID = LLUUID.Random(); + newAsset.Type = sourceAsset.Type; + newAsset.InvType = sourceAsset.InvType; + return (newAsset); + } + #endregion + + #region Textures + /// + /// + /// + /// + /// + public void AddTextureRequest(SimClient userInfo, LLUUID imageID) + { + if (imageID == new LLUUID("00000000-0000-0000-5005-000000000005")) + Console.WriteLine("request base prim texture "); + + //check to see if texture is in local cache, if not request from asset server + if (!this.Textures.ContainsKey(imageID)) + { + if (!this.RequestedTextures.ContainsKey(imageID)) + { + //not is cache so request from asset server + AssetRequest request = new AssetRequest(); + request.RequestUser = userInfo; + request.RequestAssetID = imageID; + request.IsTextureRequest = true; + this.RequestedTextures.Add(imageID, request); + this._assetServer.RequestAsset(imageID, true); + } + return; + } + + TextureImage imag = this.Textures[imageID]; + AssetRequest req = new AssetRequest(); + req.RequestUser = userInfo; + req.RequestAssetID = imageID; + req.IsTextureRequest = true; + req.ImageInfo = imag; + + if (imag.Data.LongLength > 600) + { + //over 600 bytes so split up file + req.NumPackets = 1 + (int)(imag.Data.Length - 600 + 999) / 1000; + } + else + { + req.NumPackets = 1; + } + + this.TextureRequests.Add(req); + } + + public TextureImage CloneImage(LLUUID newOwner, TextureImage source) + { + TextureImage newImage = new TextureImage(); + newImage.Data = new byte[source.Data.Length]; + Array.Copy(source.Data, newImage.Data, source.Data.Length); + //newImage.filename = source.filename; + newImage.FullID = LLUUID.Random(); + newImage.Name = source.Name; + return (newImage); + } + #endregion + + #region viewer asset uploading + public AssetBase UploadPacket(AssetUploadRequestPacket pack, LLUUID assetID) + { + + AssetBase asset = null; + if (pack.AssetBlock.Type == 0) + { + if (pack.AssetBlock.AssetData.Length > 0) + { + //first packet for transaction + asset = new AssetBase(); + asset.FullID = assetID; + asset.Type = pack.AssetBlock.Type; + asset.InvType = asset.Type; + asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000"); + asset.Data = pack.AssetBlock.AssetData; + this._assetServer.UploadNewAsset(asset); + TextureImage image = new TextureImage(asset); + this.Textures.Add(image.FullID, image); + } + } + + return asset; + } + + /* + public AssetBase TransactionComplete(LLUUID transactionID) + { + AssetBase asset = null; + if(this.IncomingAssets.ContainsKey(transactionID)) + { + // not the first packet of this transaction + asset = this.IncomingAssets[transactionID]; + if(asset.Type == 0) + { + TextureImage image = new TextureImage(asset); + this.Textures.Add(image.FullID, image); + } + } + return asset; + }*/ + + #endregion + + } + + public class AssetRequest + { + public SimClient RequestUser; + public LLUUID RequestAssetID; + public AssetInfo AssetInf; + public TextureImage ImageInfo; + public LLUUID TransferRequestID; + public long DataPointer = 0; + public int NumPackets = 0; + public int PacketCounter = 0; + public bool IsTextureRequest; + //public bool AssetInCache; + //public int TimeRequested; + + public AssetRequest() + { + + } + } + + public class AssetInfo : AssetBase + { + public AssetInfo() + { + + } + + public AssetInfo(AssetBase aBase) + { + Data = aBase.Data; + FullID = aBase.FullID; + Type = aBase.Type; + InvType = aBase.InvType; + Name = aBase.Name; + Description = aBase.Description; + } + } + + public class TextureImage : AssetBase + { + public TextureImage() + { + + } + + public TextureImage(AssetBase aBase) + { + Data = aBase.Data; + FullID = aBase.FullID; + Type = aBase.Type; + InvType = aBase.InvType; + Name = aBase.Name; + Description = aBase.Description; + } + } + +} diff --git a/OpenSim.RegionServer/Assets/InventoryCache.cs b/OpenSim.RegionServer/Assets/InventoryCache.cs new file mode 100644 index 0000000000..0788db2784 --- /dev/null +++ b/OpenSim.RegionServer/Assets/InventoryCache.cs @@ -0,0 +1,199 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using System.Collections.Generic; +using libsecondlife; +using OpenSim; +using libsecondlife.Packets; +//using OpenSim.GridServers; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Assets; + +namespace OpenSim.Assets +{ + /// + /// Description of InventoryManager. + /// + public class InventoryCache + { + private Dictionary _agentsInventory; + private List _serverRequests; //list of requests made to user server. + private System.Text.Encoding _enc = System.Text.Encoding.ASCII; + private const uint FULL_MASK_PERMISSIONS = 2147483647; + + public InventoryCache() + { + _agentsInventory = new Dictionary(); + _serverRequests = new List(); + } + + public void AddNewAgentsInventory(AgentInventory agentInventory) + { + this._agentsInventory.Add(agentInventory.AgentID, agentInventory); + } + + public void ClientLeaving(LLUUID clientID) + { + if (this._agentsInventory.ContainsKey(clientID)) + { + this._agentsInventory.Remove(clientID); + } + + } + public bool CreateNewInventoryFolder(SimClient remoteClient, LLUUID folderID) + { + bool res = false; + if (folderID != LLUUID.Zero) //don't create a folder with a zero id + { + if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) + { + res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID); + } + } + return res; + } + + public LLUUID AddNewInventoryItem(SimClient remoteClient, LLUUID folderID, OpenSim.Framework.Assets.AssetBase asset) + { + LLUUID newItem = null; + if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) + { + newItem = this._agentsInventory[remoteClient.AgentID].AddToInventory(folderID, asset); + } + + return newItem; + } + + public void FetchInventoryDescendents(SimClient userInfo, FetchInventoryDescendentsPacket FetchDescend) + { + if (this._agentsInventory.ContainsKey(userInfo.AgentID)) + { + AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID]; + if (FetchDescend.InventoryData.FetchItems) + { + if (agentInventory.InventoryFolders.ContainsKey(FetchDescend.InventoryData.FolderID)) + { + InventoryFolder Folder = agentInventory.InventoryFolders[FetchDescend.InventoryData.FolderID]; + InventoryDescendentsPacket Descend = new InventoryDescendentsPacket(); + Descend.AgentData.AgentID = userInfo.AgentID; + Descend.AgentData.OwnerID = Folder.OwnerID; + Descend.AgentData.FolderID = FetchDescend.InventoryData.FolderID; + Descend.AgentData.Descendents = Folder.Items.Count; + Descend.AgentData.Version = Folder.Items.Count; + + + Descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[Folder.Items.Count]; + for (int i = 0; i < Folder.Items.Count; i++) + { + + InventoryItem Item = Folder.Items[i]; + Descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock(); + Descend.ItemData[i].ItemID = Item.ItemID; + Descend.ItemData[i].AssetID = Item.AssetID; + Descend.ItemData[i].CreatorID = Item.CreatorID; + Descend.ItemData[i].BaseMask = FULL_MASK_PERMISSIONS; + Descend.ItemData[i].CreationDate = 1000; + Descend.ItemData[i].Description = _enc.GetBytes(Item.Description + "\0"); + Descend.ItemData[i].EveryoneMask = FULL_MASK_PERMISSIONS; + Descend.ItemData[i].Flags = 1; + Descend.ItemData[i].FolderID = Item.FolderID; + Descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); + Descend.ItemData[i].GroupMask = FULL_MASK_PERMISSIONS; + Descend.ItemData[i].InvType = Item.InvType; + Descend.ItemData[i].Name = _enc.GetBytes(Item.Name + "\0"); + Descend.ItemData[i].NextOwnerMask = FULL_MASK_PERMISSIONS; + Descend.ItemData[i].OwnerID = Item.OwnerID; + Descend.ItemData[i].OwnerMask = FULL_MASK_PERMISSIONS; + Descend.ItemData[i].SalePrice = 100; + Descend.ItemData[i].SaleType = 0; + Descend.ItemData[i].Type = Item.Type; + Descend.ItemData[i].CRC = libsecondlife.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); + } + userInfo.OutPacket(Descend); + + } + } + else + { + Console.WriteLine("fetch subfolders"); + } + } + } + + public void FetchInventory(SimClient userInfo, FetchInventoryPacket FetchItems) + { + if (this._agentsInventory.ContainsKey(userInfo.AgentID)) + { + AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID]; + + for (int i = 0; i < FetchItems.InventoryData.Length; i++) + { + if (agentInventory.InventoryItems.ContainsKey(FetchItems.InventoryData[i].ItemID)) + { + InventoryItem Item = agentInventory.InventoryItems[FetchItems.InventoryData[i].ItemID]; + FetchInventoryReplyPacket InventoryReply = new FetchInventoryReplyPacket(); + InventoryReply.AgentData.AgentID = userInfo.AgentID; + InventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1]; + InventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock(); + InventoryReply.InventoryData[0].ItemID = Item.ItemID; + InventoryReply.InventoryData[0].AssetID = Item.AssetID; + InventoryReply.InventoryData[0].CreatorID = Item.CreatorID; + InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS; + InventoryReply.InventoryData[0].CreationDate = 1000; + InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0"); + InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS; + InventoryReply.InventoryData[0].Flags = 1; + InventoryReply.InventoryData[0].FolderID = Item.FolderID; + InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); + InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS; + InventoryReply.InventoryData[0].InvType = Item.InvType; + InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0"); + InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS; + InventoryReply.InventoryData[0].OwnerID = Item.OwnerID; + InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS; + InventoryReply.InventoryData[0].SalePrice = 100; + InventoryReply.InventoryData[0].SaleType = 0; + InventoryReply.InventoryData[0].Type = Item.Type; + InventoryReply.InventoryData[0].CRC = libsecondlife.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); + userInfo.OutPacket(InventoryReply); + } + } + } + } + } + + + + public class UserServerRequest + { + public UserServerRequest() + { + + } + } +} diff --git a/OpenSim.RegionServer/CAPS/SimHttp.cs b/OpenSim.RegionServer/CAPS/SimHttp.cs new file mode 100644 index 0000000000..f5a87056ce --- /dev/null +++ b/OpenSim.RegionServer/CAPS/SimHttp.cs @@ -0,0 +1,175 @@ +/* +Copyright (c) OpenSimCAPS project, http://osgrid.org/ + + +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Text; +using Nwc.XmlRpc; +using System.Threading; +using System.Text.RegularExpressions; +using System.Net; +using System.IO; +using System.Collections; +using System.Collections.Generic; +using libsecondlife; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; + +namespace OpenSim.CAPS +{ + // Dummy HTTP server, does nothing useful for now + + public class SimCAPSHTTPServer + { + public Thread HTTPD; + public HttpListener Listener; + + public SimCAPSHTTPServer() + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Starting up HTTP Server"); + HTTPD = new Thread(new ThreadStart(StartHTTP)); + HTTPD.Start(); + } + + public void StartHTTP() + { + try + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SimHttp.cs:StartHTTP() - Spawned main thread OK"); + Listener = new HttpListener(); + + Listener.Prefixes.Add("http://+:" + OpenSimRoot.Instance.Cfg.IPListenPort + "/"); + Listener.Start(); + + HttpListenerContext context; + while (true) + { + context = Listener.GetContext(); + ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context); + } + } + catch (Exception e) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.Message); + } + } + + static string ParseXMLRPC(string requestBody) + { + try + { + XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); + + Hashtable requestData = (Hashtable)request.Params[0]; + switch (request.MethodName) + { + case "expect_user": + AgentCircuitData agent_data = new AgentCircuitData(); + agent_data.SessionID = new LLUUID((string)requestData["session_id"]); + agent_data.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]); + agent_data.firstname = (string)requestData["firstname"]; + agent_data.lastname = (string)requestData["lastname"]; + agent_data.AgentID = new LLUUID((string)requestData["agent_id"]); + agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); + if (OpenSimRoot.Instance.GridServers.GridServer.GetName() == "Remote") + { + ((RemoteGridBase)OpenSimRoot.Instance.GridServers.GridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data); + } + return ""; + break; + } + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + } + return ""; + } + + static string ParseREST(string requestBody, string requestURL) + { + return ""; + } + + static string ParseLLSDXML(string requestBody) + { + // dummy function for now - IMPLEMENT ME! + return ""; + } + + static void HandleRequest(Object stateinfo) + { + HttpListenerContext context = (HttpListenerContext)stateinfo; + + HttpListenerRequest request = context.Request; + HttpListenerResponse response = context.Response; + + response.KeepAlive = false; + response.SendChunked = false; + + System.IO.Stream body = request.InputStream; + System.Text.Encoding encoding = System.Text.Encoding.UTF8; + System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding); + + string requestBody = reader.ReadToEnd(); + body.Close(); + reader.Close(); + + string responseString = ""; + switch (request.ContentType) + { + case "text/xml": + // must be XML-RPC, so pass to the XML-RPC parser + + responseString = ParseXMLRPC(requestBody); + response.AddHeader("Content-type", "text/xml"); + break; + + case "application/xml": + // probably LLSD we hope, otherwise it should be ignored by the parser + responseString = ParseLLSDXML(requestBody); + response.AddHeader("Content-type", "application/xml"); + break; + + case null: + // must be REST or invalid crap, so pass to the REST parser + responseString = ParseREST(request.Url.OriginalString, requestBody); + break; + } + + byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString); + System.IO.Stream output = response.OutputStream; + response.SendChunked = false; + response.ContentLength64 = buffer.Length; + output.Write(buffer, 0, buffer.Length); + output.Close(); + } + } + + +} diff --git a/OpenSim.RegionServer/Grid.cs b/OpenSim.RegionServer/Grid.cs new file mode 100644 index 0000000000..b0df6a8088 --- /dev/null +++ b/OpenSim.RegionServer/Grid.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Reflection; +using OpenSim.Framework.Interfaces; +using OpenSim.UserServer; + +namespace OpenSim +{ + public class Grid + { + public IAssetServer AssetServer; + public IGridServer GridServer; + public string AssetDll = ""; + public string GridDll = ""; + + public Grid() + { + } + + public virtual void Initialise() + { + //load the dlls + this.AssetServer = this.LoadAssetDll(this.AssetDll); + this.GridServer = this.LoadGridDll(this.GridDll); + } + public virtual void Close() + { + this.AssetServer.Close(); + this.GridServer.Close(); + } + + private IAssetServer LoadAssetDll(string dllName) + { + Assembly pluginAssembly = Assembly.LoadFrom(dllName); + IAssetServer server = null; + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IAssetPlugin", true); + + if (typeInterface != null) + { + IAssetPlugin plug = (IAssetPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + server = plug.GetAssetServer(); + break; + } + + typeInterface = null; + } + } + } + pluginAssembly = null; + return server; + } + + private IGridServer LoadGridDll(string dllName) + { + Assembly pluginAssembly = Assembly.LoadFrom(dllName); + IGridServer server = null; + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IGridPlugin", true); + + if (typeInterface != null) + { + IGridPlugin plug = (IGridPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + server = plug.GetGridServer(); + break; + } + + typeInterface = null; + } + } + } + pluginAssembly = null; + return server; + } + } +} diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim.RegionServer/OpenSim.RegionServer.csproj new file mode 100644 index 0000000000..ebf2f87aff --- /dev/null +++ b/OpenSim.RegionServer/OpenSim.RegionServer.csproj @@ -0,0 +1,169 @@ + + + Local + 8.0.50727 + 2.0 + {B48F0D82-2DE5-42B0-9F1D-0F4353FA243A} + Debug + AnyCPU + + + + OpenSim.RegionServer + JScript + Grid + IE50 + false + Exe + + OpenSim.RegionServer + OpenSim.RegionServer + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\bin\ + False + False + False + 4 + + + + + \System.dll + + + \System.Xml.dll.dll + + + \libsecondlife.dll.dll + + + \Axiom.MathLib.dll.dll + + + \Db4objects.Db4o.dll.dll + + + + + OpenSim.Framework.Console + {C8405E1A-EC19-48B6-9C8C-CA03624B9916} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + OpenSim.Physics.Manager + {58360A80-9333-4E0F-8F83-3CF937E51633} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + OpenSim.Framework + {1D2865A9-CF8E-45F7-B96D-91ED128A32CF} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.exe.build b/OpenSim.RegionServer/OpenSim.RegionServer.exe.build new file mode 100644 index 0000000000..c65f751dad --- /dev/null +++ b/OpenSim.RegionServer/OpenSim.RegionServer.exe.build @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.RegionServer/OpenSimApplication.cs b/OpenSim.RegionServer/OpenSimApplication.cs new file mode 100644 index 0000000000..abfdf45812 --- /dev/null +++ b/OpenSim.RegionServer/OpenSimApplication.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Net; +using System.Net.Sockets; + +namespace OpenSim +{ + public abstract class OpenSimApplication + { + public abstract void StartUp(); + public abstract void Shutdown(); + public abstract void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode);// EndPoint packetSender); + public abstract void RemoveClientCircuit(uint circuitcode); + } +} diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs new file mode 100644 index 0000000000..b2bc0b3f75 --- /dev/null +++ b/OpenSim.RegionServer/OpenSimMain.cs @@ -0,0 +1,320 @@ +/* +Copyright (c) OpenSim project, http://osgrid.org/ + +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Text; +using System.IO; +using System.Threading; +using System.Net; +using System.Net.Sockets; +using System.Timers; +using System.Reflection; +using System.Collections; +using System.Collections.Generic; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.world; +using OpenSim.Framework.Interfaces; +using OpenSim.UserServer; +using OpenSim.Assets; +using OpenSim.CAPS; +using OpenSim.Framework.Console; +using OpenSim.Physics.Manager; + +namespace OpenSim +{ + /// + /// + /// + public class OpenSimMain : OpenSimApplication + { + private Dictionary clientCircuits = new Dictionary(); + private PhysicsManager physManager; + + public Socket Server; + private IPEndPoint ServerIncoming; + private byte[] RecvBuffer = new byte[4096]; + private byte[] ZeroBuffer = new byte[8192]; + private IPEndPoint ipeSender; + private EndPoint epSender; + private AsyncCallback ReceivedData; + + private System.Timers.Timer timer1 = new System.Timers.Timer(); + private string ConfigDll = "OpenSim.Config.SimConfigDb4o.dll"; + private string _physicsEngine = "basicphysics"; + public bool sandbox = false; + public bool loginserver = false; + + [STAThread] + public static void Main(string[] args) + { + Console.WriteLine("OpenSim " + VersionInfo.Version + "\n"); + Console.WriteLine("Starting...\n"); + OpenSim.Framework.Console.MainConsole.Instance = new SimConsole(OpenSim.Framework.Console.ConsoleBase.ConsoleType.Local, "", 0); + + //OpenSimRoot.instance = new OpenSimRoot(); + OpenSimMain sim = new OpenSimMain(); + OpenSimRoot.Instance.Application = sim; + + sim.sandbox = false; + sim.loginserver = false; + sim._physicsEngine = "basicphysics"; + + for (int i = 0; i < args.Length; i++) + { + if (args[i] == "-sandbox") + { + sim.sandbox = true; + OpenSimRoot.Instance.Sandbox = true; + } + + if (args[i] == "-loginserver") + { + sim.loginserver = true; + } + if (args[i] == "-realphysx") + { + sim._physicsEngine = "RealPhysX"; + OpenSim.world.Avatar.PhysicsEngineFlying = true; + } + } + + + OpenSimRoot.Instance.GridServers = new Grid(); + if (sim.sandbox) + { + OpenSimRoot.Instance.GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll"; + OpenSimRoot.Instance.GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll"; + OpenSimRoot.Instance.GridServers.Initialise(); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Starting in Sandbox mode"); + } + else + { + OpenSimRoot.Instance.GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll"; + OpenSimRoot.Instance.GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll"; + OpenSimRoot.Instance.GridServers.Initialise(); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Starting in Grid mode"); + } + + if (sim.loginserver && sim.sandbox) + { + LoginServer loginServer = new LoginServer(OpenSimRoot.Instance.GridServers.GridServer); + loginServer.Startup(); + } + + OpenSimRoot.Instance.StartUp(); + + while (true) + { + OpenSim.Framework.Console.MainConsole.Instance.MainConsolePrompt(); + } + } + + private OpenSimMain() + { + } + + public override void StartUp() + { + OpenSimRoot.Instance.startuptime = DateTime.Now; + + OpenSimRoot.Instance.AssetCache = new AssetCache(OpenSimRoot.Instance.GridServers.AssetServer); + OpenSimRoot.Instance.InventoryCache = new InventoryCache(); + + // We check our local database first, then the grid for config options + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:Startup() - Loading configuration"); + OpenSimRoot.Instance.Cfg = this.LoadConfigDll(this.ConfigDll); + OpenSimRoot.Instance.Cfg.InitConfig(this.sandbox); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:Startup() - Contacting gridserver"); + OpenSimRoot.Instance.Cfg.LoadFromGrid(); + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:Startup() - We are " + OpenSimRoot.Instance.Cfg.RegionName + " at " + OpenSimRoot.Instance.Cfg.RegionLocX.ToString() + "," + OpenSimRoot.Instance.Cfg.RegionLocY.ToString()); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Initialising world"); + OpenSimRoot.Instance.LocalWorld = new World(); + OpenSimRoot.Instance.LocalWorld.LandMap = OpenSimRoot.Instance.Cfg.LoadWorld(); + + this.physManager = new OpenSim.Physics.Manager.PhysicsManager(); + this.physManager.LoadPlugins(); + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting up messaging system"); + OpenSimRoot.Instance.LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this._physicsEngine); //should be reading from the config file what physics engine to use + OpenSimRoot.Instance.LocalWorld.PhysScene.SetTerrain(OpenSimRoot.Instance.LocalWorld.LandMap); + + OpenSimRoot.Instance.GridServers.AssetServer.SetServerInfo(OpenSimRoot.Instance.Cfg.AssetURL, OpenSimRoot.Instance.Cfg.AssetSendKey); + OpenSimRoot.Instance.GridServers.GridServer.SetServerInfo(OpenSimRoot.Instance.Cfg.GridURL, OpenSimRoot.Instance.Cfg.GridSendKey, OpenSimRoot.Instance.Cfg.GridRecvKey); + + OpenSimRoot.Instance.LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded. + OpenSimRoot.Instance.LocalWorld.LoadPrimsFromStorage(); + + if (this.sandbox) + { + OpenSimRoot.Instance.AssetCache.LoadDefaultTextureSet(); + } + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting CAPS HTTP server"); + OpenSimRoot.Instance.HttpServer = new SimCAPSHTTPServer(); + + timer1.Enabled = true; + timer1.Interval = 100; + timer1.Elapsed += new ElapsedEventHandler(this.Timer1Tick); + + MainServerListener(); + } + + private SimConfig LoadConfigDll(string dllName) + { + Assembly pluginAssembly = Assembly.LoadFrom(dllName); + SimConfig config = null; + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("ISimConfig", true); + + if (typeInterface != null) + { + ISimConfig plug = (ISimConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + config = plug.GetConfigObject(); + break; + } + + typeInterface = null; + } + } + } + pluginAssembly = null; + return config; + } + + private void OnReceivedData(IAsyncResult result) + { + ipeSender = new IPEndPoint(IPAddress.Any, 0); + epSender = (EndPoint)ipeSender; + Packet packet = null; + int numBytes = Server.EndReceiveFrom(result, ref epSender); + int packetEnd = numBytes - 1; + packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); + + // This is either a new client or a packet to send to an old one + // if (OpenSimRoot.Instance.ClientThreads.ContainsKey(epSender)) + + // do we already have a circuit for this endpoint + if(this.clientCircuits.ContainsKey(epSender)) + { + OpenSimRoot.Instance.ClientThreads[this.clientCircuits[epSender]].InPacket(packet); + } + else if (packet.Type == PacketType.UseCircuitCode) + { // new client + UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet; + this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); + SimClient newuser = new SimClient(epSender, useCircuit); + //OpenSimRoot.Instance.ClientThreads.Add(epSender, newuser); + OpenSimRoot.Instance.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser); + } + else + { // invalid client + Console.Error.WriteLine("Main.cs:OnReceivedData() - WARNING: Got a packet from an invalid client - " + epSender.ToString()); + } + Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); + } + + private void MainServerListener() + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - New thread started"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - Opening UDP socket on " + OpenSimRoot.Instance.Cfg.IPListenAddr + ":" + OpenSimRoot.Instance.Cfg.IPListenPort); + + ServerIncoming = new IPEndPoint(IPAddress.Any, OpenSimRoot.Instance.Cfg.IPListenPort); + Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); + Server.Bind(ServerIncoming); + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - UDP socket bound, getting ready to listen"); + + ipeSender = new IPEndPoint(IPAddress.Any, 0); + epSender = (EndPoint)ipeSender; + ReceivedData = new AsyncCallback(this.OnReceivedData); + Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - Listening..."); + + } + + public override void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode )//EndPoint packetSender) + { + // find the endpoint for this circuit + EndPoint sendto = null; + foreach(KeyValuePair p in this.clientCircuits) + { + if (p.Value == circuitcode) + { + sendto = p.Key; + break; + } + } + if (sendto != null) + { + //we found the endpoint so send the packet to it + this.Server.SendTo(buffer, size, flags, sendto); + } + } + + public override void RemoveClientCircuit(uint circuitcode) + { + foreach (KeyValuePair p in this.clientCircuits) + { + if (p.Value == circuitcode) + { + this.clientCircuits.Remove(p.Key); + break; + } + } + } + + public override void Shutdown() + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Closing all threads"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Killing listener thread"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Killing clients"); + // IMPLEMENT THIS + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Closing console and terminating"); + OpenSimRoot.Instance.LocalWorld.Close(); + OpenSimRoot.Instance.GridServers.Close(); + OpenSim.Framework.Console.MainConsole.Instance.Close(); + Environment.Exit(0); + } + + void Timer1Tick(object sender, System.EventArgs e) + { + OpenSimRoot.Instance.LocalWorld.Update(); + } + } + + +} diff --git a/OpenSim.RegionServer/OpenSimRoot.cs b/OpenSim.RegionServer/OpenSimRoot.cs new file mode 100644 index 0000000000..3361e5d85b --- /dev/null +++ b/OpenSim.RegionServer/OpenSimRoot.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Net; +//using System.Net.Sockets; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.world; +using OpenSim.Framework.Interfaces; +using OpenSim.UserServer; +using OpenSim.Assets; +using OpenSim.CAPS; +using OpenSim.Framework.Console; +using OpenSim.Physics.Manager; + +namespace OpenSim +{ + public sealed class OpenSimRoot + { + private static OpenSimRoot instance = new OpenSimRoot(); + + public static OpenSimRoot Instance + { + get + { + return instance; + } + } + + private OpenSimRoot() + { + + } + + public World LocalWorld; + public Grid GridServers; + public SimConfig Cfg; + public SimCAPSHTTPServer HttpServer; + public AssetCache AssetCache; + public InventoryCache InventoryCache; + //public Dictionary ClientThreads = new Dictionary(); + public Dictionary ClientThreads = new Dictionary(); + public DateTime startuptime; + public OpenSimApplication Application; + public bool Sandbox = false; + + public void StartUp() + { + if (this.Application != null) + { + this.Application.StartUp(); + } + } + + public void Shutdown() + { + if (this.Application != null) + { + this.Application.Shutdown(); + } + } + } +} diff --git a/OpenSim.RegionServer/QueItem.cs b/OpenSim.RegionServer/QueItem.cs new file mode 100644 index 0000000000..747e026327 --- /dev/null +++ b/OpenSim.RegionServer/QueItem.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife.Packets; + +namespace OpenSim +{ + public class QueItem + { + public QueItem() + { + } + + public Packet Packet; + public bool Incoming; + } + +} diff --git a/OpenSim.RegionServer/SimClient.cs b/OpenSim.RegionServer/SimClient.cs new file mode 100644 index 0000000000..210e0d9154 --- /dev/null +++ b/OpenSim.RegionServer/SimClient.cs @@ -0,0 +1,621 @@ +/* +Copyright (c) OpenSim project, http://osgrid.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Collections; +using System.Collections.Generic; +using libsecondlife; +using libsecondlife.Packets; +using System.Net; +using System.Net.Sockets; +using System.IO; +using System.Threading; +using System.Timers; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Utilities; +using OpenSim.world; +using OpenSim.Assets; + +namespace OpenSim +{ + /// + /// Handles new client connections + /// Constructor takes a single Packet and authenticates everything + /// + public class SimClient + { + + public LLUUID AgentID; + public LLUUID SessionID; + public LLUUID SecureSessionID = LLUUID.Zero; + public uint CircuitCode; + public world.Avatar ClientAvatar; + private UseCircuitCodePacket cirpack; + private Thread ClientThread; + public EndPoint userEP; + private BlockingQueue PacketQueue; + private Dictionary PendingAcks = new Dictionary(); + private Dictionary NeedAck = new Dictionary(); + //private Dictionary UploadedAssets = new Dictionary(); + private System.Timers.Timer AckTimer; + private uint Sequence = 0; + private object SequenceLock = new object(); + private const int MAX_APPENDED_ACKS = 10; + private const int RESEND_TIMEOUT = 4000; + private const int MAX_SEQUENCE = 0xFFFFFF; + private LLUUID newAssetFolder = LLUUID.Zero; + private bool debug = false; + + private void ack_pack(Packet Pack) + { + //libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket(); + //ack_it.Packets = new PacketAckPacket.PacketsBlock[1]; + //ack_it.Packets[0] = new PacketAckPacket.PacketsBlock(); + //ack_it.Packets[0].ID = Pack.Header.ID; + //ack_it.Header.Reliable = false; + + //OutPacket(ack_it); + + if (Pack.Header.Reliable) + { + lock (PendingAcks) + { + uint sequence = (uint)Pack.Header.Sequence; + if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; } + } + } + } + + protected virtual void ProcessInPacket(Packet Pack) + { + ack_pack(Pack); + if (debug) + { + if (Pack.Type != PacketType.AgentUpdate) + { + Console.WriteLine(Pack.Type.ToString()); + } + } + switch (Pack.Type) + { + case PacketType.CompleteAgentMovement: + ClientAvatar.CompleteMovement(OpenSimRoot.Instance.LocalWorld); + ClientAvatar.SendInitialPosition(); + break; + case PacketType.RegionHandshakeReply: + OpenSimRoot.Instance.LocalWorld.SendLayerData(this); + break; + case PacketType.AgentWearablesRequest: + ClientAvatar.SendInitialAppearance(); + foreach (SimClient client in OpenSimRoot.Instance.ClientThreads.Values) + { + if (client.AgentID != this.AgentID) + { + ObjectUpdatePacket objupdate = client.ClientAvatar.CreateUpdatePacket(); + this.OutPacket(objupdate); + client.ClientAvatar.SendAppearanceToOtherAgent(this); + } + } + OpenSimRoot.Instance.LocalWorld.GetInitialPrims(this); + break; + case PacketType.ObjectAdd: + OpenSimRoot.Instance.LocalWorld.AddNewPrim((ObjectAddPacket)Pack, this); + break; + case PacketType.ObjectLink: + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(Pack.ToString()); + break; + case PacketType.ObjectScale: + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(Pack.ToString()); + break; + case PacketType.ObjectShape: + ObjectShapePacket shape = (ObjectShapePacket)Pack; + for (int i = 0; i < shape.ObjectData.Length; i++) + { + foreach (Entity ent in OpenSimRoot.Instance.LocalWorld.Entities.Values) + { + if (ent.localid == shape.ObjectData[i].ObjectLocalID) + { + ((OpenSim.world.Primitive)ent).UpdateShape(shape.ObjectData[i]); + } + } + } + break; + case PacketType.MultipleObjectUpdate: + MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)Pack; + + for (int i = 0; i < multipleupdate.ObjectData.Length; i++) + { + if (multipleupdate.ObjectData[i].Type == 9) //change position + { + libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); + foreach (Entity ent in OpenSimRoot.Instance.LocalWorld.Entities.Values) + { + if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID) + { + ((OpenSim.world.Primitive)ent).UpdatePosition(pos); + + } + } + + //should update stored position of the prim + } + else if (multipleupdate.ObjectData[i].Type == 10)//rotation + { + libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); + foreach (Entity ent in OpenSimRoot.Instance.LocalWorld.Entities.Values) + { + if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID) + { + ent.rotation = new Axiom.MathLib.Quaternion(rot.W, rot.X, rot.Y, rot.W); + ((OpenSim.world.Primitive)ent).UpdateFlag = true; + } + } + } + else if (multipleupdate.ObjectData[i].Type == 13)//scale + { + + libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); + foreach (Entity ent in OpenSimRoot.Instance.LocalWorld.Entities.Values) + { + if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID) + { + ((OpenSim.world.Primitive)ent).Scale = scale; + } + } + } + } + break; + case PacketType.RequestImage: + RequestImagePacket imageRequest = (RequestImagePacket)Pack; + for (int i = 0; i < imageRequest.RequestImage.Length; i++) + { + OpenSimRoot.Instance.AssetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image); + } + break; + case PacketType.TransferRequest: + //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request"); + TransferRequestPacket transfer = (TransferRequestPacket)Pack; + OpenSimRoot.Instance.AssetCache.AddAssetRequest(this, transfer); + break; + case PacketType.AgentUpdate: + ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack); + break; + case PacketType.LogoutRequest: + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got a logout request"); + //send reply to let the client logout + LogoutReplyPacket logReply = new LogoutReplyPacket(); + logReply.AgentData.AgentID = this.AgentID; + logReply.AgentData.SessionID = this.SessionID; + logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1]; + logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock(); + logReply.InventoryData[0].ItemID = LLUUID.Zero; + OutPacket(logReply); + //tell all clients to kill our object + KillObjectPacket kill = new KillObjectPacket(); + kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; + kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); + kill.ObjectData[0].ID = this.ClientAvatar.localid; + foreach (SimClient client in OpenSimRoot.Instance.ClientThreads.Values) + { + client.OutPacket(kill); + } + OpenSimRoot.Instance.GridServers.GridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode); + lock (OpenSimRoot.Instance.LocalWorld.Entities) + { + OpenSimRoot.Instance.LocalWorld.Entities.Remove(this.AgentID); + } + //need to do other cleaning up here too + OpenSimRoot.Instance.ClientThreads.Remove(this.CircuitCode); //this.userEP); + OpenSimRoot.Instance.Application.RemoveClientCircuit(this.CircuitCode); + this.ClientThread.Abort(); + break; + case PacketType.ChatFromViewer: + ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack; + if (Helpers.FieldToString(inchatpack.ChatData.Message) == "") break; + + System.Text.Encoding _enc = System.Text.Encoding.ASCII; + libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket(); + reply.ChatData.Audible = 1; + reply.ChatData.Message = inchatpack.ChatData.Message; + reply.ChatData.ChatType = 1; + reply.ChatData.SourceType = 1; + reply.ChatData.Position = this.ClientAvatar.position; + reply.ChatData.FromName = _enc.GetBytes(this.ClientAvatar.firstname + " " + this.ClientAvatar.lastname + "\0"); + reply.ChatData.OwnerID = this.AgentID; + reply.ChatData.SourceID = this.AgentID; + foreach (SimClient client in OpenSimRoot.Instance.ClientThreads.Values) + { + client.OutPacket(reply); + } + break; + case PacketType.ObjectImage: + ObjectImagePacket imagePack = (ObjectImagePacket)Pack; + for (int i = 0; i < imagePack.ObjectData.Length; i++) + { + foreach (Entity ent in OpenSimRoot.Instance.LocalWorld.Entities.Values) + { + if (ent.localid == imagePack.ObjectData[i].ObjectLocalID) + { + ((OpenSim.world.Primitive)ent).UpdateTexture(imagePack.ObjectData[i].TextureEntry); + } + } + } + break; + case PacketType.ObjectFlagUpdate: + ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; + foreach (Entity ent in OpenSimRoot.Instance.LocalWorld.Entities.Values) + { + if (ent.localid == flags.AgentData.ObjectLocalID) + { + ((OpenSim.world.Primitive)ent).UpdateObjectFlags(flags); + } + } + + break; + case PacketType.AssetUploadRequest: + AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; + Console.WriteLine("upload request "+ request.AssetBlock.TransactionID); + AssetBase newAsset = OpenSimRoot.Instance.AssetCache.UploadPacket(request, LLUUID.Random()); + if (newAsset != null) + { + OpenSimRoot.Instance.InventoryCache.AddNewInventoryItem(this, this.newAssetFolder, newAsset); + } + Console.WriteLine(request.ToString()); + Console.WriteLine("combined uuid is " + request.AssetBlock.TransactionID.Combine(this.SecureSessionID).ToStringHyphenated()); + + AssetUploadCompletePacket response = new AssetUploadCompletePacket(); + response.AssetBlock.Type =request.AssetBlock.Type; + response.AssetBlock.Success = true; + response.AssetBlock.UUID = request.AssetBlock.TransactionID.Combine(this.SecureSessionID); + + this.OutPacket(response); + break; + case PacketType.CreateInventoryFolder: + //Console.WriteLine(Pack.ToString()); + break; + case PacketType.CreateInventoryItem: + //Console.WriteLine(Pack.ToString()); + break; + case PacketType.FetchInventory: + Console.WriteLine("fetch item packet"); + FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack; + OpenSimRoot.Instance.InventoryCache.FetchInventory(this, FetchInventory); + break; + case PacketType.FetchInventoryDescendents: + FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack; + OpenSimRoot.Instance.InventoryCache.FetchInventoryDescendents(this, Fetch); + break; + } + } + + private void ResendUnacked() + { + int now = Environment.TickCount; + + lock (NeedAck) + { + foreach (Packet packet in NeedAck.Values) + { + if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Resending " + packet.Type.ToString() + " packet, " + + (now - packet.TickCount) + "ms have passed"); + + packet.Header.Resent = true; + OutPacket(packet); + } + } + } + } + + private void SendAcks() + { + lock (PendingAcks) + { + if (PendingAcks.Count > 0) + { + if (PendingAcks.Count > 250) + { + // FIXME: Handle the odd case where we have too many pending ACKs queued up + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Too many ACKs queued up!"); + return; + } + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sending PacketAck"); + + + int i = 0; + PacketAckPacket acks = new PacketAckPacket(); + acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count]; + + foreach (uint ack in PendingAcks.Values) + { + acks.Packets[i] = new PacketAckPacket.PacketsBlock(); + acks.Packets[i].ID = ack; + i++; + } + + acks.Header.Reliable = false; + OutPacket(acks); + + PendingAcks.Clear(); + } + } + } + + private void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) + { + SendAcks(); + ResendUnacked(); + } + + protected virtual void ProcessOutPacket(Packet Pack) + { + + // Keep track of when this packet was sent out + Pack.TickCount = Environment.TickCount; + + if (!Pack.Header.Resent) + { + // Set the sequence number + lock (SequenceLock) + { + if (Sequence >= MAX_SEQUENCE) + Sequence = 1; + else + Sequence++; + Pack.Header.Sequence = Sequence; + } + + if (Pack.Header.Reliable) //DIRTY HACK + { + lock (NeedAck) + { + if (!NeedAck.ContainsKey(Pack.Header.Sequence)) + { + NeedAck.Add(Pack.Header.Sequence, Pack); + } + else + { + // Client.Log("Attempted to add a duplicate sequence number (" + + // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " + + // packet.Type.ToString(), Helpers.LogLevel.Warning); + } + } + + // Don't append ACKs to resent packets, in case that's what was causing the + // delivery to fail + if (!Pack.Header.Resent) + { + // Append any ACKs that need to be sent out to this packet + lock (PendingAcks) + { + if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS && + Pack.Type != PacketType.PacketAck && + Pack.Type != PacketType.LogoutRequest) + { + Pack.Header.AckList = new uint[PendingAcks.Count]; + int i = 0; + + foreach (uint ack in PendingAcks.Values) + { + Pack.Header.AckList[i] = ack; + i++; + } + + PendingAcks.Clear(); + Pack.Header.AppendedAcks = true; + } + } + } + } + } + + //ServerConsole.MainConsole.Instance.WriteLine("OUT: \n" + Pack.ToString()); + + byte[] ZeroOutBuffer = new byte[4096]; + byte[] sendbuffer; + sendbuffer = Pack.ToBytes(); + + try + { + if (Pack.Header.Zerocoded) + { + int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); + OpenSimRoot.Instance.Application.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, CircuitCode);//userEP); + } + else + { + OpenSimRoot.Instance.Application.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, CircuitCode); //userEP); + } + } + catch (Exception) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread"); + ClientThread.Abort(); + } + + } + + public virtual void InPacket(Packet NewPack) + { + // Handle appended ACKs + if (NewPack.Header.AppendedAcks) + { + lock (NeedAck) + { + foreach (uint ack in NewPack.Header.AckList) + { + NeedAck.Remove(ack); + } + } + } + + // Handle PacketAck packets + if (NewPack.Type == PacketType.PacketAck) + { + PacketAckPacket ackPacket = (PacketAckPacket)NewPack; + + lock (NeedAck) + { + foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) + { + NeedAck.Remove(block.ID); + } + } + } + else if ((NewPack.Type == PacketType.StartPingCheck)) + { + //reply to pingcheck + libsecondlife.Packets.StartPingCheckPacket startPing = (libsecondlife.Packets.StartPingCheckPacket)NewPack; + libsecondlife.Packets.CompletePingCheckPacket endPing = new CompletePingCheckPacket(); + endPing.PingID.PingID = startPing.PingID.PingID; + OutPacket(endPing); + } + else + { + QueItem item = new QueItem(); + item.Packet = NewPack; + item.Incoming = true; + this.PacketQueue.Enqueue(item); + } + + } + + public virtual void OutPacket(Packet NewPack) + { + QueItem item = new QueItem(); + item.Packet = NewPack; + item.Incoming = false; + this.PacketQueue.Enqueue(item); + } + + public SimClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs - Started up new client thread to handle incoming request"); + cirpack = initialcirpack; + userEP = remoteEP; + PacketQueue = new BlockingQueue(); + AckTimer = new System.Timers.Timer(500); + AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); + AckTimer.Start(); + + ClientThread = new Thread(new ThreadStart(AuthUser)); + ClientThread.IsBackground = true; + ClientThread.Start(); + } + + protected virtual void ClientLoop() + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:ClientLoop() - Entered loop"); + while (true) + { + QueItem nextPacket = PacketQueue.Dequeue(); + if (nextPacket.Incoming) + { + //is a incoming packet + ProcessInPacket(nextPacket.Packet); + } + else + { + //is a out going packet + ProcessOutPacket(nextPacket.Packet); + } + } + } + + protected virtual void InitNewClient() + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:InitNewClient() - Adding viewer agent to world"); + OpenSimRoot.Instance.LocalWorld.AddViewerAgent(this); + world.Entity tempent = OpenSimRoot.Instance.LocalWorld.Entities[this.AgentID]; + this.ClientAvatar = (world.Avatar)tempent; + } + + protected virtual void AuthUser() + { + AuthenticateResponse sessionInfo = OpenSimRoot.Instance.GridServers.GridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); + if (!sessionInfo.Authorised) + { + //session/circuit not authorised + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString()); + ClientThread.Abort(); + } + else + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString()); + //session is authorised + this.AgentID = cirpack.CircuitCode.ID; + this.SessionID = cirpack.CircuitCode.SessionID; + this.CircuitCode = cirpack.CircuitCode.Code; + InitNewClient(); //shouldn't be called here as we might be a child agent and not want a full avatar + this.ClientAvatar.firstname = sessionInfo.LoginInfo.First; + this.ClientAvatar.lastname = sessionInfo.LoginInfo.Last; + if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero) + { + this.SecureSessionID = sessionInfo.LoginInfo.SecureSession; + } + + // Create Inventory, currently only works for sandbox mode + if (OpenSimRoot.Instance.Sandbox) + { + if (sessionInfo.LoginInfo.InventoryFolder != null) + { + this.CreateInventory(sessionInfo.LoginInfo.InventoryFolder); + if (sessionInfo.LoginInfo.BaseFolder != null) + { + OpenSimRoot.Instance.InventoryCache.CreateNewInventoryFolder(this, sessionInfo.LoginInfo.BaseFolder); + this.newAssetFolder = sessionInfo.LoginInfo.BaseFolder; + AssetBase[] inventorySet = OpenSimRoot.Instance.AssetCache.CreateNewInventorySet(this.AgentID); + if (inventorySet != null) + { + for (int i = 0; i < inventorySet.Length; i++) + { + if (inventorySet[i] != null) + { + OpenSimRoot.Instance.InventoryCache.AddNewInventoryItem(this, sessionInfo.LoginInfo.BaseFolder, inventorySet[i]); + } + } + } + } + } + } + + ClientLoop(); + } + } + + private void CreateInventory(LLUUID baseFolder) + { + AgentInventory inventory = new AgentInventory(); + inventory.AgentID = this.AgentID; + OpenSimRoot.Instance.InventoryCache.AddNewAgentsInventory(inventory); + OpenSimRoot.Instance.InventoryCache.CreateNewInventoryFolder(this, baseFolder); + } + } +} diff --git a/src/OpenSimConsole.cs b/OpenSim.RegionServer/SimConsole.cs similarity index 86% rename from src/OpenSimConsole.cs rename to OpenSim.RegionServer/SimConsole.cs index cf8b648330..d6d5e44210 100644 --- a/src/OpenSimConsole.cs +++ b/OpenSim.RegionServer/SimConsole.cs @@ -33,14 +33,14 @@ using System.IO; using System.Net; using libsecondlife; using libsecondlife.Packets; -using ServerConsole; +using OpenSim.Framework.Console; namespace OpenSim { /// /// Description of ServerConsole. /// - public class MServerConsole : ConsoleBase + public class SimConsole : ConsoleBase { private ConsoleType ConsType; @@ -57,7 +57,7 @@ namespace OpenSim // TCP - the port to bind to // Local - param ignored // SimChat - the chat channel to accept commands from - public MServerConsole(ConsoleType constype, string sparam, int iparam) { + public SimConsole(ConsoleType constype, string sparam, int iparam) { ConsType = constype; switch(constype) { case ConsoleType.Local: @@ -156,11 +156,11 @@ namespace OpenSim break; case "regenerate": - OpenSim_Main.local_world.RegenerateTerrain(); + OpenSimRoot.Instance.LocalWorld.RegenerateTerrain(); break; case "shutdown": - OpenSim_Main.Shutdown(); + OpenSimRoot.Instance.Shutdown(); break; } return null; @@ -170,16 +170,16 @@ namespace OpenSim public override void ShowCommands(string ShowWhat) { switch(ShowWhat) { case "uptime": - this.WriteLine("OpenSim has been running since " + OpenSim_Main.sim.startuptime.ToString()); - this.WriteLine("That is " + (DateTime.Now-OpenSim_Main.sim.startuptime).ToString()); + this.WriteLine("OpenSim has been running since " + OpenSimRoot.Instance.startuptime.ToString()); + this.WriteLine("That is " + (DateTime.Now-OpenSimRoot.Instance.startuptime).ToString()); break; case "users": OpenSim.world.Avatar TempAv; this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}","Firstname", "Lastname","Agent ID", "Session ID", "Circuit", "IP")); - foreach (libsecondlife.LLUUID UUID in OpenSim_Main.local_world.Entities.Keys) { - if(OpenSim_Main.local_world.Entities[UUID].ToString()== "OpenSim.world.Avatar") + foreach (libsecondlife.LLUUID UUID in OpenSimRoot.Instance.LocalWorld.Entities.Keys) { + if(OpenSimRoot.Instance.LocalWorld.Entities[UUID].ToString()== "OpenSim.world.Avatar") { - TempAv=(OpenSim.world.Avatar)OpenSim_Main.local_world.Entities[UUID]; + TempAv=(OpenSim.world.Avatar)OpenSimRoot.Instance.LocalWorld.Entities[UUID]; this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}",TempAv.firstname, TempAv.lastname,UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString())); } } @@ -190,7 +190,7 @@ namespace OpenSim // Displays a prompt to the user and then runs the command they entered public override void MainConsolePrompt() { string[] tempstrarray; - string tempstr = this.CmdPrompt("OpenSim-" + OpenSim_Main.cfg.RegionHandle.ToString() + " # "); + string tempstr = this.CmdPrompt("OpenSim-" + OpenSimRoot.Instance.Cfg.RegionHandle.ToString() + " # "); tempstrarray = tempstr.Split(' '); string cmd=tempstrarray[0]; Array.Reverse(tempstrarray); diff --git a/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs b/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs new file mode 100644 index 0000000000..83e340b473 --- /dev/null +++ b/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Collections; +using System.Text; +using OpenSim.Framework.User; +using OpenSim.Framework.Grid; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Interfaces; +using libsecondlife; + +namespace OpenSim.UserServer +{ + class LocalUserProfileManager : UserProfileManager + { + private IGridServer _gridServer; + + public LocalUserProfileManager(IGridServer gridServer) + { + _gridServer = gridServer; + } + + public override void InitUserProfiles() + { + // TODO: need to load from database + } + + public override void CustomiseResponse(ref System.Collections.Hashtable response, UserProfile theUser) + { + uint circode = (uint)response["circuit_code"]; + theUser.AddSimCircuit(circode, LLUUID.Random()); + response["home"] = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + theUser.homepos.X.ToString() + ",r" + theUser.homepos.Y.ToString() + ",r" + theUser.homepos.Z.ToString() + "], 'look_at':[r" + theUser.homelookat.X.ToString() + ",r" + theUser.homelookat.Y.ToString() + ",r" + theUser.homelookat.Z.ToString() + "]}"; + response["sim_port"] = OpenSimRoot.Instance.Cfg.IPListenPort; + response["sim_ip"] = OpenSimRoot.Instance.Cfg.IPListenAddr; + response["region_y"] = (Int32)996 * 256; + response["region_x"] = (Int32)997* 256; + + string first; + string last; + if (response.Contains("first")) + { + first = (string)response["first"]; + } + else + { + first = "test"; + } + + if (response.Contains("last")) + { + last = (string)response["last"]; + } + else + { + last = "User"; + } + + ArrayList InventoryList = (ArrayList)response["inventory-skeleton"]; + Hashtable Inventory1 = (Hashtable)InventoryList[0]; + + Login _login = new Login(); + //copy data to login object + _login.First = first; + _login.Last = last; + _login.Agent = new LLUUID((string)response["agent_id"]) ; + _login.Session = new LLUUID((string)response["session_id"]); + _login.BaseFolder = null; + _login.InventoryFolder = new LLUUID((string)Inventory1["folder_id"]); + + //working on local computer if so lets add to the gridserver's list of sessions? + if (OpenSimRoot.Instance.GridServers.GridServer.GetName() == "Local") + { + ((LocalGridBase)this._gridServer).AddNewSession(_login); + } + } + } +} diff --git a/OpenSim.RegionServer/UserServer/LoginServer.cs b/OpenSim.RegionServer/UserServer/LoginServer.cs new file mode 100644 index 0000000000..86b098a9ca --- /dev/null +++ b/OpenSim.RegionServer/UserServer/LoginServer.cs @@ -0,0 +1,414 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using Nwc.XmlRpc; +using System; +using System.IO; +using System.Net; +using System.Net.Sockets; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Collections; +using System.Security.Cryptography; +using System.Xml; +using libsecondlife; +using OpenSim; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Grid; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.User; +using OpenSim.Framework.Utilities; + +namespace OpenSim.UserServer +{ + + /// + /// When running in local (default) mode , handles client logins. + /// + public class LoginServer : LoginService , IUserServer + { + private IGridServer _gridServer; + private ushort _loginPort = 8080; + public IPAddress clientAddress = IPAddress.Loopback; + public IPAddress remoteAddress = IPAddress.Any; + private Socket loginServer; + private int NumClients; + private string _defaultResponse; + private bool userAccounts = false; + private string _mpasswd; + private bool _needPasswd = false; + private LocalUserProfileManager userManager; + + public LoginServer(IGridServer gridServer) + { + _gridServer = gridServer; + } + + // InitializeLogin: initialize the login + private void InitializeLogin() + { + this._needPasswd = false; + //read in default response string + StreamReader SR; + string lines; + SR = File.OpenText("new-login.dat"); + + //lines=SR.ReadLine(); + + while (!SR.EndOfStream) + { + lines = SR.ReadLine(); + _defaultResponse += lines; + //lines = SR.ReadLine(); + } + SR.Close(); + this._mpasswd = EncodePassword("testpass"); + + userManager = new LocalUserProfileManager(this._gridServer); + userManager.InitUserProfiles(); + userManager.SetKeys("", "", "", "Welcome to OpenSim"); + + loginServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + loginServer.Bind(new IPEndPoint(remoteAddress, _loginPort)); + loginServer.Listen(1); + } + + public void Startup() + { + this.InitializeLogin(); + Thread runLoginProxy = new Thread(new ThreadStart(RunLogin)); + runLoginProxy.IsBackground = true; + runLoginProxy.Start(); + } + + private void RunLogin() + { + Console.WriteLine("Starting Login Server"); + try + { + for (; ; ) + { + Socket client = loginServer.Accept(); + IPEndPoint clientEndPoint = (IPEndPoint)client.RemoteEndPoint; + + + NetworkStream networkStream = new NetworkStream(client); + StreamReader networkReader = new StreamReader(networkStream); + StreamWriter networkWriter = new StreamWriter(networkStream); + + try + { + LoginRequest(networkReader, networkWriter); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + + networkWriter.Close(); + networkReader.Close(); + networkStream.Close(); + + client.Close(); + + // send any packets queued for injection + + } + } + catch (Exception e) + { + Console.WriteLine(e.Message); + Console.WriteLine(e.StackTrace); + } + } + + // ProxyLogin: proxy a login request + private void LoginRequest(StreamReader reader, StreamWriter writer) + { + lock (this) + { + string line; + int contentLength = 0; + // read HTTP header + do + { + // read one line of the header + line = reader.ReadLine(); + + // check for premature EOF + if (line == null) + throw new Exception("EOF in client HTTP header"); + + // look for Content-Length + Match match = (new Regex(@"Content-Length: (\d+)$")).Match(line); + if (match.Success) + contentLength = Convert.ToInt32(match.Groups[1].Captures[0].ToString()); + } while (line != ""); + + // read the HTTP body into a buffer + char[] content = new char[contentLength]; + reader.Read(content, 0, contentLength); + + if (this.userAccounts) + { + //ask the UserProfile Manager to process the request + string reply = this.userManager.ParseXMLRPC(new String(content)); + // forward the XML-RPC response to the client + writer.WriteLine("HTTP/1.0 200 OK"); + writer.WriteLine("Content-type: text/xml"); + writer.WriteLine(); + writer.WriteLine(reply); + } + else + { + //handle ourselves + XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content)); + if (request.MethodName == "login_to_simulator") + { + this.ProcessXmlRequest(request, writer); + } + else + { + XmlRpcResponse PresenceErrorResp = new XmlRpcResponse(); + Hashtable PresenceErrorRespData = new Hashtable(); + PresenceErrorRespData["reason"] = "XmlRequest"; ; + PresenceErrorRespData["message"] = "Unknown Rpc request"; + PresenceErrorRespData["login"] = "false"; + PresenceErrorResp.Value = PresenceErrorRespData; + string reply = Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", ""); + writer.WriteLine("HTTP/1.0 200 OK"); + writer.WriteLine("Content-type: text/xml"); + writer.WriteLine(); + writer.WriteLine(reply); + } + } + } + } + + public bool ProcessXmlRequest(XmlRpcRequest request, StreamWriter writer) + { + Hashtable requestData = (Hashtable)request.Params[0]; + string first; + string last; + string passwd; + LLUUID Agent; + LLUUID Session; + + //get login name + if (requestData.Contains("first")) + { + first = (string)requestData["first"]; + } + else + { + first = "test"; + } + + if (requestData.Contains("last")) + { + last = (string)requestData["last"]; + } + else + { + last = "User" + NumClients.ToString(); + } + + if (requestData.Contains("passwd")) + { + passwd = (string)requestData["passwd"]; + } + else + { + passwd = "notfound"; + } + + if (!Authenticate(first, last, passwd)) + { + XmlRpcResponse PresenceErrorResp = new XmlRpcResponse(); + Hashtable PresenceErrorRespData = new Hashtable(); + PresenceErrorRespData["reason"] = "key"; ; + PresenceErrorRespData["message"] = "You have entered an invalid name/password combination. Check Caps/lock."; + PresenceErrorRespData["login"] = "false"; + PresenceErrorResp.Value = PresenceErrorRespData; + string reply = Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", ""); + writer.WriteLine("HTTP/1.0 200 OK"); + writer.WriteLine("Content-type: text/xml"); + writer.WriteLine(); + writer.WriteLine(reply); + return false; + } + + NumClients++; + + //create a agent and session LLUUID + Agent = GetAgentId(first, last); + int SessionRand = Util.RandomClass.Next(1, 999); + Session = new LLUUID("aaaabbbb-0200-" + SessionRand.ToString("0000") + "-8664-58f53e442797"); + LLUUID secureSess = LLUUID.Random(); + //create some login info + Hashtable LoginFlagsHash = new Hashtable(); + LoginFlagsHash["daylight_savings"] = "N"; + LoginFlagsHash["stipend_since_login"] = "N"; + LoginFlagsHash["gendered"] = "Y"; + LoginFlagsHash["ever_logged_in"] = "Y"; + ArrayList LoginFlags = new ArrayList(); + LoginFlags.Add(LoginFlagsHash); + + Hashtable GlobalT = new Hashtable(); + GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271"; + GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; + GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; + ArrayList GlobalTextures = new ArrayList(); + GlobalTextures.Add(GlobalT); + + XmlRpcResponse response = (XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this._defaultResponse); + Hashtable responseData = (Hashtable)response.Value; + + responseData["sim_port"] = OpenSimRoot.Instance.Cfg.IPListenPort; + responseData["sim_ip"] = OpenSimRoot.Instance.Cfg.IPListenAddr; + responseData["agent_id"] = Agent.ToStringHyphenated(); + responseData["session_id"] = Session.ToStringHyphenated(); + responseData["secure_session_id"]= secureSess.ToStringHyphenated(); + responseData["circuit_code"] = (Int32)(Util.RandomClass.Next()); + responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + responseData["login-flags"] = LoginFlags; + responseData["global-textures"] = GlobalTextures; + + //inventory + ArrayList InventoryList = (ArrayList)responseData["inventory-skeleton"]; + Hashtable Inventory1 = (Hashtable)InventoryList[0]; + Hashtable Inventory2 = (Hashtable)InventoryList[1]; + LLUUID BaseFolderID = LLUUID.Random(); + LLUUID InventoryFolderID = LLUUID.Random(); + Inventory2["name"] = "Base"; + Inventory2["folder_id"] = BaseFolderID.ToStringHyphenated(); + Inventory2["type_default"] = 0; + Inventory1["folder_id"] = InventoryFolderID.ToStringHyphenated(); + + ArrayList InventoryRoot = (ArrayList)responseData["inventory-root"]; + Hashtable Inventoryroot = (Hashtable)InventoryRoot[0]; + Inventoryroot["folder_id"] = InventoryFolderID.ToStringHyphenated(); + + CustomiseLoginResponse(responseData, first, last); + + Login _login = new Login(); + //copy data to login object + _login.First = first; + _login.Last = last; + _login.Agent = Agent; + _login.Session = Session; + _login.SecureSession = secureSess; + _login.BaseFolder = BaseFolderID; + _login.InventoryFolder = InventoryFolderID; + + //working on local computer if so lets add to the gridserver's list of sessions? + if (OpenSimRoot.Instance.GridServers.GridServer.GetName() == "Local") + { + ((LocalGridBase)this._gridServer).AddNewSession(_login); + } + + // forward the XML-RPC response to the client + writer.WriteLine("HTTP/1.0 200 OK"); + writer.WriteLine("Content-type: text/xml"); + writer.WriteLine(); + + XmlTextWriter responseWriter = new XmlTextWriter(writer); + XmlRpcResponseSerializer.Singleton.Serialize(responseWriter, response); + responseWriter.Close(); + + return true; + } + + protected virtual void CustomiseLoginResponse(Hashtable responseData, string first, string last) + { + } + + protected virtual LLUUID GetAgentId(string firstName, string lastName) + { + LLUUID Agent; + int AgentRand = Util.RandomClass.Next(1, 9999); + Agent = new LLUUID("99998888-0100-" + AgentRand.ToString("0000") + "-8ec1-0b1d5cd6aead"); + return Agent; + } + + protected virtual bool Authenticate(string first, string last, string passwd) + { + if (this._needPasswd) + { + //every user needs the password to login + string encodedPass = passwd.Remove(0, 3); //remove $1$ + if (encodedPass == this._mpasswd) + { + return true; + } + else + { + return false; + } + } + else + { + //do not need password to login + return true; + } + } + + private static string EncodePassword(string passwd) + { + Byte[] originalBytes; + Byte[] encodedBytes; + MD5 md5; + + md5 = new MD5CryptoServiceProvider(); + originalBytes = ASCIIEncoding.Default.GetBytes(passwd); + encodedBytes = md5.ComputeHash(originalBytes); + + return Regex.Replace(BitConverter.ToString(encodedBytes), "-", "").ToLower(); + } + + //IUserServer implementation + public AgentInventory RequestAgentsInventory(LLUUID agentID) + { + AgentInventory aInventory = null; + if (this.userAccounts) + { + aInventory = this.userManager.GetUsersInventory(agentID); + } + + return aInventory; + } + + public void SetServerInfo(string ServerUrl, string SendKey, string RecvKey) + { + + } + + } + + +} diff --git a/src/VersionInfo.cs b/OpenSim.RegionServer/VersionInfo.cs similarity index 88% rename from src/VersionInfo.cs rename to OpenSim.RegionServer/VersionInfo.cs index 5cfd13635a..39767df665 100644 --- a/src/VersionInfo.cs +++ b/OpenSim.RegionServer/VersionInfo.cs @@ -28,10 +28,10 @@ using System; namespace OpenSim { - /// - /// - public class VersionInfo - { - public static string Version = "0.1, Build 1174381410, Revision 240M"; - } + /// + /// + public class VersionInfo + { + public static string Version = "0.1, Build 1173843165, Revision 193:206M"; + } } diff --git a/src/types/Mesh.cs b/OpenSim.RegionServer/types/Mesh.cs similarity index 100% rename from src/types/Mesh.cs rename to OpenSim.RegionServer/types/Mesh.cs diff --git a/src/types/Triangle.cs b/OpenSim.RegionServer/types/Triangle.cs similarity index 100% rename from src/types/Triangle.cs rename to OpenSim.RegionServer/types/Triangle.cs diff --git a/OpenSim.RegionServer/world/Avatar.cs b/OpenSim.RegionServer/world/Avatar.cs new file mode 100644 index 0000000000..b4a3b82d85 --- /dev/null +++ b/OpenSim.RegionServer/world/Avatar.cs @@ -0,0 +1,501 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.Physics.Manager; +using Axiom.MathLib; + +namespace OpenSim.world +{ + public class Avatar : Entity + { + public static bool PhysicsEngineFlying = false; + public string firstname; + public string lastname; + public SimClient ControllingClient; + private PhysicsActor _physActor; + private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; + private bool updateflag = false; + private byte movementflag = 0; + private List forcesList = new List(); + private short _updateCount = 0; + private Axiom.MathLib.Quaternion bodyRot; + + public Avatar(SimClient TheClient) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); + ControllingClient = TheClient; + localid = 8880000 + (OpenSimRoot.Instance.LocalWorld._localNumber++); + position = new LLVector3(100.0f, 100.0f, 30.0f); + position.Z = OpenSimRoot.Instance.LocalWorld.LandMap[(int)position.Y * 256 + (int)position.X] + 1; + } + + public PhysicsActor PhysActor + { + set + { + this._physActor = value; + } + } + + public override void addForces() + { + lock (this.forcesList) + { + if (this.forcesList.Count > 0) + { + for (int i = 0; i < this.forcesList.Count; i++) + { + NewForce force = this.forcesList[i]; + PhysicsVector phyVector = new PhysicsVector(force.X, force.Y, force.Z); + this._physActor.Velocity = phyVector; + this.updateflag = true; + this.velocity = new LLVector3(force.X, force.Y, force.Z); //shouldn't really be doing this + // but as we are setting the velocity (rather than using real forces) at the moment it is okay. + } + for (int i = 0; i < this.forcesList.Count; i++) + { + this.forcesList.RemoveAt(0); + } + } + } + } + + public override void update() + { + + if (this.updateflag) + { + //need to send movement info + //so create the improvedterseobjectupdate packet + //use CreateTerseBlock() + ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); + ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); + terse.RegionData.RegionHandle = OpenSimRoot.Instance.Cfg.RegionHandle; // FIXME + terse.RegionData.TimeDilation = 64096; + terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; + terse.ObjectData[0] = terseBlock; + foreach (SimClient client in OpenSimRoot.Instance.ClientThreads.Values) + { + client.OutPacket(terse); + } + + updateflag = false; + //this._updateCount = 0; + } + else + { + //if((movementflag & 1) !=0) + //{ + _updateCount++; + if (((!PhysicsEngineFlying) && (_updateCount > 3)) || (_updateCount > 0)) + { + //It has been a while since last update was sent so lets send one. + ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); + ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); + terse.RegionData.RegionHandle = OpenSimRoot.Instance.Cfg.RegionHandle; // FIXME + terse.RegionData.TimeDilation = 64096; + terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; + terse.ObjectData[0] = terseBlock; + foreach (SimClient client in OpenSimRoot.Instance.ClientThreads.Values) + { + client.OutPacket(terse); + } + _updateCount = 0; + } + //} + } + } + + public static void SetupTemplate(string name) + { + int i = 0; + FileInfo fInfo = new FileInfo(name); + long numBytes = fInfo.Length; + FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); + BinaryReader br = new BinaryReader(fStream); + byte[] data1 = br.ReadBytes((int)numBytes); + br.Close(); + fStream.Close(); + + libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); + + System.Text.Encoding enc = System.Text.Encoding.ASCII; + libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16); + pos.X = 100f; + objdata.ID = 8880000; + objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); + libsecondlife.LLVector3 pos2 = new LLVector3(100f, 100f, 23f); + //objdata.FullID=user.AgentID; + byte[] pb = pos.GetBytes(); + Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length); + + Avatar.AvatarTemplate = objdata; + } + + public void CompleteMovement(World RegionInfo) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet"); + AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); + mov.AgentData.SessionID = this.ControllingClient.SessionID; + mov.AgentData.AgentID = this.ControllingClient.AgentID; + mov.Data.RegionHandle = OpenSimRoot.Instance.Cfg.RegionHandle; + // TODO - dynamicalise this stuff + mov.Data.Timestamp = 1172750370; + mov.Data.Position = new LLVector3(100f, 100f, 23f); + mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0); + + ControllingClient.OutPacket(mov); + } + + public void SendInitialPosition() + { + + System.Text.Encoding _enc = System.Text.Encoding.ASCII; + //send a objectupdate packet with information about the clients avatar + ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); + objupdate.RegionData.RegionHandle = OpenSimRoot.Instance.Cfg.RegionHandle; + objupdate.RegionData.TimeDilation = 64096; + objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; + + objupdate.ObjectData[0] = AvatarTemplate; + //give this avatar object a local id and assign the user a name + objupdate.ObjectData[0].ID = this.localid; + this.uuid = objupdate.ObjectData[0].FullID = ControllingClient.AgentID; + objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0"); + + libsecondlife.LLVector3 pos2 = new LLVector3((float)this.position.X, (float)this.position.Y, (float)this.position.Z); + + byte[] pb = pos2.GetBytes(); + + Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); + OpenSimRoot.Instance.LocalWorld._localNumber++; + + foreach (SimClient client in OpenSimRoot.Instance.ClientThreads.Values) + { + client.OutPacket(objupdate); + if (client.AgentID != ControllingClient.AgentID) + { + SendAppearanceToOtherAgent(client); + } + } + //this.ControllingClient.OutPacket(objupdate); + } + + public void SendInitialAppearance() + { + AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); + aw.AgentData.AgentID = this.ControllingClient.AgentID; + aw.AgentData.SerialNum = 0; + aw.AgentData.SessionID = ControllingClient.SessionID; + + aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; + AgentWearablesUpdatePacket.WearableDataBlock awb = new AgentWearablesUpdatePacket.WearableDataBlock(); + awb.WearableType = (byte)0; + awb.AssetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); + awb.ItemID = LLUUID.Random(); + aw.WearableData[0] = awb; + + for (int i = 1; i < 13; i++) + { + awb = new AgentWearablesUpdatePacket.WearableDataBlock(); + awb.WearableType = (byte)i; + awb.AssetID = new LLUUID("00000000-0000-0000-0000-000000000000"); + awb.ItemID = new LLUUID("00000000-0000-0000-0000-000000000000"); + aw.WearableData[i] = awb; + } + + ControllingClient.OutPacket(aw); + } + + public ObjectUpdatePacket CreateUpdatePacket() + { + System.Text.Encoding _enc = System.Text.Encoding.ASCII; + //send a objectupdate packet with information about the clients avatar + ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); + objupdate.RegionData.RegionHandle = OpenSimRoot.Instance.Cfg.RegionHandle; + objupdate.RegionData.TimeDilation = 64096; + objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; + + objupdate.ObjectData[0] = AvatarTemplate; + //give this avatar object a local id and assign the user a name + objupdate.ObjectData[0].ID = this.localid; + objupdate.ObjectData[0].FullID = ControllingClient.AgentID; + objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0"); + + libsecondlife.LLVector3 pos2 = new LLVector3((float)this._physActor.Position.X, (float)this._physActor.Position.Y, (float)this._physActor.Position.Z); + + byte[] pb = pos2.GetBytes(); + + Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); + return objupdate; + } + + public void SendAppearanceToOtherAgent(SimClient userInfo) + { + AvatarAppearancePacket avp = new AvatarAppearancePacket(); + + + avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218]; + //avp.ObjectData.TextureEntry=this.avatar_template.TextureEntry;// br.ReadBytes((int)numBytes); + + LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-0000-000000000005")); + avp.ObjectData.TextureEntry = ntex.ToBytes(); + + AvatarAppearancePacket.VisualParamBlock avblock = null; + for (int i = 0; i < 218; i++) + { + avblock = new AvatarAppearancePacket.VisualParamBlock(); + avblock.ParamValue = (byte)100; + avp.VisualParam[i] = avblock; + } + + avp.Sender.IsTrial = false; + avp.Sender.ID = ControllingClient.AgentID; + userInfo.OutPacket(avp); + + } + + public void HandleUpdate(AgentUpdatePacket pack) + { + if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_FLY) != 0) + { + this._physActor.Flying = true; + } + else + { + this._physActor.Flying = false; + } + if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_POS) != 0) + { + Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z); + if (((movementflag & 1) == 0) || (q != this.bodyRot)) + { + //we should add a new force to the list + // but for now we will deal with velocities + NewForce newVelocity = new NewForce(); + Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0); + Axiom.MathLib.Vector3 direc = q * v3; + direc.Normalize(); + + //work out velocity for sim physics system + direc = direc * ((0.03f) * 128f); + if (this._physActor.Flying) + direc *= 2; + + newVelocity.X = direc.x; + newVelocity.Y = direc.y; + newVelocity.Z = direc.z; + this.forcesList.Add(newVelocity); + movementflag = 1; + this.bodyRot = q; + } + } + else if ((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_UP_POS) != 0) && (PhysicsEngineFlying)) + { + if (((movementflag & 2) == 0) && this._physActor.Flying) + { + //we should add a new force to the list + // but for now we will deal with velocities + NewForce newVelocity = new NewForce(); + Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, 1); + Axiom.MathLib.Vector3 direc = v3; + direc.Normalize(); + + //work out velocity for sim physics system + direc = direc * ((0.03f) * 128f * 2); + newVelocity.X = direc.x; + newVelocity.Y = direc.y; + newVelocity.Z = direc.z; + this.forcesList.Add(newVelocity); + movementflag = 2; + } + } + else if ((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_UP_NEG) != 0) && (PhysicsEngineFlying)) + { + if (((movementflag & 4) == 0) && this._physActor.Flying) + { + //we should add a new force to the list + // but for now we will deal with velocities + NewForce newVelocity = new NewForce(); + Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, -1); + //Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z); + Axiom.MathLib.Vector3 direc = v3; + direc.Normalize(); + + //work out velocity for sim physics system + direc = direc * ((0.03f) * 128f * 2); + newVelocity.X = direc.x; + newVelocity.Y = direc.y; + newVelocity.Z = direc.z; + this.forcesList.Add(newVelocity); + movementflag = 4; + } + } + else if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_NEG) != 0) + { + Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z); + if (((movementflag & 8) == 0) || (q != this.bodyRot)) + { + //we should add a new force to the list + // but for now we will deal with velocities + NewForce newVelocity = new NewForce(); + Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(-1, 0, 0); + Axiom.MathLib.Vector3 direc = q * v3; + direc.Normalize(); + + //work out velocity for sim physics system + direc = direc * ((0.03f) * 128f); + if (this._physActor.Flying) + direc *= 2; + + newVelocity.X = direc.x; + newVelocity.Y = direc.y; + newVelocity.Z = direc.z; + this.forcesList.Add(newVelocity); + movementflag = 8; + this.bodyRot = q; + } + } + else + { + if ((movementflag) != 0) + { + NewForce newVelocity = new NewForce(); + newVelocity.X = 0; + newVelocity.Y = 0; + newVelocity.Z = 0; + this.forcesList.Add(newVelocity); + movementflag = 0; + } + } + } + + //should be moved somewhere else + public void SendRegionHandshake(World RegionInfo) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet"); + System.Text.Encoding _enc = System.Text.Encoding.ASCII; + RegionHandshakePacket handshake = new RegionHandshakePacket(); + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionhandshake() - Filling in RegionHandshake details"); + handshake.RegionInfo.BillableFactor = 0; + handshake.RegionInfo.IsEstateManager = false; + handshake.RegionInfo.TerrainHeightRange00 = 60; + handshake.RegionInfo.TerrainHeightRange01 = 60; + handshake.RegionInfo.TerrainHeightRange10 = 60; + handshake.RegionInfo.TerrainHeightRange11 = 60; + handshake.RegionInfo.TerrainStartHeight00 = 10; + handshake.RegionInfo.TerrainStartHeight01 = 10; + handshake.RegionInfo.TerrainStartHeight10 = 10; + handshake.RegionInfo.TerrainStartHeight11 = 10; + handshake.RegionInfo.SimAccess = 13; + handshake.RegionInfo.WaterHeight = 20; + handshake.RegionInfo.RegionFlags = 72458694; + handshake.RegionInfo.SimName = _enc.GetBytes(OpenSimRoot.Instance.Cfg.RegionName + "\0"); + handshake.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000"); + handshake.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); + handshake.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); + handshake.RegionInfo.TerrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); + handshake.RegionInfo.TerrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); + handshake.RegionInfo.TerrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000"); + handshake.RegionInfo.TerrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000"); + handshake.RegionInfo.TerrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000"); + handshake.RegionInfo.TerrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000"); + handshake.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37"); + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Sending RegionHandshake packet"); + this.ControllingClient.OutPacket(handshake); + } + + public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock() + { + byte[] bytes = new byte[60]; + int i = 0; + ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); + + dat.TextureEntry = AvatarTemplate.TextureEntry; + libsecondlife.LLVector3 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z); + + uint ID = this.localid; + + bytes[i++] = (byte)(ID % 256); + bytes[i++] = (byte)((ID >> 8) % 256); + bytes[i++] = (byte)((ID >> 16) % 256); + bytes[i++] = (byte)((ID >> 24) % 256); + bytes[i++] = 0; + bytes[i++] = 1; + i += 14; + bytes[i++] = 128; + bytes[i++] = 63; + + byte[] pb = pos2.GetBytes(); + Array.Copy(pb, 0, bytes, i, pb.Length); + i += 12; + ushort InternVelocityX; + ushort InternVelocityY; + ushort InternVelocityZ; + + Axiom.MathLib.Vector3 internDirec = new Axiom.MathLib.Vector3(this._physActor.Velocity.X, this._physActor.Velocity.Y, this._physActor.Velocity.Z); + internDirec = internDirec / 128.0f; + internDirec.x += 1; + internDirec.y += 1; + internDirec.z += 1; + + InternVelocityX = (ushort)(32768 * internDirec.x); + InternVelocityY = (ushort)(32768 * internDirec.y); + InternVelocityZ = (ushort)(32768 * internDirec.z); + + ushort ac = 32767; + bytes[i++] = (byte)(InternVelocityX % 256); + bytes[i++] = (byte)((InternVelocityX >> 8) % 256); + bytes[i++] = (byte)(InternVelocityY % 256); + bytes[i++] = (byte)((InternVelocityY >> 8) % 256); + bytes[i++] = (byte)(InternVelocityZ % 256); + bytes[i++] = (byte)((InternVelocityZ >> 8) % 256); + + //accel + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + + //rot + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + + //rotation vel + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + + dat.Data = bytes; + return (dat); + } + } + + public class NewForce + { + public float X; + public float Y; + public float Z; + + public NewForce() + { + + } + } +} diff --git a/src/world/Entity.cs b/OpenSim.RegionServer/world/Entity.cs similarity index 90% rename from src/world/Entity.cs rename to OpenSim.RegionServer/world/Entity.cs index ee4b2e4826..780f3a0449 100644 --- a/src/world/Entity.cs +++ b/OpenSim.RegionServer/world/Entity.cs @@ -20,7 +20,7 @@ namespace OpenSim.world public Entity() { uuid = new libsecondlife.LLUUID(); - localid = 8880000 + (OpenSim_Main.local_world._localNumber++); // FIXME - race condition! + localid = 0; position = new LLVector3(); velocity = new LLVector3(); rotation = new Quaternion(); diff --git a/OpenSim.RegionServer/world/Primitive.cs b/OpenSim.RegionServer/world/Primitive.cs new file mode 100644 index 0000000000..b190d818df --- /dev/null +++ b/OpenSim.RegionServer/world/Primitive.cs @@ -0,0 +1,485 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.types; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.Framework.Interfaces; +using OpenSim.Physics.Manager; +using OpenSim.Framework.Assets; + +namespace OpenSim.world +{ + public class Primitive : Entity + { + protected float mesh_cutbegin; + protected float mesh_cutend; + protected PrimData primData; + protected bool newPrimFlag = false; + protected bool updateFlag = false; + protected bool dirtyFlag = false; + private ObjectUpdatePacket OurPacket; + private PhysicsActor _physActor; + private bool physicsEnabled = false; + private bool physicstest = false; //just added for testing + + public bool PhysicsEnabled + { + get + { + return physicsEnabled; + } + set + { + physicsEnabled = value; + } + } + public bool UpdateFlag + { + get + { + return updateFlag; + } + set + { + updateFlag = value; + } + } + public LLVector3 Scale + { + set + { + this.primData.Scale = value; + this.dirtyFlag = true; + } + get + { + return this.primData.Scale; + } + } + public PhysicsActor PhysActor + { + set + { + this._physActor = value; + } + } + + public Primitive() + { + mesh_cutbegin = 0.0f; + mesh_cutend = 1.0f; + } + + public override Mesh getMesh() + { + Mesh mesh = new Mesh(); + Triangle tri = new Triangle( + new Axiom.MathLib.Vector3(0.0f, 1.0f, 1.0f), + new Axiom.MathLib.Vector3(1.0f, 0.0f, 1.0f), + new Axiom.MathLib.Vector3(1.0f, 1.0f, 0.0f)); + + mesh.AddTri(tri); + mesh += base.getMesh(); + + return mesh; + } + + public void UpdatePosition(LLVector3 pos) + { + this.position = pos; + if (this._physActor != null) // && this.physicsEnabled) + { + this._physActor.Position = new PhysicsVector(pos.X, pos.Y, pos.Z); + } + this.updateFlag = true; + } + + public override void update() + { + if (this.newPrimFlag) + { + foreach (SimClient client in OpenSimRoot.Instance.ClientThreads.Values) + { + client.OutPacket(OurPacket); + } + this.newPrimFlag = false; + } + else if (this.updateFlag) + { + ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); + terse.RegionData.RegionHandle = OpenSimRoot.Instance.Cfg.RegionHandle; // FIXME + terse.RegionData.TimeDilation = 64096; + terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; + terse.ObjectData[0] = this.CreateImprovedBlock(); + foreach (SimClient client in OpenSimRoot.Instance.ClientThreads.Values) + { + client.OutPacket(terse); + } + this.updateFlag = false; + } + else if (this.dirtyFlag) + { + foreach (SimClient client in OpenSimRoot.Instance.ClientThreads.Values) + { + UpdateClient(client); + } + this.dirtyFlag = false; + } + else + { + if (this._physActor != null && this.physicsEnabled) + { + ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); + terse.RegionData.RegionHandle = OpenSimRoot.Instance.Cfg.RegionHandle; // FIXME + terse.RegionData.TimeDilation = 64096; + terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; + terse.ObjectData[0] = this.CreateImprovedBlock(); + foreach (SimClient client in OpenSimRoot.Instance.ClientThreads.Values) + { + client.OutPacket(terse); + } + } + } + + if (this.physicstest) + { + LLVector3 pos = this.position; + pos.Z += 0.0001f; + this.UpdatePosition(pos); + this.physicstest = false; + } + } + + public void UpdateClient(SimClient RemoteClient) + { + + LLVector3 lPos; + if (this._physActor != null && this.physicsEnabled) + { + PhysicsVector pPos = this._physActor.Position; + lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); + } + else + { + lPos = this.position; + } + byte[] pb = lPos.GetBytes(); + Array.Copy(pb, 0, OurPacket.ObjectData[0].ObjectData, 0, pb.Length); + + // OurPacket should be update with the follwing in updateShape() rather than having to do it here + OurPacket.ObjectData[0].OwnerID = this.primData.OwnerID; + OurPacket.ObjectData[0].PCode = this.primData.PCode; + OurPacket.ObjectData[0].PathBegin = this.primData.PathBegin; + OurPacket.ObjectData[0].PathEnd = this.primData.PathEnd; + OurPacket.ObjectData[0].PathScaleX = this.primData.PathScaleX; + OurPacket.ObjectData[0].PathScaleY = this.primData.PathScaleY; + OurPacket.ObjectData[0].PathShearX = this.primData.PathShearX; + OurPacket.ObjectData[0].PathShearY = this.primData.PathShearY; + OurPacket.ObjectData[0].PathSkew = this.primData.PathSkew; + OurPacket.ObjectData[0].ProfileBegin = this.primData.ProfileBegin; + OurPacket.ObjectData[0].ProfileEnd = this.primData.ProfileEnd; + OurPacket.ObjectData[0].Scale = this.primData.Scale; + OurPacket.ObjectData[0].PathCurve = this.primData.PathCurve; + OurPacket.ObjectData[0].ProfileCurve = this.primData.ProfileCurve; + OurPacket.ObjectData[0].ParentID = 0; + OurPacket.ObjectData[0].ProfileHollow = this.primData.ProfileHollow; + //finish off copying rest of shape data + OurPacket.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset; + OurPacket.ObjectData[0].PathRevolutions = this.primData.PathRevolutions; + OurPacket.ObjectData[0].PathTaperX = this.primData.PathTaperX; + OurPacket.ObjectData[0].PathTaperY = this.primData.PathTaperY; + OurPacket.ObjectData[0].PathTwist = this.primData.PathTwist; + OurPacket.ObjectData[0].PathTwistBegin = this.primData.PathTwistBegin; + + RemoteClient.OutPacket(OurPacket); + } + + public void UpdateShape(ObjectShapePacket.ObjectDataBlock addPacket) + { + this.primData.PathBegin = addPacket.PathBegin; + this.primData.PathEnd = addPacket.PathEnd; + this.primData.PathScaleX = addPacket.PathScaleX; + this.primData.PathScaleY = addPacket.PathScaleY; + this.primData.PathShearX = addPacket.PathShearX; + this.primData.PathShearY = addPacket.PathShearY; + this.primData.PathSkew = addPacket.PathSkew; + this.primData.ProfileBegin = addPacket.ProfileBegin; + this.primData.ProfileEnd = addPacket.ProfileEnd; + this.primData.PathCurve = addPacket.PathCurve; + this.primData.ProfileCurve = addPacket.ProfileCurve; + this.primData.ProfileHollow = addPacket.ProfileHollow; + this.primData.PathRadiusOffset = addPacket.PathRadiusOffset; + this.primData.PathRevolutions = addPacket.PathRevolutions; + this.primData.PathTaperX = addPacket.PathTaperX; + this.primData.PathTaperY = addPacket.PathTaperY; + this.primData.PathTwist = addPacket.PathTwist; + this.primData.PathTwistBegin = addPacket.PathTwistBegin; + this.dirtyFlag = true; + } + + public void UpdateTexture(byte[] tex) + { + this.primData.Texture = this.OurPacket.ObjectData[0].TextureEntry = tex; + this.dirtyFlag = true; + } + + public void UpdateObjectFlags(ObjectFlagUpdatePacket pack) + { + if (this._physActor != null) + { + if (this._physActor.Kinematic == pack.AgentData.UsePhysics) + { + this._physActor.Kinematic = !pack.AgentData.UsePhysics; //if Usephysics = true, then Kinematic should = false + } + this.physicsEnabled = pack.AgentData.UsePhysics; + if (this._physActor.Kinematic == false) + { + LLVector3 pos = this.position; + this.UpdatePosition(pos); + pos.Z += 0.000001f; + this.UpdatePosition(pos); + this.physicstest = true; + } + else + { + PhysicsVector vec = this._physActor.Position; + LLVector3 pos = new LLVector3(vec.X, vec.Y, vec.Z); + this.position = pos; + this.updateFlag = true; + } + } + } + + public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID) + { + ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); + objupdate.RegionData.RegionHandle = OpenSimRoot.Instance.Cfg.RegionHandle; + objupdate.RegionData.TimeDilation = 64096; + + objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; + PrimData PData = new PrimData(); + this.primData = PData; + objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock(); + objupdate.ObjectData[0].PSBlock = new byte[0]; + objupdate.ObjectData[0].ExtraParams = new byte[1]; + objupdate.ObjectData[0].MediaURL = new byte[0]; + objupdate.ObjectData[0].NameValue = new byte[0]; + objupdate.ObjectData[0].Text = new byte[0]; + objupdate.ObjectData[0].TextColor = new byte[4]; + objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0, 0, 0); + objupdate.ObjectData[0].JointPivot = new LLVector3(0, 0, 0); + objupdate.ObjectData[0].Material = 3; + objupdate.ObjectData[0].UpdateFlags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456; + objupdate.ObjectData[0].TextureAnim = new byte[0]; + objupdate.ObjectData[0].Sound = LLUUID.Zero; + LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); + objupdate.ObjectData[0].TextureEntry = ntex.ToBytes(); + objupdate.ObjectData[0].State = 0; + objupdate.ObjectData[0].Data = new byte[0]; + PData.OwnerID = objupdate.ObjectData[0].OwnerID = agentID; + PData.PCode = objupdate.ObjectData[0].PCode = addPacket.ObjectData.PCode; + PData.PathBegin = objupdate.ObjectData[0].PathBegin = addPacket.ObjectData.PathBegin; + PData.PathEnd = objupdate.ObjectData[0].PathEnd = addPacket.ObjectData.PathEnd; + PData.PathScaleX = objupdate.ObjectData[0].PathScaleX = addPacket.ObjectData.PathScaleX; + PData.PathScaleY = objupdate.ObjectData[0].PathScaleY = addPacket.ObjectData.PathScaleY; + PData.PathShearX = objupdate.ObjectData[0].PathShearX = addPacket.ObjectData.PathShearX; + PData.PathShearY = objupdate.ObjectData[0].PathShearY = addPacket.ObjectData.PathShearY; + PData.PathSkew = objupdate.ObjectData[0].PathSkew = addPacket.ObjectData.PathSkew; + PData.ProfileBegin = objupdate.ObjectData[0].ProfileBegin = addPacket.ObjectData.ProfileBegin; + PData.ProfileEnd = objupdate.ObjectData[0].ProfileEnd = addPacket.ObjectData.ProfileEnd; + PData.Scale = objupdate.ObjectData[0].Scale = addPacket.ObjectData.Scale; + PData.PathCurve = objupdate.ObjectData[0].PathCurve = addPacket.ObjectData.PathCurve; + PData.ProfileCurve = objupdate.ObjectData[0].ProfileCurve = addPacket.ObjectData.ProfileCurve; + PData.ParentID = objupdate.ObjectData[0].ParentID = 0; + PData.ProfileHollow = objupdate.ObjectData[0].ProfileHollow = addPacket.ObjectData.ProfileHollow; + + PData.PathRadiusOffset = objupdate.ObjectData[0].PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset; + PData.PathRevolutions = objupdate.ObjectData[0].PathRevolutions = addPacket.ObjectData.PathRevolutions; + PData.PathTaperX = objupdate.ObjectData[0].PathTaperX = addPacket.ObjectData.PathTaperX; + PData.PathTaperY = objupdate.ObjectData[0].PathTaperY = addPacket.ObjectData.PathTaperY; + PData.PathTwist = objupdate.ObjectData[0].PathTwist = addPacket.ObjectData.PathTwist; + PData.PathTwistBegin = objupdate.ObjectData[0].PathTwistBegin = addPacket.ObjectData.PathTwistBegin; + + objupdate.ObjectData[0].ID = (uint)(localID); + objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efef" + (localID - 702000).ToString("00000")); + objupdate.ObjectData[0].ObjectData = new byte[60]; + objupdate.ObjectData[0].ObjectData[46] = 128; + objupdate.ObjectData[0].ObjectData[47] = 63; + LLVector3 pos1 = addPacket.ObjectData.RayEnd; + //update position + byte[] pb = pos1.GetBytes(); + Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length); + + this.newPrimFlag = true; + this.uuid = objupdate.ObjectData[0].FullID; + this.localid = objupdate.ObjectData[0].ID; + this.position = pos1; + this.OurPacket = objupdate; + } + + public void CreateFromStorage(PrimData store) + { + //need to clean this up as it shares a lot of code with CreateFromPacket() + ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); + objupdate.RegionData.RegionHandle = OpenSimRoot.Instance.Cfg.RegionHandle; + objupdate.RegionData.TimeDilation = 64096; + objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; + + this.primData = store; + objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock(); + objupdate.ObjectData[0].PSBlock = new byte[0]; + objupdate.ObjectData[0].ExtraParams = new byte[1]; + objupdate.ObjectData[0].MediaURL = new byte[0]; + objupdate.ObjectData[0].NameValue = new byte[0]; + objupdate.ObjectData[0].Text = new byte[0]; + objupdate.ObjectData[0].TextColor = new byte[4]; + objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0, 0, 0); + objupdate.ObjectData[0].JointPivot = new LLVector3(0, 0, 0); + objupdate.ObjectData[0].Material = 3; + objupdate.ObjectData[0].UpdateFlags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456; + objupdate.ObjectData[0].TextureAnim = new byte[0]; + objupdate.ObjectData[0].Sound = LLUUID.Zero; + + if (store.Texture == null) + { + LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); + objupdate.ObjectData[0].TextureEntry = ntex.ToBytes(); + } + else + { + objupdate.ObjectData[0].TextureEntry = store.Texture; + } + + objupdate.ObjectData[0].State = 0; + objupdate.ObjectData[0].Data = new byte[0]; + objupdate.ObjectData[0].OwnerID = this.primData.OwnerID; + objupdate.ObjectData[0].PCode = this.primData.PCode; + objupdate.ObjectData[0].PathBegin = this.primData.PathBegin; + objupdate.ObjectData[0].PathEnd = this.primData.PathEnd; + objupdate.ObjectData[0].PathScaleX = this.primData.PathScaleX; + objupdate.ObjectData[0].PathScaleY = this.primData.PathScaleY; + objupdate.ObjectData[0].PathShearX = this.primData.PathShearX; + objupdate.ObjectData[0].PathShearY = this.primData.PathShearY; + objupdate.ObjectData[0].PathSkew = this.primData.PathSkew; + objupdate.ObjectData[0].ProfileBegin = this.primData.ProfileBegin; + objupdate.ObjectData[0].ProfileEnd = this.primData.ProfileEnd; + objupdate.ObjectData[0].Scale = this.primData.Scale; + objupdate.ObjectData[0].PathCurve = this.primData.PathCurve; + objupdate.ObjectData[0].ProfileCurve = this.primData.ProfileCurve; + objupdate.ObjectData[0].ParentID = 0; + objupdate.ObjectData[0].ProfileHollow = this.primData.ProfileHollow; + //finish off copying rest of shape data + objupdate.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset; + objupdate.ObjectData[0].PathRevolutions = this.primData.PathRevolutions; + objupdate.ObjectData[0].PathTaperX = this.primData.PathTaperX; + objupdate.ObjectData[0].PathTaperY = this.primData.PathTaperY; + objupdate.ObjectData[0].PathTwist = this.primData.PathTwist; + objupdate.ObjectData[0].PathTwistBegin = this.primData.PathTwistBegin; + + objupdate.ObjectData[0].ID = (uint)store.LocalID; + objupdate.ObjectData[0].FullID = store.FullID; + + objupdate.ObjectData[0].ObjectData = new byte[60]; + objupdate.ObjectData[0].ObjectData[46] = 128; + objupdate.ObjectData[0].ObjectData[47] = 63; + LLVector3 pos1 = store.Position; + //update position + byte[] pb = pos1.GetBytes(); + Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length); + + this.uuid = objupdate.ObjectData[0].FullID; + this.localid = objupdate.ObjectData[0].ID; + this.position = pos1; + this.OurPacket = objupdate; + + } + public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock() + { + uint ID = this.localid; + byte[] bytes = new byte[60]; + + int i = 0; + ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); + dat.TextureEntry = this.OurPacket.ObjectData[0].TextureEntry; + + bytes[i++] = (byte)(ID % 256); + bytes[i++] = (byte)((ID >> 8) % 256); + bytes[i++] = (byte)((ID >> 16) % 256); + bytes[i++] = (byte)((ID >> 24) % 256); + bytes[i++] = 0; + bytes[i++] = 0; + + LLVector3 lPos; + Axiom.MathLib.Quaternion lRot; + if (this._physActor != null && this.physicsEnabled) + { + PhysicsVector pPos = this._physActor.Position; + lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); + lRot = this._physActor.Orientation; + } + else + { + lPos = this.position; + lRot = this.rotation; + } + byte[] pb = lPos.GetBytes(); + Array.Copy(pb, 0, bytes, i, pb.Length); + i += 12; + ushort ac = 32767; + + //vel + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + + //accel + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + + ushort rw, rx, ry, rz; + rw = (ushort)(32768 * (lRot.w + 1)); + rx = (ushort)(32768 * (lRot.x + 1)); + ry = (ushort)(32768 * (lRot.y + 1)); + rz = (ushort)(32768 * (lRot.z + 1)); + + //rot + bytes[i++] = (byte)(rx % 256); + bytes[i++] = (byte)((rx >> 8) % 256); + bytes[i++] = (byte)(ry % 256); + bytes[i++] = (byte)((ry >> 8) % 256); + bytes[i++] = (byte)(rz % 256); + bytes[i++] = (byte)((rz >> 8) % 256); + bytes[i++] = (byte)(rw % 256); + bytes[i++] = (byte)((rw >> 8) % 256); + + //rotation vel + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(ac % 256); + bytes[i++] = (byte)((ac >> 8) % 256); + + dat.Data = bytes; + return dat; + } + + public override void BackUp() + { + this.primData.FullID = this.uuid; + this.primData.LocalID = this.localid; + this.primData.Position = this.position; + this.primData.Rotation = new LLQuaternion(this.rotation.x, this.rotation.y, this.rotation.z, this.rotation.w); + OpenSimRoot.Instance.LocalWorld.localStorage.StorePrim(this.primData); + } + } + +} diff --git a/src/world/ScriptEngine.cs b/OpenSim.RegionServer/world/ScriptEngine.cs similarity index 100% rename from src/world/ScriptEngine.cs rename to OpenSim.RegionServer/world/ScriptEngine.cs diff --git a/src/world/SurfacePatch.cs b/OpenSim.RegionServer/world/SurfacePatch.cs similarity index 100% rename from src/world/SurfacePatch.cs rename to OpenSim.RegionServer/world/SurfacePatch.cs diff --git a/src/world/World.cs b/OpenSim.RegionServer/world/World.cs similarity index 69% rename from src/world/World.cs rename to OpenSim.RegionServer/world/World.cs index e1c84bc09d..ba99233688 100644 --- a/src/world/World.cs +++ b/OpenSim.RegionServer/world/World.cs @@ -5,8 +5,10 @@ using System.Collections.Generic; using System.Text; using System.Reflection; using System.IO; -using PhysicsSystem; -using GridInterfaces; +using OpenSim.Physics.Manager; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; +using OpenSim.Framework.Terrain; namespace OpenSim.world { @@ -26,10 +28,10 @@ namespace OpenSim.world public World() { - ServerConsole.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance"); Entities = new Dictionary(); - ServerConsole.MainConsole.Instance.WriteLine("World.cs - creating LandMap"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating LandMap"); TerrainManager = new TerrainManager(new SecondLife()); Avatar.SetupTemplate("avatar-template.dat"); // ServerConsole.MainConsole.Instance.WriteLine("World.cs - Creating script engine instance"); @@ -71,7 +73,7 @@ namespace OpenSim.world //backup world data this.storageCount++; - if(storageCount> 300) //set to how often you want to backup + if(storageCount> 1200) //set to how often you want to backup { this.Backup(); storageCount =0; @@ -112,15 +114,15 @@ namespace OpenSim.world HeightmapGenHills hills = new HeightmapGenHills(); this.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); this.phyScene.SetTerrain(this.LandMap); - OpenSim_Main.cfg.SaveMap(); + OpenSimRoot.Instance.Cfg.SaveMap(this.LandMap); - foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) { + foreach(SimClient client in OpenSimRoot.Instance.ClientThreads.Values) { this.SendLayerData(client); } } public void LoadPrimsFromStorage() { - ServerConsole.MainConsole.Instance.WriteLine("World.cs: LoadPrimsFromStorage() - Loading primitives"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: LoadPrimsFromStorage() - Loading primitives"); this.localStorage.LoadPrimitives(this); } @@ -130,7 +132,7 @@ namespace OpenSim.world { _primCount = prim.LocalID + 1; } - ServerConsole.MainConsole.Instance.WriteLine("World.cs: PrimFromStorage() - Reloading prim (localId "+ prim.LocalID+ " ) from storage"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: PrimFromStorage() - Reloading prim (localId "+ prim.LocalID+ " ) from storage"); Primitive nPrim = new Primitive(); nPrim.CreateFromStorage(prim); this.Entities.Add(nPrim.uuid, nPrim); @@ -141,7 +143,7 @@ namespace OpenSim.world this.localStorage.ShutDown(); } - public void SendLayerData(OpenSimClient RemoteClient) { + public void SendLayerData(SimClient RemoteClient) { int[] patches = new int[4]; for (int y = 0; y < 16; y++) @@ -159,7 +161,7 @@ namespace OpenSim.world } } - public void GetInitialPrims(OpenSimClient RemoteClient) + public void GetInitialPrims(SimClient RemoteClient) { foreach (libsecondlife.LLUUID UUID in Entities.Keys) { @@ -170,33 +172,36 @@ namespace OpenSim.world } } - public void AddViewerAgent(OpenSimClient AgentClient) { - ServerConsole.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); + public void AddViewerAgent(SimClient AgentClient) { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); Avatar NewAvatar = new Avatar(AgentClient); - ServerConsole.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world"); - ServerConsole.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake "); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake "); NewAvatar.SendRegionHandshake(this); PhysicsVector pVec = new PhysicsVector(NewAvatar.position.X, NewAvatar.position.Y, NewAvatar.position.Z); NewAvatar.PhysActor = this.phyScene.AddAvatar(pVec); this.Entities.Add(AgentClient.AgentID, NewAvatar); } - public void AddNewPrim(ObjectAddPacket addPacket, OpenSimClient AgentClient) + public void AddNewPrim(ObjectAddPacket addPacket, SimClient AgentClient) { - ServerConsole.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Creating new prim"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Creating new prim"); Primitive prim = new Primitive(); prim.CreateFromPacket(addPacket, AgentClient.AgentID, this._primCount); PhysicsVector pVec = new PhysicsVector(prim.position.X, prim.position.Y, prim.position.Z); - PhysicsVector pSize = new PhysicsVector( 0.25f, 0.25f, 0.25f); - //prim.PhysActor = this.phyScene.AddPrim(pVec, pSize ); + PhysicsVector pSize = new PhysicsVector( 0.255f, 0.255f, 0.255f); + if(OpenSim.world.Avatar.PhysicsEngineFlying) + { + prim.PhysActor = this.phyScene.AddPrim(pVec, pSize ); + } //prim.PhysicsEnabled = true; this.Entities.Add(prim.uuid, prim); this._primCount++; } public bool Backup() { - /* TODO: Save the current world entities state. */ - ServerConsole.MainConsole.Instance.WriteLine("World.cs: Backup() - Backing up Primitives"); + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: Backup() - Backing up Primitives"); foreach (libsecondlife.LLUUID UUID in Entities.Keys) { Entities[UUID].BackUp(); diff --git a/src/world/scripting/IScript.cs b/OpenSim.RegionServer/world/scripting/IScript.cs similarity index 100% rename from src/world/scripting/IScript.cs rename to OpenSim.RegionServer/world/scripting/IScript.cs diff --git a/OpenSim.Storage/LocalStorageDb4o/AssemblyInfo.cs b/OpenSim.Storage/LocalStorageDb4o/AssemblyInfo.cs new file mode 100644 index 0000000000..66106068df --- /dev/null +++ b/OpenSim.Storage/LocalStorageDb4o/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("Db4LocalStorage")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Db4LocalStorage")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] diff --git a/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.cs b/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs similarity index 82% rename from src/LocalStorage/Db4LocalStorage/Db4LocalStorage.cs rename to OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs index bb9825c29f..93ed9cc860 100644 --- a/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.cs +++ b/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs @@ -29,9 +29,10 @@ using System.Collections.Generic; using Db4objects.Db4o; using Db4objects.Db4o.Query; using libsecondlife; -using GridInterfaces; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; -namespace Db4LocalStorage +namespace OpenSim.Storage.LocalStorageDb4o { /// /// @@ -45,13 +46,13 @@ namespace Db4LocalStorage try { db = Db4oFactory.OpenFile("localworld.yap"); - ServerConsole.MainConsole.Instance.WriteLine("Db4LocalStorage creation"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Db4LocalStorage creation"); } catch(Exception e) { db.Close(); - ServerConsole.MainConsole.Instance.WriteLine("Db4LocalStorage :Constructor - Exception occured"); - ServerConsole.MainConsole.Instance.WriteLine(e.ToString()); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Db4LocalStorage :Constructor - Exception occured"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString()); } } @@ -84,6 +85,7 @@ namespace Db4LocalStorage found.ProfileHollow = prim.ProfileHollow; found.Position = prim.Position; found.Rotation = prim.Rotation; + found.Texture = prim.Texture; db.Set(found); db.Commit(); } @@ -109,7 +111,7 @@ namespace Db4LocalStorage public void LoadPrimitives(ILocalStorageReceiver receiver) { IObjectSet result = db.Get(typeof(PrimData)); - ServerConsole.MainConsole.Instance.WriteLine("Db4LocalStorage.cs: LoadPrimitives() - number of prims in storages is "+result.Count); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Db4LocalStorage.cs: LoadPrimitives() - number of prims in storages is "+result.Count); foreach (PrimData prim in result) { receiver.PrimFromStorage(prim); } @@ -121,19 +123,4 @@ namespace Db4LocalStorage db.Close(); } } - - public class UUIDQuery : Predicate - { - private LLUUID _findID; - - public UUIDQuery(LLUUID find) - { - _findID = find; - } - public bool Match(PrimData prim) - { - return (prim.FullID == _findID); - } - } - } diff --git a/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj b/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj new file mode 100644 index 0000000000..5c2ffa5f55 --- /dev/null +++ b/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj @@ -0,0 +1,104 @@ + + + Local + 8.0.50727 + 2.0 + {2B5E9FF0-DE71-41DA-AC6A-B8E2D2D0AE09} + Debug + AnyCPU + + + + OpenSim.Storage.LocalStorageDb4o + JScript + Grid + IE50 + false + Library + + OpenSim.Storage.LocalStorageDb4o + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\ + False + False + False + 4 + + + + + \System.dll + + + \System.Xml.dll.dll + + + \Db4objects.Db4o.dll.dll + + + \libsecondlife.dll.dll + + + + + OpenSim.Framework + {1D2865A9-CF8E-45F7-B96D-91ED128A32CF} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + OpenSim.Framework.Console + {C8405E1A-EC19-48B6-9C8C-CA03624B9916} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.dll.build b/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.dll.build new file mode 100644 index 0000000000..752d0ab9b0 --- /dev/null +++ b/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.dll.build @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.Storage/LocalStorageDb4o/UUIDQuery.cs b/OpenSim.Storage/LocalStorageDb4o/UUIDQuery.cs new file mode 100644 index 0000000000..16b6685c3b --- /dev/null +++ b/OpenSim.Storage/LocalStorageDb4o/UUIDQuery.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Db4objects.Db4o; +using Db4objects.Db4o.Query; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; + +namespace OpenSim.Storage.LocalStorageDb4o +{ + public class UUIDQuery : Predicate + { + private LLUUID _findID; + + public UUIDQuery(LLUUID find) + { + _findID = find; + } + public bool Match(PrimData prim) + { + return (prim.FullID == _findID); + } + } +} diff --git a/OpenSim.build b/OpenSim.build new file mode 100644 index 0000000000..6013f9db7e --- /dev/null +++ b/OpenSim.build @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.sln b/OpenSim.sln new file mode 100644 index 0000000000..94007714a4 --- /dev/null +++ b/OpenSim.sln @@ -0,0 +1,89 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Physics.PhysXPlugin", "OpenSim.Physics\PhysXPlugin\OpenSim.Physics.PhysXPlugin.csproj", "{CBE1E31D-D7E3-4791-A616-F00173BBC26A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Framework.Console", "OpenSim.Framework.Console\OpenSim.Framework.Console.csproj", "{C8405E1A-EC19-48B6-9C8C-CA03624B9916}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Config.SimConfigDb4o", "OpenSim.Config\SimConfigDb4o\OpenSim.Config.SimConfigDb4o.csproj", "{C077B28B-2F8D-4BD9-8E47-84C51B3A7358}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Physics.BasicPhysicsPlugin", "OpenSim.Physics\BasicPhysicsPlugin\OpenSim.Physics.BasicPhysicsPlugin.csproj", "{00594B9E-29A5-4B9C-AEBD-0AD08C73CFE8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.GridInterfaces.Remote", "OpenSim.GridInterfaces\Remote\OpenSim.GridInterfaces.Remote.csproj", "{2AF1E37E-064D-4590-8D7E-B6390F721BAE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Storage.LocalStorageDb4o", "OpenSim.Storage\LocalStorageDb4o\OpenSim.Storage.LocalStorageDb4o.csproj", "{2B5E9FF0-DE71-41DA-AC6A-B8E2D2D0AE09}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Framework", "OpenSim.Framework\OpenSim.Framework.csproj", "{1D2865A9-CF8E-45F7-B96D-91ED128A32CF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.RegionServer", "OpenSim.RegionServer\OpenSim.RegionServer.csproj", "{B48F0D82-2DE5-42B0-9F1D-0F4353FA243A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Physics.Manager", "OpenSim.Physics\Manager\OpenSim.Physics.Manager.csproj", "{58360A80-9333-4E0F-8F83-3CF937E51633}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.GridInterfaces.Local", "OpenSim.GridInterfaces\Local\OpenSim.GridInterfaces.Local.csproj", "{FBF3DA4B-5176-4602-AA52-482D077EEC88}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + ({CBE1E31D-D7E3-4791-A616-F00173BBC26A}).3 = ({58360A80-9333-4E0F-8F83-3CF937E51633}) + ({C077B28B-2F8D-4BD9-8E47-84C51B3A7358}).5 = ({1D2865A9-CF8E-45F7-B96D-91ED128A32CF}) + ({C077B28B-2F8D-4BD9-8E47-84C51B3A7358}).6 = ({C8405E1A-EC19-48B6-9C8C-CA03624B9916}) + ({00594B9E-29A5-4B9C-AEBD-0AD08C73CFE8}).2 = ({58360A80-9333-4E0F-8F83-3CF937E51633}) + ({2AF1E37E-064D-4590-8D7E-B6390F721BAE}).3 = ({1D2865A9-CF8E-45F7-B96D-91ED128A32CF}) + ({2AF1E37E-064D-4590-8D7E-B6390F721BAE}).4 = ({C8405E1A-EC19-48B6-9C8C-CA03624B9916}) + ({2B5E9FF0-DE71-41DA-AC6A-B8E2D2D0AE09}).4 = ({1D2865A9-CF8E-45F7-B96D-91ED128A32CF}) + ({2B5E9FF0-DE71-41DA-AC6A-B8E2D2D0AE09}).5 = ({C8405E1A-EC19-48B6-9C8C-CA03624B9916}) + ({B48F0D82-2DE5-42B0-9F1D-0F4353FA243A}).5 = ({C8405E1A-EC19-48B6-9C8C-CA03624B9916}) + ({B48F0D82-2DE5-42B0-9F1D-0F4353FA243A}).6 = ({58360A80-9333-4E0F-8F83-3CF937E51633}) + ({B48F0D82-2DE5-42B0-9F1D-0F4353FA243A}).7 = ({1D2865A9-CF8E-45F7-B96D-91ED128A32CF}) + ({58360A80-9333-4E0F-8F83-3CF937E51633}).3 = ({C8405E1A-EC19-48B6-9C8C-CA03624B9916}) + ({FBF3DA4B-5176-4602-AA52-482D077EEC88}).4 = ({1D2865A9-CF8E-45F7-B96D-91ED128A32CF}) + ({FBF3DA4B-5176-4602-AA52-482D077EEC88}).5 = ({C8405E1A-EC19-48B6-9C8C-CA03624B9916}) + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CBE1E31D-D7E3-4791-A616-F00173BBC26A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CBE1E31D-D7E3-4791-A616-F00173BBC26A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CBE1E31D-D7E3-4791-A616-F00173BBC26A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CBE1E31D-D7E3-4791-A616-F00173BBC26A}.Release|Any CPU.Build.0 = Release|Any CPU + {C8405E1A-EC19-48B6-9C8C-CA03624B9916}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C8405E1A-EC19-48B6-9C8C-CA03624B9916}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C8405E1A-EC19-48B6-9C8C-CA03624B9916}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C8405E1A-EC19-48B6-9C8C-CA03624B9916}.Release|Any CPU.Build.0 = Release|Any CPU + {C077B28B-2F8D-4BD9-8E47-84C51B3A7358}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C077B28B-2F8D-4BD9-8E47-84C51B3A7358}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C077B28B-2F8D-4BD9-8E47-84C51B3A7358}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C077B28B-2F8D-4BD9-8E47-84C51B3A7358}.Release|Any CPU.Build.0 = Release|Any CPU + {00594B9E-29A5-4B9C-AEBD-0AD08C73CFE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {00594B9E-29A5-4B9C-AEBD-0AD08C73CFE8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {00594B9E-29A5-4B9C-AEBD-0AD08C73CFE8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {00594B9E-29A5-4B9C-AEBD-0AD08C73CFE8}.Release|Any CPU.Build.0 = Release|Any CPU + {2AF1E37E-064D-4590-8D7E-B6390F721BAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2AF1E37E-064D-4590-8D7E-B6390F721BAE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2AF1E37E-064D-4590-8D7E-B6390F721BAE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2AF1E37E-064D-4590-8D7E-B6390F721BAE}.Release|Any CPU.Build.0 = Release|Any CPU + {2B5E9FF0-DE71-41DA-AC6A-B8E2D2D0AE09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2B5E9FF0-DE71-41DA-AC6A-B8E2D2D0AE09}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2B5E9FF0-DE71-41DA-AC6A-B8E2D2D0AE09}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2B5E9FF0-DE71-41DA-AC6A-B8E2D2D0AE09}.Release|Any CPU.Build.0 = Release|Any CPU + {1D2865A9-CF8E-45F7-B96D-91ED128A32CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1D2865A9-CF8E-45F7-B96D-91ED128A32CF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1D2865A9-CF8E-45F7-B96D-91ED128A32CF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1D2865A9-CF8E-45F7-B96D-91ED128A32CF}.Release|Any CPU.Build.0 = Release|Any CPU + {B48F0D82-2DE5-42B0-9F1D-0F4353FA243A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B48F0D82-2DE5-42B0-9F1D-0F4353FA243A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B48F0D82-2DE5-42B0-9F1D-0F4353FA243A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B48F0D82-2DE5-42B0-9F1D-0F4353FA243A}.Release|Any CPU.Build.0 = Release|Any CPU + {58360A80-9333-4E0F-8F83-3CF937E51633}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {58360A80-9333-4E0F-8F83-3CF937E51633}.Debug|Any CPU.Build.0 = Debug|Any CPU + {58360A80-9333-4E0F-8F83-3CF937E51633}.Release|Any CPU.ActiveCfg = Release|Any CPU + {58360A80-9333-4E0F-8F83-3CF937E51633}.Release|Any CPU.Build.0 = Release|Any CPU + {FBF3DA4B-5176-4602-AA52-482D077EEC88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FBF3DA4B-5176-4602-AA52-482D077EEC88}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FBF3DA4B-5176-4602-AA52-482D077EEC88}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FBF3DA4B-5176-4602-AA52-482D077EEC88}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Prebuild/Prebuild.build b/Prebuild/Prebuild.build new file mode 100644 index 0000000000..395fb31e54 --- /dev/null +++ b/Prebuild/Prebuild.build @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Prebuild/Prebuild.sln b/Prebuild/Prebuild.sln new file mode 100644 index 0000000000..a0bea09ea4 --- /dev/null +++ b/Prebuild/Prebuild.sln @@ -0,0 +1,25 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prebuild", "src\Prebuild.csproj", "{A5CC8344-BEE4-442E-92F1-FBCB05D6AB78}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{468F1D07-AD17-4CC3-ABD0-2CA268E4E1A6}" + ProjectSection(SolutionItems) = preProject + prebuild = prebuild + prebuild.xml = prebuild.xml + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A5CC8344-BEE4-442E-92F1-FBCB05D6AB78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A5CC8344-BEE4-442E-92F1-FBCB05D6AB78}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A5CC8344-BEE4-442E-92F1-FBCB05D6AB78}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A5CC8344-BEE4-442E-92F1-FBCB05D6AB78}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Prebuild/README b/Prebuild/README new file mode 100644 index 0000000000..eca6be17e2 --- /dev/null +++ b/Prebuild/README @@ -0,0 +1,230 @@ +Prebuild Instructions + +Prebuild is an XML-driven pre-build tool allowing developers to easily generate project or make files for major IDE's and .NET development tools including: Visual Studio 2005, Visual Studio 2003, Visual Studio 2002, SharpDevelop, SharpDevelop2, MonoDevelop, and NAnt. + +_________________________________________________________________________________ +Overview + +Prebuild can be either be run from the command line to generate the project and make files or you can execute the included batch (*.bat) and Unix Shell script (*.sh) files. +The Prebuild file + +_________________________________________________________________________________ +The currently supported developement tools and their associated batch and shell script files. + +Visual Studio .NET 2005 (VS2005.bat) +Visual Studio .NET 2003 (VS2003.bat) +Visual Studio .NET 2002 (VS2002.bat) +SharpDevelop (SharpDevelop.bat) - http://www.icsharpcode.net/OpenSource/SD/ +SharpDevelop2 (SharpDevelop.bat) - http://www.icsharpcode.net/OpenSource/SD/ +MonoDevelop (MonoDevelop.sh) - http://www.monodevelop.com/ +NAnt (nant.sh and nant.bat) - http://nant.sourceforge.net/ +Autotools (autotools.bat and autotools.sh) http://www.gnu.org. Only partial support + +Notes: +A Unix Shell script is provided for MonoDevelop, as this is more appropriate than a windows batch file. +Visual Studio .NET 2005 and the Visual Express IDE's can import solutions from older versions of Visual Studio .NET. +Makefiles are not currently supported. + +_________________________________________________________________________________ +Command Line Syntax: + +Example: +>Prebuild /target vs2003 + +This will generate the project files for Visual Studio.NET 2003 and place the redirect the log to a file named PrebuildLog.txt in the parent directory + + +The syntax structure is as below, where commandParameter is optional depending on the command and you can provide several option-value pairs. +Note: The '>' signified the command line, do not actually enter this manually + +>Prebuild / + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] + public sealed class DataNodeAttribute : Attribute + { + #region Fields + + private string m_Name = "unknown"; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The name. + public DataNodeAttribute(string name) + { + m_Name = name; + } + + #endregion + + #region Properties + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs b/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs new file mode 100644 index 0000000000..edda56d6c4 --- /dev/null +++ b/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs @@ -0,0 +1,80 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Revision: 71 $ + */ +#endregion + +using System; + +namespace Prebuild.Core.Attributes +{ + /// + /// + /// + [AttributeUsage(AttributeTargets.Field)] + public sealed class OptionNodeAttribute : Attribute + { + #region Fields + + private string m_NodeName; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// Name of the node. + public OptionNodeAttribute(string nodeName) + { + m_NodeName = nodeName; + } + + #endregion + + #region Properties + + /// + /// Gets the name of the node. + /// + /// The name of the node. + public string NodeName + { + get + { + return m_NodeName; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Attributes/TargetAttribute.cs b/Prebuild/src/Core/Attributes/TargetAttribute.cs new file mode 100644 index 0000000000..985f1804f5 --- /dev/null +++ b/Prebuild/src/Core/Attributes/TargetAttribute.cs @@ -0,0 +1,80 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Revision: 71 $ + */ +#endregion + +using System; + +namespace Prebuild.Core.Attributes +{ + /// + /// + /// + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] + public sealed class TargetAttribute : Attribute + { + #region Fields + + private string m_Name; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The name. + public TargetAttribute(string name) + { + m_Name = name; + } + + #endregion + + #region Properties + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/FatalException.cs b/Prebuild/src/Core/FatalException.cs new file mode 100644 index 0000000000..92aad3d493 --- /dev/null +++ b/Prebuild/src/Core/FatalException.cs @@ -0,0 +1,94 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Revision: 71 $ + */ +#endregion + +using System; +using System.Runtime.Serialization; + +namespace Prebuild.Core +{ + /// + /// + /// + [Serializable()] + public class FatalException : Exception + { + #region Constructors + + + /// + /// Initializes a new instance of the class. + /// + public FatalException() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The format. + /// The args. + public FatalException(string format, params object[] args) + : base(String.Format(format, args)) + { + } + + /// + /// Exception with specified string + /// + /// Exception message + public FatalException(string message): base(message) + { + } + + /// + /// + /// + /// + /// + public FatalException(string message, Exception exception) : base(message, exception) + { + } + + /// + /// + /// + /// + /// + protected FatalException(SerializationInfo info, StreamingContext context) : base( info, context ) + { + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Interfaces/IDataNode.cs b/Prebuild/src/Core/Interfaces/IDataNode.cs new file mode 100644 index 0000000000..0bad97c6ce --- /dev/null +++ b/Prebuild/src/Core/Interfaces/IDataNode.cs @@ -0,0 +1,56 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Revision: 71 $ + */ +#endregion + +using System; +using System.Xml; + +namespace Prebuild.Core.Interfaces +{ + /// + /// + /// + public interface IDataNode + { + /// + /// Gets or sets the parent. + /// + /// The parent. + IDataNode Parent { get; set; } + /// + /// Parses the specified node. + /// + /// The node. + void Parse(XmlNode node); + } +} diff --git a/Prebuild/src/Core/Interfaces/ITarget.cs b/Prebuild/src/Core/Interfaces/ITarget.cs new file mode 100644 index 0000000000..dac6cd6ed6 --- /dev/null +++ b/Prebuild/src/Core/Interfaces/ITarget.cs @@ -0,0 +1,60 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Revision: 71 $ + */ +#endregion + +using System; + +namespace Prebuild.Core.Interfaces +{ + /// + /// + /// + public interface ITarget + { + /// + /// Writes the specified kern. + /// + /// The kern. + void Write(Kernel kern); + /// + /// Cleans the specified kern. + /// + /// The kern. + void Clean(Kernel kern); + /// + /// Gets the name. + /// + /// The name. + string Name { get; } + } +} \ No newline at end of file diff --git a/Prebuild/src/Core/Kernel.cs b/Prebuild/src/Core/Kernel.cs new file mode 100644 index 0000000000..3117e7c337 --- /dev/null +++ b/Prebuild/src/Core/Kernel.cs @@ -0,0 +1,758 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: robloach $ + * $Date: 2006-09-26 00:30:53 +0200 (ti, 26 sep 2006) $ + * $Revision: 165 $ + */ +#endregion + +using System; +using System.Diagnostics; +using System.Collections; +using System.Collections.Specialized; +using System.IO; +using System.Reflection; +using System.Xml; +using System.Xml.Schema; +using System.Text; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Parse; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core +{ + /// + /// + /// + public class Kernel : IDisposable + { + #region Inner Classes + + private struct NodeEntry + { + public Type Type; + public DataNodeAttribute Attribute; + } + + #endregion + + #region Fields + + private static Kernel m_Instance = new Kernel(); + + /// + /// This must match the version of the schema that is embeeded + /// + private static string m_SchemaVersion = "1.7"; + private static string m_Schema = "prebuild-" + m_SchemaVersion + ".xsd"; + private static string m_SchemaURI = "http://dnpb.sourceforge.net/schemas/" + m_Schema; + bool disposed; + private Version m_Version; + private string m_Revision = ""; + private CommandLineCollection m_CommandLine; + private Log m_Log; + private CurrentDirectory m_CurrentWorkingDirectory; + private XmlSchemaCollection m_Schemas; + + private Hashtable m_Targets; + private Hashtable m_Nodes; + + ArrayList m_Solutions; + string m_Target; + string m_Clean; + string[] m_RemoveDirectories; + string m_CurrentFile; + bool m_PauseAfterFinish; + string[] m_ProjectGroups; + StringCollection m_Refs; + + + #endregion + + #region Constructors + + private Kernel() + { + } + + #endregion + + #region Properties + + /// + /// Gets a value indicating whether [pause after finish]. + /// + /// true if [pause after finish]; otherwise, false. + public bool PauseAfterFinish + { + get + { + return m_PauseAfterFinish; + } + } + + /// + /// Gets the instance. + /// + /// The instance. + public static Kernel Instance + { + get + { + return m_Instance; + } + } + + /// + /// Gets the version. + /// + /// The version. + public string Version + { + get + { + return String.Format("{0}.{1}.{2}{3}", m_Version.Major, m_Version.Minor, m_Version.Build, m_Revision); + } + } + + /// + /// Gets the command line. + /// + /// The command line. + public CommandLineCollection CommandLine + { + get + { + return m_CommandLine; + } + } + + /// + /// Gets the targets. + /// + /// The targets. + public Hashtable Targets + { + get + { + return m_Targets; + } + } + + /// + /// Gets the log. + /// + /// The log. + public Log Log + { + get + { + return m_Log; + } + } + + /// + /// Gets the current working directory. + /// + /// The current working directory. + public CurrentDirectory CurrentWorkingDirectory + { + get + { + return m_CurrentWorkingDirectory; + } + } + + /// + /// Gets the solutions. + /// + /// The solutions. + public ArrayList Solutions + { + get + { + return m_Solutions; + } + } + + #endregion + + #region Private Methods + + private void RemoveDirectories(string rootDir, string[] dirNames) + { + foreach(string dir in Directory.GetDirectories(rootDir)) + { + string simpleName = Path.GetFileName(dir); + + if(Array.IndexOf(dirNames, simpleName) != -1) + { + //delete if the name matches one of the directory names to delete + string fullDirPath = Path.GetFullPath(dir); + Directory.Delete(fullDirPath,true); + } + else//not a match, so check children + { + RemoveDirectories(dir,dirNames); + //recurse, checking children for them + } + } + } + +// private void RemoveDirectoryMatches(string rootDir, string dirPattern) +// { +// foreach(string dir in Directory.GetDirectories(rootDir)) +// { +// foreach(string match in Directory.GetDirectories(dir)) +// {//delete all child directories that match +// Directory.Delete(Path.GetFullPath(match),true); +// } +// //recure through the rest checking for nested matches to delete +// RemoveDirectoryMatches(dir,dirPattern); +// } +// } + + private void LoadSchema() + { + Assembly assembly = this.GetType().Assembly; + Stream stream = assembly.GetManifestResourceStream("Prebuild.data." + m_Schema); + if(stream == null) + { + //try without the default namespace prepending to it in case was compiled with SharpDevelop or MonoDevelop instead of Visual Studio .NET + stream = assembly.GetManifestResourceStream(m_Schema); + if(stream == null) + { + throw new System.Reflection.TargetException(string.Format("Could not find the scheme embedded resource file '{0}'.", m_Schema)); + } + } + XmlReader schema = new XmlTextReader(stream); + + m_Schemas = new XmlSchemaCollection(); + m_Schemas.Add(m_SchemaURI, schema); + } + + private void CacheVersion() + { + m_Version = Assembly.GetEntryAssembly().GetName().Version; + } + + private void CacheTargets(Assembly assm) + { + foreach(Type t in assm.GetTypes()) + { + TargetAttribute ta = (TargetAttribute)Helper.CheckType(t, typeof(TargetAttribute), typeof(ITarget)); + if(ta == null) + { + continue; + } + + ITarget target = (ITarget)assm.CreateInstance(t.FullName); + if(target == null) + { + throw new MissingMethodException("Could not create ITarget instance"); + } + + m_Targets[ta.Name] = target; + } + } + + private void CacheNodeTypes(Assembly assm) + { + foreach(Type t in assm.GetTypes()) + { + DataNodeAttribute dna = (DataNodeAttribute)Helper.CheckType(t, typeof(DataNodeAttribute), typeof(IDataNode)); + if(dna == null) + { + continue; + } + + NodeEntry ne = new NodeEntry(); + ne.Type = t; + ne.Attribute = dna; + m_Nodes[dna.Name] = ne; + } + } + + private void LogBanner() + { + m_Log.Write("Prebuild v" + this.Version); + m_Log.Write("Copyright (c) Matthew Holmes, Dan Moorehead and David Hudson"); + m_Log.Write("See 'prebuild /usage' for help"); + m_Log.Write(); + } + + private void ProcessFile(string file) + { + m_CurrentWorkingDirectory.Push(); + + string path = file; + try + { + try + { + path = Helper.ResolvePath(path); + } + catch(ArgumentException) + { + m_Log.Write("Could not open Prebuild file: " + path); + m_CurrentWorkingDirectory.Pop(); + return; + } + + m_CurrentFile = path; + Helper.SetCurrentDir(Path.GetDirectoryName(path)); + + + XmlTextReader reader = new XmlTextReader(path); + + Core.Parse.Preprocessor pre = new Core.Parse.Preprocessor(); + + //register command line arguments as XML variables + IDictionaryEnumerator dict = m_CommandLine.GetEnumerator(); + while (dict.MoveNext()) + { + string name = dict.Key.ToString().Trim(); + if (name.Length > 0) + pre.RegisterVariable(name, dict.Value.ToString()); + } + + string xml = pre.Process(reader);//remove script and evaulate pre-proccessing to get schema-conforming XML + + + XmlDocument doc = new XmlDocument(); + try + { + XmlValidatingReader validator = new XmlValidatingReader(new XmlTextReader(new StringReader(xml))); + + //validate while reading from string into XmlDocument DOM structure in memory + foreach(XmlSchema schema in m_Schemas) + { + validator.Schemas.Add(schema); + } + doc.Load(validator); + } + catch(XmlException e) + { + throw new XmlException(e.ToString()); + } + + //is there a purpose to writing it? An syntax/schema problem would have been found during pre.Process() and reported with details + if(m_CommandLine.WasPassed("ppo")) + { + string ppoFile = m_CommandLine["ppo"]; + if(ppoFile == null || ppoFile.Trim().Length < 1) + { + ppoFile = "preprocessed.xml"; + } + + StreamWriter writer = null; + try + { + writer = new StreamWriter(ppoFile); + writer.Write(xml); + } + catch(IOException ex) + { + Console.WriteLine("Could not write PPO file '{0}': {1}", ppoFile, ex.Message); + } + finally + { + if(writer != null) + { + writer.Close(); + } + } + return; + } + //start reading the xml config file + XmlElement rootNode = doc.DocumentElement; + //string suggestedVersion = Helper.AttributeValue(rootNode,"version","1.0"); + Helper.CheckForOSVariables = Helper.ParseBoolean(rootNode,"checkOsVars",false); + + foreach(XmlNode node in rootNode.ChildNodes)//solutions or if pre-proc instructions + { + IDataNode dataNode = ParseNode(node, null); + if(dataNode is ProcessNode) + { + ProcessNode proc = (ProcessNode)dataNode; + if(proc.IsValid) + { + ProcessFile(proc.Path); + } + } + else if(dataNode is SolutionNode) + { + m_Solutions.Add(dataNode); + } + } + } + catch(XmlSchemaException xse) + { + m_Log.Write("XML validation error at line {0} in {1}:\n\n{2}", + xse.LineNumber, path, xse.Message); + } + finally + { + m_CurrentWorkingDirectory.Pop(); + } + } + + #endregion + + #region Public Methods + + /// + /// Allows the project. + /// + /// The project groups flags. + /// + public bool AllowProject(string projectGroupsFlags) + { + if(m_ProjectGroups != null && m_ProjectGroups.Length > 0) + { + if(projectGroupsFlags != null && projectGroupsFlags.Length == 0) + { + foreach(string group in projectGroupsFlags.Split('|')) + { + if(Array.IndexOf(m_ProjectGroups, group) != -1) //if included in the filter list + { + return true; + } + } + } + return false;//not included in the list or no groups specified for the project + } + return true;//no filter specified in the command line args + } + + /// + /// Gets the type of the node. + /// + /// The node. + /// + public Type GetNodeType(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + if(!m_Nodes.ContainsKey(node.Name)) + { + return null; + } + + NodeEntry ne = (NodeEntry)m_Nodes[node.Name]; + return ne.Type; + } + + /// + /// + /// + /// + /// + /// + public IDataNode ParseNode(XmlNode node, IDataNode parent) + { + return ParseNode(node, parent, null); + } + + //Create an instance of the data node type that is mapped to the name of the xml DOM node + /// + /// Parses the node. + /// + /// The node. + /// The parent. + /// The pre node. + /// + public IDataNode ParseNode(XmlNode node, IDataNode parent, IDataNode preNode) + { + IDataNode dataNode = null; + + try + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + if(preNode == null) + { + if(!m_Nodes.ContainsKey(node.Name)) + { + //throw new XmlException("Unknown XML node: " + node.Name); + return null; + } + + NodeEntry ne = (NodeEntry)m_Nodes[node.Name]; + Type type = ne.Type; + //DataNodeAttribute dna = ne.Attribute; + + dataNode = (IDataNode)type.Assembly.CreateInstance(type.FullName); + if(dataNode == null) + { + throw new System.Reflection.TargetException("Could not create new parser instance: " + type.FullName); + } + } + else + dataNode = preNode; + + dataNode.Parent = parent; + dataNode.Parse(node); + } + catch(WarningException wex) + { + m_Log.Write(LogType.Warning, wex.Message); + return null; + } + catch(FatalException fex) + { + m_Log.WriteException(LogType.Error, fex); + throw; + } + catch(Exception ex) + { + m_Log.WriteException(LogType.Error, ex); + throw; + } + + return dataNode; + } + + /// + /// Initializes the specified target. + /// + /// The target. + /// The args. + public void Initialize(LogTargets target, string[] args) + { + m_Targets = new Hashtable(); + CacheTargets(this.GetType().Assembly); + m_Nodes = new Hashtable(); + CacheNodeTypes(this.GetType().Assembly); + CacheVersion(); + + m_CommandLine = new CommandLineCollection(args); + + string logFile = null; + if(m_CommandLine.WasPassed("log")) + { + logFile = m_CommandLine["log"]; + + if(logFile != null && logFile.Length == 0) + { + logFile = "Prebuild.log"; + } + } + else + { + target = target & ~LogTargets.File; //dont output to a file + } + + m_Log = new Log(target, logFile); + LogBanner(); + + m_CurrentWorkingDirectory = new CurrentDirectory(); + + m_Target = m_CommandLine["target"]; + m_Clean = m_CommandLine["clean"]; + string removeDirs = m_CommandLine["removedir"]; + if(removeDirs != null && removeDirs.Length == 0) + { + m_RemoveDirectories = removeDirs.Split('|'); + } + + string flags = m_CommandLine["allowedgroups"];//allows filtering by specifying a pipe-delimited list of groups to include + if(flags != null && flags.Length == 0) + { + m_ProjectGroups = flags.Split('|'); + } + m_PauseAfterFinish = m_CommandLine.WasPassed("pause"); + + LoadSchema(); + + m_Solutions = new ArrayList(); + m_Refs = new StringCollection(); + } + + /// + /// Processes this instance. + /// + public void Process() + { + bool perfomedOtherTask = false; + if(m_RemoveDirectories != null && m_RemoveDirectories.Length > 0) + { + try + { + RemoveDirectories(".",m_RemoveDirectories); + } + catch(IOException e) + { + m_Log.Write("Failed to remove directories named {0}",m_RemoveDirectories); + m_Log.WriteException(LogType.Error,e); + } + catch(UnauthorizedAccessException e) + { + m_Log.Write("Failed to remove directories named {0}",m_RemoveDirectories); + m_Log.WriteException(LogType.Error,e); + } + perfomedOtherTask = true; + } + + if(m_Target != null && m_Clean != null) + { + m_Log.Write(LogType.Error, "The options /target and /clean cannot be passed together"); + return; + } + else if(m_Target == null && m_Clean == null) + { + if(perfomedOtherTask) //finished + { + return; + } + m_Log.Write(LogType.Error, "Must pass either /target or /clean to process a Prebuild file"); + return; + } + + string file = "./prebuild.xml"; + if(m_CommandLine.WasPassed("file")) + { + file = m_CommandLine["file"]; + } + + ProcessFile(file); + + string target = (m_Target != null ? m_Target.ToLower() : m_Clean.ToLower()); + bool clean = (m_Target == null); + if(clean && target != null && target.Length == 0) + { + target = "all"; + } + if(clean && target == "all")//default to all if no target was specified for clean + { + //check if they passed yes + if (!m_CommandLine.WasPassed("yes")) + { + Console.WriteLine("WARNING: This operation will clean ALL project files for all targets, are you sure? (y/n):"); + string ret = Console.ReadLine(); + if(ret == null) + { + return; + } + ret = ret.Trim().ToLower(); + if((ret.ToLower() != "y" && ret.ToLower() != "yes")) + { + return; + } + } + //clean all targets (just cleaning vs2002 target didn't clean nant) + foreach(ITarget targ in m_Targets.Values) + { + targ.Clean(this); + } + } + else + { + ITarget targ = (ITarget)m_Targets[target]; + + if(clean) + { + targ.Clean(this); + } + else + { + targ.Write(this); + } + } + + m_Log.Flush(); + } + + #endregion + + #region IDisposable Members + + /// + /// + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Dispose objects + /// + /// + /// If true, it will dispose close the handle + /// + /// + /// Will dispose managed and unmanaged resources. + /// + protected virtual void Dispose(bool disposing) + { + if (!this.disposed) + { + if (disposing) + { + if (this.m_Log != null) + { + this.m_Log.Close(); + this.m_Log = null; + } + } + } + this.disposed = true; + } + + /// + /// + /// + ~Kernel() + { + this.Dispose(false); + } + + /// + /// Closes and destroys this object + /// + /// + /// Same as Dispose(true) + /// + public void Close() + { + Dispose(); + } + + #endregion + } +} \ No newline at end of file diff --git a/Prebuild/src/Core/Nodes/ConfigurationNode.cs b/Prebuild/src/Core/Nodes/ConfigurationNode.cs new file mode 100644 index 0000000000..e1488a7222 --- /dev/null +++ b/Prebuild/src/Core/Nodes/ConfigurationNode.cs @@ -0,0 +1,177 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Revision: 71 $ + */ +#endregion + +using System; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Configuration")] + public class ConfigurationNode : DataNode, ICloneable + { + #region Fields + + private string m_Name = "unknown"; + private OptionsNode m_Options; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public ConfigurationNode() + { + m_Options = new OptionsNode(); + } + + #endregion + + #region Properties + + /// + /// Gets or sets the parent. + /// + /// The parent. + public override IDataNode Parent + { + get + { + return base.Parent; + } + set + { + base.Parent = value; + if(base.Parent is SolutionNode) + { + SolutionNode node = (SolutionNode)base.Parent; + if(node != null && node.Options != null) + { + node.Options.CopyTo(m_Options); + } + } + } + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + /// + /// Gets or sets the options. + /// + /// The options. + public OptionsNode Options + { + get + { + return m_Options; + } + set + { + m_Options = value; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Name = Helper.AttributeValue(node, "name", m_Name); + if( node == null ) + { + throw new ArgumentNullException("node"); + } + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is OptionsNode) + { + ((OptionsNode)dataNode).CopyTo(m_Options); + } + } + } + + /// + /// Copies to. + /// + /// The conf. + public void CopyTo(ConfigurationNode conf) + { + m_Options.CopyTo(conf.m_Options); + } + + #endregion + + #region ICloneable Members + + /// + /// Creates a new object that is a copy of the current instance. + /// + /// + /// A new object that is a copy of this instance. + /// + public object Clone() + { + ConfigurationNode ret = new ConfigurationNode(); + ret.m_Name = m_Name; + m_Options.CopyTo(ret.m_Options); + return ret; + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/DataNode.cs b/Prebuild/src/Core/Nodes/DataNode.cs new file mode 100644 index 0000000000..ef5f7ee1b6 --- /dev/null +++ b/Prebuild/src/Core/Nodes/DataNode.cs @@ -0,0 +1,82 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Revision: 71 $ + */ +#endregion + +using System; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + public class DataNode : IDataNode + { + #region Fields + + private IDataNode parent; + + #endregion + + #region IDataNode Members + + /// + /// Gets or sets the parent. + /// + /// The parent. + public virtual IDataNode Parent + { + get + { + return parent; + } + set + { + parent = value; + } + } + + /// + /// Parses the specified node. + /// + /// The node. + public virtual void Parse(XmlNode node) + { + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/ExcludeNode.cs b/Prebuild/src/Core/Nodes/ExcludeNode.cs new file mode 100644 index 0000000000..bfcebca875 --- /dev/null +++ b/Prebuild/src/Core/Nodes/ExcludeNode.cs @@ -0,0 +1,85 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-31 16:35:39 +0100 (ti, 31 jan 2006) $ + * $Revision: 74 $ + */ +#endregion + +using System; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Exclude")] + public class ExcludeNode : DataNode + { + #region Fields + + private string m_Name = "unknown"; + + #endregion + + #region Properties + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Name = Helper.AttributeValue(node, "name", m_Name); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/FileNode.cs b/Prebuild/src/Core/Nodes/FileNode.cs new file mode 100644 index 0000000000..de3b69e7dd --- /dev/null +++ b/Prebuild/src/Core/Nodes/FileNode.cs @@ -0,0 +1,238 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2007-01-08 17:55:40 +0100 (mÃ¥, 08 jan 2007) $ + * $Revision: 197 $ + */ +#endregion + +using System; +using System.IO; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + public enum BuildAction + { + /// + /// + /// + None, + /// + /// + /// + Compile, + /// + /// + /// + Content, + /// + /// + /// + EmbeddedResource + } + + /// + /// + /// + public enum SubType + { + /// + /// + /// + Code, + /// + /// + /// + Component, + /// + /// + /// + Designer, + /// + /// + /// + Form, + /// + /// + /// + Settings, + /// + /// + /// + UserControl + } + + public enum CopyToOutput + { + Never, + Always, + PreserveNewest + } + + /// + /// + /// + [DataNode("File")] + public class FileNode : DataNode + { + #region Fields + + private string m_Path; + private string m_ResourceName = ""; + private BuildAction m_BuildAction = BuildAction.Compile; + private bool m_Valid; + private SubType m_SubType = SubType.Code; + private CopyToOutput m_CopyToOutput = CopyToOutput.Never; + private bool m_Link = false; + + + #endregion + + #region Properties + + /// + /// + /// + public string Path + { + get + { + return m_Path; + } + } + + /// + /// + /// + public string ResourceName + { + get + { + return m_ResourceName; + } + } + + /// + /// + /// + public BuildAction BuildAction + { + get + { + return m_BuildAction; + } + } + + public CopyToOutput CopyToOutput + { + get + { + return this.m_CopyToOutput; + } + } + + public bool IsLink + { + get + { + return this.m_Link; + } + } + + /// + /// + /// + public SubType SubType + { + get + { + return m_SubType; + } + } + + /// + /// + /// + public bool IsValid + { + get + { + return m_Valid; + } + } + + #endregion + + #region Public Methods + + /// + /// + /// + /// + public override void Parse(XmlNode node) + { + m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), + Helper.AttributeValue(node, "buildAction", m_BuildAction.ToString())); + m_SubType = (SubType)Enum.Parse(typeof(SubType), + Helper.AttributeValue(node, "subType", m_SubType.ToString())); + m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString()); + this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString)); + this.m_CopyToOutput = (CopyToOutput) Enum.Parse(typeof(CopyToOutput), Helper.AttributeValue(node, "copyToOutput", this.m_CopyToOutput.ToString())); + + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); + if(m_Path == null) + { + m_Path = ""; + } + + m_Path = m_Path.Trim(); + m_Valid = true; + if(!File.Exists(m_Path)) + { + m_Valid = false; + Kernel.Instance.Log.Write(LogType.Warning, "File does not exist: {0}", m_Path); + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/FilesNode.cs b/Prebuild/src/Core/Nodes/FilesNode.cs new file mode 100644 index 0000000000..442a45f7ad --- /dev/null +++ b/Prebuild/src/Core/Nodes/FilesNode.cs @@ -0,0 +1,222 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-09-20 09:42:51 +0200 (on, 20 sep 2006) $ + * $Revision: 164 $ + */ +#endregion + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Files")] + public class FilesNode : DataNode + { + #region Fields + + private StringCollection m_Files; + private Hashtable m_BuildActions; + private Hashtable m_SubTypes; + private Hashtable m_ResourceNames; + private Hashtable m_CopyToOutputs; + private Hashtable m_Links; + + + #endregion + + #region Constructors + + /// + /// + /// + public FilesNode() + { + m_Files = new StringCollection(); + m_BuildActions = new Hashtable(); + m_SubTypes = new Hashtable(); + m_ResourceNames = new Hashtable(); + m_CopyToOutputs = new Hashtable(); + m_Links = new Hashtable(); + } + + #endregion + + #region Properties + + /// + /// + /// + public int Count + { + get + { + return m_Files.Count; + } + } + + #endregion + + #region Public Methods + + /// + /// + /// + /// + /// + public BuildAction GetBuildAction(string file) + { + if(!m_BuildActions.ContainsKey(file)) + { + return BuildAction.Compile; + } + + return (BuildAction)m_BuildActions[file]; + } + + public CopyToOutput GetCopyToOutput(string file) + { + if (!this.m_CopyToOutputs.ContainsKey(file)) + { + return CopyToOutput.Never; + } + return (CopyToOutput) this.m_CopyToOutputs[file]; + } + + public bool GetIsLink(string file) + { + if (!this.m_Links.ContainsKey(file)) + { + return false; + } + return (bool) this.m_Links[file]; + } + + /// + /// + /// + /// + /// + public SubType GetSubType(string file) + { + if(!m_SubTypes.ContainsKey(file)) + { + return SubType.Code; + } + + return (SubType)m_SubTypes[file]; + } + + /// + /// + /// + /// + /// + public string GetResourceName(string file) + { + if(!m_ResourceNames.ContainsKey(file)) + { + return ""; + } + + return (string)m_ResourceNames[file]; + } + + /// + /// + /// + /// + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is FileNode) + { + FileNode fileNode = (FileNode)dataNode; + if(fileNode.IsValid) + { + if (!m_Files.Contains(fileNode.Path)) + { + m_Files.Add(fileNode.Path); + m_BuildActions[fileNode.Path] = fileNode.BuildAction; + m_SubTypes[fileNode.Path] = fileNode.SubType; + m_ResourceNames[fileNode.Path] = fileNode.ResourceName; + this.m_Links[fileNode.Path] = fileNode.IsLink; + this.m_CopyToOutputs[fileNode.Path] = fileNode.CopyToOutput; + + } + } + } + else if(dataNode is MatchNode) + { + foreach(string file in ((MatchNode)dataNode).Files) + { + if (!m_Files.Contains(file)) + { + m_Files.Add(file); + m_BuildActions[file] = ((MatchNode)dataNode).BuildAction; + m_SubTypes[file] = ((MatchNode)dataNode).SubType; + m_ResourceNames[file] = ((MatchNode)dataNode).ResourceName; + this.m_Links[file] = ((MatchNode) dataNode).IsLink; + this.m_CopyToOutputs[file] = ((MatchNode) dataNode).CopyToOutput; + + } + } + } + } + } + + // TODO: Check in to why StringCollection's enumerator doesn't implement + // IEnumerator? + /// + /// + /// + /// + public StringEnumerator GetEnumerator() + { + return m_Files.GetEnumerator(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/MatchNode.cs b/Prebuild/src/Core/Nodes/MatchNode.cs new file mode 100644 index 0000000000..e0d2fa8f02 --- /dev/null +++ b/Prebuild/src/Core/Nodes/MatchNode.cs @@ -0,0 +1,299 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-09-20 09:42:51 +0200 (on, 20 sep 2006) $ + * $Revision: 164 $ + */ +#endregion + +using System; +using System.Collections.Specialized; +using System.IO; +using System.Text.RegularExpressions; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Match")] + public class MatchNode : DataNode + { + #region Fields + + private StringCollection m_Files; + private Regex m_Regex; + private BuildAction m_BuildAction = BuildAction.Compile; + private SubType m_SubType = SubType.Code; + string m_ResourceName = ""; + private CopyToOutput m_CopyToOutput; + private bool m_Link; + + + #endregion + + #region Constructors + + /// + /// + /// + public MatchNode() + { + m_Files = new StringCollection(); + } + + #endregion + + #region Properties + + /// + /// + /// + public StringCollection Files + { + get + { + return m_Files; + } + } + + /// + /// + /// + public BuildAction BuildAction + { + get + { + return m_BuildAction; + } + } + + /// + /// + /// + public SubType SubType + { + get + { + return m_SubType; + } + } + + public CopyToOutput CopyToOutput + { + get + { + return this.m_CopyToOutput; + } + } + + public bool IsLink + { + get + { + return this.m_Link; + } + } + + /// + /// + /// + public string ResourceName + { + get + { + return m_ResourceName; + } + } + + + #endregion + + #region Private Methods + + /// + /// Recurses the directories. + /// + /// The path. + /// The pattern. + /// if set to true [recurse]. + /// if set to true [use regex]. + private void RecurseDirectories(string path, string pattern, bool recurse, bool useRegex) + { + try + { + string[] files; + + if(!useRegex) + { + files = Directory.GetFiles(path, pattern); + if(files != null) + { + string fileTemp; + foreach (string file in files) + { + if (file.Substring(0,2) == "./" || file.Substring(0,2) == ".\\") + { + fileTemp = file.Substring(2); + } + else + { + fileTemp = file; + } + + m_Files.Add(fileTemp); + } + } + else + { + return; + } + } + else + { + Match match; + files = Directory.GetFiles(path); + foreach(string file in files) + { + match = m_Regex.Match(file); + if(match.Success) + { + m_Files.Add(file); + } + } + } + + if(recurse) + { + string[] dirs = Directory.GetDirectories(path); + if(dirs != null && dirs.Length > 0) + { + foreach(string str in dirs) + { + RecurseDirectories(Helper.NormalizePath(str), pattern, recurse, useRegex); + } + } + } + } + catch(DirectoryNotFoundException) + { + return; + } + catch(ArgumentException) + { + return; + } + } + + #endregion + + #region Public Methods + + /// + /// + /// + /// + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + string path = Helper.AttributeValue(node, "path", "."); + string pattern = Helper.AttributeValue(node, "pattern", "*"); + bool recurse = (bool)Helper.TranslateValue(typeof(bool), Helper.AttributeValue(node, "recurse", "false")); + bool useRegex = (bool)Helper.TranslateValue(typeof(bool), Helper.AttributeValue(node, "useRegex", "false")); + m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), + Helper.AttributeValue(node, "buildAction", m_BuildAction.ToString())); + m_SubType = (SubType)Enum.Parse(typeof(SubType), + Helper.AttributeValue(node, "subType", m_SubType.ToString())); + m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString()); + this.m_CopyToOutput = (CopyToOutput) Enum.Parse(typeof(CopyToOutput), Helper.AttributeValue(node, "copyToOutput", this.m_CopyToOutput.ToString())); + this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString)); + + + if(path != null && path.Length == 0) + { + path = ".";//use current directory + } + //throw new WarningException("Match must have a 'path' attribute"); + + if(pattern == null) + { + throw new WarningException("Match must have a 'pattern' attribute"); + } + + path = Helper.NormalizePath(path); + if(!Directory.Exists(path)) + { + throw new WarningException("Match path does not exist: {0}", path); + } + + try + { + if(useRegex) + { + m_Regex = new Regex(pattern); + } + } + catch(ArgumentException ex) + { + throw new WarningException("Could not compile regex pattern: {0}", ex.Message); + } + + RecurseDirectories(path, pattern, recurse, useRegex); + + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is ExcludeNode) + { + ExcludeNode excludeNode = (ExcludeNode)dataNode; + if (m_Files.Contains(Helper.NormalizePath(excludeNode.Name))) + { + m_Files.Remove(Helper.NormalizePath(excludeNode.Name)); + } + } + } + + if(m_Files.Count < 1) + { + throw new WarningException("Match returned no files: {0}{1}", Helper.EndPath(path), pattern); + } + m_Regex = null; + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/OptionsNode.cs b/Prebuild/src/Core/Nodes/OptionsNode.cs new file mode 100644 index 0000000000..b5a2f606db --- /dev/null +++ b/Prebuild/src/Core/Nodes/OptionsNode.cs @@ -0,0 +1,655 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2007-01-08 17:55:40 +0100 (mÃ¥, 08 jan 2007) $ + * $Revision: 197 $ + */ +#endregion + + + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.Reflection; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Options")] + public class OptionsNode : DataNode + { + #region Fields + + private static Hashtable m_OptionFields; + + [OptionNode("CompilerDefines")] + private string m_CompilerDefines = ""; + + /// + /// + /// + public string CompilerDefines + { + get + { + return m_CompilerDefines; + } + set + { + m_CompilerDefines = value; + } + } + + [OptionNode("OptimizeCode")] + private bool m_OptimizeCode; + + /// + /// + /// + public bool OptimizeCode + { + get + { + return m_OptimizeCode; + } + set + { + m_OptimizeCode = value; + } + } + + [OptionNode("CheckUnderflowOverflow")] + private bool m_CheckUnderflowOverflow; + + /// + /// + /// + public bool CheckUnderflowOverflow + { + get + { + return m_CheckUnderflowOverflow; + } + set + { + m_CheckUnderflowOverflow = value; + } + } + + [OptionNode("AllowUnsafe")] + private bool m_AllowUnsafe; + + /// + /// + /// + public bool AllowUnsafe + { + get + { + return m_AllowUnsafe; + } + set + { + m_AllowUnsafe = value; + } + } + + [OptionNode("PreBuildEvent")] + private string m_PreBuildEvent; + + /// + /// + /// + public string PreBuildEvent + { + get + { + return m_PreBuildEvent; + } + set + { + m_PreBuildEvent = value; + } + } + + [OptionNode("PostBuildEvent")] + private string m_PostBuildEvent; + + /// + /// + /// + public string PostBuildEvent + { + get + { + return m_PostBuildEvent; + } + set + { + m_PostBuildEvent = value; + } + } + + [OptionNode("PreBuildEventArgs")] + private string m_PreBuildEventArgs; + + /// + /// + /// + public string PreBuildEventArgs + { + get + { + return m_PreBuildEventArgs; + } + set + { + m_PreBuildEventArgs = value; + } + } + + [OptionNode("PostBuildEventArgs")] + private string m_PostBuildEventArgs; + + /// + /// + /// + public string PostBuildEventArgs + { + get + { + return m_PostBuildEventArgs; + } + set + { + m_PostBuildEventArgs = value; + } + } + + [OptionNode("RunPostBuildEvent")] + private string m_RunPostBuildEvent; + + /// + /// + /// + public string RunPostBuildEvent + { + get + { + return m_RunPostBuildEvent; + } + set + { + m_RunPostBuildEvent = value; + } + } + + [OptionNode("RunScript")] + private string m_RunScript; + + /// + /// + /// + public string RunScript + { + get + { + return m_RunScript; + } + set + { + m_RunScript = value; + } + } + + [OptionNode("WarningLevel")] + private int m_WarningLevel = 4; + + /// + /// + /// + public int WarningLevel + { + get + { + return m_WarningLevel; + } + set + { + m_WarningLevel = value; + } + } + + [OptionNode("WarningsAsErrors")] + private bool m_WarningsAsErrors; + + /// + /// + /// + public bool WarningsAsErrors + { + get + { + return m_WarningsAsErrors; + } + set + { + m_WarningsAsErrors = value; + } + } + + [OptionNode("SuppressWarnings")] + private string m_SuppressWarnings = ""; + + /// + /// + /// + public string SuppressWarnings + { + get + { + return m_SuppressWarnings; + } + set + { + m_SuppressWarnings = value; + } + } + + [OptionNode("OutputPath")] + private string m_OutputPath = "bin/"; + + /// + /// + /// + public string OutputPath + { + get + { + return m_OutputPath; + } + set + { + m_OutputPath = value; + } + } + + [OptionNode("GenerateDocumentation")] + private bool m_GenerateDocumentation; + + /// + /// + /// + public bool GenerateDocumentation + { + get + { + return m_GenerateDocumentation; + } + set + { + m_GenerateDocumentation = value; + } + } + + [OptionNode("GenerateXmlDocFile")] + private bool m_GenerateXmlDocFile; + + /// + /// + /// + public bool GenerateXmlDocFile + { + get + { + return m_GenerateXmlDocFile; + } + set + { + m_GenerateXmlDocFile = value; + } + } + + [OptionNode("XmlDocFile")] + private string m_XmlDocFile = ""; + + /// + /// + /// + public string XmlDocFile + { + get + { + return m_XmlDocFile; + } + set + { + m_XmlDocFile = value; + } + } + + [OptionNode("KeyFile")] + private string m_KeyFile = ""; + + /// + /// + /// + public string KeyFile + { + get + { + return m_KeyFile; + } + set + { + m_KeyFile = value; + } + } + + [OptionNode("DebugInformation")] + private bool m_DebugInformation; + + /// + /// + /// + public bool DebugInformation + { + get + { + return m_DebugInformation; + } + set + { + m_DebugInformation = value; + } + } + + [OptionNode("RegisterComInterop")] + private bool m_RegisterComInterop; + + /// + /// + /// + public bool RegisterComInterop + { + get + { + return m_RegisterComInterop; + } + set + { + m_RegisterComInterop = value; + } + } + + [OptionNode("RemoveIntegerChecks")] + private bool m_RemoveIntegerChecks; + + /// + /// + /// + public bool RemoveIntegerChecks + { + get + { + return m_RemoveIntegerChecks; + } + set + { + m_RemoveIntegerChecks = value; + } + } + + [OptionNode("IncrementalBuild")] + private bool m_IncrementalBuild; + + /// + /// + /// + public bool IncrementalBuild + { + get + { + return m_IncrementalBuild; + } + set + { + m_IncrementalBuild = value; + } + } + + [OptionNode("BaseAddress")] + private string m_BaseAddress = "285212672"; + + /// + /// + /// + public string BaseAddress + { + get + { + return m_BaseAddress; + } + set + { + m_BaseAddress = value; + } + } + + [OptionNode("FileAlignment")] + private int m_FileAlignment = 4096; + + /// + /// + /// + public int FileAlignment + { + get + { + return m_FileAlignment; + } + set + { + m_FileAlignment = value; + } + } + + [OptionNode("NoStdLib")] + private bool m_NoStdLib; + + /// + /// + /// + public bool NoStdLib + { + get + { + return m_NoStdLib; + } + set + { + m_NoStdLib = value; + } + } + + private StringCollection m_FieldsDefined; + + #endregion + + #region Constructors + + /// + /// Initializes the class. + /// + static OptionsNode() + { + Type t = typeof(OptionsNode); + + m_OptionFields = new Hashtable(); + foreach(FieldInfo f in t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)) + { + object[] attrs = f.GetCustomAttributes(typeof(OptionNodeAttribute), false); + if(attrs == null || attrs.Length < 1) + { + continue; + } + + OptionNodeAttribute ona = (OptionNodeAttribute)attrs[0]; + m_OptionFields[ona.NodeName] = f; + } + } + + /// + /// Initializes a new instance of the class. + /// + public OptionsNode() + { + m_FieldsDefined = new StringCollection(); + } + + #endregion + + #region Properties + + /// + /// Gets the at the specified index. + /// + /// + public object this[string index] + { + get + { + if(!m_OptionFields.ContainsKey(index)) + { + return null; + } + + FieldInfo f = (FieldInfo)m_OptionFields[index]; + return f.GetValue(this); + } + } + + /// + /// Gets the at the specified index. + /// + /// + public object this[string index, object defaultValue] + { + get + { + object valueObject = this[index]; + if(valueObject != null && valueObject is string && ((string)valueObject).Length == 0) + { + return defaultValue; + } + return valueObject; + } + } + + + #endregion + + #region Private Methods + + private void FlagDefined(string name) + { + if(!m_FieldsDefined.Contains(name)) + { + m_FieldsDefined.Add(name); + } + } + + private void SetOption(string nodeName, string val) + { + lock(m_OptionFields) + { + if(!m_OptionFields.ContainsKey(nodeName)) + { + return; + } + + FieldInfo f = (FieldInfo)m_OptionFields[nodeName]; + f.SetValue(this, Helper.TranslateValue(f.FieldType, val)); + FlagDefined(f.Name); + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + foreach(XmlNode child in node.ChildNodes) + { + SetOption(child.Name, Helper.InterpolateForEnvironmentVariables(child.InnerText)); + } + } + + /// + /// Copies to. + /// + /// The opt. + public void CopyTo(OptionsNode opt) + { + if(opt == null) + { + return; + } + + foreach(FieldInfo f in m_OptionFields.Values) + { + if(m_FieldsDefined.Contains(f.Name)) + { + f.SetValue(opt, f.GetValue(this)); + opt.m_FieldsDefined.Add(f.Name); + } + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/ProcessNode.cs b/Prebuild/src/Core/Nodes/ProcessNode.cs new file mode 100644 index 0000000000..f546a4bfc1 --- /dev/null +++ b/Prebuild/src/Core/Nodes/ProcessNode.cs @@ -0,0 +1,119 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Revision: 71 $ + */ +#endregion + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Process")] + public class ProcessNode : DataNode + { + #region Fields + + private string m_Path; + private bool m_IsValid = true; + + #endregion + + #region Properties + + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + /// + /// Gets a value indicating whether this instance is valid. + /// + /// true if this instance is valid; otherwise, false. + public bool IsValid + { + get + { + return m_IsValid; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); + if(m_Path == null) + { + m_Path = ""; + } + + try + { + m_Path = Helper.ResolvePath(m_Path); + } + catch(ArgumentException) + { + Kernel.Instance.Log.Write(LogType.Warning, "Could not find prebuild file for processing: {0}", m_Path); + m_IsValid = false; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/ProjectNode.cs b/Prebuild/src/Core/Nodes/ProjectNode.cs new file mode 100644 index 0000000000..7ac0a369b0 --- /dev/null +++ b/Prebuild/src/Core/Nodes/ProjectNode.cs @@ -0,0 +1,490 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-11-11 05:43:20 +0100 (lö, 11 nov 2006) $ + * $Revision: 192 $ + */ +#endregion + +using System; +using System.Collections; +using System.IO; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + public enum ProjectType + { + /// + /// + /// + Exe, + /// + /// + /// + WinExe, + /// + /// + /// + Library + } + + /// + /// + /// + public enum ClrRuntime + { + /// + /// + /// + Microsoft, + /// + /// + /// + Mono + } + + /// + /// + /// + [DataNode("Project")] + public class ProjectNode : DataNode + { + #region Fields + + private string m_Name = "unknown"; + private string m_Path = ""; + private string m_FullPath = ""; + private string m_AssemblyName; + private string m_AppIcon = ""; + private string m_DesignerFolder = ""; + private string m_Language = "C#"; + private ProjectType m_Type = ProjectType.Exe; + private ClrRuntime m_Runtime = ClrRuntime.Microsoft; + private string m_StartupObject = ""; + private string m_RootNamespace; + private string m_FilterGroups = ""; + private Guid m_Guid; + + private Hashtable m_Configurations; + private ArrayList m_ReferencePaths; + private ArrayList m_References; + private FilesNode m_Files; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public ProjectNode() + { + m_Configurations = new Hashtable(); + m_ReferencePaths = new ArrayList(); + m_References = new ArrayList(); + } + + #endregion + + #region Properties + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + /// + /// Gets the filter groups. + /// + /// The filter groups. + public string FilterGroups + { + get + { + return m_FilterGroups; + } + } + + /// + /// Gets the full path. + /// + /// The full path. + public string FullPath + { + get + { + return m_FullPath; + } + } + + /// + /// Gets the name of the assembly. + /// + /// The name of the assembly. + public string AssemblyName + { + get + { + return m_AssemblyName; + } + } + + /// + /// Gets the app icon. + /// + /// The app icon. + public string AppIcon + { + get + { + return m_AppIcon; + } + } + + /// + /// + /// + public string DesignerFolder + { + get + { + return m_DesignerFolder; + } + } + + /// + /// Gets the language. + /// + /// The language. + public string Language + { + get + { + return m_Language; + } + } + + /// + /// Gets the type. + /// + /// The type. + public ProjectType Type + { + get + { + return m_Type; + } + } + + /// + /// Gets the runtime. + /// + /// The runtime. + public ClrRuntime Runtime + { + get + { + return m_Runtime; + } + } + + private bool m_GenerateAssemblyInfoFile = false; + + /// + /// + /// + public bool GenerateAssemblyInfoFile + { + get + { + return m_GenerateAssemblyInfoFile; + } + set + { + m_GenerateAssemblyInfoFile = value; + } + } + + /// + /// Gets the startup object. + /// + /// The startup object. + public string StartupObject + { + get + { + return m_StartupObject; + } + } + + /// + /// Gets the root namespace. + /// + /// The root namespace. + public string RootNamespace + { + get + { + return m_RootNamespace; + } + } + + /// + /// Gets the configurations. + /// + /// The configurations. + public ICollection Configurations + { + get + { + return m_Configurations.Values; + } + } + + /// + /// Gets the configurations table. + /// + /// The configurations table. + public Hashtable ConfigurationsTable + { + get + { + return m_Configurations; + } + } + + /// + /// Gets the reference paths. + /// + /// The reference paths. + public ArrayList ReferencePaths + { + get + { + return m_ReferencePaths; + } + } + + /// + /// Gets the references. + /// + /// The references. + public ArrayList References + { + get + { + return m_References; + } + } + + /// + /// Gets the files. + /// + /// The files. + public FilesNode Files + { + get + { + return m_Files; + } + } + + /// + /// Gets or sets the parent. + /// + /// The parent. + public override IDataNode Parent + { + get + { + return base.Parent; + } + set + { + base.Parent = value; + if(base.Parent is SolutionNode && m_Configurations.Count < 1) + { + SolutionNode parent = (SolutionNode)base.Parent; + foreach(ConfigurationNode conf in parent.Configurations) + { + m_Configurations[conf.Name] = conf.Clone(); + } + } + } + } + + /// + /// Gets the GUID. + /// + /// The GUID. + public Guid Guid + { + get + { + return m_Guid; + } + } + + #endregion + + #region Private Methods + + private void HandleConfiguration(ConfigurationNode conf) + { + if(String.Compare(conf.Name, "all", true) == 0) //apply changes to all, this may not always be applied first, + //so it *may* override changes to the same properties for configurations defines at the project level + { + foreach(ConfigurationNode confNode in this.m_Configurations.Values) + { + conf.CopyTo(confNode);//update the config templates defines at the project level with the overrides + } + } + if(m_Configurations.ContainsKey(conf.Name)) + { + ConfigurationNode parentConf = (ConfigurationNode)m_Configurations[conf.Name]; + conf.CopyTo(parentConf);//update the config templates defines at the project level with the overrides + } + else + { + m_Configurations[conf.Name] = conf; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Name = Helper.AttributeValue(node, "name", m_Name); + m_Path = Helper.AttributeValue(node, "path", m_Path); + m_FilterGroups = Helper.AttributeValue(node, "filterGroups", m_FilterGroups); + m_AppIcon = Helper.AttributeValue(node, "icon", m_AppIcon); + m_DesignerFolder = Helper.AttributeValue(node, "designerFolder", m_DesignerFolder); + m_AssemblyName = Helper.AttributeValue(node, "assemblyName", m_AssemblyName); + m_Language = Helper.AttributeValue(node, "language", m_Language); + m_Type = (ProjectType)Helper.EnumAttributeValue(node, "type", typeof(ProjectType), m_Type); + m_Runtime = (ClrRuntime)Helper.EnumAttributeValue(node, "runtime", typeof(ClrRuntime), m_Runtime); + m_StartupObject = Helper.AttributeValue(node, "startupObject", m_StartupObject); + m_RootNamespace = Helper.AttributeValue(node, "rootNamespace", m_RootNamespace); + m_Guid = Guid.NewGuid(); + m_GenerateAssemblyInfoFile = Helper.ParseBoolean(node, "generateAssemblyInfoFile", false); + + if(m_AssemblyName == null || m_AssemblyName.Length < 1) + { + m_AssemblyName = m_Name; + } + + if(m_RootNamespace == null || m_RootNamespace.Length < 1) + { + m_RootNamespace = m_Name; + } + + m_FullPath = m_Path; + try + { + m_FullPath = Helper.ResolvePath(m_FullPath); + } + catch + { + throw new WarningException("Could not resolve Solution path: {0}", m_Path); + } + + Kernel.Instance.CurrentWorkingDirectory.Push(); + try + { + Helper.SetCurrentDir(m_FullPath); + + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is ConfigurationNode) + { + HandleConfiguration((ConfigurationNode)dataNode); + } + else if(dataNode is ReferencePathNode) + { + m_ReferencePaths.Add(dataNode); + } + else if(dataNode is ReferenceNode) + { + m_References.Add(dataNode); + } + else if(dataNode is FilesNode) + { + m_Files = (FilesNode)dataNode; + } + } + } + finally + { + Kernel.Instance.CurrentWorkingDirectory.Pop(); + } + } + + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/ReferenceNode.cs b/Prebuild/src/Core/Nodes/ReferenceNode.cs new file mode 100644 index 0000000000..beb50dcf3a --- /dev/null +++ b/Prebuild/src/Core/Nodes/ReferenceNode.cs @@ -0,0 +1,143 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-07-25 18:56:49 +0200 (ti, 25 jul 2006) $ + * $Revision: 132 $ + */ +#endregion + +using System; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Reference")] + public class ReferenceNode : DataNode + { + #region Fields + + private string m_Name = "unknown"; + private string m_Path; + private string m_LocalCopy; + private string m_Version; + + #endregion + + #region Properties + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + /// + /// Gets a value indicating whether [local copy specified]. + /// + /// true if [local copy specified]; otherwise, false. + public bool LocalCopySpecified + { + get + { + return ( m_LocalCopy != null && m_LocalCopy.Length == 0); + } + } + + /// + /// Gets a value indicating whether [local copy]. + /// + /// true if [local copy]; otherwise, false. + public bool LocalCopy + { + get + { + if( m_LocalCopy == null) + { + return false; + } + return bool.Parse(m_LocalCopy); + } + } + + /// + /// Gets the version. + /// + /// The version. + public string Version + { + get + { + return m_Version; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Name = Helper.AttributeValue(node, "name", m_Name); + m_Path = Helper.AttributeValue(node, "path", m_Path); + m_LocalCopy = Helper.AttributeValue(node, "localCopy", m_LocalCopy); + m_Version = Helper.AttributeValue(node, "version", m_Version); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/ReferencePathNode.cs b/Prebuild/src/Core/Nodes/ReferencePathNode.cs new file mode 100644 index 0000000000..5d98dda8d8 --- /dev/null +++ b/Prebuild/src/Core/Nodes/ReferencePathNode.cs @@ -0,0 +1,98 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Revision: 71 $ + */ +#endregion + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("ReferencePath")] + public class ReferencePathNode : DataNode + { + #region Fields + + private string m_Path; + + #endregion + + #region Properties + + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); + if(m_Path == null) + { + m_Path = ""; + } + + m_Path = m_Path.Trim(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/SolutionNode.cs b/Prebuild/src/Core/Nodes/SolutionNode.cs new file mode 100644 index 0000000000..0121075c1b --- /dev/null +++ b/Prebuild/src/Core/Nodes/SolutionNode.cs @@ -0,0 +1,284 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-02-28 17:15:42 +0100 (ti, 28 feb 2006) $ + * $Revision: 92 $ + */ +#endregion + +using System; +using System.Collections; +using System.Diagnostics; +using System.IO; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Solution")] + public class SolutionNode : DataNode + { + #region Fields + + private string m_Name = "unknown"; + private string m_Path = ""; + private string m_FullPath = ""; + private string m_ActiveConfig = "Debug"; + + private OptionsNode m_Options; + private FilesNode m_Files; + private Hashtable m_Configurations; + private Hashtable m_Projects; + private ArrayList m_ProjectsOrder; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public SolutionNode() + { + m_Configurations = new Hashtable(); + m_Projects = new Hashtable(); + m_ProjectsOrder = new ArrayList(); + } + + #endregion + + #region Properties + + /// + /// Gets or sets the active config. + /// + /// The active config. + public string ActiveConfig + { + get + { + return m_ActiveConfig; + } + set + { + m_ActiveConfig = value; + } + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + /// + /// Gets the full path. + /// + /// The full path. + public string FullPath + { + get + { + return m_FullPath; + } + } + + /// + /// Gets the options. + /// + /// The options. + public OptionsNode Options + { + get + { + return m_Options; + } + } + + /// + /// Gets the files. + /// + /// The files. + public FilesNode Files + { + get + { + return m_Files; + } + } + + /// + /// Gets the configurations. + /// + /// The configurations. + public ICollection Configurations + { + get + { + return m_Configurations.Values; + } + } + + /// + /// Gets the configurations table. + /// + /// The configurations table. + public Hashtable ConfigurationsTable + { + get + { + return m_Configurations; + } + } + + /// + /// Gets the projects. + /// + /// The projects. + public ICollection Projects + { + get + { + return m_Projects.Values; + } + } + + /// + /// Gets the projects table. + /// + /// The projects table. + public Hashtable ProjectsTable + { + get + { + return m_Projects; + } + } + + /// + /// Gets the projects table. + /// + /// The projects table. + public ArrayList ProjectsTableOrder + { + get + { + return m_ProjectsOrder; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Name = Helper.AttributeValue(node, "name", m_Name); + m_ActiveConfig = Helper.AttributeValue(node, "activeConfig", m_ActiveConfig); + m_Path = Helper.AttributeValue(node, "path", m_Path); + + m_FullPath = m_Path; + try + { + m_FullPath = Helper.ResolvePath(m_FullPath); + } + catch + { + throw new WarningException("Could not resolve solution path: {0}", m_Path); + } + + Kernel.Instance.CurrentWorkingDirectory.Push(); + try + { + Helper.SetCurrentDir(m_FullPath); + + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is OptionsNode) + { + m_Options = (OptionsNode)dataNode; + } + else if(dataNode is FilesNode) + { + m_Files = (FilesNode)dataNode; + } + else if(dataNode is ConfigurationNode) + { + m_Configurations[((ConfigurationNode)dataNode).Name] = dataNode; + } + else if(dataNode is ProjectNode) + { + m_Projects[((ProjectNode)dataNode).Name] = dataNode; + m_ProjectsOrder.Add(dataNode); + } + } + } + finally + { + Kernel.Instance.CurrentWorkingDirectory.Pop(); + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Parse/IfContext.cs b/Prebuild/src/Core/Parse/IfContext.cs new file mode 100644 index 0000000000..383049d169 --- /dev/null +++ b/Prebuild/src/Core/Parse/IfContext.cs @@ -0,0 +1,163 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Revision: 71 $ + */ +#endregion + +using System; + +namespace Prebuild.Core.Parse +{ + /// + /// + /// + public enum IfState + { + /// + /// + /// + None, + /// + /// + /// + If, + /// + /// + /// + ElseIf, + /// + /// + /// + Else + } + + /// + /// Summary description for IfContext. + /// + // Inspired by the equivalent WiX class (see www.sourceforge.net/projects/wix/) + public class IfContext + { + #region Properties + + bool m_Active; + bool m_Keep; + bool m_EverKept; + IfState m_State = IfState.None; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// if set to true [active]. + /// if set to true [keep]. + /// The state. + public IfContext(bool active, bool keep, IfState state) + { + m_Active = active; + m_Keep = keep; + m_EverKept = keep; + m_State = state; + } + + #endregion + + #region Properties + + /// + /// Gets or sets a value indicating whether this is active. + /// + /// true if active; otherwise, false. + public bool Active + { + get + { + return m_Active; + } + set + { + m_Active = value; + } + } + + /// + /// Gets or sets a value indicating whether this is keep. + /// + /// true if keep; otherwise, false. + public bool Keep + { + get + { + return m_Keep; + } + set + { + m_Keep = value; + if(m_Keep) + { + m_EverKept = true; + } + } + } + + /// + /// Gets a value indicating whether [ever kept]. + /// + /// true if [ever kept]; otherwise, false. + public bool EverKept + { + get + { + return m_EverKept; + } + } + + /// + /// Gets or sets the state. + /// + /// The state. + public IfState State + { + get + { + return m_State; + } + set + { + m_State = value; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Parse/Preprocessor.cs b/Prebuild/src/Core/Parse/Preprocessor.cs new file mode 100644 index 0000000000..85e92c35cc --- /dev/null +++ b/Prebuild/src/Core/Parse/Preprocessor.cs @@ -0,0 +1,519 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-09-01 19:55:06 +0200 (fr, 01 sep 2006) $ + * $Revision: 147 $ + */ +#endregion + +using System; +using System.Collections; +using System.IO; +using System.Xml; + +namespace Prebuild.Core.Parse +{ + /// + /// + /// + public enum OperatorSymbol + { + /// + /// + /// + None, + /// + /// + /// + Equal, + /// + /// + /// + NotEqual, + /// + /// + /// + LessThan, + /// + /// + /// + GreaterThan, + /// + /// + /// + LessThanEqual, + /// + /// + /// + GreaterThanEqual + } + + /// + /// + /// + public class Preprocessor + { + #region Fields + + XmlDocument m_OutDoc; + Stack m_IfStack; + Hashtable m_Variables; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public Preprocessor() + { + m_OutDoc = new XmlDocument(); + m_IfStack = new Stack(); + m_Variables = new Hashtable(); + + RegisterVariable("OS", GetOS()); + RegisterVariable("RuntimeVersion", Environment.Version.Major); + RegisterVariable("RuntimeMajor", Environment.Version.Major); + RegisterVariable("RuntimeMinor", Environment.Version.Minor); + RegisterVariable("RuntimeRevision", Environment.Version.Revision); + } + + #endregion + + #region Properties + + /// + /// Gets the processed doc. + /// + /// The processed doc. + public XmlDocument ProcessedDoc + { + get + { + return m_OutDoc; + } + } + + #endregion + + #region Private Methods + + /// + /// Parts of this code were taken from NAnt and is subject to the GPL + /// as per NAnt's license. Thanks to the NAnt guys for this little gem. + /// + /// + public static string GetOS() + { + PlatformID platId = Environment.OSVersion.Platform; + if(platId == PlatformID.Win32NT || platId == PlatformID.Win32Windows) + { + return "Win32"; + } + + /* + * .NET 1.x, under Mono, the UNIX code is 128. Under + * .NET 2.x, Mono or MS, the UNIX code is 4 + */ + if(Environment.Version.Major == 1) + { + if((int)platId == 128) + { + return "UNIX"; + } + } + else if((int)platId == 4) + { + return "UNIX"; + } + + return "Unknown"; + } + + private static bool CompareNum(OperatorSymbol oper, int val1, int val2) + { + switch(oper) + { + case OperatorSymbol.Equal: + return (val1 == val2); + case OperatorSymbol.NotEqual: + return (val1 != val2); + case OperatorSymbol.LessThan: + return (val1 < val2); + case OperatorSymbol.LessThanEqual: + return (val1 <= val2); + case OperatorSymbol.GreaterThan: + return (val1 > val2); + case OperatorSymbol.GreaterThanEqual: + return (val1 >= val2); + } + + throw new WarningException("Unknown operator type"); + } + + private static bool CompareStr(OperatorSymbol oper, string val1, string val2) + { + switch(oper) + { + case OperatorSymbol.Equal: + return (val1 == val2); + case OperatorSymbol.NotEqual: + return (val1 != val2); + case OperatorSymbol.LessThan: + return (val1.CompareTo(val2) < 0); + case OperatorSymbol.LessThanEqual: + return (val1.CompareTo(val2) <= 0); + case OperatorSymbol.GreaterThan: + return (val1.CompareTo(val2) > 0); + case OperatorSymbol.GreaterThanEqual: + return (val1.CompareTo(val2) >= 0); + } + + throw new WarningException("Unknown operator type"); + } + + private static char NextChar(int idx, string str) + { + if((idx + 1) >= str.Length) + { + return Char.MaxValue; + } + + return str[idx + 1]; + } + // Very very simple expression parser. Can only match expressions of the form + // : + // OS = Windows + // OS != Linux + // RuntimeMinor > 0 + private bool ParseExpression(string exp) + { + if(exp == null) + { + throw new ArgumentException("Invalid expression, cannot be null"); + } + + exp = exp.Trim(); + if(exp.Length < 1) + { + throw new ArgumentException("Invalid expression, cannot be 0 length"); + } + + string id = ""; + string str = ""; + OperatorSymbol oper = OperatorSymbol.None; + bool inStr = false; + char c; + + for(int i = 0; i < exp.Length; i++) + { + c = exp[i]; + if(Char.IsWhiteSpace(c)) + { + continue; + } + + if(Char.IsLetterOrDigit(c) || c == '_') + { + if(inStr) + { + str += c; + } + else + { + id += c; + } + } + else if(c == '\"') + { + inStr = !inStr; + if(inStr) + { + str = ""; + } + } + else + { + if(inStr) + { + str += c; + } + else + { + switch(c) + { + case '=': + oper = OperatorSymbol.Equal; + break; + + case '!': + if(NextChar(i, exp) == '=') + { + oper = OperatorSymbol.NotEqual; + } + + break; + + case '<': + if(NextChar(i, exp) == '=') + { + oper = OperatorSymbol.LessThanEqual; + } + else + { + oper = OperatorSymbol.LessThan; + } + + break; + + case '>': + if(NextChar(i, exp) == '=') + { + oper = OperatorSymbol.GreaterThanEqual; + } + else + { + oper = OperatorSymbol.GreaterThan; + } + + break; + } + } + } + } + + + if(inStr) + { + throw new WarningException("Expected end of string in expression"); + } + + if(oper == OperatorSymbol.None) + { + throw new WarningException("Expected operator in expression"); + } + else if(id.Length < 1) + { + throw new WarningException("Expected identifier in expression"); + } + else if(str.Length < 1) + { + throw new WarningException("Expected value in expression"); + } + + bool ret = false; + try + { + object val = m_Variables[id.ToLower()]; + if(val == null) + { + throw new WarningException("Unknown identifier '{0}'", id); + } + + int numVal, numVal2; + string strVal, strVal2; + Type t = val.GetType(); + if(t.IsAssignableFrom(typeof(int))) + { + numVal = (int)val; + numVal2 = Int32.Parse(str); + ret = CompareNum(oper, numVal, numVal2); + } + else + { + strVal = val.ToString(); + strVal2 = str; + ret = CompareStr(oper, strVal, strVal2); + } + } + catch(ArgumentException ex) + { + ex.ToString(); + throw new WarningException("Invalid value type for system variable '{0}', expected int", id); + } + + return ret; + } + + #endregion + + #region Public Methods + + /// + /// + /// + /// + /// + public void RegisterVariable(string name, object variableValue) + { + if(name == null || variableValue == null) + { + return; + } + + m_Variables[name.ToLower()] = variableValue; + } + + /// + /// Performs validation on the xml source as well as evaluates conditional and flow expresions + /// + /// For invalid use of conditional expressions or for invalid XML syntax. If a XmlValidatingReader is passed, then will also throw exceptions for non-schema-conforming xml + /// + /// the output xml + public string Process(XmlReader reader) + { + if(reader == null) + { + throw new ArgumentException("Invalid XML reader to pre-process"); + } + + IfContext context = new IfContext(true, true, IfState.None); + StringWriter xmlText = new StringWriter(); + XmlTextWriter writer = new XmlTextWriter(xmlText); + writer.Formatting = Formatting.Indented; + while(reader.Read()) + { + if(reader.NodeType == XmlNodeType.ProcessingInstruction) + { + bool ignore = false; + switch(reader.LocalName) + { + case "if": + m_IfStack.Push(context); + context = new IfContext(context.Keep & context.Active, ParseExpression(reader.Value), IfState.If); + ignore = true; + break; + + case "elseif": + if(m_IfStack.Count == 0) + { + throw new WarningException("Unexpected 'elseif' outside of 'if'"); + } + else if(context.State != IfState.If && context.State != IfState.ElseIf) + { + throw new WarningException("Unexpected 'elseif' outside of 'if'"); + } + + context.State = IfState.ElseIf; + if(!context.EverKept) + { + context.Keep = ParseExpression(reader.Value); + } + else + { + context.Keep = false; + } + + ignore = true; + break; + + case "else": + if(m_IfStack.Count == 0) + { + throw new WarningException("Unexpected 'else' outside of 'if'"); + } + else if(context.State != IfState.If && context.State != IfState.ElseIf) + { + throw new WarningException("Unexpected 'else' outside of 'if'"); + } + + context.State = IfState.Else; + context.Keep = !context.EverKept; + ignore = true; + break; + + case "endif": + if(m_IfStack.Count == 0) + { + throw new WarningException("Unexpected 'endif' outside of 'if'"); + } + + context = (IfContext)m_IfStack.Pop(); + ignore = true; + break; + } + + if(ignore) + { + continue; + } + }//end pre-proc instruction + + if(!context.Active || !context.Keep) + { + continue; + } + + switch(reader.NodeType) + { + case XmlNodeType.Element: + bool empty = reader.IsEmptyElement; + writer.WriteStartElement(reader.Name); + + while (reader.MoveToNextAttribute()) + { + writer.WriteAttributeString(reader.Name, reader.Value); + } + + if(empty) + { + writer.WriteEndElement(); + } + + break; + + case XmlNodeType.EndElement: + writer.WriteEndElement(); + break; + + case XmlNodeType.Text: + writer.WriteString(reader.Value); + break; + + case XmlNodeType.CDATA: + writer.WriteCData(reader.Value); + break; + + default: + break; + } + } + + if(m_IfStack.Count != 0) + { + throw new WarningException("Mismatched 'if', 'endif' pair"); + } + + return xmlText.ToString(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/AutotoolsTarget.cs b/Prebuild/src/Core/Targets/AutotoolsTarget.cs new file mode 100644 index 0000000000..2b4a67818d --- /dev/null +++ b/Prebuild/src/Core/Targets/AutotoolsTarget.cs @@ -0,0 +1,926 @@ +#region BSD License +/* + +Copyright (c) 2004 - 2006 +Matthew Holmes (matthew@wildfiregames.com), +Dan Moorehead (dan05a@gmail.com), +Dave Hudson (jendave@yahoo.com), +C.J. Adams-Collier (cjcollier@colliertech.org), + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +* Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +* The name of the author may not be used to endorse or promote +products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-07-28 22:43:24 -0700 (Fri, 28 Jul 2006) $ + * $Revision: 136 $ + */ +#endregion + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.IO; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Parse; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Targets +{ + /// + /// + /// + [Target("autotools")] + public class AutotoolsTarget : ITarget + { + #region Fields + + private Kernel m_Kernel; + + #endregion + + #region Private Methods + + private static string PrependPath(string path) + { + string tmpPath = Helper.NormalizePath(path, '/'); + Regex regex = new Regex(@"(\w):/(\w+)"); + Match match = regex.Match(tmpPath); + if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/') + { + tmpPath = Helper.NormalizePath(tmpPath); + } + else + { + tmpPath = Helper.NormalizePath("./" + tmpPath); + } + + return tmpPath; + } + + private static string BuildReference(SolutionNode solution, ReferenceNode refr) + { + string ret = ""; + if(solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; + string fileRef = FindFileReference(refr.Name, project); + string finalPath = Helper.NormalizePath(Helper.MakeFilePath(project.FullPath + "/$(BUILD_DIR)/$(CONFIG)/", refr.Name, "dll"), '/'); + ret += finalPath; + return ret; + } + else + { + ProjectNode project = (ProjectNode)refr.Parent; + string fileRef = FindFileReference(refr.Name, project); + + if(refr.Path != null || fileRef != null) + { + string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path + "/" + refr.Name + ".dll", '/') : fileRef; + ret += Path.Combine(project.Path, finalPath); + return ret; + } + + try + { + //Assembly assem = Assembly.Load(refr.Name); + //if (assem != null) + //{ + // int index = refr.Name.IndexOf(","); + // if ( index > 0) + // { + // ret += assem.Location; + // //Console.WriteLine("Location1: " + assem.Location); + // } + // else + // { + // ret += (refr.Name + ".dll"); + // //Console.WriteLine("Location2: " + assem.Location); + // } + //} + //else + //{ + int index = refr.Name.IndexOf(","); + if ( index > 0) + { + ret += refr.Name.Substring(0, index) + ".dll"; + //Console.WriteLine("Location3: " + assem.Location); + } + else + { + ret += (refr.Name + ".dll"); + //Console.WriteLine("Location4: " + assem.Location); + } + //} + } + catch (System.NullReferenceException e) + { + e.ToString(); + int index = refr.Name.IndexOf(","); + if ( index > 0) + { + ret += refr.Name.Substring(0, index) + ".dll"; + //Console.WriteLine("Location5: " + assem.Location); + } + else + { + ret += (refr.Name + ".dll"); + //Console.WriteLine("Location6: " + assem.Location); + } + } + } + return ret; + } + + private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr) + { + string ret = ""; + if(solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; + string finalPath = Helper.NormalizePath(Helper.MakeReferencePath(project.FullPath + "/${build.dir}/"), '/'); + ret += finalPath; + return ret; + } + else + { + ProjectNode project = (ProjectNode)refr.Parent; + string fileRef = FindFileReference(refr.Name, project); + + + if(refr.Path != null || fileRef != null) + { + string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef; + ret += finalPath; + return ret; + } + + try + { + Assembly assem = Assembly.Load(refr.Name); + if (assem != null) + { + ret += ""; + } + else + { + ret += ""; + } + } + catch (System.NullReferenceException e) + { + e.ToString(); + ret += ""; + } + } + return ret; + } + + private static string FindFileReference(string refName, ProjectNode project) + { + foreach(ReferencePathNode refPath in project.ReferencePaths) + { + string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); + + if(File.Exists(fullPath)) + { + return fullPath; + } + } + + return null; + } + + /// + /// Gets the XML doc file. + /// + /// The project. + /// The conf. + /// + public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) + { + if( conf == null ) + { + throw new ArgumentNullException("conf"); + } + if( project == null ) + { + throw new ArgumentNullException("project"); + } + string docFile = (string)conf.Options["XmlDocFile"]; + // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified + // { + // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; + // } + return docFile; + } + + /// + /// Normalizes the path. + /// + /// The path. + /// + public static string NormalizePath(string path) + { + if(path == null) + { + return ""; + } + + StringBuilder tmpPath; + + if (Core.Parse.Preprocessor.GetOS() == "Win32") + { + tmpPath = new StringBuilder(path.Replace('\\', '/')); + tmpPath.Replace("/", @"\\"); + } + else + { + tmpPath = new StringBuilder(path.Replace('\\', '/')); + tmpPath = tmpPath.Replace('/', Path.DirectorySeparatorChar); + } + return tmpPath.ToString(); + } + + private void WriteProject(SolutionNode solution, ProjectNode project) + { + string projFile = Helper.MakeFilePath(project.FullPath, "Include", "am"); + StreamWriter ss = new StreamWriter(projFile); + ss.NewLine = "\n"; + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); + + using(ss) + { + ss.WriteLine(Helper.AssemblyFullName(project.AssemblyName, project.Type) + ":"); + ss.WriteLine("\tmkdir -p " + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/"); + foreach(string file in project.Files) + { + if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) + { + ss.Write("\tresgen "); + ss.Write(Helper.NormalizePath(Path.Combine(project.Path, file.Substring(0, file.LastIndexOf('.')) + ".resx "), '/')); + if (project.Files.GetResourceName(file) != "") + { + ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/')); + } + else + { + ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/')); + } + } + } + ss.WriteLine("\t$(CSC)\t/out:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " \\"); + ss.WriteLine("\t\t/target:" + project.Type.ToString().ToLower() + " \\"); + if (project.References.Count > 0) + { + ss.Write("\t\t/reference:"); + bool firstref = true; + foreach(ReferenceNode refr in project.References) + { + if (firstref) + { + firstref = false; + } + else + { + ss.Write(","); + } + ss.Write("{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(solution.FullPath, BuildReference(solution, refr)), '/')); + } + ss.WriteLine(" \\"); + } + //ss.WriteLine("\t\tProperties/AssemblyInfo.cs \\"); + + foreach(string file in project.Files) + { + switch(project.Files.GetBuildAction(file)) + { + case BuildAction.EmbeddedResource: + ss.Write("\t\t/resource:"); + ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, file), '/') + " \\"); + break; + default: + if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) + { + ss.Write("\t\t/resource:"); + if (project.Files.GetResourceName(file) != "") + { + ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/') + "," + project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources" + " \\"); + } + else + { + ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/') + "," + project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources" + " \\"); + } + } + break; + } + } + + foreach(ConfigurationNode conf in project.Configurations) + { + if (conf.Options.KeyFile !="") + { + ss.WriteLine("\t\t/keyfile:" + Helper.NormalizePath(Path.Combine(project.Path, conf.Options.KeyFile), '/') + " \\"); + break; + } + } + foreach(ConfigurationNode conf in project.Configurations) + { + if (conf.Options.AllowUnsafe) + { + ss.WriteLine("\t\t/unsafe \\"); + break; + } + } + if (project.AppIcon != "") + { + ss.WriteLine("\t\t/win32icon:" + Helper.NormalizePath(Path.Combine(project.Path, project.AppIcon), '/') + " \\"); + } + + foreach(ConfigurationNode conf in project.Configurations) + { + ss.WriteLine("\t\t/define:{0}", conf.Options.CompilerDefines.Replace(';', ',') + " \\"); + break; + } + + foreach(ConfigurationNode conf in project.Configurations) + { + if (GetXmlDocFile(project, conf) !="") + { + ss.WriteLine("\t\t/doc:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + project.Name + ".xml \\"); + break; + } + } + foreach(string file in project.Files) + { + switch(project.Files.GetBuildAction(file)) + { + case BuildAction.Compile: + ss.WriteLine("\t\t\\"); + ss.Write("\t\t" + NormalizePath(Path.Combine(Helper.MakePathRelativeTo(solution.FullPath, project.Path), file))); + break; + default: + break; + } + } + ss.WriteLine(); + ss.WriteLine(); + + if (project.Type == ProjectType.Library) + { + ss.WriteLine("install-data-local:"); + ss.WriteLine(" echo \"$(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS)\"; \\"); + ss.WriteLine(" $(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS) || exit 1;"); + ss.WriteLine(); + ss.WriteLine("uninstall-local:"); + ss.WriteLine(" echo \"$(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS)\"; \\"); + ss.WriteLine(" $(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS) || exit 1;"); + ss.WriteLine(); + } + ss.WriteLine("CLEANFILES = $(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " $(BUILD_DIR)/$(CONFIG)/" + project.AssemblyName + ".mdb $(BUILD_DIR)/$(CONFIG)/" + project.AssemblyName + ".pdb " + project.AssemblyName + ".xml"); + ss.WriteLine("EXTRA_DIST = \\"); + ss.Write(" $(FILES)"); + foreach(ConfigurationNode conf in project.Configurations) + { + if (conf.Options.KeyFile != "") + { + ss.Write(" \\"); + ss.WriteLine("\t" + conf.Options.KeyFile); + } + break; + } + } + m_Kernel.CurrentWorkingDirectory.Pop(); + } + bool hasLibrary = false; + + private void WriteCombine(SolutionNode solution) + { + + /* TODO: These vars should be pulled from the prebuild.xml file */ + string releaseVersion = "2.0.0"; + string assemblyVersion = "2.1.0.0"; + string description = + "Tao Framework " + solution.Name + " Binding For .NET"; + + hasLibrary = false; + m_Kernel.Log.Write("Creating Autotools make files"); + foreach(ProjectNode project in solution.Projects) + { + if(m_Kernel.AllowProject(project.FilterGroups)) + { + m_Kernel.Log.Write("...Creating makefile: {0}", project.Name); + WriteProject(solution, project); + } + } + + m_Kernel.Log.Write(""); + string combFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am"); + StreamWriter ss = new StreamWriter(combFile); + ss.NewLine = "\n"; + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); + + using(ss) + { + foreach(ProjectNode project in solution.ProjectsTableOrder) + { + if (project.Type == ProjectType.Library) + { + hasLibrary = true; + break; + } + } + + if (hasLibrary) + { + ss.Write("pkgconfig_in_files = "); + foreach(ProjectNode project in solution.ProjectsTableOrder) + { + if (project.Type == ProjectType.Library) + { + string combFilepc = Helper.MakeFilePath(solution.FullPath, project.Name, "pc.in"); + ss.Write(" " + project.Name + ".pc.in "); + StreamWriter sspc = new StreamWriter(combFilepc); + sspc.NewLine = "\n"; + using(sspc) + { + sspc.WriteLine("prefix=@prefix@"); + sspc.WriteLine("exec_prefix=${prefix}"); + sspc.WriteLine("libdir=${exec_prefix}/lib"); + sspc.WriteLine(); + sspc.WriteLine("Name: @PACKAGE_NAME@"); + sspc.WriteLine("Description: @DESCRIPTION@"); + sspc.WriteLine("Version: @ASSEMBLY_VERSION@"); + sspc.WriteLine("Libs: -r:${libdir}/mono/gac/@PACKAGE_NAME@/@ASSEMBLY_VERSION@__@PUBKEY@/@PACKAGE_NAME@.dll"); + } + } + } + + ss.WriteLine(); + ss.WriteLine("pkgconfigdir=$(prefix)/lib/pkgconfig"); + ss.WriteLine("pkgconfig_DATA=$(pkgconfig_in_files:.pc.in=.pc)"); + } + ss.WriteLine(); + foreach(ProjectNode project in solution.ProjectsTableOrder) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.WriteLine("-include x {0}", + Helper.NormalizePath(Helper.MakeFilePath(path, "Include", "am"),'/')); + } + ss.WriteLine(); + ss.WriteLine("all: \\"); + ss.Write("\t"); + foreach(ProjectNode project in solution.ProjectsTableOrder) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.Write(Helper.AssemblyFullName(project.AssemblyName, project.Type) + " "); + + } + ss.WriteLine(); + if (hasLibrary) + { + ss.WriteLine("EXTRA_DIST = \\"); + ss.WriteLine("\t$(pkgconfig_in_files)"); + } + else + { + ss.WriteLine("EXTRA_DIST = "); + } + ss.WriteLine(); + ss.WriteLine("DISTCLEANFILES = \\"); + ss.WriteLine("\tconfigure \\"); + ss.WriteLine("\tMakefile.in \\"); + ss.WriteLine("\taclocal.m4"); + } + combFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac"); + StreamWriter ts = new StreamWriter(combFile); + ts.NewLine = "\n"; + using(ts) + { + if (this.hasLibrary) + { + foreach(ProjectNode project in solution.ProjectsTableOrder) + { + if (project.Type == ProjectType.Library) + { + ts.WriteLine("AC_INIT(" + project.Name + ".pc.in)"); + break; + } + } + } + else + { + ts.WriteLine("AC_INIT(Makefile.am)"); + } + ts.WriteLine("AC_PREREQ(2.53)"); + ts.WriteLine("AC_CANONICAL_SYSTEM"); + + ts.WriteLine("PACKAGE_NAME={0}", solution.Name); + ts.WriteLine("PACKAGE_VERSION={0}", releaseVersion); + ts.WriteLine("DESCRIPTION=\"{0}\"", description); + ts.WriteLine("AC_SUBST(DESCRIPTION)"); + ts.WriteLine("AM_INIT_AUTOMAKE([$PACKAGE_NAME],[$PACKAGE_VERSION],[$DESCRIPTION])"); + + ts.WriteLine("ASSEMBLY_VERSION={0}", assemblyVersion); + ts.WriteLine("AC_SUBST(ASSEMBLY_VERSION)"); + + ts.WriteLine("PUBKEY=`sn -t $PACKAGE_NAME.snk | grep 'Public Key Token' | awk -F: '{print $2}' | sed -e 's/^ //'`"); + ts.WriteLine("AC_SUBST(PUBKEY)"); + + ts.WriteLine(); + ts.WriteLine("AM_MAINTAINER_MODE"); + ts.WriteLine(); + ts.WriteLine("dnl AC_PROG_INTLTOOL([0.25])"); + ts.WriteLine(); + ts.WriteLine("AC_PROG_INSTALL"); + ts.WriteLine(); + ts.WriteLine("MONO_REQUIRED_VERSION=1.1"); + ts.WriteLine(); + ts.WriteLine("AC_MSG_CHECKING([whether we're compiling from CVS])"); + ts.WriteLine("if test -f \"$srcdir/.cvs_version\" ; then"); + ts.WriteLine(" from_cvs=yes"); + ts.WriteLine("else"); + ts.WriteLine(" if test -f \"$srcdir/.svn\" ; then"); + ts.WriteLine(" from_cvs=yes"); + ts.WriteLine(" else"); + ts.WriteLine(" from_cvs=no"); + ts.WriteLine(" fi"); + ts.WriteLine("fi"); + ts.WriteLine(); + ts.WriteLine("AC_MSG_RESULT($from_cvs)"); + ts.WriteLine(); + ts.WriteLine("AC_PATH_PROG(MONO, mono)"); + ts.WriteLine("AC_PATH_PROG(GMCS, gmcs)"); + ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil)"); + ts.WriteLine(); + ts.WriteLine("AC_MSG_CHECKING([for mono])"); + ts.WriteLine("dnl if test \"x$MONO\" = \"x\" ; then"); + ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"mono\" in your PATH])"); + ts.WriteLine("dnl else"); + ts.WriteLine(" AC_MSG_RESULT([found])"); + ts.WriteLine("dnl fi"); + ts.WriteLine(); + ts.WriteLine("AC_MSG_CHECKING([for gmcs])"); + ts.WriteLine("dnl if test \"x$GMCS\" = \"x\" ; then"); + ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"gmcs\" in your PATH])"); + ts.WriteLine("dnl else"); + ts.WriteLine(" AC_MSG_RESULT([found])"); + ts.WriteLine("dnl fi"); + ts.WriteLine(); + //ts.WriteLine("AC_MSG_CHECKING([for gacutil])"); + //ts.WriteLine("if test \"x$GACUTIL\" = \"x\" ; then"); + //ts.WriteLine(" AC_MSG_ERROR([Can't find \"gacutil\" in your PATH])"); + //ts.WriteLine("else"); + //ts.WriteLine(" AC_MSG_RESULT([found])"); + //ts.WriteLine("fi"); + ts.WriteLine(); + ts.WriteLine("AC_SUBST(PATH)"); + ts.WriteLine("AC_SUBST(LD_LIBRARY_PATH)"); + ts.WriteLine(); + ts.WriteLine("dnl CSFLAGS=\"-debug -nowarn:1574\""); + ts.WriteLine("CSFLAGS=\"\""); + ts.WriteLine("AC_SUBST(CSFLAGS)"); + ts.WriteLine(); + // ts.WriteLine("AC_MSG_CHECKING(--disable-sdl argument)"); + // ts.WriteLine("AC_ARG_ENABLE(sdl,"); + // ts.WriteLine(" [ --disable-sdl Disable Sdl interface.],"); + // ts.WriteLine(" [disable_sdl=$disableval],"); + // ts.WriteLine(" [disable_sdl=\"no\"])"); + // ts.WriteLine("AC_MSG_RESULT($disable_sdl)"); + // ts.WriteLine("if test \"$disable_sdl\" = \"yes\"; then"); + // ts.WriteLine(" AC_DEFINE(FEAT_SDL)"); + // ts.WriteLine("fi"); + ts.WriteLine(); + ts.WriteLine("dnl Find pkg-config"); + ts.WriteLine("AC_PATH_PROG(PKGCONFIG, pkg-config, no)"); + ts.WriteLine("if test \"x$PKG_CONFIG\" = \"xno\"; then"); + ts.WriteLine(" AC_MSG_ERROR([You need to install pkg-config])"); + ts.WriteLine("fi"); + ts.WriteLine(); + ts.WriteLine("PKG_CHECK_MODULES(MONO_DEPENDENCY, mono >= $MONO_REQUIRED_VERSION, has_mono=true, has_mono=false)"); + ts.WriteLine("BUILD_DIR=\"bin\""); + ts.WriteLine("AC_SUBST(BUILD_DIR)"); + ts.WriteLine("CONFIG=\"Release\""); + ts.WriteLine("AC_SUBST(CONFIG)"); + ts.WriteLine(); + ts.WriteLine("if test \"x$has_mono\" = \"xtrue\"; then"); + ts.WriteLine(" AC_PATH_PROG(RUNTIME, mono, no)"); + ts.WriteLine(" AC_PATH_PROG(CSC, gmcs, no)"); + ts.WriteLine(" if test `uname -s` = \"Darwin\"; then"); + ts.WriteLine(" LIB_PREFIX="); + ts.WriteLine(" LIB_SUFFIX=.dylib"); + ts.WriteLine(" else"); + ts.WriteLine(" LIB_PREFIX=.so"); + ts.WriteLine(" LIB_SUFFIX="); + ts.WriteLine(" fi"); + ts.WriteLine("else"); + ts.WriteLine(" AC_PATH_PROG(CSC, csc.exe, no)"); + ts.WriteLine(" if test x$CSC = \"xno\"; then"); + ts.WriteLine(" AC_MSG_ERROR([You need to install either mono or .Net])"); + ts.WriteLine(" else"); + ts.WriteLine(" RUNTIME="); + ts.WriteLine(" LIB_PREFIX="); + ts.WriteLine(" LIB_SUFFIX=.dylib"); + ts.WriteLine(" fi"); + ts.WriteLine("fi"); + ts.WriteLine(); + ts.WriteLine("AC_SUBST(LIB_PREFIX)"); + ts.WriteLine("AC_SUBST(LIB_SUFFIX)"); + ts.WriteLine(); + ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_CFLAGS)"); + ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_LIBS)"); + ts.WriteLine(); + ts.WriteLine("dnl Find monodoc"); + ts.WriteLine("MONODOC_REQUIRED_VERSION=1.0"); + ts.WriteLine("AC_SUBST(MONODOC_REQUIRED_VERSION)"); + ts.WriteLine("PKG_CHECK_MODULES(MONODOC_DEPENDENCY, monodoc >= $MONODOC_REQUIRED_VERSION, enable_monodoc=yes, enable_monodoc=no)"); + ts.WriteLine(); + ts.WriteLine("if test \"x$enable_monodoc\" = \"xyes\"; then"); + ts.WriteLine(" AC_PATH_PROG(MONODOC, monodoc, no)"); + ts.WriteLine(" if test x$MONODOC = xno; then"); + ts.WriteLine(" enable_monodoc=no"); + ts.WriteLine(" fi"); + ts.WriteLine("else"); + ts.WriteLine(" MONODOC="); + ts.WriteLine("fi"); + ts.WriteLine(); + ts.WriteLine("AC_SUBST(MONODOC)"); + ts.WriteLine("AM_CONDITIONAL(ENABLE_MONODOC, test \"x$enable_monodoc\" = \"xyes\")"); + ts.WriteLine(); + ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil, no)"); + ts.WriteLine("if test \"x$GACUTIL\" = \"xno\" ; then"); + ts.WriteLine(" AC_MSG_ERROR([No gacutil tool found])"); + ts.WriteLine("fi"); + ts.WriteLine(); + // foreach(ProjectNode project in solution.ProjectsTableOrder) + // { + // if (project.Type == ProjectType.Library) + // { + // } + // } + ts.WriteLine("GACUTIL_FLAGS='/package $(PACKAGE_NAME) /gacdir $(DESTDIR)$(prefix)'"); + ts.WriteLine("AC_SUBST(GACUTIL_FLAGS)"); + ts.WriteLine(); + ts.WriteLine("winbuild=no"); + ts.WriteLine("case \"$host\" in"); + ts.WriteLine(" *-*-mingw*|*-*-cygwin*)"); + ts.WriteLine(" winbuild=yes"); + ts.WriteLine(" ;;"); + ts.WriteLine("esac"); + ts.WriteLine("AM_CONDITIONAL(WINBUILD, test x$winbuild = xyes)"); + ts.WriteLine(); + // ts.WriteLine("dnl Check for SDL"); + // ts.WriteLine(); + // ts.WriteLine("AC_PATH_PROG([SDL_CONFIG], [sdl-config])"); + // ts.WriteLine("have_sdl=no"); + // ts.WriteLine("if test -n \"${SDL_CONFIG}\"; then"); + // ts.WriteLine(" have_sdl=yes"); + // ts.WriteLine(" SDL_CFLAGS=`$SDL_CONFIG --cflags`"); + // ts.WriteLine(" SDL_LIBS=`$SDL_CONFIG --libs`"); + // ts.WriteLine(" #"); + // ts.WriteLine(" # sdl-config sometimes emits an rpath flag pointing at its library"); + // ts.WriteLine(" # installation directory. We don't want this, as it prevents users from"); + // ts.WriteLine(" # linking sdl-viewer against, for example, a locally compiled libGL when a"); + // ts.WriteLine(" # version of the library also exists in SDL's library installation"); + // ts.WriteLine(" # directory, typically /usr/lib."); + // ts.WriteLine(" #"); + // ts.WriteLine(" SDL_LIBS=`echo $SDL_LIBS | sed 's/-Wl,-rpath,[[^ ]]* //'`"); + // ts.WriteLine("fi"); + // ts.WriteLine("AC_SUBST([SDL_CFLAGS])"); + // ts.WriteLine("AC_SUBST([SDL_LIBS])"); + ts.WriteLine(); + ts.WriteLine("AC_OUTPUT(["); + ts.WriteLine("Makefile"); + // TODO: this does not work quite right. + //ts.WriteLine("Properties/AssemblyInfo.cs"); + foreach(ProjectNode project in solution.ProjectsTableOrder) + { + if (project.Type == ProjectType.Library) + { + ts.WriteLine(project.Name + ".pc"); + } + // string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + // ts.WriteLine(Helper.NormalizePath(Helper.MakeFilePath(path, "Include"),'/')); + } + ts.WriteLine("])"); + ts.WriteLine(); + ts.WriteLine("#po/Makefile.in"); + ts.WriteLine(); + ts.WriteLine("echo \"---\""); + ts.WriteLine("echo \"Configuration summary\""); + ts.WriteLine("echo \"\""); + ts.WriteLine("echo \" * Installation prefix: $prefix\""); + ts.WriteLine("echo \" * compiler: $CSC\""); + ts.WriteLine("echo \" * Documentation: $enable_monodoc ($MONODOC)\""); + ts.WriteLine("echo \" * Package Name: $PACKAGE_NAME\""); + ts.WriteLine("echo \" * Version: $PACKAGE_VERSION\""); + ts.WriteLine("echo \" * Public Key: $PUBKEY\""); + ts.WriteLine("echo \"\""); + ts.WriteLine("echo \"---\""); + ts.WriteLine(); + } + + ts.NewLine = "\n"; + foreach (ProjectNode project in solution.ProjectsTableOrder) + { + if (project.GenerateAssemblyInfoFile) + { + GenerateAssemblyInfoFile(solution, combFile); + } + } + } + + private static void GenerateAssemblyInfoFile(SolutionNode solution, string combFile) + { + System.IO.Directory.CreateDirectory(Helper.MakePathRelativeTo(solution.FullPath, "Properties")); + combFile = Helper.MakeFilePath(solution.FullPath + "/Properties/", "AssemblyInfo.cs", "in"); + StreamWriter ai = new StreamWriter(combFile); + + using (ai) + { + ai.WriteLine("#region License"); + ai.WriteLine("/*"); + ai.WriteLine("MIT License"); + ai.WriteLine("Copyright (c)2003-2006 Tao Framework Team"); + ai.WriteLine("http://www.taoframework.com"); + ai.WriteLine("All rights reserved."); + ai.WriteLine(""); + ai.WriteLine("Permission is hereby granted, free of charge, to any person obtaining a copy"); + ai.WriteLine("of this software and associated documentation files (the \"Software\"), to deal"); + ai.WriteLine("in the Software without restriction, including without limitation the rights"); + ai.WriteLine("to use, copy, modify, merge, publish, distribute, sublicense, and/or sell"); + ai.WriteLine("copies of the Software, and to permit persons to whom the Software is"); + ai.WriteLine("furnished to do so, subject to the following conditions:"); + ai.WriteLine(""); + ai.WriteLine("The above copyright notice and this permission notice shall be included in all"); + ai.WriteLine("copies or substantial portions of the Software."); + ai.WriteLine(""); + ai.WriteLine("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR"); + ai.WriteLine("IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,"); + ai.WriteLine("FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE"); + ai.WriteLine("AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER"); + ai.WriteLine("LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,"); + ai.WriteLine("OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE"); + ai.WriteLine("SOFTWARE."); + ai.WriteLine("*/"); + ai.WriteLine("#endregion License"); + ai.WriteLine(""); + ai.WriteLine("using System;"); + ai.WriteLine("using System.Reflection;"); + ai.WriteLine("using System.Runtime.InteropServices;"); + ai.WriteLine("using System.Security;"); + ai.WriteLine("using System.Security.Permissions;"); + ai.WriteLine(""); + ai.WriteLine("[assembly: AllowPartiallyTrustedCallers]"); + ai.WriteLine("[assembly: AssemblyCompany(\"Tao Framework -- http://www.taoframework.com\")]"); + ai.WriteLine("[assembly: AssemblyConfiguration(\"Retail\")]"); + ai.WriteLine("[assembly: AssemblyCopyright(\"Copyright (c)2003-2006 Tao Framework Team. All rights reserved.\")]"); + ai.WriteLine("[assembly: AssemblyCulture(\"\")]"); + ai.WriteLine("[assembly: AssemblyDefaultAlias(\"@PACKAGE_NAME@\")]"); + ai.WriteLine("[assembly: AssemblyDelaySign(false)]"); + ai.WriteLine("[assembly: AssemblyDescription(\"@DESCRIPTION@\")]"); + ai.WriteLine("[assembly: AssemblyFileVersion(\"@ASSEMBLY_VERSION@\")]"); + ai.WriteLine("[assembly: AssemblyInformationalVersion(\"@ASSEMBLY_VERSION@\")]"); + ai.WriteLine("[assembly: AssemblyKeyName(\"\")]"); + ai.WriteLine("[assembly: AssemblyProduct(\"@PACKAGE_NAME@.dll\")]"); + ai.WriteLine("[assembly: AssemblyTitle(\"@DESCRIPTION@\")]"); + ai.WriteLine("[assembly: AssemblyTrademark(\"Tao Framework -- http://www.taoframework.com\")]"); + ai.WriteLine("[assembly: AssemblyVersion(\"@ASSEMBLY_VERSION@\")]"); + ai.WriteLine("[assembly: CLSCompliant(true)]"); + ai.WriteLine("[assembly: ComVisible(false)]"); + ai.WriteLine("[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.Execution)]"); + ai.WriteLine("[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.SkipVerification)]"); + ai.WriteLine("[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.UnmanagedCode)]"); + + } + //return combFile; + } + + private void CleanProject(ProjectNode project) + { + m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); + string projectFile = Helper.MakeFilePath(project.FullPath, "Include", "am"); + Helper.DeleteIfExists(projectFile); + } + + private void CleanSolution(SolutionNode solution) + { + m_Kernel.Log.Write("Cleaning Autotools make files for", solution.Name); + + string slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am"); + Helper.DeleteIfExists(slnFile); + + slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "in"); + Helper.DeleteIfExists(slnFile); + + slnFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac"); + Helper.DeleteIfExists(slnFile); + + slnFile = Helper.MakeFilePath(solution.FullPath, "configure"); + Helper.DeleteIfExists(slnFile); + + slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile"); + Helper.DeleteIfExists(slnFile); + + foreach(ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public void Write(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode solution in kern.Solutions) + { + WriteCombine(solution); + } + m_Kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode sol in kern.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return "autotools"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/DebugTarget.cs b/Prebuild/src/Core/Targets/DebugTarget.cs new file mode 100644 index 0000000000..6baa623cd3 --- /dev/null +++ b/Prebuild/src/Core/Targets/DebugTarget.cs @@ -0,0 +1,102 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-09-20 09:42:51 +0200 (on, 20 sep 2006) $ + * $Revision: 164 $ + */ +#endregion + +using System; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; + +#if (DEBUG && _DEBUG_TARGET) +namespace Prebuild.Core.Targets +{ + [Target("debug")] + public class DebugTarget : ITarget + { +#region Fields + + private Kernel m_Kernel = null; + +#endregion + +#region ITarget Members + + public void Write() + { + foreach(SolutionNode s in m_Kernel.Solutions) + { + Console.WriteLine("Solution [ {0}, {1} ]", s.Name, s.Path); + foreach(string file in s.Files) +{ + Console.WriteLine("\tFile [ {0} ]", file); +} + + foreach(ProjectNode proj in s.Projects) + { + Console.WriteLine("\tProject [ {0}, {1}. {2} ]", proj.Name, proj.Path, proj.Language); + foreach(string file in proj.Files) + Console.WriteLine("\t\tFile [ {0} ]", file); + } + } + } + + public void Clean() + { + Console.WriteLine("Not implemented"); + } + + public string Name + { + get + { + return "debug"; + } + } + + public Kernel Kernel + { + get + { + return m_Kernel; + } + set + { + m_Kernel = value; + } + } + +#endregion + } +} +#endif diff --git a/Prebuild/src/Core/Targets/MonoDevelopTarget.cs b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs new file mode 100644 index 0000000000..8620e4bd5b --- /dev/null +++ b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs @@ -0,0 +1,458 @@ +#region BSD License +/* +Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2007-02-13 22:07:07 +0100 (ti, 13 feb 2007) $ + * $Revision: 206 $ + */ +#endregion + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.IO; +using System.Reflection; +using System.Text.RegularExpressions; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Targets +{ + /// + /// + /// + [Target("monodev")] + public class MonoDevelopTarget : ITarget + { + #region Fields + + private Kernel m_Kernel; + + #endregion + + #region Private Methods + + private static string PrependPath(string path) + { + string tmpPath = Helper.NormalizePath(path, '/'); + Regex regex = new Regex(@"(\w):/(\w+)"); + Match match = regex.Match(tmpPath); + if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/') + { + tmpPath = Helper.NormalizePath(tmpPath); + } + else + { + tmpPath = Helper.NormalizePath("./" + tmpPath); + } + + return tmpPath; + } + + private static string BuildReference(SolutionNode solution, ReferenceNode refr) + { + string ret = ""; + } + else + { + ProjectNode project = (ProjectNode)refr.Parent; + string fileRef = FindFileReference(refr.Name, project); + + if(refr.Path != null || fileRef != null) + { + ret += "Assembly\" refto=\""; + + string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef; + + ret += finalPath; + ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; + return ret; + } + + ret += "Gac\""; + ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\""; + ret += " refto=\""; + try + { + //Assembly assem = Assembly.Load(refr.Name); + //ret += assem.FullName; + ret += refr.Name; + } + catch (System.NullReferenceException e) + { + e.ToString(); + ret += refr.Name; + } + ret += "\" />"; + } + + return ret; + } + + private static string FindFileReference(string refName, ProjectNode project) + { + foreach(ReferencePathNode refPath in project.ReferencePaths) + { + string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); + + if(File.Exists(fullPath)) + { + return fullPath; + } + } + + return null; + } + + /// + /// Gets the XML doc file. + /// + /// The project. + /// The conf. + /// + public static string GenerateXmlDocFile(ProjectNode project, ConfigurationNode conf) + { + if( conf == null ) + { + throw new ArgumentNullException("conf"); + } + if( project == null ) + { + throw new ArgumentNullException("project"); + } + string docFile = (string)conf.Options["XmlDocFile"]; + if(docFile != null && docFile.Length == 0)//default to assembly name if not specified + { + return "False"; + } + return "True"; + } + + private void WriteProject(SolutionNode solution, ProjectNode project) + { + string csComp = "Mcs"; + string netRuntime = "Mono"; + if(project.Runtime == ClrRuntime.Microsoft) + { + csComp = "Csc"; + netRuntime = "MsNet"; + } + + string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp"); + StreamWriter ss = new StreamWriter(projFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); + + using(ss) + { + ss.WriteLine( + "", + project.Name, + project.RootNamespace + ); + + int count = 0; + + ss.WriteLine(" ", solution.ActiveConfig); + + foreach(ConfigurationNode conf in project.Configurations) + { + ss.WriteLine(" ", conf.Name); + ss.Write(" "); + + ss.Write(" "); + + ss.Write(" "); + + ss.Write(" "); + ss.WriteLine(" "); + + count++; + } + ss.WriteLine(" "); + + ss.Write(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + + ss.WriteLine(" "); + foreach(string file in project.Files) + { + string buildAction = "Compile"; + switch(project.Files.GetBuildAction(file)) + { + case BuildAction.None: + buildAction = "Nothing"; + break; + + case BuildAction.Content: + buildAction = "Exclude"; + break; + + case BuildAction.EmbeddedResource: + buildAction = "EmbedAsResource"; + break; + + default: + buildAction = "Compile"; + break; + } + + // Sort of a hack, we try and resolve the path and make it relative, if we can. + string filePath = PrependPath(file); + ss.WriteLine(" ", filePath, buildAction); + } + ss.WriteLine(" "); + + ss.WriteLine(" "); + foreach(ReferenceNode refr in project.References) + { + ss.WriteLine(" {0}", BuildReference(solution, refr)); + } + ss.WriteLine(" "); + + + ss.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void WriteCombine(SolutionNode solution) + { + m_Kernel.Log.Write("Creating MonoDevelop combine and project files"); + foreach(ProjectNode project in solution.Projects) + { + if(m_Kernel.AllowProject(project.FilterGroups)) + { + m_Kernel.Log.Write("...Creating project: {0}", project.Name); + WriteProject(solution, project); + } + } + + m_Kernel.Log.Write(""); + string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds"); + StreamWriter ss = new StreamWriter(combFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); + + int count = 0; + + using(ss) + { + ss.WriteLine("", solution.Name); + + count = 0; + foreach(ConfigurationNode conf in solution.Configurations) + { + if(count == 0) + { + ss.WriteLine(" ", conf.Name); + } + + ss.WriteLine(" ", conf.Name); + foreach(ProjectNode project in solution.Projects) + { + ss.WriteLine(" ", project.Name, conf.Name); + } + ss.WriteLine(" "); + + count++; + } + ss.WriteLine(" "); + + count = 0; + + foreach(ProjectNode project in solution.Projects) + { + if(count == 0) + ss.WriteLine(" ", project.Name); + + ss.WriteLine(" ", project.Name); + count++; + } + ss.WriteLine(" "); + + ss.WriteLine(" "); + foreach(ProjectNode project in solution.Projects) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.WriteLine(" ", + Helper.MakeFilePath(path, project.Name, "mdp")); + } + ss.WriteLine(" "); + + ss.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void CleanProject(ProjectNode project) + { + m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp"); + Helper.DeleteIfExists(projectFile); + } + + private void CleanSolution(SolutionNode solution) + { + m_Kernel.Log.Write("Cleaning MonoDevelop combine and project files for", solution.Name); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds"); + Helper.DeleteIfExists(slnFile); + + foreach(ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public void Write(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode solution in kern.Solutions) + { + WriteCombine(solution); + } + m_Kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode sol in kern.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return "sharpdev"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/NAntTarget.cs b/Prebuild/src/Core/Targets/NAntTarget.cs new file mode 100644 index 0000000000..bd366dccfb --- /dev/null +++ b/Prebuild/src/Core/Targets/NAntTarget.cs @@ -0,0 +1,621 @@ +#region BSD License +/* +Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2007-02-13 21:58:03 +0100 (ti, 13 feb 2007) $ + * $Revision: 205 $ + */ +#endregion + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.IO; +using System.Reflection; +using System.Text.RegularExpressions; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Targets +{ + /// + /// + /// + [Target("nant")] + public class NAntTarget : ITarget + { + #region Fields + + private Kernel m_Kernel; + + #endregion + + #region Private Methods + + private static string PrependPath(string path) + { + string tmpPath = Helper.NormalizePath(path, '/'); + Regex regex = new Regex(@"(\w):/(\w+)"); + Match match = regex.Match(tmpPath); + //if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/') + //{ + tmpPath = Helper.NormalizePath(tmpPath); + //} +// else +// { +// tmpPath = Helper.NormalizePath("./" + tmpPath); +// } + + return tmpPath; + } + + private static string BuildReference(SolutionNode solution, ReferenceNode refr) + { + string ret = ""; + if(solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; + string fileRef = FindFileReference(refr.Name, project); + string finalPath = Helper.NormalizePath(Helper.MakeFilePath(project.FullPath + "/${build.dir}/", refr.Name, "dll"), '/'); + ret += finalPath; + return ret; + } + else + { + ProjectNode project = (ProjectNode)refr.Parent; + string fileRef = FindFileReference(refr.Name, project); + + if(refr.Path != null || fileRef != null) + { + string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path + "/" + refr.Name + ".dll", '/') : fileRef; + ret += finalPath; + return ret; + } + + try + { + //Assembly assem = Assembly.Load(refr.Name); + //if (assem != null) + //{ + //ret += (refr.Name + ".dll"); + //} + //else + //{ + ret += (refr.Name + ".dll"); + //} + } + catch (System.NullReferenceException e) + { + e.ToString(); + ret += refr.Name + ".dll"; + } + } + return ret; + } + + private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr) + { + string ret = ""; + if(solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; + string fileRef = FindFileReference(refr.Name, project); + string finalPath = Helper.NormalizePath(Helper.MakeReferencePath(project.FullPath + "/${build.dir}/"), '/'); + ret += finalPath; + return ret; + } + else + { + ProjectNode project = (ProjectNode)refr.Parent; + string fileRef = FindFileReference(refr.Name, project); + + if(refr.Path != null || fileRef != null) + { + string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef; + ret += finalPath; + return ret; + } + + try + { + Assembly assem = Assembly.Load(refr.Name); + if (assem != null) + { + ret += ""; + } + else + { + ret += ""; + } + } + catch (System.NullReferenceException e) + { + e.ToString(); + ret += ""; + } + } + return ret; + } + + private static string FindFileReference(string refName, ProjectNode project) + { + foreach(ReferencePathNode refPath in project.ReferencePaths) + { + string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); + + if(File.Exists(fullPath)) + { + return fullPath; + } + } + + return null; + } + + /// + /// Gets the XML doc file. + /// + /// The project. + /// The conf. + /// + public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) + { + if( conf == null ) + { + throw new ArgumentNullException("conf"); + } + if( project == null ) + { + throw new ArgumentNullException("project"); + } + string docFile = (string)conf.Options["XmlDocFile"]; + // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified + // { + // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; + // } + return docFile; + } + + private void WriteProject(SolutionNode solution, ProjectNode project) + { + string projFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"); + StreamWriter ss = new StreamWriter(projFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); + bool hasDoc = false; + + using(ss) + { + ss.WriteLine(""); + ss.WriteLine("", project.Name); + ss.WriteLine(" ", "build"); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach(ReferenceNode refr in project.References) + { + if (refr.LocalCopy) + { + ss.WriteLine(" ", '/')); + } + } + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.Write(" "); + ss.WriteLine(" ", project.RootNamespace); + foreach (string file in project.Files) + { + switch (project.Files.GetBuildAction(file)) + { + case BuildAction.EmbeddedResource: + ss.WriteLine(" {0}", ""); + break; + default: + if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) + { + ss.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); + } + break; + } + } + //if (project.Files.GetSubType(file).ToString() != "Code") + //{ + // ps.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); + + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach(string file in project.Files) + { + switch(project.Files.GetBuildAction(file)) + { + case BuildAction.Compile: + ss.WriteLine(" "); + break; + default: + break; + } + } + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach(ReferenceNode refr in project.References) + { + ss.WriteLine(" ", '/')); + } + ss.WriteLine(" "); + + ss.WriteLine(" "); + + foreach (ConfigurationNode conf in project.Configurations) + { + if (!String.IsNullOrEmpty(conf.Options.OutputPath)) + { + string targetDir = Helper.NormalizePath(conf.Options.OutputPath, '/'); + + ss.WriteLine(" "); + + ss.WriteLine(" "); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + break; + } + } + + ss.WriteLine(" "); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + + ss.WriteLine(" "); + if (hasDoc) + { + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.Write(" "); + } + else + { + ss.WriteLine(".exe\" />"); + } + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + // foreach(ReferenceNode refr in project.References) + // { + // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/'); + // if (path != "") + // { + // ss.WriteLine(" ", path); + // } + // } + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + } + ss.WriteLine(" "); + ss.WriteLine(""); + } + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void WriteCombine(SolutionNode solution) + { + m_Kernel.Log.Write("Creating NAnt build files"); + foreach(ProjectNode project in solution.Projects) + { + if(m_Kernel.AllowProject(project.FilterGroups)) + { + m_Kernel.Log.Write("...Creating project: {0}", project.Name); + WriteProject(solution, project); + } + } + + m_Kernel.Log.Write(""); + string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); + StreamWriter ss = new StreamWriter(combFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); + + using(ss) + { + ss.WriteLine(""); + ss.WriteLine("", solution.Name); + ss.WriteLine(" "); + ss.WriteLine(); + + //ss.WriteLine(" "); + //ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + + foreach(ConfigurationNode conf in solution.Configurations) + { + // Set the project.config to a non-debug configuration + if( conf.Options["DebugInformation"].ToString().ToLower() != "true" ) + { + ss.WriteLine(" ", conf.Name); + } + ss.WriteLine(); + ss.WriteLine(" ", conf.Name); + ss.WriteLine(" ", conf.Name); + ss.WriteLine(" ", conf.Options["DebugInformation"].ToString().ToLower()); + ss.WriteLine(" "); + ss.WriteLine(); + } + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + //ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach(ProjectNode project in solution.Projects) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.Write(" "); + } + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + + foreach(ProjectNode project in solution.ProjectsTableOrder) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.Write(" "); + } + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(); + ss.WriteLine(" "); + ss.WriteLine(); + //ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (ProjectNode project in solution.Projects) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.Write(" "); + } + ss.WriteLine(" "); + ss.WriteLine(); + ss.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void CleanProject(ProjectNode project) + { + m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"); + Helper.DeleteIfExists(projectFile); + } + + private void CleanSolution(SolutionNode solution) + { + m_Kernel.Log.Write("Cleaning NAnt build files for", solution.Name); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); + Helper.DeleteIfExists(slnFile); + + foreach(ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public void Write(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode solution in kern.Solutions) + { + WriteCombine(solution); + } + m_Kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode sol in kern.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return "nant"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/SharpDevelop2Target.cs b/Prebuild/src/Core/Targets/SharpDevelop2Target.cs new file mode 100644 index 0000000000..bc84b965fc --- /dev/null +++ b/Prebuild/src/Core/Targets/SharpDevelop2Target.cs @@ -0,0 +1,90 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-27 16:49:58 -0800 (Fri, 27 Jan 2006) $ + * $Revision: 71 $ + */ +#endregion + +using System; + +using Prebuild.Core.Attributes; + +namespace Prebuild.Core.Targets +{ + /// + /// + /// + [Target("sharpdev2")] + public class SharpDevelop2Target : VS2005Target + { + #region Private Methods + private void SetSharpDevelop2() + { + this.VersionName = "SharpDevelop2"; + } + #endregion + + #region Public Methods + + /// + /// Writes the specified kern. + /// + /// The kern. + public override void Write(Kernel kern) + { + SetSharpDevelop2(); + base.Write(kern); + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public override void Clean(Kernel kern) + { + SetSharpDevelop2(); + base.Clean(kern); + } + + /// + /// Gets the name. + /// + /// The name. + public override string Name + { + get + { + return "sharpdev2"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/SharpDevelopTarget.cs b/Prebuild/src/Core/Targets/SharpDevelopTarget.cs new file mode 100644 index 0000000000..c72573075c --- /dev/null +++ b/Prebuild/src/Core/Targets/SharpDevelopTarget.cs @@ -0,0 +1,437 @@ +#region BSD License +/* +Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2007-02-13 21:58:03 +0100 (ti, 13 feb 2007) $ + * $Revision: 205 $ + */ +#endregion + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.IO; +using System.Text.RegularExpressions; +using System.Reflection; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Targets +{ + /// + /// + /// + [Target("sharpdev")] + public class SharpDevelopTarget : ITarget + { + #region Fields + + private Kernel m_Kernel; + + #endregion + + #region Private Methods + + private static string PrependPath(string path) + { + string tmpPath = Helper.NormalizePath(path, '/'); + Regex regex = new Regex(@"(\w):/(\w+)"); + Match match = regex.Match(tmpPath); + if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/') + { + tmpPath = Helper.NormalizePath(tmpPath); + } + else + { + tmpPath = Helper.NormalizePath("./" + tmpPath); + } + + return tmpPath; + } + + private static string BuildReference(SolutionNode solution, ReferenceNode refr) + { + string ret = ""; + } + else + { + ProjectNode project = (ProjectNode)refr.Parent; + string fileRef = FindFileReference(refr.Name, project); + + if(refr.Path != null || fileRef != null) + { + ret += "Assembly\" refto=\""; + + string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef; + + ret += finalPath; + ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; + return ret; + } + + ret += "Gac\" refto=\""; + try + { + //Assembly assem = Assembly.Load(refr.Name); + ret += refr.Name;// assem.FullName; + } + catch (System.NullReferenceException e) + { + e.ToString(); + ret += refr.Name; + } + ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; + } + + return ret; + } + + private static string FindFileReference(string refName, ProjectNode project) + { + foreach(ReferencePathNode refPath in project.ReferencePaths) + { + string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); + + if(File.Exists(fullPath)) + { + return fullPath; + } + } + + return null; + } + + /// + /// Gets the XML doc file. + /// + /// The project. + /// The conf. + /// + public static string GenerateXmlDocFile(ProjectNode project, ConfigurationNode conf) + { + if( conf == null ) + { + throw new ArgumentNullException("conf"); + } + if( project == null ) + { + throw new ArgumentNullException("project"); + } + string docFile = (string)conf.Options["XmlDocFile"]; + if(docFile != null && docFile.Length == 0)//default to assembly name if not specified + { + return "False"; + } + return "True"; + } + + private void WriteProject(SolutionNode solution, ProjectNode project) + { + string csComp = "Csc"; + string netRuntime = "MsNet"; + if(project.Runtime == ClrRuntime.Mono) + { + csComp = "Mcs"; + netRuntime = "Mono"; + } + + string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "prjx"); + StreamWriter ss = new StreamWriter(projFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); + + using(ss) + { + ss.WriteLine( + "", + project.Name, + project.RootNamespace + ); + + ss.WriteLine(" "); + foreach(string file in project.Files) + { + string buildAction = "Compile"; + switch(project.Files.GetBuildAction(file)) + { + case BuildAction.None: + buildAction = "Nothing"; + break; + + case BuildAction.Content: + buildAction = "Exclude"; + break; + + case BuildAction.EmbeddedResource: + buildAction = "EmbedAsResource"; + break; + + default: + buildAction = "Compile"; + break; + } + + // Sort of a hack, we try and resolve the path and make it relative, if we can. + string filePath = PrependPath(file); + ss.WriteLine(" ", filePath, buildAction); + } + ss.WriteLine(" "); + + ss.WriteLine(" "); + foreach(ReferenceNode refr in project.References) + { + ss.WriteLine(" {0}", BuildReference(solution, refr)); + } + ss.WriteLine(" "); + + ss.Write(" "); + + int count = 0; + + ss.WriteLine(" ", solution.ActiveConfig); + + foreach(ConfigurationNode conf in project.Configurations) + { + ss.Write(" "); + ss.Write(" "); + + ss.Write(" "); + + ss.Write(" "); + ss.WriteLine(" "); + + count++; + } + ss.WriteLine(" "); + ss.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void WriteCombine(SolutionNode solution) + { + m_Kernel.Log.Write("Creating SharpDevelop combine and project files"); + foreach(ProjectNode project in solution.Projects) + { + if(m_Kernel.AllowProject(project.FilterGroups)) + { + m_Kernel.Log.Write("...Creating project: {0}", project.Name); + WriteProject(solution, project); + } + } + + m_Kernel.Log.Write(""); + string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx"); + StreamWriter ss = new StreamWriter(combFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); + + using(ss) + { + ss.WriteLine("", solution.Name); + + int count = 0; + foreach(ProjectNode project in solution.Projects) + { + if(count == 0) + ss.WriteLine(" ", project.Name); + + ss.WriteLine(" ", project.Name); + count++; + } + ss.WriteLine(" "); + + ss.WriteLine(" "); + foreach(ProjectNode project in solution.Projects) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.WriteLine(" ", + Helper.MakeFilePath(path, project.Name, "prjx")); + } + ss.WriteLine(" "); + + count = 0; + foreach(ConfigurationNode conf in solution.Configurations) + { + if(count == 0) + { + ss.WriteLine(" ", conf.Name); + } + + ss.WriteLine(" ", conf.Name); + foreach(ProjectNode project in solution.Projects) + { + ss.WriteLine(" ", project.Name, conf.Name); + } + ss.WriteLine(" "); + + count++; + } + ss.WriteLine(" "); + ss.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void CleanProject(ProjectNode project) + { + m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "prjx"); + Helper.DeleteIfExists(projectFile); + } + + private void CleanSolution(SolutionNode solution) + { + m_Kernel.Log.Write("Cleaning SharpDevelop combine and project files for", solution.Name); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx"); + Helper.DeleteIfExists(slnFile); + + foreach(ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public void Write(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode solution in kern.Solutions) + { + WriteCombine(solution); + } + m_Kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode sol in kern.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return "sharpdev"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/VS2002Target.cs b/Prebuild/src/Core/Targets/VS2002Target.cs new file mode 100644 index 0000000000..66216dc58a --- /dev/null +++ b/Prebuild/src/Core/Targets/VS2002Target.cs @@ -0,0 +1,96 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Revision: 71 $ + */ +#endregion + +using System; + +using Prebuild.Core.Attributes; + +namespace Prebuild.Core.Targets +{ + /// + /// + /// + [Target("vs2002")] + public class VS2002Target : VS2003Target + { + #region Private Methods + + private void SetVS2002() + { + this.SolutionVersion = "7.00"; + this.ProductVersion = "7.0.9254"; + this.SchemaVersion = "1.0"; + this.VersionName = "2002"; + this.Version = VSVersion.VS70; + } + + #endregion + + #region Public Methods + + /// + /// Writes the specified kern. + /// + /// The kern. + public override void Write(Kernel kern) + { + SetVS2002(); + base.Write(kern); + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public override void Clean(Kernel kern) + { + SetVS2002(); + base.Clean(kern); + } + + /// + /// Gets the name. + /// + /// The name. + public override string Name + { + get + { + return "vs2002"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/VS2003Target.cs b/Prebuild/src/Core/Targets/VS2003Target.cs new file mode 100644 index 0000000000..b3236a8b12 --- /dev/null +++ b/Prebuild/src/Core/Targets/VS2003Target.cs @@ -0,0 +1,633 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-09-29 21:11:40 +0200 (fr, 29 sep 2006) $ + * $Revision: 177 $ + */ +#endregion + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.IO; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Targets +{ + /// + /// + /// + public enum VSVersion + { + /// + /// + /// + VS70, + /// + /// + /// + VS71, + /// + /// + /// + VS80 + } + + /// + /// + /// + [Target("vs2003")] + public class VS2003Target : ITarget + { + + #region Fields + + string solutionVersion = "8.00"; + string productVersion = "7.10.3077"; + string schemaVersion = "2.0"; + string versionName = "2003"; + VSVersion version = VSVersion.VS71; + + Hashtable m_Tools; + Kernel m_Kernel; + + /// + /// Gets or sets the solution version. + /// + /// The solution version. + protected string SolutionVersion + { + get + { + return this.solutionVersion; + } + set + { + this.solutionVersion = value; + } + } + /// + /// Gets or sets the product version. + /// + /// The product version. + protected string ProductVersion + { + get + { + return this.productVersion; + } + set + { + this.productVersion = value; + } + } + /// + /// Gets or sets the schema version. + /// + /// The schema version. + protected string SchemaVersion + { + get + { + return this.schemaVersion; + } + set + { + this.schemaVersion = value; + } + } + /// + /// Gets or sets the name of the version. + /// + /// The name of the version. + protected string VersionName + { + get + { + return this.versionName; + } + set + { + this.versionName = value; + } + } + /// + /// Gets or sets the version. + /// + /// The version. + protected VSVersion Version + { + get + { + return this.version; + } + set + { + this.version = value; + } + } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public VS2003Target() + { + m_Tools = new Hashtable(); + + m_Tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP"); + m_Tools["VB.NET"] = new ToolInfo("VB.NET", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic"); + } + + #endregion + + #region Private Methods + + private string MakeRefPath(ProjectNode project) + { + string ret = ""; + foreach(ReferencePathNode node in project.ReferencePaths) + { + try + { + string fullPath = Helper.ResolvePath(node.Path); + if(ret.Length < 1) + { + ret = fullPath; + } + else + { + ret += ";" + fullPath; + } + } + catch(ArgumentException) + { + m_Kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path); + } + } + + return ret; + } + + private void WriteProject(SolutionNode solution, ProjectNode project) + { + if(!m_Tools.ContainsKey(project.Language)) + { + throw new UnknownLanguageException("Unknown .NET language: " + project.Language); + } + + ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language]; + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); + StreamWriter ps = new StreamWriter(projectFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); + + IEnumerator enumerator; + //ConfigurationNode scripts; + + using(ps) + { + ps.WriteLine(""); + ps.WriteLine(" <{0}", toolInfo.XmlTag); + ps.WriteLine("\t\t\t\tProjectType = \"Local\""); + ps.WriteLine("\t\t\t\tProductVersion = \"{0}\"", this.ProductVersion); + ps.WriteLine("\t\t\t\tSchemaVersion = \"{0}\"", this.SchemaVersion); + ps.WriteLine("\t\t\t\tProjectGuid = \"{{{0}}}\"", project.Guid.ToString().ToUpper()); + ps.WriteLine("\t\t>"); + + ps.WriteLine("\t\t\t\t"); + ps.WriteLine(" "); + + foreach(ConfigurationNode conf in project.Configurations) + { + ps.WriteLine("\t\t\t\t "); + } + + ps.WriteLine(" "); + + ps.WriteLine(" "); + foreach(ReferenceNode refr in project.References) + { + ps.WriteLine(" "); + } + ps.WriteLine(" "); + + ps.WriteLine(" "); + ps.WriteLine(" "); + + ps.WriteLine(" "); + + foreach(string file in project.Files) + { + string fileName = file.Replace(".\\", ""); + ps.WriteLine(" "); + + if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) + { + ps.WriteLine(" "); + + } + } + ps.WriteLine(" "); + + ps.WriteLine(" "); + ps.WriteLine(" ", toolInfo.XmlTag); + ps.WriteLine(""); + } + + ps = new StreamWriter(projectFile + ".user"); + using(ps) + { + ps.WriteLine(""); + ps.WriteLine(" <{0}>", toolInfo.XmlTag); + ps.WriteLine(" "); + + ps.WriteLine(" ", MakeRefPath(project)); + foreach(ConfigurationNode conf in project.Configurations) + { + ps.WriteLine(" "); + } + ps.WriteLine(" "); + + ps.WriteLine(" "); + ps.WriteLine(" ", toolInfo.XmlTag); + ps.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + /// + /// Gets the XML doc file. + /// + /// The project. + /// The conf. + /// + public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) + { + if( conf == null ) + { + throw new ArgumentNullException("conf"); + } + if( project == null ) + { + throw new ArgumentNullException("project"); + } + // if(!(bool)conf.Options["GenerateXmlDocFile"]) //default to none, if the generate option is false + // { + // return string.Empty; + // } + + //default to "AssemblyName.xml" + //string defaultValue = Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; + //return (string)conf.Options["XmlDocFile", defaultValue]; + + //default to no XmlDocFile file + return (string)conf.Options["XmlDocFile", ""]; + } + + private void WriteSolution(SolutionNode solution) + { + m_Kernel.Log.Write("Creating Visual Studio {0} solution and project files", this.VersionName); + + foreach(ProjectNode project in solution.Projects) + { + if(m_Kernel.AllowProject(project.FilterGroups)) + { + m_Kernel.Log.Write("...Creating project: {0}", project.Name); + WriteProject(solution, project); + } + } + + m_Kernel.Log.Write(""); + string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); + StreamWriter ss = new StreamWriter(solutionFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); + + using(ss) + { + ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion); + foreach(ProjectNode project in solution.Projects) + { + if(!m_Tools.ContainsKey(project.Language)) + { + throw new UnknownLanguageException("Unknown .NET language: " + project.Language); + } + + ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language]; + + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"", + toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name, + toolInfo.FileExtension), project.Guid.ToString().ToUpper()); + + ss.WriteLine("\tProjectSection(ProjectDependencies) = postProject"); + ss.WriteLine("\tEndProjectSection"); + + ss.WriteLine("EndProject"); + } + + ss.WriteLine("Global"); + + ss.WriteLine("\tGlobalSection(SolutionConfiguration) = preSolution"); + foreach(ConfigurationNode conf in solution.Configurations) + { + ss.WriteLine("\t\t{0} = {0}", conf.Name); + } + ss.WriteLine("\tEndGlobalSection"); + + ss.WriteLine("\tGlobalSection(ProjectDependencies) = postSolution"); + foreach(ProjectNode project in solution.Projects) + { + for(int i = 0; i < project.References.Count; i++) + { + ReferenceNode refr = (ReferenceNode)project.References[i]; + if(solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; + ss.WriteLine("\t\t({{{0}}}).{1} = ({{{2}}})", + project.Guid.ToString().ToUpper() + , i, + refProject.Guid.ToString().ToUpper() + ); + } + } + } + ss.WriteLine("\tEndGlobalSection"); + + ss.WriteLine("\tGlobalSection(ProjectConfiguration) = postSolution"); + foreach(ProjectNode project in solution.Projects) + { + foreach(ConfigurationNode conf in solution.Configurations) + { + ss.WriteLine("\t\t{{{0}}}.{1}.ActiveCfg = {1}|.NET", + project.Guid.ToString().ToUpper(), + conf.Name); + + ss.WriteLine("\t\t{{{0}}}.{1}.Build.0 = {1}|.NET", + project.Guid.ToString().ToUpper(), + conf.Name); + } + } + ss.WriteLine("\tEndGlobalSection"); + + if(solution.Files != null) + { + ss.WriteLine("\tGlobalSection(SolutionItems) = postSolution"); + foreach(string file in solution.Files) + { + ss.WriteLine("\t\t{0} = {0}", file); + } + ss.WriteLine("\tEndGlobalSection"); + } + + ss.WriteLine("\tGlobalSection(ExtensibilityGlobals) = postSolution"); + ss.WriteLine("\tEndGlobalSection"); + ss.WriteLine("\tGlobalSection(ExtensibilityAddIns) = postSolution"); + ss.WriteLine("\tEndGlobalSection"); + + ss.WriteLine("EndGlobal"); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void CleanProject(ProjectNode project) + { + m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); + + ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language]; + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); + string userFile = projectFile + ".user"; + + Helper.DeleteIfExists(projectFile); + Helper.DeleteIfExists(userFile); + } + + private void CleanSolution(SolutionNode solution) + { + m_Kernel.Log.Write("Cleaning Visual Studio {0} solution and project files", this.VersionName, solution.Name); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); + string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); + + Helper.DeleteIfExists(slnFile); + Helper.DeleteIfExists(suoFile); + + foreach(ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public virtual void Write(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode sol in m_Kernel.Solutions) + { + WriteSolution(sol); + } + m_Kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode sol in m_Kernel.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public virtual string Name + { + get + { + return "vs2003"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/VS2005Target.cs b/Prebuild/src/Core/Targets/VS2005Target.cs new file mode 100644 index 0000000000..3cfc8cd373 --- /dev/null +++ b/Prebuild/src/Core/Targets/VS2005Target.cs @@ -0,0 +1,869 @@ +#region BSD License +/* +Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: robloach $ + * $Date: 2007-02-27 19:52:34 +0100 (ti, 27 feb 2007) $ + * $Revision: 207 $ + */ +#endregion + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.IO; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Targets +{ + /// + /// + /// + public struct ToolInfo + { + string name; + string guid; + string fileExtension; + string xmlTag; + string importProject; + + /// + /// Gets or sets the name. + /// + /// The name. + public string Name + { + get + { + return name; + } + set + { + name = value; + } + } + + /// + /// Gets or sets the GUID. + /// + /// The GUID. + public string Guid + { + get + { + return guid; + } + set + { + guid = value; + } + } + + /// + /// Gets or sets the file extension. + /// + /// The file extension. + public string FileExtension + { + get + { + return fileExtension; + } + set + { + fileExtension = value; + } + } + /// + /// Gets or sets the XML tag. + /// + /// The XML tag. + public string XmlTag + { + get + { + return xmlTag; + } + set + { + xmlTag = value; + } + } + + /// + /// Gets or sets the import project property. + /// + /// The ImportProject tag. + public string ImportProject + { + get + { + return importProject; + } + set + { + importProject = value; + } + } + + /// + /// Initializes a new instance of the class. + /// + /// The name. + /// The GUID. + /// The file extension. + /// The XML. + /// The import project. + public ToolInfo(string name, string guid, string fileExtension, string xml, string importProject) + { + this.name = name; + this.guid = guid; + this.fileExtension = fileExtension; + this.xmlTag = xml; + this.importProject = importProject; + } + + /// + /// Initializes a new instance of the class. + /// + /// The name. + /// The GUID. + /// The file extension. + /// The XML. + public ToolInfo(string name, string guid, string fileExtension, string xml) + { + this.name = name; + this.guid = guid; + this.fileExtension = fileExtension; + this.xmlTag = xml; + this.importProject = "$(MSBuildBinPath)\\Microsoft." + xml + ".Targets"; + } + + /// + /// Equals operator + /// + /// ToolInfo to compare + /// true if toolInfos are equal + public override bool Equals(object obj) + { + if (obj == null) + { + throw new ArgumentNullException("obj"); + } + if (obj.GetType() != typeof(ToolInfo)) + return false; + + ToolInfo c = (ToolInfo)obj; + return ((this.name == c.name) && (this.guid == c.guid) && (this.fileExtension == c.fileExtension) && (this.importProject == c.importProject)); + } + + /// + /// Equals operator + /// + /// ToolInfo to compare + /// ToolInfo to compare + /// True if toolInfos are equal + public static bool operator ==(ToolInfo c1, ToolInfo c2) + { + return ((c1.name == c2.name) && (c1.guid == c2.guid) && (c1.fileExtension == c2.fileExtension) && (c1.importProject == c2.importProject) && (c1.xmlTag == c2.xmlTag)); + } + + /// + /// Not equals operator + /// + /// ToolInfo to compare + /// ToolInfo to compare + /// True if toolInfos are not equal + public static bool operator !=(ToolInfo c1, ToolInfo c2) + { + return !(c1 == c2); + } + + /// + /// Hash Code + /// + /// Hash code + public override int GetHashCode() + { + return name.GetHashCode() ^ guid.GetHashCode() ^ this.fileExtension.GetHashCode() ^ this.importProject.GetHashCode() ^ this.xmlTag.GetHashCode(); + + } + } + + /// + /// + /// + [Target("vs2005")] + public class VS2005Target : ITarget + { + #region Inner Classes + + #endregion + + #region Fields + + string solutionVersion = "9.00"; + string productVersion = "8.0.50727"; + string schemaVersion = "2.0"; + string versionName = "Visual C# 2005"; + VSVersion version = VSVersion.VS80; + + Hashtable tools; + Kernel kernel; + + /// + /// Gets or sets the solution version. + /// + /// The solution version. + protected string SolutionVersion + { + get + { + return this.solutionVersion; + } + set + { + this.solutionVersion = value; + } + } + /// + /// Gets or sets the product version. + /// + /// The product version. + protected string ProductVersion + { + get + { + return this.productVersion; + } + set + { + this.productVersion = value; + } + } + /// + /// Gets or sets the schema version. + /// + /// The schema version. + protected string SchemaVersion + { + get + { + return this.schemaVersion; + } + set + { + this.schemaVersion = value; + } + } + /// + /// Gets or sets the name of the version. + /// + /// The name of the version. + protected string VersionName + { + get + { + return this.versionName; + } + set + { + this.versionName = value; + } + } + /// + /// Gets or sets the version. + /// + /// The version. + protected VSVersion Version + { + get + { + return this.version; + } + set + { + this.version = value; + } + } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public VS2005Target() + { + this.tools = new Hashtable(); + + this.tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP", "$(MSBuildBinPath)\\Microsoft.CSHARP.Targets"); + this.tools["Boo"] = new ToolInfo("Boo", "{45CEA7DC-C2ED-48A6-ACE0-E16144C02365}", "booproj", "Boo", "$(BooBinPath)\\Boo.Microsoft.Build.targets"); + this.tools["VisualBasic"] = new ToolInfo("VisualBasic", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic", "$(MSBuildBinPath)\\Microsoft.VisualBasic.Targets"); + } + + #endregion + + #region Private Methods + + private string MakeRefPath(ProjectNode project) + { + string ret = ""; + foreach (ReferencePathNode node in project.ReferencePaths) + { + try + { + string fullPath = Helper.ResolvePath(node.Path); + if (ret.Length < 1) + { + ret = fullPath; + } + else + { + ret += ";" + fullPath; + } + } + catch (ArgumentException) + { + this.kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path); + } + } + + return ret; + } + + private void WriteProject(SolutionNode solution, ProjectNode project) + { + if (!tools.ContainsKey(project.Language)) + { + throw new UnknownLanguageException("Unknown .NET language: " + project.Language); + } + + ToolInfo toolInfo = (ToolInfo)tools[project.Language]; + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); + StreamWriter ps = new StreamWriter(projectFile); + + kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); + + #region Project File + using (ps) + { + ps.WriteLine(""); + //ps.WriteLine(" <{0}", toolInfo.XMLTag); + ps.WriteLine(" "); + ps.WriteLine(" Local"); + ps.WriteLine(" {0}", this.ProductVersion); + ps.WriteLine(" {0}", this.SchemaVersion); + ps.WriteLine(" {{{0}}}", project.Guid.ToString().ToUpper()); + + ps.WriteLine(" Debug"); + ps.WriteLine(" AnyCPU"); + //ps.WriteLine(" "); + + //ps.WriteLine(" {0}", project.AppIcon); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" {0}", project.AssemblyName); + foreach (ConfigurationNode conf in project.Configurations) + { + if (conf.Options.KeyFile != "") + { + ps.WriteLine(" {0}", conf.Options.KeyFile); + ps.WriteLine(" true"); + break; + } + } + ps.WriteLine(" JScript"); + ps.WriteLine(" Grid"); + ps.WriteLine(" IE50"); + ps.WriteLine(" false"); + + //if(m_Version == VSVersion.VS70) + // ps.WriteLine(" NoStandardLibraries = \"false\""); + + ps.WriteLine(" {0}", project.Type.ToString()); + ps.WriteLine(" {0}", project.DesignerFolder); + ps.WriteLine(" {0}", project.RootNamespace); + ps.WriteLine(" {0}", project.StartupObject); + //ps.WriteLine(" >"); + ps.WriteLine(" "); + ps.WriteLine(" "); + + ps.WriteLine(" "); + + foreach (ConfigurationNode conf in project.Configurations) + { + ps.Write(" ", conf.Name); + ps.WriteLine(" {0}", conf.Options["AllowUnsafe"]); + ps.WriteLine(" {0}", conf.Options["BaseAddress"]); + ps.WriteLine(" {0}", conf.Options["CheckUnderflowOverflow"]); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" {0}", conf.Options["CompilerDefines"]); + ps.WriteLine(" {0}", conf.Options["XmlDocFile"]); + ps.WriteLine(" {0}", conf.Options["DebugInformation"]); + ps.WriteLine(" {0}", conf.Options["FileAlignment"]); + // ps.WriteLine(" {0}", conf.Options["OptimizeCode"]); + ps.WriteLine(" {0}", + Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); + ps.WriteLine(" {0}", conf.Options["RegisterComInterop"]); + ps.WriteLine(" {0}", conf.Options["RemoveIntegerChecks"]); + ps.WriteLine(" {0}", conf.Options["WarningsAsErrors"]); + ps.WriteLine(" {0}", conf.Options["WarningLevel"]); + ps.WriteLine(" {0}", conf.Options["SuppressWarnings"]); + ps.WriteLine(" "); + } + + //ps.WriteLine(" "); + + // Assembly References + ps.WriteLine(" "); + foreach (ReferenceNode refr in project.References) + { + if (!solution.ProjectsTable.ContainsKey(refr.Name)) + { + ps.Write(" "); + + // TODO: Allow reference to *.exe files + ps.WriteLine(" {0}", Helper.MakePathRelativeTo(project.FullPath, refr.Path + "\\" + refr.Name + ".dll")); + ps.WriteLine(" {0}", refr.LocalCopy); + ps.WriteLine(" "); + } + } + ps.WriteLine(" "); + + //Project References + ps.WriteLine(" "); + foreach (ReferenceNode refr in project.References) + { + if (solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; + // TODO: Allow reference to visual basic projects + ps.WriteLine(" ", Helper.MakePathRelativeTo(project.FullPath, Helper.MakeFilePath(refProject.FullPath, refProject.Name, "csproj"))); + // + ps.WriteLine(" {0}", refProject.Name); + // RealmForge.Utility + ps.WriteLine(" {{{0}}}", refProject.Guid.ToString().ToUpper()); + // {6880D1D3-69EE-461B-B841-5319845B20D3} + ps.WriteLine(" {0}", toolInfo.Guid.ToString().ToUpper()); + // {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ps.WriteLine("\t\t\t{0}", refr.LocalCopy); + ps.WriteLine(" "); + // + } + else + { + } + } + ps.WriteLine(" "); + + // ps.WriteLine(" "); + ps.WriteLine(" "); + + // ps.WriteLine(" "); + ArrayList list = new ArrayList(); + foreach (string file in project.Files) + { + // if (file == "Properties\\Bind.Designer.cs") + // { + // Console.WriteLine("Wait a minute!"); + // Console.WriteLine(project.Files.GetSubType(file).ToString()); + // } + + if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings && project.Files.GetSubType(file) != SubType.Designer) + { + ps.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); + + int slash = file.LastIndexOf('\\'); + if (slash == -1) + { + ps.WriteLine(" {0}", file); + } + else + { + ps.WriteLine(" {0}", file.Substring(slash + 1, file.Length - slash - 1)); + } + ps.WriteLine(" Designer"); + ps.WriteLine(" "); + // + } + + if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) == SubType.Designer) + { + ps.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); + ps.WriteLine(" " + project.Files.GetSubType(file) + ""); + ps.WriteLine(" ResXFileCodeGenerator"); + ps.WriteLine(" Resources.Designer.cs"); + ps.WriteLine(" "); + ps.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"); + ps.WriteLine(" True"); + ps.WriteLine(" True"); + ps.WriteLine(" Resources.resx"); + ps.WriteLine(" "); + list.Add(file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"); + } + if (project.Files.GetSubType(file).ToString() == "Settings") + { + //Console.WriteLine("File: " + file); + //Console.WriteLine("Last index: " + file.LastIndexOf('.')); + //Console.WriteLine("Length: " + file.Length); + ps.Write(" <{0} ", project.Files.GetBuildAction(file)); + ps.WriteLine("Include=\"{0}\">", file); + int slash = file.LastIndexOf('\\'); + string fileName = file.Substring(slash + 1, file.Length - slash - 1); + if (project.Files.GetBuildAction(file) == BuildAction.None) + { + ps.WriteLine(" SettingsSingleFileGenerator"); + + //Console.WriteLine("FileName: " + fileName); + //Console.WriteLine("FileNameMain: " + fileName.Substring(0, fileName.LastIndexOf('.'))); + //Console.WriteLine("FileNameExt: " + fileName.Substring(fileName.LastIndexOf('.'), fileName.Length - fileName.LastIndexOf('.'))); + if (slash == -1) + { + ps.WriteLine(" {0}", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); + } + else + { + ps.WriteLine(" {0}", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); + } + } + else + { + ps.WriteLine(" Code"); + ps.WriteLine(" True"); + ps.WriteLine(" True"); + string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.')); + string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.')); + ps.WriteLine(" {0}", fileNameShorter + ".settings"); + } + ps.WriteLine(" ", project.Files.GetBuildAction(file)); + } + else if (project.Files.GetSubType(file) != SubType.Designer) + { + if (!list.Contains(file)) + { + ps.Write(" <{0} ", project.Files.GetBuildAction(file)); + ps.WriteLine("Include=\"{0}\">", file); + + + if (file.Contains("Designer.cs")) + { + ps.WriteLine(" {0}", file.Substring(0, file.IndexOf(".Designer.cs")) + ".cs"); + } + + if (project.Files.GetIsLink(file)) + { + ps.WriteLine(" {0}", Path.GetFileName(file)); + } + else if (project.Files.GetBuildAction(file) != BuildAction.None) + { + if (project.Files.GetBuildAction(file) != BuildAction.EmbeddedResource) + { + ps.WriteLine(" {0}", project.Files.GetSubType(file)); + } + } + if (project.Files.GetCopyToOutput(file) != CopyToOutput.Never) + { + ps.WriteLine(" {0}", project.Files.GetCopyToOutput(file)); + } + + ps.WriteLine(" ", project.Files.GetBuildAction(file)); + } + } + } + // ps.WriteLine(" "); + + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + // ps.WriteLine(" ", toolInfo.XMLTag); + ps.WriteLine(""); + } + #endregion + + #region User File + + ps = new StreamWriter(projectFile + ".user"); + using (ps) + { + ps.WriteLine(""); + //ps.WriteLine( "" ); + //ps.WriteLine(" <{0}>", toolInfo.XMLTag); + //ps.WriteLine(" "); + ps.WriteLine(" "); + //ps.WriteLine(" ", MakeRefPath(project)); + ps.WriteLine(" Debug"); + ps.WriteLine(" AnyCPU"); + ps.WriteLine(" {0}", MakeRefPath(project)); + ps.WriteLine(" {0}", this.ProductVersion); + ps.WriteLine(" ProjectFiles"); + ps.WriteLine(" 0"); + ps.WriteLine(" "); + foreach (ConfigurationNode conf in project.Configurations) + { + ps.Write(" "); + } + //ps.WriteLine(" "); + + //ps.WriteLine(" "); + //ps.WriteLine(" ", toolInfo.XMLTag); + //ps.WriteLine(""); + ps.WriteLine(""); + } + #endregion + + kernel.CurrentWorkingDirectory.Pop(); + } + + private void WriteSolution(SolutionNode solution) + { + kernel.Log.Write("Creating {0} solution and project files", this.VersionName); + + foreach (ProjectNode project in solution.Projects) + { + kernel.Log.Write("...Creating project: {0}", project.Name); + WriteProject(solution, project); + } + + kernel.Log.Write(""); + string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); + StreamWriter ss = new StreamWriter(solutionFile); + + kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); + + using (ss) + { + ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion); + ss.WriteLine("# Visual Studio 2005"); + foreach (ProjectNode project in solution.Projects) + { + if (!tools.ContainsKey(project.Language)) + { + throw new UnknownLanguageException("Unknown .NET language: " + project.Language); + } + + ToolInfo toolInfo = (ToolInfo)tools[project.Language]; + + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"", + toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name, + toolInfo.FileExtension), project.Guid.ToString().ToUpper()); + + //ss.WriteLine(" ProjectSection(ProjectDependencies) = postProject"); + //ss.WriteLine(" EndProjectSection"); + + ss.WriteLine("EndProject"); + } + + if (solution.Files != null) + { + ss.WriteLine("Project(\"{0}\") = \"Solution Items\", \"Solution Items\", \"{1}\"", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", "{468F1D07-AD17-4CC3-ABD0-2CA268E4E1A6}"); + ss.WriteLine("\tProjectSection(SolutionItems) = preProject"); + foreach (string file in solution.Files) + ss.WriteLine("\t\t{0} = {0}", file); + ss.WriteLine("\tEndProjectSection"); + ss.WriteLine("EndProject"); + } + + ss.WriteLine("Global"); + + ss.WriteLine(" GlobalSection(SolutionConfigurationPlatforms) = preSolution"); + foreach (ConfigurationNode conf in solution.Configurations) + { + ss.WriteLine(" {0}|Any CPU = {0}|Any CPU", conf.Name); + } + ss.WriteLine(" EndGlobalSection"); + + if (solution.Projects.Count > 1) + { + ss.WriteLine(" GlobalSection(ProjectDependencies) = postSolution"); + } + foreach (ProjectNode project in solution.Projects) + { + for (int i = 0; i < project.References.Count; i++) + { + ReferenceNode refr = (ReferenceNode)project.References[i]; + if (solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; + ss.WriteLine(" ({{{0}}}).{1} = ({{{2}}})", + project.Guid.ToString().ToUpper() + , i, + refProject.Guid.ToString().ToUpper() + ); + } + } + } + if (solution.Projects.Count > 1) + { + ss.WriteLine(" EndGlobalSection"); + } + ss.WriteLine(" GlobalSection(ProjectConfigurationPlatforms) = postSolution"); + foreach (ProjectNode project in solution.Projects) + { + foreach (ConfigurationNode conf in solution.Configurations) + { + ss.WriteLine(" {{{0}}}.{1}|Any CPU.ActiveCfg = {1}|Any CPU", + project.Guid.ToString().ToUpper(), + conf.Name); + + ss.WriteLine(" {{{0}}}.{1}|Any CPU.Build.0 = {1}|Any CPU", + project.Guid.ToString().ToUpper(), + conf.Name); + } + } + ss.WriteLine(" EndGlobalSection"); + ss.WriteLine(" GlobalSection(SolutionProperties) = preSolution"); + ss.WriteLine(" HideSolutionNode = FALSE"); + ss.WriteLine(" EndGlobalSection"); + + ss.WriteLine("EndGlobal"); + } + + kernel.CurrentWorkingDirectory.Pop(); + } + + private void CleanProject(ProjectNode project) + { + kernel.Log.Write("...Cleaning project: {0}", project.Name); + + ToolInfo toolInfo = (ToolInfo)tools[project.Language]; + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); + string userFile = projectFile + ".user"; + + Helper.DeleteIfExists(projectFile); + Helper.DeleteIfExists(userFile); + } + + private void CleanSolution(SolutionNode solution) + { + kernel.Log.Write("Cleaning {0} solution and project files", this.VersionName, solution.Name); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); + string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); + + Helper.DeleteIfExists(slnFile); + Helper.DeleteIfExists(suoFile); + + foreach (ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public virtual void Write(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + kernel = kern; + foreach (SolutionNode sol in kernel.Solutions) + { + WriteSolution(sol); + } + kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + kernel = kern; + foreach (SolutionNode sol in kernel.Solutions) + { + CleanSolution(sol); + } + kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public virtual string Name + { + get + { + return "vs2005"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/UnknownLanguageException.cs b/Prebuild/src/Core/UnknownLanguageException.cs new file mode 100644 index 0000000000..cbd1dc1b76 --- /dev/null +++ b/Prebuild/src/Core/UnknownLanguageException.cs @@ -0,0 +1,63 @@ +/* + * $RCSfile$ + * Copyright (C) 2004, 2005 David Hudson (jendave@yahoo.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +using System; +using System.Runtime.Serialization; + +namespace Prebuild.Core +{ + /// + /// + [Serializable()] + public class UnknownLanguageException : Exception + { + /// + /// Basic exception. + /// + public UnknownLanguageException() + { + } + + /// + /// Exception with specified string + /// + /// Exception message + public UnknownLanguageException(string message): base(message) + { + } + + /// + /// + /// + /// + /// + public UnknownLanguageException(string message, Exception exception) : base(message, exception) + { + } + + /// + /// + /// + /// + /// + protected UnknownLanguageException(SerializationInfo info, StreamingContext context) : base( info, context ) + { + } + } +} diff --git a/Prebuild/src/Core/Utilities/CommandLineCollection.cs b/Prebuild/src/Core/Utilities/CommandLineCollection.cs new file mode 100644 index 0000000000..496731f759 --- /dev/null +++ b/Prebuild/src/Core/Utilities/CommandLineCollection.cs @@ -0,0 +1,162 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: robloach $ + * $Date: 2006-09-26 00:30:53 +0200 (ti, 26 sep 2006) $ + * $Revision: 165 $ + */ +#endregion + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.Diagnostics; + +namespace Prebuild.Core.Utilities +{ + /// + /// The CommandLine class parses and interprets the command-line arguments passed to + /// prebuild. + /// + public class CommandLineCollection + { + #region Fields + + // The raw OS arguments + private string[] m_RawArgs; + + // Command-line argument storage + private Hashtable m_Arguments; + + #endregion + + #region Constructors + + /// + /// Create a new CommandLine instance and set some internal variables. + /// + public CommandLineCollection(string[] args) + { + m_RawArgs = args; + m_Arguments = new Hashtable(); + + Parse(); + } + + #endregion + + #region Private Methods + + private void Parse() + { + if(m_RawArgs.Length < 1) + return; + + int idx = 0; + string arg = null, lastArg = null; + + while(idx 2 && arg[0] == '/') + { + arg = arg.Substring(1); + lastArg = arg; + m_Arguments[arg] = ""; + } + else + { + if(lastArg != null) + { + m_Arguments[lastArg] = arg; + lastArg = null; + } + } + + idx++; + } + } + + #endregion + + #region Public Methods + + /// + /// Wases the passed. + /// + /// The arg. + /// + public bool WasPassed(string arg) + { + return (m_Arguments.ContainsKey(arg)); + } + + #endregion + + #region Properties + + /// + /// Gets the parameter associated with the command line option + /// + /// Returns null if option was not specified, + /// null string if no parameter was specified, and the value if a parameter was specified + public string this[string index] + { + get + { + if(m_Arguments.ContainsKey(index)) + { + return (string)(m_Arguments[index]); + } + else + { + return null; + } + } + } + + #endregion + + #region IEnumerable Members + + /// + /// Returns an enumerator that can iterate through a collection. + /// + /// + /// An + /// that can be used to iterate through the collection. + /// + public IDictionaryEnumerator GetEnumerator() + { + return m_Arguments.GetEnumerator(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Utilities/CurrentDirectory.cs b/Prebuild/src/Core/Utilities/CurrentDirectory.cs new file mode 100644 index 0000000000..a76d844524 --- /dev/null +++ b/Prebuild/src/Core/Utilities/CurrentDirectory.cs @@ -0,0 +1,89 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Revision: 71 $ + */ +#endregion + +using System; +using System.Collections; + +namespace Prebuild.Core.Utilities +{ + /// + /// + /// + public class CurrentDirectory + { + #region Fields + + private Stack m_Stack; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public CurrentDirectory() + { + m_Stack = new Stack(); + } + + #endregion + + #region Public Methods + + /// + /// Pushes this instance. + /// + public void Push() + { + m_Stack.Push(Environment.CurrentDirectory); + } + + /// + /// Pops this instance. + /// + public void Pop() + { + if(m_Stack.Count < 1) + { + return; + } + + string cwd = (string)m_Stack.Pop(); + Helper.SetCurrentDir(cwd); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Utilities/Helper.cs b/Prebuild/src/Core/Utilities/Helper.cs new file mode 100644 index 0000000000..33c9618886 --- /dev/null +++ b/Prebuild/src/Core/Utilities/Helper.cs @@ -0,0 +1,661 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2007-02-13 21:58:03 +0100 (ti, 13 feb 2007) $ + * $Revision: 205 $ + */ +#endregion + +using System; +using System.Collections; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using System.Text.RegularExpressions; +using System.Collections.Specialized; +using System.Xml; +using Prebuild.Core.Nodes; + +namespace Prebuild.Core.Utilities +{ + /// + /// + /// + public class Helper + { + #region Fields + + private static Stack dirStack; + private static Regex varRegex; + static bool checkForOSVariables; + + /// + /// + /// + public static bool CheckForOSVariables + { + get + { + return checkForOSVariables; + } + set + { + checkForOSVariables = value; + } + } + + #endregion + + #region Constructors + + /// + /// Initializes the class. + /// + static Helper() + { + dirStack = new Stack(); + //m_VarRegex = new Regex(@"\${(?[\w|_]+)}"); + } + + #endregion + + #region Properties + + /// + /// + /// + public static Stack DirStack + { + get + { + return dirStack; + } + } + + /// + /// + /// + public static Regex VarRegex + { + get + { + return varRegex; + } + set + { + varRegex = value; + } + } + + #endregion + + #region Public Methods + + #region String Parsing + #region Inner Classes and Delegates + /// + /// + /// + public delegate string StringLookup(string key); + + #endregion + + /// + /// Gets a collection of StringLocationPair objects that represent the matches + /// + /// The target. + /// The before group. + /// The after group. + /// if set to true [include delimiters in substrings]. + /// + public static StringCollection FindGroups(string target, string beforeGroup, string afterGroup, bool includeDelimitersInSubstrings) + { + if( beforeGroup == null ) + { + throw new ArgumentNullException("beforeGroup"); + } + if( afterGroup == null ) + { + throw new ArgumentNullException("afterGroup"); + } + StringCollection results = new StringCollection(); + if(target == null || target.Length == 0) + { + return results; + } + + int beforeMod = 0; + int afterMod = 0; + if(includeDelimitersInSubstrings) + { + //be sure to not exlude the delims + beforeMod = beforeGroup.Length; + afterMod = afterGroup.Length; + } + int startIndex = 0; + while((startIndex = target.IndexOf(beforeGroup,startIndex)) != -1) { + int endIndex = target.IndexOf(afterGroup,startIndex);//the index of the char after it + if(endIndex == -1) + { + break; + } + int length = endIndex - startIndex - beforeGroup.Length;//move to the first char in the string + string substring = substring = target.Substring(startIndex + beforeGroup.Length - beforeMod, + length - afterMod); + + results.Add(substring); + //results.Add(new StringLocationPair(substring,startIndex)); + startIndex = endIndex + 1; + //the Interpolate*() methods will not work if expressions are expandded inside expression due to an optimization + //so start after endIndex + + } + return results; + } + + /// + /// Replaces the groups. + /// + /// The target. + /// The before group. + /// The after group. + /// The lookup. + /// + public static string ReplaceGroups(string target, string beforeGroup, string afterGroup, StringLookup lookup) { + if( target == null ) + { + throw new ArgumentNullException("target"); + } + //int targetLength = target.Length; + StringCollection strings = FindGroups(target,beforeGroup,afterGroup,false); + if( lookup == null ) + { + throw new ArgumentNullException("lookup"); + } + foreach(string substring in strings) + { + target = target.Replace(beforeGroup + substring + afterGroup, lookup(substring) ); + } + return target; + } + + /// + /// Replaces ${var} statements in a string with the corresonding values as detirmined by the lookup delegate + /// + /// The target. + /// The lookup. + /// + public static string InterpolateForVariables(string target, StringLookup lookup) + { + return ReplaceGroups(target, "${" , "}" , lookup); + } + + /// + /// Replaces ${var} statements in a string with the corresonding environment variable with name var + /// + /// + /// + public static string InterpolateForEnvironmentVariables(string target) + { + return InterpolateForVariables(target, new StringLookup(Environment.GetEnvironmentVariable)); + } + + #endregion + + /// + /// Translates the value. + /// + /// Type of the translate. + /// The translation item. + /// + public static object TranslateValue(Type translateType, string translationItem) + { + if(translationItem == null) + { + return null; + } + + try + { + string lowerVal = translationItem.ToLower(); + if(translateType == typeof(bool)) + { + return (lowerVal == "true" || lowerVal == "1" || lowerVal == "y" || lowerVal == "yes" || lowerVal == "on"); + } + else if(translateType == typeof(int)) + { + return (Int32.Parse(translationItem)); + } + else + { + return translationItem; + } + } + catch(FormatException) + { + return null; + } + } + + /// + /// Deletes if exists. + /// + /// The file. + /// + public static bool DeleteIfExists(string file) + { + string resFile = null; + try + { + resFile = ResolvePath(file); + } + catch(ArgumentException) + { + return false; + } + + if(!File.Exists(resFile)) + { + return false; + } + + File.Delete(resFile); + return true; + } + + // This little gem was taken from the NeL source, thanks guys! + /// + /// Makes a relative path + /// + /// Path to start from + /// Path to end at + /// Path that will get from startPath to endPath + public static string MakePathRelativeTo(string startPath, string endPath) + { + string tmp = NormalizePath(startPath, '/'); + string src = NormalizePath(endPath, '/'); + string prefix = ""; + + while(true) + { + if((String.Compare(tmp, 0, src, 0, tmp.Length) == 0)) + { + string ret; + int size = tmp.Length; + if(size == src.Length) + { + return "./"; + } + if ((src.Length > tmp.Length) && src[tmp.Length-1] != '/' && src[tmp.Length-1] != '\\') + { + } + else + { + ret = prefix + endPath.Substring(size, endPath.Length - size); + ret = ret.Trim(); + if(ret[0] == '/' || ret[0] == '\\') + { + ret = "." + ret; + } + + return NormalizePath(ret); + } + + } + + if(tmp.Length < 2) + { + break; + } + + int lastPos = tmp.LastIndexOf('/', tmp.Length - 2); + int prevPos = tmp.IndexOf('/'); + + if((lastPos == prevPos) || (lastPos == -1)) + { + break; + } + + tmp = tmp.Substring(0, lastPos + 1); + prefix += "../"; + } + + return endPath; + } + + /// + /// Resolves the path. + /// + /// The path. + /// + public static string ResolvePath(string path) + { + string tmpPath = NormalizePath(path); + if(tmpPath.Length < 1) + { + tmpPath = "."; + } + + tmpPath = Path.GetFullPath(tmpPath); + if(!File.Exists(tmpPath) && !Directory.Exists(tmpPath)) + { + throw new ArgumentException("Path could not be resolved: " + tmpPath); + } + + return tmpPath; + } + + /// + /// Normalizes the path. + /// + /// The path. + /// The separator character. + /// + public static string NormalizePath(string path, char separatorCharacter) + { + if(path == null || path == "" || path.Length < 1) + { + return ""; + } + + string tmpPath = path.Replace('\\', '/'); + tmpPath = tmpPath.Replace('/', separatorCharacter); + return tmpPath; + } + + /// + /// Normalizes the path. + /// + /// The path. + /// + public static string NormalizePath(string path) + { + return NormalizePath(path, Path.DirectorySeparatorChar); + } + + /// + /// Ends the path. + /// + /// The path. + /// The separator character. + /// + public static string EndPath(string path, char separatorCharacter) + { + if(path == null || path == "" || path.Length < 1) + { + return ""; + } + + if(!path.EndsWith(separatorCharacter.ToString())) + { + return (path + separatorCharacter); + } + + return path; + } + + /// + /// Ends the path. + /// + /// The path. + /// + public static string EndPath(string path) + { + return EndPath(path, Path.DirectorySeparatorChar); + } + + /// + /// Makes the file path. + /// + /// The path. + /// The name. + /// The ext. + /// + public static string MakeFilePath(string path, string name, string ext) + { + string ret = EndPath(NormalizePath(path)); + + if( name == null ) + { + throw new ArgumentNullException("name"); + } + + ret += name; + if(!name.EndsWith("." + ext)) + { + ret += "." + ext; + } + + //foreach(char c in Path.GetInvalidPathChars()) + //{ + // ret = ret.Replace(c, '_'); + //} + + return ret; + } + + /// + /// Makes the file path. + /// + /// The path. + /// The name. + /// + public static string MakeFilePath(string path, string name) + { + string ret = EndPath(NormalizePath(path)); + + if( name == null ) + { + throw new ArgumentNullException("name"); + } + + ret += name; + + //foreach (char c in Path.GetInvalidPathChars()) + //{ + // ret = ret.Replace(c, '_'); + //} + + return ret; + } + + /// + /// + /// + /// + /// + public static string MakeReferencePath(string path) + { + string ret = EndPath(NormalizePath(path)); + + //foreach (char c in Path.GetInvalidPathChars()) + //{ + // ret = ret.Replace(c, '_'); + //} + + return ret; + } + + /// + /// Sets the current dir. + /// + /// The path. + public static void SetCurrentDir(string path) + { + if( path == null ) + { + throw new ArgumentNullException("path"); + } + if(path.Length < 1) + { + return; + } + + Environment.CurrentDirectory = path; + } + + /// + /// Checks the type. + /// + /// The type to check. + /// The attr. + /// The inter. + /// + public static object CheckType(Type typeToCheck, Type attr, Type inter) + { + if(typeToCheck == null || attr == null) + { + return null; + } + + object[] attrs = typeToCheck.GetCustomAttributes(attr, false); + if(attrs == null || attrs.Length < 1) + { + return null; + } + if( inter == null ) + { + throw new ArgumentNullException("inter"); + } + + if(typeToCheck.GetInterface(inter.FullName) == null) + { + return null; + } + + return attrs[0]; + } + + /* A bit of overhead for simple group parsing, there are problems with Regex in Mono + public static string ParseValue(string val) + { + if(val == null || val.Length < 1 || !CheckForOSVariables) + return val; + + string tmp = val; + Match m = m_VarRegex.Match(val); + while(m.Success) + { + if(m.Groups["var"] == null) + continue; + + Capture c = m.Groups["var"].Captures[0]; + if(c == null) + continue; + + string var = c.Value; + string envVal = Environment.GetEnvironmentVariable(var); + if(envVal == null) + envVal = ""; + + tmp = tmp.Replace("${" + var + "}", envVal); + m = m.NextMatch(); + } + + return tmp; + }*/ + + /// + /// Attributes the value. + /// + /// The node. + /// The attr. + /// The def. + /// + public static string AttributeValue(XmlNode node, string attr, string def) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + if(node.Attributes[attr] == null) + { + return def; + } + string val = node.Attributes[attr].Value; + if(!CheckForOSVariables) + { + return val; + } + + return InterpolateForEnvironmentVariables(val); + } + + /// + /// Parses the boolean. + /// + /// The node. + /// The attr. + /// if set to true [default value]. + /// + public static bool ParseBoolean(XmlNode node, string attr, bool defaultValue) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + if(node.Attributes[attr] == null) + { + return defaultValue; + } + return bool.Parse(node.Attributes[attr].Value); + } + + /// + /// Enums the attribute value. + /// + /// The node. + /// The attr. + /// Type of the enum. + /// The def. + /// + public static object EnumAttributeValue(XmlNode node, string attr, Type enumType, object def) + { + if( def == null ) + { + throw new ArgumentNullException("def"); + } + string val = AttributeValue(node, attr, def.ToString()); + return Enum.Parse(enumType, val, true); + } + + /// + /// + /// + /// + /// + /// + public static string AssemblyFullName(string assemblyName, ProjectType projectType) + { + return assemblyName + (projectType == ProjectType.Library ? ".dll" : ".exe"); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Utilities/Log.cs b/Prebuild/src/Core/Utilities/Log.cs new file mode 100644 index 0000000000..da2cc96627 --- /dev/null +++ b/Prebuild/src/Core/Utilities/Log.cs @@ -0,0 +1,279 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Revision: 71 $ + */ +#endregion + +using System; +using System.IO; + +namespace Prebuild.Core.Utilities +{ + /// + /// + /// + public enum LogType + { + /// + /// + /// + None, + /// + /// + /// + Info, + /// + /// + /// + Warning, + /// + /// + /// + Error + } + + /// + /// + /// + [Flags] + public enum LogTargets + { + /// + /// + /// + None = 0, + /// + /// + /// + Null = 1, + /// + /// + /// + File = 2, + /// + /// + /// + Console = 4 + } + + /// + /// Summary description for Log. + /// + public class Log : IDisposable + { + #region Fields + + private StreamWriter m_Writer; + private LogTargets m_Target = LogTargets.Null; + bool disposed; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The target. + /// Name of the file. + public Log(LogTargets target, string fileName) + { + m_Target = target; + + if((m_Target & LogTargets.File) != 0) + { + m_Writer = new StreamWriter(fileName, false); + } + } + + #endregion + + #region Public Methods + + /// + /// Writes this instance. + /// + public void Write() + { + Write(string.Empty); + } + + /// + /// Writes the specified MSG. + /// + /// The MSG. + public void Write(string msg) + { + if((m_Target & LogTargets.Null) != 0) + { + return; + } + + if((m_Target & LogTargets.Console) != 0) + { + Console.WriteLine(msg); + } + if((m_Target & LogTargets.File) != 0 && m_Writer != null) + { + m_Writer.WriteLine(msg); + } + } + + /// + /// Writes the specified format. + /// + /// The format. + /// The args. + public void Write(string format, params object[] args) + { + Write(string.Format(format,args)); + } + + /// + /// Writes the specified type. + /// + /// The type. + /// The format. + /// The args. + public void Write(LogType type, string format, params object[] args) + { + if((m_Target & LogTargets.Null) != 0) + { + return; + } + + string str = ""; + switch(type) + { + case LogType.Info: + str = "[I] "; + break; + case LogType.Warning: + str = "[!] "; + break; + case LogType.Error: + str = "[X] "; + break; + } + + Write(str + format,args); + } + + /// + /// Writes the exception. + /// + /// The type. + /// The ex. + public void WriteException(LogType type, Exception ex) + { + if(ex != null) + { + Write(type, ex.Message); + //#if DEBUG + m_Writer.WriteLine("Exception @{0} stack trace [[", ex.TargetSite.Name); + m_Writer.WriteLine(ex.StackTrace); + m_Writer.WriteLine("]]"); + //#endif + } + } + + /// + /// Flushes this instance. + /// + public void Flush() + { + if(m_Writer != null) + { + m_Writer.Flush(); + } + } + + #endregion + + #region IDisposable Members + + /// + /// Performs application-defined tasks associated with freeing, releasing, or + /// resetting unmanaged resources. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Dispose objects + /// + /// + /// If true, it will dispose close the handle + /// + /// + /// Will dispose managed and unmanaged resources. + /// + protected virtual void Dispose(bool disposing) + { + if (!this.disposed) + { + if (disposing) + { + if (m_Writer != null) + { + m_Writer.Close(); + m_Writer = null; + } + } + } + this.disposed = true; + } + + /// + /// + /// + ~Log() + { + this.Dispose(false); + } + + /// + /// Closes and destroys this object + /// + /// + /// Same as Dispose(true) + /// + public void Close() + { + Dispose(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/WarningException.cs b/Prebuild/src/Core/WarningException.cs new file mode 100644 index 0000000000..a200bdcfcd --- /dev/null +++ b/Prebuild/src/Core/WarningException.cs @@ -0,0 +1,93 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Revision: 71 $ + */ +#endregion + +using System; +using System.Runtime.Serialization; + +namespace Prebuild.Core +{ + /// + /// + /// + [Serializable()] + public class WarningException : Exception + { + #region Constructors + + /// + /// + /// + public WarningException() + { + } + + /// + /// + /// + /// + /// + public WarningException(string format, params object[] args) + : base(String.Format(format, args)) + { + } + + /// + /// Exception with specified string + /// + /// Exception message + public WarningException(string message): base(message) + { + } + + /// + /// + /// + /// + /// + public WarningException(string message, Exception exception) : base(message, exception) + { + } + + /// + /// + /// + /// + /// + protected WarningException(SerializationInfo info, StreamingContext context) : base( info, context ) + { + } + + #endregion + } +} diff --git a/Prebuild/src/Prebuild.cs b/Prebuild/src/Prebuild.cs new file mode 100644 index 0000000000..597db6872f --- /dev/null +++ b/Prebuild/src/Prebuild.cs @@ -0,0 +1,165 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-09-26 23:43:35 +0200 (ti, 26 sep 2006) $ + * $Revision: 168 $ + */ +#endregion + +using System; +using System.Collections.Specialized; +using System.IO; +using System.Reflection; +using System.Runtime.InteropServices; +using System.EnterpriseServices.Internal; + +using Prebuild.Core; +using Prebuild.Core.Utilities; + +namespace Prebuild +{ + /// + /// + /// + class Prebuild + { + #region Main + + [STAThread] + static void Main(string[] args) + { + Kernel kernel = null; + try + { + kernel = Kernel.Instance; + kernel.Initialize(LogTargets.File | LogTargets.Console, args); + bool exit = false; + + if(kernel.CommandLine.WasPassed("usage")) + { + exit = true; + OutputUsage(); + } + if(kernel.CommandLine.WasPassed("showtargets")) + { + exit = true; + OutputTargets(kernel); + } + if(kernel.CommandLine.WasPassed("install")) + { + exit = true; + InstallAssembly(kernel); + } + if(kernel.CommandLine.WasPassed("remove")) + { + exit = true; + RemoveAssembly(kernel); + } + + if(!exit) + { + kernel.Process(); + } + } + catch(Exception ex) + { + Console.WriteLine("Unhandled error: {0}", ex.Message); + //#if DEBUG + Console.WriteLine("{0}", ex.StackTrace); + //#endif + } + finally + { + if(kernel.PauseAfterFinish) + { + Console.WriteLine("\nPress enter to continue..."); + Console.ReadLine(); + } + } + } + + #endregion + + #region Private Methods + + private static void InstallAssembly(Kernel kernel) + { + Publish publish = new Publish(); + string file = kernel.CommandLine["install"]; + //Console.WriteLine(".."+file+".."); + publish.GacInstall(file); + } + + private static void RemoveAssembly(Kernel kernel) + { + Publish publish = new Publish(); + string file = kernel.CommandLine["remove"]; + publish.GacRemove(file); + } + + private static void OutputUsage() + { + Console.WriteLine("Usage: prebuild /target [options]"); + Console.WriteLine("Available command-line switches:"); + Console.WriteLine(); + Console.WriteLine("/target Target for Prebuild"); + Console.WriteLine("/clean Clean the build files for the given target"); + Console.WriteLine("/file XML file to process"); + Console.WriteLine("/log Log file to write to"); + Console.WriteLine("/ppo Pre-process the file, but perform no other processing"); + Console.WriteLine("/pause Pauses the application after execution to view the output"); + Console.WriteLine("/yes Default to yes to any questions asked"); + Console.WriteLine("/install Install assembly into the GAC"); + Console.WriteLine("/remove Remove assembly from the GAC"); + Console.WriteLine(); + Console.WriteLine("See 'prebuild /showtargets for a list of available targets"); + Console.WriteLine("See readme.txt or check out http://dnpb.sourceforge.net for more information"); + Console.WriteLine(); + } + + private static void OutputTargets(Kernel kern) + { + Console.WriteLine("Targets available in Prebuild:"); + Console.WriteLine(""); + if(kern.Targets.Keys.Count > 0) + { + string[] targs = new string[kern.Targets.Keys.Count]; + kern.Targets.Keys.CopyTo(targs, 0); + Array.Sort(targs); + foreach(string target in targs) + { + Console.WriteLine(target); + } + } + Console.WriteLine(""); + } + + #endregion + } +} diff --git a/Prebuild/src/Prebuild.csproj b/Prebuild/src/Prebuild.csproj new file mode 100644 index 0000000000..82589c24c1 --- /dev/null +++ b/Prebuild/src/Prebuild.csproj @@ -0,0 +1,199 @@ + + + Local + 8.0.50727 + 2.0 + {A5CC8344-BEE4-442E-92F1-FBCB05D6AB78} + Debug + AnyCPU + App.ico + + + prebuild + Prebuild.snk + true + JScript + Grid + IE50 + false + Exe + + + Prebuild + Prebuild.Prebuild + + + + + False + 285212672 + False + + + DEBUG;TRACE + + + True + 4096 + False + ..\bin\ + False + False + False + 4 + 1595 + + + False + 285212672 + False + + + TRACE + + + False + 4096 + True + ..\bin\ + False + False + False + 4 + 1595 + + + + + + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Prebuild/src/Prebuild.exe.build b/Prebuild/src/Prebuild.exe.build new file mode 100644 index 0000000000..fda34b94d0 --- /dev/null +++ b/Prebuild/src/Prebuild.exe.build @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Prebuild/src/Prebuild.snk b/Prebuild/src/Prebuild.snk new file mode 100644 index 0000000000000000000000000000000000000000..f9dce054ffae7c79dce7d3ba0b790904bdb36831 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50097%QdipZe+P78+gioe1FL>Pm`A%NYNJjT zvr&utrO*Bz`;(~1&v7SLbo#8h8*Eu!T1$f&*Z!JD(@sjU;6;rE+#4q{`Ci_P6X~Os zsqTl*?$f+z`P@h&-Z=SV9gYc!udqrVAH@hG`xHwT1SMQBX^U%@gPO$V6JX)9KT9Ww>?9GKft(b~3CsqH2^BHX{_&xGMn ztAW9|iLO>;#yB;wrHus##d%AZDeNPu@F_TTzUscSGU=aLSyvelLiSJps^FvCxcYHV z4Y1$J$Wu2ek`e>_>d43PbVJq8mILALAW%&DDsyb=|xUms2{~U~!hI$4*kXem7!Hk=k zc1qQS!>`bZbL}5fr*. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyName("")] diff --git a/Prebuild/src/data/dnpb-1.0.xsd b/Prebuild/src/data/dnpb-1.0.xsd new file mode 100644 index 0000000000..45cab86334 --- /dev/null +++ b/Prebuild/src/data/dnpb-1.0.xsd @@ -0,0 +1,183 @@ + + + + + Copyright (c) 2004 Matthew Holmes (kerion@houston.rr.com) + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + * The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Prebuild/src/data/dnpb-1.1.xsd b/Prebuild/src/data/dnpb-1.1.xsd new file mode 100644 index 0000000000..c402cebcf1 --- /dev/null +++ b/Prebuild/src/data/dnpb-1.1.xsd @@ -0,0 +1,184 @@ + + + + + Copyright (c) 2004 Matthew Holmes (kerion@houston.rr.com) + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + * The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Prebuild/src/data/dnpb-1.2.xsd b/Prebuild/src/data/dnpb-1.2.xsd new file mode 100644 index 0000000000..8004af74a8 --- /dev/null +++ b/Prebuild/src/data/dnpb-1.2.xsd @@ -0,0 +1,198 @@ + + + + + Copyright (c) 2004 Matthew Holmes (calefaction _at_ houston _._ rr _._ com) + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + * The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Prebuild/src/data/dnpb-1.3.xsd b/Prebuild/src/data/dnpb-1.3.xsd new file mode 100644 index 0000000000..5f8ada1ec4 --- /dev/null +++ b/Prebuild/src/data/dnpb-1.3.xsd @@ -0,0 +1,206 @@ + + + + + Copyright (c) 2004-2005 Matthew Holmes (calefaction at houston . rr . com), Dan Moorehead (dan05a at gmail . com) + + .NET Pre-Build is an XML-driven pre-build tool allowing developers to + easily generate project or make files for major IDE's and .NET + development tools including: Visual Studio 2003, Visual Studio 2002, + SharpDevelop, MonoDevelop, and NAnt. + + BSD License: + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + * The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Prebuild/src/data/dnpb-1.4.xsd b/Prebuild/src/data/dnpb-1.4.xsd new file mode 100644 index 0000000000..54f9ac0030 --- /dev/null +++ b/Prebuild/src/data/dnpb-1.4.xsd @@ -0,0 +1,212 @@ + + + + + Copyright (c) 2004-2005 Matthew Holmes (calefaction at houston . rr . com), Dan Moorehead (dan05a at gmail . com) + + .NET Prebuild is a cross-platform XML-driven pre-build tool which + allows developers to easily generate project or make files for major + IDE's and .NET development tools including: Visual Studio .NET 2002 and + 2003, SharpDevelop, MonoDevelop, and NAnt. + + BSD License: + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + * The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Prebuild/src/data/dnpb-1.5.xsd b/Prebuild/src/data/dnpb-1.5.xsd new file mode 100644 index 0000000000..2270e836e8 --- /dev/null +++ b/Prebuild/src/data/dnpb-1.5.xsd @@ -0,0 +1,215 @@ + + + + + Copyright (c) 2004-2005 Matthew Holmes (calefaction at houston . rr . com), Dan Moorehead (dan05a at gmail . com) + + .NET Prebuild is a cross-platform XML-driven pre-build tool which + allows developers to easily generate project or make files for major + IDE's and .NET development tools including: Visual Studio .NET 2002 and + 2003, SharpDevelop, MonoDevelop, and NAnt. + + BSD License: + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + * The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Prebuild/src/data/prebuild-1.6.xsd b/Prebuild/src/data/prebuild-1.6.xsd new file mode 100644 index 0000000000..f944fafc03 --- /dev/null +++ b/Prebuild/src/data/prebuild-1.6.xsd @@ -0,0 +1,231 @@ + + + + + Copyright (c) 2004-2005 Matthew Holmes (calefaction at houston . rr . com), Dan Moorehead (dan05a at gmail . com) + + .NET Prebuild is a cross-platform XML-driven pre-build tool which + allows developers to easily generate project or make files for major + IDE's and .NET development tools including: Visual Studio .NET 2002 and + 2003, SharpDevelop, MonoDevelop, and NAnt. + + BSD License: + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + * The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Prebuild/src/data/prebuild-1.7.xsd b/Prebuild/src/data/prebuild-1.7.xsd new file mode 100644 index 0000000000..9d63ce6e73 --- /dev/null +++ b/Prebuild/src/data/prebuild-1.7.xsd @@ -0,0 +1,261 @@ + + + + + Copyright (c) 2004-2005 Matthew Holmes (calefaction at houston . rr . com), Dan Moorehead (dan05a at gmail . com), David Hudson (jendave at yahoo dot com) + + .NET Prebuild is a cross-platform XML-driven pre-build tool which + allows developers to easily generate project or make files for major + IDE's and .NET development tools including: Visual Studio .NET 2002 and + 2003, SharpDevelop, MonoDevelop, and NAnt. + + BSD License: + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + * The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/README.txt b/README.txt index 818208642c..c7c5a93abb 100644 --- a/README.txt +++ b/README.txt @@ -4,7 +4,7 @@ Build Instructions * Check out the trunk code -* Build the /src/opensim.sln solution +* Build the /OpenSim.sln solution * open cmd window, go to /bin and launch OpenSim.exe -sandbox -loginserver @@ -23,12 +23,33 @@ secondlife.exe -loginuri http://localhost:8080/ * ensure you have nant (http://nant.sf.net) installed -* cd to the right directory and type "nant" +* cd to the trunk root directory and type "nant" * cd to bin/ and run "mono OpenSim.exe -sandbox -loginserver" -=== Windows Nant Build === +=== Prebuild === + +We use Prebuild to generate vs2005 solutions and nant build scripts. + +The Prebuild master project is /prebuild.xml + +To build it with vs2005 : + +* build the solution /Prebuild/Prebuild.sln + +To build it with nant : + +* cd to /Prebuild/ +* type 'nant' + +After you've built it, move it from /Prebuild/src/bin to /bin/ directory, + +after that you just modify the prebuild.xml and then execute + +bin/Prebuild.exe /target {target} + +where target is either +vs2005 - to generate new vs2005 solutions and projects +nant - to generate new nant build scripts + -* same as Linux/mono build, but use -nant nogenvers -to cicumvent bash invokation diff --git a/STATE_OF_PREBUILD.txt b/STATE_OF_PREBUILD.txt new file mode 100644 index 0000000000..5f763ca5f0 --- /dev/null +++ b/STATE_OF_PREBUILD.txt @@ -0,0 +1,15 @@ +These are the issues we have with Prebuild: + +* vs2005 target + * does not honour localCopy=False - fairly easy to add node on ref. ** fixed ** + * screws up solution file projects references by miscalculating relative dir (it walks one level too high up then back) **fixed** +* Nant target + * doesn't honour Output redirection at all, which causes everything to land in {project}/bin/Debug **fixed** + +Both targets + * Have problems with refs + * 'System.Xml' will have to csc ref as 'System.Xml.dll' to work on Windows + * but if you add dll, you end up with stuff like 'System.Xml.dll.dll.' + +These things need fixing in the Prebuild source. Now, the good news is that prebuild is very straight forward, so we should be able to fix what we need in the tool and submit the changes to the Prebuild team. + diff --git a/VERSION b/VERSION deleted file mode 100644 index 153b50b664..0000000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.1.0.240 \ No newline at end of file diff --git a/genvers.sh b/genvers.sh deleted file mode 100755 index 9bd8eff567..0000000000 --- a/genvers.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -MAJOR=0 -MINOR=1 -BUILD=`date +%s` -REVISION=`svnversion . | sed s/:// | sed s/M//` -REALREVISION=`svnversion` -cat src/VersionInfo.cs.template | sed s/@@VERSION/"$MAJOR.$MINOR, Build $BUILD, Revision $REALREVISION"/g >src/VersionInfo.cs -echo -n $MAJOR.$MINOR.0.$REVISION >VERSION diff --git a/ogs/assetserver/assets/00000000000000005005000000000005/data b/ogs/assetserver/assets/00000000000000005005000000000005/data deleted file mode 100644 index e6840e2139edfa1faac4a36323d94be3f2ff2f70..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 291 zcmezG|38pHp8*6Epcupk0R<=qu^AYc*%=uj=zkCc4^V)Sk(Gsof$@I~1FItg!~Y2k zTwrxKfkNmCgdH3_JOYr>|H<9PlNRC@l$O%!1-tK_ctpXXB(X5HaU6t*vk6(ErKjmnd*d{=eq%10J^jYYy}<{$F$Okoz$q{vHJe`TuKJ z>i@4{wg-xRZ0TR3B5&Zp2^3(r{=bH!`u~~*1qn<*oiF+Mm)OXA6mW~qW7Gb>h9~&U zF`y3K*JXjsP+1e8EDwv=10bI}P3EJfod9#-%yoLm?Q70pv>**yzQNDC>QJX zi$NSS&Hk^ED(&Aj$!nL!!EzGuFjUQQ8<7@qdlvX1>YG<FX51%gDVp^$4Ef}IV)wQc7w^8hmB4DOXIGN&{z>oJs%bi^_gjX=8?H-smddz(nx$|k&hYsh+2V9z)6hC>CH=Iok3rQ}gV H!~dHAp6clh diff --git a/ogs/assetserver/assets/66c41e3938f9f75a024e585989bfab73/data b/ogs/assetserver/assets/66c41e3938f9f75a024e585989bfab73/data deleted file mode 100644 index 920c7758c4..0000000000 --- a/ogs/assetserver/assets/66c41e3938f9f75a024e585989bfab73/data +++ /dev/null @@ -1,105 +0,0 @@ -LLWearable version 22 -Female Shape and Outfit 3 Shape -Created by system from avatar's appearance. - permissions 0 - { - base_mask 00082000 - owner_mask 00082000 - group_mask 00082000 - everyone_mask 00082000 - next_owner_mask 00082000 - creator_id 3d924400-038e-6ad9-920b-cfbb9b40585c - owner_id 542ffb8e-8932-49b9-8664-58f53e442797 - last_owner_id 3d924400-038e-6ad9-920b-cfbb9b40585c - group_id 00000000-0000-0000-0000-000000000000 - } - sale_info 0 - { - sale_type not - sale_price 0 - } -type 0 -parameters 82 -1 .21 -2 -.5 -4 -.11 -5 -.1 -6 -.3 -7 -.4 -8 -.5 -10 .7 -11 .34 -12 -.5 -13 0 -14 .04 -15 .58 -17 .56 -18 -.26 -19 -.73 -20 -.34 -21 -.01 -22 1 -23 -.5 -24 -.63 -25 .44 -27 .05 -33 -.24 -34 -.7 -35 -.16 -36 -.2 -37 -.98 -38 -.5 -80 0 -105 .07 -155 -.22 -157 0 -185 -1 -193 .86 -196 -.74 -505 .65 -506 .12 -507 -1.5 -515 0 -517 .16 -518 .8 -629 0 -637 0 -646 .4 -647 1 -649 .36 -650 .85 -652 .49 -653 -1 -656 0 -659 .65 -662 .5 -663 0 -664 0 -665 0 -675 -.15 -676 .26 -678 .28 -682 .27 -683 -.19 -684 -.09 -685 0 -690 .45 -692 .4 -693 -0 -753 -.5 -756 -.08 -758 .24 -759 .6 -760 .11 -764 -.38 -765 -.3 -769 .42 -773 .51 -795 .16 -796 .11 -799 .36 -841 0 -842 -.82 -879 0 -880 0 -textures 0 diff --git a/ogs/assetserver/assets/e0ee49b5a4184df8d3c9a65361fe7f49/data b/ogs/assetserver/assets/e0ee49b5a4184df8d3c9a65361fe7f49/data deleted file mode 100644 index 95cc683422..0000000000 --- a/ogs/assetserver/assets/e0ee49b5a4184df8d3c9a65361fe7f49/data +++ /dev/null @@ -1,52 +0,0 @@ -LLWearable version 22 -Sexy - Female Skin - - permissions 0 - { - base_mask 00086000 - owner_mask 00086000 - group_mask 00000000 - everyone_mask 00000000 - next_owner_mask 00086000 - creator_id 3b659a92-dbf0-4301-8fdc-208d78f00d77 - owner_id 3d924400-038e-6ad9-920b-cfbb9b40585c - last_owner_id 101358d5-469d-4b24-9b85-4dc3c05e635d - group_id 00000000-0000-0000-0000-000000000000 - } - sale_info 0 - { - sale_type not - sale_price 10 - } -type 1 -parameters 26 -108 0 -110 0 -111 0 -116 0 -117 1 -150 0 -162 0 -163 0 -165 0 -700 .01 -701 .5 -702 .26 -703 0 -704 0 -705 .5 -706 .6 -707 0 -708 0 -709 0 -710 0 -711 .5 -712 0 -713 .7 -714 0 -715 0 -775 0 -textures 3 -0 f9261672-5058-9ef8-c0c4-48f43a0b16d4 -5 b6ba53be-b5bf-9a1f-2e19-21daf998429c -6 703f6e24-a1fb-1980-acaf-6ab8a99a5bd5 diff --git a/ogs/common/src/Util.cs b/ogs/common/src/Util.cs deleted file mode 100644 index 1efa4715aa..0000000000 --- a/ogs/common/src/Util.cs +++ /dev/null @@ -1,87 +0,0 @@ -/* -Copyright (c) OpenSim project, http://osgrid.org/ - -* Copyright (c) , -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; -using System.Collections.Generic; -using System.Threading; -using libsecondlife; -using libsecondlife.Packets; - -namespace OpenGridServices -{ - /// - /// - /// - public class Util - { - public static ulong UIntsToLong(uint X, uint Y) - { - return Helpers.UIntsToLong(X,Y); - } - public Util() - { - - } - } - - public class QueItem { - public QueItem() - { - } - - public Packet Packet; - public bool Incoming; - } - - - public class BlockingQueue< T > { - private Queue< T > _queue = new Queue< T >(); - private object _queueSync = new object(); - - public void Enqueue(T value) - { - lock(_queueSync) - { - _queue.Enqueue(value); - Monitor.Pulse(_queueSync); - } - } - - public T Dequeue() - { - lock(_queueSync) - { - if( _queue.Count < 1) - Monitor.Wait(_queueSync); - - return _queue.Dequeue(); - } - } - } -} diff --git a/ogs/genvers.sh b/ogs/genvers.sh deleted file mode 100644 index 8d8007c920..0000000000 --- a/ogs/genvers.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -MAJOR=0 -MINOR=1 -BUILD=`date +%s` -REVISION=`svnversion . | sed s/:// | sed s/M//` -REALREVISION=`svnversion` -cat common/src/VersionInfo.cs.template | sed s/@@VERSION/"$MAJOR.$MINOR, Build $BUILD, Revision $REALREVISION"/g >common/src/VersionInfo.cs -echo -n $MAJOR.$MINOR.*.$REVISION >VERSION diff --git a/ogs/ogs.build b/ogs/ogs.build deleted file mode 100644 index 303b1bfdb3..0000000000 --- a/ogs/ogs.build +++ /dev/null @@ -1,38 +0,0 @@ - - - nant buildfile for OpenSim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ogs/userserver/default.build b/ogs/userserver/default.build deleted file mode 100644 index a56f92538e..0000000000 --- a/ogs/userserver/default.build +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ogs/userserver/src/UserHttp.cs b/ogs/userserver/src/UserHttp.cs deleted file mode 100644 index bc232fb8cc..0000000000 --- a/ogs/userserver/src/UserHttp.cs +++ /dev/null @@ -1,287 +0,0 @@ -/* -Copyright (c) OpenGrid project, http://osgrid.org/ - - -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; -using System.Text; -using Nwc.XmlRpc; -using System.Threading; -using System.Text.RegularExpressions; -using System.Net; -using System.IO; -using System.Collections; -using System.Collections.Generic; -using libsecondlife; -using ServerConsole; - -namespace OpenGridServices -{ - public class UserHTTPServer { - public Thread HTTPD; - public HttpListener Listener; - - public UserHTTPServer() { - ServerConsole.MainConsole.Instance.WriteLine("Starting up HTTP Server"); - HTTPD = new Thread(new ThreadStart(StartHTTP)); - HTTPD.Start(); - } - - public void StartHTTP() { - ServerConsole.MainConsole.Instance.WriteLine("UserHttp.cs:StartHTTP() - Spawned main thread OK"); - Listener = new HttpListener(); - - Listener.Prefixes.Add("http://+:8002/userserver/"); - Listener.Prefixes.Add("http://+:8002/usersessions/"); - Listener.Start(); - - HttpListenerContext context; - while(true) { - context = Listener.GetContext(); - ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context); - } - } - - static string ParseXMLRPC(string requestBody) { - XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); - - Hashtable requestData = (Hashtable)request.Params[0]; - switch(request.MethodName) { - case "login_to_simulator": - bool GoodXML= (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); - bool GoodLogin=false; - string firstname=""; - string lastname=""; - string passwd=""; - - if(GoodXML) { - firstname=(string)requestData["first"]; - lastname=(string)requestData["last"]; - passwd=(string)requestData["passwd"]; - GoodLogin=OpenUser_Main.userserver._profilemanager.AuthenticateUser(firstname,lastname,passwd); - } - - - if(!(GoodXML && GoodLogin)) { - XmlRpcResponse LoginErrorResp = new XmlRpcResponse(); - Hashtable ErrorRespData = new Hashtable(); - ErrorRespData["reason"]="key"; - ErrorRespData["message"]="Error connecting to grid. Please double check your login details and check with the grid owner if you are sure these are correct"; - ErrorRespData["login"]="false"; - LoginErrorResp.Value=ErrorRespData; - return(Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(LoginErrorResp)," encoding=\"utf-16\"","" )); - } - - UserProfile TheUser=OpenUser_Main.userserver._profilemanager.GetProfileByName(firstname,lastname); - - if(!((TheUser.CurrentSessionID==null) && (TheUser.CurrentSecureSessionID==null))) { - XmlRpcResponse PresenceErrorResp = new XmlRpcResponse(); - Hashtable PresenceErrorRespData = new Hashtable(); - PresenceErrorRespData["reason"]="presence"; - PresenceErrorRespData["message"]="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"; - PresenceErrorRespData["login"]="false"; - PresenceErrorResp.Value=PresenceErrorRespData; - return(Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp)," encoding=\"utf-16\"","" )); - - } - - try { - LLUUID AgentID = TheUser.UUID; - TheUser.InitSessionData(); - SimProfile SimInfo = new SimProfile(); - SimInfo = SimInfo.LoadFromGrid(TheUser.homeregionhandle,OpenUser_Main.userserver.GridURL,OpenUser_Main.userserver.GridSendKey,OpenUser_Main.userserver.GridRecvKey); - - XmlRpcResponse LoginGoodResp = new XmlRpcResponse(); - Hashtable LoginGoodData = new Hashtable(); - - Hashtable GlobalT = new Hashtable(); - GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271"; - GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; - GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; - ArrayList GlobalTextures = new ArrayList(); - GlobalTextures.Add(GlobalT); - - Hashtable LoginFlagsHash = new Hashtable(); - LoginFlagsHash["daylight_savings"]="N"; - LoginFlagsHash["stipend_since_login"]="N"; - LoginFlagsHash["gendered"]="Y"; - LoginFlagsHash["ever_logged_in"]="Y"; - ArrayList LoginFlags=new ArrayList(); - LoginFlags.Add(LoginFlagsHash); - - Hashtable uiconfig = new Hashtable(); - uiconfig["allow_first_life"]="Y"; - ArrayList ui_config=new ArrayList(); - ui_config.Add(uiconfig); - - Hashtable ClassifiedCategoriesHash = new Hashtable(); - ClassifiedCategoriesHash["category_name"]="bla bla"; - ClassifiedCategoriesHash["category_id"]=(Int32)1; - ArrayList ClassifiedCategories = new ArrayList(); - ClassifiedCategories.Add(ClassifiedCategoriesHash); - - ArrayList AgentInventory = new ArrayList(); - foreach(InventoryFolder InvFolder in TheUser.InventoryFolders.Values) { - Hashtable TempHash = new Hashtable(); - TempHash["name"]=InvFolder.FolderName; - TempHash["parent_id"]=InvFolder.ParentID.ToStringHyphenated(); - TempHash["version"]=(Int32)InvFolder.Version; - TempHash["type_default"]=(Int32)InvFolder.DefaultType; - TempHash["folder_id"]=InvFolder.FolderID.ToStringHyphenated(); - AgentInventory.Add(TempHash); - } - - Hashtable InventoryRootHash = new Hashtable(); - InventoryRootHash["folder_id"]=TheUser.InventoryRoot.FolderID.ToStringHyphenated(); - ArrayList InventoryRoot = new ArrayList(); - InventoryRoot.Add(InventoryRootHash); - - Hashtable InitialOutfitHash = new Hashtable(); - InitialOutfitHash["folder_name"]="Nightclub Female"; - InitialOutfitHash["gender"]="female"; - ArrayList InitialOutfit = new ArrayList(); - InitialOutfit.Add(InitialOutfitHash); - - uint circode = (uint)(new Random()).Next(); - TheUser.AddSimCircuit(circode, SimInfo.UUID); - - LoginGoodData["last_name"]="\"" + TheUser.firstname + "\""; - LoginGoodData["ui-config"]=ui_config; - LoginGoodData["sim_ip"]=SimInfo.sim_ip.ToString(); - LoginGoodData["login-flags"]=LoginFlags; - LoginGoodData["global-textures"]=GlobalTextures; - LoginGoodData["classified_categories"]=ClassifiedCategories; - LoginGoodData["event_categories"]=new ArrayList(); - LoginGoodData["inventory-skeleton"]=AgentInventory; - LoginGoodData["inventory-skel-lib"]=new ArrayList(); - LoginGoodData["inventory-root"]=InventoryRoot; - LoginGoodData["event_notifications"]=new ArrayList(); - LoginGoodData["gestures"]=new ArrayList(); - LoginGoodData["inventory-lib-owner"]=new ArrayList(); - LoginGoodData["initial-outfit"]=InitialOutfit; - LoginGoodData["seconds_since_epoch"]=(Int32)(DateTime.UtcNow - new DateTime(1970,1,1)).TotalSeconds; - LoginGoodData["start_location"]="last"; - LoginGoodData["home"]="{'region_handle':[r" + (SimInfo.RegionLocX*256).ToString() + ",r" + (SimInfo.RegionLocY*256).ToString() + "], 'position':[r" + TheUser.homepos.X.ToString() + ",r" + TheUser.homepos.Y.ToString() + ",r" + TheUser.homepos.Z.ToString() + "], 'look_at':[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]}"; - LoginGoodData["message"]=OpenUser_Main.userserver.DefaultStartupMsg; - LoginGoodData["first_name"]="\"" + firstname + "\""; - LoginGoodData["circuit_code"]=(Int32)circode; - LoginGoodData["sim_port"]=(Int32)SimInfo.sim_port; - LoginGoodData["secure_session_id"]=TheUser.CurrentSecureSessionID.ToStringHyphenated(); - LoginGoodData["look_at"]="\n[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]\n"; - LoginGoodData["agent_id"]=AgentID.ToStringHyphenated(); - LoginGoodData["region_y"]=(Int32)SimInfo.RegionLocY*256; - LoginGoodData["region_x"]=(Int32)SimInfo.RegionLocX*256; - LoginGoodData["seed_capability"]=null; - LoginGoodData["agent_access"]="M"; - LoginGoodData["session_id"]=TheUser.CurrentSessionID.ToStringHyphenated(); - LoginGoodData["login"]="true"; - - LoginGoodResp.Value=LoginGoodData; - TheUser.SendDataToSim(SimInfo); - return(Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(LoginGoodResp),"utf-16","utf-8" )); - - } catch (Exception E) { - Console.WriteLine(E.ToString()); - } - - break; - } - - return ""; - } - - static string ParseREST(HttpListenerRequest www_req) { - Console.WriteLine("INCOMING REST - " + www_req.RawUrl); - - char[] splitter = {'/'}; - string[] rest_params = www_req.RawUrl.Split(splitter); - string req_type = rest_params[1]; // First part of the URL is the type of request - usersessions/userprofiles/inventory/blabla - switch(req_type) { - case "usersessions": - LLUUID sessionid = new LLUUID(rest_params[2]); // get usersessions/sessionid - if(www_req.HttpMethod=="DELETE") { - foreach (libsecondlife.LLUUID UUID in OpenUser_Main.userserver._profilemanager.UserProfiles.Keys) { - if(OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID==sessionid) { - OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID=null; - OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSecureSessionID=null; - OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].Circuits.Clear(); - } - } - - } - return "OK"; - break; - } - - return ""; - } - - - static void HandleRequest(Object stateinfo) { - HttpListenerContext context=(HttpListenerContext)stateinfo; - - HttpListenerRequest request = context.Request; - HttpListenerResponse response = context.Response; - - response.KeepAlive=false; - response.SendChunked=false; - - System.IO.Stream body = request.InputStream; - System.Text.Encoding encoding = System.Text.Encoding.UTF8; - System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding); - - string requestBody = reader.ReadToEnd(); - body.Close(); - reader.Close(); - - string responseString=""; - switch(request.ContentType) { - case "text/xml": - // must be XML-RPC, so pass to the XML-RPC parser - - responseString=ParseXMLRPC(requestBody); - response.AddHeader("Content-type","text/xml"); - break; - - case "text/plaintext": - responseString=ParseREST(request); - response.AddHeader("Content-type","text/plaintext"); - break; - } - - - byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString); - System.IO.Stream output = response.OutputStream; - response.SendChunked=false; - response.ContentLength64=buffer.Length; - output.Write(buffer,0,buffer.Length); - output.Close(); - } - } - - -} diff --git a/ogs/userserver/src/UserProfiles.cs b/ogs/userserver/src/UserProfiles.cs deleted file mode 100644 index 4586ab3e73..0000000000 --- a/ogs/userserver/src/UserProfiles.cs +++ /dev/null @@ -1,223 +0,0 @@ -/* -Copyright (c) OpenGrid project, http://osgrid.org/ - - -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; -using System.Text; -using System.Collections; -using System.Collections.Generic; -using libsecondlife; -using Nwc.XmlRpc; -using ServerConsole; - -namespace OpenGridServices -{ - /// - /// - public class UserProfileManager { - - public Dictionary UserProfiles = new Dictionary(); - - public UserProfileManager() { - } - - public void InitUserProfiles() { - // TODO: need to load from database - } - - public UserProfile GetProfileByName(string firstname, string lastname) { - foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys) { - if((UserProfiles[UUID].firstname==firstname) && (UserProfiles[UUID].lastname==lastname)) return UserProfiles[UUID]; - } - return null; - } - - public UserProfile GetProfileByLLUUID(LLUUID ProfileLLUUID) { - return UserProfiles[ProfileLLUUID]; - } - - public bool AuthenticateUser(string firstname, string lastname, string passwd) { - UserProfile TheUser=GetProfileByName(firstname, lastname); - if(TheUser != null) - if(TheUser.MD5passwd==passwd) { - return true; - } else { - return false; - } else return false; - - } - - public void SetGod(LLUUID GodID) { - this.UserProfiles[GodID].IsGridGod=true; - } - - public UserProfile CreateNewProfile(string firstname, string lastname, string MD5passwd) { - UserProfile newprofile = new UserProfile(); - newprofile.homeregionhandle=Util.UIntsToLong((997*256), (996*256)); - newprofile.firstname=firstname; - newprofile.lastname=lastname; - newprofile.MD5passwd=MD5passwd; - newprofile.UUID=LLUUID.Random(); - this.UserProfiles.Add(newprofile.UUID,newprofile); - return newprofile; - } - - } - - public class UserProfile { - - public string firstname; - public string lastname; - public ulong homeregionhandle; - public LLVector3 homepos; - public LLVector3 homelookat; - - public bool IsGridGod=false; - public bool IsLocal=true; // will be used in future for visitors from foreign grids - public string AssetURL; - public string MD5passwd; - - public LLUUID CurrentSessionID; - public LLUUID CurrentSecureSessionID; - public LLUUID UUID; - public Dictionary Circuits = new Dictionary(); // tracks circuit codes - - public InventoryFolder InventoryRoot; - public Dictionary InventoryFolders; - public Dictionary InventoryItems; - - public UserProfile() { - Circuits = new Dictionary(); - InventoryFolders = new Dictionary(); - InventoryItems = new Dictionary(); - InventoryRoot=new InventoryFolder(); - InventoryRoot.FolderID = LLUUID.Random(); - InventoryRoot.ParentID=new LLUUID(); - InventoryRoot.Version=1; - InventoryRoot.DefaultType=8; - InventoryRoot.FolderName="My Inventory"; - InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot); - homeregionhandle=Util.UIntsToLong((997*256), (996*256));; - } - - public void InitSessionData() { - CurrentSessionID=LLUUID.Random(); - CurrentSecureSessionID=LLUUID.Random(); - } - - public void AddSimCircuit(uint circuit_code, LLUUID region_UUID) { - if(this.Circuits.ContainsKey(region_UUID)== false) - this.Circuits.Add(region_UUID, circuit_code); - } - - public void SendDataToSim(SimProfile TheSim) { - Console.WriteLine(TheSim.caps_url); - Hashtable SimParams = new Hashtable(); - SimParams["session_id"]=this.CurrentSessionID.ToString(); - SimParams["secure_session_id"]=this.CurrentSecureSessionID.ToString(); - SimParams["firstname"]=this.firstname; - SimParams["lastname"]=this.lastname; - SimParams["agent_id"]=this.UUID.ToString(); - SimParams["circuit_code"]=(Int32)this.Circuits[TheSim.UUID]; - ArrayList SendParams = new ArrayList(); - SendParams.Add(SimParams); - - XmlRpcRequest GridReq = new XmlRpcRequest("expect_user",SendParams); - XmlRpcResponse GridResp = GridReq.Send(TheSim.caps_url,3000); - } - } - - public class InventoryFolder { - public LLUUID FolderID; - public LLUUID ParentID; - public string FolderName; - public ushort DefaultType; - public ushort Version; - } - - public class InventoryItem { //TODO: Fixup this and add full permissions etc - public LLUUID FolderID; - public LLUUID OwnerID; - public LLUUID ItemID; - public LLUUID AssetID; - public LLUUID CreatorID = LLUUID.Zero; - public sbyte InvType; - public sbyte Type; - public string Name; - public string Description; - } - - public class SimProfile { - public LLUUID UUID; - public ulong regionhandle; - public string regionname; - public string sim_ip; - public uint sim_port; - public string caps_url; - public uint RegionLocX; - public uint RegionLocY; - public string sendkey; - public string recvkey; - - - public SimProfile LoadFromGrid(ulong region_handle, string GridURL, string SendKey, string RecvKey) { - try { - Hashtable GridReqParams = new Hashtable(); - GridReqParams["region_handle"]=region_handle.ToString(); - GridReqParams["caller"]="userserver"; - GridReqParams["authkey"]=SendKey; - ArrayList SendParams = new ArrayList(); - SendParams.Add(GridReqParams); - XmlRpcRequest GridReq = new XmlRpcRequest("get_sim_info",SendParams); - - XmlRpcResponse GridResp = GridReq.Send(GridURL,3000); - - Hashtable RespData=(Hashtable)GridResp.Value; - this.UUID = new LLUUID((string)RespData["UUID"]); - this.regionhandle = (ulong)Convert.ToUInt64(RespData["regionhandle"]); - this.regionname=(string)RespData["regionname"]; - this.sim_ip=(string)RespData["sim_ip"]; - this.sim_port=(uint)Convert.ToUInt16(RespData["sim_port"]); - this.caps_url=(string)RespData["caps_url"]; - this.RegionLocX=(uint)Convert.ToUInt32(RespData["RegionLocX"]); - this.RegionLocY=(uint)Convert.ToUInt32(RespData["RegionLocY"]); - this.sendkey=(string)RespData["sendkey"]; - this.recvkey=(string)RespData["recvkey"]; - } catch(Exception e) { - Console.WriteLine(e.ToString()); - } - return this; - } - - public SimProfile() { - } - - - } - -} diff --git a/ogs/userserver/src/Util.cs b/ogs/userserver/src/Util.cs deleted file mode 100644 index 1efa4715aa..0000000000 --- a/ogs/userserver/src/Util.cs +++ /dev/null @@ -1,87 +0,0 @@ -/* -Copyright (c) OpenSim project, http://osgrid.org/ - -* Copyright (c) , -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; -using System.Collections.Generic; -using System.Threading; -using libsecondlife; -using libsecondlife.Packets; - -namespace OpenGridServices -{ - /// - /// - /// - public class Util - { - public static ulong UIntsToLong(uint X, uint Y) - { - return Helpers.UIntsToLong(X,Y); - } - public Util() - { - - } - } - - public class QueItem { - public QueItem() - { - } - - public Packet Packet; - public bool Incoming; - } - - - public class BlockingQueue< T > { - private Queue< T > _queue = new Queue< T >(); - private object _queueSync = new object(); - - public void Enqueue(T value) - { - lock(_queueSync) - { - _queue.Enqueue(value); - Monitor.Pulse(_queueSync); - } - } - - public T Dequeue() - { - lock(_queueSync) - { - if( _queue.Count < 1) - Monitor.Wait(_queueSync); - - return _queue.Dequeue(); - } - } - } -} diff --git a/opensim.build b/opensim.build deleted file mode 100644 index 41c2e661f5..0000000000 --- a/opensim.build +++ /dev/null @@ -1,82 +0,0 @@ - - - nant buildfile for OpenSim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/prebuild.xml b/prebuild.xml new file mode 100644 index 0000000000..ca3ac2f359 --- /dev/null +++ b/prebuild.xml @@ -0,0 +1,326 @@ + + + + + + TRACE;DEBUG + false + false + false + 4 + false + + bin + true + true + false + + + + + TRACE + true + false + false + 4 + false + + bin + false + true + false + + + + + + + + + ../bin/ + + + + + ../bin/ + + + + ../bin/ + + + + + + + + + + + + ../bin/ + + + + + ../bin/ + + + + ../bin/ + + + + + + + + + + ../../bin/ + + + + + ../../bin/ + + + + ../../bin/ + + + + + + + + + + + + + + ../../bin/ + + + + + ../../bin/ + + + + ../../bin/ + + + + + + + + + + + + + + + + + ../../bin/ + + + + + ../../bin/ + + + + ../../bin/ + + + + + + + + + + + + + + + ../../bin/ + + + + + ../../bin/ + + + + ../../bin/ + + + + + + + + + + + + + + + ../../bin/Physics/ + + + + + ../../bin/Physics/ + + + + ../../bin/ + + + + + + + + + + + + ../../bin/Physics/ + + + + + ../../bin/Physics/ + + + + ../../bin/ + + + + + + + + + + + + + + ../bin/ + + + + + ../bin/ + + + + ../bin/ + + + + + + + + + + + + + + + + + + + ../../bin/ + + + + + ../../bin/ + + + + ../../bin/ + + + + + + + + + + + + + + + DEBUG;TRACE + false + bin/Debug + true + 1595 + + + + + TRACE + bin/Release + true + false + 1595 + + + + prebuild.xml + prebuild + + + + + DEBUG;TRACE + false + ..\bin\ + true + Prebuild.snk + 1595 + + + + + TRACE + ..\bin\ + true + false + Prebuild.snk + 1595 + + + + + + + + + + + + + + + diff --git a/src/AssemblyInfo.cs b/src/AssemblyInfo.cs deleted file mode 100644 index b88eb7582d..0000000000 --- a/src/AssemblyInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.InteropServices; - -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -[assembly: ComVisibleAttribute(false)] -[assembly: CLSCompliantAttribute(false)] -[assembly: AssemblyVersionAttribute("0.0.0.1")] -[assembly: AssemblyTitleAttribute("opensim")] -[assembly: AssemblyDescriptionAttribute("The C# implementation of the simulator portion of OGS")] -[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] - diff --git a/src/Assets/AssetCache.cs b/src/Assets/AssetCache.cs deleted file mode 100644 index d35b4828c6..0000000000 --- a/src/Assets/AssetCache.cs +++ /dev/null @@ -1,436 +0,0 @@ -/* -* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using System; -using System.Collections.Generic; -using System.Threading; -using libsecondlife; -using libsecondlife.Packets; -using OpenSim; -using OpenSim.GridServers; - -namespace OpenSim.Assets -{ - /// - /// Manages local cache of assets and their sending to viewers. - /// - public class AssetCache : IAssetReceiver - { - public Dictionary Assets; - public Dictionary Textures; - - public List AssetRequests = new List(); //assets ready to be sent to viewers - public List TextureRequests = new List(); //textures ready to be sent - - public Dictionary RequestedAssets = new Dictionary(); //Assets requested from the asset server - public Dictionary RequestedTextures = new Dictionary(); //Textures requested from the asset server - - private IAssetServer _assetServer; - private Thread _assetCacheThread; - - /// - /// - /// - public AssetCache( IAssetServer assetServer) - { - _assetServer = assetServer; - _assetServer.SetReceiver(this); - Assets = new Dictionary (); - Textures = new Dictionary (); - this._assetCacheThread = new Thread( new ThreadStart(RunAssetManager)); - this._assetCacheThread.IsBackground = true; - this._assetCacheThread.Start(); - } - - /// - /// - /// - private void RunAssetManager() - { - this.ProcessAssetQueue(); - this.ProcessTextureQueue(); - Thread.Sleep(100); - } - - /// - /// - /// - private void ProcessTextureQueue() - { - if(this.TextureRequests.Count == 0) - { - //no requests waiting - return; - } - int num; - - if(this.TextureRequests.Count < 5) - { - //lower than 5 so do all of them - num = this.TextureRequests.Count; - } - else - { - num=5; - } - AssetRequest req; - for(int i = 0; i < num; i++) - { - req=(AssetRequest)this.TextureRequests[i]; - - if(req.PacketCounter == 0) - { - //first time for this request so send imagedata packet - if(req.NumPackets == 1) - { - //only one packet so send whole file - ImageDataPacket im = new ImageDataPacket(); - im.ImageID.Packets = 1; - im.ImageID.ID = req.ImageInfo.FullID; - im.ImageID.Size = (uint)req.ImageInfo.Data.Length; - im.ImageData.Data = req.ImageInfo.Data; - im.ImageID.Codec = 2; - req.RequestUser.OutPacket(im); - req.PacketCounter++; - //req.ImageInfo.l= time; - //System.Console.WriteLine("sent texture: "+req.image_info.FullID); - } - else - { - //more than one packet so split file up - ImageDataPacket im = new ImageDataPacket(); - im.ImageID.Packets = (ushort)req.NumPackets; - im.ImageID.ID = req.ImageInfo.FullID; - im.ImageID.Size = (uint)req.ImageInfo.Data.Length; - im.ImageData.Data = new byte[600]; - Array.Copy(req.ImageInfo.Data, 0, im.ImageData.Data, 0, 600); - im.ImageID.Codec = 2; - req.RequestUser.OutPacket(im); - req.PacketCounter++; - //req.ImageInfo.last_used = time; - //System.Console.WriteLine("sent first packet of texture: - } - } - else - { - //send imagepacket - //more than one packet so split file up - ImagePacketPacket im = new ImagePacketPacket(); - im.ImageID.Packet = (ushort)req.PacketCounter; - im.ImageID.ID = req.ImageInfo.FullID; - int size = req.ImageInfo.Data.Length - 600 - 1000*(req.PacketCounter - 1); - if(size > 1000) size = 1000; - im.ImageData.Data = new byte[size]; - Array.Copy(req.ImageInfo.Data, 600 + 1000*(req.PacketCounter - 1), im.ImageData.Data, 0, size); - req.RequestUser.OutPacket(im); - req.PacketCounter++; - //req.ImageInfo.last_used = time; - //System.Console.WriteLine("sent a packet of texture: "+req.image_info.FullID); - } - } - - //remove requests that have been completed - int count = 0; - for(int i = 0; i < num; i++) - { - req=(AssetRequest)this.TextureRequests[count]; - if(req.PacketCounter == req.NumPackets) - { - this.TextureRequests.Remove(req); - } - else - { - count++; - } - } - - } - public void AssetReceived(AssetBase asset, bool IsTexture) - { - //check if it is a texture or not - //then add to the correct cache list - //then check for waiting requests for this asset/texture (in the Requested lists) - //and move those requests into the Requests list. - if(IsTexture) - { - TextureImage image = new TextureImage(asset); - this.Textures.Add(image.FullID, image); - if(this.RequestedTextures.ContainsKey(image.FullID)) - { - AssetRequest req = this.RequestedTextures[image.FullID]; - req.ImageInfo = image; - this.RequestedTextures.Remove(image.FullID); - this.TextureRequests.Add(req); - } - } - else - { - AssetInfo assetInf = new AssetInfo(asset); - this.Assets.Add(assetInf.FullID, assetInf); - if(this.RequestedAssets.ContainsKey(assetInf.FullID)) - { - AssetRequest req = this.RequestedAssets[assetInf.FullID]; - req.AssetInf = assetInf; - this.RequestedAssets.Remove(assetInf.FullID); - this.AssetRequests.Add(req); - } - } - } - - public void AssetNotFound(AssetBase asset) - { - //the asset server had no knowledge of requested asset - - } - - #region Assets - /// - /// - /// - /// - /// - public void AddAssetRequest(OpenSimClient userInfo, TransferRequestPacket transferRequest) - { - LLUUID requestID = new LLUUID(transferRequest.TransferInfo.Params, 0); - //check to see if asset is in local cache, if not we need to request it from asset server. - if(!this.Assets.ContainsKey(requestID)) - { - //not found asset - // so request from asset server - AssetRequest request = new AssetRequest(); - request.RequestUser = userInfo; - request.RequestAssetID = requestID; - request.TransferRequestID = transferRequest.TransferInfo.TransferID; - this.RequestedAssets.Add(requestID,request); - this._assetServer.RequestAsset(requestID, false); - return; - } - //it is in our cache - AssetInfo asset = this.Assets[requestID]; - - //work out how many packets it should be sent in - // and add to the AssetRequests list - AssetRequest req = new AssetRequest(); - req.RequestUser = userInfo; - req.RequestAssetID = requestID; - req.TransferRequestID = transferRequest.TransferInfo.TransferID; - req.AssetInf = asset; - - if(asset.Data.LongLength>600) - { - //over 600 bytes so split up file - req.NumPackets = 1 + (int)(asset.Data.Length-600+999)/1000; - } - else - { - req.NumPackets = 1; - } - - this.AssetRequests.Add(req); - } - - /// - /// - /// - private void ProcessAssetQueue() - { - if(this.AssetRequests.Count == 0) - { - //no requests waiting - return; - } - int num; - - if(this.AssetRequests.Count < 5) - { - //lower than 5 so do all of them - num = this.AssetRequests.Count; - } - else - { - num=5; - } - AssetRequest req; - for(int i = 0; i < num; i++) - { - req=(AssetRequest)this.AssetRequests[i]; - - TransferInfoPacket Transfer = new TransferInfoPacket(); - Transfer.TransferInfo.ChannelType = 2; - Transfer.TransferInfo.Status = 0; - Transfer.TransferInfo.TargetType = 0; - Transfer.TransferInfo.Params = req.RequestAssetID.GetBytes(); - Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; - Transfer.TransferInfo.TransferID = req.TransferRequestID; - req.RequestUser.OutPacket(Transfer); - - if(req.NumPackets == 1) - { - TransferPacketPacket TransferPacket = new TransferPacketPacket(); - TransferPacket.TransferData.Packet = 0; - TransferPacket.TransferData.ChannelType = 2; - TransferPacket.TransferData.TransferID=req.TransferRequestID; - TransferPacket.TransferData.Data = req.AssetInf.Data; - TransferPacket.TransferData.Status = 1; - req.RequestUser.OutPacket(TransferPacket); - } - else - { - //more than one packet so split file up , for now it can't be bigger than 2000 bytes - TransferPacketPacket TransferPacket = new TransferPacketPacket(); - TransferPacket.TransferData.Packet = 0; - TransferPacket.TransferData.ChannelType = 2; - TransferPacket.TransferData.TransferID=req.TransferRequestID; - byte[] chunk = new byte[1000]; - Array.Copy(req.AssetInf.Data,chunk,1000); - TransferPacket.TransferData.Data = chunk; - TransferPacket.TransferData.Status = 0; - req.RequestUser.OutPacket(TransferPacket); - - TransferPacket = new TransferPacketPacket(); - TransferPacket.TransferData.Packet = 1; - TransferPacket.TransferData.ChannelType = 2; - TransferPacket.TransferData.TransferID = req.TransferRequestID; - byte[] chunk1 = new byte[(req.AssetInf.Data.Length-1000)]; - Array.Copy(req.AssetInf.Data, 1000, chunk1, 0, chunk1.Length); - TransferPacket.TransferData.Data = chunk1; - TransferPacket.TransferData.Status = 1; - req.RequestUser.OutPacket(TransferPacket); - } - - } - - //remove requests that have been completed - for(int i = 0; i < num; i++) - { - this.AssetRequests.RemoveAt(0); - } - - } - - #endregion - - #region Textures - /// - /// - /// - /// - /// - public void AddTextureRequest(OpenSimClient userInfo, LLUUID imageID) - { - //check to see if texture is in local cache, if not request from asset server - if(!this.Textures.ContainsKey(imageID)) - { - //not is cache so request from asset server - AssetRequest request = new AssetRequest(); - request.RequestUser = userInfo; - request.RequestAssetID = imageID; - request.IsTextureRequest = true; - this.RequestedTextures.Add(imageID, request); - this._assetServer.RequestAsset(imageID, true); - return; - } - TextureImage imag = this.Textures[imageID]; - AssetRequest req = new AssetRequest(); - req.RequestUser = userInfo; - req.RequestAssetID = imageID; - req.IsTextureRequest = true; - req.ImageInfo = imag; - - if(imag.Data.LongLength>600) - { - //over 600 bytes so split up file - req.NumPackets = 1 + (int)(imag.Data.Length-600+999)/1000; - } - else - { - req.NumPackets = 1; - } - - this.TextureRequests.Add(req); - } - #endregion - - } - - public class AssetRequest - { - public OpenSimClient RequestUser; - public LLUUID RequestAssetID; - public AssetInfo AssetInf; - public TextureImage ImageInfo; - public LLUUID TransferRequestID; - public long DataPointer = 0; - public int NumPackets = 0; - public int PacketCounter = 0; - public bool IsTextureRequest; - //public bool AssetInCache; - //public int TimeRequested; - - public AssetRequest() - { - - } - } - - public class AssetInfo : AssetBase - { - public AssetInfo() - { - - } - - public AssetInfo(AssetBase aBase) - { - Data= aBase.Data; - FullID = aBase.FullID; - Type = aBase.Type; - InvType = aBase.InvType; - Name= aBase.Name; - Description = aBase.Description; - } - } - - public class TextureImage : AssetBase - { - public TextureImage() - { - - } - - public TextureImage(AssetBase aBase) - { - Data= aBase.Data; - FullID = aBase.FullID; - Type = aBase.Type; - InvType = aBase.InvType; - Name= aBase.Name; - Description = aBase.Description; - } - } - -} diff --git a/src/CAPS/SimHttp.cs b/src/CAPS/SimHttp.cs deleted file mode 100644 index c0373de835..0000000000 --- a/src/CAPS/SimHttp.cs +++ /dev/null @@ -1,165 +0,0 @@ -/* -Copyright (c) OpenSimCAPS project, http://osgrid.org/ - - -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; -using System.Text; -using Nwc.XmlRpc; -using System.Threading; -using System.Text.RegularExpressions; -using System.Net; -using System.IO; -using System.Collections; -using System.Collections.Generic; -using libsecondlife; -using ServerConsole; -using OpenSim.GridServers; - -namespace OpenSim -{ - // Dummy HTTP server, does nothing useful for now - - public class SimCAPSHTTPServer { - public Thread HTTPD; - public HttpListener Listener; - - public SimCAPSHTTPServer() { - ServerConsole.MainConsole.Instance.WriteLine("Starting up HTTP Server"); - HTTPD = new Thread(new ThreadStart(StartHTTP)); - HTTPD.Start(); - } - - public void StartHTTP() { - try - { - ServerConsole.MainConsole.Instance.WriteLine("SimHttp.cs:StartHTTP() - Spawned main thread OK"); - Listener = new HttpListener(); - - Listener.Prefixes.Add("http://+:" + OpenSim_Main.cfg.IPListenPort + "/"); - Listener.Start(); - - HttpListenerContext context; - while(true) { - context = Listener.GetContext(); - ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context); - } - } - catch (Exception e) - { - ServerConsole.MainConsole.Instance.WriteLine(e.Message); - } - } - - static string ParseXMLRPC(string requestBody) { - try - { - XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); - - Hashtable requestData = (Hashtable)request.Params[0]; - switch(request.MethodName) { - case "expect_user": - GridServers.agentcircuitdata agent_data = new GridServers.agentcircuitdata(); - agent_data.SessionID = new LLUUID((string)requestData["session_id"]); - agent_data.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]); - agent_data.firstname = (string)requestData["firstname"]; - agent_data.lastname = (string)requestData["lastname"]; - agent_data.AgentID = new LLUUID((string)requestData["agent_id"]); - agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); - if (OpenSim_Main.gridServers.GridServer.GetName() == "Remote") - { - ((RemoteGridBase) OpenSim_Main.gridServers.GridServer).agentcircuits.Add((uint)agent_data.circuitcode,agent_data); - } - return ""; - break; - } - } - catch(Exception e) - { - Console.WriteLine(e.ToString()); - } - return ""; - } - - static string ParseREST(string requestBody, string requestURL) { - return ""; - } - - static string ParseLLSDXML(string requestBody) { - // dummy function for now - IMPLEMENT ME! - return ""; - } - - static void HandleRequest(Object stateinfo) { - HttpListenerContext context=(HttpListenerContext)stateinfo; - - HttpListenerRequest request = context.Request; - HttpListenerResponse response = context.Response; - - response.KeepAlive=false; - response.SendChunked=false; - - System.IO.Stream body = request.InputStream; - System.Text.Encoding encoding = System.Text.Encoding.UTF8; - System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding); - - string requestBody = reader.ReadToEnd(); - body.Close(); - reader.Close(); - - string responseString=""; - switch(request.ContentType) { - case "text/xml": - // must be XML-RPC, so pass to the XML-RPC parser - - responseString=ParseXMLRPC(requestBody); - response.AddHeader("Content-type","text/xml"); - break; - - case "application/xml": - // probably LLSD we hope, otherwise it should be ignored by the parser - responseString=ParseLLSDXML(requestBody); - response.AddHeader("Content-type","application/xml"); - break; - - case null: - // must be REST or invalid crap, so pass to the REST parser - responseString=ParseREST(request.Url.OriginalString,requestBody); - break; - } - - byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString); - System.IO.Stream output = response.OutputStream; - response.SendChunked=false; - response.ContentLength64=buffer.Length; - output.Write(buffer,0,buffer.Length); - output.Close(); - } - } - - -} diff --git a/src/Config/SimConfig/AssemblyInfo.cs b/src/Config/SimConfig/AssemblyInfo.cs deleted file mode 100644 index 7fabd63b2c..0000000000 --- a/src/Config/SimConfig/AssemblyInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.InteropServices; - -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -[assembly: ComVisibleAttribute(false)] -[assembly: CLSCompliantAttribute(false)] -[assembly: AssemblyVersionAttribute("0.1.0.240")] -[assembly: AssemblyTitleAttribute("opensim-simconfig")] -[assembly: AssemblyDescriptionAttribute("The default configuration handler")] -[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] - diff --git a/src/Config/SimConfig/Db4SimConfig.cs b/src/Config/SimConfig/Db4SimConfig.cs deleted file mode 100644 index 1b696fe279..0000000000 --- a/src/Config/SimConfig/Db4SimConfig.cs +++ /dev/null @@ -1,177 +0,0 @@ -/* -* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections.Generic; -using OpenSim; -using OpenSim.world; -using Db4objects.Db4o; - -namespace Db40SimConfig -{ - public class Db40ConfigPlugin: ISimConfig - { - public SimConfig GetConfigObject() - { - ServerConsole.MainConsole.Instance.WriteLine("Loading Db40Config dll"); - return ( new DbSimConfig()); - } - } - - public class DbSimConfig :SimConfig - { - private IObjectContainer db; - - public void LoadDefaults() { - ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings"); - - this.RegionName=ServerConsole.MainConsole.Instance.CmdPrompt("Name [OpenSim test]: ","OpenSim test"); - this.RegionLocX=(uint)Convert.ToInt32(ServerConsole.MainConsole.Instance.CmdPrompt("Grid Location X [997]: ","997")); - this.RegionLocY=(uint)Convert.ToInt32(ServerConsole.MainConsole.Instance.CmdPrompt("Grid Location Y [996]: ","996")); - this.IPListenPort=Convert.ToInt32(ServerConsole.MainConsole.Instance.CmdPrompt("UDP port for client connections [9000]: ","9000")); - this.IPListenAddr=ServerConsole.MainConsole.Instance.CmdPrompt("IP Address to listen on for client connections [127.0.0.1]: ","127.0.0.1"); - - if(!OpenSim_Main.sim.sandbox) - { - this.AssetURL=ServerConsole.MainConsole.Instance.CmdPrompt("Asset server URL: "); - this.AssetSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Asset server key: "); - this.GridURL=ServerConsole.MainConsole.Instance.CmdPrompt("Grid server URL: "); - this.GridSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to grid server: "); - this.GridRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from grid server: "); - this.UserURL=ServerConsole.MainConsole.Instance.CmdPrompt("User server URL: "); - this.UserSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to user server: "); - this.UserRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from user server: "); - } - this.RegionHandle = Util.UIntsToLong((RegionLocX*256), (RegionLocY*256)); - } - - public override void InitConfig() { - try { - db = Db4oFactory.OpenFile("opensim.yap"); - IObjectSet result = db.Get(typeof(DbSimConfig)); - if(result.Count==1) { - ServerConsole.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Found a SimConfig object in the local database, loading"); - foreach (DbSimConfig cfg in result) { - this.RegionName = cfg.RegionName; - this.RegionLocX = cfg.RegionLocX; - this.RegionLocY = cfg.RegionLocY; - this.RegionHandle = Util.UIntsToLong((RegionLocX*256), (RegionLocY*256)); - this.IPListenPort = cfg.IPListenPort; - this.IPListenAddr = cfg.IPListenAddr; - this.AssetURL = cfg.AssetURL; - this.AssetSendKey = cfg.AssetSendKey; - this.GridURL = cfg.GridURL; - this.GridSendKey = cfg.GridSendKey; - } - } else { - ServerConsole.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Could not find object in database, loading precompiled defaults"); - LoadDefaults(); - ServerConsole.MainConsole.Instance.WriteLine("Writing out default settings to local database"); - db.Set(this); - } - } catch(Exception e) { - db.Close(); - ServerConsole.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Exception occured"); - ServerConsole.MainConsole.Instance.WriteLine(e.ToString()); - } - - ServerConsole.MainConsole.Instance.WriteLine("Sim settings loaded:"); - ServerConsole.MainConsole.Instance.WriteLine("Name: " + this.RegionName); - ServerConsole.MainConsole.Instance.WriteLine("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]"); - ServerConsole.MainConsole.Instance.WriteLine("Region Handle: " + this.RegionHandle.ToString()); - ServerConsole.MainConsole.Instance.WriteLine("Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort); - ServerConsole.MainConsole.Instance.WriteLine("Sandbox Mode? " + OpenSim_Main.sim.sandbox.ToString()); - ServerConsole.MainConsole.Instance.WriteLine("Asset URL: " + this.AssetURL); - ServerConsole.MainConsole.Instance.WriteLine("Asset key: " + this.AssetSendKey); - ServerConsole.MainConsole.Instance.WriteLine("Grid URL: " + this.GridURL); - ServerConsole.MainConsole.Instance.WriteLine("Grid key: " + this.GridSendKey); - } - - public override World LoadWorld() - { - ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Loading world...."); - World blank = new World(); - ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Looking for a heightmap in local DB"); - IObjectSet world_result = db.Get(typeof(MapStorage)); - if(world_result.Count>0) { - ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Found a heightmap in local database, loading"); - MapStorage map=(MapStorage)world_result.Next(); - blank.LandMap = map.Map; - } else { - ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - No heightmap found, generating new one"); - HeightmapGenHills hills = new HeightmapGenHills(); - blank.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); - ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Saving heightmap to local database"); - MapStorage map= new MapStorage(); - map.Map = blank.LandMap; - db.Set(map); - db.Commit(); - } - return blank; - } - - public override void SaveMap() - { - IObjectSet world_result = db.Get(typeof(MapStorage)); - if(world_result.Count>0) { - ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - updating saved copy of heightmap in local database"); - MapStorage map=(MapStorage)world_result.Next(); - db.Delete(map); - } - MapStorage map1= new MapStorage(); - map1.Map = OpenSim_Main.local_world.LandMap; - db.Set(map1); - db.Commit(); - } - - public override void LoadFromGrid() { - ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadFromGrid() - dummy function, DOING ABSOLUTELY NOTHING AT ALL!!!"); - // TODO: Make this crap work - /* WebRequest GridLogin = WebRequest.Create(this.GridURL + "regions/" + this.RegionHandle.ToString() + "/login"); - WebResponse GridResponse = GridLogin.GetResponse(); - byte[] idata = new byte[(int)GridResponse.ContentLength]; - BinaryReader br = new BinaryReader(GridResponse.GetResponseStream()); - - br.Close(); - GridResponse.Close(); - */ - } - - public void Shutdown() { - db.Close(); - } - } - - public class MapStorage - { - public float[] Map; - - public MapStorage() - { - - } - } -} diff --git a/src/Config/SimConfig/SimConfig.csproj b/src/Config/SimConfig/SimConfig.csproj deleted file mode 100644 index 43e9499188..0000000000 --- a/src/Config/SimConfig/SimConfig.csproj +++ /dev/null @@ -1,52 +0,0 @@ - - - Library - SimConfig - SimConfig - Debug - AnyCPU - {B063760D-DB8D-4F64-B6FE-335FAD1E650A} - - - ..\..\..\bin\ - False - DEBUG;TRACE - True - Full - True - - - ..\..\..\bin\ - True - TRACE - False - None - False - - - - - - ..\..\..\bin\Db4objects.Db4o.dll - False - - - - - - - - {C9A6026D-8E0C-4FE4-8691-FB2A566AA245} - ServerConsole - - - {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E} - Second-server - - - {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9} - GridInterfaces - - - - \ No newline at end of file diff --git a/src/Config/default.build b/src/Config/default.build deleted file mode 100644 index 9e13ca6bdd..0000000000 --- a/src/Config/default.build +++ /dev/null @@ -1,53 +0,0 @@ - - - nant buildfile for OpenSim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/GridInterfaces/AssemblyInfo.cs b/src/GridInterfaces/AssemblyInfo.cs deleted file mode 100644 index 32f1380b05..0000000000 --- a/src/GridInterfaces/AssemblyInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.InteropServices; - -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -[assembly: ComVisibleAttribute(false)] -[assembly: CLSCompliantAttribute(false)] -[assembly: AssemblyVersionAttribute("0.1.0.240")] -[assembly: AssemblyTitleAttribute("opensim-gridinterfaces")] -[assembly: AssemblyDescriptionAttribute("Definitions for OGS interface")] -[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] - diff --git a/src/GridInterfaces/GridInterfaces.csproj b/src/GridInterfaces/GridInterfaces.csproj deleted file mode 100644 index 197994f9f3..0000000000 --- a/src/GridInterfaces/GridInterfaces.csproj +++ /dev/null @@ -1,40 +0,0 @@ - - - Library - GridInterfaces - GridInterfaces - Debug - AnyCPU - {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9} - - - bin\Debug\ - False - DEBUG;TRACE - True - Full - True - - - bin\Release\ - True - TRACE - False - None - False - - - - - - ..\..\bin\libsecondlife.dll - False - - - - - - - - - \ No newline at end of file diff --git a/src/GridInterfaces/IGridServer.cs b/src/GridInterfaces/IGridServer.cs deleted file mode 100644 index dcb8ef22d7..0000000000 --- a/src/GridInterfaces/IGridServer.cs +++ /dev/null @@ -1,145 +0,0 @@ -/* -* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - - -using System; -using System.Collections.Generic; -using System.Net; -using System.Net.Sockets; -using System.IO; -using libsecondlife; -using OpenSim; - -namespace OpenSim.GridServers -{ - /// - /// Handles connection to Grid Servers. - /// also Sim to Sim connections? - /// - - - - - public interface IGridServer - { - UUIDBlock RequestUUIDBlock(); - neighbourinfo[] RequestNeighbours(ulong regionhandle); //should return a array of neighbouring regions - AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); - bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); - string GetName(); - bool RequestConnection(); - void SetServerInfo(string GridServerUrl, string GridSendKey, string GridRecvKey, string UserServerUrl, string UserSendKey, string UserRecvKey); - } - - public abstract class RemoteGridBase : IGridServer - { - public abstract Dictionary agentcircuits { - get; - set; - } - - public abstract UUIDBlock RequestUUIDBlock(); - public abstract neighbourinfo[] RequestNeighbours(ulong regionhandle); - public abstract AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); - public abstract bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); - public abstract string GetName(); - public abstract bool RequestConnection(); - public abstract void SetServerInfo(string GridServerUrl, string GridSendKey, string GridRecvKey, string UserServerUrl, string UserSendKey, string UserRecvKey); - } - - public abstract class LocalGridBase : IGridServer - { - public abstract UUIDBlock RequestUUIDBlock(); - public abstract neighbourinfo[] RequestNeighbours(ulong regionhandle); - public abstract AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); - public abstract bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); - public abstract string GetName(); - public abstract bool RequestConnection(); - public abstract void SetServerInfo(string GridServerUrl, string GridSendKey, string GridRecvKey, string UserServerUrl, string UserSendKey, string UserRecvKey); - public abstract void AddNewSession(Login session); - } - - public struct UUIDBlock - { - public LLUUID BlockStart; - public LLUUID BlockEnd; - } - - public class AuthenticateResponse - { - public bool Authorised; - public Login LoginInfo; - - public AuthenticateResponse() - { - - } - - } - - public class Login - { - public string First = "Test"; - public string Last = "User"; - public LLUUID Agent; - public LLUUID Session; - public LLUUID InventoryFolder; - public LLUUID BaseFolder; - public Login() - { - - } - } - - public interface IGridPlugin - { - IGridServer GetGridServer(); - } - - public class agentcircuitdata - { - public agentcircuitdata() { } - public LLUUID AgentID; - public LLUUID SessionID; - public LLUUID SecureSessionID; - public string firstname; - public string lastname; - public uint circuitcode; - public bool child_agent; - } - - public class neighbourinfo - { - public neighbourinfo() { } - public ulong regionhandle; - public uint RegionLocX; - public uint RegionLocY; - public string sim_ip; - public uint sim_port; - } - -} diff --git a/src/GridInterfaces/default.build b/src/GridInterfaces/default.build deleted file mode 100644 index dd02448cc8..0000000000 --- a/src/GridInterfaces/default.build +++ /dev/null @@ -1,50 +0,0 @@ - - - nant buildfile for OpenSim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/GridServers/LoginServer.cs b/src/GridServers/LoginServer.cs deleted file mode 100644 index dbf211de46..0000000000 --- a/src/GridServers/LoginServer.cs +++ /dev/null @@ -1,350 +0,0 @@ -/* -* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using Nwc.XmlRpc; -using System; -using System.IO; -using System.Net; -using System.Net.Sockets; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading; -using System.Collections; -using System.Security.Cryptography; -using System.Xml; -using libsecondlife; -using OpenSim; -using OpenSim.Framework; - -namespace OpenSim.GridServers -{ - - /// - /// When running in local (default) mode , handles client logins. - /// - public class LoginServer : LoginService - { - public LoginServer(IGridServer gridServer) - { - _gridServer = gridServer; - } - - private IGridServer _gridServer; - private ushort _loginPort = 8080; - public IPAddress clientAddress = IPAddress.Loopback; - public IPAddress remoteAddress = IPAddress.Any; - private Socket loginServer; - private int NumClients; - private string _defaultResponse; - - private string _mpasswd; - private bool _needPasswd=false; - - // InitializeLogin: initialize the login - private void InitializeLogin() { - loginServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - loginServer.Bind(new IPEndPoint(remoteAddress, _loginPort)); - loginServer.Listen(1); - - this._needPasswd=false; - //read in default response string - StreamReader SR; - string lines; - SR=File.OpenText("new-login.dat"); - - //lines=SR.ReadLine(); - - while(!SR.EndOfStream) - { - lines = SR.ReadLine(); - _defaultResponse += lines; - //lines = SR.ReadLine(); - } - SR.Close(); - this._mpasswd = EncodePassword("testpass"); - } - - public void Startup() - { - this.InitializeLogin(); - Thread runLoginProxy = new Thread(new ThreadStart(RunLogin)); - runLoginProxy.IsBackground = true; - runLoginProxy.Start(); - } - - private void RunLogin() - { - Console.WriteLine("Starting Login Server"); - try - { - for (;;) - { - Socket client = loginServer.Accept(); - IPEndPoint clientEndPoint = (IPEndPoint)client.RemoteEndPoint; - - - NetworkStream networkStream = new NetworkStream(client); - StreamReader networkReader = new StreamReader(networkStream); - StreamWriter networkWriter = new StreamWriter(networkStream); - - try - { - LoginRequest(networkReader, networkWriter); - } - catch (Exception e) - { - Console.WriteLine(e.Message); - } - - networkWriter.Close(); - networkReader.Close(); - networkStream.Close(); - - client.Close(); - - // send any packets queued for injection - - } - } - catch (Exception e) - { - Console.WriteLine(e.Message); - Console.WriteLine(e.StackTrace); - } - } - - // ProxyLogin: proxy a login request - private void LoginRequest(StreamReader reader, StreamWriter writer) - { - lock(this) - { - string line; - int contentLength = 0; - // read HTTP header - do - { - // read one line of the header - line = reader.ReadLine(); - - // check for premature EOF - if (line == null) - throw new Exception("EOF in client HTTP header"); - - // look for Content-Length - Match match = (new Regex(@"Content-Length: (\d+)$")).Match(line); - if (match.Success) - contentLength = Convert.ToInt32(match.Groups[1].Captures[0].ToString()); - } while (line != ""); - - // read the HTTP body into a buffer - char[] content = new char[contentLength]; - reader.Read(content, 0, contentLength); - - XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content)); - if(request.MethodName == "login_to_simulator") - { - XmlRpcResponse response = ProcessRequest(request); - - // forward the XML-RPC response to the client - writer.WriteLine("HTTP/1.0 200 OK"); - writer.WriteLine("Content-type: text/xml"); - writer.WriteLine(); - - XmlTextWriter responseWriter = new XmlTextWriter(writer); - XmlRpcResponseSerializer.Singleton.Serialize(responseWriter, response); - responseWriter.Close(); - } - else - { - writer.WriteLine("HTTP/1.0 403 Authentication Forbidden"); - writer.WriteLine(); - } - } - } - - private XmlRpcResponse ProcessRequest(XmlRpcRequest request) - { - XmlRpcResponse response = (XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this._defaultResponse); - - Hashtable responseData = (Hashtable)response.Value; - Hashtable requestData = (Hashtable)request.Params[0]; - - string first; - string last; - string passwd; - LLUUID Agent; - LLUUID Session; - - //get login name - if(requestData.Contains("first")) - { - first = (string)requestData["first"]; - } - else - { - first = "test"; - } - - if(requestData.Contains("last")) - { - last = (string)requestData["last"]; - } - else - { - last = "User"+NumClients.ToString(); - } - - if(requestData.Contains("passwd")) - { - passwd = (string)requestData["passwd"]; - } - else - { - passwd = "notfound"; - } - - if( !Authenticate(first, last, passwd)) - { - responseData["reason"] = "key"; - responseData["message"] = "You have entered an invalid name/password combination. Check Caps/lock."; - responseData["login"] = "false"; - } - else - { - NumClients++; - - //create a agent and session LLUUID - Agent = GetAgentId( first, last ); - Session = LLUUID.Random(); - - //create some login info - Hashtable LoginFlagsHash = new Hashtable(); - LoginFlagsHash["daylight_savings"]="N"; - LoginFlagsHash["stipend_since_login"]="N"; - LoginFlagsHash["gendered"]="Y"; - LoginFlagsHash["ever_logged_in"]="Y"; - ArrayList LoginFlags=new ArrayList(); - LoginFlags.Add(LoginFlagsHash); - - Hashtable GlobalT = new Hashtable(); - GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271"; - GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; - GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; - ArrayList GlobalTextures = new ArrayList(); - GlobalTextures.Add(GlobalT); - - responseData["sim_port"] = OpenSim_Main.cfg.IPListenPort; - responseData["sim_ip"] = OpenSim_Main.cfg.IPListenAddr; - responseData["agent_id"] = Agent.ToStringHyphenated(); - responseData["session_id"] = Session.ToStringHyphenated(); - responseData["seconds_since_epoch"]=(Int32)(DateTime.UtcNow - new DateTime(1970,1,1)).TotalSeconds; - responseData["login-flags"]=LoginFlags; - responseData["global-textures"]=GlobalTextures; - - //inventory - ArrayList InventoryList = (ArrayList) responseData["inventory-skeleton"]; - Hashtable Inventory1 = (Hashtable)InventoryList[0]; - Hashtable Inventory2 = (Hashtable)InventoryList[1]; - LLUUID BaseFolderID = LLUUID.Random(); - LLUUID InventoryFolderID = LLUUID.Random(); - Inventory2["name"] = "Base"; - Inventory2["folder_id"] = BaseFolderID.ToStringHyphenated(); - Inventory2["type_default"] =6; - Inventory1["folder_id"] = InventoryFolderID.ToStringHyphenated(); - - ArrayList InventoryRoot = (ArrayList) responseData["inventory-root"]; - Hashtable Inventoryroot = (Hashtable)InventoryRoot[0]; - Inventoryroot["folder_id"] = InventoryFolderID.ToStringHyphenated(); - - CustomiseLoginResponse( responseData, first, last ); - - Login _login = new Login(); - //copy data to login object - _login.First = first; - _login.Last = last; - _login.Agent = Agent; - _login.Session = Session; - _login.BaseFolder = BaseFolderID; - _login.InventoryFolder = InventoryFolderID; - - //working on local computer if so lets add to the gridserver's list of sessions? - if(OpenSim_Main.gridServers.GridServer.GetName() == "Local") - { - ((LocalGridBase)this._gridServer).AddNewSession(_login); - } - } - return response; - } - - protected virtual void CustomiseLoginResponse( Hashtable responseData, string first, string last ) - { - } - - protected virtual LLUUID GetAgentId(string firstName, string lastName) - { - return LLUUID.Random(); - } - - protected virtual bool Authenticate(string first, string last, string passwd) - { - if(this._needPasswd) - { - //every user needs the password to login - string encodedPass = passwd.Remove(0,3); //remove $1$ - if(encodedPass == this._mpasswd) - { - return true; - } - else - { - return false; - } - } - else - { - //do not need password to login - return true; - } - } - - private static string EncodePassword(string passwd) - { - Byte[] originalBytes; - Byte[] encodedBytes; - MD5 md5; - - md5 = new MD5CryptoServiceProvider(); - originalBytes = ASCIIEncoding.Default.GetBytes(passwd); - encodedBytes = md5.ComputeHash(originalBytes); - - return Regex.Replace(BitConverter.ToString(encodedBytes), "-", "").ToLower(); - } - - } - - -} diff --git a/src/LocalServers/LocalGridServers/AssemblyInfo.cs b/src/LocalServers/LocalGridServers/AssemblyInfo.cs deleted file mode 100644 index 4b17ba2f03..0000000000 --- a/src/LocalServers/LocalGridServers/AssemblyInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.InteropServices; - -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -[assembly: ComVisibleAttribute(false)] -[assembly: CLSCompliantAttribute(false)] -[assembly: AssemblyVersionAttribute("0.1.0.240")] -[assembly: AssemblyTitleAttribute("opensim-localservers")] -[assembly: AssemblyDescriptionAttribute("local grid servers")] -[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] - diff --git a/src/LocalServers/LocalGridServers/LocalGridServers.csproj b/src/LocalServers/LocalGridServers/LocalGridServers.csproj deleted file mode 100644 index 7a5ce3d550..0000000000 --- a/src/LocalServers/LocalGridServers/LocalGridServers.csproj +++ /dev/null @@ -1,48 +0,0 @@ - - - Library - LocalGridServers - LocalGridServers - Debug - AnyCPU - {D7F0395B-FADC-4936-80A0-D95AACE92F62} - - - bin\Debug\ - False - DEBUG;TRACE - True - Full - True - - - bin\Release\ - True - TRACE - False - None - False - - - - - - ..\..\..\bin\libsecondlife.dll - False - - - - - - - - {C9A6026D-8E0C-4FE4-8691-FB2A566AA245} - ServerConsole - - - {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9} - GridInterfaces - - - - \ No newline at end of file diff --git a/src/LocalServers/default.build b/src/LocalServers/default.build deleted file mode 100644 index 14c52cd927..0000000000 --- a/src/LocalServers/default.build +++ /dev/null @@ -1,51 +0,0 @@ - - - nant buildfile for OpenSim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/LocalStorage/Db4LocalStorage/AssemblyInfo.cs b/src/LocalStorage/Db4LocalStorage/AssemblyInfo.cs deleted file mode 100644 index 0c5ff7559a..0000000000 --- a/src/LocalStorage/Db4LocalStorage/AssemblyInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.InteropServices; - -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -[assembly: ComVisibleAttribute(false)] -[assembly: CLSCompliantAttribute(false)] -[assembly: AssemblyVersionAttribute("0.1.0.240")] -[assembly: AssemblyTitleAttribute("opensim-localstorage")] -[assembly: AssemblyDescriptionAttribute("The local storage handler")] -[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] - diff --git a/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.csproj b/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.csproj deleted file mode 100644 index c00771c05b..0000000000 --- a/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.csproj +++ /dev/null @@ -1,52 +0,0 @@ - - - Library - Db4LocalStorage - Db4LocalStorage - Debug - AnyCPU - {74784F23-B0FD-484C-82C1-96C0215733DC} - - - bin\Debug\ - False - DEBUG;TRACE - True - Full - True - - - bin\Release\ - True - TRACE - False - None - False - - - - - - ..\..\..\bin\libsecondlife.dll - False - - - ..\..\..\bin\Db4objects.Db4o.dll - False - - - - - - - - {C9A6026D-8E0C-4FE4-8691-FB2A566AA245} - ServerConsole - - - {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9} - GridInterfaces - - - - \ No newline at end of file diff --git a/src/LocalStorage/default.build b/src/LocalStorage/default.build deleted file mode 100644 index 5ed183e398..0000000000 --- a/src/LocalStorage/default.build +++ /dev/null @@ -1,53 +0,0 @@ - - - nant buildfile for OpenSim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Main.cs b/src/Main.cs deleted file mode 100644 index a738d038b6..0000000000 --- a/src/Main.cs +++ /dev/null @@ -1,338 +0,0 @@ -/* -Copyright (c) OpenSim project, http://osgrid.org/ - - -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; -using System.Text; -using System.IO; -using System.Threading; -using System.Net; -using System.Net.Sockets; -using System.Timers; -using System.Reflection; -using System.Collections; -using System.Collections.Generic; -using libsecondlife; -using libsecondlife.Packets; -using OpenSim.world; -using OpenSim.GridServers; -using OpenSim.Assets; -using ServerConsole; -using PhysicsSystem; - -namespace OpenSim -{ - /// - /// Description of MainForm. - /// - public class OpenSim_Main - { - public static OpenSim_Main sim; - public static SimConfig cfg; - public static World local_world; - public static Grid gridServers; - public static SimCAPSHTTPServer http_server; - - public static Socket Server; - private static IPEndPoint ServerIncoming; - private static byte[] RecvBuffer = new byte[4096]; - private byte[] ZeroBuffer = new byte[8192]; - private static IPEndPoint ipeSender; - private static EndPoint epSender; - private static AsyncCallback ReceivedData; - - public AssetCache assetCache; - public DateTime startuptime; - public Dictionary ClientThreads = new Dictionary(); - private PhysicsManager physManager; - private System.Timers.Timer timer1 = new System.Timers.Timer(); - private string ConfigDll = "SimConfig.dll"; - private string _physicsEngine = "PhysX"; - public bool sandbox = false; - public bool loginserver = false; - - [STAThread] - public static void Main( string[] args ) - { - Console.WriteLine("OpenSim " + VersionInfo.Version + "\n"); - Console.WriteLine("Starting...\n"); - ServerConsole.MainConsole.Instance = new MServerConsole(ServerConsole.ConsoleBase.ConsoleType.Local,"",0); - - sim = new OpenSim_Main(); - - sim.sandbox = false; - sim.loginserver = false; - sim._physicsEngine = "PhysX"; - - for (int i = 0; i < args.Length; i++) - { - if(args[i] == "-sandbox") - { - sim.sandbox = true; - } - - if(args[i] == "-loginserver") - { - sim.loginserver = true; - } - if(args[i] == "-realphysx") - { - sim._physicsEngine = "RealPhysX"; - OpenSim.world.Avatar.PhysicsEngineFlying = true; - } - } - - OpenSim_Main.gridServers = new Grid(); - if(sim.sandbox) - { - OpenSim_Main.gridServers.AssetDll = "LocalGridServers.dll"; - OpenSim_Main.gridServers.GridDll = "LocalGridServers.dll"; - OpenSim_Main.gridServers.LoadPlugins(); - ServerConsole.MainConsole.Instance.WriteLine("Starting in Sandbox mode"); - } - else - { - OpenSim_Main.gridServers.AssetDll = "RemoteGridServers.dll"; - OpenSim_Main.gridServers.GridDll = "RemoteGridServers.dll"; - OpenSim_Main.gridServers.LoadPlugins(); - ServerConsole.MainConsole.Instance.WriteLine("Starting in Grid mode"); - } - - if(sim.loginserver && sim.sandbox) - { - LoginServer loginServer = new LoginServer(OpenSim_Main.gridServers.GridServer); - loginServer.Startup(); - } - sim.assetCache = new AssetCache(OpenSim_Main.gridServers.AssetServer); - - sim.Startup(); - - while(true) { - ServerConsole.MainConsole.Instance.MainConsolePrompt(); - } - } - - private OpenSim_Main() { - } - - private void Startup() { - startuptime=DateTime.Now; - - // We check our local database first, then the grid for config options - ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Loading configuration"); - cfg = this.LoadConfigDll(this.ConfigDll); - cfg.InitConfig(); - ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Contacting gridserver"); - cfg.LoadFromGrid(); - - ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - We are " + cfg.RegionName + " at " + cfg.RegionLocX.ToString() + "," + cfg.RegionLocY.ToString()); - ServerConsole.MainConsole.Instance.WriteLine("Initialising world"); - local_world = cfg.LoadWorld(); - - this.physManager = new PhysicsSystem.PhysicsManager(); - this.physManager.LoadPlugins(); - ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting up messaging system"); - local_world.PhysScene = this.physManager.GetPhysicsScene(this._physicsEngine); //should be reading from the config file what physics engine to use - local_world.PhysScene.SetTerrain(local_world.LandMap); - - OpenSim_Main.gridServers.AssetServer.SetServerInfo(OpenSim_Main.cfg.AssetURL, OpenSim_Main.cfg.AssetSendKey); - OpenSim_Main.gridServers.GridServer.SetServerInfo(OpenSim_Main.cfg.GridURL, OpenSim_Main.cfg.GridSendKey, OpenSim_Main.cfg.GridRecvKey, OpenSim_Main.cfg.UserURL, OpenSim_Main.cfg.UserSendKey, OpenSim_Main.cfg.UserRecvKey); - - local_world.LoadStorageDLL("Db4LocalStorage.dll"); //all these dll names shouldn't be hard coded. - local_world.LoadPrimsFromStorage(); - - ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting CAPS HTTP server"); - http_server = new SimCAPSHTTPServer(); - - timer1.Enabled = true; - timer1.Interval = 100; - timer1.Elapsed += new ElapsedEventHandler(this.Timer1Tick); - - MainServerListener(); - - } - - private SimConfig LoadConfigDll(string dllName) - { - Assembly pluginAssembly = Assembly.LoadFrom(dllName); - SimConfig config = null; - - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (pluginType.IsPublic) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("ISimConfig", true); - - if (typeInterface != null) - { - ISimConfig plug = (ISimConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - config = plug.GetConfigObject(); - break; - } - - typeInterface = null; - } - } - } - pluginAssembly = null; - return config; - } - - private void OnReceivedData(IAsyncResult result) { - ipeSender = new IPEndPoint(IPAddress.Any, 0); - epSender = (EndPoint)ipeSender; - Packet packet = null; - int numBytes = Server.EndReceiveFrom(result, ref epSender); - int packetEnd = numBytes - 1; - packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); - - // This is either a new client or a packet to send to an old one - if(ClientThreads.ContainsKey(epSender)) { - ClientThreads[epSender].InPacket(packet); - } else if( packet.Type == PacketType.UseCircuitCode ) { // new client - OpenSimClient newuser = new OpenSimClient(epSender,(UseCircuitCodePacket)packet); - ClientThreads.Add(epSender, newuser); - } else { // invalid client - Console.Error.WriteLine("Main.cs:OnReceivedData() - WARNING: Got a packet from an invalid client - " + epSender.ToString()); - } - Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); - } - - private void MainServerListener() { - ServerConsole.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - New thread started"); - ServerConsole.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - Opening UDP socket on " + cfg.IPListenAddr + ":" + cfg.IPListenPort); - - ServerIncoming = new IPEndPoint(IPAddress.Any, cfg.IPListenPort); - Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); - Server.Bind(ServerIncoming); - - ServerConsole.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - UDP socket bound, getting ready to listen"); - - ipeSender = new IPEndPoint(IPAddress.Any, 0); - epSender = (EndPoint) ipeSender; - ReceivedData = new AsyncCallback(this.OnReceivedData); - Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); - - ServerConsole.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - Listening..."); - - } - - public static void Shutdown() { - ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Closing all threads"); - ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Killing listener thread"); - ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Killing clients"); - // IMPLEMENT THIS - ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Closing console and terminating"); - OpenSim_Main.local_world.Close(); - ServerConsole.MainConsole.Instance.Close(); - Environment.Exit(0); - } - - void Timer1Tick( object sender, System.EventArgs e ) - { - - local_world.Update(); - } - } - - public class Grid - { - public IAssetServer AssetServer; - public IGridServer GridServer; - public string AssetDll = ""; - public string GridDll = ""; - - public Grid() - { - } - - public void LoadPlugins() - { - this.AssetServer = this.LoadAssetDll(this.AssetDll); - this.GridServer = this.LoadGridDll(this.GridDll); - } - - private IAssetServer LoadAssetDll(string dllName) - { - Assembly pluginAssembly = Assembly.LoadFrom(dllName); - IAssetServer server = null; - - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (pluginType.IsPublic) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IAssetPlugin", true); - - if (typeInterface != null) - { - IAssetPlugin plug = (IAssetPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - server = plug.GetAssetServer(); - break; - } - - typeInterface = null; - } - } - } - pluginAssembly = null; - return server; - } - - private IGridServer LoadGridDll(string dllName) - { - Assembly pluginAssembly = Assembly.LoadFrom(dllName); - IGridServer server = null; - - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (pluginType.IsPublic) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IGridPlugin", true); - - if (typeInterface != null) - { - IGridPlugin plug = (IGridPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - server = plug.GetGridServer(); - break; - } - - typeInterface = null; - } - } - } - pluginAssembly = null; - return server; - } - } -} diff --git a/src/OpenSim.Framework/AssemblyInfo.cs b/src/OpenSim.Framework/AssemblyInfo.cs deleted file mode 100644 index 32f1380b05..0000000000 --- a/src/OpenSim.Framework/AssemblyInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.InteropServices; - -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -[assembly: ComVisibleAttribute(false)] -[assembly: CLSCompliantAttribute(false)] -[assembly: AssemblyVersionAttribute("0.1.0.240")] -[assembly: AssemblyTitleAttribute("opensim-gridinterfaces")] -[assembly: AssemblyDescriptionAttribute("Definitions for OGS interface")] -[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] - diff --git a/src/OpenSim.Framework/OpenSim.Framework.csproj b/src/OpenSim.Framework/OpenSim.Framework.csproj deleted file mode 100644 index ec586c3525..0000000000 --- a/src/OpenSim.Framework/OpenSim.Framework.csproj +++ /dev/null @@ -1,49 +0,0 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {407CE85B-628C-4788-9DBC-49BCEFC3A84F} - Library - Properties - OpenSim.Framework - OpenGrid.Framework - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - False - ..\..\bin\libsecondlife.dll - - - - - - - - - - - {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9} - GridInterfaces - - - - \ No newline at end of file diff --git a/src/OpenSim.Framework/Properties/AssemblyInfo.cs b/src/OpenSim.Framework/Properties/AssemblyInfo.cs deleted file mode 100644 index 72e55b9e81..0000000000 --- a/src/OpenSim.Framework/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("OpenGrid.Framework")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Playahead AB")] -[assembly: AssemblyProduct("OpenGrid.Framework")] -[assembly: AssemblyCopyright("Copyright © Playahead AB 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("67d2b810-0969-4550-ab2b-d2f5ac191191")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/OpenSim.Framework/default.build b/src/OpenSim.Framework/default.build deleted file mode 100644 index 57dfee8e6e..0000000000 --- a/src/OpenSim.Framework/default.build +++ /dev/null @@ -1,50 +0,0 @@ - - - nant buildfile for OpenSim.Framework - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/OpenSimClient.cs b/src/OpenSimClient.cs deleted file mode 100644 index dd698e4ddd..0000000000 --- a/src/OpenSimClient.cs +++ /dev/null @@ -1,471 +0,0 @@ -/* -Copyright (c) OpenSim project, http://osgrid.org/ -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; -using System.Collections; -using System.Collections.Generic; -using libsecondlife; -using libsecondlife.Packets; -using System.Net; -using System.Net.Sockets; -using System.IO; -using System.Threading; -using System.Timers; -using OpenSim.GridServers; -using OpenSim.world; - -namespace OpenSim -{ - /// - /// Handles new client connections - /// Constructor takes a single Packet and authenticates everything - /// - public class OpenSimClient { - - public LLUUID AgentID; - public LLUUID SessionID; - public uint CircuitCode; - public world.Avatar ClientAvatar; - private UseCircuitCodePacket cirpack; - private Thread ClientThread; - public EndPoint userEP; - private BlockingQueue PacketQueue; - private Dictionary PendingAcks = new Dictionary(); - private Dictionary NeedAck = new Dictionary(); - private System.Timers.Timer AckTimer; - private uint Sequence = 0; - private object SequenceLock = new object(); - private const int MAX_APPENDED_ACKS = 10; - private const int RESEND_TIMEOUT = 4000; - private const int MAX_SEQUENCE = 0xFFFFFF; - - public void ack_pack(Packet Pack) { - //libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket(); - //ack_it.Packets = new PacketAckPacket.PacketsBlock[1]; - //ack_it.Packets[0] = new PacketAckPacket.PacketsBlock(); - //ack_it.Packets[0].ID = Pack.Header.ID; - //ack_it.Header.Reliable = false; - - //OutPacket(ack_it); - - if (Pack.Header.Reliable) { - lock (PendingAcks) { - uint sequence = (uint)Pack.Header.Sequence; - if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; } - } - } - } - - public void ProcessInPacket(Packet Pack) { - ack_pack(Pack); - switch(Pack.Type) { - case PacketType.CompleteAgentMovement: - ClientAvatar.CompleteMovement(OpenSim_Main.local_world); - ClientAvatar.SendInitialPosition(); - break; - case PacketType.RegionHandshakeReply: - OpenSim_Main.local_world.SendLayerData(this); - break; - case PacketType.AgentWearablesRequest: - ClientAvatar.SendInitialAppearance(); - foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) { - if(client.AgentID != this.AgentID) - { - ObjectUpdatePacket objupdate = client.ClientAvatar.CreateUpdatePacket(); - this.OutPacket(objupdate); - client.ClientAvatar.SendAppearanceToOtherAgent(this); - } - } - OpenSim_Main.local_world.GetInitialPrims(this); - break; - case PacketType.ObjectAdd: - OpenSim_Main.local_world.AddNewPrim((ObjectAddPacket)Pack, this); - break; - case PacketType.ObjectLink: - ServerConsole.MainConsole.Instance.WriteLine(Pack.ToString()); - break; - case PacketType.ObjectScale: - ServerConsole.MainConsole.Instance.WriteLine(Pack.ToString()); - break; - case PacketType.ObjectShape: - ObjectShapePacket shape = (ObjectShapePacket)Pack; - for(int i =0; i RESEND_TIMEOUT) && (!packet.Header.Resent)) - { - ServerConsole.MainConsole.Instance.WriteLine("Resending " + packet.Type.ToString() + " packet, " + - (now - packet.TickCount) + "ms have passed"); - - packet.Header.Resent = true; - OutPacket(packet); - } - } - } - } - - private void SendAcks() - { - lock (PendingAcks) - { - if (PendingAcks.Count > 0) - { - if (PendingAcks.Count > 250) - { - // FIXME: Handle the odd case where we have too many pending ACKs queued up - ServerConsole.MainConsole.Instance.WriteLine("Too many ACKs queued up!"); - return; - } - - ServerConsole.MainConsole.Instance.WriteLine("Sending PacketAck"); - - - int i = 0; - PacketAckPacket acks = new PacketAckPacket(); - acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count]; - - foreach (uint ack in PendingAcks.Values) - { - acks.Packets[i] = new PacketAckPacket.PacketsBlock(); - acks.Packets[i].ID = ack; - i++; - } - - acks.Header.Reliable = false; - OutPacket(acks); - - PendingAcks.Clear(); - } - } - } - - private void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) - { - SendAcks(); - ResendUnacked(); - } - - public void ProcessOutPacket(Packet Pack) { - - // Keep track of when this packet was sent out - Pack.TickCount = Environment.TickCount; - - if (!Pack.Header.Resent) - { - // Set the sequence number - lock (SequenceLock) - { - if (Sequence >= MAX_SEQUENCE) - Sequence = 1; - else - Sequence++; - Pack.Header.Sequence = Sequence; - } - - if (Pack.Header.Reliable) //DIRTY HACK - { - lock (NeedAck) - { - if (!NeedAck.ContainsKey(Pack.Header.Sequence)) - { - NeedAck.Add(Pack.Header.Sequence, Pack); - } - else - { - // Client.Log("Attempted to add a duplicate sequence number (" + - // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " + - // packet.Type.ToString(), Helpers.LogLevel.Warning); - } - } - - // Don't append ACKs to resent packets, in case that's what was causing the - // delivery to fail - if (!Pack.Header.Resent) - { - // Append any ACKs that need to be sent out to this packet - lock (PendingAcks) - { - if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS && - Pack.Type != PacketType.PacketAck && - Pack.Type != PacketType.LogoutRequest) - { - Pack.Header.AckList = new uint[PendingAcks.Count]; - int i = 0; - - foreach (uint ack in PendingAcks.Values) - { - Pack.Header.AckList[i] = ack; - i++; - } - - PendingAcks.Clear(); - Pack.Header.AppendedAcks = true; - } - } - } - } - } - - //ServerConsole.MainConsole.Instance.WriteLine("OUT: \n" + Pack.ToString()); - - byte[] ZeroOutBuffer = new byte[4096]; - byte[] sendbuffer; - sendbuffer = Pack.ToBytes(); - - try { - if (Pack.Header.Zerocoded) { - int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); - OpenSim_Main.Server.SendTo(ZeroOutBuffer, packetsize, SocketFlags.None,userEP); - } else { - OpenSim_Main.Server.SendTo(sendbuffer, sendbuffer.Length, SocketFlags.None,userEP); - } - } catch (Exception) { - ServerConsole.MainConsole.Instance.WriteLine("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread"); - ClientThread.Abort(); - } - - } - - public void InPacket(Packet NewPack) { - // Handle appended ACKs - if (NewPack.Header.AppendedAcks) - { - lock (NeedAck) - { - foreach (uint ack in NewPack.Header.AckList) - { - NeedAck.Remove(ack); - } - } - } - - // Handle PacketAck packets - if (NewPack.Type == PacketType.PacketAck) - { - PacketAckPacket ackPacket = (PacketAckPacket)NewPack; - - lock (NeedAck) - { - foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) - { - NeedAck.Remove(block.ID); - } - } - } else if( ( NewPack.Type == PacketType.StartPingCheck ) ) { - //reply to pingcheck - libsecondlife.Packets.StartPingCheckPacket startPing = (libsecondlife.Packets.StartPingCheckPacket)NewPack; - libsecondlife.Packets.CompletePingCheckPacket endPing = new CompletePingCheckPacket(); - endPing.PingID.PingID = startPing.PingID.PingID; - OutPacket(endPing); - } - else - { - QueItem item = new QueItem(); - item.Packet = NewPack; - item.Incoming = true; - this.PacketQueue.Enqueue(item); - } - - } - - public void OutPacket(Packet NewPack) { - QueItem item = new QueItem(); - item.Packet = NewPack; - item.Incoming = false; - this.PacketQueue.Enqueue(item); - } - - public OpenSimClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack) { - ServerConsole.MainConsole.Instance.WriteLine("OpenSimClient.cs - Started up new client thread to handle incoming request"); - cirpack = initialcirpack; - userEP = remoteEP; - PacketQueue = new BlockingQueue(); - AckTimer = new System.Timers.Timer(500); - AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); - AckTimer.Start(); - - ClientThread = new Thread(new ThreadStart(AuthUser)); - ClientThread.IsBackground = true; - ClientThread.Start(); - } - - private void ClientLoop() { - ServerConsole.MainConsole.Instance.WriteLine("OpenSimClient.cs:ClientLoop() - Entered loop"); - while(true) { - QueItem nextPacket = PacketQueue.Dequeue(); - if(nextPacket.Incoming) - { - //is a incoming packet - ProcessInPacket(nextPacket.Packet); - } - else - { - //is a out going packet - ProcessOutPacket(nextPacket.Packet); - } - } - } - - private void InitNewClient() { - ServerConsole.MainConsole.Instance.WriteLine("OpenSimClient.cs:InitNewClient() - Adding viewer agent to world"); - OpenSim_Main.local_world.AddViewerAgent(this); - world.Entity tempent=OpenSim_Main.local_world.Entities[this.AgentID]; - this.ClientAvatar=(world.Avatar)tempent; - } - - private void AuthUser() - { - AuthenticateResponse sessionInfo = OpenSim_Main.gridServers.GridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); - if(!sessionInfo.Authorised) - { - //session/circuit not authorised - ServerConsole.MainConsole.Instance.WriteLine("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString()); - ClientThread.Abort(); - } - else - { - ServerConsole.MainConsole.Instance.WriteLine("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString()); - //session is authorised - this.AgentID=cirpack.CircuitCode.ID; - this.SessionID=cirpack.CircuitCode.SessionID; - this.CircuitCode=cirpack.CircuitCode.Code; - InitNewClient(); - this.ClientAvatar.firstname = sessionInfo.LoginInfo.First; - this.ClientAvatar.lastname = sessionInfo.LoginInfo.Last; - ClientLoop(); - } - } - } - -} diff --git a/src/RemoteServers/RemoteGridServers/AssemblyInfo.cs b/src/RemoteServers/RemoteGridServers/AssemblyInfo.cs deleted file mode 100644 index 7d3f3141c9..0000000000 --- a/src/RemoteServers/RemoteGridServers/AssemblyInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.InteropServices; - -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -[assembly: ComVisibleAttribute(false)] -[assembly: CLSCompliantAttribute(false)] -[assembly: AssemblyVersionAttribute("0.1.0.240")] -[assembly: AssemblyTitleAttribute("opensim-remoteservers")] -[assembly: AssemblyDescriptionAttribute("Connects to remote OGS installation")] -[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] - diff --git a/src/RemoteServers/RemoteGridServers/RemoteGrid.cs b/src/RemoteServers/RemoteGridServers/RemoteGrid.cs deleted file mode 100644 index adb3d0f751..0000000000 --- a/src/RemoteServers/RemoteGridServers/RemoteGrid.cs +++ /dev/null @@ -1,279 +0,0 @@ -/* -* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Threading; -using System.Net; -using System.Net.Sockets; -using System.IO; -using System.Xml; -using libsecondlife; -using OpenSim.GridServers; - -namespace RemoteGridServers -{ - /// - /// - /// - /// - - public class RemoteGridPlugin : IGridPlugin - { - public RemoteGridPlugin() - { - - } - - public IGridServer GetGridServer() - { - return(new RemoteGridServer()); - } - } - - public class RemoteAssetPlugin : IAssetPlugin - { - public RemoteAssetPlugin() - { - - } - - public IAssetServer GetAssetServer() - { - return(new RemoteAssetServer()); - } - } - public class RemoteGridServer : RemoteGridBase - { - private string GridServerUrl; - private string GridSendKey; - private string GridRecvKey; - private string UserServerUrl; - private string UserSendKey; - private string UserRecvKey; - - private Dictionary AgentCircuits = new Dictionary(); - - public override Dictionary agentcircuits { - get {return AgentCircuits;} - set {AgentCircuits=value;} - } - - public RemoteGridServer() - { - ServerConsole.MainConsole.Instance.WriteLine("Remote Grid Server class created"); - } - - public override bool RequestConnection() - { - return true; - } - - public override AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode) - { - agentcircuitdata validcircuit=this.AgentCircuits[circuitcode]; - AuthenticateResponse user = new AuthenticateResponse(); - if((sessionID==validcircuit.SessionID) && (agentID==validcircuit.AgentID)) - { - // YAY! Valid login - user.Authorised = true; - user.LoginInfo = new Login(); - user.LoginInfo.Agent = agentID; - user.LoginInfo.Session = sessionID; - user.LoginInfo.First = validcircuit.firstname; - user.LoginInfo.Last = validcircuit.lastname; - } - else - { - // Invalid - user.Authorised = false; - } - - return(user); - } - - public override bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) - { - WebRequest DeleteSession = WebRequest.Create(UserServerUrl + "/usersessions/" + sessionID.ToString()); - DeleteSession.Method="DELETE"; - DeleteSession.ContentType="text/plaintext"; - DeleteSession.ContentLength=0; - - StreamWriter stOut = new StreamWriter (DeleteSession.GetRequestStream(), System.Text.Encoding.ASCII); - stOut.Write(""); - stOut.Close(); - - StreamReader stIn = new StreamReader(DeleteSession.GetResponse().GetResponseStream()); - string GridResponse = stIn.ReadToEnd(); - stIn.Close(); - return(true); - } - - public override UUIDBlock RequestUUIDBlock() - { - UUIDBlock uuidBlock = new UUIDBlock(); - return(uuidBlock); - } - - public override neighbourinfo[] RequestNeighbours(ulong regionhandle) - { - ArrayList neighbourlist = new ArrayList(); - - WebRequest FindNeighbours = WebRequest.Create(GridServerUrl + "/regions/" + regionhandle.ToString() + "/neighbours"); - FindNeighbours.ContentType="text/plaintext"; - FindNeighbours.ContentLength=0; - - StreamWriter stOut = new StreamWriter (FindNeighbours.GetRequestStream(), System.Text.Encoding.ASCII); - stOut.Write(""); - stOut.Close(); - - - XmlDocument GridRespXml = new XmlDocument(); - GridRespXml.Load(FindNeighbours.GetResponse().GetResponseStream()); - - - XmlNode NeighboursRoot = GridRespXml.FirstChild; - if(NeighboursRoot.Name != "neighbours") { - return new neighbourinfo[0]; - } - - FindNeighbours.GetResponse().GetResponseStream().Close(); - - return new neighbourinfo[0]; - } - - public override void SetServerInfo(string UserServerUrl, string UserSendKey, string UserRecvKey, string GridServerUrl, string GridSendKey, string GridRecvKey) - { - this.UserServerUrl = UserServerUrl; - this.UserSendKey = UserSendKey; - this.UserRecvKey = UserRecvKey; - this.GridServerUrl = GridServerUrl; - this.GridSendKey = GridSendKey; - this.GridRecvKey = GridRecvKey; - } - - public override string GetName() - { - return "Remote"; - } - } - - - public class RemoteAssetServer : IAssetServer - { - private IAssetReceiver _receiver; - private BlockingQueue _assetRequests; - private Thread _remoteAssetServerThread; - private string AssetServerUrl; - private string AssetSendKey; - - public RemoteAssetServer() - { - this._assetRequests = new BlockingQueue(); - this._remoteAssetServerThread = new Thread(new ThreadStart(RunRequests)); - this._remoteAssetServerThread.IsBackground = true; - this._remoteAssetServerThread.Start(); - ServerConsole.MainConsole.Instance.WriteLine("Remote Asset Server class created"); - } - - public void SetReceiver(IAssetReceiver receiver) - { - this._receiver = receiver; - } - - public void RequestAsset(LLUUID assetID, bool isTexture) - { - ARequest req = new ARequest(); - req.AssetID = assetID; - req.IsTexture = isTexture; - this._assetRequests.Enqueue(req); - } - - public void UpdateAsset(AssetBase asset) - { - - } - - public void UploadNewAsset(AssetBase asset) - { - - } - - public void SetServerInfo(string ServerUrl, string ServerKey) - { - this.AssetServerUrl = ServerUrl; - this.AssetSendKey = ServerKey; - } - - private void RunRequests() - { - while(true) - { - //we need to add support for the asset server not knowing about a requested asset - ARequest req = this._assetRequests.Dequeue(); - LLUUID assetID = req.AssetID; - ServerConsole.MainConsole.Instance.WriteLine(" RemoteAssetServer- Got a AssetServer request, processing it"); - WebRequest AssetLoad = WebRequest.Create(this.AssetServerUrl + "getasset/" + AssetSendKey + "/" + assetID + "/data"); - WebResponse AssetResponse = AssetLoad.GetResponse(); - byte[] idata = new byte[(int)AssetResponse.ContentLength]; - BinaryReader br = new BinaryReader(AssetResponse.GetResponseStream()); - idata = br.ReadBytes((int)AssetResponse.ContentLength); - br.Close(); - - AssetBase asset = new AssetBase(); - asset.FullID = assetID; - asset.Data = idata; - _receiver.AssetReceived(asset, req.IsTexture ); - } - } - } - - public class BlockingQueue< T > { - private Queue< T > _queue = new Queue< T >(); - private object _queueSync = new object(); - - public void Enqueue(T value) - { - lock(_queueSync) - { - _queue.Enqueue(value); - Monitor.Pulse(_queueSync); - } - } - - public T Dequeue() - { - lock(_queueSync) - { - if( _queue.Count < 1) - Monitor.Wait(_queueSync); - - return _queue.Dequeue(); - } - } - } -} diff --git a/src/RemoteServers/RemoteGridServers/RemoteGridServers.csproj b/src/RemoteServers/RemoteGridServers/RemoteGridServers.csproj deleted file mode 100644 index f1c5649117..0000000000 --- a/src/RemoteServers/RemoteGridServers/RemoteGridServers.csproj +++ /dev/null @@ -1,48 +0,0 @@ - - - Library - RemoteGridServers - RemoteGridServers - Debug - AnyCPU - {CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5} - - - bin\Debug\ - False - DEBUG;TRACE - True - Full - True - - - bin\Release\ - True - TRACE - False - None - False - - - - - - ..\..\..\bin\libsecondlife.dll - False - - - - - - - - {C9A6026D-8E0C-4FE4-8691-FB2A566AA245} - ServerConsole - - - {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9} - GridInterfaces - - - - \ No newline at end of file diff --git a/src/RemoteServers/default.build b/src/RemoteServers/default.build deleted file mode 100644 index f8e69770f1..0000000000 --- a/src/RemoteServers/default.build +++ /dev/null @@ -1,51 +0,0 @@ - - - nant buildfile for OpenSim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Second-server.csproj b/src/Second-server.csproj deleted file mode 100644 index 7c0d17c104..0000000000 --- a/src/Second-server.csproj +++ /dev/null @@ -1,110 +0,0 @@ - - - Exe - OpenSim - OpenSim - Debug - AnyCPU - {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E} - OpenSim.OpenSim_Main - False - False - 4 - false - - - bin\ - False - DEBUG;TRACE - true - Full - True - - - ..\bin\ - True - TRACE - False - None - False - - - False - Auto - 4194304 - AnyCPU - 4096 - - - ..\bin\ - - - - - - - ..\bin\libsecondlife.dll - False - - - ..\bin\Axiom.MathLib.dll - False - - - ..\bin\log4net.dll - False - - - - - - - - - - - - - - - - - - - - - - - - - - {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9} - GridInterfaces - - - {D7F0395B-FADC-4936-80A0-D95AACE92F62} - LocalGridServers - - - {74784F23-B0FD-484C-82C1-96C0215733DC} - Db4LocalStorage - - - {407CE85B-628C-4788-9DBC-49BCEFC3A84F} - OpenSim.Framework - - - {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B} - PhysicsManager - - - {CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5} - RemoteGridServers - - - {C9A6026D-8E0C-4FE4-8691-FB2A566AA245} - ServerConsole - - - - \ No newline at end of file diff --git a/src/ServerConsole/ServerConsole/AssemblyInfo.cs b/src/ServerConsole/ServerConsole/AssemblyInfo.cs deleted file mode 100644 index e6b64d6f45..0000000000 --- a/src/ServerConsole/ServerConsole/AssemblyInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.InteropServices; - -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -[assembly: ComVisibleAttribute(false)] -[assembly: CLSCompliantAttribute(false)] -[assembly: AssemblyVersionAttribute("0.1.0.240")] -[assembly: AssemblyTitleAttribute("opensim-serverconsole")] -[assembly: AssemblyDescriptionAttribute("The default server console")] -[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] - diff --git a/src/ServerConsole/ServerConsole/ServerConsole.cs b/src/ServerConsole/ServerConsole/ServerConsole.cs deleted file mode 100644 index 27d97e5f0e..0000000000 --- a/src/ServerConsole/ServerConsole/ServerConsole.cs +++ /dev/null @@ -1,87 +0,0 @@ -/* -* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; - -namespace ServerConsole -{ - public class MainConsole { - - private static ConsoleBase instance; - - public static ConsoleBase Instance - { - get - { - return instance; - } - set - { - instance = value; - } - } - } - - public abstract class ConsoleBase - { - - public enum ConsoleType { - Local, // Use stdio - TCP, // Use TCP/telnet - SimChat // Use in-world chat (for gods) - } - - public abstract void Close(); - - public abstract void Write(string format, params object[] args); - - public abstract void WriteLine(string format, params object[] args); - - public abstract string ReadLine(); - - public abstract int Read() ; - - // Displays a command prompt and waits for the user to enter a string, then returns that string - public abstract string CmdPrompt(string prompt) ; - - // Displays a command prompt and returns a default value if the user simply presses enter - public abstract string CmdPrompt(string prompt, string defaultresponse); - - // Displays a command prompt and returns a default value, user may only enter 1 of 2 options - public abstract string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) ; - - // Runs a command with a number of parameters - public abstract Object RunCmd(string Cmd, string[] cmdparams) ; - - // Shows data about something - public abstract void ShowCommands(string ShowWhat) ; - - // Displays a prompt to the user and then runs the command they entered - public abstract void MainConsolePrompt() ; - - public abstract void SetStatus( string status ); - } -} diff --git a/src/ServerConsole/ServerConsole/ServerConsole.csproj b/src/ServerConsole/ServerConsole/ServerConsole.csproj deleted file mode 100644 index d1094de1b2..0000000000 --- a/src/ServerConsole/ServerConsole/ServerConsole.csproj +++ /dev/null @@ -1,34 +0,0 @@ - - - Library - ServerConsole - ServerConsole - Debug - AnyCPU - {C9A6026D-8E0C-4FE4-8691-FB2A566AA245} - - - bin\Debug\ - False - DEBUG;TRACE - True - Full - True - - - bin\Release\ - True - TRACE - False - None - False - - - - - - - - - - \ No newline at end of file diff --git a/src/ServerConsole/default.build b/src/ServerConsole/default.build deleted file mode 100644 index 0de930ad32..0000000000 --- a/src/ServerConsole/default.build +++ /dev/null @@ -1,48 +0,0 @@ - - - nant buildfile for OpenSim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Util.cs b/src/Util.cs deleted file mode 100644 index 477390e8fd..0000000000 --- a/src/Util.cs +++ /dev/null @@ -1,99 +0,0 @@ -/* -Copyright (c) OpenSim project, http://osgrid.org/ - -* Copyright (c) , -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; -using System.Collections.Generic; -using System.Threading; -using libsecondlife; -using libsecondlife.Packets; - -namespace OpenSim -{ - /// - /// - /// - public class Util - { - public static ulong UIntsToLong(uint X, uint Y) - { - return Helpers.UIntsToLong(X,Y); - } - public Util() - { - - } - } - - public class QueItem { - public QueItem() - { - } - - public Packet Packet; - public bool Incoming; - } - - /* this is in IGridServer.cs, so there should be no reason for it to be here as well - public class agentcircuitdata - { - public agentcircuitdata() { } - public LLUUID AgentID; - public LLUUID SessionID; - public LLUUID SecureSessionID; - public string firstname; - public string lastname; - public uint circuitcode; - } - */ - - public class BlockingQueue< T > { - private Queue< T > _queue = new Queue< T >(); - private object _queueSync = new object(); - - public void Enqueue(T value) - { - lock(_queueSync) - { - _queue.Enqueue(value); - Monitor.Pulse(_queueSync); - } - } - - public T Dequeue() - { - lock(_queueSync) - { - if( _queue.Count < 1) - Monitor.Wait(_queueSync); - - return _queue.Dequeue(); - } - } - } -} diff --git a/src/opensim.sln b/src/opensim.sln deleted file mode 100644 index c4be551c1a..0000000000 --- a/src/opensim.sln +++ /dev/null @@ -1,80 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Second-server", "Second-server.csproj", "{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GridInterfaces", "GridInterfaces\GridInterfaces.csproj", "{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysicsManager", "physics\PhysicsManager.csproj", "{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerConsole", "ServerConsole\ServerConsole\ServerConsole.csproj", "{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalGridServers", "LocalServers\LocalGridServers\LocalGridServers.csproj", "{D7F0395B-FADC-4936-80A0-D95AACE92F62}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RemoteGridServers", "RemoteServers\RemoteGridServers\RemoteGridServers.csproj", "{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimConfig", "Config\SimConfig\SimConfig.csproj", "{B063760D-DB8D-4F64-B6FE-335FAD1E650A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4LocalStorage", "LocalStorage\Db4LocalStorage\Db4LocalStorage.csproj", "{74784F23-B0FD-484C-82C1-96C0215733DC}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicPhysicsplugin", "physics\plugins\BasicPhysicsplugin.csproj", "{52BCCE7B-69EA-4AC3-9DBC-D571B96C2EA1}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RealPhysXplugin", "physics\RealPhysX\RealPhysXplugin\RealPhysXplugin.csproj", "{56C1D214-F389-4228-921A-0A3A0712C159}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Framework", "OpenSim.Framework\OpenSim.Framework.csproj", "{407CE85B-628C-4788-9DBC-49BCEFC3A84F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|Any CPU.Build.0 = Release|Any CPU - {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Release|Any CPU.Build.0 = Release|Any CPU - {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Release|Any CPU.Build.0 = Release|Any CPU - {C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|Any CPU.Build.0 = Release|Any CPU - {D7F0395B-FADC-4936-80A0-D95AACE92F62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D7F0395B-FADC-4936-80A0-D95AACE92F62}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D7F0395B-FADC-4936-80A0-D95AACE92F62}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D7F0395B-FADC-4936-80A0-D95AACE92F62}.Release|Any CPU.Build.0 = Release|Any CPU - {CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Release|Any CPU.Build.0 = Release|Any CPU - {B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Release|Any CPU.Build.0 = Release|Any CPU - {74784F23-B0FD-484C-82C1-96C0215733DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {74784F23-B0FD-484C-82C1-96C0215733DC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {74784F23-B0FD-484C-82C1-96C0215733DC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {74784F23-B0FD-484C-82C1-96C0215733DC}.Release|Any CPU.Build.0 = Release|Any CPU - {52BCCE7B-69EA-4AC3-9DBC-D571B96C2EA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {52BCCE7B-69EA-4AC3-9DBC-D571B96C2EA1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {52BCCE7B-69EA-4AC3-9DBC-D571B96C2EA1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {52BCCE7B-69EA-4AC3-9DBC-D571B96C2EA1}.Release|Any CPU.Build.0 = Release|Any CPU - {56C1D214-F389-4228-921A-0A3A0712C159}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {56C1D214-F389-4228-921A-0A3A0712C159}.Debug|Any CPU.Build.0 = Debug|Any CPU - {56C1D214-F389-4228-921A-0A3A0712C159}.Release|Any CPU.ActiveCfg = Release|Any CPU - {56C1D214-F389-4228-921A-0A3A0712C159}.Release|Any CPU.Build.0 = Release|Any CPU - {407CE85B-628C-4788-9DBC-49BCEFC3A84F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {407CE85B-628C-4788-9DBC-49BCEFC3A84F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {407CE85B-628C-4788-9DBC-49BCEFC3A84F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {407CE85B-628C-4788-9DBC-49BCEFC3A84F}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/src/physics/AssemblyInfo.cs b/src/physics/AssemblyInfo.cs deleted file mode 100644 index c6a4efa80b..0000000000 --- a/src/physics/AssemblyInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.InteropServices; - -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -[assembly: ComVisibleAttribute(false)] -[assembly: CLSCompliantAttribute(false)] -[assembly: AssemblyVersionAttribute("0.1.0.240")] -[assembly: AssemblyTitleAttribute("opensim-physicsmanager")] -[assembly: AssemblyDescriptionAttribute("Handles physics plugins")] -[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] - diff --git a/src/physics/PhysicsManager.cs b/src/physics/PhysicsManager.cs deleted file mode 100644 index 1fee628a1d..0000000000 --- a/src/physics/PhysicsManager.cs +++ /dev/null @@ -1,285 +0,0 @@ -/* -* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections.Generic; -using System.Collections; -using System.IO; -using System.Reflection; - -namespace PhysicsSystem -{ - /// - /// Description of MyClass. - /// - public class PhysicsManager - { - private Dictionary _plugins=new Dictionary(); - - public PhysicsManager() - { - - } - - public PhysicsScene GetPhysicsScene(string engineName) - { - if( String.IsNullOrEmpty( engineName ) ) - { - return new NullPhysicsScene(); - } - - if(_plugins.ContainsKey(engineName)) - { - ServerConsole.MainConsole.Instance.WriteLine("creating "+engineName); - return _plugins[engineName].GetScene(); - } - else - { - string error = String.Format("couldn't find physicsEngine: {0}", engineName); - ServerConsole.MainConsole.Instance.WriteLine( error ); - throw new ArgumentException( error ); - } - } - - public void LoadPlugins() - { - string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory ,"Physics"); - string[] pluginFiles = Directory.GetFiles(path, "*.dll"); - - - for(int i= 0; i - - Library - PhysicsManager - PhysicsManager - Debug - AnyCPU - {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B} - - - bin\Debug\ - False - DEBUG;TRACE - True - Full - True - - - bin\Release\ - True - TRACE - False - None - False - - - - - - - - - - - {C9A6026D-8E0C-4FE4-8691-FB2A566AA245} - ServerConsole - - - - \ No newline at end of file diff --git a/src/physics/RealPhysX/RealPhysXplugin/RealPhysXplugin.csproj b/src/physics/RealPhysX/RealPhysXplugin/RealPhysXplugin.csproj deleted file mode 100644 index 554df5e62e..0000000000 --- a/src/physics/RealPhysX/RealPhysXplugin/RealPhysXplugin.csproj +++ /dev/null @@ -1,46 +0,0 @@ - - - Library - RealPhysXplugin - RealPhysXplugin - Debug - AnyCPU - {56C1D214-F389-4228-921A-0A3A0712C159} - - - ..\..\..\..\bin\Physics\ - False - DEBUG;TRACE - True - Full - True - - - ..\..\..\..\bin\Physics\ - True - TRACE - False - None - False - - - - - - ..\..\..\..\bin\PhysX_Wrapper_Dotnet.dll - False - False - - - - - - - - {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B} - PhysicsManager - False - - - - \ No newline at end of file diff --git a/src/physics/default.build b/src/physics/default.build deleted file mode 100644 index 01d2415b9d..0000000000 --- a/src/physics/default.build +++ /dev/null @@ -1,49 +0,0 @@ - - - nant buildfile for OpenSim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/physics/plugins/AssemblyInfo.cs b/src/physics/plugins/AssemblyInfo.cs deleted file mode 100644 index 4cd5558a20..0000000000 --- a/src/physics/plugins/AssemblyInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.InteropServices; - -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -[assembly: ComVisibleAttribute(false)] -[assembly: CLSCompliantAttribute(false)] -[assembly: AssemblyVersionAttribute("0.1.0.240")] -[assembly: AssemblyTitleAttribute("opensim-physicsmanager-physx")] -[assembly: AssemblyDescriptionAttribute("PhysX plugin for OpenSim")] -[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")] - diff --git a/src/physics/plugins/BasicPhysicsplugin.csproj b/src/physics/plugins/BasicPhysicsplugin.csproj deleted file mode 100644 index b3f47d330e..0000000000 --- a/src/physics/plugins/BasicPhysicsplugin.csproj +++ /dev/null @@ -1,51 +0,0 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {52BCCE7B-69EA-4AC3-9DBC-D571B96C2EA1} - Library - Properties - BasicPhysicsplugin - BasicPhysicsplugin - - - true - full - false - ..\..\..\bin\Physics\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - ..\..\..\bin\Physics\ - TRACE - prompt - 4 - - - - False - ..\..\..\bin\Axiom.MathLib.dll - False - - - - - - - - - - - {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B} - PhysicsManager - False - - - - \ No newline at end of file diff --git a/src/physics/plugins/default.build b/src/physics/plugins/default.build deleted file mode 100644 index 66056a55fd..0000000000 --- a/src/physics/plugins/default.build +++ /dev/null @@ -1,51 +0,0 @@ - - - nant buildfile for OpenSim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/world/Avatar.cs b/src/world/Avatar.cs deleted file mode 100644 index facfeee1db..0000000000 --- a/src/world/Avatar.cs +++ /dev/null @@ -1,487 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using libsecondlife; -using libsecondlife.Packets; -using PhysicsSystem; -using Axiom.MathLib; - -namespace OpenSim.world -{ - public class Avatar : Entity - { - public static bool PhysicsEngineFlying; - public string firstname; - public string lastname; - public OpenSimClient ControllingClient; - private PhysicsActor _physActor; - private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; - private bool updateflag; - private byte movementflag; - private List forcesList = new List(); - private short _updateCount; - private Axiom.MathLib.Quaternion bodyRot; - - public Avatar(OpenSimClient TheClient) { - ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); - ControllingClient=TheClient; - position = new LLVector3(100.0f,100.0f,30.0f); - position.Z = OpenSim_Main.local_world.LandMap[(int)position.Y * 256 + (int)position.X]+1; - } - - public PhysicsActor PhysActor - { - set - { - this._physActor = value; - } - } - public override void addForces() - { - lock(this.forcesList) - { - if(this.forcesList.Count>0) - { - for(int i=0 ; i < this.forcesList.Count; i++) - { - NewForce force = this.forcesList[i]; - PhysicsVector phyVector = new PhysicsVector(force.X, force.Y, force.Z); - this._physActor.Velocity = phyVector; - this.updateflag = true; - this.velocity = new LLVector3(force.X, force.Y, force.Z); //shouldn't really be doing this - // but as we are setting the velocity (rather than using real forces) at the moment it is okay. - } - for(int i=0 ; i < this.forcesList.Count; i++) - { - this.forcesList.RemoveAt(0); - } - } - } - } - - public override void update() - { - - if(this.updateflag) - { - //need to send movement info - //so create the improvedterseobjectupdate packet - //use CreateTerseBlock() - ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); - ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); - terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME - terse.RegionData.TimeDilation = 64096; - terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; - terse.ObjectData[0] = terseBlock; - foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) { - client.OutPacket(terse); - } - - updateflag =false; - //this._updateCount = 0; - } - else - { - //if((movementflag & 1) !=0) - //{ - _updateCount++; - if(( (!PhysicsEngineFlying) && (_updateCount>3)) || (_updateCount>0)) - { - //It has been a while since last update was sent so lets send one. - ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); - ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); - terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME - terse.RegionData.TimeDilation = 64096; - terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; - terse.ObjectData[0] = terseBlock; - foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) { - client.OutPacket(terse); - } - _updateCount = 0; - } - //} - } - } - - public static void SetupTemplate(string name) - { - int i = 0; - FileInfo fInfo = new FileInfo(name); - long numBytes = fInfo.Length; - FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); - BinaryReader br = new BinaryReader(fStream); - byte [] data1 = br.ReadBytes((int)numBytes); - br.Close(); - fStream.Close(); - - libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); - - System.Text.Encoding enc = System.Text.Encoding.ASCII; - libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16); - pos.X = 100f; - objdata.ID = 8880000; - objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); - libsecondlife.LLVector3 pos2 = new LLVector3(100f,100f,23f); - //objdata.FullID=user.AgentID; - byte[] pb = pos.GetBytes(); - Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length); - - Avatar.AvatarTemplate = objdata; - } - - public void CompleteMovement(World RegionInfo) { - ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet"); - AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); - mov.AgentData.SessionID = this.ControllingClient.SessionID; - mov.AgentData.AgentID = this.ControllingClient.AgentID; - mov.Data.RegionHandle = OpenSim_Main.cfg.RegionHandle; - // TODO - dynamicalise this stuff - mov.Data.Timestamp = 1172750370; - mov.Data.Position = new LLVector3(100f, 100f, 23f); - mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0); - - ControllingClient.OutPacket(mov); - } - - public void SendInitialPosition() { - - System.Text.Encoding _enc = System.Text.Encoding.ASCII; - //send a objectupdate packet with information about the clients avatar - ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); - objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; - objupdate.RegionData.TimeDilation = 64096; - objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; - - objupdate.ObjectData[0] = AvatarTemplate; - //give this avatar object a local id and assign the user a name - objupdate.ObjectData[0].ID = this.localid; - objupdate.ObjectData[0].FullID = ControllingClient.AgentID; - objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0"); - - libsecondlife.LLVector3 pos2 = new LLVector3((float)this.position.X, (float)this.position.Y, (float)this.position.Z); - - byte[] pb = pos2.GetBytes(); - - Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); - OpenSim_Main.local_world._localNumber++; - - foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) - { - client.OutPacket(objupdate); - if(client.AgentID != ControllingClient.AgentID) - { - SendAppearanceToOtherAgent(client); - } - } - //this.ControllingClient.OutPacket(objupdate); - } - - public void SendInitialAppearance() { - AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); - aw.AgentData.AgentID = this.ControllingClient.AgentID; - aw.AgentData.SerialNum = 0; - aw.AgentData.SessionID = ControllingClient.SessionID; - - aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; - AgentWearablesUpdatePacket.WearableDataBlock awb = new AgentWearablesUpdatePacket.WearableDataBlock(); - awb.WearableType = (byte)0; - awb.AssetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); - awb.ItemID = LLUUID.Random(); - aw.WearableData[0] = awb; - - for(int i=1; i<13; i++) - { - awb = new AgentWearablesUpdatePacket.WearableDataBlock(); - awb.WearableType = (byte)i; - awb.AssetID = new LLUUID("00000000-0000-0000-0000-000000000000"); - awb.ItemID = new LLUUID("00000000-0000-0000-0000-000000000000"); - aw.WearableData[i] = awb; - } - - ControllingClient.OutPacket(aw); - } - - public ObjectUpdatePacket CreateUpdatePacket() - { - System.Text.Encoding _enc = System.Text.Encoding.ASCII; - //send a objectupdate packet with information about the clients avatar - ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); - objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; - objupdate.RegionData.TimeDilation = 64096; - objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; - - objupdate.ObjectData[0] = AvatarTemplate; - //give this avatar object a local id and assign the user a name - objupdate.ObjectData[0].ID = this.localid; - objupdate.ObjectData[0].FullID = ControllingClient.AgentID; - objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0"); - - libsecondlife.LLVector3 pos2 = new LLVector3((float)this._physActor.Position.X, (float)this._physActor.Position.Y, (float)this._physActor.Position.Z); - - byte[] pb = pos2.GetBytes(); - - Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); - return objupdate; - } - - public void SendAppearanceToOtherAgent(OpenSimClient userInfo) - { - AvatarAppearancePacket avp = new AvatarAppearancePacket(); - - - avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218]; - //avp.ObjectData.TextureEntry=this.avatar_template.TextureEntry;// br.ReadBytes((int)numBytes); - - LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-0000-000000000005")); - avp.ObjectData.TextureEntry = ntex.ToBytes(); - - AvatarAppearancePacket.VisualParamBlock avblock = null; - for(int i = 0; i < 218; i++) - { - avblock = new AvatarAppearancePacket.VisualParamBlock(); - avblock.ParamValue = (byte)100; - avp.VisualParam[i] = avblock; - } - - avp.Sender.IsTrial = false; - avp.Sender.ID = ControllingClient.AgentID; - userInfo.OutPacket(avp); - - } - - public void HandleUpdate(AgentUpdatePacket pack) { - if(((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_FLY) !=0) - { - this._physActor.Flying = true; - } - else - { - this._physActor.Flying = false; - } - if(((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_POS) !=0) { - Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z); - if(((movementflag & 1) ==0) || (q!= this.bodyRot)) - { - //we should add a new force to the list - // but for now we will deal with velocities - NewForce newVelocity = new NewForce(); - Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0); - Axiom.MathLib.Vector3 direc = q * v3; - direc.Normalize(); - - //work out velocity for sim physics system - direc = direc * ((0.03f) * 128f); - if(this._physActor.Flying) - direc *=2; - - newVelocity.X = direc.x; - newVelocity.Y = direc.y; - newVelocity.Z = direc.z; - this.forcesList.Add(newVelocity); - movementflag = 1; - this.bodyRot = q; - } - } - else if((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_UP_POS) !=0) &&(PhysicsEngineFlying)) { - if(((movementflag & 2) ==0) && this._physActor.Flying) - { - //we should add a new force to the list - // but for now we will deal with velocities - NewForce newVelocity = new NewForce(); - Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, 1); - Axiom.MathLib.Vector3 direc = v3; - direc.Normalize(); - - //work out velocity for sim physics system - direc = direc * ((0.03f) * 128f *2); - newVelocity.X = direc.x; - newVelocity.Y = direc.y; - newVelocity.Z = direc.z; - this.forcesList.Add(newVelocity); - movementflag = 2; - } - } - else if((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_UP_NEG) !=0) && (PhysicsEngineFlying)) { - if(((movementflag & 4) ==0) && this._physActor.Flying) - { - //we should add a new force to the list - // but for now we will deal with velocities - NewForce newVelocity = new NewForce(); - Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, -1); - //Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z); - Axiom.MathLib.Vector3 direc = v3; - direc.Normalize(); - - //work out velocity for sim physics system - direc = direc * ((0.03f) * 128f *2); - newVelocity.X = direc.x; - newVelocity.Y = direc.y; - newVelocity.Z = direc.z; - this.forcesList.Add(newVelocity); - movementflag = 4; - } - } - else if(((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_NEG) !=0) { - Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z); - if(((movementflag & 8) ==0) || (q!= this.bodyRot)) - { - //we should add a new force to the list - // but for now we will deal with velocities - NewForce newVelocity = new NewForce(); - Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(-1, 0, 0); - Axiom.MathLib.Vector3 direc = q * v3; - direc.Normalize(); - - //work out velocity for sim physics system - direc = direc * ((0.03f) * 128f); - if(this._physActor.Flying) - direc *=2; - - newVelocity.X = direc.x; - newVelocity.Y = direc.y; - newVelocity.Z = direc.z; - this.forcesList.Add(newVelocity); - movementflag = 8; - this.bodyRot = q; - } - } - else - { - if((movementflag) !=0) - { - NewForce newVelocity = new NewForce(); - newVelocity.X = 0; - newVelocity.Y = 0; - newVelocity.Z = 0; - this.forcesList.Add(newVelocity); - movementflag = 0; - } - } - } - - //should be moved somewhere else - public void SendRegionHandshake(World RegionInfo) { - ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet"); - System.Text.Encoding _enc = System.Text.Encoding.ASCII; - RegionHandshakePacket handshake = new RegionHandshakePacket(); - - ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionhandshake() - Filling in RegionHandshake details"); - handshake.RegionInfo.BillableFactor = 0; - handshake.RegionInfo.IsEstateManager = false; - handshake.RegionInfo.TerrainHeightRange00 = 60; - handshake.RegionInfo.TerrainHeightRange01 = 60; - handshake.RegionInfo.TerrainHeightRange10 = 60; - handshake.RegionInfo.TerrainHeightRange11 = 60; - handshake.RegionInfo.TerrainStartHeight00 = 10; - handshake.RegionInfo.TerrainStartHeight01 = 10; - handshake.RegionInfo.TerrainStartHeight10 = 10; - handshake.RegionInfo.TerrainStartHeight11 = 10; - handshake.RegionInfo.SimAccess = 13; - handshake.RegionInfo.WaterHeight = 20; - handshake.RegionInfo.RegionFlags = 72458694; - handshake.RegionInfo.SimName = _enc.GetBytes(OpenSim_Main.cfg.RegionName + "\0"); - handshake.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000"); - handshake.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); - handshake.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); - handshake.RegionInfo.TerrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); - handshake.RegionInfo.TerrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); - handshake.RegionInfo.TerrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000"); - handshake.RegionInfo.TerrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000"); - handshake.RegionInfo.TerrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000"); - handshake.RegionInfo.TerrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000"); - handshake.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37"); - - ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Sending RegionHandshake packet"); - this.ControllingClient.OutPacket(handshake); - } - - public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock() - { - byte[] bytes = new byte[60]; - int i=0; - ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); - - dat.TextureEntry = AvatarTemplate.TextureEntry; - libsecondlife.LLVector3 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z); - - uint ID = this.localid; - - bytes[i++] = (byte)(ID % 256); - bytes[i++] = (byte)((ID >> 8) % 256); - bytes[i++] = (byte)((ID >> 16) % 256); - bytes[i++] = (byte)((ID >> 24) % 256); - bytes[i++] = 0; - bytes[i++] = 1; - i += 14; - bytes[i++] = 128; - bytes[i++] = 63; - - byte[] pb = pos2.GetBytes(); - Array.Copy(pb, 0, bytes, i, pb.Length); - i += 12; - ushort InternVelocityX; - ushort InternVelocityY; - ushort InternVelocityZ; - - Axiom.MathLib.Vector3 internDirec = new Axiom.MathLib.Vector3(this._physActor.Velocity.X, this._physActor.Velocity.Y, this._physActor.Velocity.Z); - internDirec = internDirec /128.0f; - internDirec.x += 1; - internDirec.y += 1; - internDirec.z += 1; - - InternVelocityX = (ushort)(32768 * internDirec.x); - InternVelocityY = (ushort)(32768 * internDirec.y); - InternVelocityZ = (ushort)(32768 * internDirec.z); - - ushort ac = 32767; - bytes[i++] = (byte)(InternVelocityX % 256); - bytes[i++] = (byte)((InternVelocityX >> 8) % 256); - bytes[i++] = (byte)(InternVelocityY % 256); - bytes[i++] = (byte)((InternVelocityY>> 8) % 256); - bytes[i++] = (byte)(InternVelocityZ % 256); - bytes[i++] = (byte)((InternVelocityZ >> 8) % 256); - - //accel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - - //rot - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - - //rotation vel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - - dat.Data=bytes; - return(dat); - } - } - - public class NewForce - { - public float X; - public float Y; - public float Z; - - public NewForce() - { - - } - } -} diff --git a/src/world/Primitive.cs b/src/world/Primitive.cs deleted file mode 100644 index 6be33ef853..0000000000 --- a/src/world/Primitive.cs +++ /dev/null @@ -1,429 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.types; -using libsecondlife; -using libsecondlife.Packets; -using GridInterfaces; -using PhysicsSystem; - -namespace OpenSim.world -{ - public class Primitive : Entity - { - protected float mesh_cutbegin; - protected float mesh_cutend; - protected PrimData primData; - protected bool newPrimFlag; - protected bool updateFlag; - protected bool dirtyFlag; - private ObjectUpdatePacket OurPacket; - private PhysicsActor _physActor; - private bool physicsEnabled; - - public bool PhysicsEnabled - { - get - { - return physicsEnabled; - } - set - { - physicsEnabled = value; - } - } - public bool UpdateFlag - { - get - { - return updateFlag; - } - set - { - updateFlag = value; - } - } - public LLVector3 Scale - { - set - { - this.primData.Scale = value; - this.dirtyFlag = true; - } - get - { - return this.primData.Scale; - } - } - public PhysicsActor PhysActor - { - set - { - this._physActor = value; - } - } - - public Primitive() - { - mesh_cutbegin = 0.0f; - mesh_cutend = 1.0f; - } - - public override Mesh getMesh() - { - Mesh mesh = new Mesh(); - Triangle tri = new Triangle( - new Axiom.MathLib.Vector3(0.0f, 1.0f, 1.0f), - new Axiom.MathLib.Vector3(1.0f, 0.0f, 1.0f), - new Axiom.MathLib.Vector3(1.0f, 1.0f, 0.0f)); - - mesh.AddTri(tri); - mesh += base.getMesh(); - - return mesh; - } - - public void UpdatePosition( LLVector3 pos) - { - this.position = pos; - if(this._physActor != null && this.physicsEnabled) - { - this._physActor.Position = new PhysicsVector(pos.X, pos.Y, pos.Z); - } - this.updateFlag = true; - } - - public override void update() - { - if(this.newPrimFlag) - { - foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) { - client.OutPacket(OurPacket); - } - this.newPrimFlag = false; - } - else if(this.updateFlag) - { - ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); - terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME - terse.RegionData.TimeDilation = 64096; - terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; - terse.ObjectData[0] = this.CreateImprovedBlock(); - foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) { - client.OutPacket(terse); - } - this.updateFlag = false; - } - else if(this.dirtyFlag) - { - foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) { - UpdateClient(client); - } - this.dirtyFlag = false; - } - else - { - if(this._physActor != null && this.physicsEnabled) - { - ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); - terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME - terse.RegionData.TimeDilation = 64096; - terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; - terse.ObjectData[0] = this.CreateImprovedBlock(); - foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) { - client.OutPacket(terse); - } - } - } - } - - public void UpdateClient(OpenSimClient RemoteClient) - { - - LLVector3 lPos; - if( this._physActor != null && this.physicsEnabled) - { - PhysicsVector pPos = this._physActor.Position; - lPos = new LLVector3( pPos.X, pPos.Y, pPos.Z); - } - else - { - lPos = this.position; - } - byte[] pb = lPos.GetBytes(); - Array.Copy(pb, 0, OurPacket.ObjectData[0].ObjectData, 0, pb.Length); - - // OurPacket should be update with the follwing in updateShape() rather than having to do it here - OurPacket.ObjectData[0].OwnerID = this.primData.OwnerID; - OurPacket.ObjectData[0].PCode = this.primData.PCode; - OurPacket.ObjectData[0].PathBegin = this.primData.PathBegin; - OurPacket.ObjectData[0].PathEnd = this.primData.PathEnd; - OurPacket.ObjectData[0].PathScaleX = this.primData.PathScaleX; - OurPacket.ObjectData[0].PathScaleY = this.primData.PathScaleY; - OurPacket.ObjectData[0].PathShearX = this.primData.PathShearX; - OurPacket.ObjectData[0].PathShearY = this.primData.PathShearY; - OurPacket.ObjectData[0].PathSkew = this.primData.PathSkew; - OurPacket.ObjectData[0].ProfileBegin = this.primData.ProfileBegin; - OurPacket.ObjectData[0].ProfileEnd = this.primData.ProfileEnd; - OurPacket.ObjectData[0].Scale = this.primData.Scale; - OurPacket.ObjectData[0].PathCurve = this.primData.PathCurve; - OurPacket.ObjectData[0].ProfileCurve = this.primData.ProfileCurve; - OurPacket.ObjectData[0].ParentID = 0; - OurPacket.ObjectData[0].ProfileHollow = this.primData.ProfileHollow; - //finish off copying rest of shape data - OurPacket.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset; - OurPacket.ObjectData[0].PathRevolutions = this.primData.PathRevolutions; - OurPacket.ObjectData[0].PathTaperX = this.primData.PathTaperX; - OurPacket.ObjectData[0].PathTaperY = this.primData.PathTaperY; - OurPacket.ObjectData[0].PathTwist = this.primData.PathTwist; - OurPacket.ObjectData[0].PathTwistBegin= this.primData.PathTwistBegin; - - RemoteClient.OutPacket(OurPacket); - } - - public void UpdateShape(ObjectShapePacket.ObjectDataBlock addPacket) - { - this.primData.PathBegin = addPacket.PathBegin; - this.primData.PathEnd = addPacket.PathEnd; - this.primData.PathScaleX = addPacket.PathScaleX; - this.primData.PathScaleY = addPacket.PathScaleY; - this.primData.PathShearX = addPacket.PathShearX; - this.primData.PathShearY = addPacket.PathShearY; - this.primData.PathSkew = addPacket.PathSkew; - this.primData.ProfileBegin = addPacket.ProfileBegin; - this.primData.ProfileEnd = addPacket.ProfileEnd; - this.primData.PathCurve = addPacket.PathCurve; - this.primData.ProfileCurve = addPacket.ProfileCurve; - this.primData.ProfileHollow = addPacket.ProfileHollow; - this.primData.PathRadiusOffset = addPacket.PathRadiusOffset; - this.primData.PathRevolutions = addPacket.PathRevolutions; - this.primData.PathTaperX = addPacket.PathTaperX; - this.primData.PathTaperY = addPacket.PathTaperY; - this.primData.PathTwist = addPacket.PathTwist; - this.primData.PathTwistBegin =addPacket.PathTwistBegin; - this.dirtyFlag = true; - } - - public void CreateFromPacket( ObjectAddPacket addPacket, LLUUID agentID, uint localID) - { - ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); - objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; - objupdate.RegionData.TimeDilation = 64096; - - objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; - PrimData PData = new PrimData(); - this.primData = PData; - objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock(); - objupdate.ObjectData[0].PSBlock = new byte[0]; - objupdate.ObjectData[0].ExtraParams = new byte[1]; - objupdate.ObjectData[0].MediaURL = new byte[0]; - objupdate.ObjectData[0].NameValue = new byte[0]; - objupdate.ObjectData[0].Text = new byte[0]; - objupdate.ObjectData[0].TextColor = new byte[4]; - objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0,0,0); - objupdate.ObjectData[0].JointPivot = new LLVector3(0,0,0); - objupdate.ObjectData[0].Material = 3; - objupdate.ObjectData[0].UpdateFlags=32+65536+131072+256+4+8+2048+524288+268435456; - objupdate.ObjectData[0].TextureAnim = new byte[0]; - objupdate.ObjectData[0].Sound = LLUUID.Zero; - LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); - objupdate.ObjectData[0].TextureEntry = ntex.ToBytes(); - objupdate.ObjectData[0].State = 0; - objupdate.ObjectData[0].Data = new byte[0]; - PData.OwnerID = objupdate.ObjectData[0].OwnerID = agentID; - PData.PCode = objupdate.ObjectData[0].PCode = addPacket.ObjectData.PCode; - PData.PathBegin = objupdate.ObjectData[0].PathBegin = addPacket.ObjectData.PathBegin; - PData.PathEnd = objupdate.ObjectData[0].PathEnd = addPacket.ObjectData.PathEnd; - PData.PathScaleX = objupdate.ObjectData[0].PathScaleX = addPacket.ObjectData.PathScaleX; - PData.PathScaleY = objupdate.ObjectData[0].PathScaleY = addPacket.ObjectData.PathScaleY; - PData.PathShearX = objupdate.ObjectData[0].PathShearX = addPacket.ObjectData.PathShearX; - PData.PathShearY = objupdate.ObjectData[0].PathShearY = addPacket.ObjectData.PathShearY; - PData.PathSkew = objupdate.ObjectData[0].PathSkew = addPacket.ObjectData.PathSkew; - PData.ProfileBegin = objupdate.ObjectData[0].ProfileBegin = addPacket.ObjectData.ProfileBegin; - PData.ProfileEnd = objupdate.ObjectData[0].ProfileEnd = addPacket.ObjectData.ProfileEnd; - PData.Scale = objupdate.ObjectData[0].Scale = addPacket.ObjectData.Scale; - PData.PathCurve = objupdate.ObjectData[0].PathCurve = addPacket.ObjectData.PathCurve; - PData.ProfileCurve = objupdate.ObjectData[0].ProfileCurve = addPacket.ObjectData.ProfileCurve; - PData.ParentID = objupdate.ObjectData[0].ParentID = 0; - PData.ProfileHollow = objupdate.ObjectData[0].ProfileHollow = addPacket.ObjectData.ProfileHollow; - - PData.PathRadiusOffset = objupdate.ObjectData[0].PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset; - PData.PathRevolutions = objupdate.ObjectData[0].PathRevolutions = addPacket.ObjectData.PathRevolutions; - PData.PathTaperX = objupdate.ObjectData[0].PathTaperX = addPacket.ObjectData.PathTaperX; - PData.PathTaperY = objupdate.ObjectData[0].PathTaperY = addPacket.ObjectData.PathTaperY; - PData.PathTwist = objupdate.ObjectData[0].PathTwist = addPacket.ObjectData.PathTwist; - PData.PathTwistBegin = objupdate.ObjectData[0].PathTwistBegin = addPacket.ObjectData.PathTwistBegin; - - //finish off copying rest of shape data - - objupdate.ObjectData[0].ID = (uint)(localID); - objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efef" + (localID- 702000).ToString("00000")); - objupdate.ObjectData[0].ObjectData = new byte[60]; - objupdate.ObjectData[0].ObjectData[46] = 128; - objupdate.ObjectData[0].ObjectData[47] = 63; - LLVector3 pos1= addPacket.ObjectData.RayEnd; - //update position - byte[] pb = pos1.GetBytes(); - Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length); - - this.newPrimFlag = true; - this.uuid = objupdate.ObjectData[0].FullID; - this.localid = objupdate.ObjectData[0].ID; - this.position = pos1; - this.OurPacket = objupdate; - } - - public void CreateFromStorage(PrimData store) - { - //need to clean this up as it shares a lot of code with CreateFromPacket() - ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); - objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; - objupdate.RegionData.TimeDilation = 64096; - objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; - - this.primData = store; - objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock(); - objupdate.ObjectData[0].PSBlock = new byte[0]; - objupdate.ObjectData[0].ExtraParams = new byte[1]; - objupdate.ObjectData[0].MediaURL = new byte[0]; - objupdate.ObjectData[0].NameValue = new byte[0]; - objupdate.ObjectData[0].Text = new byte[0]; - objupdate.ObjectData[0].TextColor = new byte[4]; - objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0,0,0); - objupdate.ObjectData[0].JointPivot = new LLVector3(0,0,0); - objupdate.ObjectData[0].Material = 3; - objupdate.ObjectData[0].UpdateFlags=32+65536+131072+256+4+8+2048+524288+268435456; - objupdate.ObjectData[0].TextureAnim = new byte[0]; - objupdate.ObjectData[0].Sound = LLUUID.Zero; - LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); - objupdate.ObjectData[0].TextureEntry = ntex.ToBytes(); - objupdate.ObjectData[0].State = 0; - objupdate.ObjectData[0].Data = new byte[0]; - objupdate.ObjectData[0].OwnerID = this.primData.OwnerID; - objupdate.ObjectData[0].PCode = this.primData.PCode; - objupdate.ObjectData[0].PathBegin = this.primData.PathBegin; - objupdate.ObjectData[0].PathEnd = this.primData.PathEnd; - objupdate.ObjectData[0].PathScaleX = this.primData.PathScaleX; - objupdate.ObjectData[0].PathScaleY = this.primData.PathScaleY; - objupdate.ObjectData[0].PathShearX = this.primData.PathShearX; - objupdate.ObjectData[0].PathShearY = this.primData.PathShearY; - objupdate.ObjectData[0].PathSkew = this.primData.PathSkew; - objupdate.ObjectData[0].ProfileBegin = this.primData.ProfileBegin; - objupdate.ObjectData[0].ProfileEnd = this.primData.ProfileEnd; - objupdate.ObjectData[0].Scale = this.primData.Scale; - objupdate.ObjectData[0].PathCurve = this.primData.PathCurve; - objupdate.ObjectData[0].ProfileCurve = this.primData.ProfileCurve; - objupdate.ObjectData[0].ParentID = 0; - objupdate.ObjectData[0].ProfileHollow = this.primData.ProfileHollow; - //finish off copying rest of shape data - objupdate.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset; - objupdate.ObjectData[0].PathRevolutions = this.primData.PathRevolutions; - objupdate.ObjectData[0].PathTaperX = this.primData.PathTaperX; - objupdate.ObjectData[0].PathTaperY = this.primData.PathTaperY; - objupdate.ObjectData[0].PathTwist = this.primData.PathTwist; - objupdate.ObjectData[0].PathTwistBegin= this.primData.PathTwistBegin; - - objupdate.ObjectData[0].ID = (uint)store.LocalID; - objupdate.ObjectData[0].FullID = store.FullID; - - objupdate.ObjectData[0].ObjectData = new byte[60]; - objupdate.ObjectData[0].ObjectData[46] = 128; - objupdate.ObjectData[0].ObjectData[47] = 63; - LLVector3 pos1= store.Position; - //update position - byte[] pb = pos1.GetBytes(); - Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length); - - this.uuid = objupdate.ObjectData[0].FullID; - this.localid = objupdate.ObjectData[0].ID; - this.position = pos1; - this.OurPacket = objupdate; - - } - public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock() - { - uint ID = this.localid; - byte[] bytes = new byte[60]; - - int i = 0; - ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); - dat.TextureEntry = this.OurPacket.ObjectData[0].TextureEntry; - - bytes[i++] = (byte)(ID % 256); - bytes[i++] = (byte)((ID >> 8) % 256); - bytes[i++] = (byte)((ID >> 16) % 256); - bytes[i++] = (byte)((ID >> 24) % 256); - bytes[i++]= 0; - bytes[i++]= 0; - - LLVector3 lPos; - if( this._physActor != null && this.physicsEnabled) - { - PhysicsVector pPos = this._physActor.Position; - lPos = new LLVector3( pPos.X, pPos.Y, pPos.Z); - } - else - { - lPos = this.position; - } - byte[] pb = lPos.GetBytes(); - Array.Copy(pb, 0, bytes, i, pb.Length); - i += 12; - ushort ac = 32767; - - //vel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - - //accel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - - ushort rw, rx,ry,rz; - rw = (ushort)(32768 * (this.rotation.w+1)); - rx = (ushort)(32768 * (this.rotation.x+1)); - ry = (ushort)(32768 * (this.rotation.y+1)); - rz = (ushort)(32768 * (this.rotation.z+1)); - - //rot - bytes[i++] = (byte)(rx % 256); - bytes[i++] = (byte)((rx >> 8) % 256); - bytes[i++] = (byte)(ry % 256); - bytes[i++] = (byte)((ry >> 8) % 256); - bytes[i++] = (byte)(rz % 256); - bytes[i++] = (byte)((rz >> 8) % 256); - bytes[i++] = (byte)(rw % 256); - bytes[i++] = (byte)((rw >> 8) % 256); - - //rotation vel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - - dat.Data=bytes; - return dat; - } - - public override void BackUp() - { - - this.primData.FullID = this.uuid; - this.primData.LocalID = this.localid; - this.primData.Position = this.position; - this.primData.Rotation = new LLQuaternion(this.rotation.x, this.rotation.y, this.rotation.z , this.rotation.w); - OpenSim_Main.local_world.localStorage.StorePrim(this.primData); - } - } - -}