Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f0f5060ec | ||
|
|
4c10826caa | ||
|
|
873c9098d8 | ||
|
|
6ce5080049 | ||
|
|
b9546d12f2 | ||
|
|
a49c524c9e | ||
|
|
b7f1fc116e | ||
|
|
28aa8010b2 | ||
|
|
c09eb00031 | ||
|
|
1113b3b6eb | ||
|
|
a81a16f22f | ||
|
|
8428b25939 |
34
.gitignore
vendored
34
.gitignore
vendored
@@ -9,14 +9,6 @@
|
||||
*.pdb
|
||||
*.pidb
|
||||
*.dll.build
|
||||
*.dll
|
||||
*.VisualState.xml
|
||||
*/*/obj
|
||||
*/*/*/obj
|
||||
*/*/*/*/obj
|
||||
*/*/*/*/*/obj
|
||||
*/*/*/*/*/*/obj
|
||||
*/*/*/*/*/*/*/obj
|
||||
*/*/bin
|
||||
*/*/*/bin
|
||||
*/*/*/*/bin
|
||||
@@ -26,14 +18,9 @@
|
||||
bin/Debug/*.dll
|
||||
bin/*.dll.mdb
|
||||
bin/*.db
|
||||
bin/*.db-journal
|
||||
bin/addin-db-*
|
||||
bin/*.dll
|
||||
bin/OpenSim.vshost.exe.config
|
||||
bin/OpenSim.32BitLaunch.vshost.exe.config
|
||||
bin/OpenSim.32BitLaunch.log
|
||||
UpgradeLog.XML
|
||||
_UpgradeReport_Files/
|
||||
bin/ScriptEngines/*-*-*-*-*
|
||||
bin/ScriptEngines/*.dll
|
||||
bin/ScriptEngines/*/*.dll
|
||||
@@ -46,8 +33,6 @@ bin/Physics*
|
||||
bin/Terrain*
|
||||
bin/Regions/*
|
||||
bin/UserAssets
|
||||
bin/assetcache
|
||||
bin/maptiles
|
||||
bin/estate_settings.xml
|
||||
bin/config-include/CenomeCache.ini
|
||||
bin/config-include/FlotsamCache.ini
|
||||
@@ -60,7 +45,6 @@ bin/OpenSim.Grid.InventoryServer.log
|
||||
bin/OpenSim.Grid.MessagingServer.log
|
||||
bin/OpenSim.Grid.UserServer.log
|
||||
bin/OpenSim.log
|
||||
bin/*.manifest
|
||||
bin/crashes/
|
||||
Examples/*.dll
|
||||
OpenSim.build
|
||||
@@ -77,20 +61,4 @@ TAGS
|
||||
Makefile.local
|
||||
bin/.version
|
||||
compile.bat
|
||||
addon-modules
|
||||
OpenSim/Data/Tests/test-results/
|
||||
OpenSim/Framework/Serialization/Tests/test-results/
|
||||
OpenSim/Framework/Servers/Tests/test-results/
|
||||
OpenSim/Framework/Tests/test-results/
|
||||
OpenSim/Region/ClientStack/Linden/Caps/test-results/
|
||||
OpenSim/Region/ClientStack/Linden/UDP/Tests/test-results/
|
||||
OpenSim/Region/CoreModules/test-results/
|
||||
OpenSim/Region/Framework/test-results/
|
||||
OpenSim/Region/OptionalModules/test-results/
|
||||
OpenSim/Region/Physics/BulletDotNETPlugin/
|
||||
OpenSim/Region/Physics/Manager/test-results/
|
||||
OpenSim/Region/Physics/OdePlugin/Tests/test-results/
|
||||
OpenSim/Region/ScriptEngine/test-results/
|
||||
OpenSim/Tests/Common/test-results/
|
||||
OpenSim/Tests/test-results/
|
||||
test-results/
|
||||
|
||||
|
||||
@@ -1,67 +1,33 @@
|
||||
<!-- -*- xml -*- -->
|
||||
<!-- please leave the top comment for us emacs folks -->
|
||||
<property name="projectdir" value="opensim-0.5.5" />
|
||||
<property name="nunitcmd" value="nunit-console" />
|
||||
|
||||
<!-- This target produces a source distribution of OpenSimulator -->
|
||||
<!-- TODO: A few parameters still need to be tweaked after running this - need to do this automatically with sed or similar -->
|
||||
<target name="distsrc">
|
||||
<copy file="bin/OpenSim.ini.example" tofile="bin/OpenSim.ini"/>
|
||||
<copy file="bin/config-include/StandaloneCommon.ini.example" tofile="bin/config-include/StandaloneCommon.ini"/>
|
||||
<copy file="bin/config-include/FlotsamCache.ini.example" tofile="bin/config-include/FlotsamCache.ini"/>
|
||||
<!-- delete files generated by runprebuild.sh which had to be run in order to generate the build file for this target-->
|
||||
<delete>
|
||||
<fileset basedir="OpenSim">
|
||||
<include name="**/*.build"/>
|
||||
<include name="**/*.csproj*"/>
|
||||
<include name="**/*.dll.build"/>
|
||||
<include name="**/*.pidb"/>
|
||||
<exclude name="Tools/OpenSim.32BitLaunch/**"/>
|
||||
<exclude name="Tools/Robust.32BitLaunch/**"/>
|
||||
<exclude name="Tools/LaunchSLClient/**"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
<delete>
|
||||
<fileset>
|
||||
<include name="OpenSim.build"/>
|
||||
<include name="OpenSim.sln"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<property name="distbindir" value="distbin" />
|
||||
<!-- This target produces a binary directory called distbin/ in OpenSim/bin which contains everything needed for binary distribution -->
|
||||
<!-- For safety/laziness sake, we're going to take the approach of deleting known extraneous files here rather than
|
||||
trying to copy across only the essential ones -->
|
||||
<target name="distbin">
|
||||
<delete dir="${distbindir}"/>
|
||||
<copy todir="${distbindir}">
|
||||
<fileset>
|
||||
<include name="**"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<delete dir="${distbindir}/OpenSim"/>
|
||||
<delete dir="${distbindir}/Prebuild"/>
|
||||
<delete dir="${distbindir}/%temp%"/>
|
||||
<delete dir="${distbindir}/.nant"/>
|
||||
<delete>
|
||||
<fileset basedir="${distbindir}">
|
||||
<include name="compile.bat"/>
|
||||
<include name="BUILDING.txt"/>
|
||||
<include name="Makefile"/>
|
||||
<include name="nant-color"/>
|
||||
<include name="OpenSim.*"/>
|
||||
<include name="prebuild.xml"/>
|
||||
<include name="runprebuild*"/>
|
||||
<include name="TESTING.txt"/>
|
||||
<include name="TestResult.xml"/>
|
||||
<include name="bin/OpenSim.Server.ini"/>
|
||||
<include name="bin/Regions/Regions.ini"/>
|
||||
<include name="bin/*.db"/>
|
||||
<include name="**/.git/**"/>
|
||||
<include name=".gitignore"/>
|
||||
<include name=".hgignore"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
<target name="distdir">
|
||||
<delete dir="${projectdir}" />
|
||||
<copy todir="${projectdir}">
|
||||
<fileset basedir=".">
|
||||
<include name="ThirdPartyLicenses/**" />
|
||||
<include name="CONTRIBUTORS.txt" />
|
||||
<include name="README" />
|
||||
<include name="OpenSim/**/*.cs" />
|
||||
<include name="**/*.build" />
|
||||
<include name="**/*.csproj" />
|
||||
<include name="**/*.csproj.user" />
|
||||
<include name="**/*.sln" />
|
||||
<include name="bin/*.dll" />
|
||||
<include name="bin/*.so" />
|
||||
<include name="bin/*.config" />
|
||||
<include name="bin/assets/**" />
|
||||
<include name="bin/data/**" />
|
||||
<include name="bin/OpenSim*xml" />
|
||||
<!-- the next is to exclude built libs -->
|
||||
<exclude name="bin/OpenSim.*dll" />
|
||||
<include name="bin/OpenSim.ini" />
|
||||
<include name="bin/defaultstripe.png" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<touch file="${projectdir}/bin/startup_commands.txt" />
|
||||
</target>
|
||||
|
||||
<target name="test" depends="build, find-nunit">
|
||||
@@ -72,16 +38,16 @@
|
||||
the assembly here as an exec, and you add the fail clause later.
|
||||
This lets all the unit tests run and tells you if they fail at the
|
||||
end, instead of stopping short -->
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.tests">
|
||||
<arg value="./bin/OpenSim.Tests.dll" />
|
||||
</exec>
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.tests)==0}" />
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.framework.tests">
|
||||
<arg value="./bin/OpenSim.Framework.Tests.dll" />
|
||||
</exec>
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.tests)==0}" />
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.framework.communications.tests">
|
||||
<arg value="./bin/OpenSim.Framework.Communications.Tests.dll" />
|
||||
</exec>
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.communications.tests)==0}" />
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.framework.servers.tests">
|
||||
<arg value="./bin/OpenSim.Framework.Servers.Tests.dll" />
|
||||
</exec>
|
||||
@@ -92,15 +58,12 @@
|
||||
</exec>
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.serialization.tests)==0}" />
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.region.clientstack.lindencaps.tests">
|
||||
<arg value="./bin/OpenSim.Region.ClientStack.LindenCaps.Tests.dll" />
|
||||
</exec>
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.clientstack.lindencaps.tests)==0}" />
|
||||
|
||||
<!--
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.region.clientstack.lindenudp.tests">
|
||||
<arg value="./bin/OpenSim.Region.ClientStack.LindenUDP.Tests.dll" />
|
||||
</exec>
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.clientstack.lindenudp.tests)==0}" />
|
||||
-->
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.region.scriptengine.tests">
|
||||
<arg value="./bin/OpenSim.Region.ScriptEngine.Tests.dll" />
|
||||
@@ -112,49 +75,130 @@
|
||||
</exec>
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.coremodules.tests)==0}" />
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.region.optionalmodules.tests">
|
||||
<arg value="./bin/OpenSim.Region.OptionalModules.Tests.dll" />
|
||||
</exec>
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.optionalmodules.tests)==0}" />
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.region.framework.tests">
|
||||
<arg value="./bin/OpenSim.Region.Framework.Tests.dll" />
|
||||
</exec>
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.framework.tests)==0}" />
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.data.tests">
|
||||
<arg value="./bin/OpenSim.Data.Tests.dll" />
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.data.sqlite.tests">
|
||||
<arg value="./bin/OpenSim.Data.SQLite.Tests.dll" />
|
||||
</exec>
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.data.tests)==0}" />
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.data.sqlite.tests)==0}" />
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.capabilities.handlers.tests">
|
||||
<arg value="./bin/OpenSim.Capabilities.Handlers.Tests.dll" />
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.data.mysql.tests">
|
||||
<arg value="./bin/OpenSim.Data.MySQL.Tests.dll" />
|
||||
</exec>
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.capabilities.handlers.tests)==0}" />
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.data.mysql.tests)==0}" />
|
||||
|
||||
<delete dir="%temp%"/>
|
||||
</target>
|
||||
|
||||
<target name="test-stress" depends="build, find-nunit">
|
||||
<setenv name="MONO_THREADS_PER_CPU" value="100" />
|
||||
<target name="test-cov" depends="build">
|
||||
<!-- Code Coverage Test. Prototype, only works with mono 1.2. Instructions in http://opensimulator.org/wiki/Automated_Testing -->
|
||||
<mkdir dir="cov" failonerror="false" />
|
||||
<exec program="mono">
|
||||
<arg value="--debug" />
|
||||
<arg value="--profile=monocov:outfile=./cov/OpenSim.Framework.Servers.cov,+[OpenSim.Framework.Servers]" />
|
||||
<arg value="/usr/lib/nunit/nunit-console.exe" />
|
||||
<arg value="./bin/OpenSim.Framework.Servers.Tests.dll" />
|
||||
</exec>
|
||||
<delete dir="./cov/OpenSim.Framework.Servers" />
|
||||
<exec program="monocov">
|
||||
<arg value="--export-html=./cov/OpenSim.Framework.Servers ./cov/OpenSim.Framework.Servers.cov" />
|
||||
</exec>
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.tests.stress">
|
||||
<arg value="./bin/OpenSim.Tests.Stress.dll" />
|
||||
</exec>
|
||||
<exec program="mono">
|
||||
<arg value="--debug" />
|
||||
<arg value="--profile=monocov:outfile=./cov/OpenSim.Framework.Communications.cov,+[OpenSim.Framework.Communications]" />
|
||||
<arg value="/usr/lib/nunit/nunit-console.exe" />
|
||||
<arg value="./bin/OpenSim.Framework.Communications.Tests.dll" />
|
||||
</exec>
|
||||
<delete dir="./cov/OpenSim.Framework.Communications" />
|
||||
<exec program="monocov">
|
||||
<arg value="--export-html=./cov/OpenSim.Framework.Servers ./cov/OpenSim.Framework.Communications.cov" />
|
||||
</exec>
|
||||
|
||||
<!--
|
||||
<exec program="mono">
|
||||
<arg value="--debug" />
|
||||
<arg value="--profile=monocov:outfile=./cov/OpenSim.Region.ClientStack.LindenUDP.cov,+[OpenSim.Region.ClientStack.LindenUDP]" />
|
||||
<arg value="/usr/lib/nunit/nunit-console.exe" />
|
||||
<arg value="./bin/OpenSim.Region.ClientStack.LindenUDP.Tests.dll" />
|
||||
</exec>
|
||||
<delete dir="./cov/OpenSim.Region.ClientStack.LindenUDP" />
|
||||
<exec program="monocov">
|
||||
<arg value="--export-html=./cov/OpenSim.Region.ClientStack.LindenUDP ./cov/OpenSim.Region.ClientStack.LindenUDP.cov" />
|
||||
</exec>
|
||||
-->
|
||||
|
||||
<exec program="mono">
|
||||
<arg value="--debug" />
|
||||
<arg value="--profile=monocov:outfile=./cov/OpenSim.Region.ScriptEngine.Shared.cov,+[OpenSim.Region.ScriptEngine.Shared]" />
|
||||
<arg value="/usr/lib/nunit/nunit-console.exe" />
|
||||
<arg value="./bin/OpenSim.Region.ScriptEngine.Shared.Tests.dll" />
|
||||
</exec>
|
||||
<delete dir="./cov/OpenSim.Region.ScriptEngine.Shared" />
|
||||
<exec program="monocov">
|
||||
<arg value="--export-html=./cov/OpenSim.Region.ScriptEngine.Shared ./cov/OpenSim.Region.ScriptEngine.Shared.cov" />
|
||||
</exec>
|
||||
|
||||
<exec program="mono">
|
||||
<arg value="--debug" />
|
||||
<arg value="--profile=monocov:outfile=./cov/OpenSim.Region.ScriptEngine.Shared.CodeTools.cov,+[OpenSim.Region.ScriptEngine.Shared.CodeTools]" />
|
||||
<arg value="/usr/lib/nunit/nunit-console.exe" />
|
||||
<arg value="./bin/OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests.dll" />
|
||||
</exec>
|
||||
<delete dir="./cov/OpenSim.Region.ScriptEngine.Shared.CodeTools" />
|
||||
<exec program="monocov">
|
||||
<arg value="--export-html=./cov/OpenSim.Region.ScriptEngine.Shared.CodeTools ./cov/OpenSim.Region.ScriptEngine.Shared.CodeTools.cov" />
|
||||
</exec>
|
||||
|
||||
<exec program="mono">
|
||||
<arg value="--debug" />
|
||||
<arg value="--profile=monocov:outfile=./cov/OpenSim.Region.CoreModules.cov,+[OpenSim.Region.CoreModules]" />
|
||||
<arg value="/usr/lib/nunit/nunit-console.exe" />
|
||||
<arg value="./bin/OpenSim.Region.CoreModules.Tests.dll" />
|
||||
</exec>
|
||||
<delete dir="./cov/OpenSim.Region.CoreModules" />
|
||||
<exec program="monocov">
|
||||
<arg value="--export-html=./cov/OpenSim.Region.CoreModules ./cov/OpenSim.Region.CoreModules.cov" />
|
||||
</exec>
|
||||
|
||||
<fail message="Failures reported in stress tests." unless="${int::parse(testresult.opensim.tests.stress)==0}" />
|
||||
<delete dir="%temp%"/>
|
||||
</target>
|
||||
<exec program="mono">
|
||||
<arg value="--debug" />
|
||||
<arg value="--profile=monocov:outfile=./cov/OpenSim.Region.Framework.cov,+[OpenSim.Region.Framework]" />
|
||||
<arg value="/usr/lib/nunit/nunit-console.exe" />
|
||||
<arg value="./bin/OpenSim.Region.Framework.Tests.dll" />
|
||||
</exec>
|
||||
<delete dir="./cov/OpenSim.Region.Framework" />
|
||||
<exec program="monocov">
|
||||
<arg value="--export-html=./cov/OpenSim.Region.Framework ./cov/OpenSim.Region.Framework.cov" />
|
||||
</exec>
|
||||
|
||||
<exec program="mono">
|
||||
<arg value="--debug" />
|
||||
<arg value="--profile=monocov:outfile=./cov/OpenSim.Data.SQLite.cov,+[OpenSim.Data.SQLite]" />
|
||||
<arg value="/usr/lib/nunit/nunit-console.exe" />
|
||||
<arg value="./bin/OpenSim.Data.SQLite.Tests.dll" />
|
||||
</exec>
|
||||
<delete dir="./cov/OpenSim.Data.SQLite" />
|
||||
<exec program="monocov">
|
||||
<arg value="--export-html=./cov/OpenSim.Data.SQLite ./cov/OpenSim.Data.SQLite.cov" />
|
||||
</exec>
|
||||
|
||||
<exec program="mono">
|
||||
<arg value="--debug" />
|
||||
<arg value="--profile=monocov:outfile=./cov/OpenSim.Data.MySQL.cov,+[OpenSim.Data.MySQL.Tests]" />
|
||||
<arg value="/usr/lib/nunit/nunit-console.exe" />
|
||||
<arg value="./bin/OpenSim.Data.MySQL.Tests.dll" />
|
||||
</exec>
|
||||
<delete dir="./cov/OpenSim.Data.MySQL" />
|
||||
<exec program="monocov">
|
||||
<arg value="--export-html=./cov/OpenSim.Data.MySQL ./cov/OpenSim.Data.MySQL.cov" />
|
||||
</exec>
|
||||
|
||||
<target name="test-perf" depends="build, find-nunit">
|
||||
<setenv name="MONO_THREADS_PER_CPU" value="100" />
|
||||
<delete file="C:\NUnitPrimaryTrace.txt" failonerror="false" />
|
||||
<delete file="TestResult.xml" failonerror="false" />
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.tests.performance">
|
||||
<arg value="./bin/OpenSim.Tests.Performance.dll" />
|
||||
</exec>
|
||||
|
||||
<fail message="Failures reported in performance tests." unless="${int::parse(testresult.opensim.tests.performance)==0}" />
|
||||
<delete dir="%temp%"/>
|
||||
</target>
|
||||
|
||||
<target name="find-nunit">
|
||||
@@ -167,24 +211,27 @@
|
||||
if="${int::parse(hasnunit2)==0}" />
|
||||
<property name="nunitcmd" value="nunit-console"
|
||||
if="${int::parse(hasnunit2)==1}" />
|
||||
|
||||
</target>
|
||||
|
||||
<!-- this is used for panda test execution -->
|
||||
<!-- work in progress -->
|
||||
|
||||
<target name="test-xml" depends="build, find-nunit">
|
||||
|
||||
|
||||
<mkdir dir="test-results" failonerror="false" />
|
||||
<!-- Unit Test Assembly -->
|
||||
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.tests">
|
||||
<arg value="./bin/OpenSim.Tests.dll" />
|
||||
<arg value="-xml=test-results/OpenSim.Tests.dll-Results.xml" />
|
||||
</exec>
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.framework.tests">
|
||||
<arg value="./bin/OpenSim.Framework.Tests.dll" />
|
||||
<arg value="-xml=test-results/OpenSim.Framework.Tests.dll-Results.xml" />
|
||||
</exec>
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.framework.communications.tests">
|
||||
<arg value="./bin/OpenSim.Framework.Communications.Tests.dll" />
|
||||
<arg value="-xml=test-results/OpenSim.Framework.Communications.Tests.dll-Results.xml" />
|
||||
</exec>
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.framework.serialization.tests">
|
||||
<arg value="./bin/OpenSim.Framework.Serialization.Tests.dll" />
|
||||
<arg value="-xml=test-results/OpenSim.Framework.Serialization.Tests.dll-Results.xml" />
|
||||
@@ -195,15 +242,12 @@
|
||||
<arg value="-xml=test-results/OpenSim.Framework.Servers.Tests.dll-Results.xml" />
|
||||
</exec>
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.region.clientstack.lindencaps.tests">
|
||||
<arg value="./bin/OpenSim.Region.ClientStack.LindenCaps.Tests.dll" />
|
||||
<arg value="-xml=test-results/OpenSim.Region.ClientStack.LindenCaps.Tests.dll-Results.xml" />
|
||||
</exec>
|
||||
|
||||
<!--
|
||||
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.region.clientstack.lindenudp.tests">
|
||||
<arg value="./bin/OpenSim.Region.ClientStack.LindenUDP.Tests.dll" />
|
||||
<arg value="-xml=test-results/OpenSim.Region.ClientStack.LindenUDP.Tests.dll-Results.xml" />
|
||||
</exec>
|
||||
-->
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.region.scriptengine.tests">
|
||||
<arg value="./bin/OpenSim.Region.ScriptEngine.Tests.dll" />
|
||||
@@ -215,38 +259,75 @@
|
||||
<arg value="-xml=test-results/OpenSim.Region.CoreModules.Tests.dll-Results.xml" />
|
||||
</exec>
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.region.optionalmodules.tests">
|
||||
<arg value="./bin/OpenSim.Region.OptionalModules.Tests.dll" />
|
||||
<arg value="-xml=test-results/OpenSim.Region.OptionalModules.Tests.dll-Results.xml" />
|
||||
</exec>
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.region.framework.tests">
|
||||
<arg value="./bin/OpenSim.Region.Framework.Tests.dll" />
|
||||
<arg value="-xml=test-results/OpenSim.Region.Framework.Tests.dll-Results.xml" />
|
||||
</exec>
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.data.tests">
|
||||
<arg value="./bin/OpenSim.Data.Tests.dll" />
|
||||
<arg value="-xml=test-results/OpenSim.Data.Tests.dll-Results.xml" />
|
||||
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.data.sqlite.tests">
|
||||
<arg value="./bin/OpenSim.Data.SQLite.Tests.dll" />
|
||||
<arg value="-xml=test-results/OpenSim.Data.SQLite.Tests.dll-Results.xml" />
|
||||
</exec>
|
||||
|
||||
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.capabilities.handlers.tests">
|
||||
<arg value="./bin/OpenSim.Capabilities.Handlers.Tests.dll" />
|
||||
<arg value="-xml=test-results/OpenSim.Capabilities.Handlers.Tests.dll-Results.xml" />
|
||||
<exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.data.mysql.tests">
|
||||
<arg value="./bin/OpenSim.Data.MySQL.Tests.dll" />
|
||||
<arg value="-xml=test-results/OpenSim.Data.MySQL.Tests.dll-Results.xml" />
|
||||
</exec>
|
||||
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.tests)==0}" />
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.tests)==0}" />
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.communications.tests)==0}" />
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.servers.tests)==0}" />
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.clientstack.lindenudp.tests)==0}" />
|
||||
<!-- <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.clientstack.lindenudp.tests)==0}" /> -->
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.scriptengine.tests)==0}" />
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.coremodules.tests)==0}" />
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.optionalmodules.tests)==0}" />
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.framework.tests)==0}" />
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.data.tests)==0}" />
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.capabilities.handlers.tests)==0}" />
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.data.sqlite.tests)==0}" />
|
||||
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.data.mysql.tests)==0}" />
|
||||
|
||||
</target>
|
||||
<!-- <exec program="nunit-console.exe" failonerror="false" resultproperty="testresult.acceptancetestassembly"> -->
|
||||
<!-- <arg value="AcceptanceTestAssembly.dll" /> -->
|
||||
<!-- <arg value="/xml=AcceptanceTestAssembly-Results.xml" /> -->
|
||||
<!-- </exec> -->
|
||||
|
||||
<!-- <fail message="Failures reported in unit tests." unless="${int::parse(testresult.unittestassembly)==0}" /> -->
|
||||
<!-- <fail message="Failures reported in acceptance tests." unless="${int::parse(testresult.acceptancetestassembly)==0}" /> -->
|
||||
<!-- </target> -->
|
||||
|
||||
|
||||
|
||||
<!-- <nunit2 failonerror="true" verbose="true"> -->
|
||||
<!-- <formatter type="Xml" usefile="true" extension=".xml" outputdir="./test-results" /> -->
|
||||
<!-- <test> -->
|
||||
<!-- <assemblies> -->
|
||||
<!-- <include name="./bin/OpenSim.Framework.Tests.dll" /> -->
|
||||
<!-- <include name="./bin/OpenSim.Framework.Communications.Tests.dll"/> -->
|
||||
<!-- <include name="./bin/OpenSim.Framework.Servers.Tests.dll" /> -->
|
||||
<!-- <include name="./bin/OpenSim.Region.ClientStack.LindenUDP.Tests.dll" /> -->
|
||||
<!-- <include name="./bin/OpenSim.Region.ScriptEngine.Tests.dll" /> -->
|
||||
<!-- <include name="./bin/OpenSim.Region.CoreModules.Tests.dll" /> -->
|
||||
<!-- <include name="./bin/OpenSim.Region.Framework.Tests.dll" /> -->
|
||||
<!-- <include name="./bin/OpenSim.Data.SQLite.Tests.dll" /> -->
|
||||
<!-- <include name="./bin/OpenSim.Data.MySQL.Tests.dll" /> -->
|
||||
<!-- </assemblies> -->
|
||||
<!-- </test> -->
|
||||
<!-- </nunit2> -->
|
||||
<!-- </target> -->
|
||||
|
||||
<target name="doxygen">
|
||||
<exec program="doxygen" workingdir="doc" commandline="doxygen.conf" />
|
||||
</target>
|
||||
|
||||
|
||||
<target name="dist" depends="distdir">
|
||||
<zip zipfile="${projectdir}.zip">
|
||||
<fileset basedir=".">
|
||||
<include name="${projectdir}/**" />
|
||||
</fileset>
|
||||
</zip>
|
||||
<tar destfile="${projectdir}.tar.gz" compression="GZip">
|
||||
<fileset basedir=".">
|
||||
<include name="${projectdir}/**" />
|
||||
</fileset>
|
||||
</tar>
|
||||
</target>
|
||||
|
||||
39
BUILDING.txt
39
BUILDING.txt
@@ -1,39 +0,0 @@
|
||||
==== Building OpenSim ====
|
||||
|
||||
=== Building on Windows ===
|
||||
|
||||
Steps:
|
||||
* runprebuild.bat
|
||||
* Load OpenSim.sln into Visual Studio .NET and build the solution.
|
||||
* chdir bin
|
||||
* copy OpenSim.ini.example to OpenSim.ini and other appropriate files in bin/config-include
|
||||
* run OpenSim.exe
|
||||
|
||||
=== Building on Linux ===
|
||||
|
||||
Prereqs:
|
||||
* Mono >= 2.4.3
|
||||
* Nant >= 0.85
|
||||
* On some Linux distributions you may need to install additional packages.
|
||||
See http://opensimulator.org/wiki/Dependencies for more information.
|
||||
|
||||
* May also use xbuild (included in mono distributions)
|
||||
* May use Monodevelop, a cross-platform IDE
|
||||
|
||||
From the distribution type:
|
||||
* ./runprebuild.sh
|
||||
* nant (or xbuild)
|
||||
* cd bin
|
||||
* copy OpenSim.ini.example to OpenSim.ini and other appropriate files in bin/config-include
|
||||
* run mono OpenSim.exe
|
||||
|
||||
=== Using Monodevelop ===
|
||||
|
||||
From the distribution type:
|
||||
* ./runprebuild.sh
|
||||
* type monodevelop OpenSim.sln
|
||||
|
||||
=== References ===
|
||||
|
||||
Helpful resources:
|
||||
* http://opensimulator.org/wiki/Build_Instructions
|
||||
@@ -1,39 +1,34 @@
|
||||
<<<>>>>The following people have contributed to OpenSim (Thank you
|
||||
The following people have contributed to OpenSim (Thank you
|
||||
for your effort!)
|
||||
|
||||
Add your name in here if you have committed to OpenSim
|
||||
|
||||
= Current OpenSim Developers (in very rough order of appearance) =
|
||||
These folks represent the current core team for OpenSim, and are the
|
||||
people that make the day to day of OpenSim happen.
|
||||
|
||||
* justincc (OSVW Consulting, justincc.org)
|
||||
* chi11ken (Genkii)
|
||||
* dahlia
|
||||
* Melanie Thielker
|
||||
* Diva (Crista Lopes, University of California, Irvine)
|
||||
* Dan Lake (Intel)
|
||||
* Marck
|
||||
* Mic Bowman (Intel)
|
||||
* BlueWall (James Hughes)
|
||||
* Nebadon Izumi (Michael Cerquoni, OSgrid)
|
||||
* Snoopy Pfeffer
|
||||
* Richard Adams (Intel)
|
||||
|
||||
= Core Developers Following the White Rabbit =
|
||||
Core developers who have temporarily (we hope) gone chasing the white rabbit.
|
||||
They are in all similar to the active core developers, except that they haven't
|
||||
been that active lately, so their voting rights are awaiting their come back.
|
||||
|
||||
* MW (Tribal Media AB)
|
||||
* Adam Frisby (DeepThink Pty Ltd)
|
||||
* MingChen (DeepThink Pty Ltd)
|
||||
* lbsa71 (Tribal Media AB)
|
||||
* Sean Dague / sdague (IBM)
|
||||
* Tedd
|
||||
* justincc
|
||||
* Teravus (w3z)
|
||||
* Johan Berntsson (3Di)
|
||||
* Ckrinke (Charles Krinke)
|
||||
* chi11ken (Genkii)
|
||||
* adjohn (Genkii)
|
||||
* Dr Scofield aka Dirk Husemann (IBM Research - Zurich)
|
||||
* dahlia
|
||||
* mikem (3Di)
|
||||
* Melanie Thielker
|
||||
* Homer_Horwitz
|
||||
* idb (Ian Brown)
|
||||
* Diva (Crista Lopes, University of California, Irvine)
|
||||
* nlin (3Di)
|
||||
* Arthur Rodrigo S Valadares (IBM)
|
||||
* John Hurliman
|
||||
|
||||
|
||||
= Past Open Sim Developers =
|
||||
These folks are alumns of the OpenSim core group, but are now
|
||||
@@ -49,12 +44,6 @@ where we are today.
|
||||
* Dalien
|
||||
* Darok
|
||||
* Alondria
|
||||
* Sean Dague / sdague (IBM)
|
||||
* Tedd
|
||||
* MingChen (DeepThink Pty Ltd)
|
||||
* adjohn (Genkii)
|
||||
* idb (Ian Brown)
|
||||
* Johan Berntsson (3Di)
|
||||
|
||||
|
||||
= Additional OpenSim Contributors =
|
||||
@@ -71,7 +60,6 @@ what it is today.
|
||||
* CharlieO
|
||||
* ChrisDown
|
||||
* Chris Yeoh (IBM)
|
||||
* controlbreak
|
||||
* coyled
|
||||
* Daedius
|
||||
* Dong Jun Lan (IBM)
|
||||
@@ -81,18 +69,12 @@ what it is today.
|
||||
* dmiles (Daxtron Labs)
|
||||
* dslake (Intel)
|
||||
* FredoChaplin
|
||||
* Garmin Kawaguichi
|
||||
* Gerhard
|
||||
* Godfrey
|
||||
* Grumly57
|
||||
* GuduleLapointe
|
||||
* Ewe Loon
|
||||
* Fernando Oliveira
|
||||
* Fly-Man
|
||||
* Flyte Xevious
|
||||
* Garmin Kawaguichi
|
||||
* Gryc Ueusp
|
||||
* Hiro Lecker
|
||||
* Imaze Rhiano
|
||||
* Intimidated
|
||||
* Jeremy Bongio (IBM)
|
||||
@@ -104,36 +86,24 @@ what it is today.
|
||||
* Kevin Cozens
|
||||
* kinoc (Daxtron Labs)
|
||||
* Kitto Flora
|
||||
* KittyLiu
|
||||
* Kurt Taylor (IBM)
|
||||
* lkalif
|
||||
* lulurun
|
||||
* M.Igarashi
|
||||
* maimedleech
|
||||
* Mana Janus
|
||||
* MarcelEdward
|
||||
* Mic Bowman
|
||||
* Michelle Argus
|
||||
* Michael Cortez (The Flotsam Project, http://osflotsam.org/)
|
||||
* Micheil Merlin
|
||||
* Mike Osias (IBM)
|
||||
* Mike Pitman (IBM)
|
||||
* mikkopa/_someone - RealXtend
|
||||
* Misterblue (Intel)
|
||||
* Mircea Kitsune
|
||||
* mpallari
|
||||
* MrMonkE
|
||||
* Nebadon Izumi (Michael Cerquoni - http://OSgrid.org)
|
||||
* Neil Canham
|
||||
* nornalbion
|
||||
* Omar Vera Ustariz (IBM)
|
||||
* openlifegrid.com
|
||||
* Oren Hurvitz (Kitely)
|
||||
* otakup0pe
|
||||
* Pixel Tomsen
|
||||
* ralphos
|
||||
* RemedyTomm
|
||||
* Revolution
|
||||
* Richard Alimi (IBM)
|
||||
* Rick Alther (IBM)
|
||||
* Rob Smart (IBM)
|
||||
@@ -141,19 +111,12 @@ what it is today.
|
||||
* Ruud Lathorp
|
||||
* SachaMagne
|
||||
* Salahzar Stenvaag
|
||||
* satguru p srivastava
|
||||
* sempuki
|
||||
* SignpostMarv
|
||||
* SpotOn3D
|
||||
* Stefan_Boom / stoehr
|
||||
* Snoopy
|
||||
* Strawberry Fride
|
||||
* Talun
|
||||
* TechplexEngineer (Blake Bourque)
|
||||
* TBG Renfold
|
||||
* tglion
|
||||
* tlaukkan/Tommil (Tommi S. E. Laukkanen, Bubble Cloud)
|
||||
* tyre
|
||||
* VikingErik
|
||||
* Vytek
|
||||
* webmage (IBM)
|
||||
* Xantor
|
||||
@@ -161,7 +124,6 @@ what it is today.
|
||||
* YZh
|
||||
* Zackary Geers aka Kunnis Basiat
|
||||
* Zha Ewry
|
||||
* ziah
|
||||
|
||||
|
||||
= LSL Devs =
|
||||
@@ -196,9 +158,6 @@ This software uses components from the following developers:
|
||||
* Nini (http://nini.sourceforge.net/)
|
||||
* log4net (http://logging.apache.org/log4net/)
|
||||
* GlynnTucker.Cache (http://gtcache.sourceforge.net/)
|
||||
* NDesk.Options 0.2.1 (http://www.ndesk.org/Options)
|
||||
* Json.NET 3.5 Release 6. The binary used is actually Newtonsoft.Json.Net20.dll for Mono 2.4 compatability (http://james.newtonking.com/projects/json-net.aspx)
|
||||
* zlib.net for C# 1.0.4 (http://www.componentace.com/zlib_.NET.htm)
|
||||
|
||||
Some plugins are based on Cable Beach
|
||||
Cable Beach is Copyright (c) 2008 Intel Corporation
|
||||
@@ -208,4 +167,3 @@ In addition, we would like to thank:
|
||||
* The Mono Project
|
||||
* The NANT Developers
|
||||
* Microsoft (.NET, MSSQL-Adapters)
|
||||
*x
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) Contributors, http://opensimulator.org/
|
||||
Copyright (c) Contributors, http://opensimulator.org/
|
||||
See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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.Reflection;
|
||||
using log4net;
|
||||
using OpenSim.Data;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications;
|
||||
using OpenSim.Framework.Communications.Services;
|
||||
using OpenSim.Framework.Communications.Cache;
|
||||
using OpenSim.Framework.Communications.Osp;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Region.Communications.Hypergrid;
|
||||
using OpenSim.Region.Communications.Local;
|
||||
using OpenSim.Region.Communications.OGS1;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.CreateCommsManager
|
||||
{
|
||||
public class CreateCommsManagerPlugin : IApplicationPlugin
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
#region IApplicationPlugin Members
|
||||
|
||||
// TODO: required by IPlugin, but likely not at all right
|
||||
private string m_name = "CreateCommsManagerPlugin";
|
||||
private string m_version = "0.0";
|
||||
|
||||
public string Version
|
||||
{
|
||||
get { return m_version; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return m_name; }
|
||||
}
|
||||
|
||||
protected OpenSimBase m_openSim;
|
||||
|
||||
protected BaseHttpServer m_httpServer;
|
||||
|
||||
protected CommunicationsManager m_commsManager;
|
||||
protected GridInfoService m_gridInfoService;
|
||||
|
||||
protected IRegionCreator m_regionCreator;
|
||||
|
||||
public void Initialise()
|
||||
{
|
||||
m_log.Info("[LOADREGIONS]: " + Name + " cannot be default-initialized!");
|
||||
throw new PluginNotInitialisedException(Name);
|
||||
}
|
||||
|
||||
public void Initialise(OpenSimBase openSim)
|
||||
{
|
||||
m_openSim = openSim;
|
||||
m_httpServer = openSim.HttpServer;
|
||||
MainServer.Instance = m_httpServer;
|
||||
|
||||
InitialiseCommsManager(openSim);
|
||||
if (m_commsManager != null)
|
||||
{
|
||||
m_openSim.ApplicationRegistry.RegisterInterface<IUserService>(m_commsManager.UserService);
|
||||
}
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
if (m_openSim.ApplicationRegistry.TryGet<IRegionCreator>(out m_regionCreator))
|
||||
{
|
||||
m_regionCreator.OnNewRegionCreated += RegionCreated;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void RegionCreated(IScene scene)
|
||||
{
|
||||
if (m_commsManager != null)
|
||||
{
|
||||
scene.RegisterModuleInterface<IUserService>(m_commsManager.UserService);
|
||||
}
|
||||
}
|
||||
|
||||
protected void InitialiseCommsManager(OpenSimBase openSim)
|
||||
{
|
||||
LibraryRootFolder libraryRootFolder = new LibraryRootFolder(m_openSim.ConfigurationSettings.LibrariesXMLFile);
|
||||
|
||||
bool hgrid = m_openSim.ConfigSource.Source.Configs["Startup"].GetBoolean("hypergrid", false);
|
||||
|
||||
if (hgrid)
|
||||
{
|
||||
InitialiseHGServices(openSim, libraryRootFolder);
|
||||
}
|
||||
else
|
||||
{
|
||||
InitialiseStandardServices(libraryRootFolder);
|
||||
}
|
||||
|
||||
openSim.CommunicationsManager = m_commsManager;
|
||||
}
|
||||
|
||||
protected void InitialiseHGServices(OpenSimBase openSim, LibraryRootFolder libraryRootFolder)
|
||||
{
|
||||
// Standalone mode is determined by !startupConfig.GetBoolean("gridmode", false)
|
||||
if (m_openSim.ConfigurationSettings.Standalone)
|
||||
{
|
||||
InitialiseHGStandaloneServices(libraryRootFolder);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We are in grid mode
|
||||
InitialiseHGGridServices(libraryRootFolder);
|
||||
}
|
||||
}
|
||||
|
||||
protected void InitialiseStandardServices(LibraryRootFolder libraryRootFolder)
|
||||
{
|
||||
// Standalone mode is determined by !startupConfig.GetBoolean("gridmode", false)
|
||||
if (m_openSim.ConfigurationSettings.Standalone)
|
||||
{
|
||||
InitialiseStandaloneServices(libraryRootFolder);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We are in grid mode
|
||||
InitialiseGridServices(libraryRootFolder);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialises the backend services for standalone mode, and registers some http handlers
|
||||
/// </summary>
|
||||
/// <param name="libraryRootFolder"></param>
|
||||
protected virtual void InitialiseStandaloneServices(LibraryRootFolder libraryRootFolder)
|
||||
{
|
||||
m_commsManager
|
||||
= new CommunicationsLocal(
|
||||
m_openSim.ConfigurationSettings, m_openSim.NetServersInfo,
|
||||
libraryRootFolder);
|
||||
|
||||
CreateGridInfoService();
|
||||
}
|
||||
|
||||
protected virtual void InitialiseGridServices(LibraryRootFolder libraryRootFolder)
|
||||
{
|
||||
m_commsManager
|
||||
= new CommunicationsOGS1(m_openSim.NetServersInfo, libraryRootFolder);
|
||||
|
||||
m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler());
|
||||
m_httpServer.AddStreamHandler(new OpenSim.XSimStatusHandler(m_openSim));
|
||||
if (m_openSim.userStatsURI != String.Empty)
|
||||
m_httpServer.AddStreamHandler(new OpenSim.UXSimStatusHandler(m_openSim));
|
||||
}
|
||||
|
||||
protected virtual void InitialiseHGStandaloneServices(LibraryRootFolder libraryRootFolder)
|
||||
{
|
||||
m_commsManager
|
||||
= new HGCommunicationsStandalone(
|
||||
m_openSim.ConfigurationSettings, m_openSim.NetServersInfo, m_httpServer,
|
||||
libraryRootFolder, false);
|
||||
|
||||
CreateGridInfoService();
|
||||
}
|
||||
|
||||
protected virtual void InitialiseHGGridServices(LibraryRootFolder libraryRootFolder)
|
||||
{
|
||||
m_commsManager
|
||||
= new HGCommunicationsGridMode(
|
||||
m_openSim.NetServersInfo,
|
||||
m_openSim.SceneManager, libraryRootFolder);
|
||||
|
||||
m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler());
|
||||
m_httpServer.AddStreamHandler(new OpenSim.XSimStatusHandler(m_openSim));
|
||||
if (m_openSim.userStatsURI != String.Empty)
|
||||
m_httpServer.AddStreamHandler(new OpenSim.UXSimStatusHandler(m_openSim));
|
||||
}
|
||||
|
||||
private void CreateGridInfoService()
|
||||
{
|
||||
// provide grid info
|
||||
m_gridInfoService = new GridInfoService(m_openSim.ConfigSource.Source);
|
||||
m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod);
|
||||
m_httpServer.AddStreamHandler(
|
||||
new RestStreamHandler("GET", "/get_grid_info", m_gridInfoService.RestGetGridInfoMethod));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<Addin id="OpenSim.ApplicationPlugins.CreateCommsManager" version="0.1">
|
||||
<Runtime>
|
||||
<Import assembly="OpenSim.ApplicationPlugins.CreateCommsManager.dll"/>
|
||||
</Runtime>
|
||||
<Dependencies>
|
||||
<Addin id="OpenSim" version="0.5" />
|
||||
</Dependencies>
|
||||
<Extension path = "/OpenSim/Startup">
|
||||
<Plugin id="CreateCommsManager" type="OpenSim.ApplicationPlugins.CreateCommsManager.CreateCommsManagerPlugin" />
|
||||
</Extension>
|
||||
</Addin>
|
||||
@@ -30,7 +30,6 @@ using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.RegionLoader.Filesystem;
|
||||
using OpenSim.Framework.RegionLoader.Web;
|
||||
@@ -69,7 +68,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
||||
|
||||
public void Initialise()
|
||||
{
|
||||
m_log.Error("[LOAD REGIONS PLUGIN]: " + Name + " cannot be default-initialized!");
|
||||
m_log.Error("[LOADREGIONS]: " + Name + " cannot be default-initialized!");
|
||||
throw new PluginNotInitialisedException(Name);
|
||||
}
|
||||
|
||||
@@ -86,47 +85,46 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
||||
IRegionLoader regionLoader;
|
||||
if (m_openSim.ConfigSource.Source.Configs["Startup"].GetString("region_info_source", "filesystem") == "filesystem")
|
||||
{
|
||||
m_log.Info("[LOAD REGIONS PLUGIN]: Loading region configurations from filesystem");
|
||||
m_log.Info("[LOADREGIONS]: Loading region configurations from filesystem");
|
||||
regionLoader = new RegionLoaderFileSystem();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Info("[LOAD REGIONS PLUGIN]: Loading region configurations from web");
|
||||
m_log.Info("[LOADREGIONSPLUGIN]: Loading region configurations from web");
|
||||
regionLoader = new RegionLoaderWebServer();
|
||||
}
|
||||
|
||||
m_log.Info("[LOADREGIONSPLUGIN]: Loading region configurations...");
|
||||
|
||||
regionLoader.SetIniConfigSource(m_openSim.ConfigSource.Source);
|
||||
RegionInfo[] regionsToLoad = regionLoader.LoadRegions();
|
||||
|
||||
m_log.Info("[LOAD REGIONS PLUGIN]: Loading specific shared modules...");
|
||||
m_log.Info("[LOAD REGIONS PLUGIN]: DynamicTextureModule...");
|
||||
m_log.Info("[LOADREGIONSPLUGIN]: Loading specific shared modules...");
|
||||
m_log.Info("[LOADREGIONSPLUGIN]: DynamicTextureModule...");
|
||||
m_openSim.ModuleLoader.LoadDefaultSharedModule(new DynamicTextureModule());
|
||||
m_log.Info("[LOAD REGIONS PLUGIN]: LoadImageURLModule...");
|
||||
m_log.Info("[LOADREGIONSPLUGIN]: InstantMessageModule...");
|
||||
m_openSim.ModuleLoader.LoadDefaultSharedModule(new InstantMessageModule());
|
||||
m_log.Info("[LOADREGIONSPLUGIN]: LoadImageURLModule...");
|
||||
m_openSim.ModuleLoader.LoadDefaultSharedModule(new LoadImageURLModule());
|
||||
m_log.Info("[LOAD REGIONS PLUGIN]: XMLRPCModule...");
|
||||
m_log.Info("[LOADREGIONSPLUGIN]: XMLRPCModule...");
|
||||
m_openSim.ModuleLoader.LoadDefaultSharedModule(new XMLRPCModule());
|
||||
// m_log.Info("[LOADREGIONSPLUGIN]: AssetTransactionModule...");
|
||||
// m_openSim.ModuleLoader.LoadDefaultSharedModule(new AssetTransactionModule());
|
||||
m_log.Info("[LOAD REGIONS PLUGIN]: Done.");
|
||||
m_log.Info("[LOADREGIONSPLUGIN]: AssetTransactionModule...");
|
||||
m_openSim.ModuleLoader.LoadDefaultSharedModule(new AssetTransactionModule());
|
||||
m_log.Info("[LOADREGIONSPLUGIN]: Done.");
|
||||
|
||||
if (!CheckRegionsForSanity(regionsToLoad))
|
||||
{
|
||||
m_log.Error("[LOAD REGIONS PLUGIN]: Halting startup due to conflicts in region configurations");
|
||||
m_log.Error("[LOADREGIONS]: Halting startup due to conflicts in region configurations");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < regionsToLoad.Length; i++)
|
||||
{
|
||||
IScene scene;
|
||||
m_log.Debug("[LOAD REGIONS PLUGIN]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " +
|
||||
m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " +
|
||||
Thread.CurrentThread.ManagedThreadId.ToString() +
|
||||
")");
|
||||
|
||||
bool changed = m_openSim.PopulateRegionEstateInfo(regionsToLoad[i]);
|
||||
m_openSim.CreateRegion(regionsToLoad[i], true, out scene);
|
||||
if (changed)
|
||||
regionsToLoad[i].EstateSettings.Save();
|
||||
|
||||
if (scene != null)
|
||||
{
|
||||
m_newRegionCreatedHandler = OnNewRegionCreated;
|
||||
@@ -154,20 +152,9 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
||||
/// <returns>True if we're sane, false if we're insane</returns>
|
||||
private bool CheckRegionsForSanity(RegionInfo[] regions)
|
||||
{
|
||||
if (regions.Length == 0)
|
||||
if (regions.Length <= 1)
|
||||
return true;
|
||||
|
||||
foreach (RegionInfo region in regions)
|
||||
{
|
||||
if (region.RegionID == UUID.Zero)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[LOAD REGIONS PLUGIN]: Region {0} has invalid UUID {1}",
|
||||
region.RegionName, region.RegionID);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < regions.Length - 1; i++)
|
||||
{
|
||||
for (int j = i + 1; j < regions.Length; j++)
|
||||
@@ -175,7 +162,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
||||
if (regions[i].RegionID == regions[j].RegionID)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[LOAD REGIONS PLUGIN]: Regions {0} and {1} have the same UUID {2}",
|
||||
"[LOADREGIONS]: Regions {0} and {1} have the same UUID {2}",
|
||||
regions[i].RegionName, regions[j].RegionName, regions[i].RegionID);
|
||||
return false;
|
||||
}
|
||||
@@ -183,14 +170,14 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
||||
regions[i].RegionLocX == regions[j].RegionLocX && regions[i].RegionLocY == regions[j].RegionLocY)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[LOAD REGIONS PLUGIN]: Regions {0} and {1} have the same grid location ({2}, {3})",
|
||||
"[LOADREGIONS]: Regions {0} and {1} have the same grid location ({2}, {3})",
|
||||
regions[i].RegionName, regions[j].RegionName, regions[i].RegionLocX, regions[i].RegionLocY);
|
||||
return false;
|
||||
}
|
||||
else if (regions[i].InternalEndPoint.Port == regions[j].InternalEndPoint.Port)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[LOAD REGIONS PLUGIN]: Regions {0} and {1} have the same internal IP port {2}",
|
||||
"[LOADREGIONS]: Regions {0} and {1} have the same internal IP port {2}",
|
||||
regions[i].RegionName, regions[j].RegionName, regions[i].InternalEndPoint.Port);
|
||||
return false;
|
||||
}
|
||||
@@ -199,5 +186,35 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void LoadRegionFromConfig(OpenSimBase openSim, ulong regionhandle)
|
||||
{
|
||||
m_log.Info("[LOADREGIONS]: Load Regions addin being initialised");
|
||||
|
||||
IRegionLoader regionLoader;
|
||||
if (openSim.ConfigSource.Source.Configs["Startup"].GetString("region_info_source", "filesystem") == "filesystem")
|
||||
{
|
||||
m_log.Info("[LOADREGIONS]: Loading Region Info from filesystem");
|
||||
regionLoader = new RegionLoaderFileSystem();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Info("[LOADREGIONS]: Loading Region Info from web");
|
||||
regionLoader = new RegionLoaderWebServer();
|
||||
}
|
||||
|
||||
regionLoader.SetIniConfigSource(openSim.ConfigSource.Source);
|
||||
RegionInfo[] regionsToLoad = regionLoader.LoadRegions();
|
||||
for (int i = 0; i < regionsToLoad.Length; i++)
|
||||
{
|
||||
if (regionhandle == regionsToLoad[i].RegionHandle)
|
||||
{
|
||||
IScene scene;
|
||||
m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " +
|
||||
Thread.CurrentThread.ManagedThreadId.ToString() + ")");
|
||||
openSim.CreateRegion(regionsToLoad[i], true, out scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,12 +62,12 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||
new List<ISharedRegionModule>();
|
||||
|
||||
#region IApplicationPlugin implementation
|
||||
|
||||
|
||||
public void Initialise (OpenSimBase openSim)
|
||||
{
|
||||
m_openSim = openSim;
|
||||
m_openSim.ApplicationRegistry.RegisterInterface<IRegionModulesController>(this);
|
||||
m_log.DebugFormat("[REGIONMODULES]: Initializing...");
|
||||
m_openSim = openSim;
|
||||
openSim.ApplicationRegistry.RegisterInterface<IRegionModulesController>(this);
|
||||
|
||||
// Who we are
|
||||
string id = AddinManager.CurrentAddin.Id;
|
||||
@@ -81,9 +81,9 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||
|
||||
// The [Modules] section in the ini file
|
||||
IConfig modulesConfig =
|
||||
m_openSim.ConfigSource.Source.Configs["Modules"];
|
||||
openSim.ConfigSource.Source.Configs["Modules"];
|
||||
if (modulesConfig == null)
|
||||
modulesConfig = m_openSim.ConfigSource.Source.AddConfig("Modules");
|
||||
modulesConfig = openSim.ConfigSource.Source.AddConfig("Modules");
|
||||
|
||||
// Scan modules and load all that aren't disabled
|
||||
foreach (TypeExtensionNode node in
|
||||
@@ -91,24 +91,66 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||
{
|
||||
if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null)
|
||||
{
|
||||
if (CheckModuleEnabled(node, modulesConfig))
|
||||
// Get the config string
|
||||
string moduleString =
|
||||
modulesConfig.GetString("Setup_" + node.Id, String.Empty);
|
||||
|
||||
// We have a selector
|
||||
if (moduleString != String.Empty)
|
||||
{
|
||||
m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type);
|
||||
m_sharedModules.Add(node);
|
||||
// Allow disabling modules even if they don't have
|
||||
// support for it
|
||||
if (moduleString == "disabled")
|
||||
continue;
|
||||
|
||||
// Split off port, if present
|
||||
string[] moduleParts = moduleString.Split(new char[] {'/'}, 2);
|
||||
// Format is [port/][class]
|
||||
string className = moduleParts[0];
|
||||
if (moduleParts.Length > 1)
|
||||
className = moduleParts[1];
|
||||
|
||||
// Match the class name if given
|
||||
if (className != String.Empty &&
|
||||
node.Type.ToString() != className)
|
||||
continue;
|
||||
}
|
||||
|
||||
m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type);
|
||||
m_sharedModules.Add(node);
|
||||
}
|
||||
else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null)
|
||||
{
|
||||
if (CheckModuleEnabled(node, modulesConfig))
|
||||
// Get the config string
|
||||
string moduleString =
|
||||
modulesConfig.GetString("Setup_" + node.Id, String.Empty);
|
||||
|
||||
// We have a selector
|
||||
if (moduleString != String.Empty)
|
||||
{
|
||||
m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type);
|
||||
m_nonSharedModules.Add(node);
|
||||
// Allow disabling modules even if they don't have
|
||||
// support for it
|
||||
if (moduleString == "disabled")
|
||||
continue;
|
||||
|
||||
// Split off port, if present
|
||||
string[] moduleParts = moduleString.Split(new char[] {'/'}, 2);
|
||||
// Format is [port/][class]
|
||||
string className = moduleParts[0];
|
||||
if (moduleParts.Length > 1)
|
||||
className = moduleParts[1];
|
||||
|
||||
// Match the class name if given
|
||||
if (className != String.Empty &&
|
||||
node.Type.ToString() != className)
|
||||
continue;
|
||||
}
|
||||
|
||||
m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type);
|
||||
m_nonSharedModules.Add(node);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.DebugFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type);
|
||||
}
|
||||
}
|
||||
|
||||
// Load and init the module. We try a constructor with a port
|
||||
@@ -120,7 +162,7 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||
//
|
||||
foreach (TypeExtensionNode node in m_sharedModules)
|
||||
{
|
||||
Object[] ctorArgs = new Object[] { (uint)0 };
|
||||
Object[] ctorArgs = new Object[] {(uint)0};
|
||||
|
||||
// Read the config again
|
||||
string moduleString =
|
||||
@@ -130,7 +172,7 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||
if (moduleString != String.Empty)
|
||||
{
|
||||
// Get the port number from the string
|
||||
string[] moduleParts = moduleString.Split(new char[] { '/' },
|
||||
string[] moduleParts = moduleString.Split(new char[] {'/'},
|
||||
2);
|
||||
if (moduleParts.Length > 1)
|
||||
ctorArgs[0] = Convert.ToUInt32(moduleParts[0]);
|
||||
@@ -153,13 +195,8 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||
|
||||
// OK, we're up and running
|
||||
m_sharedInstances.Add(module);
|
||||
module.Initialise(m_openSim.ConfigSource.Source);
|
||||
module.Initialise(openSim.ConfigSource.Source);
|
||||
}
|
||||
}
|
||||
|
||||
public void PostInitialise ()
|
||||
{
|
||||
m_log.DebugFormat("[REGIONMODULES]: PostInitializing...");
|
||||
|
||||
// Immediately run PostInitialise on shared modules
|
||||
foreach (ISharedRegionModule module in m_sharedInstances)
|
||||
@@ -168,6 +205,10 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||
}
|
||||
}
|
||||
|
||||
public void PostInitialise ()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IPlugin implementation
|
||||
@@ -199,6 +240,7 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public string Version
|
||||
{
|
||||
get
|
||||
@@ -216,42 +258,6 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||
}
|
||||
|
||||
#region IRegionModulesController implementation
|
||||
|
||||
/// <summary>
|
||||
/// Check that the given module is no disabled in the [Modules] section of the config files.
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
/// <param name="modulesConfig">The config section</param>
|
||||
/// <returns>true if the module is enabled, false if it is disabled</returns>
|
||||
protected bool CheckModuleEnabled(TypeExtensionNode node, IConfig modulesConfig)
|
||||
{
|
||||
// Get the config string
|
||||
string moduleString =
|
||||
modulesConfig.GetString("Setup_" + node.Id, String.Empty);
|
||||
|
||||
// We have a selector
|
||||
if (moduleString != String.Empty)
|
||||
{
|
||||
// Allow disabling modules even if they don't have
|
||||
// support for it
|
||||
if (moduleString == "disabled")
|
||||
return false;
|
||||
|
||||
// Split off port, if present
|
||||
string[] moduleParts = moduleString.Split(new char[] { '/' }, 2);
|
||||
// Format is [port/][class]
|
||||
string className = moduleParts[0];
|
||||
if (moduleParts.Length > 1)
|
||||
className = moduleParts[1];
|
||||
|
||||
// Match the class name if given
|
||||
if (className != String.Empty &&
|
||||
node.Type.ToString() != className)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// The root of all evil.
|
||||
// This is where we handle adding the modules to scenes when they
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -35,9 +35,6 @@ using System.Xml;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
{
|
||||
@@ -661,6 +658,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
{
|
||||
|
||||
int x;
|
||||
string HA1;
|
||||
string first;
|
||||
string last;
|
||||
|
||||
@@ -677,13 +675,17 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
last = String.Empty;
|
||||
}
|
||||
|
||||
UserAccount account = Rest.UserServices.GetUserAccount(UUID.Zero, first, last);
|
||||
UserProfileData udata = Rest.UserServices.GetUserProfile(first, last);
|
||||
|
||||
// If we don't recognize the user id, perhaps it is god?
|
||||
if (account == null)
|
||||
|
||||
if (udata == null)
|
||||
return pass == Rest.GodKey;
|
||||
|
||||
return (Rest.AuthServices.Authenticate(account.PrincipalID, pass, 1) != string.Empty);
|
||||
HA1 = HashToString(pass);
|
||||
HA1 = HashToString(String.Format("{0}:{1}",HA1,udata.PasswordSalt));
|
||||
|
||||
return (0 == sc.Compare(HA1, udata.PasswordHash));
|
||||
|
||||
}
|
||||
|
||||
@@ -895,10 +897,11 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
last = String.Empty;
|
||||
}
|
||||
|
||||
UserAccount account = Rest.UserServices.GetUserAccount(UUID.Zero, first, last);
|
||||
UserProfileData udata = Rest.UserServices.GetUserProfile(first, last);
|
||||
|
||||
// If we don;t recognize the user id, perhaps it is god?
|
||||
|
||||
if (account == null)
|
||||
if (udata == null)
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Administrator", MsgId);
|
||||
return Rest.GodKey;
|
||||
@@ -906,12 +909,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
else
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Normal User {1}", MsgId, user);
|
||||
|
||||
// !!! REFACTORING PROBLEM
|
||||
// This is what it was. It doesn't work in 0.7
|
||||
// Nothing retrieves the password from the authentication service, there's only authentication.
|
||||
//return udata.PasswordHash;
|
||||
return string.Empty;
|
||||
return udata.PasswordHash;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using IAvatarService = OpenSim.Services.Interfaces.IAvatarService;
|
||||
using IUserService = OpenSim.Framework.Communications.IUserService;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
{
|
||||
@@ -92,24 +92,24 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
/// initializes.
|
||||
/// </summary>
|
||||
|
||||
internal static CommunicationsManager Comms
|
||||
{
|
||||
get { return main.CommunicationsManager; }
|
||||
}
|
||||
|
||||
internal static IInventoryService InventoryServices
|
||||
{
|
||||
get { return main.SceneManager.CurrentOrFirstScene.InventoryService; }
|
||||
}
|
||||
|
||||
internal static IUserAccountService UserServices
|
||||
internal static IUserService UserServices
|
||||
{
|
||||
get { return main.SceneManager.CurrentOrFirstScene.UserAccountService; }
|
||||
get { return Comms.UserService; }
|
||||
}
|
||||
|
||||
internal static IAuthenticationService AuthServices
|
||||
{
|
||||
get { return main.SceneManager.CurrentOrFirstScene.AuthenticationService; }
|
||||
}
|
||||
|
||||
|
||||
internal static IAvatarService AvatarServices
|
||||
{
|
||||
get { return main.SceneManager.CurrentOrFirstScene.AvatarService; }
|
||||
get { return Comms.AvatarService; }
|
||||
}
|
||||
|
||||
internal static IAssetService AssetServices
|
||||
|
||||
@@ -27,24 +27,23 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
{
|
||||
|
||||
public class RestAppearanceServices : IRest
|
||||
{
|
||||
// private static readonly int PARM_USERID = 0;
|
||||
|
||||
private static readonly int PARM_USERID = 0;
|
||||
|
||||
// private static readonly int PARM_PATH = 1;
|
||||
|
||||
// private bool enabled = false;
|
||||
private bool enabled = false;
|
||||
private string qPrefix = "appearance";
|
||||
|
||||
/// <summary>
|
||||
@@ -64,7 +63,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
{
|
||||
Rest.Log.InfoFormat("{0} Domain is relative, adding absolute prefix", MsgId);
|
||||
qPrefix = String.Format("{0}{1}{2}", Rest.Prefix, Rest.UrlPathSeparator, qPrefix);
|
||||
qPrefix = String.Format("{0}{1}{2}", Rest.Prefix, Rest.UrlPathSeparator, qPrefix);
|
||||
Rest.Log.InfoFormat("{0} Domain is now <{1}>", MsgId, qPrefix);
|
||||
}
|
||||
|
||||
@@ -74,7 +72,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
|
||||
// Activate if everything went OK
|
||||
|
||||
// enabled = true;
|
||||
enabled = true;
|
||||
|
||||
Rest.Log.InfoFormat("{0} User appearance services initialization complete", MsgId);
|
||||
}
|
||||
@@ -95,7 +93,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
|
||||
public void Close()
|
||||
{
|
||||
// enabled = false;
|
||||
enabled = false;
|
||||
Rest.Log.InfoFormat("{0} User appearance services closing down", MsgId);
|
||||
}
|
||||
|
||||
@@ -137,153 +135,152 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
|
||||
private void DoAppearance(RequestData hdata)
|
||||
{
|
||||
// !!! REFACTORIMG PROBLEM. This needs rewriting for 0.7
|
||||
|
||||
//AppearanceRequestData rdata = (AppearanceRequestData) hdata;
|
||||
AppearanceRequestData rdata = (AppearanceRequestData) hdata;
|
||||
|
||||
//Rest.Log.DebugFormat("{0} DoAppearance ENTRY", MsgId);
|
||||
Rest.Log.DebugFormat("{0} DoAppearance ENTRY", MsgId);
|
||||
|
||||
//// If we're disabled, do nothing.
|
||||
// If we're disabled, do nothing.
|
||||
|
||||
//if (!enabled)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
if (!enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//// Now that we know this is a serious attempt to
|
||||
//// access inventory data, we should find out who
|
||||
//// is asking, and make sure they are authorized
|
||||
//// to do so. We need to validate the caller's
|
||||
//// identity before revealing anything about the
|
||||
//// status quo. Authenticate throws an exception
|
||||
//// via Fail if no identity information is present.
|
||||
////
|
||||
//// With the present HTTP server we can't use the
|
||||
//// builtin authentication mechanisms because they
|
||||
//// would be enforced for all in-bound requests.
|
||||
//// Instead we look at the headers ourselves and
|
||||
//// handle authentication directly.
|
||||
// Now that we know this is a serious attempt to
|
||||
// access inventory data, we should find out who
|
||||
// is asking, and make sure they are authorized
|
||||
// to do so. We need to validate the caller's
|
||||
// identity before revealing anything about the
|
||||
// status quo. Authenticate throws an exception
|
||||
// via Fail if no identity information is present.
|
||||
//
|
||||
// With the present HTTP server we can't use the
|
||||
// builtin authentication mechanisms because they
|
||||
// would be enforced for all in-bound requests.
|
||||
// Instead we look at the headers ourselves and
|
||||
// handle authentication directly.
|
||||
|
||||
//try
|
||||
//{
|
||||
// if (!rdata.IsAuthenticated)
|
||||
// {
|
||||
// rdata.Fail(Rest.HttpStatusCodeNotAuthorized,String.Format("user \"{0}\" could not be authenticated", rdata.userName));
|
||||
// }
|
||||
//}
|
||||
//catch (RestException e)
|
||||
//{
|
||||
// if (e.statusCode == Rest.HttpStatusCodeNotAuthorized)
|
||||
// {
|
||||
// Rest.Log.WarnFormat("{0} User not authenticated", MsgId);
|
||||
// Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Rest.Log.ErrorFormat("{0} User authentication failed", MsgId);
|
||||
// Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
|
||||
// }
|
||||
// throw (e);
|
||||
//}
|
||||
try
|
||||
{
|
||||
if (!rdata.IsAuthenticated)
|
||||
{
|
||||
rdata.Fail(Rest.HttpStatusCodeNotAuthorized,String.Format("user \"{0}\" could not be authenticated", rdata.userName));
|
||||
}
|
||||
}
|
||||
catch (RestException e)
|
||||
{
|
||||
if (e.statusCode == Rest.HttpStatusCodeNotAuthorized)
|
||||
{
|
||||
Rest.Log.WarnFormat("{0} User not authenticated", MsgId);
|
||||
Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Rest.Log.ErrorFormat("{0} User authentication failed", MsgId);
|
||||
Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
|
||||
}
|
||||
throw (e);
|
||||
}
|
||||
|
||||
//Rest.Log.DebugFormat("{0} Authenticated {1}", MsgId, rdata.userName);
|
||||
Rest.Log.DebugFormat("{0} Authenticated {1}", MsgId, rdata.userName);
|
||||
|
||||
//// We can only get here if we are authorized
|
||||
////
|
||||
//// The requestor may have specified an UUID or
|
||||
//// a conjoined FirstName LastName string. We'll
|
||||
//// try both. If we fail with the first, UUID,
|
||||
//// attempt, we try the other. As an example, the
|
||||
//// URI for a valid inventory request might be:
|
||||
////
|
||||
//// http://<host>:<port>/admin/inventory/Arthur Dent
|
||||
////
|
||||
//// Indicating that this is an inventory request for
|
||||
//// an avatar named Arthur Dent. This is ALL that is
|
||||
//// required to designate a GET for an entire
|
||||
//// inventory.
|
||||
////
|
||||
// We can only get here if we are authorized
|
||||
//
|
||||
// The requestor may have specified an UUID or
|
||||
// a conjoined FirstName LastName string. We'll
|
||||
// try both. If we fail with the first, UUID,
|
||||
// attempt, we try the other. As an example, the
|
||||
// URI for a valid inventory request might be:
|
||||
//
|
||||
// http://<host>:<port>/admin/inventory/Arthur Dent
|
||||
//
|
||||
// Indicating that this is an inventory request for
|
||||
// an avatar named Arthur Dent. This is ALL that is
|
||||
// required to designate a GET for an entire
|
||||
// inventory.
|
||||
//
|
||||
|
||||
//// Do we have at least a user agent name?
|
||||
// Do we have at least a user agent name?
|
||||
|
||||
//if (rdata.Parameters.Length < 1)
|
||||
//{
|
||||
// Rest.Log.WarnFormat("{0} Appearance: No user agent identifier specified", MsgId);
|
||||
// rdata.Fail(Rest.HttpStatusCodeBadRequest, "no user identity specified");
|
||||
//}
|
||||
if (rdata.Parameters.Length < 1)
|
||||
{
|
||||
Rest.Log.WarnFormat("{0} Appearance: No user agent identifier specified", MsgId);
|
||||
rdata.Fail(Rest.HttpStatusCodeBadRequest, "no user identity specified");
|
||||
}
|
||||
|
||||
//// The first parameter MUST be the agent identification, either an UUID
|
||||
//// or a space-separated First-name Last-Name specification. We check for
|
||||
//// an UUID first, if anyone names their character using a valid UUID
|
||||
//// that identifies another existing avatar will cause this a problem...
|
||||
// The first parameter MUST be the agent identification, either an UUID
|
||||
// or a space-separated First-name Last-Name specification. We check for
|
||||
// an UUID first, if anyone names their character using a valid UUID
|
||||
// that identifies another existing avatar will cause this a problem...
|
||||
|
||||
//try
|
||||
//{
|
||||
// rdata.uuid = new UUID(rdata.Parameters[PARM_USERID]);
|
||||
// Rest.Log.DebugFormat("{0} UUID supplied", MsgId);
|
||||
// rdata.userProfile = Rest.UserServices.GetUserProfile(rdata.uuid);
|
||||
//}
|
||||
//catch
|
||||
//{
|
||||
// string[] names = rdata.Parameters[PARM_USERID].Split(Rest.CA_SPACE);
|
||||
// if (names.Length == 2)
|
||||
// {
|
||||
// Rest.Log.DebugFormat("{0} Agent Name supplied [2]", MsgId);
|
||||
// rdata.userProfile = Rest.UserServices.GetUserProfile(names[0],names[1]);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Rest.Log.WarnFormat("{0} A Valid UUID or both first and last names must be specified", MsgId);
|
||||
// rdata.Fail(Rest.HttpStatusCodeBadRequest, "invalid user identity");
|
||||
// }
|
||||
//}
|
||||
try
|
||||
{
|
||||
rdata.uuid = new UUID(rdata.Parameters[PARM_USERID]);
|
||||
Rest.Log.DebugFormat("{0} UUID supplied", MsgId);
|
||||
rdata.userProfile = Rest.UserServices.GetUserProfile(rdata.uuid);
|
||||
}
|
||||
catch
|
||||
{
|
||||
string[] names = rdata.Parameters[PARM_USERID].Split(Rest.CA_SPACE);
|
||||
if (names.Length == 2)
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Agent Name supplied [2]", MsgId);
|
||||
rdata.userProfile = Rest.UserServices.GetUserProfile(names[0],names[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Rest.Log.WarnFormat("{0} A Valid UUID or both first and last names must be specified", MsgId);
|
||||
rdata.Fail(Rest.HttpStatusCodeBadRequest, "invalid user identity");
|
||||
}
|
||||
}
|
||||
|
||||
//// If the user profile is null then either the server is broken, or the
|
||||
//// user is not known. We always assume the latter case.
|
||||
// If the user profile is null then either the server is broken, or the
|
||||
// user is not known. We always assume the latter case.
|
||||
|
||||
//if (rdata.userProfile != null)
|
||||
//{
|
||||
// Rest.Log.DebugFormat("{0} User profile obtained for agent {1} {2}",
|
||||
// MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// Rest.Log.WarnFormat("{0} No user profile for {1}", MsgId, rdata.path);
|
||||
// rdata.Fail(Rest.HttpStatusCodeNotFound, "unrecognized user identity");
|
||||
//}
|
||||
if (rdata.userProfile != null)
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} User profile obtained for agent {1} {2}",
|
||||
MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
|
||||
}
|
||||
else
|
||||
{
|
||||
Rest.Log.WarnFormat("{0} No user profile for {1}", MsgId, rdata.path);
|
||||
rdata.Fail(Rest.HttpStatusCodeNotFound, "unrecognized user identity");
|
||||
}
|
||||
|
||||
//// If we get to here, then we have effectively validated the user's
|
||||
// If we get to here, then we have effectively validated the user's
|
||||
|
||||
//switch (rdata.method)
|
||||
//{
|
||||
// case Rest.HEAD : // Do the processing, set the status code, suppress entity
|
||||
// DoGet(rdata);
|
||||
// rdata.buffer = null;
|
||||
// break;
|
||||
switch (rdata.method)
|
||||
{
|
||||
case Rest.HEAD : // Do the processing, set the status code, suppress entity
|
||||
DoGet(rdata);
|
||||
rdata.buffer = null;
|
||||
break;
|
||||
|
||||
// case Rest.GET : // Do the processing, set the status code, return entity
|
||||
// DoGet(rdata);
|
||||
// break;
|
||||
case Rest.GET : // Do the processing, set the status code, return entity
|
||||
DoGet(rdata);
|
||||
break;
|
||||
|
||||
// case Rest.PUT : // Update named element
|
||||
// DoUpdate(rdata);
|
||||
// break;
|
||||
case Rest.PUT : // Update named element
|
||||
DoUpdate(rdata);
|
||||
break;
|
||||
|
||||
// case Rest.POST : // Add new information to identified context.
|
||||
// DoExtend(rdata);
|
||||
// break;
|
||||
case Rest.POST : // Add new information to identified context.
|
||||
DoExtend(rdata);
|
||||
break;
|
||||
|
||||
// case Rest.DELETE : // Delete information
|
||||
// DoDelete(rdata);
|
||||
// break;
|
||||
case Rest.DELETE : // Delete information
|
||||
DoDelete(rdata);
|
||||
break;
|
||||
|
||||
// default :
|
||||
// Rest.Log.WarnFormat("{0} Method {1} not supported for {2}",
|
||||
// MsgId, rdata.method, rdata.path);
|
||||
// rdata.Fail(Rest.HttpStatusCodeMethodNotAllowed,
|
||||
// String.Format("{0} not supported", rdata.method));
|
||||
// break;
|
||||
//}
|
||||
default :
|
||||
Rest.Log.WarnFormat("{0} Method {1} not supported for {2}",
|
||||
MsgId, rdata.method, rdata.path);
|
||||
rdata.Fail(Rest.HttpStatusCodeMethodNotAllowed,
|
||||
String.Format("{0} not supported", rdata.method));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Interface
|
||||
@@ -295,31 +292,31 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
/// </summary>
|
||||
/// <param name=rdata>HTTP service request work area</param>
|
||||
|
||||
// private void DoGet(AppearanceRequestData rdata)
|
||||
// {
|
||||
// AvatarData adata = Rest.AvatarServices.GetAvatar(rdata.userProfile.ID);
|
||||
//
|
||||
// if (adata == null)
|
||||
// {
|
||||
// rdata.Fail(Rest.HttpStatusCodeNoContent,
|
||||
// String.Format("appearance data not found for user {0} {1}",
|
||||
// rdata.userProfile.FirstName, rdata.userProfile.SurName));
|
||||
// }
|
||||
// rdata.userAppearance = adata.ToAvatarAppearance(rdata.userProfile.ID);
|
||||
//
|
||||
// rdata.initXmlWriter();
|
||||
//
|
||||
// FormatUserAppearance(rdata);
|
||||
//
|
||||
// // Indicate a successful request
|
||||
//
|
||||
// rdata.Complete();
|
||||
//
|
||||
// // Send the response to the user. The body will be implicitly
|
||||
// // constructed from the result of the XML writer.
|
||||
//
|
||||
// rdata.Respond(String.Format("Appearance {0} Normal completion", rdata.method));
|
||||
// }
|
||||
private void DoGet(AppearanceRequestData rdata)
|
||||
{
|
||||
|
||||
rdata.userAppearance = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID);
|
||||
|
||||
if (rdata.userAppearance == null)
|
||||
{
|
||||
rdata.Fail(Rest.HttpStatusCodeNoContent,
|
||||
String.Format("appearance data not found for user {0} {1}",
|
||||
rdata.userProfile.FirstName, rdata.userProfile.SurName));
|
||||
}
|
||||
|
||||
rdata.initXmlWriter();
|
||||
|
||||
FormatUserAppearance(rdata);
|
||||
|
||||
// Indicate a successful request
|
||||
|
||||
rdata.Complete();
|
||||
|
||||
// Send the response to the user. The body will be implicitly
|
||||
// constructed from the result of the XML writer.
|
||||
|
||||
rdata.Respond(String.Format("Appearance {0} Normal completion", rdata.method));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// POST adds NEW information to the user profile database.
|
||||
@@ -327,112 +324,108 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
/// characteristics supplied in the request.
|
||||
/// </summary>
|
||||
|
||||
// private void DoExtend(AppearanceRequestData rdata)
|
||||
// {
|
||||
//
|
||||
// bool created = false;
|
||||
// bool modified = false;
|
||||
// string newnode = String.Empty;
|
||||
//
|
||||
// Rest.Log.DebugFormat("{0} POST ENTRY", MsgId);
|
||||
//
|
||||
// //AvatarAppearance old = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID);
|
||||
//
|
||||
// rdata.userAppearance = new AvatarAppearance();
|
||||
//
|
||||
// // Although the following behavior is admitted by HTTP I am becoming
|
||||
// // increasingly doubtful that it is appropriate for REST. If I attempt to
|
||||
// // add a new record, and it already exists, then it seems to me that the
|
||||
// // attempt should fail, rather than update the existing record.
|
||||
// AvatarData adata = null;
|
||||
// if (GetUserAppearance(rdata))
|
||||
// {
|
||||
// modified = rdata.userAppearance != null;
|
||||
// created = !modified;
|
||||
// adata = new AvatarData(rdata.userAppearance);
|
||||
// Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata);
|
||||
// // Rest.UserServices.UpdateUserProfile(rdata.userProfile);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// created = true;
|
||||
// adata = new AvatarData(rdata.userAppearance);
|
||||
// Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata);
|
||||
// // Rest.UserServices.UpdateUserProfile(rdata.userProfile);
|
||||
// }
|
||||
//
|
||||
// if (created)
|
||||
// {
|
||||
// newnode = String.Format("{0} {1}", rdata.userProfile.FirstName,
|
||||
// rdata.userProfile.SurName);
|
||||
// // Must include a location header with a URI that identifies the new resource.
|
||||
//
|
||||
// rdata.AddHeader(Rest.HttpHeaderLocation,String.Format("http://{0}{1}:{2}{3}{4}",
|
||||
// rdata.hostname,rdata.port,rdata.path,Rest.UrlPathSeparator, newnode));
|
||||
// rdata.Complete(Rest.HttpStatusCodeCreated);
|
||||
//
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (modified)
|
||||
// {
|
||||
// rdata.Complete(Rest.HttpStatusCodeOK);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// rdata.Complete(Rest.HttpStatusCodeNoContent);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method));
|
||||
//
|
||||
// }
|
||||
private void DoExtend(AppearanceRequestData rdata)
|
||||
{
|
||||
|
||||
bool created = false;
|
||||
bool modified = false;
|
||||
string newnode = String.Empty;
|
||||
|
||||
Rest.Log.DebugFormat("{0} POST ENTRY", MsgId);
|
||||
|
||||
//AvatarAppearance old = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID);
|
||||
|
||||
rdata.userAppearance = new AvatarAppearance();
|
||||
|
||||
// Although the following behavior is admitted by HTTP I am becoming
|
||||
// increasingly doubtful that it is appropriate for REST. If I attempt to
|
||||
// add a new record, and it already exists, then it seems to me that the
|
||||
// attempt should fail, rather than update the existing record.
|
||||
|
||||
if (GetUserAppearance(rdata))
|
||||
{
|
||||
modified = rdata.userAppearance != null;
|
||||
created = !modified;
|
||||
Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
|
||||
// Rest.UserServices.UpdateUserProfile(rdata.userProfile);
|
||||
}
|
||||
else
|
||||
{
|
||||
created = true;
|
||||
Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
|
||||
// Rest.UserServices.UpdateUserProfile(rdata.userProfile);
|
||||
}
|
||||
|
||||
if (created)
|
||||
{
|
||||
newnode = String.Format("{0} {1}", rdata.userProfile.FirstName,
|
||||
rdata.userProfile.SurName);
|
||||
// Must include a location header with a URI that identifies the new resource.
|
||||
|
||||
rdata.AddHeader(Rest.HttpHeaderLocation,String.Format("http://{0}{1}:{2}{3}{4}",
|
||||
rdata.hostname,rdata.port,rdata.path,Rest.UrlPathSeparator, newnode));
|
||||
rdata.Complete(Rest.HttpStatusCodeCreated);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (modified)
|
||||
{
|
||||
rdata.Complete(Rest.HttpStatusCodeOK);
|
||||
}
|
||||
else
|
||||
{
|
||||
rdata.Complete(Rest.HttpStatusCodeNoContent);
|
||||
}
|
||||
}
|
||||
|
||||
rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This updates the user's appearance. not all aspects need to be provided,
|
||||
/// only those supplied will be changed.
|
||||
/// </summary>
|
||||
|
||||
// private void DoUpdate(AppearanceRequestData rdata)
|
||||
// {
|
||||
//
|
||||
// // REFACTORING PROBLEM This was commented out. It doesn't work for 0.7
|
||||
//
|
||||
// //bool created = false;
|
||||
// //bool modified = false;
|
||||
//
|
||||
//
|
||||
// //rdata.userAppearance = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID);
|
||||
//
|
||||
// //// If the user exists then this is considered a modification regardless
|
||||
// //// of what may, or may not be, specified in the payload.
|
||||
//
|
||||
// //if (rdata.userAppearance != null)
|
||||
// //{
|
||||
// // modified = true;
|
||||
// // Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
|
||||
// // Rest.UserServices.UpdateUserProfile(rdata.userProfile);
|
||||
// //}
|
||||
//
|
||||
// //if (created)
|
||||
// //{
|
||||
// // rdata.Complete(Rest.HttpStatusCodeCreated);
|
||||
// //}
|
||||
// //else
|
||||
// //{
|
||||
// // if (modified)
|
||||
// // {
|
||||
// // rdata.Complete(Rest.HttpStatusCodeOK);
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // rdata.Complete(Rest.HttpStatusCodeNoContent);
|
||||
// // }
|
||||
// //}
|
||||
//
|
||||
// rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method));
|
||||
//
|
||||
// }
|
||||
private void DoUpdate(AppearanceRequestData rdata)
|
||||
{
|
||||
|
||||
bool created = false;
|
||||
bool modified = false;
|
||||
|
||||
|
||||
rdata.userAppearance = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID);
|
||||
|
||||
// If the user exists then this is considered a modification regardless
|
||||
// of what may, or may not be, specified in the payload.
|
||||
|
||||
if (rdata.userAppearance != null)
|
||||
{
|
||||
modified = true;
|
||||
Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
|
||||
Rest.UserServices.UpdateUserProfile(rdata.userProfile);
|
||||
}
|
||||
|
||||
if (created)
|
||||
{
|
||||
rdata.Complete(Rest.HttpStatusCodeCreated);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (modified)
|
||||
{
|
||||
rdata.Complete(Rest.HttpStatusCodeOK);
|
||||
}
|
||||
else
|
||||
{
|
||||
rdata.Complete(Rest.HttpStatusCodeNoContent);
|
||||
}
|
||||
}
|
||||
|
||||
rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete the specified user's appearance. This actually performs a reset
|
||||
@@ -440,29 +433,30 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
/// Existing ownership is preserved. All prior updates are lost and can not
|
||||
/// be recovered.
|
||||
/// </summary>
|
||||
// private void DoDelete(AppearanceRequestData rdata)
|
||||
// {
|
||||
// AvatarData adata = Rest.AvatarServices.GetAvatar(rdata.userProfile.ID);
|
||||
//
|
||||
// if (adata != null)
|
||||
// {
|
||||
// AvatarAppearance old = adata.ToAvatarAppearance(rdata.userProfile.ID);
|
||||
// rdata.userAppearance = new AvatarAppearance();
|
||||
// rdata.userAppearance.Owner = old.Owner;
|
||||
// adata = new AvatarData(rdata.userAppearance);
|
||||
//
|
||||
// Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata);
|
||||
//
|
||||
// rdata.Complete();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
//
|
||||
// rdata.Complete(Rest.HttpStatusCodeNoContent);
|
||||
// }
|
||||
//
|
||||
// rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method));
|
||||
// }
|
||||
|
||||
private void DoDelete(AppearanceRequestData rdata)
|
||||
{
|
||||
|
||||
AvatarAppearance old = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID);
|
||||
|
||||
if (old != null)
|
||||
{
|
||||
rdata.userAppearance = new AvatarAppearance();
|
||||
|
||||
rdata.userAppearance.Owner = old.Owner;
|
||||
|
||||
Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
|
||||
|
||||
rdata.Complete();
|
||||
}
|
||||
else
|
||||
{
|
||||
rdata.Complete(Rest.HttpStatusCodeNoContent);
|
||||
}
|
||||
|
||||
rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method));
|
||||
|
||||
}
|
||||
|
||||
#endregion method-specific processing
|
||||
|
||||
@@ -488,18 +482,17 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
rdata.userAppearance.AvatarHeight = (float) Convert.ToDouble(xml.Value);
|
||||
indata = true;
|
||||
}
|
||||
// if (xml.MoveToAttribute("Owner"))
|
||||
// {
|
||||
// rdata.userAppearance.Owner = (UUID)xml.Value;
|
||||
// indata = true;
|
||||
// }
|
||||
if (xml.MoveToAttribute("Owner"))
|
||||
{
|
||||
rdata.userAppearance.Owner = (UUID)xml.Value;
|
||||
indata = true;
|
||||
}
|
||||
if (xml.MoveToAttribute("Serial"))
|
||||
{
|
||||
rdata.userAppearance.Serial = Convert.ToInt32(xml.Value);
|
||||
indata = true;
|
||||
}
|
||||
break;
|
||||
/*
|
||||
case "Body" :
|
||||
if (xml.MoveToAttribute("Item"))
|
||||
{
|
||||
@@ -656,7 +649,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
indata = true;
|
||||
}
|
||||
break;
|
||||
*/
|
||||
case "Attachment" :
|
||||
{
|
||||
|
||||
@@ -747,11 +739,10 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
rdata.writer.WriteStartElement("Appearance");
|
||||
|
||||
rdata.writer.WriteAttributeString("Height", rdata.userAppearance.AvatarHeight.ToString());
|
||||
// if (rdata.userAppearance.Owner != UUID.Zero)
|
||||
// rdata.writer.WriteAttributeString("Owner", rdata.userAppearance.Owner.ToString());
|
||||
if (rdata.userAppearance.Owner != UUID.Zero)
|
||||
rdata.writer.WriteAttributeString("Owner", rdata.userAppearance.Owner.ToString());
|
||||
rdata.writer.WriteAttributeString("Serial", rdata.userAppearance.Serial.ToString());
|
||||
|
||||
/*
|
||||
FormatPart(rdata, "Body", rdata.userAppearance.BodyItem, rdata.userAppearance.BodyAsset);
|
||||
FormatPart(rdata, "Skin", rdata.userAppearance.SkinItem, rdata.userAppearance.SkinAsset);
|
||||
FormatPart(rdata, "Hair", rdata.userAppearance.HairItem, rdata.userAppearance.HairAsset);
|
||||
@@ -768,20 +759,26 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
|
||||
FormatPart(rdata, "UnderShirt", rdata.userAppearance.UnderShirtItem, rdata.userAppearance.UnderShirtAsset);
|
||||
FormatPart(rdata, "UnderPants", rdata.userAppearance.UnderPantsItem, rdata.userAppearance.UnderPantsAsset);
|
||||
*/
|
||||
Rest.Log.DebugFormat("{0} FormatUserAppearance: Formatting attachments", MsgId);
|
||||
|
||||
rdata.writer.WriteStartElement("Attachments");
|
||||
List<AvatarAttachment> attachments = rdata.userAppearance.GetAttachments();
|
||||
foreach (AvatarAttachment attach in attachments)
|
||||
Hashtable attachments = rdata.userAppearance.GetAttachments();
|
||||
|
||||
if (attachments != null)
|
||||
{
|
||||
rdata.writer.WriteStartElement("Attachment");
|
||||
rdata.writer.WriteAttributeString("AtPoint", attach.AttachPoint.ToString());
|
||||
rdata.writer.WriteAttributeString("Item", attach.ItemID.ToString());
|
||||
rdata.writer.WriteAttributeString("Asset", attach.AssetID.ToString());
|
||||
|
||||
Rest.Log.DebugFormat("{0} FormatUserAppearance: Formatting attachments", MsgId);
|
||||
|
||||
rdata.writer.WriteStartElement("Attachments");
|
||||
for (int i = 0; i < attachments.Count; i++)
|
||||
{
|
||||
Hashtable attachment = attachments[i] as Hashtable;
|
||||
rdata.writer.WriteStartElement("Attachment");
|
||||
rdata.writer.WriteAttributeString("AtPoint", i.ToString());
|
||||
rdata.writer.WriteAttributeString("Item", (string) attachment["item"]);
|
||||
rdata.writer.WriteAttributeString("Asset", (string) attachment["asset"]);
|
||||
rdata.writer.WriteEndElement();
|
||||
}
|
||||
rdata.writer.WriteEndElement();
|
||||
}
|
||||
rdata.writer.WriteEndElement();
|
||||
|
||||
Primitive.TextureEntry texture = rdata.userAppearance.Texture;
|
||||
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
modified = (asset != null);
|
||||
created = !modified;
|
||||
|
||||
asset = new AssetBase(uuid, xml.GetAttribute("name"), SByte.Parse(xml.GetAttribute("type")), UUID.Zero.ToString());
|
||||
asset = new AssetBase(uuid, xml.GetAttribute("name"), SByte.Parse(xml.GetAttribute("type")));
|
||||
asset.Description = xml.GetAttribute("desc");
|
||||
asset.Local = Int32.Parse(xml.GetAttribute("local")) != 0;
|
||||
asset.Temporary = Int32.Parse(xml.GetAttribute("temporary")) != 0;
|
||||
@@ -338,7 +338,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
modified = (asset != null);
|
||||
created = !modified;
|
||||
|
||||
asset = new AssetBase(uuid, xml.GetAttribute("name"), SByte.Parse(xml.GetAttribute("type")), UUID.Zero.ToString());
|
||||
asset = new AssetBase(uuid, xml.GetAttribute("name"), SByte.Parse(xml.GetAttribute("type")));
|
||||
asset.Description = xml.GetAttribute("desc");
|
||||
asset.Local = Int32.Parse(xml.GetAttribute("local")) != 0;
|
||||
asset.Temporary = Int32.Parse(xml.GetAttribute("temporary")) != 0;
|
||||
|
||||
@@ -539,6 +539,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||
/// path has not already been registered, the method is added to the active
|
||||
/// handler table.
|
||||
/// </summary>
|
||||
|
||||
public void AddStreamHandler(string httpMethod, string path, RestMethod method)
|
||||
{
|
||||
if (!IsEnabled)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -123,15 +123,10 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
|
||||
|
||||
private void DoMove(RequestData rdata)
|
||||
{
|
||||
if (rdata.Parameters.Length < 6)
|
||||
{
|
||||
Rest.Log.WarnFormat("{0} Move: No movement information provided", MsgId);
|
||||
rdata.Fail(Rest.HttpStatusCodeBadRequest, "no movement information provided");
|
||||
}
|
||||
else
|
||||
if (rdata.Parameters.Length >= 6)
|
||||
{
|
||||
string[] names = rdata.Parameters[PARM_MOVE_AVATAR].Split(Rest.CA_SPACE);
|
||||
ScenePresence presence = null;
|
||||
ScenePresence avatar = null;
|
||||
Scene scene = null;
|
||||
|
||||
if (names.Length != 2)
|
||||
@@ -146,19 +141,21 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
|
||||
// The first parameter should be an avatar name, look for the
|
||||
// avatar in the known regions first.
|
||||
|
||||
Rest.main.SceneManager.ForEachScene(delegate(Scene s)
|
||||
foreach (Scene cs in Rest.main.SceneManager.Scenes)
|
||||
{
|
||||
s.ForEachRootScenePresence(delegate(ScenePresence sp)
|
||||
foreach (ScenePresence presence in cs.GetAvatars())
|
||||
{
|
||||
if (sp.Firstname == names[0] && sp.Lastname == names[1])
|
||||
if (presence.Firstname == names[0] &&
|
||||
presence.Lastname == names[1])
|
||||
{
|
||||
scene = s;
|
||||
presence = sp;
|
||||
scene = cs;
|
||||
avatar = presence;
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (presence != null)
|
||||
if (avatar != null)
|
||||
{
|
||||
Rest.Log.DebugFormat("{0} Move : Avatar {1} located in region {2}",
|
||||
MsgId, rdata.Parameters[PARM_MOVE_AVATAR], scene.RegionInfo.RegionName);
|
||||
@@ -168,14 +165,15 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
|
||||
float x = Convert.ToSingle(rdata.Parameters[PARM_MOVE_X]);
|
||||
float y = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Y]);
|
||||
float z = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Z]);
|
||||
Vector3 vector = new Vector3(x, y, z);
|
||||
presence.MoveToTarget(vector, false, false);
|
||||
Vector3 vector = new Vector3(x,y,z);
|
||||
avatar.DoAutoPilot(0,vector,avatar.ControllingClient);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
rdata.Fail(Rest.HttpStatusCodeBadRequest,
|
||||
String.Format("invalid parameters: {0}", e.Message));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -185,6 +183,12 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
|
||||
|
||||
rdata.Complete();
|
||||
rdata.Respond("OK");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Rest.Log.WarnFormat("{0} Move: No movement information provided", MsgId);
|
||||
rdata.Fail(Rest.HttpStatusCodeBadRequest, "no movement information provided");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ using System;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
@@ -41,7 +40,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
{
|
||||
#region GET methods
|
||||
public string GetHandler(string request, string path, string param,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
||||
{
|
||||
// foreach (string h in httpRequest.Headers.AllKeys)
|
||||
// foreach (string v in httpRequest.Headers.GetValues(h))
|
||||
@@ -64,7 +63,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
}
|
||||
}
|
||||
|
||||
public string GetHandlerRegions(IOSHttpResponse httpResponse)
|
||||
public string GetHandlerRegions(OSHttpResponse httpResponse)
|
||||
{
|
||||
RestXmlWriter rxw = new RestXmlWriter(new StringWriter());
|
||||
|
||||
@@ -95,7 +94,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
return rxw.ToString();
|
||||
}
|
||||
|
||||
public string GetHandlerRegion(IOSHttpResponse httpResponse, string param)
|
||||
public string GetHandlerRegion(OSHttpResponse httpResponse, string param)
|
||||
{
|
||||
// be resilient and don't get confused by a terminating '/'
|
||||
param = param.TrimEnd(new char[]{'/'});
|
||||
@@ -157,8 +156,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
Vector3 min, max;
|
||||
try
|
||||
{
|
||||
min = new Vector3((float)Double.Parse(subregion[0], Culture.NumberFormatInfo), (float)Double.Parse(subregion[1], Culture.NumberFormatInfo), (float)Double.Parse(subregion[2], Culture.NumberFormatInfo));
|
||||
max = new Vector3((float)Double.Parse(subregion[3], Culture.NumberFormatInfo), (float)Double.Parse(subregion[4], Culture.NumberFormatInfo), (float)Double.Parse(subregion[5], Culture.NumberFormatInfo));
|
||||
min = new Vector3((float)Double.Parse(subregion[0]), (float)Double.Parse(subregion[1]), (float)Double.Parse(subregion[2]));
|
||||
max = new Vector3((float)Double.Parse(subregion[3]), (float)Double.Parse(subregion[4]), (float)Double.Parse(subregion[5]));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -180,7 +179,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
}
|
||||
#endregion GET methods
|
||||
|
||||
protected string RegionTerrain(IOSHttpResponse httpResponse, Scene scene)
|
||||
protected string RegionTerrain(OSHttpResponse httpResponse, Scene scene)
|
||||
{
|
||||
httpResponse.SendChunked = true;
|
||||
httpResponse.ContentType = "text/xml";
|
||||
@@ -190,9 +189,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
// "GET", "terrain not implemented");
|
||||
}
|
||||
|
||||
protected string RegionStats(IOSHttpResponse httpResponse, Scene scene)
|
||||
protected string RegionStats(OSHttpResponse httpResponse, Scene scene)
|
||||
{
|
||||
int users = scene.GetRootAgentCount();
|
||||
int users = scene.GetAvatars().Count;
|
||||
int objects = scene.Entities.Count - users;
|
||||
|
||||
RestXmlWriter rxw = new RestXmlWriter(new StringWriter());
|
||||
@@ -213,7 +212,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
return rxw.ToString();
|
||||
}
|
||||
|
||||
protected string RegionPrims(IOSHttpResponse httpResponse, Scene scene, Vector3 min, Vector3 max)
|
||||
protected string RegionPrims(OSHttpResponse httpResponse, Scene scene, Vector3 min, Vector3 max)
|
||||
{
|
||||
httpResponse.SendChunked = true;
|
||||
httpResponse.ContentType = "text/xml";
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
{
|
||||
#region GET methods
|
||||
public string GetRegionInfoHandler(string request, string path, string param,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
||||
{
|
||||
// foreach (string h in httpRequest.Headers.AllKeys)
|
||||
// foreach (string v in httpRequest.Headers.GetValues(h))
|
||||
@@ -64,7 +64,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
}
|
||||
}
|
||||
|
||||
public string GetRegionInfoHandlerRegions(IOSHttpResponse httpResponse)
|
||||
public string GetRegionInfoHandlerRegions(OSHttpResponse httpResponse)
|
||||
{
|
||||
RestXmlWriter rxw = new RestXmlWriter(new StringWriter());
|
||||
|
||||
@@ -113,11 +113,19 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
rxw.WriteString(s.RegionInfo.ExternalHostName);
|
||||
rxw.WriteEndAttribute();
|
||||
|
||||
rxw.WriteStartAttribute(String.Empty, "master_name", String.Empty);
|
||||
rxw.WriteString(String.Format("{0} {1}", s.RegionInfo.MasterAvatarFirstName, s.RegionInfo.MasterAvatarLastName));
|
||||
rxw.WriteEndAttribute();
|
||||
|
||||
rxw.WriteStartAttribute(String.Empty, "master_uuid", String.Empty);
|
||||
rxw.WriteString(s.RegionInfo.MasterAvatarAssignedUUID.ToString());
|
||||
rxw.WriteEndAttribute();
|
||||
|
||||
rxw.WriteStartAttribute(String.Empty, "ip", String.Empty);
|
||||
rxw.WriteString(s.RegionInfo.InternalEndPoint.ToString());
|
||||
rxw.WriteEndAttribute();
|
||||
|
||||
int users = s.GetRootAgentCount();
|
||||
int users = s.GetAvatars().Count;
|
||||
rxw.WriteStartAttribute(String.Empty, "avatars", String.Empty);
|
||||
rxw.WriteValue(users);
|
||||
rxw.WriteEndAttribute();
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
#region POST methods
|
||||
|
||||
public string PostHandler(string request, string path, string param,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
||||
{
|
||||
// foreach (string h in httpRequest.Headers.AllKeys)
|
||||
// foreach (string v in httpRequest.Headers.GetValues(h))
|
||||
@@ -92,7 +92,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
}
|
||||
}
|
||||
|
||||
public string CreateRegion(IOSHttpRequest request, IOSHttpResponse response)
|
||||
public string CreateRegion(OSHttpRequest request, OSHttpResponse response)
|
||||
{
|
||||
RestXmlWriter rxw = new RestXmlWriter(new StringWriter());
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
return rxw.ToString();
|
||||
}
|
||||
|
||||
public string LoadPrims(string requestBody, IOSHttpRequest request, IOSHttpResponse response, Scene scene)
|
||||
public string LoadPrims(string requestBody, OSHttpRequest request, OSHttpResponse response, Scene scene)
|
||||
{
|
||||
IRegionSerialiserModule serialiser = scene.RequestModuleInterface<IRegionSerialiserModule>();
|
||||
if (serialiser != null)
|
||||
|
||||
@@ -56,13 +56,20 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
region_id = regInfo.RegionID.ToString();
|
||||
region_x = regInfo.RegionLocX;
|
||||
region_y = regInfo.RegionLocY;
|
||||
region_owner_id = regInfo.EstateSettings.EstateOwner.ToString();
|
||||
if (regInfo.EstateSettings.EstateOwner != UUID.Zero)
|
||||
region_owner_id = regInfo.EstateSettings.EstateOwner.ToString();
|
||||
else
|
||||
region_owner_id = regInfo.MasterAvatarAssignedUUID.ToString();
|
||||
region_http_port = regInfo.HttpPort;
|
||||
region_server_uri = regInfo.ServerURI;
|
||||
region_external_hostname = regInfo.ExternalHostName;
|
||||
|
||||
Uri uri = new Uri(region_server_uri);
|
||||
region_port = (uint)uri.Port;
|
||||
|
||||
if (!String.IsNullOrEmpty(regInfo.MasterAvatarFirstName))
|
||||
region_owner = String.Format("{0} {1}", regInfo.MasterAvatarFirstName,
|
||||
regInfo.MasterAvatarLastName);
|
||||
}
|
||||
|
||||
public string this[string idx]
|
||||
|
||||
@@ -328,7 +328,7 @@ namespace OpenSim.ApplicationPlugins.Rest
|
||||
/// </summary>
|
||||
/// <param name="request">HTTP request header</param>
|
||||
/// <returns>true when the HTTP request came from god.</returns>
|
||||
protected bool IsGod(IOSHttpRequest request)
|
||||
protected bool IsGod(OSHttpRequest request)
|
||||
{
|
||||
string[] keys = request.Headers.GetValues("X-OpenSim-Godkey");
|
||||
if (null == keys) return false;
|
||||
@@ -342,7 +342,7 @@ namespace OpenSim.ApplicationPlugins.Rest
|
||||
/// HTTP header is indeed the password on file for the avatar
|
||||
/// specified by the UUID
|
||||
/// </summary>
|
||||
protected bool IsVerifiedUser(IOSHttpRequest request, UUID uuid)
|
||||
protected bool IsVerifiedUser(OSHttpRequest request, UUID uuid)
|
||||
{
|
||||
// XXX under construction
|
||||
return false;
|
||||
@@ -377,7 +377,7 @@ namespace OpenSim.ApplicationPlugins.Rest
|
||||
/// <param name="message">failure message</param>
|
||||
/// <remarks>This should probably set a return code as
|
||||
/// well. (?)</remarks>
|
||||
protected string Failure(IOSHttpResponse response, OSHttpStatusCode status,
|
||||
protected string Failure(OSHttpResponse response, OSHttpStatusCode status,
|
||||
string method, string format, params string[] msg)
|
||||
{
|
||||
string m = String.Format(format, msg);
|
||||
@@ -396,7 +396,7 @@ namespace OpenSim.ApplicationPlugins.Rest
|
||||
/// <param name="e">exception causing the failure message</param>
|
||||
/// <remarks>This should probably set a return code as
|
||||
/// well. (?)</remarks>
|
||||
public string Failure(IOSHttpResponse response, OSHttpStatusCode status,
|
||||
public string Failure(OSHttpResponse response, OSHttpStatusCode status,
|
||||
string method, Exception e)
|
||||
{
|
||||
string m = String.Format("exception occurred: {0}", e.Message);
|
||||
|
||||
@@ -1,175 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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.IO;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
||||
// using OpenSim.Region.Framework.Interfaces;
|
||||
|
||||
namespace OpenSim.Framework.Capabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// XXX Probably not a particularly nice way of allow us to get the scene presence from the scene (chiefly so that
|
||||
/// we can popup a message on the user's client if the inventory service has permanently failed). But I didn't want
|
||||
/// to just pass the whole Scene into CAPS.
|
||||
/// </summary>
|
||||
public delegate IClientAPI GetClientDelegate(UUID agentID);
|
||||
|
||||
public class Caps
|
||||
{
|
||||
// private static readonly ILog m_log =
|
||||
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private string m_httpListenerHostName;
|
||||
private uint m_httpListenPort;
|
||||
|
||||
/// <summary>
|
||||
/// This is the uuid portion of every CAPS path. It is used to make capability urls private to the requester.
|
||||
/// </summary>
|
||||
private string m_capsObjectPath;
|
||||
public string CapsObjectPath { get { return m_capsObjectPath; } }
|
||||
|
||||
private CapsHandlers m_capsHandlers;
|
||||
private Dictionary<string, string> m_externalCapsHandlers;
|
||||
|
||||
private IHttpServer m_httpListener;
|
||||
private UUID m_agentID;
|
||||
private string m_regionName;
|
||||
|
||||
public UUID AgentID
|
||||
{
|
||||
get { return m_agentID; }
|
||||
}
|
||||
|
||||
public string RegionName
|
||||
{
|
||||
get { return m_regionName; }
|
||||
}
|
||||
|
||||
public string HostName
|
||||
{
|
||||
get { return m_httpListenerHostName; }
|
||||
}
|
||||
|
||||
public uint Port
|
||||
{
|
||||
get { return m_httpListenPort; }
|
||||
}
|
||||
|
||||
public IHttpServer HttpListener
|
||||
{
|
||||
get { return m_httpListener; }
|
||||
}
|
||||
|
||||
public bool SSLCaps
|
||||
{
|
||||
get { return m_httpListener.UseSSL; }
|
||||
}
|
||||
|
||||
public string SSLCommonName
|
||||
{
|
||||
get { return m_httpListener.SSLCommonName; }
|
||||
}
|
||||
|
||||
public CapsHandlers CapsHandlers
|
||||
{
|
||||
get { return m_capsHandlers; }
|
||||
}
|
||||
|
||||
public Dictionary<string, string> ExternalCapsHandlers
|
||||
{
|
||||
get { return m_externalCapsHandlers; }
|
||||
}
|
||||
|
||||
public Caps(IHttpServer httpServer, string httpListen, uint httpPort, string capsPath,
|
||||
UUID agent, string regionName)
|
||||
{
|
||||
m_capsObjectPath = capsPath;
|
||||
m_httpListener = httpServer;
|
||||
m_httpListenerHostName = httpListen;
|
||||
|
||||
m_httpListenPort = httpPort;
|
||||
|
||||
if (httpServer != null && httpServer.UseSSL)
|
||||
{
|
||||
m_httpListenPort = httpServer.SSLPort;
|
||||
httpListen = httpServer.SSLCommonName;
|
||||
httpPort = httpServer.SSLPort;
|
||||
}
|
||||
|
||||
m_agentID = agent;
|
||||
m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, (httpServer == null) ? false : httpServer.UseSSL);
|
||||
m_externalCapsHandlers = new Dictionary<string, string>();
|
||||
m_regionName = regionName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register a handler. This allows modules to register handlers.
|
||||
/// </summary>
|
||||
/// <param name="capName"></param>
|
||||
/// <param name="handler"></param>
|
||||
public void RegisterHandler(string capName, IRequestHandler handler)
|
||||
{
|
||||
m_capsHandlers[capName] = handler;
|
||||
//m_log.DebugFormat("[CAPS]: Registering handler for \"{0}\": path {1}", capName, handler.Path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register an external handler. The service for this capability is somewhere else
|
||||
/// given by the URL.
|
||||
/// </summary>
|
||||
/// <param name="capsName"></param>
|
||||
/// <param name="url"></param>
|
||||
public void RegisterHandler(string capsName, string url)
|
||||
{
|
||||
m_externalCapsHandlers.Add(capsName, url);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all CAPS service handlers.
|
||||
/// </summary>
|
||||
public void DeregisterHandlers()
|
||||
{
|
||||
if (m_capsHandlers != null)
|
||||
{
|
||||
foreach (string capsName in m_capsHandlers.Caps)
|
||||
{
|
||||
m_capsHandlers.Remove(capsName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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.Reflection;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Capabilities;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using Caps = OpenSim.Framework.Capabilities.Caps;
|
||||
using OSDArray = OpenMetaverse.StructuredData.OSDArray;
|
||||
using OSDMap = OpenMetaverse.StructuredData.OSDMap;
|
||||
|
||||
namespace OpenSim.Capabilities.Handlers
|
||||
{
|
||||
public class FetchInventory2Handler
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private IInventoryService m_inventoryService;
|
||||
|
||||
public FetchInventory2Handler(IInventoryService invService)
|
||||
{
|
||||
m_inventoryService = invService;
|
||||
}
|
||||
|
||||
public string FetchInventoryRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
// m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capabilty request");
|
||||
|
||||
OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request));
|
||||
OSDArray itemsRequested = (OSDArray)requestmap["items"];
|
||||
|
||||
string reply;
|
||||
LLSDFetchInventory llsdReply = new LLSDFetchInventory();
|
||||
|
||||
foreach (OSDMap osdItemId in itemsRequested)
|
||||
{
|
||||
UUID itemId = osdItemId["item_id"].AsUUID();
|
||||
|
||||
InventoryItemBase item = m_inventoryService.GetItem(new InventoryItemBase(itemId));
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
// We don't know the agent that this request belongs to so we'll use the agent id of the item
|
||||
// which will be the same for all items.
|
||||
llsdReply.agent_id = item.Owner;
|
||||
|
||||
llsdReply.items.Array.Add(ConvertInventoryItem(item));
|
||||
}
|
||||
}
|
||||
|
||||
reply = LLSDHelpers.SerialiseLLSDReply(llsdReply);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert an internal inventory item object into an LLSD object.
|
||||
/// </summary>
|
||||
/// <param name="invItem"></param>
|
||||
/// <returns></returns>
|
||||
private LLSDInventoryItem ConvertInventoryItem(InventoryItemBase invItem)
|
||||
{
|
||||
LLSDInventoryItem llsdItem = new LLSDInventoryItem();
|
||||
llsdItem.asset_id = invItem.AssetID;
|
||||
llsdItem.created_at = invItem.CreationDate;
|
||||
llsdItem.desc = invItem.Description;
|
||||
llsdItem.flags = (int)invItem.Flags;
|
||||
llsdItem.item_id = invItem.ID;
|
||||
llsdItem.name = invItem.Name;
|
||||
llsdItem.parent_id = invItem.Folder;
|
||||
llsdItem.type = invItem.AssetType;
|
||||
llsdItem.inv_type = invItem.InvType;
|
||||
|
||||
llsdItem.permissions = new LLSDPermissions();
|
||||
llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid;
|
||||
llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions;
|
||||
llsdItem.permissions.everyone_mask = (int)invItem.EveryOnePermissions;
|
||||
llsdItem.permissions.group_id = invItem.GroupID;
|
||||
llsdItem.permissions.group_mask = (int)invItem.GroupPermissions;
|
||||
llsdItem.permissions.is_owner_group = invItem.GroupOwned;
|
||||
llsdItem.permissions.next_owner_mask = (int)invItem.NextPermissions;
|
||||
llsdItem.permissions.owner_id = invItem.Owner;
|
||||
llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions;
|
||||
llsdItem.sale_info = new LLSDSaleInfo();
|
||||
llsdItem.sale_info.sale_price = invItem.SalePrice;
|
||||
llsdItem.sale_info.sale_type = invItem.SaleType;
|
||||
|
||||
return llsdItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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 Nini.Config;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Server.Handlers.Base;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Capabilities.Handlers
|
||||
{
|
||||
public class FetchInventory2ServerConnector : ServiceConnector
|
||||
{
|
||||
private IInventoryService m_InventoryService;
|
||||
private string m_ConfigName = "CapsService";
|
||||
|
||||
public FetchInventory2ServerConnector(IConfigSource config, IHttpServer server, string configName)
|
||||
: base(config, server, configName)
|
||||
{
|
||||
if (configName != String.Empty)
|
||||
m_ConfigName = configName;
|
||||
|
||||
IConfig serverConfig = config.Configs[m_ConfigName];
|
||||
if (serverConfig == null)
|
||||
throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
|
||||
|
||||
string invService = serverConfig.GetString("InventoryService", String.Empty);
|
||||
|
||||
if (invService == String.Empty)
|
||||
throw new Exception("No InventoryService in config file");
|
||||
|
||||
Object[] args = new Object[] { config };
|
||||
m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args);
|
||||
|
||||
if (m_InventoryService == null)
|
||||
throw new Exception(String.Format("Failed to load InventoryService from {0}; config is {1}", invService, m_ConfigName));
|
||||
|
||||
FetchInventory2Handler fiHandler = new FetchInventory2Handler(m_InventoryService);
|
||||
IRequestHandler reqHandler
|
||||
= new RestStreamHandler(
|
||||
"POST", "/CAPS/FetchInventory/", fiHandler.FetchInventoryRequest, "FetchInventory", null);
|
||||
server.AddStreamHandler(reqHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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.Specialized;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using Caps = OpenSim.Framework.Capabilities.Caps;
|
||||
|
||||
namespace OpenSim.Capabilities.Handlers
|
||||
{
|
||||
public class GetMeshHandler
|
||||
{
|
||||
// private static readonly ILog m_log =
|
||||
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private IAssetService m_assetService;
|
||||
|
||||
public GetMeshHandler(IAssetService assService)
|
||||
{
|
||||
m_assetService = assService;
|
||||
}
|
||||
|
||||
public Hashtable ProcessGetMesh(Hashtable request, UUID AgentId, Caps cap)
|
||||
{
|
||||
Hashtable responsedata = new Hashtable();
|
||||
responsedata["int_response_code"] = 400; //501; //410; //404;
|
||||
responsedata["content_type"] = "text/plain";
|
||||
responsedata["keepalive"] = false;
|
||||
responsedata["str_response_string"] = "Request wasn't what was expected";
|
||||
|
||||
string meshStr = string.Empty;
|
||||
|
||||
if (request.ContainsKey("mesh_id"))
|
||||
meshStr = request["mesh_id"].ToString();
|
||||
|
||||
UUID meshID = UUID.Zero;
|
||||
if (!String.IsNullOrEmpty(meshStr) && UUID.TryParse(meshStr, out meshID))
|
||||
{
|
||||
if (m_assetService == null)
|
||||
{
|
||||
responsedata["int_response_code"] = 404; //501; //410; //404;
|
||||
responsedata["content_type"] = "text/plain";
|
||||
responsedata["keepalive"] = false;
|
||||
responsedata["str_response_string"] = "The asset service is unavailable. So is your mesh.";
|
||||
return responsedata;
|
||||
}
|
||||
|
||||
AssetBase mesh = m_assetService.Get(meshID.ToString());
|
||||
|
||||
if (mesh != null)
|
||||
{
|
||||
if (mesh.Type == (SByte)AssetType.Mesh)
|
||||
{
|
||||
responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data);
|
||||
responsedata["content_type"] = "application/vnd.ll.mesh";
|
||||
responsedata["int_response_code"] = 200;
|
||||
}
|
||||
// Optionally add additional mesh types here
|
||||
else
|
||||
{
|
||||
responsedata["int_response_code"] = 404; //501; //410; //404;
|
||||
responsedata["content_type"] = "text/plain";
|
||||
responsedata["keepalive"] = false;
|
||||
responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh.";
|
||||
return responsedata;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responsedata["int_response_code"] = 404; //501; //410; //404;
|
||||
responsedata["content_type"] = "text/plain";
|
||||
responsedata["keepalive"] = false;
|
||||
responsedata["str_response_string"] = "Your Mesh wasn't found. Sorry!";
|
||||
return responsedata;
|
||||
}
|
||||
}
|
||||
|
||||
return responsedata;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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 Nini.Config;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Server.Handlers.Base;
|
||||
using OpenSim.Framework.Servers;
|
||||
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Capabilities.Handlers
|
||||
{
|
||||
public class GetMeshServerConnector : ServiceConnector
|
||||
{
|
||||
private IAssetService m_AssetService;
|
||||
private string m_ConfigName = "CapsService";
|
||||
|
||||
public GetMeshServerConnector(IConfigSource config, IHttpServer server, string configName) :
|
||||
base(config, server, configName)
|
||||
{
|
||||
if (configName != String.Empty)
|
||||
m_ConfigName = configName;
|
||||
|
||||
IConfig serverConfig = config.Configs[m_ConfigName];
|
||||
if (serverConfig == null)
|
||||
throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
|
||||
|
||||
string assetService = serverConfig.GetString("AssetService", String.Empty);
|
||||
|
||||
if (assetService == String.Empty)
|
||||
throw new Exception("No AssetService in config file");
|
||||
|
||||
Object[] args = new Object[] { config };
|
||||
m_AssetService =
|
||||
ServerUtils.LoadPlugin<IAssetService>(assetService, args);
|
||||
|
||||
if (m_AssetService == null)
|
||||
throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName));
|
||||
|
||||
GetMeshHandler gmeshHandler = new GetMeshHandler(m_AssetService);
|
||||
IRequestHandler reqHandler
|
||||
= new RestHTTPHandler(
|
||||
"GET",
|
||||
"/CAPS/" + UUID.Random(),
|
||||
httpMethod => gmeshHandler.ProcessGetMesh(httpMethod, UUID.Zero, null),
|
||||
"GetMesh",
|
||||
null);
|
||||
server.AddStreamHandler(reqHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,369 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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.Specialized;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenMetaverse.Imaging;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using Caps = OpenSim.Framework.Capabilities.Caps;
|
||||
|
||||
namespace OpenSim.Capabilities.Handlers
|
||||
{
|
||||
public class GetTextureHandler : BaseStreamHandler
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private IAssetService m_assetService;
|
||||
|
||||
public const string DefaultFormat = "x-j2c";
|
||||
|
||||
// TODO: Change this to a config option
|
||||
const string REDIRECT_URL = null;
|
||||
|
||||
public GetTextureHandler(string path, IAssetService assService, string name, string description)
|
||||
: base("GET", path, name, description)
|
||||
{
|
||||
m_assetService = assService;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
// Try to parse the texture ID from the request URL
|
||||
NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
|
||||
string textureStr = query.GetOne("texture_id");
|
||||
string format = query.GetOne("format");
|
||||
|
||||
//m_log.DebugFormat("[GETTEXTURE]: called {0}", textureStr);
|
||||
|
||||
if (m_assetService == null)
|
||||
{
|
||||
m_log.Error("[GETTEXTURE]: Cannot fetch texture " + textureStr + " without an asset service");
|
||||
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
|
||||
}
|
||||
|
||||
UUID textureID;
|
||||
if (!String.IsNullOrEmpty(textureStr) && UUID.TryParse(textureStr, out textureID))
|
||||
{
|
||||
// m_log.DebugFormat("[GETTEXTURE]: Received request for texture id {0}", textureID);
|
||||
|
||||
string[] formats;
|
||||
if (format != null && format != string.Empty)
|
||||
{
|
||||
formats = new string[1] { format.ToLower() };
|
||||
}
|
||||
else
|
||||
{
|
||||
formats = WebUtil.GetPreferredImageTypes(httpRequest.Headers.Get("Accept"));
|
||||
if (formats.Length == 0)
|
||||
formats = new string[1] { DefaultFormat }; // default
|
||||
|
||||
}
|
||||
// OK, we have an array with preferred formats, possibly with only one entry
|
||||
|
||||
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
|
||||
foreach (string f in formats)
|
||||
{
|
||||
if (FetchTexture(httpRequest, httpResponse, textureID, f))
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Warn("[GETTEXTURE]: Failed to parse a texture_id from GetTexture request: " + httpRequest.Url);
|
||||
}
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[GETTEXTURE]: For texture {0} sending back response {1}, data length {2}",
|
||||
// textureID, httpResponse.StatusCode, httpResponse.ContentLength);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="httpRequest"></param>
|
||||
/// <param name="httpResponse"></param>
|
||||
/// <param name="textureID"></param>
|
||||
/// <param name="format"></param>
|
||||
/// <returns>False for "caller try another codec"; true otherwise</returns>
|
||||
private bool FetchTexture(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID textureID, string format)
|
||||
{
|
||||
// m_log.DebugFormat("[GETTEXTURE]: {0} with requested format {1}", textureID, format);
|
||||
AssetBase texture;
|
||||
|
||||
string fullID = textureID.ToString();
|
||||
if (format != DefaultFormat)
|
||||
fullID = fullID + "-" + format;
|
||||
|
||||
if (!String.IsNullOrEmpty(REDIRECT_URL))
|
||||
{
|
||||
// Only try to fetch locally cached textures. Misses are redirected
|
||||
texture = m_assetService.GetCached(fullID);
|
||||
|
||||
if (texture != null)
|
||||
{
|
||||
if (texture.Type != (sbyte)AssetType.Texture)
|
||||
{
|
||||
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
|
||||
return true;
|
||||
}
|
||||
WriteTextureData(httpRequest, httpResponse, texture, format);
|
||||
}
|
||||
else
|
||||
{
|
||||
string textureUrl = REDIRECT_URL + textureID.ToString();
|
||||
m_log.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl);
|
||||
httpResponse.RedirectLocation = textureUrl;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else // no redirect
|
||||
{
|
||||
// try the cache
|
||||
texture = m_assetService.GetCached(fullID);
|
||||
|
||||
if (texture == null)
|
||||
{
|
||||
//m_log.DebugFormat("[GETTEXTURE]: texture was not in the cache");
|
||||
|
||||
// Fetch locally or remotely. Misses return a 404
|
||||
texture = m_assetService.Get(textureID.ToString());
|
||||
|
||||
if (texture != null)
|
||||
{
|
||||
if (texture.Type != (sbyte)AssetType.Texture)
|
||||
{
|
||||
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
|
||||
return true;
|
||||
}
|
||||
if (format == DefaultFormat)
|
||||
{
|
||||
WriteTextureData(httpRequest, httpResponse, texture, format);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
AssetBase newTexture = new AssetBase(texture.ID + "-" + format, texture.Name, (sbyte)AssetType.Texture, texture.Metadata.CreatorID);
|
||||
newTexture.Data = ConvertTextureData(texture, format);
|
||||
if (newTexture.Data.Length == 0)
|
||||
return false; // !!! Caller try another codec, please!
|
||||
|
||||
newTexture.Flags = AssetFlags.Collectable;
|
||||
newTexture.Temporary = true;
|
||||
m_assetService.Store(newTexture);
|
||||
WriteTextureData(httpRequest, httpResponse, newTexture, format);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // it was on the cache
|
||||
{
|
||||
//m_log.DebugFormat("[GETTEXTURE]: texture was in the cache");
|
||||
WriteTextureData(httpRequest, httpResponse, texture, format);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// not found
|
||||
// m_log.Warn("[GETTEXTURE]: Texture " + textureID + " not found");
|
||||
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void WriteTextureData(IOSHttpRequest request, IOSHttpResponse response, AssetBase texture, string format)
|
||||
{
|
||||
string range = request.Headers.GetOne("Range");
|
||||
|
||||
if (!String.IsNullOrEmpty(range)) // JP2's only
|
||||
{
|
||||
// Range request
|
||||
int start, end;
|
||||
if (TryParseRange(range, out start, out end))
|
||||
{
|
||||
|
||||
// Before clamping start make sure we can satisfy it in order to avoid
|
||||
// sending back the last byte instead of an error status
|
||||
if (start >= texture.Data.Length)
|
||||
{
|
||||
response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable;
|
||||
}
|
||||
else
|
||||
{
|
||||
end = Utils.Clamp(end, 0, texture.Data.Length - 1);
|
||||
start = Utils.Clamp(start, 0, end);
|
||||
int len = end - start + 1;
|
||||
|
||||
//m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID);
|
||||
|
||||
// Always return PartialContent, even if the range covered the entire data length
|
||||
// We were accidentally sending back 404 before in this situation
|
||||
// https://issues.apache.org/bugzilla/show_bug.cgi?id=51878 supports sending 206 even if the
|
||||
// entire range is requested, and viewer 3.2.2 (and very probably earlier) seems fine with this.
|
||||
response.StatusCode = (int)System.Net.HttpStatusCode.PartialContent;
|
||||
|
||||
response.ContentLength = len;
|
||||
response.ContentType = texture.Metadata.ContentType;
|
||||
response.AddHeader("Content-Range", String.Format("bytes {0}-{1}/{2}", start, end, texture.Data.Length));
|
||||
|
||||
response.Body.Write(texture.Data, start, len);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Warn("[GETTEXTURE]: Malformed Range header: " + range);
|
||||
response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
|
||||
}
|
||||
}
|
||||
else // JP2's or other formats
|
||||
{
|
||||
// Full content request
|
||||
response.StatusCode = (int)System.Net.HttpStatusCode.OK;
|
||||
response.ContentLength = texture.Data.Length;
|
||||
if (format == DefaultFormat)
|
||||
response.ContentType = texture.Metadata.ContentType;
|
||||
else
|
||||
response.ContentType = "image/" + format;
|
||||
response.Body.Write(texture.Data, 0, texture.Data.Length);
|
||||
}
|
||||
|
||||
// if (response.StatusCode < 200 || response.StatusCode > 299)
|
||||
// m_log.WarnFormat(
|
||||
// "[GETTEXTURE]: For texture {0} requested range {1} responded {2} with content length {3} (actual {4})",
|
||||
// texture.FullID, range, response.StatusCode, response.ContentLength, texture.Data.Length);
|
||||
// else
|
||||
// m_log.DebugFormat(
|
||||
// "[GETTEXTURE]: For texture {0} requested range {1} responded {2} with content length {3} (actual {4})",
|
||||
// texture.FullID, range, response.StatusCode, response.ContentLength, texture.Data.Length);
|
||||
}
|
||||
|
||||
private bool TryParseRange(string header, out int start, out int end)
|
||||
{
|
||||
if (header.StartsWith("bytes="))
|
||||
{
|
||||
string[] rangeValues = header.Substring(6).Split('-');
|
||||
if (rangeValues.Length == 2)
|
||||
{
|
||||
if (Int32.TryParse(rangeValues[0], out start) && Int32.TryParse(rangeValues[1], out end))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
start = end = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
private byte[] ConvertTextureData(AssetBase texture, string format)
|
||||
{
|
||||
m_log.DebugFormat("[GETTEXTURE]: Converting texture {0} to {1}", texture.ID, format);
|
||||
byte[] data = new byte[0];
|
||||
|
||||
MemoryStream imgstream = new MemoryStream();
|
||||
Bitmap mTexture = new Bitmap(1, 1);
|
||||
ManagedImage managedImage;
|
||||
Image image = (Image)mTexture;
|
||||
|
||||
try
|
||||
{
|
||||
// Taking our jpeg2000 data, decoding it, then saving it to a byte array with regular data
|
||||
|
||||
imgstream = new MemoryStream();
|
||||
|
||||
// Decode image to System.Drawing.Image
|
||||
if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image))
|
||||
{
|
||||
// Save to bitmap
|
||||
mTexture = new Bitmap(image);
|
||||
|
||||
EncoderParameters myEncoderParameters = new EncoderParameters();
|
||||
myEncoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, 95L);
|
||||
|
||||
// Save bitmap to stream
|
||||
ImageCodecInfo codec = GetEncoderInfo("image/" + format);
|
||||
if (codec != null)
|
||||
{
|
||||
mTexture.Save(imgstream, codec, myEncoderParameters);
|
||||
// Write the stream to a byte array for output
|
||||
data = imgstream.ToArray();
|
||||
}
|
||||
else
|
||||
m_log.WarnFormat("[GETTEXTURE]: No such codec {0}", format);
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.WarnFormat("[GETTEXTURE]: Unable to convert texture {0} to {1}: {2}", texture.ID, format, e.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Reclaim memory, these are unmanaged resources
|
||||
// If we encountered an exception, one or more of these will be null
|
||||
if (mTexture != null)
|
||||
mTexture.Dispose();
|
||||
|
||||
if (image != null)
|
||||
image.Dispose();
|
||||
|
||||
if (imgstream != null)
|
||||
{
|
||||
imgstream.Close();
|
||||
imgstream.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
// From msdn
|
||||
private static ImageCodecInfo GetEncoderInfo(String mimeType)
|
||||
{
|
||||
ImageCodecInfo[] encoders;
|
||||
encoders = ImageCodecInfo.GetImageEncoders();
|
||||
for (int j = 0; j < encoders.Length; ++j)
|
||||
{
|
||||
if (encoders[j].MimeType == mimeType)
|
||||
return encoders[j];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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 Nini.Config;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Server.Handlers.Base;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Capabilities.Handlers
|
||||
{
|
||||
public class GetTextureServerConnector : ServiceConnector
|
||||
{
|
||||
private IAssetService m_AssetService;
|
||||
private string m_ConfigName = "CapsService";
|
||||
|
||||
public GetTextureServerConnector(IConfigSource config, IHttpServer server, string configName) :
|
||||
base(config, server, configName)
|
||||
{
|
||||
if (configName != String.Empty)
|
||||
m_ConfigName = configName;
|
||||
|
||||
IConfig serverConfig = config.Configs[m_ConfigName];
|
||||
if (serverConfig == null)
|
||||
throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
|
||||
|
||||
string assetService = serverConfig.GetString("AssetService", String.Empty);
|
||||
|
||||
if (assetService == String.Empty)
|
||||
throw new Exception("No AssetService in config file");
|
||||
|
||||
Object[] args = new Object[] { config };
|
||||
m_AssetService =
|
||||
ServerUtils.LoadPlugin<IAssetService>(assetService, args);
|
||||
|
||||
if (m_AssetService == null)
|
||||
throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName));
|
||||
|
||||
server.AddStreamHandler(
|
||||
new GetTextureHandler("/CAPS/GetTexture/" /*+ UUID.Random() */, m_AssetService, "GetTexture", null));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,181 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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.Specialized;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenMetaverse.Imaging;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Capabilities;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using Caps = OpenSim.Framework.Capabilities.Caps;
|
||||
|
||||
namespace OpenSim.Capabilities.Handlers
|
||||
{
|
||||
public class UploadBakedTextureHandler
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private Caps m_HostCapsObj;
|
||||
private IAssetService m_assetService;
|
||||
private bool m_persistBakedTextures;
|
||||
|
||||
public UploadBakedTextureHandler(Caps caps, IAssetService assetService, bool persistBakedTextures)
|
||||
{
|
||||
m_HostCapsObj = caps;
|
||||
m_assetService = assetService;
|
||||
m_persistBakedTextures = persistBakedTextures;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle a request from the client for a Uri to upload a baked texture.
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="param"></param>
|
||||
/// <param name="httpRequest"></param>
|
||||
/// <param name="httpResponse"></param>
|
||||
/// <returns>The upload response if the request is successful, null otherwise.</returns>
|
||||
public string UploadBakedTexture(
|
||||
string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
try
|
||||
{
|
||||
string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath;
|
||||
string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
|
||||
|
||||
BakedTextureUploader uploader =
|
||||
new BakedTextureUploader(capsBase + uploaderPath, m_HostCapsObj.HttpListener);
|
||||
uploader.OnUpLoad += BakedTextureUploaded;
|
||||
|
||||
m_HostCapsObj.HttpListener.AddStreamHandler(
|
||||
new BinaryStreamHandler(
|
||||
"POST", capsBase + uploaderPath, uploader.uploaderCaps, "UploadBakedTexture", null));
|
||||
|
||||
string protocol = "http://";
|
||||
|
||||
if (m_HostCapsObj.SSLCaps)
|
||||
protocol = "https://";
|
||||
|
||||
string uploaderURL = protocol + m_HostCapsObj.HostName + ":" +
|
||||
m_HostCapsObj.Port.ToString() + capsBase + uploaderPath;
|
||||
|
||||
LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse();
|
||||
uploadResponse.uploader = uploaderURL;
|
||||
uploadResponse.state = "upload";
|
||||
|
||||
return LLSDHelpers.SerialiseLLSDReply(uploadResponse);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[UPLOAD BAKED TEXTURE HANDLER]: {0}{1}", e.Message, e.StackTrace);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a baked texture has been successfully uploaded by a client.
|
||||
/// </summary>
|
||||
/// <param name="assetID"></param>
|
||||
/// <param name="data"></param>
|
||||
private void BakedTextureUploaded(UUID assetID, byte[] data)
|
||||
{
|
||||
// m_log.DebugFormat("[UPLOAD BAKED TEXTURE HANDLER]: Received baked texture {0}", assetID.ToString());
|
||||
|
||||
AssetBase asset;
|
||||
asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_HostCapsObj.AgentID.ToString());
|
||||
asset.Data = data;
|
||||
asset.Temporary = true;
|
||||
asset.Local = !m_persistBakedTextures; // Local assets aren't persisted, non-local are
|
||||
m_assetService.Store(asset);
|
||||
}
|
||||
}
|
||||
|
||||
class BakedTextureUploader
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public event Action<UUID, byte[]> OnUpLoad;
|
||||
|
||||
private string uploaderPath = String.Empty;
|
||||
private UUID newAssetID;
|
||||
private IHttpServer httpListener;
|
||||
|
||||
public BakedTextureUploader(string path, IHttpServer httpServer)
|
||||
{
|
||||
newAssetID = UUID.Random();
|
||||
uploaderPath = path;
|
||||
httpListener = httpServer;
|
||||
// m_log.InfoFormat("[CAPS] baked texture upload starting for {0}",newAssetID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle raw uploaded baked texture data.
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="param"></param>
|
||||
/// <returns></returns>
|
||||
public string uploaderCaps(byte[] data, string path, string param)
|
||||
{
|
||||
Action<UUID, byte[]> handlerUpLoad = OnUpLoad;
|
||||
|
||||
// Don't do this asynchronously, otherwise it's possible for the client to send set appearance information
|
||||
// on another thread which might send out avatar updates before the asset has been put into the asset
|
||||
// service.
|
||||
if (handlerUpLoad != null)
|
||||
handlerUpLoad(newAssetID, data);
|
||||
|
||||
string res = String.Empty;
|
||||
LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
|
||||
uploadComplete.new_asset = newAssetID.ToString();
|
||||
uploadComplete.new_inventory_item = UUID.Zero;
|
||||
uploadComplete.state = "complete";
|
||||
|
||||
res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
|
||||
|
||||
httpListener.RemoveStreamHandler("POST", uploaderPath);
|
||||
|
||||
// m_log.DebugFormat("[BAKED TEXTURE UPLOADER]: baked texture upload completed for {0}", newAssetID);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,438 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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.Reflection;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Capabilities;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using Caps = OpenSim.Framework.Capabilities.Caps;
|
||||
|
||||
namespace OpenSim.Capabilities.Handlers
|
||||
{
|
||||
public class WebFetchInvDescHandler
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private IInventoryService m_InventoryService;
|
||||
private ILibraryService m_LibraryService;
|
||||
// private object m_fetchLock = new Object();
|
||||
|
||||
public WebFetchInvDescHandler(IInventoryService invService, ILibraryService libService)
|
||||
{
|
||||
m_InventoryService = invService;
|
||||
m_LibraryService = libService;
|
||||
}
|
||||
|
||||
public string FetchInventoryDescendentsRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
// lock (m_fetchLock)
|
||||
// {
|
||||
// m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Received request {0}", request);
|
||||
|
||||
// nasty temporary hack here, the linden client falsely
|
||||
// identifies the uuid 00000000-0000-0000-0000-000000000000
|
||||
// as a string which breaks us
|
||||
//
|
||||
// correctly mark it as a uuid
|
||||
//
|
||||
request = request.Replace("<string>00000000-0000-0000-0000-000000000000</string>", "<uuid>00000000-0000-0000-0000-000000000000</uuid>");
|
||||
|
||||
// another hack <integer>1</integer> results in a
|
||||
// System.ArgumentException: Object type System.Int32 cannot
|
||||
// be converted to target type: System.Boolean
|
||||
//
|
||||
request = request.Replace("<key>fetch_folders</key><integer>0</integer>", "<key>fetch_folders</key><boolean>0</boolean>");
|
||||
request = request.Replace("<key>fetch_folders</key><integer>1</integer>", "<key>fetch_folders</key><boolean>1</boolean>");
|
||||
|
||||
Hashtable hash = new Hashtable();
|
||||
try
|
||||
{
|
||||
hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request));
|
||||
}
|
||||
catch (LLSD.LLSDParseException e)
|
||||
{
|
||||
m_log.ErrorFormat("[WEB FETCH INV DESC HANDLER]: Fetch error: {0}{1}" + e.Message, e.StackTrace);
|
||||
m_log.Error("Request: " + request);
|
||||
}
|
||||
|
||||
ArrayList foldersrequested = (ArrayList)hash["folders"];
|
||||
|
||||
string response = "";
|
||||
|
||||
for (int i = 0; i < foldersrequested.Count; i++)
|
||||
{
|
||||
string inventoryitemstr = "";
|
||||
Hashtable inventoryhash = (Hashtable)foldersrequested[i];
|
||||
|
||||
LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents();
|
||||
|
||||
try
|
||||
{
|
||||
LLSDHelpers.DeserialiseOSDMap(inventoryhash, llsdRequest);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Debug("[WEB FETCH INV DESC HANDLER]: caught exception doing OSD deserialize" + e);
|
||||
}
|
||||
LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest);
|
||||
|
||||
inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply);
|
||||
inventoryitemstr = inventoryitemstr.Replace("<llsd><map><key>folders</key><array>", "");
|
||||
inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", "");
|
||||
|
||||
response += inventoryitemstr;
|
||||
}
|
||||
|
||||
if (response.Length == 0)
|
||||
{
|
||||
// Ter-guess: If requests fail a lot, the client seems to stop requesting descendants.
|
||||
// Therefore, I'm concluding that the client only has so many threads available to do requests
|
||||
// and when a thread stalls.. is stays stalled.
|
||||
// Therefore we need to return something valid
|
||||
response = "<llsd><map><key>folders</key><array /></map></llsd>";
|
||||
}
|
||||
else
|
||||
{
|
||||
response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>";
|
||||
}
|
||||
|
||||
// m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Replying to CAPS fetch inventory request");
|
||||
//m_log.Debug("[WEB FETCH INV DESC HANDLER] "+response);
|
||||
|
||||
return response;
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Construct an LLSD reply packet to a CAPS inventory request
|
||||
/// </summary>
|
||||
/// <param name="invFetch"></param>
|
||||
/// <returns></returns>
|
||||
private LLSDInventoryDescendents FetchInventoryReply(LLSDFetchInventoryDescendents invFetch)
|
||||
{
|
||||
LLSDInventoryDescendents reply = new LLSDInventoryDescendents();
|
||||
LLSDInventoryFolderContents contents = new LLSDInventoryFolderContents();
|
||||
contents.agent_id = invFetch.owner_id;
|
||||
contents.owner_id = invFetch.owner_id;
|
||||
contents.folder_id = invFetch.folder_id;
|
||||
|
||||
reply.folders.Array.Add(contents);
|
||||
InventoryCollection inv = new InventoryCollection();
|
||||
inv.Folders = new List<InventoryFolderBase>();
|
||||
inv.Items = new List<InventoryItemBase>();
|
||||
int version = 0;
|
||||
int descendents = 0;
|
||||
|
||||
inv
|
||||
= Fetch(
|
||||
invFetch.owner_id, invFetch.folder_id, invFetch.owner_id,
|
||||
invFetch.fetch_folders, invFetch.fetch_items, invFetch.sort_order, out version, out descendents);
|
||||
|
||||
if (inv != null && inv.Folders != null)
|
||||
{
|
||||
foreach (InventoryFolderBase invFolder in inv.Folders)
|
||||
{
|
||||
contents.categories.Array.Add(ConvertInventoryFolder(invFolder));
|
||||
}
|
||||
|
||||
descendents += inv.Folders.Count;
|
||||
}
|
||||
|
||||
if (inv != null && inv.Items != null)
|
||||
{
|
||||
foreach (InventoryItemBase invItem in inv.Items)
|
||||
{
|
||||
contents.items.Array.Add(ConvertInventoryItem(invItem));
|
||||
}
|
||||
}
|
||||
|
||||
contents.descendents = descendents;
|
||||
contents.version = version;
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[WEB FETCH INV DESC HANDLER]: Replying to request for folder {0} (fetch items {1}, fetch folders {2}) with {3} items and {4} folders for agent {5}",
|
||||
// invFetch.folder_id,
|
||||
// invFetch.fetch_items,
|
||||
// invFetch.fetch_folders,
|
||||
// contents.items.Array.Count,
|
||||
// contents.categories.Array.Count,
|
||||
// invFetch.owner_id);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle the caps inventory descendents fetch.
|
||||
/// </summary>
|
||||
/// <param name="agentID"></param>
|
||||
/// <param name="folderID"></param>
|
||||
/// <param name="ownerID"></param>
|
||||
/// <param name="fetchFolders"></param>
|
||||
/// <param name="fetchItems"></param>
|
||||
/// <param name="sortOrder"></param>
|
||||
/// <param name="version"></param>
|
||||
/// <returns>An empty InventoryCollection if the inventory look up failed</returns>
|
||||
private InventoryCollection Fetch(
|
||||
UUID agentID, UUID folderID, UUID ownerID,
|
||||
bool fetchFolders, bool fetchItems, int sortOrder, out int version, out int descendents)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[WEB FETCH INV DESC HANDLER]: Fetching folders ({0}), items ({1}) from {2} for agent {3}",
|
||||
// fetchFolders, fetchItems, folderID, agentID);
|
||||
|
||||
// FIXME MAYBE: We're not handling sortOrder!
|
||||
|
||||
version = 0;
|
||||
descendents = 0;
|
||||
|
||||
InventoryFolderImpl fold;
|
||||
if (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null && agentID == m_LibraryService.LibraryRootFolder.Owner)
|
||||
{
|
||||
if ((fold = m_LibraryService.LibraryRootFolder.FindFolder(folderID)) != null)
|
||||
{
|
||||
InventoryCollection ret = new InventoryCollection();
|
||||
ret.Folders = new List<InventoryFolderBase>();
|
||||
ret.Items = fold.RequestListOfItems();
|
||||
descendents = ret.Folders.Count + ret.Items.Count;
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
InventoryCollection contents = new InventoryCollection();
|
||||
|
||||
if (folderID != UUID.Zero)
|
||||
{
|
||||
contents = m_InventoryService.GetFolderContent(agentID, folderID);
|
||||
InventoryFolderBase containingFolder = new InventoryFolderBase();
|
||||
containingFolder.ID = folderID;
|
||||
containingFolder.Owner = agentID;
|
||||
containingFolder = m_InventoryService.GetFolder(containingFolder);
|
||||
|
||||
if (containingFolder != null)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[WEB FETCH INV DESC HANDLER]: Retrieved folder {0} {1} for agent id {2}",
|
||||
// containingFolder.Name, containingFolder.ID, agentID);
|
||||
|
||||
version = containingFolder.Version;
|
||||
|
||||
if (fetchItems)
|
||||
{
|
||||
List<InventoryItemBase> itemsToReturn = contents.Items;
|
||||
List<InventoryItemBase> originalItems = new List<InventoryItemBase>(itemsToReturn);
|
||||
|
||||
// descendents must only include the links, not the linked items we add
|
||||
descendents = originalItems.Count;
|
||||
|
||||
// Add target items for links in this folder before the links themselves.
|
||||
foreach (InventoryItemBase item in originalItems)
|
||||
{
|
||||
if (item.AssetType == (int)AssetType.Link)
|
||||
{
|
||||
InventoryItemBase linkedItem = m_InventoryService.GetItem(new InventoryItemBase(item.AssetID));
|
||||
|
||||
// Take care of genuinely broken links where the target doesn't exist
|
||||
// HACK: Also, don't follow up links that just point to other links. In theory this is legitimate,
|
||||
// but no viewer has been observed to set these up and this is the lazy way of avoiding cycles
|
||||
// rather than having to keep track of every folder requested in the recursion.
|
||||
if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link)
|
||||
itemsToReturn.Insert(0, linkedItem);
|
||||
}
|
||||
}
|
||||
|
||||
// Now scan for folder links and insert the items they target and those links at the head of the return data
|
||||
foreach (InventoryItemBase item in originalItems)
|
||||
{
|
||||
if (item.AssetType == (int)AssetType.LinkFolder)
|
||||
{
|
||||
InventoryCollection linkedFolderContents = m_InventoryService.GetFolderContent(ownerID, item.AssetID);
|
||||
List<InventoryItemBase> links = linkedFolderContents.Items;
|
||||
|
||||
itemsToReturn.InsertRange(0, links);
|
||||
|
||||
foreach (InventoryItemBase link in linkedFolderContents.Items)
|
||||
{
|
||||
// Take care of genuinely broken links where the target doesn't exist
|
||||
// HACK: Also, don't follow up links that just point to other links. In theory this is legitimate,
|
||||
// but no viewer has been observed to set these up and this is the lazy way of avoiding cycles
|
||||
// rather than having to keep track of every folder requested in the recursion.
|
||||
if (link != null)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[WEB FETCH INV DESC HANDLER]: Adding item {0} {1} from folder {2} linked from {3}",
|
||||
// link.Name, (AssetType)link.AssetType, item.AssetID, containingFolder.Name);
|
||||
|
||||
InventoryItemBase linkedItem
|
||||
= m_InventoryService.GetItem(new InventoryItemBase(link.AssetID));
|
||||
|
||||
if (linkedItem != null)
|
||||
itemsToReturn.Insert(0, linkedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// foreach (InventoryItemBase item in contents.Items)
|
||||
// {
|
||||
// m_log.DebugFormat(
|
||||
// "[WEB FETCH INV DESC HANDLER]: Returning item {0}, type {1}, parent {2} in {3} {4}",
|
||||
// item.Name, (AssetType)item.AssetType, item.Folder, containingFolder.Name, containingFolder.ID);
|
||||
// }
|
||||
|
||||
// =====
|
||||
|
||||
//
|
||||
// foreach (InventoryItemBase linkedItem in linkedItemsToAdd)
|
||||
// {
|
||||
// m_log.DebugFormat(
|
||||
// "[WEB FETCH INV DESC HANDLER]: Inserted linked item {0} for link in folder {1} for agent {2}",
|
||||
// linkedItem.Name, folderID, agentID);
|
||||
//
|
||||
// contents.Items.Add(linkedItem);
|
||||
// }
|
||||
//
|
||||
// // If the folder requested contains links, then we need to send those folders first, otherwise the links
|
||||
// // will be broken in the viewer.
|
||||
// HashSet<UUID> linkedItemFolderIdsToSend = new HashSet<UUID>();
|
||||
// foreach (InventoryItemBase item in contents.Items)
|
||||
// {
|
||||
// if (item.AssetType == (int)AssetType.Link)
|
||||
// {
|
||||
// InventoryItemBase linkedItem = m_InventoryService.GetItem(new InventoryItemBase(item.AssetID));
|
||||
//
|
||||
// // Take care of genuinely broken links where the target doesn't exist
|
||||
// // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate,
|
||||
// // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles
|
||||
// // rather than having to keep track of every folder requested in the recursion.
|
||||
// if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link)
|
||||
// {
|
||||
// // We don't need to send the folder if source and destination of the link are in the same
|
||||
// // folder.
|
||||
// if (linkedItem.Folder != containingFolder.ID)
|
||||
// linkedItemFolderIdsToSend.Add(linkedItem.Folder);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// foreach (UUID linkedItemFolderId in linkedItemFolderIdsToSend)
|
||||
// {
|
||||
// m_log.DebugFormat(
|
||||
// "[WEB FETCH INV DESC HANDLER]: Recursively fetching folder {0} linked by item in folder {1} for agent {2}",
|
||||
// linkedItemFolderId, folderID, agentID);
|
||||
//
|
||||
// int dummyVersion;
|
||||
// InventoryCollection linkedCollection
|
||||
// = Fetch(
|
||||
// agentID, linkedItemFolderId, ownerID, fetchFolders, fetchItems, sortOrder, out dummyVersion);
|
||||
//
|
||||
// InventoryFolderBase linkedFolder = new InventoryFolderBase(linkedItemFolderId);
|
||||
// linkedFolder.Owner = agentID;
|
||||
// linkedFolder = m_InventoryService.GetFolder(linkedFolder);
|
||||
//
|
||||
//// contents.Folders.AddRange(linkedCollection.Folders);
|
||||
//
|
||||
// contents.Folders.Add(linkedFolder);
|
||||
// contents.Items.AddRange(linkedCollection.Items);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Lost items don't really need a version
|
||||
version = 1;
|
||||
}
|
||||
|
||||
return contents;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Convert an internal inventory folder object into an LLSD object.
|
||||
/// </summary>
|
||||
/// <param name="invFolder"></param>
|
||||
/// <returns></returns>
|
||||
private LLSDInventoryFolder ConvertInventoryFolder(InventoryFolderBase invFolder)
|
||||
{
|
||||
LLSDInventoryFolder llsdFolder = new LLSDInventoryFolder();
|
||||
llsdFolder.folder_id = invFolder.ID;
|
||||
llsdFolder.parent_id = invFolder.ParentID;
|
||||
llsdFolder.name = invFolder.Name;
|
||||
llsdFolder.type = invFolder.Type;
|
||||
llsdFolder.preferred_type = -1;
|
||||
|
||||
return llsdFolder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert an internal inventory item object into an LLSD object.
|
||||
/// </summary>
|
||||
/// <param name="invItem"></param>
|
||||
/// <returns></returns>
|
||||
private LLSDInventoryItem ConvertInventoryItem(InventoryItemBase invItem)
|
||||
{
|
||||
LLSDInventoryItem llsdItem = new LLSDInventoryItem();
|
||||
llsdItem.asset_id = invItem.AssetID;
|
||||
llsdItem.created_at = invItem.CreationDate;
|
||||
llsdItem.desc = invItem.Description;
|
||||
llsdItem.flags = (int)invItem.Flags;
|
||||
llsdItem.item_id = invItem.ID;
|
||||
llsdItem.name = invItem.Name;
|
||||
llsdItem.parent_id = invItem.Folder;
|
||||
llsdItem.type = invItem.AssetType;
|
||||
llsdItem.inv_type = invItem.InvType;
|
||||
|
||||
llsdItem.permissions = new LLSDPermissions();
|
||||
llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid;
|
||||
llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions;
|
||||
llsdItem.permissions.everyone_mask = (int)invItem.EveryOnePermissions;
|
||||
llsdItem.permissions.group_id = invItem.GroupID;
|
||||
llsdItem.permissions.group_mask = (int)invItem.GroupPermissions;
|
||||
llsdItem.permissions.is_owner_group = invItem.GroupOwned;
|
||||
llsdItem.permissions.next_owner_mask = (int)invItem.NextPermissions;
|
||||
llsdItem.permissions.owner_id = invItem.Owner;
|
||||
llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions;
|
||||
llsdItem.sale_info = new LLSDSaleInfo();
|
||||
llsdItem.sale_info.sale_price = invItem.SalePrice;
|
||||
llsdItem.sale_info.sale_type = invItem.SaleType;
|
||||
|
||||
return llsdItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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 Nini.Config;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Server.Handlers.Base;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Capabilities.Handlers
|
||||
{
|
||||
public class WebFetchInvDescServerConnector : ServiceConnector
|
||||
{
|
||||
private IInventoryService m_InventoryService;
|
||||
private ILibraryService m_LibraryService;
|
||||
private string m_ConfigName = "CapsService";
|
||||
|
||||
public WebFetchInvDescServerConnector(IConfigSource config, IHttpServer server, string configName) :
|
||||
base(config, server, configName)
|
||||
{
|
||||
if (configName != String.Empty)
|
||||
m_ConfigName = configName;
|
||||
|
||||
IConfig serverConfig = config.Configs[m_ConfigName];
|
||||
if (serverConfig == null)
|
||||
throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
|
||||
|
||||
string invService = serverConfig.GetString("InventoryService", String.Empty);
|
||||
|
||||
if (invService == String.Empty)
|
||||
throw new Exception("No InventoryService in config file");
|
||||
|
||||
Object[] args = new Object[] { config };
|
||||
m_InventoryService =
|
||||
ServerUtils.LoadPlugin<IInventoryService>(invService, args);
|
||||
|
||||
if (m_InventoryService == null)
|
||||
throw new Exception(String.Format("Failed to load InventoryService from {0}; config is {1}", invService, m_ConfigName));
|
||||
|
||||
string libService = serverConfig.GetString("LibraryService", String.Empty);
|
||||
m_LibraryService =
|
||||
ServerUtils.LoadPlugin<ILibraryService>(libService, args);
|
||||
|
||||
WebFetchInvDescHandler webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService);
|
||||
IRequestHandler reqHandler
|
||||
= new RestStreamHandler(
|
||||
"POST",
|
||||
"/CAPS/WebFetchInvDesc/" /*+ UUID.Random()*/,
|
||||
webFetchHandler.FetchInventoryDescendentsRequest,
|
||||
"WebFetchInvDesc",
|
||||
null);
|
||||
server.AddStreamHandler(reqHandler);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -26,53 +26,94 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Region.ClientStack;
|
||||
using OpenSim.Region.ClientStack.LindenUDP;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Server.Handlers.Base;
|
||||
using OpenSim.Server.Handlers.Authentication;
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Authentication
|
||||
namespace OpenSim.Client.Linden
|
||||
{
|
||||
public class AuthenticationServiceInConnectorModule : ISharedRegionModule
|
||||
/// <summary>
|
||||
/// Linden UDP Stack Region Module
|
||||
/// </summary>
|
||||
public class LLClientStackModule : INonSharedRegionModule
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static bool m_Enabled = false;
|
||||
|
||||
private IConfigSource m_Config;
|
||||
bool m_Registered = false;
|
||||
|
||||
#region IRegionModule interface
|
||||
#region IRegionModule Members
|
||||
|
||||
public void Initialise(IConfigSource config)
|
||||
/// <summary>
|
||||
/// Scene that contains the region's data
|
||||
/// </summary>
|
||||
protected Scene m_scene;
|
||||
protected bool m_createClientStack = false;
|
||||
protected IClientNetworkServer m_clientServer;
|
||||
protected ClientStackManager m_clientStackManager;
|
||||
protected IConfigSource m_source;
|
||||
|
||||
protected string m_clientStackDll = "OpenSim.Region.ClientStack.LindenUDP.dll";
|
||||
|
||||
public void Initialise(IConfigSource source)
|
||||
{
|
||||
m_Config = config;
|
||||
IConfig moduleConfig = config.Configs["Modules"];
|
||||
if (moduleConfig != null)
|
||||
if (m_scene == null)
|
||||
{
|
||||
m_Enabled = moduleConfig.GetBoolean("AuthenticationServiceInConnector", false);
|
||||
if (m_Enabled)
|
||||
{
|
||||
m_log.Info("[AUTHENTICATION IN CONNECTOR]: Authentication Service In Connector enabled");
|
||||
}
|
||||
m_source = source;
|
||||
|
||||
IConfig startupConfig = m_source.Configs["Startup"];
|
||||
if (startupConfig != null)
|
||||
{
|
||||
m_clientStackDll = startupConfig.GetString("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
if (m_scene == null)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
if ((m_scene != null) && (m_createClientStack))
|
||||
{
|
||||
m_log.Info("[LLClientStackModule] Starting up LLClientStack.");
|
||||
IPEndPoint endPoint = m_scene.RegionInfo.InternalEndPoint;
|
||||
|
||||
uint port = (uint)endPoint.Port;
|
||||
m_clientStackManager = new ClientStackManager(m_clientStackDll);
|
||||
|
||||
m_clientServer
|
||||
= m_clientStackManager.CreateServer(endPoint.Address,
|
||||
ref port, m_scene.RegionInfo.ProxyOffset, m_scene.RegionInfo.m_allow_alternate_ports, m_source,
|
||||
m_scene.AuthenticateHandler);
|
||||
|
||||
m_clientServer.AddScene(m_scene);
|
||||
|
||||
m_clientServer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Type ReplaceableInterface
|
||||
@@ -82,38 +123,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Authentication
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "AuthenticationServiceInConnectorModule"; }
|
||||
get { return "LLClientStackModule"; }
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
public bool IsSharedModule
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
|
||||
if (!m_Registered)
|
||||
{
|
||||
m_Registered = true;
|
||||
|
||||
m_log.Info("[AUTHENTICATION IN CONNECTOR]: Starting...");
|
||||
|
||||
new AuthenticationServiceConnector(m_Config, MainServer.Instance, "AuthenticationService");
|
||||
}
|
||||
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
364
OpenSim/Client/Linden/LLProxyLoginModule.cs
Normal file
364
OpenSim/Client/Linden/LLProxyLoginModule.cs
Normal file
@@ -0,0 +1,364 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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.Text;
|
||||
using Nwc.XmlRpc;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
using System.Security.Authentication;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Client.Linden
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles login user (expect user) and logoff user messages from the remote LL login server
|
||||
/// </summary>
|
||||
public class LLProxyLoginModule : ISharedRegionModule
|
||||
{
|
||||
private uint m_port = 0;
|
||||
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public LLProxyLoginModule(uint port)
|
||||
{
|
||||
m_log.DebugFormat("[CLIENT]: LLProxyLoginModule port {0}", port);
|
||||
m_port = port;
|
||||
}
|
||||
|
||||
protected bool RegionLoginsEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_firstScene != null)
|
||||
{
|
||||
return m_firstScene.SceneGridService.RegionLoginsEnabled;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected List<Scene> m_scenes = new List<Scene>();
|
||||
protected Scene m_firstScene;
|
||||
|
||||
protected bool m_enabled = false; // Module is only enabled if running in grid mode
|
||||
|
||||
#region IRegionModule Members
|
||||
|
||||
public void Initialise(IConfigSource source)
|
||||
{
|
||||
IConfig startupConfig = source.Configs["Modules"];
|
||||
if (startupConfig != null)
|
||||
{
|
||||
m_enabled = startupConfig.GetBoolean("LLProxyLoginModule", false);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
{
|
||||
if (m_firstScene == null)
|
||||
{
|
||||
m_firstScene = scene;
|
||||
|
||||
if (m_enabled)
|
||||
{
|
||||
AddHttpHandlers();
|
||||
}
|
||||
}
|
||||
|
||||
if (m_enabled)
|
||||
{
|
||||
AddScene(scene);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
if (m_enabled)
|
||||
{
|
||||
RemoveScene(scene);
|
||||
}
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Type ReplaceableInterface
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "LLProxyLoginModule"; }
|
||||
}
|
||||
|
||||
public bool IsSharedModule
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Adds "expect_user" and "logoff_user" xmlrpc method handlers
|
||||
/// </summary>
|
||||
protected void AddHttpHandlers()
|
||||
{
|
||||
//we will add our handlers to the first scene we received, as all scenes share a http server. But will this ever change?
|
||||
MainServer.GetHttpServer(m_port).AddXmlRPCHandler("expect_user", ExpectUser, false);
|
||||
MainServer.GetHttpServer(m_port).AddXmlRPCHandler("logoff_user", LogOffUser, false);
|
||||
}
|
||||
|
||||
protected void AddScene(Scene scene)
|
||||
{
|
||||
lock (m_scenes)
|
||||
{
|
||||
if (!m_scenes.Contains(scene))
|
||||
{
|
||||
m_scenes.Add(scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void RemoveScene(Scene scene)
|
||||
{
|
||||
lock (m_scenes)
|
||||
{
|
||||
if (m_scenes.Contains(scene))
|
||||
{
|
||||
m_scenes.Remove(scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Received from the user server when a user starts logging in. This call allows
|
||||
/// the region to prepare for direct communication from the client. Sends back an empty
|
||||
/// xmlrpc response on completion.
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public XmlRpcResponse ExpectUser(XmlRpcRequest request, IPEndPoint remoteClient)
|
||||
{
|
||||
XmlRpcResponse resp = new XmlRpcResponse();
|
||||
|
||||
try
|
||||
{
|
||||
ulong regionHandle = 0;
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
AgentCircuitData agentData = new AgentCircuitData();
|
||||
if (requestData.ContainsKey("session_id"))
|
||||
agentData.SessionID = new UUID((string)requestData["session_id"]);
|
||||
if (requestData.ContainsKey("secure_session_id"))
|
||||
agentData.SecureSessionID = new UUID((string)requestData["secure_session_id"]);
|
||||
if (requestData.ContainsKey("firstname"))
|
||||
agentData.firstname = (string)requestData["firstname"];
|
||||
if (requestData.ContainsKey("lastname"))
|
||||
agentData.lastname = (string)requestData["lastname"];
|
||||
if (requestData.ContainsKey("agent_id"))
|
||||
agentData.AgentID = new UUID((string)requestData["agent_id"]);
|
||||
if (requestData.ContainsKey("circuit_code"))
|
||||
agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
|
||||
if (requestData.ContainsKey("caps_path"))
|
||||
agentData.CapsPath = (string)requestData["caps_path"];
|
||||
if (requestData.ContainsKey("regionhandle"))
|
||||
regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
|
||||
else
|
||||
m_log.Warn("[CLIENT]: request from login server did not contain regionhandle");
|
||||
|
||||
// Appearance
|
||||
if (requestData.ContainsKey("appearance"))
|
||||
agentData.Appearance = new AvatarAppearance((Hashtable)requestData["appearance"]);
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[CLIENT]: Told by user service to prepare for a connection from {0} {1} {2}, circuit {3}",
|
||||
agentData.firstname, agentData.lastname, agentData.AgentID, agentData.circuitcode);
|
||||
|
||||
if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
|
||||
{
|
||||
//m_log.Debug("[CLIENT]: Child agent detected");
|
||||
agentData.child = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//m_log.Debug("[CLIENT]: Main agent detected");
|
||||
agentData.startpos =
|
||||
new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]),
|
||||
(float)Convert.ToDecimal((string)requestData["startpos_y"]),
|
||||
(float)Convert.ToDecimal((string)requestData["startpos_z"]));
|
||||
agentData.child = false;
|
||||
}
|
||||
|
||||
if (!RegionLoginsEnabled)
|
||||
{
|
||||
m_log.InfoFormat(
|
||||
"[CLIENT]: Denying access for user {0} {1} because region login is currently disabled",
|
||||
agentData.firstname, agentData.lastname);
|
||||
|
||||
Hashtable respdata = new Hashtable();
|
||||
respdata["success"] = "FALSE";
|
||||
respdata["reason"] = "region login currently disabled";
|
||||
resp.Value = respdata;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool success = false;
|
||||
string denyMess = "";
|
||||
|
||||
Scene scene;
|
||||
if (TryGetRegion(regionHandle, out scene))
|
||||
{
|
||||
if (scene.RegionInfo.EstateSettings.IsBanned(agentData.AgentID))
|
||||
{
|
||||
denyMess = "User is banned from this region";
|
||||
m_log.InfoFormat(
|
||||
"[CLIENT]: Denying access for user {0} {1} because user is banned",
|
||||
agentData.firstname, agentData.lastname);
|
||||
}
|
||||
else
|
||||
{
|
||||
string reason;
|
||||
if (scene.NewUserConnection(agentData, out reason))
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
denyMess = String.Format("Login refused by region: {0}", reason);
|
||||
m_log.InfoFormat(
|
||||
"[CLIENT]: Denying access for user {0} {1} because user connection was refused by the region",
|
||||
agentData.firstname, agentData.lastname);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
denyMess = "Region not found";
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
Hashtable respdata = new Hashtable();
|
||||
respdata["success"] = "TRUE";
|
||||
resp.Value = respdata;
|
||||
}
|
||||
else
|
||||
{
|
||||
Hashtable respdata = new Hashtable();
|
||||
respdata["success"] = "FALSE";
|
||||
respdata["reason"] = denyMess;
|
||||
resp.Value = respdata;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.WarnFormat("[CLIENT]: Unable to receive user. Reason: {0}", e);
|
||||
Hashtable respdata = new Hashtable();
|
||||
respdata["success"] = "FALSE";
|
||||
respdata["reason"] = "Exception occurred";
|
||||
resp.Value = respdata;
|
||||
}
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
// Grid Request Processing
|
||||
/// <summary>
|
||||
/// Ooops, our Agent must be dead if we're getting this request!
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public XmlRpcResponse LogOffUser(XmlRpcRequest request, IPEndPoint remoteClient)
|
||||
{
|
||||
m_log.Debug("[CONNECTION DEBUGGING]: LogOff User Called");
|
||||
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
string message = (string)requestData["message"];
|
||||
UUID agentID = UUID.Zero;
|
||||
UUID RegionSecret = UUID.Zero;
|
||||
UUID.TryParse((string)requestData["agent_id"], out agentID);
|
||||
UUID.TryParse((string)requestData["region_secret"], out RegionSecret);
|
||||
|
||||
ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
|
||||
|
||||
Scene scene;
|
||||
if (TryGetRegion(regionHandle, out scene))
|
||||
{
|
||||
scene.HandleLogOffUserFromGrid(agentID, RegionSecret, message);
|
||||
}
|
||||
|
||||
return new XmlRpcResponse();
|
||||
}
|
||||
|
||||
protected bool TryGetRegion(ulong regionHandle, out Scene scene)
|
||||
{
|
||||
lock (m_scenes)
|
||||
{
|
||||
foreach (Scene nextScene in m_scenes)
|
||||
{
|
||||
if (nextScene.RegionInfo.RegionHandle == regionHandle)
|
||||
{
|
||||
scene = nextScene;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scene = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
305
OpenSim/Client/Linden/LLStandaloneLoginModule.cs
Normal file
305
OpenSim/Client/Linden/LLStandaloneLoginModule.cs
Normal file
@@ -0,0 +1,305 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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.Net;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications;
|
||||
using OpenSim.Framework.Communications.Cache;
|
||||
using OpenSim.Framework.Capabilities;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
|
||||
namespace OpenSim.Client.Linden
|
||||
{
|
||||
public class LLStandaloneLoginModule : ISharedRegionModule, ILoginServiceToRegionsConnector
|
||||
{
|
||||
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected List<Scene> m_scenes = new List<Scene>();
|
||||
protected Scene m_firstScene;
|
||||
|
||||
protected bool m_enabled = false; // Module is only enabled if running in standalone mode
|
||||
|
||||
protected bool authenticate;
|
||||
protected string welcomeMessage;
|
||||
|
||||
public bool RegionLoginsEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_firstScene != null)
|
||||
{
|
||||
return m_firstScene.SceneGridService.RegionLoginsEnabled;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected LLStandaloneLoginService m_loginService;
|
||||
|
||||
#region IRegionModule Members
|
||||
|
||||
public void Initialise(IConfigSource source)
|
||||
{
|
||||
IConfig startupConfig = source.Configs["Startup"];
|
||||
if (startupConfig != null)
|
||||
{
|
||||
m_enabled = !startupConfig.GetBoolean("gridmode", false);
|
||||
}
|
||||
|
||||
if (m_enabled)
|
||||
{
|
||||
authenticate = true;
|
||||
welcomeMessage = "Welcome to OpenSim";
|
||||
IConfig standaloneConfig = source.Configs["StandAlone"];
|
||||
if (standaloneConfig != null)
|
||||
{
|
||||
authenticate = standaloneConfig.GetBoolean("accounts_authenticate", true);
|
||||
welcomeMessage = standaloneConfig.GetString("welcome_message");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
{
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
if (m_enabled)
|
||||
{
|
||||
RemoveScene(scene);
|
||||
}
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
if (m_firstScene == null)
|
||||
{
|
||||
m_firstScene = scene;
|
||||
|
||||
if (m_enabled)
|
||||
{
|
||||
//TODO: fix casting.
|
||||
LibraryRootFolder rootFolder
|
||||
= m_firstScene.CommsManager.UserProfileCacheService.LibraryRoot as LibraryRootFolder;
|
||||
|
||||
IHttpServer httpServer = MainServer.Instance;
|
||||
|
||||
//TODO: fix the casting of the user service, maybe by registering the userManagerBase with scenes, or refactoring so we just need a IUserService reference
|
||||
m_loginService
|
||||
= new LLStandaloneLoginService(
|
||||
(UserManagerBase)m_firstScene.CommsManager.UserAdminService, welcomeMessage,
|
||||
m_firstScene.InventoryService, m_firstScene.CommsManager.NetworkServersInfo, authenticate,
|
||||
rootFolder, this);
|
||||
|
||||
httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod);
|
||||
|
||||
// provides the web form login
|
||||
httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin);
|
||||
|
||||
// Provides the LLSD login
|
||||
httpServer.SetDefaultLLSDHandler(m_loginService.LLSDLoginMethod);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_enabled)
|
||||
{
|
||||
AddScene(scene);
|
||||
}
|
||||
}
|
||||
|
||||
public Type ReplaceableInterface
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "LLStandaloneLoginModule"; }
|
||||
}
|
||||
|
||||
public bool IsSharedModule
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected void AddScene(Scene scene)
|
||||
{
|
||||
lock (m_scenes)
|
||||
{
|
||||
if (!m_scenes.Contains(scene))
|
||||
{
|
||||
m_scenes.Add(scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void RemoveScene(Scene scene)
|
||||
{
|
||||
lock (m_scenes)
|
||||
{
|
||||
if (m_scenes.Contains(scene))
|
||||
{
|
||||
m_scenes.Remove(scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent, out string reason)
|
||||
{
|
||||
Scene scene;
|
||||
if (TryGetRegion(regionHandle, out scene))
|
||||
{
|
||||
return scene.NewUserConnection(agent, out reason);
|
||||
}
|
||||
reason = "Region not found.";
|
||||
return false;
|
||||
}
|
||||
|
||||
public void LogOffUserFromGrid(ulong regionHandle, UUID AvatarID, UUID RegionSecret, string message)
|
||||
{
|
||||
Scene scene;
|
||||
if (TryGetRegion(regionHandle, out scene))
|
||||
{
|
||||
scene.HandleLogOffUserFromGrid(AvatarID, RegionSecret, message);
|
||||
}
|
||||
}
|
||||
|
||||
public RegionInfo RequestNeighbourInfo(ulong regionhandle)
|
||||
{
|
||||
Scene scene;
|
||||
if (TryGetRegion(regionhandle, out scene))
|
||||
{
|
||||
return scene.RegionInfo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public RegionInfo RequestClosestRegion(string region)
|
||||
{
|
||||
Scene scene;
|
||||
if (TryGetRegion(region, out scene))
|
||||
{
|
||||
return scene.RegionInfo;
|
||||
}
|
||||
else if (m_scenes.Count > 0)
|
||||
{
|
||||
return m_scenes[0].RegionInfo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public RegionInfo RequestNeighbourInfo(UUID regionID)
|
||||
{
|
||||
Scene scene;
|
||||
if (TryGetRegion(regionID, out scene))
|
||||
{
|
||||
return scene.RegionInfo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected bool TryGetRegion(ulong regionHandle, out Scene scene)
|
||||
{
|
||||
lock (m_scenes)
|
||||
{
|
||||
foreach (Scene nextScene in m_scenes)
|
||||
{
|
||||
if (nextScene.RegionInfo.RegionHandle == regionHandle)
|
||||
{
|
||||
scene = nextScene;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scene = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected bool TryGetRegion(UUID regionID, out Scene scene)
|
||||
{
|
||||
lock (m_scenes)
|
||||
{
|
||||
foreach (Scene nextScene in m_scenes)
|
||||
{
|
||||
if (nextScene.RegionInfo.RegionID == regionID)
|
||||
{
|
||||
scene = nextScene;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scene = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected bool TryGetRegion(string regionName, out Scene scene)
|
||||
{
|
||||
lock (m_scenes)
|
||||
{
|
||||
foreach (Scene nextScene in m_scenes)
|
||||
{
|
||||
if (nextScene.RegionInfo.RegionName.Equals(regionName, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
scene = nextScene;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scene = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
244
OpenSim/Client/Linden/LLStandaloneLoginService.cs
Normal file
244
OpenSim/Client/Linden/LLStandaloneLoginService.cs
Normal file
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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.Net;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications;
|
||||
using OpenSim.Framework.Communications.Services;
|
||||
using OpenSim.Framework.Communications.Cache;
|
||||
using OpenSim.Framework.Capabilities;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
||||
namespace OpenSim.Client.Linden
|
||||
{
|
||||
public class LLStandaloneLoginService : LoginService
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected NetworkServersInfo m_serversInfo;
|
||||
protected bool m_authUsers = false;
|
||||
|
||||
/// <summary>
|
||||
/// Used to make requests to the local regions.
|
||||
/// </summary>
|
||||
protected ILoginServiceToRegionsConnector m_regionsConnector;
|
||||
|
||||
public LLStandaloneLoginService(
|
||||
UserManagerBase userManager, string welcomeMess,
|
||||
IInventoryService interServiceInventoryService,
|
||||
NetworkServersInfo serversInfo,
|
||||
bool authenticate, LibraryRootFolder libraryRootFolder, ILoginServiceToRegionsConnector regionsConnector)
|
||||
: base(userManager, libraryRootFolder, welcomeMess)
|
||||
{
|
||||
this.m_serversInfo = serversInfo;
|
||||
m_defaultHomeX = this.m_serversInfo.DefaultHomeLocX;
|
||||
m_defaultHomeY = this.m_serversInfo.DefaultHomeLocY;
|
||||
m_authUsers = authenticate;
|
||||
|
||||
m_InventoryService = interServiceInventoryService;
|
||||
m_regionsConnector = regionsConnector;
|
||||
// Standard behavior: In StandAlone, silent logout of last hung session
|
||||
m_warn_already_logged = false;
|
||||
}
|
||||
|
||||
public override UserProfileData GetTheUser(string firstname, string lastname)
|
||||
{
|
||||
UserProfileData profile = m_userManager.GetUserProfile(firstname, lastname);
|
||||
if (profile != null)
|
||||
{
|
||||
return profile;
|
||||
}
|
||||
|
||||
if (!m_authUsers)
|
||||
{
|
||||
//no current user account so make one
|
||||
m_log.Info("[LOGIN]: No user account found so creating a new one.");
|
||||
|
||||
m_userManager.AddUser(firstname, lastname, "test", "", m_defaultHomeX, m_defaultHomeY);
|
||||
|
||||
return m_userManager.GetUserProfile(firstname, lastname);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override bool AuthenticateUser(UserProfileData profile, string password)
|
||||
{
|
||||
if (!m_authUsers)
|
||||
{
|
||||
//for now we will accept any password in sandbox mode
|
||||
m_log.Info("[LOGIN]: Authorising user (no actual password check)");
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Info(
|
||||
"[LOGIN]: Authenticating " + profile.FirstName + " " + profile.SurName);
|
||||
|
||||
if (!password.StartsWith("$1$"))
|
||||
password = "$1$" + Util.Md5Hash(password);
|
||||
|
||||
password = password.Remove(0, 3); //remove $1$
|
||||
|
||||
string s = Util.Md5Hash(password + ":" + profile.PasswordSalt);
|
||||
|
||||
bool loginresult = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase)
|
||||
|| profile.PasswordHash.Equals(password, StringComparison.InvariantCulture));
|
||||
return loginresult;
|
||||
}
|
||||
}
|
||||
|
||||
protected override RegionInfo RequestClosestRegion(string region)
|
||||
{
|
||||
return m_regionsConnector.RequestClosestRegion(region);
|
||||
}
|
||||
|
||||
protected override RegionInfo GetRegionInfo(ulong homeRegionHandle)
|
||||
{
|
||||
return m_regionsConnector.RequestNeighbourInfo(homeRegionHandle);
|
||||
}
|
||||
|
||||
protected override RegionInfo GetRegionInfo(UUID homeRegionId)
|
||||
{
|
||||
return m_regionsConnector.RequestNeighbourInfo(homeRegionId);
|
||||
}
|
||||
|
||||
protected override bool PrepareLoginToRegion(
|
||||
RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint remoteClient)
|
||||
{
|
||||
IPEndPoint endPoint = regionInfo.ExternalEndPoint;
|
||||
response.SimAddress = endPoint.Address.ToString();
|
||||
response.SimPort = (uint)endPoint.Port;
|
||||
response.RegionX = regionInfo.RegionLocX;
|
||||
response.RegionY = regionInfo.RegionLocY;
|
||||
|
||||
string capsPath = CapsUtil.GetRandomCapsObjectPath();
|
||||
string capsSeedPath = CapsUtil.GetCapsSeedPath(capsPath);
|
||||
|
||||
// Don't use the following! It Fails for logging into any region not on the same port as the http server!
|
||||
// Kept here so it doesn't happen again!
|
||||
// response.SeedCapability = regionInfo.ServerURI + capsSeedPath;
|
||||
|
||||
string seedcap = "http://";
|
||||
|
||||
if (m_serversInfo.HttpUsesSSL)
|
||||
{
|
||||
// For NAT
|
||||
string host = NetworkUtil.GetHostFor(remoteClient.Address, m_serversInfo.HttpSSLCN);
|
||||
|
||||
seedcap = "https://" + host + ":" + m_serversInfo.httpSSLPort + capsSeedPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
// For NAT
|
||||
string host = NetworkUtil.GetHostFor(remoteClient.Address, regionInfo.ExternalHostName);
|
||||
|
||||
seedcap = "http://" + host + ":" + m_serversInfo.HttpListenerPort + capsSeedPath;
|
||||
}
|
||||
|
||||
response.SeedCapability = seedcap;
|
||||
|
||||
// Notify the target of an incoming user
|
||||
m_log.InfoFormat(
|
||||
"[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection",
|
||||
regionInfo.RegionName, response.RegionX, response.RegionY, regionInfo.ServerURI);
|
||||
|
||||
// Update agent with target sim
|
||||
user.CurrentAgent.Region = regionInfo.RegionID;
|
||||
user.CurrentAgent.Handle = regionInfo.RegionHandle;
|
||||
|
||||
AgentCircuitData agent = new AgentCircuitData();
|
||||
agent.AgentID = user.ID;
|
||||
agent.firstname = user.FirstName;
|
||||
agent.lastname = user.SurName;
|
||||
agent.SessionID = user.CurrentAgent.SessionID;
|
||||
agent.SecureSessionID = user.CurrentAgent.SecureSessionID;
|
||||
agent.circuitcode = Convert.ToUInt32(response.CircuitCode);
|
||||
agent.BaseFolder = UUID.Zero;
|
||||
agent.InventoryFolder = UUID.Zero;
|
||||
agent.startpos = user.CurrentAgent.Position;
|
||||
agent.CapsPath = capsPath;
|
||||
agent.Appearance = m_userManager.GetUserAppearance(user.ID);
|
||||
if (agent.Appearance == null)
|
||||
{
|
||||
m_log.WarnFormat(
|
||||
"[INTER]: Appearance not found for {0} {1}. Creating default.", agent.firstname, agent.lastname);
|
||||
agent.Appearance = new AvatarAppearance(agent.AgentID);
|
||||
}
|
||||
|
||||
if (m_regionsConnector.RegionLoginsEnabled)
|
||||
{
|
||||
string reason;
|
||||
bool success = m_regionsConnector.NewUserConnection(regionInfo.RegionHandle, agent, out reason);
|
||||
if (!success)
|
||||
{
|
||||
response.ErrorReason = "key";
|
||||
response.ErrorMessage = reason;
|
||||
}
|
||||
return success;
|
||||
// return m_regionsConnector.NewUserConnection(regionInfo.RegionHandle, agent, out reason);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void LogOffUser(UserProfileData theUser, string message)
|
||||
{
|
||||
RegionInfo SimInfo;
|
||||
try
|
||||
{
|
||||
SimInfo = this.m_regionsConnector.RequestNeighbourInfo(theUser.CurrentAgent.Handle);
|
||||
|
||||
if (SimInfo == null)
|
||||
{
|
||||
m_log.Error("[LOCAL LOGIN]: Region user was in isn't currently logged in");
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
m_log.Error("[LOCAL LOGIN]: Unable to look up region to log user off");
|
||||
return;
|
||||
}
|
||||
|
||||
m_regionsConnector.LogOffUserFromGrid(
|
||||
SimInfo.RegionHandle, theUser.ID, theUser.CurrentAgent.SecureSessionID, "Logging you off");
|
||||
}
|
||||
}
|
||||
}
|
||||
15
OpenSim/Client/Linden/Resources/LindenModules.addin.xml
Normal file
15
OpenSim/Client/Linden/Resources/LindenModules.addin.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<Addin id="OpenSim.Client.Linden.LindenModules" version="0.2">
|
||||
<Runtime>
|
||||
<Import assembly="OpenSim.Client.Linden.dll"/>
|
||||
</Runtime>
|
||||
|
||||
<Dependencies>
|
||||
<Addin id="OpenSim" version="0.5" />
|
||||
</Dependencies>
|
||||
|
||||
<Extension path = "/OpenSim/RegionModules">
|
||||
<RegionModule id="LLStandaloneLoginModule" type="OpenSim.Client.Linden.LLStandaloneLoginModule" />
|
||||
<RegionModule id="LLProxyLoginModule" type="OpenSim.Client.Linden.LLProxyLoginModule" />
|
||||
<RegionModule id="LLClientStackModule" type="OpenSim.Client.Linden.LLClientStackModule" />
|
||||
</Extension>
|
||||
</Addin>
|
||||
1659
OpenSim/Client/MXP/ClientStack/MXPClientView.cs
Normal file
1659
OpenSim/Client/MXP/ClientStack/MXPClientView.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -26,103 +26,106 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Timers;
|
||||
using log4net;
|
||||
using MXP;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Client.MXP.PacketHandler;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Server.Handlers.Base;
|
||||
using OpenSim.Server.Handlers.Login;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
|
||||
namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Login
|
||||
namespace OpenSim.Client.MXP
|
||||
{
|
||||
public class LLLoginServiceInConnectorModule : ISharedRegionModule
|
||||
|
||||
/**
|
||||
* MXP Client Module which adds MXP support to client / region communication.
|
||||
*/
|
||||
public class MXPModule : IRegionModule
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static bool m_Enabled = false;
|
||||
private static bool m_Registered = false;
|
||||
|
||||
private IConfigSource m_Config;
|
||||
private List<Scene> m_Scenes = new List<Scene>();
|
||||
private MXPPacketServer m_server;
|
||||
|
||||
#region IRegionModule interface
|
||||
private IConfigSource m_config;
|
||||
private int m_port = 1253;
|
||||
private Timer m_ticker;
|
||||
|
||||
public void Initialise(IConfigSource config)
|
||||
private readonly Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
|
||||
private bool m_shutdown;
|
||||
|
||||
public void Initialise(Scene scene, IConfigSource source)
|
||||
{
|
||||
m_Config = config;
|
||||
|
||||
IConfig moduleConfig = config.Configs["Modules"];
|
||||
if (moduleConfig != null)
|
||||
{
|
||||
m_Enabled = moduleConfig.GetBoolean("LLLoginServiceInConnector", false);
|
||||
if (m_Enabled)
|
||||
{
|
||||
m_log.Info("[LLLOGIN IN CONNECTOR]: LLLoginerviceInConnector enabled");
|
||||
}
|
||||
|
||||
}
|
||||
if (!m_scenes.ContainsKey(scene.RegionInfo.RegionID))
|
||||
m_scenes.Add(scene.RegionInfo.RegionID, scene);
|
||||
|
||||
m_config = source;
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
if (m_config.Configs["MXP"] != null)
|
||||
{
|
||||
IConfig con = m_config.Configs["MXP"];
|
||||
|
||||
m_log.Info("[LLLOGIN IN CONNECTOR]: Starting...");
|
||||
if (!con.GetBoolean("Enabled", false))
|
||||
return;
|
||||
|
||||
m_port = con.GetInt("Port", m_port);
|
||||
|
||||
m_server = new MXPPacketServer(m_port, m_scenes,m_config.Configs["StandAlone"].GetBoolean("accounts_authenticate",true));
|
||||
|
||||
m_ticker = new Timer(100);
|
||||
m_ticker.AutoReset = false;
|
||||
m_ticker.Elapsed += ticker_Elapsed;
|
||||
|
||||
lock (m_ticker)
|
||||
m_ticker.Start();
|
||||
|
||||
m_log.Info("[MXP ClientStack] MXP Enabled and Listening");
|
||||
}
|
||||
}
|
||||
|
||||
void ticker_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_server.Process();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
m_log.Error("[MXP ClientStack]: Unhandled exception in process loop: " + ex.ToString() + " :" + ex.StackTrace.ToString());
|
||||
}
|
||||
|
||||
if (!m_shutdown)
|
||||
{
|
||||
lock (m_ticker)
|
||||
m_ticker.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
}
|
||||
|
||||
public Type ReplaceableInterface
|
||||
{
|
||||
get { return null; }
|
||||
m_shutdown = true;
|
||||
if (m_ticker != null)
|
||||
{
|
||||
lock (m_ticker)
|
||||
m_ticker.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "LLLoginServiceInConnectorModule"; }
|
||||
get { return "MXP ClientStack Module"; }
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
public bool IsSharedModule
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
|
||||
m_Scenes.Add(scene);
|
||||
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
if (m_Enabled && m_Scenes.Contains(scene))
|
||||
m_Scenes.Remove(scene);
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
|
||||
if (!m_Registered)
|
||||
{
|
||||
m_Registered = true;
|
||||
new LLLoginServiceInConnector(m_Config, MainServer.Instance, scene);
|
||||
//Object[] args = new Object[] { m_Config, MainServer.Instance, this, scene };
|
||||
//ServerUtils.LoadPlugin<IServiceConnector>("OpenSim.Server.Handlers.dll:LLLoginServiceInConnector", args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -25,25 +25,18 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using pCampBot.Interfaces;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace pCampBot
|
||||
namespace OpenSim.Client.MXP
|
||||
{
|
||||
public class AbstractBehaviour : IBehaviour
|
||||
public static class MXPUtil
|
||||
{
|
||||
public string Name { get; protected set; }
|
||||
|
||||
public Bot Bot { get; protected set; }
|
||||
|
||||
public virtual void Action() {}
|
||||
|
||||
public virtual void Initialize(Bot bot)
|
||||
public static string GenerateMXPURL(string server, int port, UUID bubbleID, Vector3 location)
|
||||
{
|
||||
Bot = bot;
|
||||
return string.Format("mxp://{0}:{1}/{2}/{3}", server, port, bubbleID.Guid, location);
|
||||
}
|
||||
}
|
||||
}
|
||||
629
OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
Normal file
629
OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
Normal file
@@ -0,0 +1,629 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
/* This file borrows heavily from MXPServer.cs - the reference MXPServer
|
||||
* See http://www.bubblecloud.org for a copy of the original file and
|
||||
* implementation details. */
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using MXP;
|
||||
using MXP.Messages;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Client.MXP.ClientStack;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Framework.Communications;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace OpenSim.Client.MXP.PacketHandler
|
||||
{
|
||||
public class MXPPacketServer
|
||||
{
|
||||
internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
#region Fields
|
||||
|
||||
private readonly List<MXPClientView> m_clients = new List<MXPClientView>();
|
||||
private readonly Dictionary<UUID, Scene> m_scenes;
|
||||
private readonly Transmitter m_transmitter;
|
||||
|
||||
private readonly Thread m_clientThread;
|
||||
|
||||
private readonly IList<Session> m_sessions = new List<Session>();
|
||||
private readonly IList<Session> m_sessionsToClient = new List<Session>();
|
||||
private readonly IList<MXPClientView> m_sessionsToRemove = new List<MXPClientView>();
|
||||
|
||||
private readonly int m_port;
|
||||
private readonly bool m_accountsAuthenticate;
|
||||
|
||||
private readonly String m_programName;
|
||||
private readonly byte m_programMajorVersion;
|
||||
private readonly byte m_programMinorVersion;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public MXPPacketServer(int port, Dictionary<UUID, Scene> scenes, bool accountsAuthenticate)
|
||||
{
|
||||
m_port = port;
|
||||
m_accountsAuthenticate = accountsAuthenticate;
|
||||
|
||||
m_scenes = scenes;
|
||||
|
||||
m_programMinorVersion = 63;
|
||||
m_programMajorVersion = 0;
|
||||
m_programName = "OpenSimulator";
|
||||
|
||||
m_transmitter = new Transmitter(port);
|
||||
|
||||
StartListener();
|
||||
}
|
||||
|
||||
public void StartListener()
|
||||
{
|
||||
m_log.Info("[MXP ClientStack] Transmitter starting on UDP server port: " + m_port);
|
||||
m_transmitter.Startup();
|
||||
m_log.Info("[MXP ClientStack] Transmitter started. MXP version: "+MxpConstants.ProtocolMajorVersion+"."+MxpConstants.ProtocolMinorVersion+" Source Revision: "+MxpConstants.ProtocolSourceRevision);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Number of sessions pending. (Process() accepts pending sessions).
|
||||
/// </summary>
|
||||
public int PendingSessionCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_transmitter.PendingSessionCount;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Number of connected sessions.
|
||||
/// </summary>
|
||||
public int SessionCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_sessions.Count;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Property reflecting whether client transmitter threads are alive.
|
||||
/// </summary>
|
||||
public bool IsTransmitterAlive
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_transmitter != null && m_transmitter.IsAlive;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Number of packets sent.
|
||||
/// </summary>
|
||||
public ulong PacketsSent
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_transmitter != null ? m_transmitter.PacketsSent : 0;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Number of packets received.
|
||||
/// </summary>
|
||||
public ulong PacketsReceived
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_transmitter != null ? m_transmitter.PacketsReceived : 0;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Bytes client has received so far.
|
||||
/// </summary>
|
||||
public ulong BytesReceived
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_transmitter != null ? m_transmitter.BytesReceived : 0;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Bytes client has sent so far.
|
||||
/// </summary>
|
||||
public ulong BytesSent
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_transmitter != null ? m_transmitter.BytesSent : 0;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Number of bytes received (bytes per second) during past second.
|
||||
/// </summary>
|
||||
public double ReceiveRate
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_transmitter != null ? m_transmitter.ReceiveRate : 0;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Number of bytes sent (bytes per second) during past second.
|
||||
/// </summary>
|
||||
public double SendRate
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_transmitter != null ? m_transmitter.SendRate : 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Session Management
|
||||
|
||||
public void Disconnect(Session session)
|
||||
{
|
||||
if (session.IsConnected)
|
||||
{
|
||||
Message message = MessageFactory.Current.ReserveMessage(typeof(LeaveRequestMessage));
|
||||
session.Send(message);
|
||||
MessageFactory.Current.ReleaseMessage(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Not connected.");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Processing
|
||||
|
||||
public void Process()
|
||||
{
|
||||
ProcessMessages();
|
||||
Clean();
|
||||
}
|
||||
|
||||
public void Clean()
|
||||
{
|
||||
foreach (MXPClientView clientView in m_clients)
|
||||
{
|
||||
if (clientView.Session.SessionState == SessionState.Disconnected)
|
||||
{
|
||||
m_sessionsToRemove.Add(clientView);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (MXPClientView clientView in m_sessionsToRemove)
|
||||
{
|
||||
clientView.Scene.RemoveClient(clientView.AgentId);
|
||||
clientView.OnClean();
|
||||
m_clients.Remove(clientView);
|
||||
m_sessions.Remove(clientView.Session);
|
||||
}
|
||||
|
||||
m_sessionsToRemove.Clear();
|
||||
}
|
||||
|
||||
public void ProcessMessages()
|
||||
{
|
||||
if (m_transmitter.PendingSessionCount > 0)
|
||||
{
|
||||
Session tmp = m_transmitter.AcceptPendingSession();
|
||||
m_sessions.Add(tmp);
|
||||
m_sessionsToClient.Add(tmp);
|
||||
|
||||
}
|
||||
|
||||
List<Session> tmpRemove = new List<Session>();
|
||||
|
||||
foreach (Session session in m_sessionsToClient)
|
||||
{
|
||||
while (session.AvailableMessages > 0)
|
||||
{
|
||||
Message message = session.Receive();
|
||||
|
||||
if (message.GetType() == typeof (JoinRequestMessage))
|
||||
{
|
||||
|
||||
JoinRequestMessage joinRequestMessage = (JoinRequestMessage) message;
|
||||
|
||||
m_log.Info("[MXP ClientStack]: Session join request: " + session.SessionId + " (" +
|
||||
(session.IsIncoming ? "from" : "to") + " " + session.RemoteEndPoint.Address + ":" +
|
||||
session.RemoteEndPoint.Port + ")");
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if (joinRequestMessage.BubbleId == Guid.Empty)
|
||||
{
|
||||
foreach (Scene scene in m_scenes.Values)
|
||||
{
|
||||
if (scene.RegionInfo.RegionName == joinRequestMessage.BubbleName)
|
||||
{
|
||||
m_log.Info("[MXP ClientStack]: Resolved region by name: " + joinRequestMessage.BubbleName + " (" + scene.RegionInfo.RegionID + ")");
|
||||
joinRequestMessage.BubbleId = scene.RegionInfo.RegionID.Guid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (joinRequestMessage.BubbleId == Guid.Empty)
|
||||
{
|
||||
m_log.Warn("[MXP ClientStack]: Failed to resolve region by name: " + joinRequestMessage.BubbleName);
|
||||
}
|
||||
|
||||
UUID sceneId = new UUID(joinRequestMessage.BubbleId);
|
||||
|
||||
bool regionExists = true;
|
||||
if (!m_scenes.ContainsKey(sceneId))
|
||||
{
|
||||
m_log.Info("[MXP ClientStack]: No such region: " + sceneId);
|
||||
regionExists = false;
|
||||
}
|
||||
|
||||
UserProfileData user = null;
|
||||
UUID userId = UUID.Zero;
|
||||
string firstName = null;
|
||||
string lastName = null;
|
||||
bool authorized = regionExists ? AuthoriseUser(joinRequestMessage.ParticipantName,
|
||||
joinRequestMessage.ParticipantPassphrase,
|
||||
new UUID(joinRequestMessage.BubbleId), out userId, out firstName, out lastName, out user)
|
||||
: false;
|
||||
|
||||
if (authorized)
|
||||
{
|
||||
Scene scene = m_scenes[sceneId];
|
||||
UUID mxpSessionID = UUID.Random();
|
||||
|
||||
string reason;
|
||||
|
||||
m_log.Debug("[MXP ClientStack]: Session join request success: " + session.SessionId + " (" +
|
||||
(session.IsIncoming ? "from" : "to") + " " + session.RemoteEndPoint.Address + ":" +
|
||||
session.RemoteEndPoint.Port + ")");
|
||||
|
||||
m_log.Debug("[MXP ClientStack]: Attaching UserAgent to UserProfile...");
|
||||
AttachUserAgentToUserProfile(session, mxpSessionID, sceneId, user);
|
||||
m_log.Debug("[MXP ClientStack]: Attached UserAgent to UserProfile.");
|
||||
m_log.Debug("[MXP ClientStack]: Preparing Scene to Connection...");
|
||||
if (!PrepareSceneForConnection(mxpSessionID, sceneId, user, out reason))
|
||||
{
|
||||
m_log.DebugFormat("[MXP ClientStack]: Scene refused connection: {0}", reason);
|
||||
DeclineConnection(session, joinRequestMessage);
|
||||
tmpRemove.Add(session);
|
||||
continue;
|
||||
}
|
||||
m_log.Debug("[MXP ClientStack]: Prepared Scene to Connection.");
|
||||
m_log.Debug("[MXP ClientStack]: Accepting connection...");
|
||||
AcceptConnection(session, joinRequestMessage, mxpSessionID, userId);
|
||||
m_log.Info("[MXP ClientStack]: Accepted connection.");
|
||||
|
||||
m_log.Debug("[MXP ClientStack]: Creating ClientView....");
|
||||
MXPClientView client = new MXPClientView(session, mxpSessionID, userId, scene, firstName, lastName);
|
||||
m_clients.Add(client);
|
||||
m_log.Debug("[MXP ClientStack]: Created ClientView.");
|
||||
|
||||
client.MXPSendSynchronizationBegin(m_scenes[new UUID(joinRequestMessage.BubbleId)].SceneContents.GetTotalObjectsCount());
|
||||
|
||||
m_log.Debug("[MXP ClientStack]: Starting ClientView...");
|
||||
try
|
||||
{
|
||||
client.Start();
|
||||
m_log.Debug("[MXP ClientStack]: Started ClientView.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(e);
|
||||
}
|
||||
|
||||
m_log.Debug("[MXP ClientStack]: Connected");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Info("[MXP ClientStack]: Session join request failure: " + session.SessionId + " (" +
|
||||
(session.IsIncoming ? "from" : "to") + " " + session.RemoteEndPoint.Address + ":" +
|
||||
session.RemoteEndPoint.Port + ")");
|
||||
|
||||
DeclineConnection(session, joinRequestMessage);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[MXP ClientStack]: Session join request failure: " + session.SessionId + " (" +
|
||||
(session.IsIncoming ? "from" : "to") + " " + session.RemoteEndPoint.Address + ":" +
|
||||
session.RemoteEndPoint.Port + "): "+e.ToString()+" :"+e.StackTrace.ToString());
|
||||
}
|
||||
tmpRemove.Add(session);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Session session in tmpRemove)
|
||||
{
|
||||
m_sessionsToClient.Remove(session);
|
||||
}
|
||||
|
||||
foreach (MXPClientView clientView in m_clients)
|
||||
{
|
||||
int messagesProcessedCount = 0;
|
||||
Session session = clientView.Session;
|
||||
|
||||
while (session.AvailableMessages > 0)
|
||||
{
|
||||
Message message = session.Receive();
|
||||
|
||||
if (message.GetType() == typeof(LeaveRequestMessage))
|
||||
{
|
||||
LeaveResponseMessage leaveResponseMessage = (LeaveResponseMessage)MessageFactory.Current.ReserveMessage(
|
||||
typeof(LeaveResponseMessage));
|
||||
|
||||
m_log.Debug("[MXP ClientStack]: Session leave request: " + session.SessionId + " (" + (session.IsIncoming ? "from" : "to") + " " + session.RemoteEndPoint.Address + ":" + session.RemoteEndPoint.Port + ")");
|
||||
|
||||
leaveResponseMessage.RequestMessageId = message.MessageId;
|
||||
leaveResponseMessage.FailureCode = 0;
|
||||
session.Send(leaveResponseMessage);
|
||||
|
||||
if (session.SessionState != SessionState.Disconnected)
|
||||
{
|
||||
session.SetStateDisconnected();
|
||||
}
|
||||
|
||||
m_log.Debug("[MXP ClientStack]: Removing Client from Scene");
|
||||
//clientView.Scene.RemoveClient(clientView.AgentId);
|
||||
}
|
||||
if (message.GetType() == typeof(LeaveResponseMessage))
|
||||
{
|
||||
LeaveResponseMessage leaveResponseMessage = (LeaveResponseMessage)message;
|
||||
|
||||
m_log.Debug("[MXP ClientStack]: Session leave response: " + session.SessionId + " (" + (session.IsIncoming ? "from" : "to") + " " + session.RemoteEndPoint.Address + ":" + session.RemoteEndPoint.Port + ")");
|
||||
|
||||
if (leaveResponseMessage.FailureCode == 0)
|
||||
{
|
||||
session.SetStateDisconnected();
|
||||
}
|
||||
|
||||
m_log.Debug("[MXP ClientStack]: Removing Client from Scene");
|
||||
//clientView.Scene.RemoveClient(clientView.AgentId);
|
||||
}
|
||||
else
|
||||
{
|
||||
clientView.MXPPRocessMessage(message);
|
||||
}
|
||||
|
||||
MessageFactory.Current.ReleaseMessage(message);
|
||||
messagesProcessedCount++;
|
||||
if (messagesProcessedCount > 1000)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AcceptConnection(Session session, JoinRequestMessage joinRequestMessage, UUID mxpSessionID, UUID userId)
|
||||
{
|
||||
JoinResponseMessage joinResponseMessage = (JoinResponseMessage)MessageFactory.Current.ReserveMessage(
|
||||
typeof(JoinResponseMessage));
|
||||
|
||||
joinResponseMessage.RequestMessageId = joinRequestMessage.MessageId;
|
||||
joinResponseMessage.FailureCode = MxpResponseCodes.SUCCESS;
|
||||
|
||||
joinResponseMessage.BubbleId = joinRequestMessage.BubbleId;
|
||||
joinResponseMessage.ParticipantId = userId.Guid;
|
||||
joinResponseMessage.AvatarId = userId.Guid;
|
||||
joinResponseMessage.BubbleAssetCacheUrl = "http://" +
|
||||
NetworkUtil.GetHostFor(session.RemoteEndPoint.Address,
|
||||
m_scenes[
|
||||
new UUID(joinRequestMessage.BubbleId)].
|
||||
RegionInfo.
|
||||
ExternalHostName) + ":" +
|
||||
m_scenes[new UUID(joinRequestMessage.BubbleId)].RegionInfo.
|
||||
HttpPort + "/assets/";
|
||||
|
||||
joinResponseMessage.BubbleName = m_scenes[new UUID(joinRequestMessage.BubbleId)].RegionInfo.RegionName;
|
||||
|
||||
joinResponseMessage.BubbleRange = 128;
|
||||
joinResponseMessage.BubblePerceptionRange = 128 + 256;
|
||||
joinResponseMessage.BubbleRealTime = 0;
|
||||
joinResponseMessage.ProgramName = m_programName;
|
||||
joinResponseMessage.ProgramMajorVersion = m_programMajorVersion;
|
||||
joinResponseMessage.ProgramMinorVersion = m_programMinorVersion;
|
||||
joinResponseMessage.ProtocolMajorVersion = MxpConstants.ProtocolMajorVersion;
|
||||
joinResponseMessage.ProtocolMinorVersion = MxpConstants.ProtocolMinorVersion;
|
||||
joinResponseMessage.ProtocolSourceRevision = MxpConstants.ProtocolSourceRevision;
|
||||
|
||||
session.Send(joinResponseMessage);
|
||||
|
||||
session.SetStateConnected();
|
||||
}
|
||||
|
||||
private void DeclineConnection(Session session, Message joinRequestMessage)
|
||||
{
|
||||
JoinResponseMessage joinResponseMessage = (JoinResponseMessage)MessageFactory.Current.ReserveMessage(typeof(JoinResponseMessage));
|
||||
|
||||
joinResponseMessage.RequestMessageId = joinRequestMessage.MessageId;
|
||||
joinResponseMessage.FailureCode = MxpResponseCodes.UNAUTHORIZED_OPERATION;
|
||||
|
||||
joinResponseMessage.ProgramName = m_programName;
|
||||
joinResponseMessage.ProgramMajorVersion = m_programMajorVersion;
|
||||
joinResponseMessage.ProgramMinorVersion = m_programMinorVersion;
|
||||
joinResponseMessage.ProtocolMajorVersion = MxpConstants.ProtocolMajorVersion;
|
||||
joinResponseMessage.ProtocolMinorVersion = MxpConstants.ProtocolMinorVersion;
|
||||
joinResponseMessage.ProtocolSourceRevision = MxpConstants.ProtocolSourceRevision;
|
||||
|
||||
session.Send(joinResponseMessage);
|
||||
|
||||
session.SetStateDisconnected();
|
||||
}
|
||||
|
||||
public bool AuthoriseUser(string participantName, string password, UUID sceneId, out UUID userId, out string firstName, out string lastName, out UserProfileData userProfile)
|
||||
{
|
||||
userId = UUID.Zero;
|
||||
firstName = "";
|
||||
lastName = "";
|
||||
userProfile = null;
|
||||
|
||||
string[] nameParts = participantName.Split(' ');
|
||||
if (nameParts.Length != 2)
|
||||
{
|
||||
m_log.Error("[MXP ClientStack]: Login failed as user name is not formed of first and last name separated by space: " + participantName);
|
||||
return false;
|
||||
}
|
||||
firstName = nameParts[0];
|
||||
lastName = nameParts[1];
|
||||
|
||||
userProfile = m_scenes[sceneId].CommsManager.UserService.GetUserProfile(firstName, lastName);
|
||||
|
||||
if (userProfile == null && !m_accountsAuthenticate)
|
||||
{
|
||||
userId = ((UserManagerBase)m_scenes[sceneId].CommsManager.UserService).AddUser(firstName, lastName, "test", "", 1000, 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (userProfile == null)
|
||||
{
|
||||
m_log.Error("[MXP ClientStack]: Login failed as user was not found: " + participantName);
|
||||
return false;
|
||||
}
|
||||
userId = userProfile.ID;
|
||||
}
|
||||
|
||||
if (m_accountsAuthenticate)
|
||||
{
|
||||
if (!password.StartsWith("$1$"))
|
||||
{
|
||||
password = "$1$" + Util.Md5Hash(password);
|
||||
}
|
||||
password = password.Remove(0, 3); //remove $1$
|
||||
string s = Util.Md5Hash(password + ":" + userProfile.PasswordSalt);
|
||||
return (userProfile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase)
|
||||
|| userProfile.PasswordHash.Equals(password, StringComparison.InvariantCulture));
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void AttachUserAgentToUserProfile(Session session, UUID sessionId, UUID sceneId, UserProfileData userProfile)
|
||||
{
|
||||
//Scene scene = m_scenes[sceneId];
|
||||
CommunicationsManager commsManager = m_scenes[sceneId].CommsManager;
|
||||
IUserService userService = (IUserService)commsManager.UserService;
|
||||
|
||||
UserAgentData agent = new UserAgentData();
|
||||
|
||||
// User connection
|
||||
agent.AgentOnline = true;
|
||||
agent.AgentIP = session.RemoteEndPoint.Address.ToString();
|
||||
agent.AgentPort = (uint)session.RemoteEndPoint.Port;
|
||||
|
||||
agent.SecureSessionID = UUID.Random();
|
||||
agent.SessionID = sessionId;
|
||||
|
||||
// Profile UUID
|
||||
agent.ProfileID = userProfile.ID;
|
||||
|
||||
// Current location/position/alignment
|
||||
if (userProfile.CurrentAgent != null)
|
||||
{
|
||||
agent.Region = userProfile.CurrentAgent.Region;
|
||||
agent.Handle = userProfile.CurrentAgent.Handle;
|
||||
agent.Position = userProfile.CurrentAgent.Position;
|
||||
agent.LookAt = userProfile.CurrentAgent.LookAt;
|
||||
}
|
||||
else
|
||||
{
|
||||
agent.Region = userProfile.HomeRegionID;
|
||||
agent.Handle = userProfile.HomeRegion;
|
||||
agent.Position = userProfile.HomeLocation;
|
||||
agent.LookAt = userProfile.HomeLookAt;
|
||||
}
|
||||
|
||||
// What time did the user login?
|
||||
agent.LoginTime = Util.UnixTimeSinceEpoch();
|
||||
agent.LogoutTime = 0;
|
||||
|
||||
userProfile.CurrentAgent = agent;
|
||||
|
||||
|
||||
userService.UpdateUserProfile(userProfile);
|
||||
//userService.CommitAgent(ref userProfile);
|
||||
}
|
||||
|
||||
private bool PrepareSceneForConnection(UUID sessionId, UUID sceneId, UserProfileData userProfile, out string reason)
|
||||
{
|
||||
Scene scene = m_scenes[sceneId];
|
||||
CommunicationsManager commsManager = m_scenes[sceneId].CommsManager;
|
||||
UserManagerBase userService = (UserManagerBase)commsManager.UserService;
|
||||
|
||||
AgentCircuitData agent = new AgentCircuitData();
|
||||
agent.AgentID = userProfile.ID;
|
||||
agent.firstname = userProfile.FirstName;
|
||||
agent.lastname = userProfile.SurName;
|
||||
agent.SessionID = sessionId;
|
||||
agent.SecureSessionID = userProfile.CurrentAgent.SecureSessionID;
|
||||
agent.circuitcode = sessionId.CRC();
|
||||
agent.BaseFolder = UUID.Zero;
|
||||
agent.InventoryFolder = UUID.Zero;
|
||||
agent.startpos = new Vector3(0, 0, 0); // TODO Fill in region start position
|
||||
agent.CapsPath = "http://localhost/";
|
||||
agent.Appearance = userService.GetUserAppearance(userProfile.ID);
|
||||
|
||||
if (agent.Appearance == null)
|
||||
{
|
||||
m_log.WarnFormat("[INTER]: Appearance not found for {0} {1}. Creating default.", agent.firstname, agent.lastname);
|
||||
agent.Appearance = new AvatarAppearance();
|
||||
}
|
||||
|
||||
return scene.NewUserConnection(agent, out reason);
|
||||
}
|
||||
|
||||
public void PrintDebugInformation()
|
||||
{
|
||||
m_log.Info("[MXP ClientStack]: Statistics report");
|
||||
m_log.Info("Pending Sessions: " + PendingSessionCount);
|
||||
m_log.Info("Sessions: " + SessionCount + " (Clients: " + m_clients.Count + " )");
|
||||
m_log.Info("Transmitter Alive?: " + IsTransmitterAlive);
|
||||
m_log.Info("Packets Sent/Received: " + PacketsSent + " / " + PacketsReceived);
|
||||
m_log.Info("Bytes Sent/Received: " + BytesSent + " / " + BytesReceived);
|
||||
m_log.Info("Send/Receive Rate (bps): " + SendRate + " / " + ReceiveRate);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
1165
OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs
Normal file
1165
OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs
Normal file
File diff suppressed because it is too large
Load Diff
133
OpenSim/Client/VWoHTTP/VWoHTTPModule.cs
Normal file
133
OpenSim/Client/VWoHTTP/VWoHTTPModule.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Client.VWoHTTP.ClientStack;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Client.VWoHTTP
|
||||
{
|
||||
class VWoHTTPModule : IRegionModule, IHttpAgentHandler
|
||||
{
|
||||
private bool m_disabled = true;
|
||||
|
||||
private IHttpServer m_httpd;
|
||||
|
||||
private readonly List<Scene> m_scenes = new List<Scene>();
|
||||
|
||||
private Dictionary<UUID, VWHClientView> m_clients = new Dictionary<UUID, VWHClientView>();
|
||||
|
||||
#region Implementation of IRegionModule
|
||||
|
||||
public void Initialise(Scene scene, IConfigSource source)
|
||||
{
|
||||
if (m_disabled)
|
||||
return;
|
||||
|
||||
m_scenes.Add(scene);
|
||||
|
||||
m_httpd = MainServer.Instance;
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
if (m_disabled)
|
||||
return;
|
||||
|
||||
m_httpd.AddAgentHandler("vwohttp", this);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
if (m_disabled)
|
||||
return;
|
||||
|
||||
m_httpd.RemoveAgentHandler("vwohttp", this);
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "VWoHTTP ClientStack"; }
|
||||
}
|
||||
|
||||
public bool IsSharedModule
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Implementation of IHttpAgentHandler
|
||||
|
||||
public bool Handle(OSHttpRequest req, OSHttpResponse resp)
|
||||
{
|
||||
string[] urlparts = req.Url.AbsolutePath.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (urlparts.Length < 2)
|
||||
return false;
|
||||
|
||||
if (urlparts[1] == "connect")
|
||||
{
|
||||
UUID sessID = UUID.Random();
|
||||
|
||||
VWHClientView client = new VWHClientView(sessID, UUID.Random(), "VWoHTTPClient", m_scenes[0]);
|
||||
|
||||
m_clients.Add(sessID, client);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (urlparts.Length < 3)
|
||||
return false;
|
||||
|
||||
UUID sessionID;
|
||||
if (!UUID.TryParse(urlparts[1], out sessionID))
|
||||
return false;
|
||||
|
||||
if (!m_clients.ContainsKey(sessionID))
|
||||
return false;
|
||||
|
||||
return m_clients[sessionID].ProcessInMsg(req, resp);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Match(OSHttpRequest req, OSHttpResponse resp)
|
||||
{
|
||||
return req.Url.ToString().Contains("vwohttp");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -29,11 +29,9 @@ using Nini.Config;
|
||||
using log4net;
|
||||
using System.Reflection;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Collections.Generic;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenMetaverse;
|
||||
|
||||
@@ -75,34 +73,16 @@ namespace OpenSim.ConsoleClient
|
||||
|
||||
Requester.MakeRequest("http://"+m_Host+":"+m_Port.ToString()+"/StartSession/", String.Format("USER={0}&PASS={1}", m_User, m_Pass), LoginReply);
|
||||
|
||||
string pidFile = serverConfig.GetString("PIDFile", String.Empty);
|
||||
int res = m_Server.Run();
|
||||
|
||||
while (m_Server.Running)
|
||||
{
|
||||
System.Threading.Thread.Sleep(500);
|
||||
// MainConsole.Instance.Prompt();
|
||||
}
|
||||
|
||||
if (pidFile != String.Empty)
|
||||
File.Delete(pidFile);
|
||||
|
||||
Environment.Exit(0);
|
||||
Environment.Exit(res);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static void SendCommand(string module, string[] cmd)
|
||||
{
|
||||
string sendCmd = "";
|
||||
string[] cmdlist = new string[cmd.Length - 1];
|
||||
|
||||
sendCmd = cmd[0];
|
||||
|
||||
if (cmd.Length > 1)
|
||||
{
|
||||
Array.Copy(cmd, 1, cmdlist, 0, cmd.Length - 1);
|
||||
sendCmd += " \"" + String.Join("\" \"", cmdlist) + "\"";
|
||||
}
|
||||
string sendCmd = String.Join(" ", cmd);
|
||||
|
||||
Requester.MakeRequest("http://"+m_Host+":"+m_Port.ToString()+"/SessionCommand/", String.Format("ID={0}&COMMAND={1}", m_SessionID, sendCmd), CommandReply);
|
||||
}
|
||||
@@ -195,27 +175,16 @@ namespace OpenSim.ConsoleClient
|
||||
while (lines.Count > 100)
|
||||
lines.RemoveAt(0);
|
||||
|
||||
string prompt = String.Empty;
|
||||
|
||||
foreach (string l in lines)
|
||||
{
|
||||
string[] parts = l.Split(new char[] {':'}, 3);
|
||||
if (parts.Length != 3)
|
||||
continue;
|
||||
|
||||
if (parts[2].StartsWith("+++") || parts[2].StartsWith("-++"))
|
||||
prompt = parts[2];
|
||||
else
|
||||
MainConsole.Instance.Output(parts[2].Trim(), parts[1]);
|
||||
MainConsole.Instance.Output(parts[2].Trim(), parts[1]);
|
||||
}
|
||||
|
||||
|
||||
Requester.MakeRequest(requestUrl, requestData, ReadResponses);
|
||||
|
||||
if (prompt.StartsWith("+++"))
|
||||
MainConsole.Instance.ReadLine(prompt.Substring(3), true, true);
|
||||
else if (prompt.StartsWith("-++"))
|
||||
SendCommand(String.Empty, new string[] { MainConsole.Instance.ReadLine(prompt.Substring(3), false, true) });
|
||||
}
|
||||
|
||||
public static void CommandReply(string requestUrl, string requestData, string replyData)
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace OpenSim.ConsoleClient
|
||||
|
||||
request.ContentType = "application/x-www-form-urlencoded";
|
||||
|
||||
byte[] buffer = Encoding.ASCII.GetBytes(data);
|
||||
byte[] buffer = new System.Text.ASCIIEncoding().GetBytes(data);
|
||||
int length = (int) buffer.Length;
|
||||
request.ContentLength = length;
|
||||
|
||||
|
||||
@@ -48,6 +48,5 @@ namespace OpenSim.Data
|
||||
public abstract void Initialise(string connect);
|
||||
public abstract void Initialise();
|
||||
public abstract void Dispose();
|
||||
public abstract bool Delete(string id);
|
||||
}
|
||||
}
|
||||
|
||||
155
OpenSim/Data/DataPluginFactory.cs
Normal file
155
OpenSim/Data/DataPluginFactory.cs
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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.Framework;
|
||||
|
||||
namespace OpenSim.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// A static class containing methods for obtaining handles to database
|
||||
/// storage objects.
|
||||
/// </summary>
|
||||
public static class DataPluginFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Based on <typeparam name="T" />, returns the appropriate
|
||||
/// PluginInitialiserBase instance in <paramref name="init" /> and
|
||||
/// extension point path in <paramref name="path" />.
|
||||
/// </summary>
|
||||
/// <param name="connect">
|
||||
/// The DB connection string used when creating a new
|
||||
/// PluginInitialiserBase, returned in <paramref name="init" />.
|
||||
/// </param>
|
||||
/// <param name="init">
|
||||
/// A reference to a PluginInitialiserBase object in which the proper
|
||||
/// initialiser will be returned.
|
||||
/// </param>
|
||||
/// <param name="path">
|
||||
/// A string in which the proper extension point path will be returned.
|
||||
/// </param>
|
||||
/// <typeparam name="T">
|
||||
/// The type of data plugin requested.
|
||||
/// </typeparam>
|
||||
/// <exception cref="NotImplementedException">
|
||||
/// Thrown if <typeparamref name="T" /> is not one of the expected data
|
||||
/// interfaces.
|
||||
/// </exception>
|
||||
private static void PluginLoaderParamFactory<T>(string connect, out PluginInitialiserBase init, out string path) where T : IPlugin
|
||||
{
|
||||
Type type = typeof(T);
|
||||
|
||||
if (type == typeof(IInventoryDataPlugin))
|
||||
{
|
||||
init = new InventoryDataInitialiser(connect);
|
||||
path = "/OpenSim/InventoryData";
|
||||
}
|
||||
else if (type == typeof(IUserDataPlugin))
|
||||
{
|
||||
init = new UserDataInitialiser(connect);
|
||||
path = "/OpenSim/UserData";
|
||||
}
|
||||
else if (type == typeof(IGridDataPlugin))
|
||||
{
|
||||
init = new GridDataInitialiser(connect);
|
||||
path = "/OpenSim/GridData";
|
||||
}
|
||||
else if (type == typeof(ILogDataPlugin))
|
||||
{
|
||||
init = new LogDataInitialiser(connect);
|
||||
path = "/OpenSim/LogData";
|
||||
}
|
||||
else if (type == typeof(IAssetDataPlugin))
|
||||
{
|
||||
init = new AssetDataInitialiser(connect);
|
||||
path = "/OpenSim/AssetData";
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't support this data plugin.
|
||||
throw new NotImplementedException(String.Format("The type '{0}' is not a valid data plugin.", type));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of new <typeparamref name="T" /> data plugins.
|
||||
/// Plugins will be requested in the order they were added.
|
||||
/// </summary>
|
||||
/// <param name="provider">
|
||||
/// The filename of the inventory server plugin DLL.
|
||||
/// </param>
|
||||
/// <param name="connect">
|
||||
/// The connection string for the storage backend.
|
||||
/// </param>
|
||||
/// <typeparam name="T">
|
||||
/// The type of data plugin requested.
|
||||
/// </typeparam>
|
||||
/// <returns>
|
||||
/// A list of all loaded plugins matching <typeparamref name="T" />.
|
||||
/// </returns>
|
||||
public static List<T> LoadDataPlugins<T>(string provider, string connect) where T : IPlugin
|
||||
{
|
||||
PluginInitialiserBase pluginInitialiser;
|
||||
string extensionPointPath;
|
||||
|
||||
PluginLoaderParamFactory<T>(connect, out pluginInitialiser, out extensionPointPath);
|
||||
|
||||
using (PluginLoader<T> loader = new PluginLoader<T>(pluginInitialiser))
|
||||
{
|
||||
// loader will try to load all providers (MySQL, MSSQL, etc)
|
||||
// unless it is constrainted to the correct "Provider" entry in the addin.xml
|
||||
loader.Add(extensionPointPath, new PluginProviderFilter(provider));
|
||||
loader.Load();
|
||||
|
||||
return loader.Plugins;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new <typeparamref name="T" /> data plugin instance if
|
||||
/// only one was loaded, otherwise returns null (<c>default(T)</c>).
|
||||
/// </summary>
|
||||
/// <param name="provider">
|
||||
/// The filename of the inventory server plugin DLL.
|
||||
/// </param>
|
||||
/// <param name="connect">
|
||||
/// The connection string for the storage backend.
|
||||
/// </param>
|
||||
/// <typeparam name="T">
|
||||
/// The type of data plugin requested.
|
||||
/// </typeparam>
|
||||
/// <returns>
|
||||
/// A list of all loaded plugins matching <typeparamref name="T" />.
|
||||
/// </returns>
|
||||
public static T LoadDataPlugin<T>(string provider, string connect) where T : IPlugin
|
||||
{
|
||||
List<T> plugins = LoadDataPlugins<T>(provider, connect);
|
||||
return (plugins.Count == 1) ? plugins[0] : default(T);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,21 +27,26 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface exists to distinguish between the normal IAssetDataPlugin and the one used by XAssetService
|
||||
/// for now.
|
||||
/// </summary>
|
||||
public interface IXAssetDataPlugin : IPlugin
|
||||
public abstract class GridDataBase : IGridDataPlugin
|
||||
{
|
||||
AssetBase GetAsset(UUID uuid);
|
||||
void StoreAsset(AssetBase asset);
|
||||
bool ExistsAsset(UUID uuid);
|
||||
List<AssetMetadata> FetchAssetMetadataSet(int start, int count);
|
||||
void Initialise(string connect);
|
||||
bool Delete(string id);
|
||||
public abstract RegionProfileData GetProfileByHandle(ulong regionHandle);
|
||||
public abstract RegionProfileData GetProfileByUUID(UUID UUID);
|
||||
public abstract RegionProfileData GetProfileByString(string regionName);
|
||||
public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
|
||||
public abstract List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum);
|
||||
public abstract bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey);
|
||||
public abstract DataResponse StoreProfile(RegionProfileData profile);
|
||||
public abstract ReservationData GetReservationAtPoint(uint x, uint y);
|
||||
public abstract DataResponse DeleteProfile(string uuid);
|
||||
|
||||
public abstract void Initialise();
|
||||
public abstract void Initialise(string connect);
|
||||
public abstract void Dispose();
|
||||
|
||||
public abstract string Name { get; }
|
||||
public abstract string Version { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,16 @@ namespace OpenSim.Data
|
||||
bool ExistsAsset(UUID uuid);
|
||||
List<AssetMetadata> FetchAssetMetadataSet(int start, int count);
|
||||
void Initialise(string connect);
|
||||
bool Delete(string id);
|
||||
}
|
||||
|
||||
public class AssetDataInitialiser : PluginInitialiserBase
|
||||
{
|
||||
private string connect;
|
||||
public AssetDataInitialiser (string s) { connect = s; }
|
||||
public override void Initialise (IPlugin plugin)
|
||||
{
|
||||
IAssetDataPlugin p = plugin as IAssetDataPlugin;
|
||||
p.Initialise (connect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
134
OpenSim/Data/IGridData.cs
Normal file
134
OpenSim/Data/IGridData.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Data
|
||||
{
|
||||
public enum DataResponse
|
||||
{
|
||||
RESPONSE_OK,
|
||||
RESPONSE_AUTHREQUIRED,
|
||||
RESPONSE_INVALIDCREDENTIALS,
|
||||
RESPONSE_ERROR
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A standard grid interface
|
||||
/// </summary>
|
||||
public interface IGridDataPlugin : IPlugin
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialises the interface
|
||||
/// </summary>
|
||||
void Initialise(string connect);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a sim profile from a regionHandle
|
||||
/// </summary>
|
||||
/// <param name="regionHandle">A 64bit Region Handle</param>
|
||||
/// <returns>A simprofile</returns>
|
||||
RegionProfileData GetProfileByHandle(ulong regionHandle);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a sim profile from a UUID
|
||||
/// </summary>
|
||||
/// <param name="UUID">A 128bit UUID</param>
|
||||
/// <returns>A sim profile</returns>
|
||||
RegionProfileData GetProfileByUUID(UUID UUID);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a sim profile from a string match
|
||||
/// </summary>
|
||||
/// <param name="regionName">A string for a partial region name match</param>
|
||||
/// <returns>A sim profile</returns>
|
||||
RegionProfileData GetProfileByString(string regionName);
|
||||
|
||||
/// <summary>
|
||||
/// Returns all profiles within the specified range
|
||||
/// </summary>
|
||||
/// <param name="Xmin">Minimum sim coordinate (X)</param>
|
||||
/// <param name="Ymin">Minimum sim coordinate (Y)</param>
|
||||
/// <param name="Xmax">Maximum sim coordinate (X)</param>
|
||||
/// <param name="Ymin">Maximum sim coordinate (Y)</param>
|
||||
/// <returns>An array containing all the sim profiles in the specified range</returns>
|
||||
RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
|
||||
|
||||
/// <summary>
|
||||
/// Returns up to maxNum profiles of regions that have a name starting with namePrefix
|
||||
/// </summary>
|
||||
/// <param name="name">The name to match against</param>
|
||||
/// <param name="maxNum">Maximum number of profiles to return</param>
|
||||
/// <returns>A list of sim profiles</returns>
|
||||
List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum);
|
||||
|
||||
/// <summary>
|
||||
/// Authenticates a sim by use of its recv key.
|
||||
/// WARNING: Insecure
|
||||
/// </summary>
|
||||
/// <param name="UUID">The UUID sent by the sim</param>
|
||||
/// <param name="regionHandle">The regionhandle sent by the sim</param>
|
||||
/// <param name="simrecvkey">The receiving key sent by the sim</param>
|
||||
/// <returns>Whether the sim has been authenticated</returns>
|
||||
bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey);
|
||||
|
||||
/// <summary>
|
||||
/// Adds or updates a profile in the database
|
||||
/// </summary>
|
||||
/// <param name="profile">The profile to add</param>
|
||||
/// <returns>RESPONSE_OK if successful, error if not.</returns>
|
||||
DataResponse StoreProfile(RegionProfileData profile);
|
||||
|
||||
/// <summary>
|
||||
/// Remove a profile from the database
|
||||
/// </summary>
|
||||
/// <param name="UUID">ID of profile to remove</param>
|
||||
/// <returns></returns>
|
||||
DataResponse DeleteProfile(string UUID);
|
||||
|
||||
/// <summary>
|
||||
/// Function not used????
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <returns></returns>
|
||||
ReservationData GetReservationAtPoint(uint x, uint y);
|
||||
}
|
||||
|
||||
public class GridDataInitialiser : PluginInitialiserBase
|
||||
{
|
||||
private string connect;
|
||||
public GridDataInitialiser (string s) { connect = s; }
|
||||
public override void Initialise (IPlugin plugin)
|
||||
{
|
||||
IGridDataPlugin p = plugin as IGridDataPlugin;
|
||||
p.Initialise (connect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,4 +155,15 @@ namespace OpenSim.Data
|
||||
/// </returns>
|
||||
List<InventoryItemBase> fetchActiveGestures(UUID avatarID);
|
||||
}
|
||||
|
||||
public class InventoryDataInitialiser : PluginInitialiserBase
|
||||
{
|
||||
private string connect;
|
||||
public InventoryDataInitialiser (string s) { connect = s; }
|
||||
public override void Initialise (IPlugin plugin)
|
||||
{
|
||||
IInventoryDataPlugin p = plugin as IInventoryDataPlugin;
|
||||
p.Initialise (connect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,43 +25,63 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Region.Framework.Interfaces
|
||||
namespace OpenSim.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides methods from manipulating media-on-a-prim
|
||||
/// The severity of an individual log message
|
||||
/// </summary>
|
||||
public interface IMoapModule
|
||||
public enum LogSeverity : int
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the media entry for a given prim face.
|
||||
/// Critical: systems failure
|
||||
/// </summary>
|
||||
/// A copy of the media entry is returned rather than the original, so this can be altered at will without
|
||||
/// affecting the original settings.
|
||||
/// <param name="part"></param>
|
||||
/// <param name="face"></param>
|
||||
/// <returns></returns>
|
||||
MediaEntry GetMediaEntry(SceneObjectPart part, int face);
|
||||
|
||||
CRITICAL = 1,
|
||||
/// <summary>
|
||||
/// Set the media entry for a given prim face.
|
||||
/// Major: warning prior to systems failure
|
||||
/// </summary>
|
||||
/// <param name="SceneObjectPart"></param>
|
||||
/// <param name="face"></param>
|
||||
/// <param name="me"></param>
|
||||
void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me);
|
||||
|
||||
MAJOR = 2,
|
||||
/// <summary>
|
||||
/// Clear the media entry for a given prim face.
|
||||
/// Medium: an individual non-critical task failed
|
||||
/// </summary>
|
||||
///
|
||||
/// This is the equivalent of setting a media entry of null
|
||||
///
|
||||
/// <param name="part"></param>
|
||||
/// <param name="face">/param>
|
||||
void ClearMediaEntry(SceneObjectPart part, int face);
|
||||
MEDIUM = 3,
|
||||
/// <summary>
|
||||
/// Low: Informational warning
|
||||
/// </summary>
|
||||
LOW = 4,
|
||||
/// <summary>
|
||||
/// Info: Information
|
||||
/// </summary>
|
||||
INFO = 5,
|
||||
/// <summary>
|
||||
/// Verbose: Debug Information
|
||||
/// </summary>
|
||||
VERBOSE = 6
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An interface to a LogData storage system
|
||||
/// </summary>
|
||||
public interface ILogDataPlugin : IPlugin
|
||||
{
|
||||
void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,
|
||||
string logMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Initialises the interface
|
||||
/// </summary>
|
||||
void Initialise(string connect);
|
||||
}
|
||||
|
||||
public class LogDataInitialiser : PluginInitialiserBase
|
||||
{
|
||||
private string connect;
|
||||
public LogDataInitialiser (string s) { connect = s; }
|
||||
public override void Initialise (IPlugin plugin)
|
||||
{
|
||||
ILogDataPlugin p = plugin as ILogDataPlugin;
|
||||
p.Initialise (connect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,26 +32,24 @@ using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Data
|
||||
{
|
||||
// This MUST be a ref type!
|
||||
public class PresenceData
|
||||
{
|
||||
public string UserID;
|
||||
public UUID PrincipalID;
|
||||
public UUID RegionID;
|
||||
public UUID SessionID;
|
||||
public Dictionary<string, string> Data;
|
||||
public Dictionary<string, object> Data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An interface for connecting to the presence datastore
|
||||
/// An interface for connecting to the authentication datastore
|
||||
/// </summary>
|
||||
public interface IPresenceData
|
||||
{
|
||||
bool Store(PresenceData data);
|
||||
|
||||
PresenceData Get(UUID sessionID);
|
||||
void LogoutRegionAgents(UUID regionID);
|
||||
bool ReportAgent(UUID sessionID, UUID regionID);
|
||||
PresenceData[] Get(string field, string data);
|
||||
bool Delete(string field, string val);
|
||||
PresenceData Get(UUID principalID);
|
||||
|
||||
bool SetDataItem(UUID principalID, string item, string value);
|
||||
|
||||
bool Delete(UUID regionID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,30 +37,10 @@ namespace OpenSim.Data
|
||||
public UUID RegionID;
|
||||
public UUID ScopeID;
|
||||
public string RegionName;
|
||||
|
||||
/// <summary>
|
||||
/// The position in meters of this region.
|
||||
/// </summary>
|
||||
public int posX;
|
||||
|
||||
/// <summary>
|
||||
/// The position in meters of this region.
|
||||
/// </summary>
|
||||
public int posY;
|
||||
|
||||
public int sizeX;
|
||||
public int sizeY;
|
||||
|
||||
/// <summary>
|
||||
/// Return the x-coordinate of this region.
|
||||
/// </summary>
|
||||
public int coordX { get { return posX / (int)Constants.RegionSize; } }
|
||||
|
||||
/// <summary>
|
||||
/// Return the y-coordinate of this region.
|
||||
/// </summary>
|
||||
public int coordY { get { return posY / (int)Constants.RegionSize; } }
|
||||
|
||||
public Dictionary<string, object> Data;
|
||||
}
|
||||
|
||||
@@ -80,45 +60,5 @@ namespace OpenSim.Data
|
||||
|
||||
bool Delete(UUID regionID);
|
||||
|
||||
List<RegionData> GetDefaultRegions(UUID scopeID);
|
||||
List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y);
|
||||
List<RegionData> GetHyperlinks(UUID scopeID);
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum RegionFlags : int
|
||||
{
|
||||
DefaultRegion = 1, // Used for new Rez. Random if multiple defined
|
||||
FallbackRegion = 2, // Regions we redirect to when the destination is down
|
||||
RegionOnline = 4, // Set when a region comes online, unset when it unregisters and DeleteOnUnregister is false
|
||||
NoDirectLogin = 8, // Region unavailable for direct logins (by name)
|
||||
Persistent = 16, // Don't remove on unregister
|
||||
LockedOut = 32, // Don't allow registration
|
||||
NoMove = 64, // Don't allow moving this region
|
||||
Reservation = 128, // This is an inactive reservation
|
||||
Authenticate = 256, // Require authentication
|
||||
Hyperlink = 512 // Record represents a HG link
|
||||
}
|
||||
|
||||
public class RegionDataDistanceCompare : IComparer<RegionData>
|
||||
{
|
||||
private Vector2 m_origin;
|
||||
|
||||
public RegionDataDistanceCompare(int x, int y)
|
||||
{
|
||||
m_origin = new Vector2(x, y);
|
||||
}
|
||||
|
||||
public int Compare(RegionData regionA, RegionData regionB)
|
||||
{
|
||||
Vector2 vectorA = new Vector2(regionA.posX, regionA.posY);
|
||||
Vector2 vectorB = new Vector2(regionB.posX, regionB.posY);
|
||||
return Math.Sign(VectorDistance(m_origin, vectorA) - VectorDistance(m_origin, vectorB));
|
||||
}
|
||||
|
||||
private float VectorDistance(Vector2 x, Vector2 y)
|
||||
{
|
||||
return (x - y).Length();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
100
OpenSim/Data/IRegionProfileService.cs
Normal file
100
OpenSim/Data/IRegionProfileService.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Data
|
||||
{
|
||||
public interface IRegionProfileService
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a region by argument
|
||||
/// </summary>
|
||||
/// <param name="uuid">A UUID key of the region to return</param>
|
||||
/// <returns>A SimProfileData for the region</returns>
|
||||
RegionProfileData GetRegion(UUID uuid);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a region by argument
|
||||
/// </summary>
|
||||
/// <param name="uuid">A regionHandle of the region to return</param>
|
||||
/// <returns>A SimProfileData for the region</returns>
|
||||
RegionProfileData GetRegion(ulong handle);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a region by argument
|
||||
/// </summary>
|
||||
/// <param name="regionName">A partial regionName of the region to return</param>
|
||||
/// <returns>A SimProfileData for the region</returns>
|
||||
RegionProfileData GetRegion(string regionName);
|
||||
|
||||
List<RegionProfileData> GetRegions(uint xmin, uint ymin, uint xmax, uint ymax);
|
||||
List<RegionProfileData> GetRegions(string name, int maxNum);
|
||||
DataResponse AddUpdateRegion(RegionProfileData sim, RegionProfileData existingSim);
|
||||
DataResponse DeleteRegion(string uuid);
|
||||
}
|
||||
|
||||
public interface IRegionProfileRouter
|
||||
{
|
||||
/// <summary>
|
||||
/// Request sim profile information from a grid server, by Region UUID
|
||||
/// </summary>
|
||||
/// <param name="regionId">The region UUID to look for</param>
|
||||
/// <param name="gridserverUrl"></param>
|
||||
/// <param name="gridserverSendkey"></param>
|
||||
/// <param name="gridserverRecvkey"></param>
|
||||
/// <returns>The sim profile. Null if there was a request failure</returns>
|
||||
/// <remarks>This method should be statics</remarks>
|
||||
RegionProfileData RequestSimProfileData(UUID regionId, Uri gridserverUrl,
|
||||
string gridserverSendkey, string gridserverRecvkey);
|
||||
|
||||
/// <summary>
|
||||
/// Request sim profile information from a grid server, by Region Handle
|
||||
/// </summary>
|
||||
/// <param name="regionHandle">the region handle to look for</param>
|
||||
/// <param name="gridserverUrl"></param>
|
||||
/// <param name="gridserverSendkey"></param>
|
||||
/// <param name="gridserverRecvkey"></param>
|
||||
/// <returns>The sim profile. Null if there was a request failure</returns>
|
||||
RegionProfileData RequestSimProfileData(ulong regionHandle, Uri gridserverUrl,
|
||||
string gridserverSendkey, string gridserverRecvkey);
|
||||
|
||||
/// <summary>
|
||||
/// Request sim profile information from a grid server, by Region Name
|
||||
/// </summary>
|
||||
/// <param name="regionName">the region name to look for</param>
|
||||
/// <param name="gridserverUrl"></param>
|
||||
/// <param name="gridserverSendkey"></param>
|
||||
/// <param name="gridserverRecvkey"></param>
|
||||
/// <returns>The sim profile. Null if there was a request failure</returns>
|
||||
RegionProfileData RequestSimProfileData(string regionName, Uri gridserverUrl,
|
||||
string gridserverSendkey, string gridserverRecvkey);
|
||||
}
|
||||
}
|
||||
@@ -36,19 +36,20 @@ namespace OpenSim.Data
|
||||
{
|
||||
public UUID PrincipalID;
|
||||
public UUID ScopeID;
|
||||
public string FirstName;
|
||||
public string LastName;
|
||||
public Dictionary<string, string> Data;
|
||||
public Dictionary<string, object> Data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An interface for connecting to the user accounts datastore
|
||||
/// An interface for connecting to the authentication datastore
|
||||
/// </summary>
|
||||
public interface IUserAccountData
|
||||
{
|
||||
UserAccountData[] Get(string[] fields, string[] values);
|
||||
UserAccountData Get(UUID principalID, UUID ScopeID);
|
||||
|
||||
List<UserAccountData> Query(UUID principalID, UUID ScopeID, string query);
|
||||
|
||||
bool Store(UserAccountData data);
|
||||
bool Delete(string field, string val);
|
||||
UserAccountData[] GetUsers(UUID scopeID, string query);
|
||||
|
||||
bool SetDataItem(UUID principalID, string item, string value);
|
||||
}
|
||||
}
|
||||
|
||||
209
OpenSim/Data/IUserData.cs
Normal file
209
OpenSim/Data/IUserData.cs
Normal file
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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 OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface for connecting to user storage servers.
|
||||
/// </summary>
|
||||
public interface IUserDataPlugin : IPlugin
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a user profile from a database via their UUID
|
||||
/// </summary>
|
||||
/// <param name="user">The user's UUID</param>
|
||||
/// <returns>The user data profile. Returns null if no user is found</returns>
|
||||
UserProfileData GetUserByUUID(UUID user);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a users profile by searching their username parts
|
||||
/// </summary>
|
||||
/// <param name="fname">Account firstname</param>
|
||||
/// <param name="lname">Account lastname</param>
|
||||
/// <returns>The user data profile. Null if no user is found</returns>
|
||||
UserProfileData GetUserByName(string fname, string lname);
|
||||
|
||||
/// <summary>
|
||||
/// Get a user from a given uri.
|
||||
/// </summary>
|
||||
/// <param name="uri"></param>
|
||||
/// <returns>The user data profile. Null if no user is found.</returns>
|
||||
UserProfileData GetUserByUri(Uri uri);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of UUIDs firstnames and lastnames that match string query entered into the avatar picker.
|
||||
/// </summary>
|
||||
/// <param name="queryID">ID associated with the user's query. This must match what the client sent</param>
|
||||
/// <param name="query">The filtered contents of the search box when the user hit search.</param>
|
||||
/// <returns>A list of user details. If there are no results than either an empty list or null</returns>
|
||||
List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current agent for a user searching by it's UUID
|
||||
/// </summary>
|
||||
/// <param name="user">The users UUID</param>
|
||||
/// <returns>The current agent session. Null if no session was found</returns>
|
||||
UserAgentData GetAgentByUUID(UUID user);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current session agent for a user searching by username
|
||||
/// </summary>
|
||||
/// <param name="name">The users account name</param>
|
||||
/// <returns>The current agent session</returns>
|
||||
UserAgentData GetAgentByName(string name);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current session agent for a user searching by username parts
|
||||
/// </summary>
|
||||
/// <param name="fname">The users first account name</param>
|
||||
/// <param name="lname">The users account surname</param>
|
||||
/// <returns>The current agent session</returns>
|
||||
UserAgentData GetAgentByName(string fname, string lname);
|
||||
|
||||
/// <summary>
|
||||
/// Stores new web-login key for user during web page login
|
||||
/// </summary>
|
||||
/// <param name="webLoginKey"></param>
|
||||
void StoreWebLoginKey(UUID agentID, UUID webLoginKey);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new User profile to the database
|
||||
/// </summary>
|
||||
/// <param name="user">UserProfile to add</param>
|
||||
void AddNewUserProfile(UserProfileData user);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a temporary user profile. A temporary userprofile is one that should exist only for the lifetime of
|
||||
/// the process.
|
||||
/// </summary>
|
||||
/// <param name="userProfile"></param>
|
||||
void AddTemporaryUserProfile(UserProfileData userProfile);
|
||||
|
||||
/// <summary>
|
||||
/// Updates an existing user profile
|
||||
/// </summary>
|
||||
/// <param name="user">UserProfile to update</param>
|
||||
bool UpdateUserProfile(UserProfileData user);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new agent to the database
|
||||
/// </summary>
|
||||
/// <param name="agent">The agent to add</param>
|
||||
void AddNewUserAgent(UserAgentData agent);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new friend to the database for XUser
|
||||
/// </summary>
|
||||
/// <param name="friendlistowner">The agent that who's friends list is being added to</param>
|
||||
/// <param name="friend">The agent that being added to the friends list of the friends list owner</param>
|
||||
/// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param>
|
||||
void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms);
|
||||
|
||||
/// <summary>
|
||||
/// Delete friend on friendlistowner's friendlist.
|
||||
/// </summary>
|
||||
/// <param name="friendlistowner">The agent that who's friends list is being updated</param>
|
||||
/// <param name="friend">The Ex-friend agent</param>
|
||||
void RemoveUserFriend(UUID friendlistowner, UUID friend);
|
||||
|
||||
/// <summary>
|
||||
/// Update permissions for friend on friendlistowner's friendlist.
|
||||
/// </summary>
|
||||
/// <param name="friendlistowner">The agent that who's friends list is being updated</param>
|
||||
/// <param name="friend">The agent that is getting or loosing permissions</param>
|
||||
/// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param>
|
||||
void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner
|
||||
/// </summary>
|
||||
/// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param>
|
||||
/// <returns>The user's friends. If there are no results than either an empty list or null</returns>
|
||||
List<FriendListItem> GetUserFriendList(UUID friendlistowner);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of <see cref="FriendRegionInfo/>s for the specified UUIDs.
|
||||
/// </summary>
|
||||
/// <param name="uuids">
|
||||
/// A <see cref="List"/> of <see cref="UUID/>s to fetch info for
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A <see cref="Dictionary"/>, mapping the <see cref="UUID"/>s to <see cref="FriendRegionInfo"/>s.
|
||||
/// </returns>
|
||||
Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids);
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to move currency units between accounts (NOT RELIABLE / TRUSTWORTHY. DONT TRY RUN YOUR OWN CURRENCY EXCHANGE WITH REAL VALUES)
|
||||
/// </summary>
|
||||
/// <param name="from">The account to transfer from</param>
|
||||
/// <param name="to">The account to transfer to</param>
|
||||
/// <param name="amount">The amount to transfer</param>
|
||||
/// <returns>Successful?</returns>
|
||||
bool MoneyTransferRequest(UUID from, UUID to, uint amount);
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to move inventory between accounts, if inventory is copyable it will be copied into the target account.
|
||||
/// </summary>
|
||||
/// <param name="from">User to transfer from</param>
|
||||
/// <param name="to">User to transfer to</param>
|
||||
/// <param name="inventory">Specified inventory item</param>
|
||||
/// <returns>Successful?</returns>
|
||||
bool InventoryTransferRequest(UUID from, UUID to, UUID inventory);
|
||||
|
||||
/// <summary>
|
||||
/// Initialises the plugin (artificial constructor)
|
||||
/// </summary>
|
||||
void Initialise(string connect);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user appearance
|
||||
/// </summer>
|
||||
AvatarAppearance GetUserAppearance(UUID user);
|
||||
|
||||
void UpdateUserAppearance(UUID user, AvatarAppearance appearance);
|
||||
|
||||
void ResetAttachments(UUID userID);
|
||||
|
||||
void LogoutUsers(UUID regionID);
|
||||
}
|
||||
|
||||
public class UserDataInitialiser : PluginInitialiserBase
|
||||
{
|
||||
private string connect;
|
||||
public UserDataInitialiser (string s) { connect = s; }
|
||||
public override void Initialise (IPlugin plugin)
|
||||
{
|
||||
IUserDataPlugin p = plugin as IUserDataPlugin;
|
||||
p.Initialise (connect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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 OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Data
|
||||
{
|
||||
public class XInventoryFolder
|
||||
{
|
||||
public string folderName;
|
||||
public int type;
|
||||
public int version;
|
||||
public UUID folderID;
|
||||
public UUID agentID;
|
||||
public UUID parentFolderID;
|
||||
|
||||
public XInventoryFolder Clone()
|
||||
{
|
||||
return (XInventoryFolder)MemberwiseClone();
|
||||
}
|
||||
}
|
||||
|
||||
public class XInventoryItem
|
||||
{
|
||||
public UUID assetID;
|
||||
public int assetType;
|
||||
public string inventoryName;
|
||||
public string inventoryDescription;
|
||||
public int inventoryNextPermissions;
|
||||
public int inventoryCurrentPermissions;
|
||||
public int invType;
|
||||
public string creatorID;
|
||||
public int inventoryBasePermissions;
|
||||
public int inventoryEveryOnePermissions;
|
||||
public int salePrice;
|
||||
public int saleType;
|
||||
public int creationDate;
|
||||
public UUID groupID;
|
||||
public int groupOwned;
|
||||
public int flags;
|
||||
public UUID inventoryID;
|
||||
public UUID avatarID;
|
||||
public UUID parentFolderID;
|
||||
public int inventoryGroupPermissions;
|
||||
|
||||
public XInventoryItem Clone()
|
||||
{
|
||||
return (XInventoryItem)MemberwiseClone();
|
||||
}
|
||||
}
|
||||
|
||||
public interface IXInventoryData
|
||||
{
|
||||
XInventoryFolder[] GetFolders(string[] fields, string[] vals);
|
||||
XInventoryItem[] GetItems(string[] fields, string[] vals);
|
||||
|
||||
bool StoreFolder(XInventoryFolder folder);
|
||||
bool StoreItem(XInventoryItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Delete folders where field == val
|
||||
/// </summary>
|
||||
/// <param name="field"></param>
|
||||
/// <param name="val"></param>
|
||||
/// <returns>true if the delete was successful, false if it was not</returns>
|
||||
bool DeleteFolders(string field, string val);
|
||||
|
||||
/// <summary>
|
||||
/// Delete folders where field1 == val1, field2 == val2...
|
||||
/// </summary>
|
||||
/// <param name="fields"></param>
|
||||
/// <param name="vals"></param>
|
||||
/// <returns>true if the delete was successful, false if it was not</returns>
|
||||
bool DeleteFolders(string[] fields, string[] vals);
|
||||
|
||||
/// <summary>
|
||||
/// Delete items where field == val
|
||||
/// </summary>
|
||||
/// <param name="field"></param>
|
||||
/// <param name="val"></param>
|
||||
/// <returns>true if the delete was successful, false if it was not</returns>
|
||||
bool DeleteItems(string field, string val);
|
||||
|
||||
/// <summary>
|
||||
/// Delete items where field1 == val1, field2 == val2...
|
||||
/// </summary>
|
||||
/// <param name="fields"></param>
|
||||
/// <param name="vals"></param>
|
||||
/// <returns>true if the delete was successful, false if it was not</returns>
|
||||
bool DeleteItems(string[] fields, string[] vals);
|
||||
|
||||
bool MoveItem(string id, string newParent);
|
||||
XInventoryItem[] GetActiveGestures(UUID principalID);
|
||||
int GetAssetPermissions(UUID principalID, UUID assetID);
|
||||
}
|
||||
}
|
||||
219
OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs
Normal file
219
OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs
Normal file
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// Encapsulates a SqlCommand object but ensures that when it is disposed, its connection is closed and disposed also.
|
||||
/// </summary>
|
||||
internal class AutoClosingSqlCommand : IDbCommand
|
||||
{
|
||||
private SqlCommand realCommand;
|
||||
|
||||
public AutoClosingSqlCommand(SqlCommand cmd)
|
||||
{
|
||||
realCommand = cmd;
|
||||
}
|
||||
|
||||
#region IDbCommand Members
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
realCommand.Cancel();
|
||||
}
|
||||
|
||||
public string CommandText
|
||||
{
|
||||
get
|
||||
{
|
||||
return realCommand.CommandText;
|
||||
}
|
||||
set
|
||||
{
|
||||
realCommand.CommandText = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int CommandTimeout
|
||||
{
|
||||
get
|
||||
{
|
||||
return realCommand.CommandTimeout;
|
||||
}
|
||||
set
|
||||
{
|
||||
realCommand.CommandTimeout = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CommandType CommandType
|
||||
{
|
||||
get
|
||||
{
|
||||
return realCommand.CommandType;
|
||||
}
|
||||
set
|
||||
{
|
||||
realCommand.CommandType = value;
|
||||
}
|
||||
}
|
||||
|
||||
IDbConnection IDbCommand.Connection
|
||||
{
|
||||
get
|
||||
{
|
||||
return realCommand.Connection;
|
||||
}
|
||||
set
|
||||
{
|
||||
realCommand.Connection = (SqlConnection) value;
|
||||
}
|
||||
}
|
||||
|
||||
public SqlConnection Connection
|
||||
{
|
||||
get
|
||||
{
|
||||
return realCommand.Connection;
|
||||
}
|
||||
}
|
||||
|
||||
IDbDataParameter IDbCommand.CreateParameter()
|
||||
{
|
||||
return realCommand.CreateParameter();
|
||||
}
|
||||
|
||||
public SqlParameter CreateParameter()
|
||||
{
|
||||
return realCommand.CreateParameter();
|
||||
}
|
||||
|
||||
public int ExecuteNonQuery()
|
||||
{
|
||||
return realCommand.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
IDataReader IDbCommand.ExecuteReader(CommandBehavior behavior)
|
||||
{
|
||||
return realCommand.ExecuteReader(behavior);
|
||||
}
|
||||
|
||||
public SqlDataReader ExecuteReader(CommandBehavior behavior)
|
||||
{
|
||||
return realCommand.ExecuteReader(behavior);
|
||||
}
|
||||
|
||||
IDataReader IDbCommand.ExecuteReader()
|
||||
{
|
||||
return realCommand.ExecuteReader();
|
||||
}
|
||||
|
||||
public SqlDataReader ExecuteReader()
|
||||
{
|
||||
return realCommand.ExecuteReader();
|
||||
}
|
||||
|
||||
public object ExecuteScalar()
|
||||
{
|
||||
return realCommand.ExecuteScalar();
|
||||
}
|
||||
|
||||
IDataParameterCollection IDbCommand.Parameters
|
||||
{
|
||||
get { return realCommand.Parameters; }
|
||||
}
|
||||
|
||||
public SqlParameterCollection Parameters
|
||||
{
|
||||
get { return realCommand.Parameters; }
|
||||
}
|
||||
|
||||
public void Prepare()
|
||||
{
|
||||
realCommand.Prepare();
|
||||
}
|
||||
|
||||
// IDbTransaction IDbCommand.Transaction
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return realCommand.Transaction;
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// realCommand.Transaction = (SqlTransaction) value;
|
||||
// }
|
||||
// }
|
||||
|
||||
public IDbTransaction Transaction
|
||||
{
|
||||
get { return realCommand.Transaction; }
|
||||
set { realCommand.Transaction = (SqlTransaction)value; }
|
||||
}
|
||||
|
||||
UpdateRowSource IDbCommand.UpdatedRowSource
|
||||
{
|
||||
get
|
||||
{
|
||||
return realCommand.UpdatedRowSource;
|
||||
}
|
||||
set
|
||||
{
|
||||
realCommand.UpdatedRowSource = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
SqlConnection conn = realCommand.Connection;
|
||||
try
|
||||
{
|
||||
realCommand.Dispose();
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,6 @@ namespace OpenSim.Data.MSSQL
|
||||
/// Database manager
|
||||
/// </summary>
|
||||
private MSSQLManager m_database;
|
||||
private string m_connectionString;
|
||||
|
||||
#region IPlugin Members
|
||||
|
||||
@@ -76,8 +75,23 @@ namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
m_ticksToEpoch = new System.DateTime(1970, 1, 1).Ticks;
|
||||
|
||||
m_database = new MSSQLManager(connectionString);
|
||||
m_connectionString = connectionString;
|
||||
if (!string.IsNullOrEmpty(connectionString))
|
||||
{
|
||||
m_database = new MSSQLManager(connectionString);
|
||||
}
|
||||
else
|
||||
{
|
||||
IniFile gridDataMSSqlFile = new IniFile("mssql_connection.ini");
|
||||
string settingDataSource = gridDataMSSqlFile.ParseFileReadValue("data_source");
|
||||
string settingInitialCatalog = gridDataMSSqlFile.ParseFileReadValue("initial_catalog");
|
||||
string settingPersistSecurityInfo = gridDataMSSqlFile.ParseFileReadValue("persist_security_info");
|
||||
string settingUserId = gridDataMSSqlFile.ParseFileReadValue("user_id");
|
||||
string settingPassword = gridDataMSSqlFile.ParseFileReadValue("password");
|
||||
|
||||
m_database =
|
||||
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
|
||||
settingPassword);
|
||||
}
|
||||
|
||||
//New migration to check for DB changes
|
||||
m_database.CheckMigration(_migrationStore);
|
||||
@@ -111,26 +125,22 @@ namespace OpenSim.Data.MSSQL
|
||||
override public AssetBase GetAsset(UUID assetID)
|
||||
{
|
||||
string sql = "SELECT * FROM assets WHERE id = @id";
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
using (AutoClosingSqlCommand command = m_database.Query(sql))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("id", assetID));
|
||||
conn.Open();
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
command.Parameters.Add(m_database.CreateParameter("id", assetID));
|
||||
using (SqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
AssetBase asset = new AssetBase(
|
||||
DBGuid.FromDB(reader["id"]),
|
||||
new UUID((Guid)reader["id"]),
|
||||
(string)reader["name"],
|
||||
Convert.ToSByte(reader["assetType"]),
|
||||
reader["creatorid"].ToString()
|
||||
Convert.ToSByte(reader["assetType"])
|
||||
);
|
||||
// Region Main
|
||||
asset.Description = (string)reader["description"];
|
||||
asset.Local = Convert.ToBoolean(reader["local"]);
|
||||
asset.Temporary = Convert.ToBoolean(reader["temporary"]);
|
||||
asset.Flags = (AssetFlags)(Convert.ToInt32(reader["asset_flags"]));
|
||||
asset.Data = (byte[])reader["data"];
|
||||
return asset;
|
||||
}
|
||||
@@ -145,19 +155,26 @@ namespace OpenSim.Data.MSSQL
|
||||
/// <param name="asset">the asset</param>
|
||||
override public void StoreAsset(AssetBase asset)
|
||||
{
|
||||
|
||||
string sql =
|
||||
@"IF EXISTS(SELECT * FROM assets WHERE id=@id)
|
||||
UPDATE assets set name = @name, description = @description, assetType = @assetType,
|
||||
local = @local, temporary = @temporary, creatorid = @creatorid, data = @data
|
||||
WHERE id=@id
|
||||
ELSE
|
||||
INSERT INTO assets
|
||||
([id], [name], [description], [assetType], [local],
|
||||
[temporary], [create_time], [access_time], [creatorid], [asset_flags], [data])
|
||||
VALUES
|
||||
(@id, @name, @description, @assetType, @local,
|
||||
@temporary, @create_time, @access_time, @creatorid, @asset_flags, @data)";
|
||||
if (ExistsAsset(asset.FullID))
|
||||
UpdateAsset(asset);
|
||||
else
|
||||
InsertAsset(asset);
|
||||
}
|
||||
|
||||
|
||||
private void InsertAsset(AssetBase asset)
|
||||
{
|
||||
if (ExistsAsset(asset.FullID))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string sql = @"INSERT INTO assets
|
||||
([id], [name], [description], [assetType], [local],
|
||||
[temporary], [create_time], [access_time], [data])
|
||||
VALUES
|
||||
(@id, @name, @description, @assetType, @local,
|
||||
@temporary, @create_time, @access_time, @data)";
|
||||
|
||||
string assetName = asset.Name;
|
||||
if (asset.Name.Length > 64)
|
||||
@@ -173,8 +190,7 @@ namespace OpenSim.Data.MSSQL
|
||||
m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add");
|
||||
}
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand command = new SqlCommand(sql, conn))
|
||||
using (AutoClosingSqlCommand command = m_database.Query(sql))
|
||||
{
|
||||
int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000);
|
||||
command.Parameters.Add(m_database.CreateParameter("id", asset.FullID));
|
||||
@@ -185,21 +201,64 @@ namespace OpenSim.Data.MSSQL
|
||||
command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary));
|
||||
command.Parameters.Add(m_database.CreateParameter("access_time", now));
|
||||
command.Parameters.Add(m_database.CreateParameter("create_time", now));
|
||||
command.Parameters.Add(m_database.CreateParameter("asset_flags", (int)asset.Flags));
|
||||
command.Parameters.Add(m_database.CreateParameter("creatorid", asset.Metadata.CreatorID));
|
||||
command.Parameters.Add(m_database.CreateParameter("data", asset.Data));
|
||||
conn.Open();
|
||||
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
m_log.Error("[ASSET DB]: Error storing item :" + e.Message);
|
||||
m_log.Error("[ASSET DB]: Error inserting item :" + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update asset in m_database
|
||||
/// </summary>
|
||||
/// <param name="asset">the asset</param>
|
||||
private void UpdateAsset(AssetBase asset)
|
||||
{
|
||||
string sql = @"UPDATE assets set id = @id, name = @name, description = @description, assetType = @assetType,
|
||||
local = @local, temporary = @temporary, data = @data
|
||||
WHERE id = @keyId;";
|
||||
|
||||
string assetName = asset.Name;
|
||||
if (asset.Name.Length > 64)
|
||||
{
|
||||
assetName = asset.Name.Substring(0, 64);
|
||||
m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on update");
|
||||
}
|
||||
|
||||
string assetDescription = asset.Description;
|
||||
if (asset.Description.Length > 64)
|
||||
{
|
||||
assetDescription = asset.Description.Substring(0, 64);
|
||||
m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on update");
|
||||
}
|
||||
|
||||
using (AutoClosingSqlCommand command = m_database.Query(sql))
|
||||
{
|
||||
command.Parameters.Add(m_database.CreateParameter("id", asset.FullID));
|
||||
command.Parameters.Add(m_database.CreateParameter("name", assetName));
|
||||
command.Parameters.Add(m_database.CreateParameter("description", assetDescription));
|
||||
command.Parameters.Add(m_database.CreateParameter("assetType", asset.Type));
|
||||
command.Parameters.Add(m_database.CreateParameter("local", asset.Local));
|
||||
command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary));
|
||||
command.Parameters.Add(m_database.CreateParameter("data", asset.Data));
|
||||
command.Parameters.Add(m_database.CreateParameter("@keyId", asset.FullID));
|
||||
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(e.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Commented out since currently unused - this probably should be called in GetAsset()
|
||||
// private void UpdateAccessTime(AssetBase asset)
|
||||
@@ -245,34 +304,25 @@ namespace OpenSim.Data.MSSQL
|
||||
public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count)
|
||||
{
|
||||
List<AssetMetadata> retList = new List<AssetMetadata>(count);
|
||||
string sql = @"WITH OrderedAssets AS
|
||||
(
|
||||
SELECT id, name, description, assetType, temporary, creatorid,
|
||||
RowNumber = ROW_NUMBER() OVER (ORDER BY id)
|
||||
FROM assets
|
||||
)
|
||||
SELECT *
|
||||
FROM OrderedAssets
|
||||
WHERE RowNumber BETWEEN @start AND @stop;";
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
string sql = @"SELECT (name,description,assetType,temporary,id), Row = ROW_NUMBER()
|
||||
OVER (ORDER BY (some column to order by))
|
||||
WHERE Row >= @Start AND Row < @Start + @Count";
|
||||
|
||||
using (AutoClosingSqlCommand command = m_database.Query(sql))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("start", start));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("stop", start + count - 1));
|
||||
conn.Open();
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
command.Parameters.Add(m_database.CreateParameter("start", start));
|
||||
command.Parameters.Add(m_database.CreateParameter("count", count));
|
||||
|
||||
using (SqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
AssetMetadata metadata = new AssetMetadata();
|
||||
metadata.FullID = DBGuid.FromDB(reader["id"]);
|
||||
metadata.FullID = new UUID((Guid)reader["id"]);
|
||||
metadata.Name = (string)reader["name"];
|
||||
metadata.Description = (string)reader["description"];
|
||||
metadata.Type = Convert.ToSByte(reader["assetType"]);
|
||||
metadata.Temporary = Convert.ToBoolean(reader["temporary"]);
|
||||
metadata.CreatorID = (string)reader["creatorid"];
|
||||
retList.Add(metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -280,10 +330,6 @@ namespace OpenSim.Data.MSSQL
|
||||
return retList;
|
||||
}
|
||||
|
||||
public override bool Delete(string id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
conn.Open();
|
||||
Migration m = new Migration(conn, GetType().Assembly, "AuthStore");
|
||||
m_database = new MSSQLManager(m_ConnectionString);
|
||||
m.Update();
|
||||
}
|
||||
}
|
||||
@@ -169,14 +168,13 @@ namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
if (System.Environment.TickCount - m_LastExpire > 30000)
|
||||
DoExpire();
|
||||
|
||||
string sql = "insert into tokens (UUID, token, validity) values (@principalID, @token, @lifetime)";
|
||||
string sql = "insert into tokens (UUID, token, validity) values (@principalID, @token, date_add(now(), interval @lifetime minute))";
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@token", token));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@lifetime", DateTime.Now.AddMinutes(lifetime)));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@lifetime", lifetime));
|
||||
conn.Open();
|
||||
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
@@ -191,15 +189,13 @@ namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
if (System.Environment.TickCount - m_LastExpire > 30000)
|
||||
DoExpire();
|
||||
|
||||
DateTime validDate = DateTime.Now.AddMinutes(lifetime);
|
||||
string sql = "update tokens set validity = @validDate where UUID = @principalID and token = @token and validity > GetDate()";
|
||||
string sql = "update tokens set validity = date_add(now(), interval @lifetime minute) where UUID = @principalID and token = @token and validity > now()";
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@token", token));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@validDate", validDate));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@lifetime", lifetime));
|
||||
conn.Open();
|
||||
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
@@ -212,13 +208,11 @@ namespace OpenSim.Data.MSSQL
|
||||
|
||||
private void DoExpire()
|
||||
{
|
||||
DateTime currentDateTime = DateTime.Now;
|
||||
string sql = "delete from tokens where validity < @currentDateTime";
|
||||
string sql = "delete from tokens where validity < now()";
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
conn.Open();
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@currentDateTime", currentDateTime));
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
m_LastExpire = System.Environment.TickCount;
|
||||
|
||||
@@ -37,28 +37,19 @@ using OpenSim.Region.Framework.Interfaces;
|
||||
|
||||
namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
public class MSSQLEstateStore : IEstateDataStore
|
||||
public class MSSQLEstateData : IEstateDataStore
|
||||
{
|
||||
private const string _migrationStore = "EstateStore";
|
||||
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static readonly ILog _Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private MSSQLManager _Database;
|
||||
private string m_connectionString;
|
||||
|
||||
private FieldInfo[] _Fields;
|
||||
private Dictionary<string, FieldInfo> _FieldMap = new Dictionary<string, FieldInfo>();
|
||||
|
||||
#region Public methods
|
||||
|
||||
public MSSQLEstateStore()
|
||||
{
|
||||
}
|
||||
|
||||
public MSSQLEstateStore(string connectionString)
|
||||
{
|
||||
Initialise(connectionString);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialises the estatedata class.
|
||||
/// </summary>
|
||||
@@ -67,17 +58,25 @@ namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
if (!string.IsNullOrEmpty(connectionString))
|
||||
{
|
||||
m_connectionString = connectionString;
|
||||
_Database = new MSSQLManager(connectionString);
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO when can this be deleted
|
||||
IniFile iniFile = new IniFile("mssql_connection.ini");
|
||||
string settingDataSource = iniFile.ParseFileReadValue("data_source");
|
||||
string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog");
|
||||
string settingPersistSecurityInfo = iniFile.ParseFileReadValue("persist_security_info");
|
||||
string settingUserId = iniFile.ParseFileReadValue("user_id");
|
||||
string settingPassword = iniFile.ParseFileReadValue("password");
|
||||
|
||||
_Database =
|
||||
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
|
||||
settingPassword);
|
||||
}
|
||||
|
||||
//Migration settings
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
Migration m = new Migration(conn, GetType().Assembly, "EstateStore");
|
||||
m.Update();
|
||||
}
|
||||
_Database.CheckMigration(_migrationStore);
|
||||
|
||||
//Interesting way to get parameters! Maybe implement that also with other types
|
||||
Type t = typeof(EstateSettings);
|
||||
@@ -97,48 +96,40 @@ namespace OpenSim.Data.MSSQL
|
||||
/// </summary>
|
||||
/// <param name="regionID">region ID.</param>
|
||||
/// <returns></returns>
|
||||
public EstateSettings LoadEstateSettings(UUID regionID, bool create)
|
||||
public EstateSettings LoadEstateSettings(UUID regionID)
|
||||
{
|
||||
EstateSettings es = new EstateSettings();
|
||||
|
||||
string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + " from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = @RegionID";
|
||||
|
||||
bool insertEstate = false;
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
|
||||
using (AutoClosingSqlCommand cmd = _Database.Query(sql))
|
||||
{
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@RegionID", regionID));
|
||||
conn.Open();
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
foreach (string name in FieldList)
|
||||
{
|
||||
FieldInfo f = _FieldMap[name];
|
||||
object v = reader[name];
|
||||
if (f.FieldType == typeof(bool))
|
||||
if (_FieldMap[name].GetValue(es) is bool)
|
||||
{
|
||||
f.SetValue(es, Convert.ToInt32(v) != 0);
|
||||
int v = Convert.ToInt32(reader[name]);
|
||||
if (v != 0)
|
||||
_FieldMap[name].SetValue(es, true);
|
||||
else
|
||||
_FieldMap[name].SetValue(es, false);
|
||||
}
|
||||
else if (f.FieldType == typeof(UUID))
|
||||
else if (_FieldMap[name].GetValue(es) is UUID)
|
||||
{
|
||||
f.SetValue(es, new UUID((Guid)v)); // uuid);
|
||||
}
|
||||
else if (f.FieldType == typeof(string))
|
||||
{
|
||||
f.SetValue(es, v.ToString());
|
||||
}
|
||||
else if (f.FieldType == typeof(UInt32))
|
||||
{
|
||||
f.SetValue(es, Convert.ToUInt32(v));
|
||||
}
|
||||
else if (f.FieldType == typeof(Single))
|
||||
{
|
||||
f.SetValue(es, Convert.ToSingle(v));
|
||||
_FieldMap[name].SetValue(es, new UUID((Guid) reader[name])); // uuid);
|
||||
}
|
||||
else
|
||||
f.SetValue(es, v);
|
||||
{
|
||||
es.EstateID = Convert.ToUInt32(reader["EstateID"].ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -148,10 +139,70 @@ namespace OpenSim.Data.MSSQL
|
||||
}
|
||||
}
|
||||
|
||||
if (insertEstate && create)
|
||||
|
||||
if (insertEstate)
|
||||
{
|
||||
DoCreate(es);
|
||||
LinkRegion(regionID, (int)es.EstateID);
|
||||
List<string> names = new List<string>(FieldList);
|
||||
|
||||
names.Remove("EstateID");
|
||||
|
||||
sql = string.Format("insert into estate_settings ({0}) values ( @{1})", String.Join(",", names.ToArray()), String.Join(", @", names.ToArray()));
|
||||
|
||||
//_Log.Debug("[DB ESTATE]: SQL: " + sql);
|
||||
using (SqlConnection connection = _Database.DatabaseConnection())
|
||||
{
|
||||
using (SqlCommand insertCommand = connection.CreateCommand())
|
||||
{
|
||||
insertCommand.CommandText = sql + " SET @ID = SCOPE_IDENTITY()";
|
||||
|
||||
foreach (string name in names)
|
||||
{
|
||||
insertCommand.Parameters.Add(_Database.CreateParameter("@" + name, _FieldMap[name].GetValue(es)));
|
||||
}
|
||||
SqlParameter idParameter = new SqlParameter("@ID", SqlDbType.Int);
|
||||
idParameter.Direction = ParameterDirection.Output;
|
||||
insertCommand.Parameters.Add(idParameter);
|
||||
|
||||
insertCommand.ExecuteNonQuery();
|
||||
|
||||
es.EstateID = Convert.ToUInt32(idParameter.Value);
|
||||
}
|
||||
}
|
||||
|
||||
using (AutoClosingSqlCommand cmd = _Database.Query("INSERT INTO [estate_map] ([RegionID] ,[EstateID]) VALUES (@RegionID, @EstateID)"))
|
||||
{
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@RegionID", regionID));
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@EstateID", es.EstateID));
|
||||
// This will throw on dupe key
|
||||
try
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_Log.DebugFormat("[ESTATE DB]: Error inserting regionID and EstateID in estate_map: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Munge and transfer the ban list
|
||||
|
||||
sql = string.Format("insert into estateban select {0}, bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = @UUID", es.EstateID);
|
||||
using (AutoClosingSqlCommand cmd = _Database.Query(sql))
|
||||
{
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@UUID", regionID));
|
||||
try
|
||||
{
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_Log.Debug("[ESTATE DB]: Error setting up estateban from regionban");
|
||||
}
|
||||
}
|
||||
|
||||
//TODO check if this is needed??
|
||||
es.Save();
|
||||
}
|
||||
|
||||
LoadBanList(es);
|
||||
@@ -165,53 +216,6 @@ namespace OpenSim.Data.MSSQL
|
||||
return es;
|
||||
}
|
||||
|
||||
public EstateSettings CreateNewEstate()
|
||||
{
|
||||
EstateSettings es = new EstateSettings();
|
||||
es.OnSave += StoreEstateSettings;
|
||||
|
||||
DoCreate(es);
|
||||
|
||||
LoadBanList(es);
|
||||
|
||||
es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
|
||||
es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
|
||||
es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups");
|
||||
|
||||
return es;
|
||||
}
|
||||
|
||||
private void DoCreate(EstateSettings es)
|
||||
{
|
||||
List<string> names = new List<string>(FieldList);
|
||||
|
||||
names.Remove("EstateID");
|
||||
|
||||
string sql = string.Format("insert into estate_settings ({0}) values ( @{1})", String.Join(",", names.ToArray()), String.Join(", @", names.ToArray()));
|
||||
|
||||
//_Log.Debug("[DB ESTATE]: SQL: " + sql);
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand insertCommand = new SqlCommand(sql, conn))
|
||||
{
|
||||
insertCommand.CommandText = sql + " SET @ID = SCOPE_IDENTITY()";
|
||||
|
||||
foreach (string name in names)
|
||||
{
|
||||
insertCommand.Parameters.Add(_Database.CreateParameter("@" + name, _FieldMap[name].GetValue(es)));
|
||||
}
|
||||
SqlParameter idParameter = new SqlParameter("@ID", SqlDbType.Int);
|
||||
idParameter.Direction = ParameterDirection.Output;
|
||||
insertCommand.Parameters.Add(idParameter);
|
||||
conn.Open();
|
||||
insertCommand.ExecuteNonQuery();
|
||||
|
||||
es.EstateID = Convert.ToUInt32(idParameter.Value);
|
||||
}
|
||||
|
||||
//TODO check if this is needed??
|
||||
es.Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores the estate settings.
|
||||
/// </summary>
|
||||
@@ -222,7 +226,7 @@ namespace OpenSim.Data.MSSQL
|
||||
|
||||
names.Remove("EstateID");
|
||||
|
||||
string sql = string.Format("UPDATE estate_settings SET ");
|
||||
string sql = string.Format("UPDATE estate_settings SET ") ;
|
||||
foreach (string name in names)
|
||||
{
|
||||
sql += name + " = @" + name + ", ";
|
||||
@@ -230,8 +234,7 @@ namespace OpenSim.Data.MSSQL
|
||||
sql = sql.Remove(sql.LastIndexOf(","));
|
||||
sql += " WHERE EstateID = @EstateID";
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
using (AutoClosingSqlCommand cmd = _Database.Query(sql))
|
||||
{
|
||||
foreach (string name in names)
|
||||
{
|
||||
@@ -239,7 +242,6 @@ namespace OpenSim.Data.MSSQL
|
||||
}
|
||||
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@EstateID", es.EstateID));
|
||||
conn.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
@@ -264,13 +266,12 @@ namespace OpenSim.Data.MSSQL
|
||||
|
||||
string sql = "select bannedUUID from estateban where EstateID = @EstateID";
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
using (AutoClosingSqlCommand cmd = _Database.Query(sql))
|
||||
{
|
||||
SqlParameter idParameter = new SqlParameter("@EstateID", SqlDbType.Int);
|
||||
idParameter.Value = es.EstateID;
|
||||
cmd.Parameters.Add(idParameter);
|
||||
conn.Open();
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
@@ -292,11 +293,10 @@ namespace OpenSim.Data.MSSQL
|
||||
|
||||
string sql = string.Format("select uuid from {0} where EstateID = @EstateID", table);
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
using (AutoClosingSqlCommand cmd = _Database.Query(sql))
|
||||
{
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@EstateID", estateID));
|
||||
conn.Open();
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
@@ -312,266 +312,58 @@ namespace OpenSim.Data.MSSQL
|
||||
private void SaveBanList(EstateSettings es)
|
||||
{
|
||||
//Delete first
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
string sql = "delete from estateban where EstateID = @EstateID";
|
||||
using (AutoClosingSqlCommand cmd = _Database.Query(sql))
|
||||
{
|
||||
conn.Open();
|
||||
using (SqlCommand cmd = conn.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "delete from estateban where EstateID = @EstateID";
|
||||
cmd.Parameters.AddWithValue("@EstateID", (int)es.EstateID);
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@EstateID", es.EstateID));
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
//Insert after
|
||||
cmd.CommandText = "insert into estateban (EstateID, bannedUUID,bannedIp, bannedIpHostMask, bannedNameMask) values ( @EstateID, @bannedUUID, '','','' )";
|
||||
cmd.Parameters.AddWithValue("@bannedUUID", Guid.Empty);
|
||||
foreach (EstateBan b in es.EstateBans)
|
||||
{
|
||||
cmd.Parameters["@bannedUUID"].Value = b.BannedUserID.Guid;
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
//Insert after
|
||||
sql = "insert into estateban (EstateID, bannedUUID) values ( @EstateID, @bannedUUID )";
|
||||
using (AutoClosingSqlCommand cmd = _Database.Query(sql))
|
||||
{
|
||||
foreach (EstateBan b in es.EstateBans)
|
||||
{
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@EstateID", es.EstateID));
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@bannedUUID", b.BannedUserID));
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveUUIDList(uint estateID, string table, UUID[] data)
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
//Delete first
|
||||
string sql = string.Format("delete from {0} where EstateID = @EstateID", table);
|
||||
using (AutoClosingSqlCommand cmd = _Database.Query(sql))
|
||||
{
|
||||
conn.Open();
|
||||
using (SqlCommand cmd = conn.CreateCommand())
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@EstateID", (int)estateID);
|
||||
cmd.CommandText = string.Format("delete from {0} where EstateID = @EstateID", table);
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@EstateID", estateID));
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
cmd.CommandText = string.Format("insert into {0} (EstateID, uuid) values ( @EstateID, @uuid )", table);
|
||||
cmd.Parameters.AddWithValue("@uuid", Guid.Empty);
|
||||
foreach (UUID uuid in data)
|
||||
sql = string.Format("insert into {0} (EstateID, uuid) values ( @EstateID, @uuid )", table);
|
||||
using (AutoClosingSqlCommand cmd = _Database.Query(sql))
|
||||
{
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@EstateID", estateID));
|
||||
|
||||
bool createParamOnce = true;
|
||||
|
||||
foreach (UUID uuid in data)
|
||||
{
|
||||
if (createParamOnce)
|
||||
{
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@uuid", uuid));
|
||||
createParamOnce = false;
|
||||
}
|
||||
else
|
||||
cmd.Parameters["@uuid"].Value = uuid.Guid; //.ToString(); //TODO check if this works
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public EstateSettings LoadEstateSettings(int estateID)
|
||||
{
|
||||
EstateSettings es = new EstateSettings();
|
||||
string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + " from estate_settings where EstateID = @EstateID";
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@EstateID", (int)estateID);
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
foreach (string name in FieldList)
|
||||
{
|
||||
FieldInfo f = _FieldMap[name];
|
||||
object v = reader[name];
|
||||
if (f.FieldType == typeof(bool))
|
||||
{
|
||||
f.SetValue(es, Convert.ToInt32(v) != 0);
|
||||
}
|
||||
else if (f.FieldType == typeof(UUID))
|
||||
{
|
||||
f.SetValue(es, new UUID((Guid)v)); // uuid);
|
||||
}
|
||||
else if (f.FieldType == typeof(string))
|
||||
{
|
||||
f.SetValue(es, v.ToString());
|
||||
}
|
||||
else if (f.FieldType == typeof(UInt32))
|
||||
{
|
||||
f.SetValue(es, Convert.ToUInt32(v));
|
||||
}
|
||||
else if (f.FieldType == typeof(Single))
|
||||
{
|
||||
f.SetValue(es, Convert.ToSingle(v));
|
||||
}
|
||||
else
|
||||
f.SetValue(es, v);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
LoadBanList(es);
|
||||
|
||||
es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
|
||||
es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
|
||||
es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups");
|
||||
|
||||
//Set event
|
||||
es.OnSave += StoreEstateSettings;
|
||||
return es;
|
||||
|
||||
}
|
||||
|
||||
public List<EstateSettings> LoadEstateSettingsAll()
|
||||
{
|
||||
List<EstateSettings> allEstateSettings = new List<EstateSettings>();
|
||||
|
||||
List<int> allEstateIds = GetEstatesAll();
|
||||
|
||||
foreach (int estateId in allEstateIds)
|
||||
allEstateSettings.Add(LoadEstateSettings(estateId));
|
||||
|
||||
return allEstateSettings;
|
||||
}
|
||||
|
||||
public List<int> GetEstates(string search)
|
||||
{
|
||||
List<int> result = new List<int>();
|
||||
string sql = "select estateID from estate_settings where EstateName = @EstateName";
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@EstateName", search);
|
||||
|
||||
using (IDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Add(Convert.ToInt32(reader["EstateID"]));
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<int> GetEstatesAll()
|
||||
{
|
||||
List<int> result = new List<int>();
|
||||
string sql = "select estateID from estate_settings";
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
using (IDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Add(Convert.ToInt32(reader["EstateID"]));
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<int> GetEstatesByOwner(UUID ownerID)
|
||||
{
|
||||
List<int> result = new List<int>();
|
||||
string sql = "select estateID from estate_settings where EstateOwner = @EstateOwner";
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@EstateOwner", ownerID);
|
||||
|
||||
using (IDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Add(Convert.ToInt32(reader["EstateID"]));
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool LinkRegion(UUID regionID, int estateID)
|
||||
{
|
||||
string deleteSQL = "delete from estate_map where RegionID = @RegionID";
|
||||
string insertSQL = "insert into estate_map values (@RegionID, @EstateID)";
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
SqlTransaction transaction = conn.BeginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand(deleteSQL, conn))
|
||||
{
|
||||
cmd.Transaction = transaction;
|
||||
cmd.Parameters.AddWithValue("@RegionID", regionID.Guid);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(insertSQL, conn))
|
||||
{
|
||||
cmd.Transaction = transaction;
|
||||
cmd.Parameters.AddWithValue("@RegionID", regionID.Guid);
|
||||
cmd.Parameters.AddWithValue("@EstateID", estateID);
|
||||
|
||||
int ret = cmd.ExecuteNonQuery();
|
||||
|
||||
if (ret != 0)
|
||||
transaction.Commit();
|
||||
else
|
||||
transaction.Rollback();
|
||||
|
||||
return (ret != 0);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
m_log.Error("[REGION DB]: LinkRegion failed: " + ex.Message);
|
||||
transaction.Rollback();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<UUID> GetRegions(int estateID)
|
||||
{
|
||||
List<UUID> result = new List<UUID>();
|
||||
string sql = "select RegionID from estate_map where EstateID = @EstateID";
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@EstateID", estateID);
|
||||
|
||||
using (IDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Add(DBGuid.FromDB(reader["RegionID"]));
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool DeleteEstate(int estateID)
|
||||
{
|
||||
// TODO: Implementation!
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ''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 CONTRIBUTORS 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.Data;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using System.Data.SqlClient;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
public class MSSQLFriendsData : MSSQLGenericTableHandler<FriendsData>, IFriendsData
|
||||
{
|
||||
public MSSQLFriendsData(string connectionString, string realm)
|
||||
: base(connectionString, realm, "FriendsStore")
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
Migration m = new Migration(conn, GetType().Assembly, "FriendsStore");
|
||||
m.Update();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Delete(UUID principalID, string friend)
|
||||
{
|
||||
return Delete(principalID.ToString(), friend);
|
||||
}
|
||||
|
||||
public bool Delete(string principalID, string friend)
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("delete from {0} where PrincipalID = @PrincipalID and Friend = @Friend", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString()));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@Friend", friend));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public FriendsData[] GetFriends(UUID principalID)
|
||||
{
|
||||
return GetFriends(principalID.ToString());
|
||||
}
|
||||
|
||||
public FriendsData[] GetFriends(string principalID)
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
|
||||
cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = @PrincipalID", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString()));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public FriendsData[] GetFriends(Guid principalID)
|
||||
{
|
||||
return GetFriends(principalID.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,384 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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.Data;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using System.Data.SqlClient;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
public class MSSQLGenericTableHandler<T> where T : class, new()
|
||||
{
|
||||
// private static readonly ILog m_log =
|
||||
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected string m_ConnectionString;
|
||||
protected MSSQLManager m_database; //used for parameter type translation
|
||||
protected Dictionary<string, FieldInfo> m_Fields =
|
||||
new Dictionary<string, FieldInfo>();
|
||||
|
||||
protected List<string> m_ColumnNames = null;
|
||||
protected string m_Realm;
|
||||
protected FieldInfo m_DataField = null;
|
||||
|
||||
public MSSQLGenericTableHandler(string connectionString,
|
||||
string realm, string storeName)
|
||||
{
|
||||
m_Realm = realm;
|
||||
|
||||
m_ConnectionString = connectionString;
|
||||
|
||||
if (storeName != String.Empty)
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
Migration m = new Migration(conn, GetType().Assembly, storeName);
|
||||
m.Update();
|
||||
}
|
||||
|
||||
}
|
||||
m_database = new MSSQLManager(m_ConnectionString);
|
||||
|
||||
Type t = typeof(T);
|
||||
FieldInfo[] fields = t.GetFields(BindingFlags.Public |
|
||||
BindingFlags.Instance |
|
||||
BindingFlags.DeclaredOnly);
|
||||
|
||||
if (fields.Length == 0)
|
||||
return;
|
||||
|
||||
foreach (FieldInfo f in fields)
|
||||
{
|
||||
if (f.Name != "Data")
|
||||
m_Fields[f.Name] = f;
|
||||
else
|
||||
m_DataField = f;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void CheckColumnNames(SqlDataReader reader)
|
||||
{
|
||||
if (m_ColumnNames != null)
|
||||
return;
|
||||
|
||||
m_ColumnNames = new List<string>();
|
||||
|
||||
DataTable schemaTable = reader.GetSchemaTable();
|
||||
foreach (DataRow row in schemaTable.Rows)
|
||||
{
|
||||
if (row["ColumnName"] != null &&
|
||||
(!m_Fields.ContainsKey(row["ColumnName"].ToString())))
|
||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> GetConstraints()
|
||||
{
|
||||
List<string> constraints = new List<string>();
|
||||
string query = string.Format(@"SELECT
|
||||
COL_NAME(ic.object_id,ic.column_id) AS column_name
|
||||
FROM sys.indexes AS i
|
||||
INNER JOIN sys.index_columns AS ic
|
||||
ON i.object_id = ic.object_id AND i.index_id = ic.index_id
|
||||
WHERE i.is_primary_key = 1
|
||||
AND i.object_id = OBJECT_ID('{0}');", m_Realm);
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(query, conn))
|
||||
{
|
||||
conn.Open();
|
||||
using (SqlDataReader rdr = cmd.ExecuteReader())
|
||||
{
|
||||
while (rdr.Read())
|
||||
{
|
||||
// query produces 0 to many rows of single column, so always add the first item in each row
|
||||
constraints.Add((string)rdr[0]);
|
||||
}
|
||||
}
|
||||
return constraints;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual T[] Get(string field, string key)
|
||||
{
|
||||
return Get(new string[] { field }, new string[] { key });
|
||||
}
|
||||
|
||||
public virtual T[] Get(string[] fields, string[] keys)
|
||||
{
|
||||
if (fields.Length != keys.Length)
|
||||
return new T[0];
|
||||
|
||||
List<string> terms = new List<string>();
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
|
||||
for (int i = 0; i < fields.Length; i++)
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i]));
|
||||
terms.Add("[" + fields[i] + "] = @" + fields[i]);
|
||||
}
|
||||
|
||||
string where = String.Join(" AND ", terms.ToArray());
|
||||
|
||||
string query = String.Format("SELECT * FROM {0} WHERE {1}",
|
||||
m_Realm, where);
|
||||
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = query;
|
||||
conn.Open();
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
protected T[] DoQuery(SqlCommand cmd)
|
||||
{
|
||||
List<T> result = new List<T>();
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader == null)
|
||||
return new T[0];
|
||||
|
||||
CheckColumnNames(reader);
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
T row = new T();
|
||||
|
||||
foreach (string name in m_Fields.Keys)
|
||||
{
|
||||
if (m_Fields[name].GetValue(row) is bool)
|
||||
{
|
||||
int v = Convert.ToInt32(reader[name]);
|
||||
m_Fields[name].SetValue(row, v != 0 ? true : false);
|
||||
}
|
||||
else if (m_Fields[name].GetValue(row) is UUID)
|
||||
{
|
||||
UUID uuid = UUID.Zero;
|
||||
|
||||
UUID.TryParse(reader[name].ToString(), out uuid);
|
||||
m_Fields[name].SetValue(row, uuid);
|
||||
}
|
||||
else if (m_Fields[name].GetValue(row) is int)
|
||||
{
|
||||
int v = Convert.ToInt32(reader[name]);
|
||||
m_Fields[name].SetValue(row, v);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Fields[name].SetValue(row, reader[name]);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_DataField != null)
|
||||
{
|
||||
Dictionary<string, string> data =
|
||||
new Dictionary<string, string>();
|
||||
|
||||
foreach (string col in m_ColumnNames)
|
||||
{
|
||||
data[col] = reader[col].ToString();
|
||||
if (data[col] == null)
|
||||
data[col] = String.Empty;
|
||||
}
|
||||
|
||||
m_DataField.SetValue(row, data);
|
||||
}
|
||||
|
||||
result.Add(row);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual T[] Get(string where)
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
|
||||
string query = String.Format("SELECT * FROM {0} WHERE {1}",
|
||||
m_Realm, where);
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = query;
|
||||
|
||||
//m_log.WarnFormat("[MSSQLGenericTable]: SELECT {0} WHERE {1}", m_Realm, where);
|
||||
|
||||
conn.Open();
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool Store(T row)
|
||||
{
|
||||
List<string> constraintFields = GetConstraints();
|
||||
List<KeyValuePair<string, string>> constraints = new List<KeyValuePair<string, string>>();
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
|
||||
StringBuilder query = new StringBuilder();
|
||||
List<String> names = new List<String>();
|
||||
List<String> values = new List<String>();
|
||||
|
||||
foreach (FieldInfo fi in m_Fields.Values)
|
||||
{
|
||||
names.Add(fi.Name);
|
||||
values.Add("@" + fi.Name);
|
||||
// Temporarily return more information about what field is unexpectedly null for
|
||||
// http://opensimulator.org/mantis/view.php?id=5403. This might be due to a bug in the
|
||||
// InventoryTransferModule or we may be required to substitute a DBNull here.
|
||||
if (fi.GetValue(row) == null)
|
||||
throw new NullReferenceException(
|
||||
string.Format(
|
||||
"[MSSQL GENERIC TABLE HANDLER]: Trying to store field {0} for {1} which is unexpectedly null",
|
||||
fi.Name, row));
|
||||
|
||||
if (constraintFields.Count > 0 && constraintFields.Contains(fi.Name))
|
||||
{
|
||||
constraints.Add(new KeyValuePair<string, string>(fi.Name, fi.GetValue(row).ToString()));
|
||||
}
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fi.Name, fi.GetValue(row).ToString()));
|
||||
}
|
||||
|
||||
if (m_DataField != null)
|
||||
{
|
||||
Dictionary<string, string> data =
|
||||
(Dictionary<string, string>)m_DataField.GetValue(row);
|
||||
|
||||
foreach (KeyValuePair<string, string> kvp in data)
|
||||
{
|
||||
if (constraintFields.Count > 0 && constraintFields.Contains(kvp.Key))
|
||||
{
|
||||
constraints.Add(new KeyValuePair<string, string>(kvp.Key, kvp.Key));
|
||||
}
|
||||
names.Add(kvp.Key);
|
||||
values.Add("@" + kvp.Key);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@" + kvp.Key, kvp.Value));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
query.AppendFormat("UPDATE {0} SET ", m_Realm);
|
||||
int i = 0;
|
||||
for (i = 0; i < names.Count - 1; i++)
|
||||
{
|
||||
query.AppendFormat("[{0}] = {1}, ", names[i], values[i]);
|
||||
}
|
||||
query.AppendFormat("[{0}] = {1} ", names[i], values[i]);
|
||||
if (constraints.Count > 0)
|
||||
{
|
||||
List<string> terms = new List<string>();
|
||||
for (int j = 0; j < constraints.Count; j++)
|
||||
{
|
||||
terms.Add(" [" + constraints[j].Key + "] = @" + constraints[j].Key);
|
||||
}
|
||||
string where = String.Join(" AND ", terms.ToArray());
|
||||
query.AppendFormat(" WHERE {0} ", where);
|
||||
|
||||
}
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = query.ToString();
|
||||
|
||||
conn.Open();
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
{
|
||||
//m_log.WarnFormat("[MSSQLGenericTable]: Updating {0}", m_Realm);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// assume record has not yet been inserted
|
||||
|
||||
query = new StringBuilder();
|
||||
query.AppendFormat("INSERT INTO {0} ([", m_Realm);
|
||||
query.Append(String.Join("],[", names.ToArray()));
|
||||
query.Append("]) values (" + String.Join(",", values.ToArray()) + ")");
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = query.ToString();
|
||||
//m_log.WarnFormat("[MSSQLGenericTable]: Inserting into {0}", m_Realm);
|
||||
if (conn.State != ConnectionState.Open)
|
||||
conn.Open();
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool Delete(string field, string key)
|
||||
{
|
||||
return Delete(new string[] { field }, new string[] { key });
|
||||
}
|
||||
|
||||
public virtual bool Delete(string[] fields, string[] keys)
|
||||
{
|
||||
if (fields.Length != keys.Length)
|
||||
return false;
|
||||
|
||||
List<string> terms = new List<string>();
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
for (int i = 0; i < fields.Length; i++)
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i]));
|
||||
terms.Add("[" + fields[i] + "] = @" + fields[i]);
|
||||
}
|
||||
|
||||
string where = String.Join(" AND ", terms.ToArray());
|
||||
|
||||
string query = String.Format("DELETE FROM {0} WHERE {1}", m_Realm, where);
|
||||
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = query;
|
||||
conn.Open();
|
||||
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
{
|
||||
//m_log.Warn("[MSSQLGenericTable]: " + deleteCommand);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
587
OpenSim/Data/MSSQL/MSSQLGridData.cs
Normal file
587
OpenSim/Data/MSSQL/MSSQLGridData.cs
Normal file
@@ -0,0 +1,587 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A grid data interface for MSSQL Server
|
||||
/// </summary>
|
||||
public class MSSQLGridData : GridDataBase
|
||||
{
|
||||
private const string _migrationStore = "GridStore";
|
||||
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// Database manager
|
||||
/// </summary>
|
||||
private MSSQLManager database;
|
||||
|
||||
private string m_regionsTableName = "regions";
|
||||
|
||||
#region IPlugin Members
|
||||
|
||||
// [Obsolete("Cannot be default-initialized!")]
|
||||
override public void Initialise()
|
||||
{
|
||||
m_log.Info("[GRID DB]: " + Name + " cannot be default-initialized!");
|
||||
throw new PluginNotInitialisedException(Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialises the Grid Interface
|
||||
/// </summary>
|
||||
/// <param name="connectionString">connect string</param>
|
||||
/// <remarks>use mssql_connection.ini</remarks>
|
||||
override public void Initialise(string connectionString)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(connectionString))
|
||||
{
|
||||
database = new MSSQLManager(connectionString);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: make the connect string actually do something
|
||||
IniFile iniFile = new IniFile("mssql_connection.ini");
|
||||
|
||||
string settingDataSource = iniFile.ParseFileReadValue("data_source");
|
||||
string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog");
|
||||
string settingPersistSecurityInfo = iniFile.ParseFileReadValue("persist_security_info");
|
||||
string settingUserId = iniFile.ParseFileReadValue("user_id");
|
||||
string settingPassword = iniFile.ParseFileReadValue("password");
|
||||
|
||||
m_regionsTableName = iniFile.ParseFileReadValue("regionstablename");
|
||||
if (m_regionsTableName == null)
|
||||
{
|
||||
m_regionsTableName = "regions";
|
||||
}
|
||||
|
||||
database =
|
||||
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
|
||||
settingPassword);
|
||||
}
|
||||
|
||||
//New migrations check of store
|
||||
database.CheckMigration(_migrationStore);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shuts down the grid interface
|
||||
/// </summary>
|
||||
override public void Dispose()
|
||||
{
|
||||
database = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of this DB provider.
|
||||
/// </summary>
|
||||
/// <returns>A string containing the storage system name</returns>
|
||||
override public string Name
|
||||
{
|
||||
get { return "MSSQL OpenGridData"; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Database provider version.
|
||||
/// </summary>
|
||||
/// <returns>A string containing the storage system version</returns>
|
||||
override public string Version
|
||||
{
|
||||
get { return "0.1"; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public override GridDataBase methods
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of regions within the specified ranges
|
||||
/// </summary>
|
||||
/// <param name="xmin">minimum X coordinate</param>
|
||||
/// <param name="ymin">minimum Y coordinate</param>
|
||||
/// <param name="xmax">maximum X coordinate</param>
|
||||
/// <param name="ymax">maximum Y coordinate</param>
|
||||
/// <returns>null</returns>
|
||||
/// <remarks>always return null</remarks>
|
||||
override public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax)
|
||||
{
|
||||
using (AutoClosingSqlCommand command = database.Query("SELECT * FROM regions WHERE locX >= @xmin AND locX <= @xmax AND locY >= @ymin AND locY <= @ymax"))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("xmin", xmin));
|
||||
command.Parameters.Add(database.CreateParameter("ymin", ymin));
|
||||
command.Parameters.Add(database.CreateParameter("xmax", xmax));
|
||||
command.Parameters.Add(database.CreateParameter("ymax", ymax));
|
||||
|
||||
List<RegionProfileData> rows = new List<RegionProfileData>();
|
||||
|
||||
using (SqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
rows.Add(ReadSimRow(reader));
|
||||
}
|
||||
}
|
||||
|
||||
if (rows.Count > 0)
|
||||
{
|
||||
return rows.ToArray();
|
||||
}
|
||||
}
|
||||
m_log.Info("[GRID DB] : Found no regions within range.");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns up to maxNum profiles of regions that have a name starting with namePrefix
|
||||
/// </summary>
|
||||
/// <param name="namePrefix">The name to match against</param>
|
||||
/// <param name="maxNum">Maximum number of profiles to return</param>
|
||||
/// <returns>A list of sim profiles</returns>
|
||||
override public List<RegionProfileData> GetRegionsByName (string namePrefix, uint maxNum)
|
||||
{
|
||||
using (AutoClosingSqlCommand command = database.Query("SELECT * FROM regions WHERE regionName LIKE @name"))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("name", namePrefix + "%"));
|
||||
|
||||
List<RegionProfileData> rows = new List<RegionProfileData>();
|
||||
|
||||
using (SqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
while (rows.Count < maxNum && reader.Read())
|
||||
{
|
||||
rows.Add(ReadSimRow(reader));
|
||||
}
|
||||
}
|
||||
|
||||
return rows;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a sim profile from its location
|
||||
/// </summary>
|
||||
/// <param name="handle">Region location handle</param>
|
||||
/// <returns>Sim profile</returns>
|
||||
override public RegionProfileData GetProfileByHandle(ulong handle)
|
||||
{
|
||||
using (AutoClosingSqlCommand command = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE regionHandle = @handle"))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("handle", handle));
|
||||
|
||||
using (SqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
return ReadSimRow(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_log.InfoFormat("[GRID DB] : No region found with handle : {0}", handle);
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a sim profile from its UUID
|
||||
/// </summary>
|
||||
/// <param name="uuid">The region UUID</param>
|
||||
/// <returns>The sim profile</returns>
|
||||
override public RegionProfileData GetProfileByUUID(UUID uuid)
|
||||
{
|
||||
using (AutoClosingSqlCommand command = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE uuid = @uuid"))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("uuid", uuid));
|
||||
|
||||
using (SqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
return ReadSimRow(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_log.InfoFormat("[GRID DB] : No region found with UUID : {0}", uuid);
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a sim profile from it's Region name string
|
||||
/// </summary>
|
||||
/// <param name="regionName">The region name search query</param>
|
||||
/// <returns>The sim profile</returns>
|
||||
override public RegionProfileData GetProfileByString(string regionName)
|
||||
{
|
||||
if (regionName.Length > 2)
|
||||
{
|
||||
using (AutoClosingSqlCommand command = database.Query("SELECT top 1 * FROM " + m_regionsTableName + " WHERE regionName like @regionName order by regionName"))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("regionName", regionName + "%"));
|
||||
|
||||
using (SqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
return ReadSimRow(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_log.InfoFormat("[GRID DB] : No region found with regionName : {0}", regionName);
|
||||
return null;
|
||||
}
|
||||
|
||||
m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters");
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new specified region to the database
|
||||
/// </summary>
|
||||
/// <param name="profile">The profile to add</param>
|
||||
/// <returns>A dataresponse enum indicating success</returns>
|
||||
override public DataResponse StoreProfile(RegionProfileData profile)
|
||||
{
|
||||
if (GetProfileByUUID(profile.UUID) == null)
|
||||
{
|
||||
if (InsertRegionRow(profile))
|
||||
{
|
||||
return DataResponse.RESPONSE_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UpdateRegionRow(profile))
|
||||
{
|
||||
return DataResponse.RESPONSE_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return DataResponse.RESPONSE_ERROR;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a sim profile from the database
|
||||
/// </summary>
|
||||
/// <param name="uuid">the sim UUID</param>
|
||||
/// <returns>Successful?</returns>
|
||||
//public DataResponse DeleteProfile(RegionProfileData profile)
|
||||
override public DataResponse DeleteProfile(string uuid)
|
||||
{
|
||||
using (AutoClosingSqlCommand command = database.Query("DELETE FROM regions WHERE uuid = @uuid;"))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("uuid", uuid));
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
return DataResponse.RESPONSE_OK;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.DebugFormat("[GRID DB] : Error deleting region info, error is : {0}", e.Message);
|
||||
return DataResponse.RESPONSE_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods that are not used or deprecated (still needed because of base class)
|
||||
|
||||
/// <summary>
|
||||
/// DEPRECATED. Attempts to authenticate a region by comparing a shared secret.
|
||||
/// </summary>
|
||||
/// <param name="uuid">The UUID of the challenger</param>
|
||||
/// <param name="handle">The attempted regionHandle of the challenger</param>
|
||||
/// <param name="authkey">The secret</param>
|
||||
/// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
|
||||
override public bool AuthenticateSim(UUID uuid, ulong handle, string authkey)
|
||||
{
|
||||
bool throwHissyFit = false; // Should be true by 1.0
|
||||
|
||||
if (throwHissyFit)
|
||||
throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
|
||||
|
||||
RegionProfileData data = GetProfileByUUID(uuid);
|
||||
|
||||
return (handle == data.regionHandle && authkey == data.regionSecret);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region
|
||||
/// </summary>
|
||||
/// <remarks>This requires a security audit.</remarks>
|
||||
/// <param name="uuid"></param>
|
||||
/// <param name="handle"></param>
|
||||
/// <param name="authhash"></param>
|
||||
/// <param name="challenge"></param>
|
||||
/// <returns></returns>
|
||||
public bool AuthenticateSim(UUID uuid, ulong handle, string authhash, string challenge)
|
||||
{
|
||||
// SHA512Managed HashProvider = new SHA512Managed();
|
||||
// Encoding TextProvider = new UTF8Encoding();
|
||||
|
||||
// byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge);
|
||||
// byte[] hash = HashProvider.ComputeHash(stream);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NOT IMPLEMENTED
|
||||
/// WHEN IS THIS GONNA BE IMPLEMENTED.
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <returns>null</returns>
|
||||
override public ReservationData GetReservationAtPoint(uint x, uint y)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region private methods
|
||||
|
||||
/// <summary>
|
||||
/// Reads a region row from a database reader
|
||||
/// </summary>
|
||||
/// <param name="reader">An active database reader</param>
|
||||
/// <returns>A region profile</returns>
|
||||
private static RegionProfileData ReadSimRow(IDataRecord reader)
|
||||
{
|
||||
RegionProfileData retval = new RegionProfileData();
|
||||
|
||||
// Region Main gotta-have-or-we-return-null parts
|
||||
UInt64 tmp64;
|
||||
if (!UInt64.TryParse(reader["regionHandle"].ToString(), out tmp64))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
retval.regionHandle = tmp64;
|
||||
|
||||
// UUID tmp_uuid;
|
||||
// if (!UUID.TryParse((string)reader["uuid"], out tmp_uuid))
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
retval.UUID = new UUID((Guid)reader["uuid"]); // tmp_uuid;
|
||||
|
||||
// non-critical parts
|
||||
retval.regionName = reader["regionName"].ToString();
|
||||
retval.originUUID = new UUID((Guid)reader["originUUID"]);
|
||||
|
||||
// Secrets
|
||||
retval.regionRecvKey = reader["regionRecvKey"].ToString();
|
||||
retval.regionSecret = reader["regionSecret"].ToString();
|
||||
retval.regionSendKey = reader["regionSendKey"].ToString();
|
||||
|
||||
// Region Server
|
||||
retval.regionDataURI = reader["regionDataURI"].ToString();
|
||||
retval.regionOnline = false; // Needs to be pinged before this can be set.
|
||||
retval.serverIP = reader["serverIP"].ToString();
|
||||
retval.serverPort = Convert.ToUInt32(reader["serverPort"]);
|
||||
retval.serverURI = reader["serverURI"].ToString();
|
||||
retval.httpPort = Convert.ToUInt32(reader["serverHttpPort"].ToString());
|
||||
retval.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"].ToString());
|
||||
|
||||
// Location
|
||||
retval.regionLocX = Convert.ToUInt32(reader["locX"].ToString());
|
||||
retval.regionLocY = Convert.ToUInt32(reader["locY"].ToString());
|
||||
retval.regionLocZ = Convert.ToUInt32(reader["locZ"].ToString());
|
||||
|
||||
// Neighbours - 0 = No Override
|
||||
retval.regionEastOverrideHandle = Convert.ToUInt64(reader["eastOverrideHandle"].ToString());
|
||||
retval.regionWestOverrideHandle = Convert.ToUInt64(reader["westOverrideHandle"].ToString());
|
||||
retval.regionSouthOverrideHandle = Convert.ToUInt64(reader["southOverrideHandle"].ToString());
|
||||
retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString());
|
||||
|
||||
// Assets
|
||||
retval.regionAssetURI = reader["regionAssetURI"].ToString();
|
||||
retval.regionAssetRecvKey = reader["regionAssetRecvKey"].ToString();
|
||||
retval.regionAssetSendKey = reader["regionAssetSendKey"].ToString();
|
||||
|
||||
// Userserver
|
||||
retval.regionUserURI = reader["regionUserURI"].ToString();
|
||||
retval.regionUserRecvKey = reader["regionUserRecvKey"].ToString();
|
||||
retval.regionUserSendKey = reader["regionUserSendKey"].ToString();
|
||||
|
||||
// World Map Addition
|
||||
retval.regionMapTextureID = new UUID((Guid)reader["regionMapTexture"]);
|
||||
retval.owner_uuid = new UUID((Guid)reader["owner_uuid"]);
|
||||
retval.maturity = Convert.ToUInt32(reader["access"]);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the specified region in the database
|
||||
/// </summary>
|
||||
/// <param name="profile">The profile to update</param>
|
||||
/// <returns>success ?</returns>
|
||||
private bool UpdateRegionRow(RegionProfileData profile)
|
||||
{
|
||||
bool returnval = false;
|
||||
|
||||
//Insert new region
|
||||
string sql =
|
||||
"UPDATE " + m_regionsTableName + @" SET
|
||||
[regionHandle]=@regionHandle, [regionName]=@regionName,
|
||||
[regionRecvKey]=@regionRecvKey, [regionSecret]=@regionSecret, [regionSendKey]=@regionSendKey,
|
||||
[regionDataURI]=@regionDataURI, [serverIP]=@serverIP, [serverPort]=@serverPort, [serverURI]=@serverURI,
|
||||
[locX]=@locX, [locY]=@locY, [locZ]=@locZ, [eastOverrideHandle]=@eastOverrideHandle,
|
||||
[westOverrideHandle]=@westOverrideHandle, [southOverrideHandle]=@southOverrideHandle,
|
||||
[northOverrideHandle]=@northOverrideHandle, [regionAssetURI]=@regionAssetURI,
|
||||
[regionAssetRecvKey]=@regionAssetRecvKey, [regionAssetSendKey]=@regionAssetSendKey,
|
||||
[regionUserURI]=@regionUserURI, [regionUserRecvKey]=@regionUserRecvKey, [regionUserSendKey]=@regionUserSendKey,
|
||||
[regionMapTexture]=@regionMapTexture, [serverHttpPort]=@serverHttpPort,
|
||||
[serverRemotingPort]=@serverRemotingPort, [owner_uuid]=@owner_uuid , [originUUID]=@originUUID
|
||||
where [uuid]=@uuid";
|
||||
|
||||
using (AutoClosingSqlCommand command = database.Query(sql))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("regionHandle", profile.regionHandle));
|
||||
command.Parameters.Add(database.CreateParameter("regionName", profile.regionName));
|
||||
command.Parameters.Add(database.CreateParameter("uuid", profile.UUID));
|
||||
command.Parameters.Add(database.CreateParameter("regionRecvKey", profile.regionRecvKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionSecret", profile.regionSecret));
|
||||
command.Parameters.Add(database.CreateParameter("regionSendKey", profile.regionSendKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionDataURI", profile.regionDataURI));
|
||||
command.Parameters.Add(database.CreateParameter("serverIP", profile.serverIP));
|
||||
command.Parameters.Add(database.CreateParameter("serverPort", profile.serverPort));
|
||||
command.Parameters.Add(database.CreateParameter("serverURI", profile.serverURI));
|
||||
command.Parameters.Add(database.CreateParameter("locX", profile.regionLocX));
|
||||
command.Parameters.Add(database.CreateParameter("locY", profile.regionLocY));
|
||||
command.Parameters.Add(database.CreateParameter("locZ", profile.regionLocZ));
|
||||
command.Parameters.Add(database.CreateParameter("eastOverrideHandle", profile.regionEastOverrideHandle));
|
||||
command.Parameters.Add(database.CreateParameter("westOverrideHandle", profile.regionWestOverrideHandle));
|
||||
command.Parameters.Add(database.CreateParameter("northOverrideHandle", profile.regionNorthOverrideHandle));
|
||||
command.Parameters.Add(database.CreateParameter("southOverrideHandle", profile.regionSouthOverrideHandle));
|
||||
command.Parameters.Add(database.CreateParameter("regionAssetURI", profile.regionAssetURI));
|
||||
command.Parameters.Add(database.CreateParameter("regionAssetRecvKey", profile.regionAssetRecvKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionAssetSendKey", profile.regionAssetSendKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionUserURI", profile.regionUserURI));
|
||||
command.Parameters.Add(database.CreateParameter("regionUserRecvKey", profile.regionUserRecvKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionUserSendKey", profile.regionUserSendKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionMapTexture", profile.regionMapTextureID));
|
||||
command.Parameters.Add(database.CreateParameter("serverHttpPort", profile.httpPort));
|
||||
command.Parameters.Add(database.CreateParameter("serverRemotingPort", profile.remotingPort));
|
||||
command.Parameters.Add(database.CreateParameter("owner_uuid", profile.owner_uuid));
|
||||
command.Parameters.Add(database.CreateParameter("originUUID", profile.originUUID));
|
||||
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
returnval = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[GRID DB] : Error updating region, error: " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return returnval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new region in the database
|
||||
/// </summary>
|
||||
/// <param name="profile">The region profile to insert</param>
|
||||
/// <returns>Successful?</returns>
|
||||
private bool InsertRegionRow(RegionProfileData profile)
|
||||
{
|
||||
bool returnval = false;
|
||||
|
||||
//Insert new region
|
||||
string sql =
|
||||
"INSERT INTO " + m_regionsTableName + @" ([regionHandle], [regionName], [uuid], [regionRecvKey], [regionSecret], [regionSendKey], [regionDataURI],
|
||||
[serverIP], [serverPort], [serverURI], [locX], [locY], [locZ], [eastOverrideHandle], [westOverrideHandle],
|
||||
[southOverrideHandle], [northOverrideHandle], [regionAssetURI], [regionAssetRecvKey], [regionAssetSendKey],
|
||||
[regionUserURI], [regionUserRecvKey], [regionUserSendKey], [regionMapTexture], [serverHttpPort],
|
||||
[serverRemotingPort], [owner_uuid], [originUUID], [access])
|
||||
VALUES (@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI,
|
||||
@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle,
|
||||
@southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, @regionAssetSendKey,
|
||||
@regionUserURI, @regionUserRecvKey, @regionUserSendKey, @regionMapTexture, @serverHttpPort, @serverRemotingPort, @owner_uuid, @originUUID, @access);";
|
||||
|
||||
using (AutoClosingSqlCommand command = database.Query(sql))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("regionHandle", profile.regionHandle));
|
||||
command.Parameters.Add(database.CreateParameter("regionName", profile.regionName));
|
||||
command.Parameters.Add(database.CreateParameter("uuid", profile.UUID));
|
||||
command.Parameters.Add(database.CreateParameter("regionRecvKey", profile.regionRecvKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionSecret", profile.regionSecret));
|
||||
command.Parameters.Add(database.CreateParameter("regionSendKey", profile.regionSendKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionDataURI", profile.regionDataURI));
|
||||
command.Parameters.Add(database.CreateParameter("serverIP", profile.serverIP));
|
||||
command.Parameters.Add(database.CreateParameter("serverPort", profile.serverPort));
|
||||
command.Parameters.Add(database.CreateParameter("serverURI", profile.serverURI));
|
||||
command.Parameters.Add(database.CreateParameter("locX", profile.regionLocX));
|
||||
command.Parameters.Add(database.CreateParameter("locY", profile.regionLocY));
|
||||
command.Parameters.Add(database.CreateParameter("locZ", profile.regionLocZ));
|
||||
command.Parameters.Add(database.CreateParameter("eastOverrideHandle", profile.regionEastOverrideHandle));
|
||||
command.Parameters.Add(database.CreateParameter("westOverrideHandle", profile.regionWestOverrideHandle));
|
||||
command.Parameters.Add(database.CreateParameter("northOverrideHandle", profile.regionNorthOverrideHandle));
|
||||
command.Parameters.Add(database.CreateParameter("southOverrideHandle", profile.regionSouthOverrideHandle));
|
||||
command.Parameters.Add(database.CreateParameter("regionAssetURI", profile.regionAssetURI));
|
||||
command.Parameters.Add(database.CreateParameter("regionAssetRecvKey", profile.regionAssetRecvKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionAssetSendKey", profile.regionAssetSendKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionUserURI", profile.regionUserURI));
|
||||
command.Parameters.Add(database.CreateParameter("regionUserRecvKey", profile.regionUserRecvKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionUserSendKey", profile.regionUserSendKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionMapTexture", profile.regionMapTextureID));
|
||||
command.Parameters.Add(database.CreateParameter("serverHttpPort", profile.httpPort));
|
||||
command.Parameters.Add(database.CreateParameter("serverRemotingPort", profile.remotingPort));
|
||||
command.Parameters.Add(database.CreateParameter("owner_uuid", profile.owner_uuid));
|
||||
command.Parameters.Add(database.CreateParameter("originUUID", profile.originUUID));
|
||||
command.Parameters.Add(database.CreateParameter("access", profile.maturity));
|
||||
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
returnval = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[GRID DB] : Error inserting region, error: " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return returnval;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,6 @@ namespace OpenSim.Data.MSSQL
|
||||
/// The database manager
|
||||
/// </summary>
|
||||
private MSSQLManager database;
|
||||
private string m_connectionString;
|
||||
|
||||
#region IPlugin members
|
||||
|
||||
@@ -67,9 +66,24 @@ namespace OpenSim.Data.MSSQL
|
||||
/// <remarks>use mssql_connection.ini</remarks>
|
||||
public void Initialise(string connectionString)
|
||||
{
|
||||
m_connectionString = connectionString;
|
||||
database = new MSSQLManager(connectionString);
|
||||
|
||||
if (!string.IsNullOrEmpty(connectionString))
|
||||
{
|
||||
database = new MSSQLManager(connectionString);
|
||||
}
|
||||
else
|
||||
{
|
||||
IniFile gridDataMSSqlFile = new IniFile("mssql_connection.ini");
|
||||
string settingDataSource = gridDataMSSqlFile.ParseFileReadValue("data_source");
|
||||
string settingInitialCatalog = gridDataMSSqlFile.ParseFileReadValue("initial_catalog");
|
||||
string settingPersistSecurityInfo = gridDataMSSqlFile.ParseFileReadValue("persist_security_info");
|
||||
string settingUserId = gridDataMSSqlFile.ParseFileReadValue("user_id");
|
||||
string settingPassword = gridDataMSSqlFile.ParseFileReadValue("password");
|
||||
|
||||
database =
|
||||
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
|
||||
settingPassword);
|
||||
}
|
||||
|
||||
//New migrations check of store
|
||||
database.CheckMigration(_migrationStore);
|
||||
}
|
||||
@@ -111,9 +125,6 @@ namespace OpenSim.Data.MSSQL
|
||||
/// <returns>A list of folder objects</returns>
|
||||
public List<InventoryFolderBase> getUserRootFolders(UUID user)
|
||||
{
|
||||
if (user == UUID.Zero)
|
||||
return new List<InventoryFolderBase>();
|
||||
|
||||
return getInventoryFolders(UUID.Zero, user);
|
||||
}
|
||||
|
||||
@@ -158,13 +169,11 @@ namespace OpenSim.Data.MSSQL
|
||||
/// <returns>A folder class</returns>
|
||||
public InventoryFolderBase getInventoryFolder(UUID folderID)
|
||||
{
|
||||
string sql = "SELECT * FROM inventoryfolders WHERE folderID = @folderID";
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
using (AutoClosingSqlCommand command = database.Query("SELECT * FROM inventoryfolders WHERE folderID = @folderID"))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("folderID", folderID));
|
||||
conn.Open();
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
command.Parameters.Add(database.CreateParameter("folderID", folderID));
|
||||
|
||||
using (IDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
@@ -187,32 +196,19 @@ namespace OpenSim.Data.MSSQL
|
||||
//Note maybe change this to use a Dataset that loading in all folders of a user and then go throw it that way.
|
||||
//Note this is changed so it opens only one connection to the database and not everytime it wants to get data.
|
||||
|
||||
/* NOTE: the implementation below is very inefficient (makes a separate request to get subfolders for
|
||||
* every found folder, recursively). Inventory code for other DBs has been already rewritten to get ALL
|
||||
* inventory for a specific user at once.
|
||||
*
|
||||
* Meanwhile, one little thing is corrected: getFolderHierarchy(UUID.Zero) doesn't make sense and should never
|
||||
* be used, so check for that and return an empty list.
|
||||
*/
|
||||
|
||||
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
|
||||
|
||||
if (parentID == UUID.Zero)
|
||||
return folders;
|
||||
|
||||
string sql = "SELECT * FROM inventoryfolders WHERE parentFolderID = @parentID";
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
using (AutoClosingSqlCommand command = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = @parentID"))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("@parentID", parentID));
|
||||
conn.Open();
|
||||
folders.AddRange(getInventoryFolders(cmd));
|
||||
command.Parameters.Add(database.CreateParameter("@parentID", parentID));
|
||||
|
||||
folders.AddRange(getInventoryFolders(command));
|
||||
|
||||
List<InventoryFolderBase> tempFolders = new List<InventoryFolderBase>();
|
||||
|
||||
foreach (InventoryFolderBase folderBase in folders)
|
||||
{
|
||||
tempFolders.AddRange(getFolderHierarchy(folderBase.ID, cmd));
|
||||
tempFolders.AddRange(getFolderHierarchy(folderBase.ID, command));
|
||||
}
|
||||
if (tempFolders.Count > 0)
|
||||
{
|
||||
@@ -237,19 +233,20 @@ namespace OpenSim.Data.MSSQL
|
||||
folderName = folderName.Substring(0, 64);
|
||||
m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length.ToString() + " to " + folderName.Length + " characters on add");
|
||||
}
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
|
||||
using (AutoClosingSqlCommand command = database.Query(sql))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID));
|
||||
cmd.Parameters.Add(database.CreateParameter("agentID", folder.Owner));
|
||||
cmd.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID));
|
||||
cmd.Parameters.Add(database.CreateParameter("folderName", folderName));
|
||||
cmd.Parameters.Add(database.CreateParameter("type", folder.Type));
|
||||
cmd.Parameters.Add(database.CreateParameter("version", folder.Version));
|
||||
conn.Open();
|
||||
command.Parameters.Add(database.CreateParameter("folderID", folder.ID));
|
||||
command.Parameters.Add(database.CreateParameter("agentID", folder.Owner));
|
||||
command.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID));
|
||||
command.Parameters.Add(database.CreateParameter("folderName", folderName));
|
||||
command.Parameters.Add(database.CreateParameter("type", folder.Type));
|
||||
command.Parameters.Add(database.CreateParameter("version", folder.Version));
|
||||
|
||||
try
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
//IDbCommand result = database.Query(sql, param);
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -264,12 +261,13 @@ namespace OpenSim.Data.MSSQL
|
||||
/// <param name="folder">Folder to update</param>
|
||||
public void updateInventoryFolder(InventoryFolderBase folder)
|
||||
{
|
||||
string sql = @"UPDATE inventoryfolders SET agentID = @agentID,
|
||||
string sql = @"UPDATE inventoryfolders SET folderID = @folderID,
|
||||
agentID = @agentID,
|
||||
parentFolderID = @parentFolderID,
|
||||
folderName = @folderName,
|
||||
type = @type,
|
||||
version = @version
|
||||
WHERE folderID = @folderID";
|
||||
WHERE folderID = @keyFolderID";
|
||||
|
||||
string folderName = folder.Name;
|
||||
if (folderName.Length > 64)
|
||||
@@ -277,19 +275,20 @@ namespace OpenSim.Data.MSSQL
|
||||
folderName = folderName.Substring(0, 64);
|
||||
m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length.ToString() + " to " + folderName.Length + " characters on update");
|
||||
}
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
|
||||
using (AutoClosingSqlCommand command = database.Query(sql))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID));
|
||||
cmd.Parameters.Add(database.CreateParameter("agentID", folder.Owner));
|
||||
cmd.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID));
|
||||
cmd.Parameters.Add(database.CreateParameter("folderName", folderName));
|
||||
cmd.Parameters.Add(database.CreateParameter("type", folder.Type));
|
||||
cmd.Parameters.Add(database.CreateParameter("version", folder.Version));
|
||||
conn.Open();
|
||||
command.Parameters.Add(database.CreateParameter("folderID", folder.ID));
|
||||
command.Parameters.Add(database.CreateParameter("agentID", folder.Owner));
|
||||
command.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID));
|
||||
command.Parameters.Add(database.CreateParameter("folderName", folderName));
|
||||
command.Parameters.Add(database.CreateParameter("type", folder.Type));
|
||||
command.Parameters.Add(database.CreateParameter("version", folder.Version));
|
||||
command.Parameters.Add(database.CreateParameter("@keyFolderID", folder.ID));
|
||||
|
||||
try
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -305,15 +304,14 @@ namespace OpenSim.Data.MSSQL
|
||||
public void moveInventoryFolder(InventoryFolderBase folder)
|
||||
{
|
||||
string sql = @"UPDATE inventoryfolders SET parentFolderID = @parentFolderID WHERE folderID = @folderID";
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
using (IDbCommand command = database.Query(sql))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID));
|
||||
cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID));
|
||||
conn.Open();
|
||||
command.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID));
|
||||
command.Parameters.Add(database.CreateParameter("@folderID", folder.ID));
|
||||
|
||||
try
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -328,27 +326,30 @@ namespace OpenSim.Data.MSSQL
|
||||
/// <param name="folderID">Id of folder to delete</param>
|
||||
public void deleteInventoryFolder(UUID folderID)
|
||||
{
|
||||
string sql = "SELECT * FROM inventoryfolders WHERE parentFolderID = @parentID";
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
using (SqlConnection connection = database.DatabaseConnection())
|
||||
{
|
||||
List<InventoryFolderBase> subFolders;
|
||||
cmd.Parameters.Add(database.CreateParameter("@parentID", UUID.Zero));
|
||||
conn.Open();
|
||||
subFolders = getFolderHierarchy(folderID, cmd);
|
||||
|
||||
using (SqlCommand command = new SqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = @parentID", connection))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("@parentID", UUID.Zero));
|
||||
|
||||
AutoClosingSqlCommand autoCommand = new AutoClosingSqlCommand(command);
|
||||
|
||||
subFolders = getFolderHierarchy(folderID, autoCommand);
|
||||
}
|
||||
|
||||
//Delete all sub-folders
|
||||
foreach (InventoryFolderBase f in subFolders)
|
||||
{
|
||||
DeleteOneFolder(f.ID, conn);
|
||||
DeleteItemsInFolder(f.ID, conn);
|
||||
DeleteOneFolder(f.ID, connection);
|
||||
DeleteItemsInFolder(f.ID, connection);
|
||||
}
|
||||
|
||||
//Delete the actual row
|
||||
DeleteOneFolder(folderID, conn);
|
||||
DeleteItemsInFolder(folderID, conn);
|
||||
DeleteOneFolder(folderID, connection);
|
||||
DeleteItemsInFolder(folderID, connection);
|
||||
|
||||
connection.Close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,15 +364,13 @@ namespace OpenSim.Data.MSSQL
|
||||
/// <returns>A list containing inventory items</returns>
|
||||
public List<InventoryItemBase> getInventoryInFolder(UUID folderID)
|
||||
{
|
||||
string sql = "SELECT * FROM inventoryitems WHERE parentFolderID = @parentFolderID";
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
using (AutoClosingSqlCommand command = database.Query("SELECT * FROM inventoryitems WHERE parentFolderID = @parentFolderID"))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("parentFolderID", folderID));
|
||||
conn.Open();
|
||||
command.Parameters.Add(database.CreateParameter("parentFolderID", folderID));
|
||||
|
||||
List<InventoryItemBase> items = new List<InventoryItemBase>();
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
using (SqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
@@ -389,13 +388,11 @@ namespace OpenSim.Data.MSSQL
|
||||
/// <returns>An inventory item</returns>
|
||||
public InventoryItemBase getInventoryItem(UUID itemID)
|
||||
{
|
||||
string sql = "SELECT * FROM inventoryitems WHERE inventoryID = @inventoryID";
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
using (AutoClosingSqlCommand result = database.Query("SELECT * FROM inventoryitems WHERE inventoryID = @inventoryID"))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("inventoryID", itemID));
|
||||
conn.Open();
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
result.Parameters.Add(database.CreateParameter("inventoryID", itemID));
|
||||
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
@@ -444,9 +441,8 @@ namespace OpenSim.Data.MSSQL
|
||||
itemDesc = item.Description.Substring(0, 128);
|
||||
m_log.Warn("[INVENTORY DB]: Description field truncated from " + item.Description.Length.ToString() + " to " + itemDesc.Length.ToString() + " characters");
|
||||
}
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand command = new SqlCommand(sql, conn))
|
||||
|
||||
using (AutoClosingSqlCommand command = database.Query(sql))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("inventoryID", item.ID));
|
||||
command.Parameters.Add(database.CreateParameter("assetID", item.AssetID));
|
||||
@@ -468,7 +464,7 @@ namespace OpenSim.Data.MSSQL
|
||||
command.Parameters.Add(database.CreateParameter("groupID", item.GroupID));
|
||||
command.Parameters.Add(database.CreateParameter("groupOwned", item.GroupOwned));
|
||||
command.Parameters.Add(database.CreateParameter("flags", item.Flags));
|
||||
conn.Open();
|
||||
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
@@ -480,11 +476,9 @@ namespace OpenSim.Data.MSSQL
|
||||
}
|
||||
|
||||
sql = "UPDATE inventoryfolders SET version = version + 1 WHERE folderID = @folderID";
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand command = new SqlCommand(sql, conn))
|
||||
using (AutoClosingSqlCommand command = database.Query(sql))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("folderID", item.Folder.ToString()));
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
@@ -502,7 +496,8 @@ namespace OpenSim.Data.MSSQL
|
||||
/// <param name="item">Inventory item to update</param>
|
||||
public void updateInventoryItem(InventoryItemBase item)
|
||||
{
|
||||
string sql = @"UPDATE inventoryitems SET assetID = @assetID,
|
||||
string sql = @"UPDATE inventoryitems SET inventoryID = @inventoryID,
|
||||
assetID = @assetID,
|
||||
assetType = @assetType,
|
||||
parentFolderID = @parentFolderID,
|
||||
avatarID = @avatarID,
|
||||
@@ -514,14 +509,13 @@ namespace OpenSim.Data.MSSQL
|
||||
creatorID = @creatorID,
|
||||
inventoryBasePermissions = @inventoryBasePermissions,
|
||||
inventoryEveryOnePermissions = @inventoryEveryOnePermissions,
|
||||
inventoryGroupPermissions = @inventoryGroupPermissions,
|
||||
salePrice = @salePrice,
|
||||
saleType = @saleType,
|
||||
creationDate = @creationDate,
|
||||
groupID = @groupID,
|
||||
groupOwned = @groupOwned,
|
||||
flags = @flags
|
||||
WHERE inventoryID = @inventoryID";
|
||||
WHERE inventoryID = @keyInventoryID";
|
||||
|
||||
string itemName = item.Name;
|
||||
if (item.Name.Length > 64)
|
||||
@@ -536,9 +530,8 @@ namespace OpenSim.Data.MSSQL
|
||||
itemDesc = item.Description.Substring(0, 128);
|
||||
m_log.Warn("[INVENTORY DB]: Description field truncated from " + item.Description.Length.ToString() + " to " + itemDesc.Length.ToString() + " characters on update");
|
||||
}
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand command = new SqlCommand(sql, conn))
|
||||
|
||||
using (AutoClosingSqlCommand command = database.Query(sql))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("inventoryID", item.ID));
|
||||
command.Parameters.Add(database.CreateParameter("assetID", item.AssetID));
|
||||
@@ -550,17 +543,17 @@ namespace OpenSim.Data.MSSQL
|
||||
command.Parameters.Add(database.CreateParameter("inventoryNextPermissions", item.NextPermissions));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryCurrentPermissions", item.CurrentPermissions));
|
||||
command.Parameters.Add(database.CreateParameter("invType", item.InvType));
|
||||
command.Parameters.Add(database.CreateParameter("creatorID", item.CreatorId));
|
||||
command.Parameters.Add(database.CreateParameter("creatorID", item.CreatorIdAsUuid));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryBasePermissions", item.BasePermissions));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryEveryOnePermissions", item.EveryOnePermissions));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryGroupPermissions", item.GroupPermissions));
|
||||
command.Parameters.Add(database.CreateParameter("salePrice", item.SalePrice));
|
||||
command.Parameters.Add(database.CreateParameter("saleType", item.SaleType));
|
||||
command.Parameters.Add(database.CreateParameter("creationDate", item.CreationDate));
|
||||
command.Parameters.Add(database.CreateParameter("groupID", item.GroupID));
|
||||
command.Parameters.Add(database.CreateParameter("groupOwned", item.GroupOwned));
|
||||
command.Parameters.Add(database.CreateParameter("flags", item.Flags));
|
||||
conn.Open();
|
||||
command.Parameters.Add(database.CreateParameter("@keyInventoryID", item.ID));
|
||||
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
@@ -580,15 +573,13 @@ namespace OpenSim.Data.MSSQL
|
||||
/// <param name="itemID">the item UUID</param>
|
||||
public void deleteInventoryItem(UUID itemID)
|
||||
{
|
||||
string sql = "DELETE FROM inventoryitems WHERE inventoryID=@inventoryID";
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
using (AutoClosingSqlCommand command = database.Query("DELETE FROM inventoryitems WHERE inventoryID=@inventoryID"))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("inventoryID", itemID));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryID", itemID));
|
||||
try
|
||||
{
|
||||
conn.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -616,14 +607,12 @@ namespace OpenSim.Data.MSSQL
|
||||
/// </returns>
|
||||
public List<InventoryItemBase> fetchActiveGestures(UUID avatarID)
|
||||
{
|
||||
string sql = "SELECT * FROM inventoryitems WHERE avatarId = @uuid AND assetType = @assetType and flags = 1";
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
using (AutoClosingSqlCommand command = database.Query("SELECT * FROM inventoryitems WHERE avatarId = @uuid AND assetType = @assetType and flags = 1"))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("uuid", avatarID));
|
||||
cmd.Parameters.Add(database.CreateParameter("assetType", (int)AssetType.Gesture));
|
||||
conn.Open();
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
command.Parameters.Add(database.CreateParameter("uuid", avatarID));
|
||||
command.Parameters.Add(database.CreateParameter("assetType", (int)AssetType.Gesture));
|
||||
|
||||
using (IDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
List<InventoryItemBase> gestureList = new List<InventoryItemBase>();
|
||||
while (reader.Read())
|
||||
@@ -667,7 +656,7 @@ namespace OpenSim.Data.MSSQL
|
||||
/// <param name="parentID">parent ID.</param>
|
||||
/// <param name="command">SQL command/connection to database</param>
|
||||
/// <returns></returns>
|
||||
private static List<InventoryFolderBase> getFolderHierarchy(UUID parentID, SqlCommand command)
|
||||
private static List<InventoryFolderBase> getFolderHierarchy(UUID parentID, AutoClosingSqlCommand command)
|
||||
{
|
||||
command.Parameters["@parentID"].Value = parentID.Guid; //.ToString();
|
||||
|
||||
@@ -698,9 +687,7 @@ namespace OpenSim.Data.MSSQL
|
||||
/// <returns></returns>
|
||||
private List<InventoryFolderBase> getInventoryFolders(UUID parentID, UUID user)
|
||||
{
|
||||
string sql = "SELECT * FROM inventoryfolders WHERE parentFolderID = @parentID AND agentID LIKE @uuid";
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand command = new SqlCommand(sql, conn))
|
||||
using (AutoClosingSqlCommand command = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = @parentID AND agentID LIKE @uuid"))
|
||||
{
|
||||
if (user == UUID.Zero)
|
||||
{
|
||||
@@ -711,7 +698,7 @@ namespace OpenSim.Data.MSSQL
|
||||
command.Parameters.Add(database.CreateParameter("uuid", user));
|
||||
}
|
||||
command.Parameters.Add(database.CreateParameter("parentID", parentID));
|
||||
conn.Open();
|
||||
|
||||
return getInventoryFolders(command);
|
||||
}
|
||||
}
|
||||
@@ -721,9 +708,9 @@ namespace OpenSim.Data.MSSQL
|
||||
/// </summary>
|
||||
/// <param name="command">SQLcommand.</param>
|
||||
/// <returns></returns>
|
||||
private static List<InventoryFolderBase> getInventoryFolders(SqlCommand command)
|
||||
private static List<InventoryFolderBase> getInventoryFolders(AutoClosingSqlCommand command)
|
||||
{
|
||||
using (SqlDataReader reader = command.ExecuteReader())
|
||||
using (IDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
|
||||
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
|
||||
@@ -740,14 +727,14 @@ namespace OpenSim.Data.MSSQL
|
||||
/// </summary>
|
||||
/// <param name="reader">A MSSQL Data Reader</param>
|
||||
/// <returns>A List containing inventory folders</returns>
|
||||
protected static InventoryFolderBase readInventoryFolder(SqlDataReader reader)
|
||||
protected static InventoryFolderBase readInventoryFolder(IDataReader reader)
|
||||
{
|
||||
try
|
||||
{
|
||||
InventoryFolderBase folder = new InventoryFolderBase();
|
||||
folder.Owner = DBGuid.FromDB(reader["agentID"]);
|
||||
folder.ParentID = DBGuid.FromDB(reader["parentFolderID"]);
|
||||
folder.ID = DBGuid.FromDB(reader["folderID"]);
|
||||
folder.Owner = new UUID((Guid)reader["agentID"]);
|
||||
folder.ParentID = new UUID((Guid)reader["parentFolderID"]);
|
||||
folder.ID = new UUID((Guid)reader["folderID"]);
|
||||
folder.Name = (string)reader["folderName"];
|
||||
folder.Type = (short)reader["type"];
|
||||
folder.Version = Convert.ToUInt16(reader["version"]);
|
||||
@@ -773,24 +760,24 @@ namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
InventoryItemBase item = new InventoryItemBase();
|
||||
|
||||
item.ID = DBGuid.FromDB(reader["inventoryID"]);
|
||||
item.AssetID = DBGuid.FromDB(reader["assetID"]);
|
||||
item.ID = new UUID((Guid)reader["inventoryID"]);
|
||||
item.AssetID = new UUID((Guid)reader["assetID"]);
|
||||
item.AssetType = Convert.ToInt32(reader["assetType"].ToString());
|
||||
item.Folder = DBGuid.FromDB(reader["parentFolderID"]);
|
||||
item.Owner = DBGuid.FromDB(reader["avatarID"]);
|
||||
item.Folder = new UUID((Guid)reader["parentFolderID"]);
|
||||
item.Owner = new UUID((Guid)reader["avatarID"]);
|
||||
item.Name = reader["inventoryName"].ToString();
|
||||
item.Description = reader["inventoryDescription"].ToString();
|
||||
item.NextPermissions = Convert.ToUInt32(reader["inventoryNextPermissions"]);
|
||||
item.CurrentPermissions = Convert.ToUInt32(reader["inventoryCurrentPermissions"]);
|
||||
item.InvType = Convert.ToInt32(reader["invType"].ToString());
|
||||
item.CreatorId = reader["creatorID"].ToString();
|
||||
item.CreatorId = ((Guid)reader["creatorID"]).ToString();
|
||||
item.BasePermissions = Convert.ToUInt32(reader["inventoryBasePermissions"]);
|
||||
item.EveryOnePermissions = Convert.ToUInt32(reader["inventoryEveryOnePermissions"]);
|
||||
item.GroupPermissions = Convert.ToUInt32(reader["inventoryGroupPermissions"]);
|
||||
item.SalePrice = Convert.ToInt32(reader["salePrice"]);
|
||||
item.SaleType = Convert.ToByte(reader["saleType"]);
|
||||
item.CreationDate = Convert.ToInt32(reader["creationDate"]);
|
||||
item.GroupID = DBGuid.FromDB(reader["groupID"]);
|
||||
item.GroupID = new UUID((Guid)reader["groupID"]);
|
||||
item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]);
|
||||
item.Flags = Convert.ToUInt32(reader["flags"]);
|
||||
|
||||
@@ -813,7 +800,7 @@ namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlCommand command = new SqlCommand("DELETE FROM inventoryfolders WHERE folderID=@folderID and type=-1", connection))
|
||||
using (SqlCommand command = new SqlCommand("DELETE FROM inventoryfolders WHERE folderID=@folderID", connection))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("folderID", folderID));
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
146
OpenSim/Data/MSSQL/MSSQLLogData.cs
Normal file
146
OpenSim/Data/MSSQL/MSSQLLogData.cs
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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.Reflection;
|
||||
using log4net;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface to the log database for MSSQL
|
||||
/// </summary>
|
||||
internal class MSSQLLogData : ILogDataPlugin
|
||||
{
|
||||
private const string _migrationStore = "LogStore";
|
||||
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// The database manager
|
||||
/// </summary>
|
||||
public MSSQLManager database;
|
||||
|
||||
[Obsolete("Cannot be default-initialized!")]
|
||||
public void Initialise()
|
||||
{
|
||||
m_log.Info("[LOG DB]: " + Name + " cannot be default-initialized!");
|
||||
throw new PluginNotInitialisedException (Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Artificial constructor called when the plugin is loaded
|
||||
/// </summary>
|
||||
public void Initialise(string connect)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(connect))
|
||||
{
|
||||
database = new MSSQLManager(connect);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: do something with the connect string
|
||||
IniFile gridDataMSSqlFile = new IniFile("mssql_connection.ini");
|
||||
string settingDataSource = gridDataMSSqlFile.ParseFileReadValue("data_source");
|
||||
string settingInitialCatalog = gridDataMSSqlFile.ParseFileReadValue("initial_catalog");
|
||||
string settingPersistSecurityInfo = gridDataMSSqlFile.ParseFileReadValue("persist_security_info");
|
||||
string settingUserId = gridDataMSSqlFile.ParseFileReadValue("user_id");
|
||||
string settingPassword = gridDataMSSqlFile.ParseFileReadValue("password");
|
||||
|
||||
database =
|
||||
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
|
||||
settingPassword);
|
||||
}
|
||||
|
||||
//Updating mechanisme
|
||||
database.CheckMigration(_migrationStore);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves a log item to the database
|
||||
/// </summary>
|
||||
/// <param name="serverDaemon">The daemon triggering the event</param>
|
||||
/// <param name="target">The target of the action (region / agent UUID, etc)</param>
|
||||
/// <param name="methodCall">The method call where the problem occured</param>
|
||||
/// <param name="arguments">The arguments passed to the method</param>
|
||||
/// <param name="priority">How critical is this?</param>
|
||||
/// <param name="logMessage">The message to log</param>
|
||||
public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,
|
||||
string logMessage)
|
||||
{
|
||||
string sql = "INSERT INTO logs ([target], [server], [method], [arguments], [priority], [message]) VALUES ";
|
||||
sql += "(@target, @server, @method, @arguments, @priority, @message);";
|
||||
|
||||
using (AutoClosingSqlCommand command = database.Query(sql))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("server", serverDaemon));
|
||||
command.Parameters.Add(database.CreateParameter("target",target));
|
||||
command.Parameters.Add(database.CreateParameter("method", methodCall));
|
||||
command.Parameters.Add(database.CreateParameter("arguments", arguments));
|
||||
command.Parameters.Add(database.CreateParameter("priority", priority.ToString()));
|
||||
command.Parameters.Add(database.CreateParameter("message", logMessage));
|
||||
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//Are we not in a loop here
|
||||
m_log.Error("[LOG DB] Error logging : " + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of this DB provider
|
||||
/// </summary>
|
||||
/// <returns>A string containing the DB provider name</returns>
|
||||
public string Name
|
||||
{
|
||||
get { return "MSSQL Logdata Interface"; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the database provider
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
database = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the version of this DB provider
|
||||
/// </summary>
|
||||
/// <returns>A string containing the provider version</returns>
|
||||
public string Version
|
||||
{
|
||||
get { return "0.1"; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,13 +41,28 @@ namespace OpenSim.Data.MSSQL
|
||||
/// </summary>
|
||||
public class MSSQLManager
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// Connection string for ADO.net
|
||||
/// </summary>
|
||||
private readonly string connectionString;
|
||||
|
||||
public MSSQLManager(string dataSource, string initialCatalog, string persistSecurityInfo, string userId,
|
||||
string password)
|
||||
{
|
||||
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
|
||||
|
||||
builder.DataSource = dataSource;
|
||||
builder.InitialCatalog = initialCatalog;
|
||||
builder.PersistSecurityInfo = Convert.ToBoolean(persistSecurityInfo);
|
||||
builder.UserID = userId;
|
||||
builder.Password = password;
|
||||
builder.ApplicationName = Assembly.GetEntryAssembly().Location;
|
||||
|
||||
connectionString = builder.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the manager and set the connectionstring
|
||||
/// </summary>
|
||||
@@ -57,6 +72,94 @@ namespace OpenSim.Data.MSSQL
|
||||
connectionString = connection;
|
||||
}
|
||||
|
||||
public SqlConnection DatabaseConnection()
|
||||
{
|
||||
SqlConnection conn = new SqlConnection(connectionString);
|
||||
|
||||
//TODO is this good??? Opening connection here
|
||||
conn.Open();
|
||||
|
||||
return conn;
|
||||
}
|
||||
|
||||
#region Obsolete functions, can be removed!
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="dt"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="type"></param>
|
||||
[Obsolete("Do not use!")]
|
||||
protected static void createCol(DataTable dt, string name, Type type)
|
||||
{
|
||||
DataColumn col = new DataColumn(name, type);
|
||||
dt.Columns.Add(col);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define Table function
|
||||
/// </summary>
|
||||
/// <param name="dt"></param>
|
||||
/// <returns></returns>
|
||||
/*
|
||||
[Obsolete("Do not use!")]
|
||||
protected static string defineTable(DataTable dt)
|
||||
{
|
||||
string sql = "create table " + dt.TableName + "(";
|
||||
string subsql = String.Empty;
|
||||
foreach (DataColumn col in dt.Columns)
|
||||
{
|
||||
if (subsql.Length > 0)
|
||||
{
|
||||
// a map function would rock so much here
|
||||
subsql += ",\n";
|
||||
}
|
||||
|
||||
subsql += col.ColumnName + " " + SqlType(col.DataType);
|
||||
if (col == dt.PrimaryKey[0])
|
||||
{
|
||||
subsql += " primary key";
|
||||
}
|
||||
}
|
||||
sql += subsql;
|
||||
sql += ")";
|
||||
return sql;
|
||||
}
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Type conversion function
|
||||
/// </summary>
|
||||
/// <param name="type">a type</param>
|
||||
/// <returns>a sqltype</returns>
|
||||
/// <remarks>this is something we'll need to implement for each db slightly differently.</remarks>
|
||||
/*
|
||||
[Obsolete("Used by a obsolete methods")]
|
||||
public static string SqlType(Type type)
|
||||
{
|
||||
if (type == typeof(String))
|
||||
{
|
||||
return "varchar(255)";
|
||||
}
|
||||
if (type == typeof(Int32))
|
||||
{
|
||||
return "integer";
|
||||
}
|
||||
if (type == typeof(Double))
|
||||
{
|
||||
return "float";
|
||||
}
|
||||
if (type == typeof(Byte[]))
|
||||
{
|
||||
return "image";
|
||||
}
|
||||
return "varchar(255)";
|
||||
}
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Type conversion to a SQLDbType functions
|
||||
/// </summary>
|
||||
@@ -104,11 +207,6 @@ namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
return SqlDbType.BigInt;
|
||||
}
|
||||
if (type == typeof(DateTime))
|
||||
{
|
||||
return SqlDbType.DateTime;
|
||||
}
|
||||
|
||||
return SqlDbType.VarChar;
|
||||
}
|
||||
|
||||
@@ -185,22 +283,138 @@ namespace OpenSim.Data.MSSQL
|
||||
return parameter;
|
||||
}
|
||||
|
||||
private static readonly Dictionary<string, string> emptyDictionary = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Run a query and return a sql db command
|
||||
/// </summary>
|
||||
/// <param name="sql">The SQL query.</param>
|
||||
/// <returns></returns>
|
||||
internal AutoClosingSqlCommand Query(string sql)
|
||||
{
|
||||
return Query(sql, emptyDictionary);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs a query with protection against SQL Injection by using parameterised input.
|
||||
/// </summary>
|
||||
/// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param>
|
||||
/// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param>
|
||||
/// <returns>A Sql DB Command</returns>
|
||||
internal AutoClosingSqlCommand Query(string sql, Dictionary<string, string> parameters)
|
||||
{
|
||||
SqlCommand dbcommand = DatabaseConnection().CreateCommand();
|
||||
dbcommand.CommandText = sql;
|
||||
foreach (KeyValuePair<string, string> param in parameters)
|
||||
{
|
||||
dbcommand.Parameters.AddWithValue(param.Key, param.Value);
|
||||
}
|
||||
|
||||
return new AutoClosingSqlCommand(dbcommand);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs a query with protection against SQL Injection by using parameterised input.
|
||||
/// </summary>
|
||||
/// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param>
|
||||
/// <param name="sqlParameter">A parameter - use createparameter to create parameter</param>
|
||||
/// <returns></returns>
|
||||
internal AutoClosingSqlCommand Query(string sql, SqlParameter sqlParameter)
|
||||
{
|
||||
SqlCommand dbcommand = DatabaseConnection().CreateCommand();
|
||||
dbcommand.CommandText = sql;
|
||||
dbcommand.Parameters.Add(sqlParameter);
|
||||
|
||||
return new AutoClosingSqlCommand(dbcommand);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if we need to do some migrations to the database
|
||||
/// </summary>
|
||||
/// <param name="migrationStore">migrationStore.</param>
|
||||
public void CheckMigration(string migrationStore)
|
||||
{
|
||||
using (SqlConnection connection = new SqlConnection(connectionString))
|
||||
using (SqlConnection connection = DatabaseConnection())
|
||||
{
|
||||
connection.Open();
|
||||
Assembly assem = GetType().Assembly;
|
||||
MSSQLMigration migration = new MSSQLMigration(connection, assem, migrationStore);
|
||||
|
||||
migration.Update();
|
||||
|
||||
connection.Close();
|
||||
}
|
||||
}
|
||||
|
||||
#region Old Testtable functions
|
||||
|
||||
/// <summary>
|
||||
/// Execute a SQL statement stored in a resource, as a string
|
||||
/// </summary>
|
||||
/// <param name="name">the ressource string</param>
|
||||
public void ExecuteResourceSql(string name)
|
||||
{
|
||||
using (IDbCommand cmd = Query(getResourceString(name), new Dictionary<string, string>()))
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Given a list of tables, return the version of the tables, as seen in the database
|
||||
/// </summary>
|
||||
/// <param name="tableList"></param>
|
||||
public void GetTableVersion(Dictionary<string, string> tableList)
|
||||
{
|
||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||
param["dbname"] = new SqlConnectionStringBuilder(connectionString).InitialCatalog;
|
||||
|
||||
using (IDbCommand tablesCmd =
|
||||
Query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_CATALOG=@dbname", param))
|
||||
using (IDataReader tables = tablesCmd.ExecuteReader())
|
||||
{
|
||||
while (tables.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
string tableName = (string)tables["TABLE_NAME"];
|
||||
if (tableList.ContainsKey(tableName))
|
||||
tableList[tableName] = tableName;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(e.ToString());
|
||||
}
|
||||
}
|
||||
tables.Close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
private string getResourceString(string name)
|
||||
{
|
||||
Assembly assem = GetType().Assembly;
|
||||
string[] names = assem.GetManifestResourceNames();
|
||||
|
||||
foreach (string s in names)
|
||||
if (s.EndsWith(name))
|
||||
using (Stream resource = assem.GetManifestResourceStream(s))
|
||||
{
|
||||
using (StreamReader resourceReader = new StreamReader(resource))
|
||||
{
|
||||
string resourceString = resourceReader.ReadToEnd();
|
||||
return resourceString;
|
||||
}
|
||||
}
|
||||
throw new Exception(string.Format("Resource '{0}' was not found", name));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Returns the version of this DB provider
|
||||
/// </summary>
|
||||
|
||||
@@ -29,19 +29,16 @@ using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Reflection;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
public class MSSQLMigration : Migration
|
||||
{
|
||||
public MSSQLMigration(DbConnection conn, Assembly assem, string type)
|
||||
: base(conn, assem, type)
|
||||
public MSSQLMigration(DbConnection conn, Assembly assem, string type) : base(conn, assem, type)
|
||||
{
|
||||
}
|
||||
|
||||
public MSSQLMigration(DbConnection conn, Assembly assem, string subtype, string type)
|
||||
: base(conn, assem, subtype, type)
|
||||
public MSSQLMigration(DbConnection conn, Assembly assem, string subtype, string type) : base(conn, assem, subtype, type)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -64,36 +61,10 @@ namespace OpenSim.Data.MSSQL
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Return -1 to indicate table does not exist
|
||||
return -1;
|
||||
// Something went wrong, so we're version 0
|
||||
}
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
protected override void ExecuteScript(DbConnection conn, string[] script)
|
||||
{
|
||||
if (!(conn is SqlConnection))
|
||||
{
|
||||
base.ExecuteScript(conn, script);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (string sql in script)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand(sql, (SqlConnection)conn))
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new Exception(sql);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ``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 CONTRIBUTORS 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.Data;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A MySQL Interface for the Presence Server
|
||||
/// </summary>
|
||||
public class MSSQLPresenceData : MSSQLGenericTableHandler<PresenceData>,
|
||||
IPresenceData
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public MSSQLPresenceData(string connectionString, string realm) :
|
||||
base(connectionString, realm, "Presence")
|
||||
{
|
||||
}
|
||||
|
||||
public PresenceData Get(UUID sessionID)
|
||||
{
|
||||
PresenceData[] ret = Get("SessionID",
|
||||
sessionID.ToString());
|
||||
|
||||
if (ret.Length == 0)
|
||||
return null;
|
||||
|
||||
return ret[0];
|
||||
}
|
||||
|
||||
public void LogoutRegionAgents(UUID regionID)
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
|
||||
cmd.CommandText = String.Format("DELETE FROM {0} WHERE [RegionID]=@RegionID", m_Realm);
|
||||
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString()));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
public bool ReportAgent(UUID sessionID, UUID regionID)
|
||||
{
|
||||
PresenceData[] pd = Get("SessionID", sessionID.ToString());
|
||||
if (pd.Length == 0)
|
||||
return false;
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
|
||||
cmd.CommandText = String.Format(@"UPDATE {0} SET
|
||||
[RegionID] = @RegionID
|
||||
WHERE [SessionID] = @SessionID", m_Realm);
|
||||
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@SessionID", sessionID.ToString()));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString()));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
if (cmd.ExecuteNonQuery() == 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,6 @@ namespace OpenSim.Data.MSSQL
|
||||
string sql = "select * from ["+m_Realm+"] where regionName like @regionName";
|
||||
if (scopeID != UUID.Zero)
|
||||
sql += " and ScopeID = @scopeID";
|
||||
sql += " order by regionName";
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
@@ -130,10 +129,10 @@ namespace OpenSim.Data.MSSQL
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@startX", startX));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@startY", startY));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@endX", endX));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@endY", endY));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@startX", startX.ToString()));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@startY", startY.ToString()));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@endX", endX.ToString()));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@endY", endY.ToString()));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID));
|
||||
conn.Open();
|
||||
return RunCommand(cmd);
|
||||
@@ -308,39 +307,5 @@ namespace OpenSim.Data.MSSQL
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<RegionData> GetDefaultRegions(UUID scopeID)
|
||||
{
|
||||
return Get((int)RegionFlags.DefaultRegion, scopeID);
|
||||
}
|
||||
|
||||
public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y)
|
||||
{
|
||||
List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID);
|
||||
RegionDataDistanceCompare distanceComparer = new RegionDataDistanceCompare(x, y);
|
||||
regions.Sort(distanceComparer);
|
||||
|
||||
return regions;
|
||||
}
|
||||
|
||||
public List<RegionData> GetHyperlinks(UUID scopeID)
|
||||
{
|
||||
return Get((int)RegionFlags.Hyperlink, scopeID);
|
||||
}
|
||||
|
||||
private List<RegionData> Get(int regionFlags, UUID scopeID)
|
||||
{
|
||||
string sql = "SELECT * FROM [" + m_Realm + "] WHERE (flags & " + regionFlags.ToString() + ") <> 0";
|
||||
if (scopeID != UUID.Zero)
|
||||
sql += " AND ScopeID = @scopeID";
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID));
|
||||
conn.Open();
|
||||
return RunCommand(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,211 +36,153 @@ using System.Text;
|
||||
|
||||
namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
public class MSSQLUserAccountData : MSSQLGenericTableHandler<UserAccountData>,IUserAccountData
|
||||
public class MSSQLUserAccountData : IUserAccountData
|
||||
{
|
||||
public MSSQLUserAccountData(string connectionString, string realm) :
|
||||
base(connectionString, realm, "UserAccount")
|
||||
private string m_Realm;
|
||||
private List<string> m_ColumnNames = null;
|
||||
private string m_ConnectionString;
|
||||
private MSSQLManager m_database;
|
||||
|
||||
public MSSQLUserAccountData(string connectionString, string realm)
|
||||
{
|
||||
}
|
||||
//private string m_Realm;
|
||||
//private List<string> m_ColumnNames = null;
|
||||
//private MSSQLManager m_database;
|
||||
m_Realm = realm;
|
||||
m_ConnectionString = connectionString;
|
||||
m_database = new MSSQLManager(connectionString);
|
||||
|
||||
//public MSSQLUserAccountData(string connectionString, string realm)
|
||||
//{
|
||||
// m_Realm = realm;
|
||||
// m_ConnectionString = connectionString;
|
||||
// m_database = new MSSQLManager(connectionString);
|
||||
|
||||
// using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
// {
|
||||
// conn.Open();
|
||||
// Migration m = new Migration(conn, GetType().Assembly, "UserStore");
|
||||
// m.Update();
|
||||
// }
|
||||
//}
|
||||
|
||||
//public List<UserAccountData> Query(UUID principalID, UUID scopeID, string query)
|
||||
//{
|
||||
// return null;
|
||||
//}
|
||||
|
||||
//public UserAccountData Get(UUID principalID, UUID scopeID)
|
||||
//{
|
||||
// UserAccountData ret = new UserAccountData();
|
||||
// ret.Data = new Dictionary<string, string>();
|
||||
|
||||
// string sql = string.Format("select * from {0} where UUID = @principalID", m_Realm);
|
||||
// if (scopeID != UUID.Zero)
|
||||
// sql += " and ScopeID = @scopeID";
|
||||
|
||||
// using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
// using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
// {
|
||||
// cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID));
|
||||
// cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID));
|
||||
|
||||
// conn.Open();
|
||||
// using (SqlDataReader result = cmd.ExecuteReader())
|
||||
// {
|
||||
// if (result.Read())
|
||||
// {
|
||||
// ret.PrincipalID = principalID;
|
||||
// UUID scope;
|
||||
// UUID.TryParse(result["ScopeID"].ToString(), out scope);
|
||||
// ret.ScopeID = scope;
|
||||
|
||||
// if (m_ColumnNames == null)
|
||||
// {
|
||||
// m_ColumnNames = new List<string>();
|
||||
|
||||
// DataTable schemaTable = result.GetSchemaTable();
|
||||
// foreach (DataRow row in schemaTable.Rows)
|
||||
// m_ColumnNames.Add(row["ColumnName"].ToString());
|
||||
// }
|
||||
|
||||
// foreach (string s in m_ColumnNames)
|
||||
// {
|
||||
// if (s == "UUID")
|
||||
// continue;
|
||||
// if (s == "ScopeID")
|
||||
// continue;
|
||||
|
||||
// ret.Data[s] = result[s].ToString();
|
||||
// }
|
||||
// return ret;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
//}
|
||||
|
||||
//public bool Store(UserAccountData data)
|
||||
//{
|
||||
// if (data.Data.ContainsKey("UUID"))
|
||||
// data.Data.Remove("UUID");
|
||||
// if (data.Data.ContainsKey("ScopeID"))
|
||||
// data.Data.Remove("ScopeID");
|
||||
|
||||
// string[] fields = new List<string>(data.Data.Keys).ToArray();
|
||||
|
||||
// using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
// using (SqlCommand cmd = new SqlCommand())
|
||||
// {
|
||||
// StringBuilder updateBuilder = new StringBuilder();
|
||||
// updateBuilder.AppendFormat("update {0} set ", m_Realm);
|
||||
// bool first = true;
|
||||
// foreach (string field in fields)
|
||||
// {
|
||||
// if (!first)
|
||||
// updateBuilder.Append(", ");
|
||||
// updateBuilder.AppendFormat("{0} = @{0}", field);
|
||||
|
||||
// first = false;
|
||||
// cmd.Parameters.Add(m_database.CreateParameter("@" + field, data.Data[field]));
|
||||
// }
|
||||
|
||||
// updateBuilder.Append(" where UUID = @principalID");
|
||||
|
||||
// if (data.ScopeID != UUID.Zero)
|
||||
// updateBuilder.Append(" and ScopeID = @scopeID");
|
||||
|
||||
// cmd.CommandText = updateBuilder.ToString();
|
||||
// cmd.Connection = conn;
|
||||
// cmd.Parameters.Add(m_database.CreateParameter("@principalID", data.PrincipalID));
|
||||
// cmd.Parameters.Add(m_database.CreateParameter("@scopeID", data.ScopeID));
|
||||
// conn.Open();
|
||||
|
||||
// if (cmd.ExecuteNonQuery() < 1)
|
||||
// {
|
||||
// StringBuilder insertBuilder = new StringBuilder();
|
||||
// insertBuilder.AppendFormat("insert into {0} (UUID, ScopeID, ", m_Realm);
|
||||
// insertBuilder.Append(String.Join(", ", fields));
|
||||
// insertBuilder.Append(") values (@principalID, @scopeID, @");
|
||||
// insertBuilder.Append(String.Join(", @", fields));
|
||||
// insertBuilder.Append(")");
|
||||
|
||||
// cmd.CommandText = insertBuilder.ToString();
|
||||
|
||||
// if (cmd.ExecuteNonQuery() < 1)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
//}
|
||||
|
||||
//public bool Store(UserAccountData data, UUID principalID, string token)
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
|
||||
//public bool SetDataItem(UUID principalID, string item, string value)
|
||||
//{
|
||||
// string sql = string.Format("update {0} set {1} = @{1} where UUID = @UUID", m_Realm, item);
|
||||
// using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
// using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
// {
|
||||
// cmd.Parameters.Add(m_database.CreateParameter("@" + item, value));
|
||||
// cmd.Parameters.Add(m_database.CreateParameter("@UUID", principalID));
|
||||
|
||||
// conn.Open();
|
||||
|
||||
// if (cmd.ExecuteNonQuery() > 0)
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
//}
|
||||
|
||||
//public UserAccountData[] Get(string[] keys, string[] vals)
|
||||
//{
|
||||
// return null;
|
||||
//}
|
||||
|
||||
public UserAccountData[] GetUsers(UUID scopeID, string query)
|
||||
{
|
||||
string[] words = query.Split(new char[] { ' ' });
|
||||
|
||||
for (int i = 0; i < words.Length; i++)
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
{
|
||||
if (words[i].Length < 3)
|
||||
conn.Open();
|
||||
Migration m = new Migration(conn, GetType().Assembly, "UserStore");
|
||||
m.Update();
|
||||
}
|
||||
}
|
||||
|
||||
public List<UserAccountData> Query(UUID principalID, UUID scopeID, string query)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public UserAccountData Get(UUID principalID, UUID scopeID)
|
||||
{
|
||||
UserAccountData ret = new UserAccountData();
|
||||
ret.Data = new Dictionary<string, object>();
|
||||
|
||||
string sql = string.Format("select * from {0} where UUID = @principalID", m_Realm);
|
||||
if (scopeID != UUID.Zero)
|
||||
sql += " and ScopeID = @scopeID";
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID));
|
||||
|
||||
conn.Open();
|
||||
using (SqlDataReader result = cmd.ExecuteReader())
|
||||
{
|
||||
if (i != words.Length - 1)
|
||||
Array.Copy(words, i + 1, words, i, words.Length - i - 1);
|
||||
Array.Resize(ref words, words.Length - 1);
|
||||
if (result.Read())
|
||||
{
|
||||
ret.PrincipalID = principalID;
|
||||
UUID scope;
|
||||
UUID.TryParse(result["ScopeID"].ToString(), out scope);
|
||||
ret.ScopeID = scope;
|
||||
|
||||
if (m_ColumnNames == null)
|
||||
{
|
||||
m_ColumnNames = new List<string>();
|
||||
|
||||
DataTable schemaTable = result.GetSchemaTable();
|
||||
foreach (DataRow row in schemaTable.Rows)
|
||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
||||
}
|
||||
|
||||
foreach (string s in m_ColumnNames)
|
||||
{
|
||||
if (s == "UUID")
|
||||
continue;
|
||||
if (s == "ScopeID")
|
||||
continue;
|
||||
|
||||
ret.Data[s] = result[s].ToString();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (words.Length == 0)
|
||||
return new UserAccountData[0];
|
||||
public bool Store(UserAccountData data)
|
||||
{
|
||||
if (data.Data.ContainsKey("UUID"))
|
||||
data.Data.Remove("UUID");
|
||||
if (data.Data.ContainsKey("ScopeID"))
|
||||
data.Data.Remove("ScopeID");
|
||||
|
||||
if (words.Length > 2)
|
||||
return new UserAccountData[0];
|
||||
|
||||
string sql = "";
|
||||
string[] fields = new List<string>(data.Data.Keys).ToArray();
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
if (words.Length == 1)
|
||||
StringBuilder updateBuilder = new StringBuilder();
|
||||
updateBuilder.AppendFormat("update {0} set ", m_Realm);
|
||||
bool first = true;
|
||||
foreach (string field in fields)
|
||||
{
|
||||
sql = String.Format("select * from {0} where ([ScopeID]=@ScopeID or [ScopeID]='00000000-0000-0000-0000-000000000000') and ([FirstName] like @search or [LastName] like @search)", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@search", "%" + words[0] + "%"));
|
||||
}
|
||||
else
|
||||
{
|
||||
sql = String.Format("select * from {0} where ([ScopeID]=@ScopeID or [ScopeID]='00000000-0000-0000-0000-000000000000') and ([FirstName] like @searchFirst or [LastName] like @searchLast)", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@searchFirst", "%" + words[0] + "%"));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@searchLast", "%" + words[1] + "%"));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@ScopeID", scopeID.ToString()));
|
||||
if (!first)
|
||||
updateBuilder.Append(", ");
|
||||
updateBuilder.AppendFormat("{0} = @{0}", field);
|
||||
|
||||
first = false;
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@" + field, data.Data[field]));
|
||||
}
|
||||
|
||||
updateBuilder.Append(" where UUID = @principalID");
|
||||
|
||||
if (data.ScopeID != UUID.Zero)
|
||||
updateBuilder.Append(" and ScopeID = @scopeID");
|
||||
|
||||
cmd.CommandText = updateBuilder.ToString();
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = sql;
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@principalID", data.PrincipalID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@scopeID", data.ScopeID));
|
||||
conn.Open();
|
||||
return DoQuery(cmd);
|
||||
|
||||
if (cmd.ExecuteNonQuery() < 1)
|
||||
{
|
||||
StringBuilder insertBuilder = new StringBuilder();
|
||||
insertBuilder.AppendFormat("insert into {0} (UUID, ScopeID, ", m_Realm);
|
||||
insertBuilder.Append(String.Join(", ", fields));
|
||||
insertBuilder.Append(") values (@principalID, @scopeID, @");
|
||||
insertBuilder.Append(String.Join(", @", fields));
|
||||
insertBuilder.Append(")");
|
||||
|
||||
cmd.CommandText = insertBuilder.ToString();
|
||||
|
||||
if (cmd.ExecuteNonQuery() < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool SetDataItem(UUID principalID, string item, string value)
|
||||
{
|
||||
string sql = string.Format("update {0} set {1} = @{1} where UUID = @UUID", m_Realm, item);
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@" + item, value));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@UUID", principalID));
|
||||
|
||||
conn.Open();
|
||||
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1214
OpenSim/Data/MSSQL/MSSQLUserData.cs
Normal file
1214
OpenSim/Data/MSSQL/MSSQLUserData.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,202 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* 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 OpenSimulator Project 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 THE DEVELOPERS ''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 CONTRIBUTORS 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.Data;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using System.Data.SqlClient;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using log4net;
|
||||
|
||||
namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
public class MSSQLXInventoryData : IXInventoryData
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(
|
||||
// MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private MSSQLGenericTableHandler<XInventoryFolder> m_Folders;
|
||||
private MSSQLItemHandler m_Items;
|
||||
|
||||
public MSSQLXInventoryData(string conn, string realm)
|
||||
{
|
||||
m_Folders = new MSSQLGenericTableHandler<XInventoryFolder>(
|
||||
conn, "inventoryfolders", "InventoryStore");
|
||||
m_Items = new MSSQLItemHandler(
|
||||
conn, "inventoryitems", String.Empty);
|
||||
}
|
||||
|
||||
public XInventoryFolder[] GetFolders(string[] fields, string[] vals)
|
||||
{
|
||||
return m_Folders.Get(fields, vals);
|
||||
}
|
||||
|
||||
public XInventoryItem[] GetItems(string[] fields, string[] vals)
|
||||
{
|
||||
return m_Items.Get(fields, vals);
|
||||
}
|
||||
|
||||
public bool StoreFolder(XInventoryFolder folder)
|
||||
{
|
||||
if (folder.folderName.Length > 64)
|
||||
folder.folderName = folder.folderName.Substring(0, 64);
|
||||
return m_Folders.Store(folder);
|
||||
}
|
||||
|
||||
public bool StoreItem(XInventoryItem item)
|
||||
{
|
||||
if (item.inventoryName.Length > 64)
|
||||
item.inventoryName = item.inventoryName.Substring(0, 64);
|
||||
if (item.inventoryDescription.Length > 128)
|
||||
item.inventoryDescription = item.inventoryDescription.Substring(0, 128);
|
||||
|
||||
return m_Items.Store(item);
|
||||
}
|
||||
|
||||
public bool DeleteFolders(string field, string val)
|
||||
{
|
||||
return m_Folders.Delete(field, val);
|
||||
}
|
||||
public bool DeleteFolders(string[] fields, string[] vals)
|
||||
{
|
||||
return m_Folders.Delete(fields, vals);
|
||||
}
|
||||
|
||||
public bool DeleteItems(string field, string val)
|
||||
{
|
||||
return m_Items.Delete(field, val);
|
||||
}
|
||||
public bool DeleteItems(string[] fields, string[] vals)
|
||||
{
|
||||
return m_Items.Delete(fields, vals);
|
||||
}
|
||||
public bool MoveItem(string id, string newParent)
|
||||
{
|
||||
return m_Items.MoveItem(id, newParent);
|
||||
}
|
||||
|
||||
public XInventoryItem[] GetActiveGestures(UUID principalID)
|
||||
{
|
||||
return m_Items.GetActiveGestures(principalID);
|
||||
}
|
||||
|
||||
public int GetAssetPermissions(UUID principalID, UUID assetID)
|
||||
{
|
||||
return m_Items.GetAssetPermissions(principalID, assetID);
|
||||
}
|
||||
}
|
||||
|
||||
public class MSSQLItemHandler : MSSQLGenericTableHandler<XInventoryItem>
|
||||
{
|
||||
public MSSQLItemHandler(string c, string t, string m) :
|
||||
base(c, t, m)
|
||||
{
|
||||
}
|
||||
|
||||
public bool MoveItem(string id, string newParent)
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
|
||||
cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where inventoryID = @InventoryID", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParent));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@InventoryID", id));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
return cmd.ExecuteNonQuery() == 0 ? false : true;
|
||||
}
|
||||
}
|
||||
|
||||
public XInventoryItem[] GetActiveGestures(UUID principalID)
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("select * from inventoryitems where avatarId = @uuid and assetType = @type and flags = 1", m_Realm);
|
||||
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@uuid", principalID.ToString()));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@type", (int)AssetType.Gesture));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public int GetAssetPermissions(UUID principalID, UUID assetID)
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = @PrincipalID and assetID = @AssetID group by assetID", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString()));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("@AssetID", assetID.ToString()));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
|
||||
int perms = 0;
|
||||
|
||||
if (reader.Read())
|
||||
{
|
||||
perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]);
|
||||
}
|
||||
|
||||
return perms;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public override bool Store(XInventoryItem item)
|
||||
{
|
||||
if (!base.Store(item))
|
||||
return false;
|
||||
string sql = "update inventoryfolders set version=version+1 where folderID = @folderID";
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
cmd.Parameters.AddWithValue("@folderID", item.parentFolderID.ToString());
|
||||
try
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
OpenSim/Data/MSSQL/Resources/001_AssetStore.sql
Normal file
13
OpenSim/Data/MSSQL/Resources/001_AssetStore.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
CREATE TABLE [assets] (
|
||||
[id] [varchar](36) NOT NULL,
|
||||
[name] [varchar](64) NOT NULL,
|
||||
[description] [varchar](64) NOT NULL,
|
||||
[assetType] [tinyint] NOT NULL,
|
||||
[local] [tinyint] NOT NULL,
|
||||
[temporary] [tinyint] NOT NULL,
|
||||
[data] [image] NOT NULL,
|
||||
PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
85
OpenSim/Data/MSSQL/Resources/001_EstateStore.sql
Normal file
85
OpenSim/Data/MSSQL/Resources/001_EstateStore.sql
Normal file
@@ -0,0 +1,85 @@
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE [dbo].[estate_managers](
|
||||
[EstateID] [int] NOT NULL,
|
||||
[uuid] [varchar](36) NOT NULL,
|
||||
CONSTRAINT [PK_estate_managers] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[EstateID] ASC
|
||||
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY];
|
||||
|
||||
CREATE TABLE [dbo].[estate_groups](
|
||||
[EstateID] [int] NOT NULL,
|
||||
[uuid] [varchar](36) NOT NULL,
|
||||
CONSTRAINT [PK_estate_groups] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[EstateID] ASC
|
||||
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY];
|
||||
|
||||
|
||||
CREATE TABLE [dbo].[estate_users](
|
||||
[EstateID] [int] NOT NULL,
|
||||
[uuid] [varchar](36) NOT NULL,
|
||||
CONSTRAINT [PK_estate_users] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[EstateID] ASC
|
||||
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY];
|
||||
|
||||
|
||||
CREATE TABLE [dbo].[estateban](
|
||||
[EstateID] [int] NOT NULL,
|
||||
[bannedUUID] [varchar](36) NOT NULL,
|
||||
[bannedIp] [varchar](16) NOT NULL,
|
||||
[bannedIpHostMask] [varchar](16) NOT NULL,
|
||||
[bannedNameMask] [varchar](64) NULL DEFAULT (NULL),
|
||||
CONSTRAINT [PK_estateban] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[EstateID] ASC
|
||||
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY];
|
||||
|
||||
CREATE TABLE [dbo].[estate_settings](
|
||||
[EstateID] [int] IDENTITY(1,100) NOT NULL,
|
||||
[EstateName] [varchar](64) NULL DEFAULT (NULL),
|
||||
[AbuseEmailToEstateOwner] [bit] NOT NULL,
|
||||
[DenyAnonymous] [bit] NOT NULL,
|
||||
[ResetHomeOnTeleport] [bit] NOT NULL,
|
||||
[FixedSun] [bit] NOT NULL,
|
||||
[DenyTransacted] [bit] NOT NULL,
|
||||
[BlockDwell] [bit] NOT NULL,
|
||||
[DenyIdentified] [bit] NOT NULL,
|
||||
[AllowVoice] [bit] NOT NULL,
|
||||
[UseGlobalTime] [bit] NOT NULL,
|
||||
[PricePerMeter] [int] NOT NULL,
|
||||
[TaxFree] [bit] NOT NULL,
|
||||
[AllowDirectTeleport] [bit] NOT NULL,
|
||||
[RedirectGridX] [int] NOT NULL,
|
||||
[RedirectGridY] [int] NOT NULL,
|
||||
[ParentEstateID] [int] NOT NULL,
|
||||
[SunPosition] [float] NOT NULL,
|
||||
[EstateSkipScripts] [bit] NOT NULL,
|
||||
[BillableFactor] [float] NOT NULL,
|
||||
[PublicAccess] [bit] NOT NULL,
|
||||
[AbuseEmail] [varchar](255) NOT NULL,
|
||||
[EstateOwner] [varchar](36) NOT NULL,
|
||||
[DenyMinors] [bit] NOT NULL,
|
||||
CONSTRAINT [PK_estate_settings] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[EstateID] ASC
|
||||
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY];
|
||||
|
||||
|
||||
CREATE TABLE [dbo].[estate_map](
|
||||
[RegionID] [varchar](36) NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
|
||||
[EstateID] [int] NOT NULL,
|
||||
CONSTRAINT [PK_estate_map] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[RegionID] ASC
|
||||
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY];
|
||||
|
||||
COMMIT
|
||||
37
OpenSim/Data/MSSQL/Resources/001_GridStore.sql
Normal file
37
OpenSim/Data/MSSQL/Resources/001_GridStore.sql
Normal file
@@ -0,0 +1,37 @@
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE [dbo].[regions](
|
||||
[regionHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionName] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[uuid] [varchar](255) COLLATE Latin1_General_CI_AS NOT NULL,
|
||||
[regionRecvKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionSecret] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionSendKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionDataURI] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[serverIP] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[serverPort] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[serverURI] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[locX] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[locY] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[locZ] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[eastOverrideHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[westOverrideHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[southOverrideHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[northOverrideHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionAssetURI] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionAssetRecvKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionAssetSendKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionUserURI] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionUserRecvKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionUserSendKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionMapTexture] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[serverHttpPort] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[serverRemotingPort] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[owner_uuid] [varchar](36) COLLATE Latin1_General_CI_AS NULL,
|
||||
PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[uuid] ASC
|
||||
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
||||
64
OpenSim/Data/MSSQL/Resources/001_InventoryStore.sql
Normal file
64
OpenSim/Data/MSSQL/Resources/001_InventoryStore.sql
Normal file
@@ -0,0 +1,64 @@
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE [inventoryfolders] (
|
||||
[folderID] [varchar](36) NOT NULL default '',
|
||||
[agentID] [varchar](36) default NULL,
|
||||
[parentFolderID] [varchar](36) default NULL,
|
||||
[folderName] [varchar](64) default NULL,
|
||||
[type] [smallint] NOT NULL default 0,
|
||||
[version] [int] NOT NULL default 0,
|
||||
PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[folderID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX [owner] ON [inventoryfolders]
|
||||
(
|
||||
[agentID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX [parent] ON [inventoryfolders]
|
||||
(
|
||||
[parentFolderID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
|
||||
CREATE TABLE [inventoryitems] (
|
||||
[inventoryID] [varchar](36) NOT NULL default '',
|
||||
[assetID] [varchar](36) default NULL,
|
||||
[assetType] [int] default NULL,
|
||||
[parentFolderID] [varchar](36) default NULL,
|
||||
[avatarID] [varchar](36) default NULL,
|
||||
[inventoryName] [varchar](64) default NULL,
|
||||
[inventoryDescription] [varchar](128) default NULL,
|
||||
[inventoryNextPermissions] [int] default NULL,
|
||||
[inventoryCurrentPermissions] [int] default NULL,
|
||||
[invType] [int] default NULL,
|
||||
[creatorID] [varchar](36) default NULL,
|
||||
[inventoryBasePermissions] [int] NOT NULL default 0,
|
||||
[inventoryEveryOnePermissions] [int] NOT NULL default 0,
|
||||
[salePrice] [int] default NULL,
|
||||
[saleType] [tinyint] default NULL,
|
||||
[creationDate] [int] default NULL,
|
||||
[groupID] [varchar](36) default NULL,
|
||||
[groupOwned] [bit] default NULL,
|
||||
[flags] [int] default NULL,
|
||||
PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[inventoryID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
|
||||
CREATE NONCLUSTERED INDEX [owner] ON [inventoryitems]
|
||||
(
|
||||
[avatarID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX [folder] ON [inventoryitems]
|
||||
(
|
||||
[parentFolderID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
||||
@@ -1,5 +1,3 @@
|
||||
:VERSION 1
|
||||
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE [logs] (
|
||||
161
OpenSim/Data/MSSQL/Resources/001_RegionStore.sql
Normal file
161
OpenSim/Data/MSSQL/Resources/001_RegionStore.sql
Normal file
@@ -0,0 +1,161 @@
|
||||
CREATE TABLE [dbo].[prims](
|
||||
[UUID] [varchar](255) NOT NULL,
|
||||
[RegionUUID] [varchar](255) NULL,
|
||||
[ParentID] [int] NULL,
|
||||
[CreationDate] [int] NULL,
|
||||
[Name] [varchar](255) NULL,
|
||||
[SceneGroupID] [varchar](255) NULL,
|
||||
[Text] [varchar](255) NULL,
|
||||
[Description] [varchar](255) NULL,
|
||||
[SitName] [varchar](255) NULL,
|
||||
[TouchName] [varchar](255) NULL,
|
||||
[ObjectFlags] [int] NULL,
|
||||
[CreatorID] [varchar](255) NULL,
|
||||
[OwnerID] [varchar](255) NULL,
|
||||
[GroupID] [varchar](255) NULL,
|
||||
[LastOwnerID] [varchar](255) NULL,
|
||||
[OwnerMask] [int] NULL,
|
||||
[NextOwnerMask] [int] NULL,
|
||||
[GroupMask] [int] NULL,
|
||||
[EveryoneMask] [int] NULL,
|
||||
[BaseMask] [int] NULL,
|
||||
[PositionX] [float] NULL,
|
||||
[PositionY] [float] NULL,
|
||||
[PositionZ] [float] NULL,
|
||||
[GroupPositionX] [float] NULL,
|
||||
[GroupPositionY] [float] NULL,
|
||||
[GroupPositionZ] [float] NULL,
|
||||
[VelocityX] [float] NULL,
|
||||
[VelocityY] [float] NULL,
|
||||
[VelocityZ] [float] NULL,
|
||||
[AngularVelocityX] [float] NULL,
|
||||
[AngularVelocityY] [float] NULL,
|
||||
[AngularVelocityZ] [float] NULL,
|
||||
[AccelerationX] [float] NULL,
|
||||
[AccelerationY] [float] NULL,
|
||||
[AccelerationZ] [float] NULL,
|
||||
[RotationX] [float] NULL,
|
||||
[RotationY] [float] NULL,
|
||||
[RotationZ] [float] NULL,
|
||||
[RotationW] [float] NULL,
|
||||
[SitTargetOffsetX] [float] NULL,
|
||||
[SitTargetOffsetY] [float] NULL,
|
||||
[SitTargetOffsetZ] [float] NULL,
|
||||
[SitTargetOrientW] [float] NULL,
|
||||
[SitTargetOrientX] [float] NULL,
|
||||
[SitTargetOrientY] [float] NULL,
|
||||
[SitTargetOrientZ] [float] NULL,
|
||||
PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[UUID] ASC
|
||||
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
CREATE TABLE [dbo].[primshapes](
|
||||
[UUID] [varchar](255) NOT NULL,
|
||||
[Shape] [int] NULL,
|
||||
[ScaleX] [float] NULL,
|
||||
[ScaleY] [float] NULL,
|
||||
[ScaleZ] [float] NULL,
|
||||
[PCode] [int] NULL,
|
||||
[PathBegin] [int] NULL,
|
||||
[PathEnd] [int] NULL,
|
||||
[PathScaleX] [int] NULL,
|
||||
[PathScaleY] [int] NULL,
|
||||
[PathShearX] [int] NULL,
|
||||
[PathShearY] [int] NULL,
|
||||
[PathSkew] [int] NULL,
|
||||
[PathCurve] [int] NULL,
|
||||
[PathRadiusOffset] [int] NULL,
|
||||
[PathRevolutions] [int] NULL,
|
||||
[PathTaperX] [int] NULL,
|
||||
[PathTaperY] [int] NULL,
|
||||
[PathTwist] [int] NULL,
|
||||
[PathTwistBegin] [int] NULL,
|
||||
[ProfileBegin] [int] NULL,
|
||||
[ProfileEnd] [int] NULL,
|
||||
[ProfileCurve] [int] NULL,
|
||||
[ProfileHollow] [int] NULL,
|
||||
[State] [int] NULL,
|
||||
[Texture] [image] NULL,
|
||||
[ExtraParams] [image] NULL,
|
||||
PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[UUID] ASC
|
||||
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
|
||||
CREATE TABLE [dbo].[primitems](
|
||||
[itemID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
|
||||
[primID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[assetID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[parentFolderID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[invType] [int] NULL,
|
||||
[assetType] [int] NULL,
|
||||
[name] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[description] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[creationDate] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[creatorID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[ownerID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[lastOwnerID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[groupID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[nextPermissions] [int] NULL,
|
||||
[currentPermissions] [int] NULL,
|
||||
[basePermissions] [int] NULL,
|
||||
[everyonePermissions] [int] NULL,
|
||||
[groupPermissions] [int] NULL,
|
||||
PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[itemID] ASC
|
||||
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
CREATE TABLE [dbo].[terrain](
|
||||
[RegionUUID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[Revision] [int] NULL,
|
||||
[Heightfield] [image] NULL
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
|
||||
CREATE TABLE [dbo].[land](
|
||||
[UUID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
|
||||
[RegionUUID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[LocalLandID] [int] NULL,
|
||||
[Bitmap] [image] NULL,
|
||||
[Name] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[Description] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[OwnerUUID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[IsGroupOwned] [int] NULL,
|
||||
[Area] [int] NULL,
|
||||
[AuctionID] [int] NULL,
|
||||
[Category] [int] NULL,
|
||||
[ClaimDate] [int] NULL,
|
||||
[ClaimPrice] [int] NULL,
|
||||
[GroupUUID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[SalePrice] [int] NULL,
|
||||
[LandStatus] [int] NULL,
|
||||
[LandFlags] [int] NULL,
|
||||
[LandingType] [int] NULL,
|
||||
[MediaAutoScale] [int] NULL,
|
||||
[MediaTextureUUID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[MediaURL] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[MusicURL] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[PassHours] [float] NULL,
|
||||
[PassPrice] [int] NULL,
|
||||
[SnapshotUUID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[UserLocationX] [float] NULL,
|
||||
[UserLocationY] [float] NULL,
|
||||
[UserLocationZ] [float] NULL,
|
||||
[UserLookAtX] [float] NULL,
|
||||
[UserLookAtY] [float] NULL,
|
||||
[UserLookAtZ] [float] NULL,
|
||||
PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[UUID] ASC
|
||||
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
|
||||
CREATE TABLE [dbo].[landaccesslist](
|
||||
[LandUUID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[AccessUUID] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
[Flags] [int] NULL
|
||||
) ON [PRIMARY]
|
||||
112
OpenSim/Data/MSSQL/Resources/001_UserStore.sql
Normal file
112
OpenSim/Data/MSSQL/Resources/001_UserStore.sql
Normal file
@@ -0,0 +1,112 @@
|
||||
CREATE TABLE [users] (
|
||||
[UUID] [varchar](36) NOT NULL default '',
|
||||
[username] [varchar](32) NOT NULL,
|
||||
[lastname] [varchar](32) NOT NULL,
|
||||
[passwordHash] [varchar](32) NOT NULL,
|
||||
[passwordSalt] [varchar](32) NOT NULL,
|
||||
[homeRegion] [bigint] default NULL,
|
||||
[homeLocationX] [float] default NULL,
|
||||
[homeLocationY] [float] default NULL,
|
||||
[homeLocationZ] [float] default NULL,
|
||||
[homeLookAtX] [float] default NULL,
|
||||
[homeLookAtY] [float] default NULL,
|
||||
[homeLookAtZ] [float] default NULL,
|
||||
[created] [int] NOT NULL,
|
||||
[lastLogin] [int] NOT NULL,
|
||||
[userInventoryURI] [varchar](255) default NULL,
|
||||
[userAssetURI] [varchar](255) default NULL,
|
||||
[profileCanDoMask] [int] default NULL,
|
||||
[profileWantDoMask] [int] default NULL,
|
||||
[profileAboutText] [ntext],
|
||||
[profileFirstText] [ntext],
|
||||
[profileImage] [varchar](36) default NULL,
|
||||
[profileFirstImage] [varchar](36) default NULL,
|
||||
[webLoginKey] [varchar](36) default NULL,
|
||||
PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[UUID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
|
||||
CREATE NONCLUSTERED INDEX [usernames] ON [users]
|
||||
(
|
||||
[username] ASC,
|
||||
[lastname] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
|
||||
CREATE TABLE [agents] (
|
||||
[UUID] [varchar](36) NOT NULL,
|
||||
[sessionID] [varchar](36) NOT NULL,
|
||||
[secureSessionID] [varchar](36) NOT NULL,
|
||||
[agentIP] [varchar](16) NOT NULL,
|
||||
[agentPort] [int] NOT NULL,
|
||||
[agentOnline] [tinyint] NOT NULL,
|
||||
[loginTime] [int] NOT NULL,
|
||||
[logoutTime] [int] NOT NULL,
|
||||
[currentRegion] [varchar](36) NOT NULL,
|
||||
[currentHandle] [bigint] NOT NULL,
|
||||
[currentPos] [varchar](64) NOT NULL,
|
||||
PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[UUID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
|
||||
CREATE NONCLUSTERED INDEX [session] ON [agents]
|
||||
(
|
||||
[sessionID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX [ssession] ON [agents]
|
||||
(
|
||||
[secureSessionID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
|
||||
CREATE TABLE [dbo].[userfriends](
|
||||
[ownerID] [varchar](50) COLLATE Latin1_General_CI_AS NOT NULL,
|
||||
[friendID] [varchar](50) COLLATE Latin1_General_CI_AS NOT NULL,
|
||||
[friendPerms] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
|
||||
[datetimestamp] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
|
||||
) ON [PRIMARY]
|
||||
|
||||
CREATE TABLE [avatarappearance] (
|
||||
[Owner] [varchar](36) NOT NULL,
|
||||
[Serial] int NOT NULL,
|
||||
[Visual_Params] [image] NOT NULL,
|
||||
[Texture] [image] NOT NULL,
|
||||
[Avatar_Height] float NOT NULL,
|
||||
[Body_Item] [varchar](36) NOT NULL,
|
||||
[Body_Asset] [varchar](36) NOT NULL,
|
||||
[Skin_Item] [varchar](36) NOT NULL,
|
||||
[Skin_Asset] [varchar](36) NOT NULL,
|
||||
[Hair_Item] [varchar](36) NOT NULL,
|
||||
[Hair_Asset] [varchar](36) NOT NULL,
|
||||
[Eyes_Item] [varchar](36) NOT NULL,
|
||||
[Eyes_Asset] [varchar](36) NOT NULL,
|
||||
[Shirt_Item] [varchar](36) NOT NULL,
|
||||
[Shirt_Asset] [varchar](36) NOT NULL,
|
||||
[Pants_Item] [varchar](36) NOT NULL,
|
||||
[Pants_Asset] [varchar](36) NOT NULL,
|
||||
[Shoes_Item] [varchar](36) NOT NULL,
|
||||
[Shoes_Asset] [varchar](36) NOT NULL,
|
||||
[Socks_Item] [varchar](36) NOT NULL,
|
||||
[Socks_Asset] [varchar](36) NOT NULL,
|
||||
[Jacket_Item] [varchar](36) NOT NULL,
|
||||
[Jacket_Asset] [varchar](36) NOT NULL,
|
||||
[Gloves_Item] [varchar](36) NOT NULL,
|
||||
[Gloves_Asset] [varchar](36) NOT NULL,
|
||||
[Undershirt_Item] [varchar](36) NOT NULL,
|
||||
[Undershirt_Asset] [varchar](36) NOT NULL,
|
||||
[Underpants_Item] [varchar](36) NOT NULL,
|
||||
[Underpants_Asset] [varchar](36) NOT NULL,
|
||||
[Skirt_Item] [varchar](36) NOT NULL,
|
||||
[Skirt_Asset] [varchar](36) NOT NULL,
|
||||
|
||||
PRIMARY KEY CLUSTERED (
|
||||
[Owner]
|
||||
) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
29
OpenSim/Data/MSSQL/Resources/002_AssetStore.sql
Normal file
29
OpenSim/Data/MSSQL/Resources/002_AssetStore.sql
Normal file
@@ -0,0 +1,29 @@
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE Tmp_assets
|
||||
(
|
||||
id varchar(36) NOT NULL,
|
||||
name varchar(64) NOT NULL,
|
||||
description varchar(64) NOT NULL,
|
||||
assetType tinyint NOT NULL,
|
||||
local bit NOT NULL,
|
||||
temporary bit NOT NULL,
|
||||
data image NOT NULL
|
||||
) ON [PRIMARY]
|
||||
TEXTIMAGE_ON [PRIMARY]
|
||||
|
||||
IF EXISTS(SELECT * FROM assets)
|
||||
EXEC('INSERT INTO Tmp_assets (id, name, description, assetType, local, temporary, data)
|
||||
SELECT id, name, description, assetType, CONVERT(bit, local), CONVERT(bit, temporary), data FROM assets WITH (HOLDLOCK TABLOCKX)')
|
||||
|
||||
DROP TABLE assets
|
||||
|
||||
EXECUTE sp_rename N'Tmp_assets', N'assets', 'OBJECT'
|
||||
|
||||
ALTER TABLE dbo.assets ADD CONSTRAINT
|
||||
PK__assets__id PRIMARY KEY CLUSTERED
|
||||
(
|
||||
id
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
||||
25
OpenSim/Data/MSSQL/Resources/002_EstateStore.sql
Normal file
25
OpenSim/Data/MSSQL/Resources/002_EstateStore.sql
Normal file
@@ -0,0 +1,25 @@
|
||||
BEGIN TRANSACTION
|
||||
|
||||
ALTER TABLE dbo.estate_managers DROP CONSTRAINT PK_estate_managers
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_estate_managers ON dbo.estate_managers
|
||||
(
|
||||
EstateID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
ALTER TABLE dbo.estate_groups DROP CONSTRAINT PK_estate_groups
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_estate_groups ON dbo.estate_groups
|
||||
(
|
||||
EstateID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
|
||||
ALTER TABLE dbo.estate_users DROP CONSTRAINT PK_estate_users
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_estate_users ON dbo.estate_users
|
||||
(
|
||||
EstateID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
||||
49
OpenSim/Data/MSSQL/Resources/002_GridStore.sql
Normal file
49
OpenSim/Data/MSSQL/Resources/002_GridStore.sql
Normal file
@@ -0,0 +1,49 @@
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE Tmp_regions
|
||||
(
|
||||
uuid varchar(36) COLLATE Latin1_General_CI_AS NOT NULL,
|
||||
regionHandle bigint NULL,
|
||||
regionName varchar(20) NULL,
|
||||
regionRecvKey varchar(128) NULL,
|
||||
regionSendKey varchar(128) NULL,
|
||||
regionSecret varchar(128) NULL,
|
||||
regionDataURI varchar(128) NULL,
|
||||
serverIP varchar(64) NULL,
|
||||
serverPort int NULL,
|
||||
serverURI varchar(255) NULL,
|
||||
locX int NULL,
|
||||
locY int NULL,
|
||||
locZ int NULL,
|
||||
eastOverrideHandle bigint NULL,
|
||||
westOverrideHandle bigint NULL,
|
||||
southOverrideHandle bigint NULL,
|
||||
northOverrideHandle bigint NULL,
|
||||
regionAssetURI varchar(255) NULL,
|
||||
regionAssetRecvKey varchar(128) NULL,
|
||||
regionAssetSendKey varchar(128) NULL,
|
||||
regionUserURI varchar(255) NULL,
|
||||
regionUserRecvKey varchar(128) NULL,
|
||||
regionUserSendKey varchar(128) NULL,
|
||||
regionMapTexture varchar(36) NULL,
|
||||
serverHttpPort int NULL,
|
||||
serverRemotingPort int NULL,
|
||||
owner_uuid varchar(36) NULL,
|
||||
originUUID varchar(36) NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000')
|
||||
) ON [PRIMARY]
|
||||
|
||||
IF EXISTS(SELECT * FROM regions)
|
||||
EXEC('INSERT INTO Tmp_regions (uuid, regionHandle, regionName, regionRecvKey, regionSendKey, regionSecret, regionDataURI, serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort, owner_uuid)
|
||||
SELECT CONVERT(varchar(36), uuid), CONVERT(bigint, regionHandle), CONVERT(varchar(20), regionName), CONVERT(varchar(128), regionRecvKey), CONVERT(varchar(128), regionSendKey), CONVERT(varchar(128), regionSecret), CONVERT(varchar(128), regionDataURI), CONVERT(varchar(64), serverIP), CONVERT(int, serverPort), serverURI, CONVERT(int, locX), CONVERT(int, locY), CONVERT(int, locZ), CONVERT(bigint, eastOverrideHandle), CONVERT(bigint, westOverrideHandle), CONVERT(bigint, southOverrideHandle), CONVERT(bigint, northOverrideHandle), regionAssetURI, CONVERT(varchar(128), regionAssetRecvKey), CONVERT(varchar(128), regionAssetSendKey), regionUserURI, CONVERT(varchar(128), regionUserRecvKey), CONVERT(varchar(128), regionUserSendKey), CONVERT(varchar(36), regionMapTexture), CONVERT(int, serverHttpPort), CONVERT(int, serverRemotingPort), owner_uuid FROM regions')
|
||||
|
||||
DROP TABLE regions
|
||||
|
||||
EXECUTE sp_rename N'Tmp_regions', N'regions', 'OBJECT'
|
||||
|
||||
ALTER TABLE regions ADD CONSTRAINT
|
||||
PK__regions__uuid PRIMARY KEY CLUSTERED
|
||||
(
|
||||
uuid
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
||||
5
OpenSim/Data/MSSQL/Resources/002_InventoryStore.sql
Normal file
5
OpenSim/Data/MSSQL/Resources/002_InventoryStore.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
BEGIN TRANSACTION
|
||||
|
||||
ALTER TABLE inventoryitems ADD inventoryGroupPermissions INTEGER NOT NULL default 0
|
||||
|
||||
COMMIT
|
||||
50
OpenSim/Data/MSSQL/Resources/002_RegionStore.sql
Normal file
50
OpenSim/Data/MSSQL/Resources/002_RegionStore.sql
Normal file
@@ -0,0 +1,50 @@
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE regionban (
|
||||
[regionUUID] VARCHAR(36) NOT NULL,
|
||||
[bannedUUID] VARCHAR(36) NOT NULL,
|
||||
[bannedIp] VARCHAR(16) NOT NULL,
|
||||
[bannedIpHostMask] VARCHAR(16) NOT NULL)
|
||||
|
||||
create table [dbo].[regionsettings] (
|
||||
[regionUUID] [varchar](36) not null,
|
||||
[block_terraform] [bit] not null,
|
||||
[block_fly] [bit] not null,
|
||||
[allow_damage] [bit] not null,
|
||||
[restrict_pushing] [bit] not null,
|
||||
[allow_land_resell] [bit] not null,
|
||||
[allow_land_join_divide] [bit] not null,
|
||||
[block_show_in_search] [bit] not null,
|
||||
[agent_limit] [int] not null,
|
||||
[object_bonus] [float] not null,
|
||||
[maturity] [int] not null,
|
||||
[disable_scripts] [bit] not null,
|
||||
[disable_collisions] [bit] not null,
|
||||
[disable_physics] [bit] not null,
|
||||
[terrain_texture_1] [varchar](36) not null,
|
||||
[terrain_texture_2] [varchar](36) not null,
|
||||
[terrain_texture_3] [varchar](36) not null,
|
||||
[terrain_texture_4] [varchar](36) not null,
|
||||
[elevation_1_nw] [float] not null,
|
||||
[elevation_2_nw] [float] not null,
|
||||
[elevation_1_ne] [float] not null,
|
||||
[elevation_2_ne] [float] not null,
|
||||
[elevation_1_se] [float] not null,
|
||||
[elevation_2_se] [float] not null,
|
||||
[elevation_1_sw] [float] not null,
|
||||
[elevation_2_sw] [float] not null,
|
||||
[water_height] [float] not null,
|
||||
[terrain_raise_limit] [float] not null,
|
||||
[terrain_lower_limit] [float] not null,
|
||||
[use_estate_sun] [bit] not null,
|
||||
[fixed_sun] [bit] not null,
|
||||
[sun_position] [float] not null,
|
||||
[covenant] [varchar](36) default NULL,
|
||||
[Sandbox] [bit] NOT NULL,
|
||||
PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[regionUUID] ASC
|
||||
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
||||
9
OpenSim/Data/MSSQL/Resources/002_UserStore.sql
Normal file
9
OpenSim/Data/MSSQL/Resources/002_UserStore.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
BEGIN TRANSACTION
|
||||
|
||||
ALTER TABLE users ADD homeRegionID varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000';
|
||||
ALTER TABLE users ADD userFlags int NOT NULL default 0;
|
||||
ALTER TABLE users ADD godLevel int NOT NULL default 0;
|
||||
ALTER TABLE users ADD customType varchar(32) not null default '';
|
||||
ALTER TABLE users ADD partner varchar(36) not null default '00000000-0000-0000-0000-000000000000';
|
||||
|
||||
COMMIT
|
||||
6
OpenSim/Data/MSSQL/Resources/003_AssetStore.sql
Normal file
6
OpenSim/Data/MSSQL/Resources/003_AssetStore.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
BEGIN TRANSACTION
|
||||
|
||||
ALTER TABLE assets add create_time integer default 0
|
||||
ALTER TABLE assets add access_time integer default 0
|
||||
|
||||
COMMIT
|
||||
25
OpenSim/Data/MSSQL/Resources/003_EstateStore.sql
Normal file
25
OpenSim/Data/MSSQL/Resources/003_EstateStore.sql
Normal file
@@ -0,0 +1,25 @@
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE dbo.Tmp_estateban
|
||||
(
|
||||
EstateID int NOT NULL,
|
||||
bannedUUID varchar(36) NOT NULL,
|
||||
bannedIp varchar(16) NULL,
|
||||
bannedIpHostMask varchar(16) NULL,
|
||||
bannedNameMask varchar(64) NULL
|
||||
) ON [PRIMARY]
|
||||
|
||||
IF EXISTS(SELECT * FROM dbo.estateban)
|
||||
EXEC('INSERT INTO dbo.Tmp_estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask)
|
||||
SELECT EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask FROM dbo.estateban')
|
||||
|
||||
DROP TABLE dbo.estateban
|
||||
|
||||
EXECUTE sp_rename N'dbo.Tmp_estateban', N'estateban', 'OBJECT'
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_estateban ON dbo.estateban
|
||||
(
|
||||
EstateID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
||||
22
OpenSim/Data/MSSQL/Resources/003_GridStore.sql
Normal file
22
OpenSim/Data/MSSQL/Resources/003_GridStore.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_regions_name ON dbo.regions
|
||||
(
|
||||
regionName
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_regions_handle ON dbo.regions
|
||||
(
|
||||
regionHandle
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_regions_override ON dbo.regions
|
||||
(
|
||||
eastOverrideHandle,
|
||||
westOverrideHandle,
|
||||
southOverrideHandle,
|
||||
northOverrideHandle
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
||||
38
OpenSim/Data/MSSQL/Resources/003_InventoryStore.sql
Normal file
38
OpenSim/Data/MSSQL/Resources/003_InventoryStore.sql
Normal file
@@ -0,0 +1,38 @@
|
||||
/* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE dbo.Tmp_inventoryfolders
|
||||
(
|
||||
folderID uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
|
||||
agentID uniqueidentifier NULL DEFAULT (NULL),
|
||||
parentFolderID uniqueidentifier NULL DEFAULT (NULL),
|
||||
folderName varchar(64) NULL DEFAULT (NULL),
|
||||
type smallint NOT NULL DEFAULT ((0)),
|
||||
version int NOT NULL DEFAULT ((0))
|
||||
) ON [PRIMARY]
|
||||
|
||||
IF EXISTS(SELECT * FROM dbo.inventoryfolders)
|
||||
EXEC('INSERT INTO dbo.Tmp_inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version)
|
||||
SELECT CONVERT(uniqueidentifier, folderID), CONVERT(uniqueidentifier, agentID), CONVERT(uniqueidentifier, parentFolderID), folderName, type, version FROM dbo.inventoryfolders WITH (HOLDLOCK TABLOCKX)')
|
||||
|
||||
DROP TABLE dbo.inventoryfolders
|
||||
|
||||
EXECUTE sp_rename N'dbo.Tmp_inventoryfolders', N'inventoryfolders', 'OBJECT'
|
||||
|
||||
ALTER TABLE dbo.inventoryfolders ADD CONSTRAINT
|
||||
PK__inventor__C2FABFB3173876EA PRIMARY KEY CLUSTERED
|
||||
(
|
||||
folderID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX owner ON dbo.inventoryfolders
|
||||
(
|
||||
agentID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX parent ON dbo.inventoryfolders
|
||||
(
|
||||
parentFolderID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
||||
67
OpenSim/Data/MSSQL/Resources/003_RegionStore.sql
Normal file
67
OpenSim/Data/MSSQL/Resources/003_RegionStore.sql
Normal file
@@ -0,0 +1,67 @@
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE dbo.Tmp_prims
|
||||
(
|
||||
UUID varchar(36) NOT NULL,
|
||||
RegionUUID varchar(36) NULL,
|
||||
ParentID int NULL,
|
||||
CreationDate int NULL,
|
||||
Name varchar(255) NULL,
|
||||
SceneGroupID varchar(36) NULL,
|
||||
Text varchar(255) NULL,
|
||||
Description varchar(255) NULL,
|
||||
SitName varchar(255) NULL,
|
||||
TouchName varchar(255) NULL,
|
||||
ObjectFlags int NULL,
|
||||
CreatorID varchar(36) NULL,
|
||||
OwnerID varchar(36) NULL,
|
||||
GroupID varchar(36) NULL,
|
||||
LastOwnerID varchar(36) NULL,
|
||||
OwnerMask int NULL,
|
||||
NextOwnerMask int NULL,
|
||||
GroupMask int NULL,
|
||||
EveryoneMask int NULL,
|
||||
BaseMask int NULL,
|
||||
PositionX float(53) NULL,
|
||||
PositionY float(53) NULL,
|
||||
PositionZ float(53) NULL,
|
||||
GroupPositionX float(53) NULL,
|
||||
GroupPositionY float(53) NULL,
|
||||
GroupPositionZ float(53) NULL,
|
||||
VelocityX float(53) NULL,
|
||||
VelocityY float(53) NULL,
|
||||
VelocityZ float(53) NULL,
|
||||
AngularVelocityX float(53) NULL,
|
||||
AngularVelocityY float(53) NULL,
|
||||
AngularVelocityZ float(53) NULL,
|
||||
AccelerationX float(53) NULL,
|
||||
AccelerationY float(53) NULL,
|
||||
AccelerationZ float(53) NULL,
|
||||
RotationX float(53) NULL,
|
||||
RotationY float(53) NULL,
|
||||
RotationZ float(53) NULL,
|
||||
RotationW float(53) NULL,
|
||||
SitTargetOffsetX float(53) NULL,
|
||||
SitTargetOffsetY float(53) NULL,
|
||||
SitTargetOffsetZ float(53) NULL,
|
||||
SitTargetOrientW float(53) NULL,
|
||||
SitTargetOrientX float(53) NULL,
|
||||
SitTargetOrientY float(53) NULL,
|
||||
SitTargetOrientZ float(53) NULL
|
||||
) ON [PRIMARY]
|
||||
|
||||
IF EXISTS(SELECT * FROM dbo.prims)
|
||||
EXEC('INSERT INTO dbo.Tmp_prims (UUID, RegionUUID, ParentID, CreationDate, Name, SceneGroupID, Text, Description, SitName, TouchName, ObjectFlags, CreatorID, OwnerID, GroupID, LastOwnerID, OwnerMask, NextOwnerMask, GroupMask, EveryoneMask, BaseMask, PositionX, PositionY, PositionZ, GroupPositionX, GroupPositionY, GroupPositionZ, VelocityX, VelocityY, VelocityZ, AngularVelocityX, AngularVelocityY, AngularVelocityZ, AccelerationX, AccelerationY, AccelerationZ, RotationX, RotationY, RotationZ, RotationW, SitTargetOffsetX, SitTargetOffsetY, SitTargetOffsetZ, SitTargetOrientW, SitTargetOrientX, SitTargetOrientY, SitTargetOrientZ)
|
||||
SELECT CONVERT(varchar(36), UUID), CONVERT(varchar(36), RegionUUID), ParentID, CreationDate, Name, CONVERT(varchar(36), SceneGroupID), Text, Description, SitName, TouchName, ObjectFlags, CONVERT(varchar(36), CreatorID), CONVERT(varchar(36), OwnerID), CONVERT(varchar(36), GroupID), CONVERT(varchar(36), LastOwnerID), OwnerMask, NextOwnerMask, GroupMask, EveryoneMask, BaseMask, PositionX, PositionY, PositionZ, GroupPositionX, GroupPositionY, GroupPositionZ, VelocityX, VelocityY, VelocityZ, AngularVelocityX, AngularVelocityY, AngularVelocityZ, AccelerationX, AccelerationY, AccelerationZ, RotationX, RotationY, RotationZ, RotationW, SitTargetOffsetX, SitTargetOffsetY, SitTargetOffsetZ, SitTargetOrientW, SitTargetOrientX, SitTargetOrientY, SitTargetOrientZ FROM dbo.prims WITH (HOLDLOCK TABLOCKX)')
|
||||
|
||||
DROP TABLE dbo.prims
|
||||
|
||||
EXECUTE sp_rename N'dbo.Tmp_prims', N'prims', 'OBJECT'
|
||||
|
||||
ALTER TABLE dbo.prims ADD CONSTRAINT
|
||||
PK__prims__10566F31 PRIMARY KEY CLUSTERED
|
||||
(
|
||||
UUID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
||||
15
OpenSim/Data/MSSQL/Resources/003_UserStore.sql
Normal file
15
OpenSim/Data/MSSQL/Resources/003_UserStore.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE [avatarattachments] (
|
||||
[UUID] varchar(36) NOT NULL
|
||||
, [attachpoint] int NOT NULL
|
||||
, [item] varchar(36) NOT NULL
|
||||
, [asset] varchar(36) NOT NULL)
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_avatarattachments ON dbo.avatarattachments
|
||||
(
|
||||
UUID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
|
||||
COMMIT
|
||||
31
OpenSim/Data/MSSQL/Resources/004_AssetStore.sql
Normal file
31
OpenSim/Data/MSSQL/Resources/004_AssetStore.sql
Normal file
@@ -0,0 +1,31 @@
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE dbo.Tmp_assets
|
||||
(
|
||||
id uniqueidentifier NOT NULL,
|
||||
name varchar(64) NOT NULL,
|
||||
description varchar(64) NOT NULL,
|
||||
assetType tinyint NOT NULL,
|
||||
local bit NOT NULL,
|
||||
temporary bit NOT NULL,
|
||||
data image NOT NULL,
|
||||
create_time int NULL,
|
||||
access_time int NULL
|
||||
) ON [PRIMARY]
|
||||
TEXTIMAGE_ON [PRIMARY]
|
||||
|
||||
IF EXISTS(SELECT * FROM dbo.assets)
|
||||
EXEC('INSERT INTO dbo.Tmp_assets (id, name, description, assetType, local, temporary, data, create_time, access_time)
|
||||
SELECT CONVERT(uniqueidentifier, id), name, description, assetType, local, temporary, data, create_time, access_time FROM dbo.assets WITH (HOLDLOCK TABLOCKX)')
|
||||
|
||||
DROP TABLE assets
|
||||
|
||||
EXECUTE sp_rename N'Tmp_assets', N'assets', 'OBJECT'
|
||||
|
||||
ALTER TABLE dbo.assets ADD CONSTRAINT
|
||||
PK__assets__id PRIMARY KEY CLUSTERED
|
||||
(
|
||||
id
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
||||
22
OpenSim/Data/MSSQL/Resources/004_EstateStore.sql
Normal file
22
OpenSim/Data/MSSQL/Resources/004_EstateStore.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE dbo.Tmp_estate_managers
|
||||
(
|
||||
EstateID int NOT NULL,
|
||||
uuid uniqueidentifier NOT NULL
|
||||
) ON [PRIMARY]
|
||||
|
||||
IF EXISTS(SELECT * FROM dbo.estate_managers)
|
||||
EXEC('INSERT INTO dbo.Tmp_estate_managers (EstateID, uuid)
|
||||
SELECT EstateID, CONVERT(uniqueidentifier, uuid) FROM dbo.estate_managers WITH (HOLDLOCK TABLOCKX)')
|
||||
|
||||
DROP TABLE dbo.estate_managers
|
||||
|
||||
EXECUTE sp_rename N'dbo.Tmp_estate_managers', N'estate_managers', 'OBJECT'
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_estate_managers ON dbo.estate_managers
|
||||
(
|
||||
EstateID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
||||
68
OpenSim/Data/MSSQL/Resources/004_GridStore.sql
Normal file
68
OpenSim/Data/MSSQL/Resources/004_GridStore.sql
Normal file
@@ -0,0 +1,68 @@
|
||||
/* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE dbo.Tmp_regions
|
||||
(
|
||||
uuid uniqueidentifier NOT NULL,
|
||||
regionHandle bigint NULL,
|
||||
regionName varchar(20) NULL,
|
||||
regionRecvKey varchar(128) NULL,
|
||||
regionSendKey varchar(128) NULL,
|
||||
regionSecret varchar(128) NULL,
|
||||
regionDataURI varchar(128) NULL,
|
||||
serverIP varchar(64) NULL,
|
||||
serverPort int NULL,
|
||||
serverURI varchar(255) NULL,
|
||||
locX int NULL,
|
||||
locY int NULL,
|
||||
locZ int NULL,
|
||||
eastOverrideHandle bigint NULL,
|
||||
westOverrideHandle bigint NULL,
|
||||
southOverrideHandle bigint NULL,
|
||||
northOverrideHandle bigint NULL,
|
||||
regionAssetURI varchar(255) NULL,
|
||||
regionAssetRecvKey varchar(128) NULL,
|
||||
regionAssetSendKey varchar(128) NULL,
|
||||
regionUserURI varchar(255) NULL,
|
||||
regionUserRecvKey varchar(128) NULL,
|
||||
regionUserSendKey varchar(128) NULL,
|
||||
regionMapTexture uniqueidentifier NULL,
|
||||
serverHttpPort int NULL,
|
||||
serverRemotingPort int NULL,
|
||||
owner_uuid uniqueidentifier NOT NULL,
|
||||
originUUID uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000')
|
||||
) ON [PRIMARY]
|
||||
|
||||
IF EXISTS(SELECT * FROM dbo.regions)
|
||||
EXEC('INSERT INTO dbo.Tmp_regions (uuid, regionHandle, regionName, regionRecvKey, regionSendKey, regionSecret, regionDataURI, serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort, owner_uuid, originUUID)
|
||||
SELECT CONVERT(uniqueidentifier, uuid), regionHandle, regionName, regionRecvKey, regionSendKey, regionSecret, regionDataURI, serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, CONVERT(uniqueidentifier, regionMapTexture), serverHttpPort, serverRemotingPort, CONVERT(uniqueidentifier, owner_uuid), CONVERT(uniqueidentifier, originUUID) FROM dbo.regions WITH (HOLDLOCK TABLOCKX)')
|
||||
|
||||
DROP TABLE dbo.regions
|
||||
|
||||
EXECUTE sp_rename N'dbo.Tmp_regions', N'regions', 'OBJECT'
|
||||
|
||||
ALTER TABLE dbo.regions ADD CONSTRAINT
|
||||
PK__regions__uuid PRIMARY KEY CLUSTERED
|
||||
(
|
||||
uuid
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_regions_name ON dbo.regions
|
||||
(
|
||||
regionName
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_regions_handle ON dbo.regions
|
||||
(
|
||||
regionHandle
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_regions_override ON dbo.regions
|
||||
(
|
||||
eastOverrideHandle,
|
||||
westOverrideHandle,
|
||||
southOverrideHandle,
|
||||
northOverrideHandle
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
||||
52
OpenSim/Data/MSSQL/Resources/004_InventoryStore.sql
Normal file
52
OpenSim/Data/MSSQL/Resources/004_InventoryStore.sql
Normal file
@@ -0,0 +1,52 @@
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE dbo.Tmp_inventoryitems
|
||||
(
|
||||
inventoryID uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
|
||||
assetID uniqueidentifier NULL DEFAULT (NULL),
|
||||
assetType int NULL DEFAULT (NULL),
|
||||
parentFolderID uniqueidentifier NULL DEFAULT (NULL),
|
||||
avatarID uniqueidentifier NULL DEFAULT (NULL),
|
||||
inventoryName varchar(64) NULL DEFAULT (NULL),
|
||||
inventoryDescription varchar(128) NULL DEFAULT (NULL),
|
||||
inventoryNextPermissions int NULL DEFAULT (NULL),
|
||||
inventoryCurrentPermissions int NULL DEFAULT (NULL),
|
||||
invType int NULL DEFAULT (NULL),
|
||||
creatorID uniqueidentifier NULL DEFAULT (NULL),
|
||||
inventoryBasePermissions int NOT NULL DEFAULT ((0)),
|
||||
inventoryEveryOnePermissions int NOT NULL DEFAULT ((0)),
|
||||
salePrice int NULL DEFAULT (NULL),
|
||||
saleType tinyint NULL DEFAULT (NULL),
|
||||
creationDate int NULL DEFAULT (NULL),
|
||||
groupID uniqueidentifier NULL DEFAULT (NULL),
|
||||
groupOwned bit NULL DEFAULT (NULL),
|
||||
flags int NULL DEFAULT (NULL),
|
||||
inventoryGroupPermissions int NOT NULL DEFAULT ((0))
|
||||
) ON [PRIMARY]
|
||||
|
||||
IF EXISTS(SELECT * FROM dbo.inventoryitems)
|
||||
EXEC('INSERT INTO dbo.Tmp_inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType, creatorID, inventoryBasePermissions, inventoryEveryOnePermissions, salePrice, saleType, creationDate, groupID, groupOwned, flags, inventoryGroupPermissions)
|
||||
SELECT CONVERT(uniqueidentifier, inventoryID), CONVERT(uniqueidentifier, assetID), assetType, CONVERT(uniqueidentifier, parentFolderID), CONVERT(uniqueidentifier, avatarID), inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType, CONVERT(uniqueidentifier, creatorID), inventoryBasePermissions, inventoryEveryOnePermissions, salePrice, saleType, creationDate, CONVERT(uniqueidentifier, groupID), groupOwned, flags, inventoryGroupPermissions FROM dbo.inventoryitems WITH (HOLDLOCK TABLOCKX)')
|
||||
|
||||
DROP TABLE dbo.inventoryitems
|
||||
|
||||
EXECUTE sp_rename N'dbo.Tmp_inventoryitems', N'inventoryitems', 'OBJECT'
|
||||
|
||||
ALTER TABLE dbo.inventoryitems ADD CONSTRAINT
|
||||
PK__inventor__C4B7BC2220C1E124 PRIMARY KEY CLUSTERED
|
||||
(
|
||||
inventoryID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
|
||||
CREATE NONCLUSTERED INDEX owner ON dbo.inventoryitems
|
||||
(
|
||||
avatarID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX folder ON dbo.inventoryitems
|
||||
(
|
||||
parentFolderID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
||||
40
OpenSim/Data/MSSQL/Resources/004_RegionStore.sql
Normal file
40
OpenSim/Data/MSSQL/Resources/004_RegionStore.sql
Normal file
@@ -0,0 +1,40 @@
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE Tmp_primitems
|
||||
(
|
||||
itemID varchar(36) NOT NULL,
|
||||
primID varchar(36) NULL,
|
||||
assetID varchar(36) NULL,
|
||||
parentFolderID varchar(36) NULL,
|
||||
invType int NULL,
|
||||
assetType int NULL,
|
||||
name varchar(255) NULL,
|
||||
description varchar(255) NULL,
|
||||
creationDate varchar(255) NULL,
|
||||
creatorID varchar(36) NULL,
|
||||
ownerID varchar(36) NULL,
|
||||
lastOwnerID varchar(36) NULL,
|
||||
groupID varchar(36) NULL,
|
||||
nextPermissions int NULL,
|
||||
currentPermissions int NULL,
|
||||
basePermissions int NULL,
|
||||
everyonePermissions int NULL,
|
||||
groupPermissions int NULL
|
||||
) ON [PRIMARY]
|
||||
|
||||
IF EXISTS(SELECT * FROM primitems)
|
||||
EXEC('INSERT INTO Tmp_primitems (itemID, primID, assetID, parentFolderID, invType, assetType, name, description, creationDate, creatorID, ownerID, lastOwnerID, groupID, nextPermissions, currentPermissions, basePermissions, everyonePermissions, groupPermissions)
|
||||
SELECT CONVERT(varchar(36), itemID), CONVERT(varchar(36), primID), CONVERT(varchar(36), assetID), CONVERT(varchar(36), parentFolderID), invType, assetType, name, description, creationDate, CONVERT(varchar(36), creatorID), CONVERT(varchar(36), ownerID), CONVERT(varchar(36), lastOwnerID), CONVERT(varchar(36), groupID), nextPermissions, currentPermissions, basePermissions, everyonePermissions, groupPermissions')
|
||||
|
||||
DROP TABLE primitems
|
||||
|
||||
EXECUTE sp_rename N'Tmp_primitems', N'primitems', 'OBJECT'
|
||||
|
||||
ALTER TABLE primitems ADD CONSTRAINT
|
||||
PK__primitems__0A688BB1 PRIMARY KEY CLUSTERED
|
||||
(
|
||||
itemID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
|
||||
COMMIT
|
||||
29
OpenSim/Data/MSSQL/Resources/004_UserStore.sql
Normal file
29
OpenSim/Data/MSSQL/Resources/004_UserStore.sql
Normal file
@@ -0,0 +1,29 @@
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE Tmp_userfriends
|
||||
(
|
||||
ownerID varchar(36) NOT NULL,
|
||||
friendID varchar(36) NOT NULL,
|
||||
friendPerms int NOT NULL,
|
||||
datetimestamp int NOT NULL
|
||||
) ON [PRIMARY]
|
||||
|
||||
IF EXISTS(SELECT * FROM userfriends)
|
||||
EXEC('INSERT INTO dbo.Tmp_userfriends (ownerID, friendID, friendPerms, datetimestamp)
|
||||
SELECT CONVERT(varchar(36), ownerID), CONVERT(varchar(36), friendID), CONVERT(int, friendPerms), CONVERT(int, datetimestamp) FROM dbo.userfriends WITH (HOLDLOCK TABLOCKX)')
|
||||
|
||||
DROP TABLE dbo.userfriends
|
||||
|
||||
EXECUTE sp_rename N'Tmp_userfriends', N'userfriends', 'OBJECT'
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_userfriends_ownerID ON userfriends
|
||||
(
|
||||
ownerID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_userfriends_friendID ON userfriends
|
||||
(
|
||||
friendID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user