aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/CommunicationsManager.cs70
-rw-r--r--OpenSim/Framework/Communications/IGridServices.cs43
-rw-r--r--OpenSim/Framework/Communications/IInterRegionCommunications.cs38
-rw-r--r--OpenSim/Framework/Communications/IUserServices.cs43
-rw-r--r--OpenSim/Framework/Communications/Properties/AssemblyInfo.cs60
-rw-r--r--OpenSim/Framework/Console/AssemblyInfo.cs56
-rw-r--r--OpenSim/Framework/Console/ConsoleCallbacksBase.cs35
-rw-r--r--OpenSim/Framework/Console/LogBase.cs282
-rw-r--r--OpenSim/Framework/Console/MainLog.cs47
-rw-r--r--OpenSim/Framework/Data.DB4o/DB4oGridData.cs162
-rw-r--r--OpenSim/Framework/Data.DB4o/DB4oManager.cs163
-rw-r--r--OpenSim/Framework/Data.DB4o/DB4oUserData.cs202
-rw-r--r--OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs194
-rw-r--r--OpenSim/Framework/Data.MSSQL/MSSQLManager.cs211
-rw-r--r--OpenSim/Framework/Data.MSSQL/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLGridData.cs287
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs309
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLLogData.cs105
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLManager.cs602
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLUserData.cs256
-rw-r--r--OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteGridData.cs197
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteManager.cs206
-rw-r--r--OpenSim/Framework/Data/GridData.cs111
-rw-r--r--OpenSim/Framework/Data/ILogData.cs90
-rw-r--r--OpenSim/Framework/Data/IniConfig.cs96
-rw-r--r--OpenSim/Framework/Data/InventoryData.cs185
-rw-r--r--OpenSim/Framework/Data/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Framework/Data/ReservationData.cs47
-rw-r--r--OpenSim/Framework/Data/SimProfileData.cs192
-rw-r--r--OpenSim/Framework/Data/UserData.cs128
-rw-r--r--OpenSim/Framework/Data/UserProfileData.cs180
-rw-r--r--OpenSim/Framework/General/AgentInventory.cs265
-rw-r--r--OpenSim/Framework/General/AuthenticateSessionBase.cs130
-rw-r--r--OpenSim/Framework/General/BlockingQueue.cs58
-rw-r--r--OpenSim/Framework/General/ClientManager.cs36
-rw-r--r--OpenSim/Framework/General/IRegionCommsListener.cs46
-rw-r--r--OpenSim/Framework/General/Interfaces/AuthenticateResponse.cs43
-rw-r--r--OpenSim/Framework/General/Interfaces/Config/IGenericConfig.cs38
-rw-r--r--OpenSim/Framework/General/Interfaces/Config/IGridConfig.cs59
-rw-r--r--OpenSim/Framework/General/Interfaces/Config/IUserConfig.cs53
-rw-r--r--OpenSim/Framework/General/Interfaces/IAssetServer.cs64
-rw-r--r--OpenSim/Framework/General/Interfaces/IClientAPI.cs180
-rw-r--r--OpenSim/Framework/General/Interfaces/ILocalStorage.cs68
-rw-r--r--OpenSim/Framework/General/Interfaces/IUserServer.cs39
-rw-r--r--OpenSim/Framework/General/Interfaces/IWorld.cs42
-rw-r--r--OpenSim/Framework/General/LoginService.cs34
-rw-r--r--OpenSim/Framework/General/Properties/AssemblyInfo.cs31
-rw-r--r--OpenSim/Framework/General/RegionCommsListener.cs68
-rw-r--r--OpenSim/Framework/General/Remoting.cs135
-rw-r--r--OpenSim/Framework/General/Types/AgentCiruitData.cs49
-rw-r--r--OpenSim/Framework/General/Types/AgentWearable.cs57
-rw-r--r--OpenSim/Framework/General/Types/AssetBase.cs46
-rw-r--r--OpenSim/Framework/General/Types/AssetLandmark.cs59
-rw-r--r--OpenSim/Framework/General/Types/AssetStorage.cs47
-rw-r--r--OpenSim/Framework/General/Types/EstateSettings.cs93
-rw-r--r--OpenSim/Framework/General/Types/Login.cs49
-rw-r--r--OpenSim/Framework/General/Types/MapBlockData.cs23
-rw-r--r--OpenSim/Framework/General/Types/NeighbourInfo.cs42
-rw-r--r--OpenSim/Framework/General/Types/NetworkServersInfo.cs219
-rw-r--r--OpenSim/Framework/General/Types/ParcelData.cs112
-rw-r--r--OpenSim/Framework/General/Types/PrimData.cs228
-rw-r--r--OpenSim/Framework/General/Types/PrimitiveBaseShape.cs102
-rw-r--r--OpenSim/Framework/General/Types/RegionHandle.cs121
-rw-r--r--OpenSim/Framework/General/Types/RegionInfo.cs342
-rw-r--r--OpenSim/Framework/General/Types/UUID.cs127
-rw-r--r--OpenSim/Framework/General/UserProfile.cs87
-rw-r--r--OpenSim/Framework/General/Util.cs184
-rw-r--r--OpenSim/Framework/GenericConfig/Xml/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Framework/GenericConfig/Xml/XmlConfig.cs122
-rw-r--r--OpenSim/Framework/Servers/BaseHttpServer.cs224
-rw-r--r--OpenSim/Framework/Servers/BaseStreamHandler.cs40
-rw-r--r--OpenSim/Framework/Servers/CheckSumServer.cs127
-rw-r--r--OpenSim/Framework/Servers/IStreamHandler.cs22
-rw-r--r--OpenSim/Framework/Servers/RestMethod.cs31
-rw-r--r--OpenSim/Framework/Servers/RestStreamHandler.cs31
-rw-r--r--OpenSim/Framework/Servers/UDPServerBase.cs87
-rw-r--r--OpenSim/Framework/Servers/XmlRpcMethod.cs33
-rw-r--r--OpenSim/Framework/UserManager/LoginResponse.cs643
-rw-r--r--OpenSim/Framework/UserManager/UserManagerBase.cs630
82 files changed, 10161 insertions, 0 deletions
diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs
new file mode 100644
index 0000000..109d027
--- /dev/null
+++ b/OpenSim/Framework/Communications/CommunicationsManager.cs
@@ -0,0 +1,70 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Text;
29using libsecondlife;
30using libsecondlife.Packets;
31using OpenSim.Framework.Data;
32using OpenSim.Framework.Interfaces;
33using OpenSim.Framework.Types;
34using OpenSim.Framework.Servers;
35
36namespace OpenSim.Framework.Communications
37{
38
39 public class CommunicationsManager
40 {
41 public IUserServices UserServer;
42 public IGridServices GridServer;
43 public IInterRegionCommunications InterRegion;
44
45 public NetworkServersInfo ServersInfo;
46 public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer)
47 {
48 ServersInfo = serversInfo;
49 }
50
51 #region Packet Handlers
52 public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client)
53 {
54 Encoding enc = Encoding.ASCII;
55 UserProfileData profileData = this.UserServer.GetUserProfile(uuid);
56 if (profileData != null)
57 {
58 UUIDNameReplyPacket packet = new UUIDNameReplyPacket();
59 packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1];
60 packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
61 packet.UUIDNameBlock[0].ID = profileData.UUID;
62 packet.UUIDNameBlock[0].FirstName = enc.GetBytes(profileData.username + "\0");
63 packet.UUIDNameBlock[0].LastName = enc.GetBytes(profileData.surname +"\0");
64 remote_client.OutPacket((Packet)packet);
65 }
66
67 }
68 #endregion
69 }
70}
diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs
new file mode 100644
index 0000000..c296209
--- /dev/null
+++ b/OpenSim/Framework/Communications/IGridServices.cs
@@ -0,0 +1,43 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using System.Collections.Generic;
30using OpenSim.Framework.Types;
31
32namespace OpenSim.Framework.Communications
33{
34
35
36 public interface IGridServices
37 {
38 RegionCommsListener RegisterRegion(RegionInfo regionInfos);
39 List<RegionInfo> RequestNeighbours(RegionInfo regionInfo);
40 RegionInfo RequestNeighbourInfo(ulong regionHandle);
41 List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY);
42 }
43}
diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs
new file mode 100644
index 0000000..55f12ac
--- /dev/null
+++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs
@@ -0,0 +1,38 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using libsecondlife;
29using OpenSim.Framework.Types;
30
31namespace OpenSim.Framework.Communications
32{
33 public interface IInterRegionCommunications
34 {
35 bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData);
36 bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position);
37 }
38}
diff --git a/OpenSim/Framework/Communications/IUserServices.cs b/OpenSim/Framework/Communications/IUserServices.cs
new file mode 100644
index 0000000..0b1f86c
--- /dev/null
+++ b/OpenSim/Framework/Communications/IUserServices.cs
@@ -0,0 +1,43 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using libsecondlife;
29using OpenSim.Framework.Data;
30
31namespace OpenSim.Framework.Communications
32{
33 public interface IUserServices
34 {
35 UserProfileData GetUserProfile(string firstName, string lastName);
36 UserProfileData GetUserProfile(string name);
37 UserProfileData GetUserProfile(LLUUID avatarID);
38
39 UserProfileData SetupMasterUser(string firstName, string lastName);
40 UserProfileData SetupMasterUser(string firstName, string lastName, string password);
41
42 }
43}
diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..09f6473
--- /dev/null
+++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs
@@ -0,0 +1,60 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Reflection;
29using System.Runtime.InteropServices;
30// General Information about an assembly is controlled through the following
31// set of attributes. Change these attribute values to modify the information
32// associated with an assembly.
33[assembly: AssemblyTitle("OpenGrid.Framework.Communications")]
34[assembly: AssemblyDescription("")]
35[assembly: AssemblyConfiguration("")]
36[assembly: AssemblyCompany("")]
37[assembly: AssemblyProduct("OpenGrid.Framework.Communications")]
38[assembly: AssemblyCopyright("Copyright © 2007")]
39[assembly: AssemblyTrademark("")]
40[assembly: AssemblyCulture("")]
41
42// Setting ComVisible to false makes the types in this assembly not visible
43// to COM components. If you need to access a type in this assembly from
44// COM, set the ComVisible attribute to true on that type.
45[assembly: ComVisible(false)]
46
47// The following GUID is for the ID of the typelib if this project is exposed to COM
48[assembly: Guid("13e7c396-78a9-4a5c-baf2-6f980ea75d95")]
49
50// Version information for an assembly consists of the following four values:
51//
52// Major Version
53// Minor Version
54// Build Number
55// Revision
56//
57// You can specify all the values or you can default the Revision and Build Numbers
58// by using the '*' as shown below:
59[assembly: AssemblyVersion("1.0.0.0")]
60[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Framework/Console/AssemblyInfo.cs b/OpenSim/Framework/Console/AssemblyInfo.cs
new file mode 100644
index 0000000..30f6167
--- /dev/null
+++ b/OpenSim/Framework/Console/AssemblyInfo.cs
@@ -0,0 +1,56 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Reflection;
29using System.Runtime.InteropServices;
30// Information about this assembly is defined by the following
31// attributes.
32//
33// change them to the information which is associated with the assembly
34// you compile.
35
36[assembly: AssemblyTitle("ServerConsole")]
37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("ServerConsole")]
41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")]
44
45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)]
48
49// The assembly version has following format :
50//
51// Major.Minor.Build.Revision
52//
53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default):
55
56[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Framework/Console/ConsoleCallbacksBase.cs b/OpenSim/Framework/Console/ConsoleCallbacksBase.cs
new file mode 100644
index 0000000..346cfe6
--- /dev/null
+++ b/OpenSim/Framework/Console/ConsoleCallbacksBase.cs
@@ -0,0 +1,35 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28namespace OpenSim.Framework.Console
29{
30 public interface conscmd_callback
31 {
32 void RunCmd(string cmd, string[] cmdparams);
33 void Show(string ShowWhat);
34 }
35}
diff --git a/OpenSim/Framework/Console/LogBase.cs b/OpenSim/Framework/Console/LogBase.cs
new file mode 100644
index 0000000..f73e15e
--- /dev/null
+++ b/OpenSim/Framework/Console/LogBase.cs
@@ -0,0 +1,282 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.IO;
30using System.Net;
31
32namespace OpenSim.Framework.Console
33{
34 public enum LogPriority : int
35 {
36 CRITICAL,
37 HIGH,
38 MEDIUM,
39 NORMAL,
40 LOW,
41 VERBOSE,
42 EXTRAVERBOSE
43 }
44
45 public class LogBase
46 {
47 StreamWriter Log;
48 public conscmd_callback cmdparser;
49 public string componentname;
50 private bool m_silent;
51
52 public LogBase(string LogFile, string componentname, conscmd_callback cmdparser, bool silent)
53 {
54 this.componentname = componentname;
55 this.cmdparser = cmdparser;
56 this.m_silent = silent;
57 System.Console.WriteLine("ServerConsole.cs - creating new local console");
58
59 if (String.IsNullOrEmpty(LogFile))
60 {
61 LogFile = componentname + ".log";
62 }
63
64 System.Console.WriteLine("Logs will be saved to current directory in " + LogFile);
65 Log = File.AppendText(LogFile);
66 Log.WriteLine("========================================================================");
67 Log.WriteLine(componentname + " Started at " + DateTime.Now.ToString());
68 }
69
70 public void Close()
71 {
72 Log.WriteLine("Shutdown at " + DateTime.Now.ToString());
73 Log.Close();
74 }
75
76 public void Write(string format, params object[] args)
77 {
78 Notice(format, args);
79 return;
80 }
81
82 public void WriteLine(LogPriority importance, string format, params object[] args)
83 {
84 Log.WriteLine(format, args);
85 Log.Flush();
86 if (!m_silent)
87 {
88 System.Console.WriteLine(format, args);
89 }
90 return;
91 }
92
93 public void Warn(string format, params object[] args)
94 {
95 WriteNewLine(ConsoleColor.Yellow, format, args);
96 return;
97 }
98
99 public void Notice(string format, params object[] args)
100 {
101 WriteNewLine(ConsoleColor.White, format, args);
102 return;
103 }
104
105 public void Error(string format, params object[] args)
106 {
107 WriteNewLine(ConsoleColor.Red, format, args);
108 return;
109 }
110
111 public void Verbose(string format, params object[] args)
112 {
113 WriteNewLine(ConsoleColor.Gray, format, args);
114 return;
115 }
116
117 public void Status(string format, params object[] args)
118 {
119 WriteNewLine(ConsoleColor.Blue, format, args);
120 return;
121 }
122
123 private void WriteNewLine(ConsoleColor color, string format, params object[] args)
124 {
125 Log.WriteLine(format, args);
126 Log.Flush();
127 if (!m_silent)
128 {
129 try
130 {
131 System.Console.ForegroundColor = color;
132 System.Console.WriteLine(format, args);
133 System.Console.ResetColor();
134 }
135 catch (ArgumentNullException)
136 {
137 // Some older systems dont support coloured text.
138 System.Console.WriteLine(format, args);
139 }
140 }
141 return;
142 }
143
144 public string ReadLine()
145 {
146 string TempStr = System.Console.ReadLine();
147 Log.WriteLine(TempStr);
148 return TempStr;
149 }
150
151 public int Read()
152 {
153 int TempInt = System.Console.Read();
154 Log.Write((char)TempInt);
155 return TempInt;
156 }
157
158 public IPAddress CmdPromptIPAddress(string prompt, string defaultvalue)
159 {
160 IPAddress address;
161 string addressStr;
162
163 while (true)
164 {
165 addressStr = MainLog.Instance.CmdPrompt(prompt, defaultvalue);
166 if (IPAddress.TryParse(addressStr, out address))
167 {
168 break;
169 }
170 else
171 {
172 MainLog.Instance.Error("Illegal address. Please re-enter.");
173 }
174 }
175
176 return address;
177 }
178
179 public int CmdPromptIPPort(string prompt, string defaultvalue)
180 {
181 int port;
182 string portStr;
183
184 while (true)
185 {
186 portStr = MainLog.Instance.CmdPrompt(prompt, defaultvalue);
187 if (int.TryParse(portStr, out port))
188 {
189 if (port >= IPEndPoint.MinPort && port <= IPEndPoint.MaxPort)
190 {
191 break;
192 }
193 }
194
195 MainLog.Instance.Error("Illegal address. Please re-enter.");
196 }
197
198 return port;
199 }
200
201 // Displays a prompt and waits for the user to enter a string, then returns that string
202 // Done with no echo and suitable for passwords
203 public string PasswdPrompt(string prompt)
204 {
205 // FIXME: Needs to be better abstracted
206 Log.WriteLine(prompt);
207 this.Write(prompt);
208 ConsoleColor oldfg = System.Console.ForegroundColor;
209 System.Console.ForegroundColor = System.Console.BackgroundColor;
210 string temp = System.Console.ReadLine();
211 System.Console.ForegroundColor = oldfg;
212 return temp;
213 }
214
215 // Displays a command prompt and waits for the user to enter a string, then returns that string
216 public string CmdPrompt(string prompt)
217 {
218 this.Write(String.Format("{0}: ", prompt));
219 return this.ReadLine();
220 }
221
222 // Displays a command prompt and returns a default value if the user simply presses enter
223 public string CmdPrompt(string prompt, string defaultresponse)
224 {
225 string temp = CmdPrompt(String.Format("{0} [{1}]", prompt, defaultresponse));
226 if (temp == "")
227 {
228 return defaultresponse;
229 }
230 else
231 {
232 return temp;
233 }
234 }
235
236 // Displays a command prompt and returns a default value, user may only enter 1 of 2 options
237 public string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB)
238 {
239 bool itisdone = false;
240 string temp = CmdPrompt(prompt, defaultresponse);
241 while (itisdone == false)
242 {
243 if ((temp == OptionA) || (temp == OptionB))
244 {
245 itisdone = true;
246 }
247 else
248 {
249 Notice("Valid options are " + OptionA + " or " + OptionB);
250 temp = CmdPrompt(prompt, defaultresponse);
251 }
252 }
253 return temp;
254 }
255
256 // Runs a command with a number of parameters
257 public Object RunCmd(string Cmd, string[] cmdparams)
258 {
259 cmdparser.RunCmd(Cmd, cmdparams);
260 return null;
261 }
262
263 // Shows data about something
264 public void ShowCommands(string ShowWhat)
265 {
266 cmdparser.Show(ShowWhat);
267 }
268
269 public void MainLogPrompt()
270 {
271 string[] tempstrarray;
272 string tempstr = this.CmdPrompt(this.componentname + "# ");
273 tempstrarray = tempstr.Split(' ');
274 string cmd = tempstrarray[0];
275 Array.Reverse(tempstrarray);
276 Array.Resize<string>(ref tempstrarray, tempstrarray.Length - 1);
277 Array.Reverse(tempstrarray);
278 string[] cmdparams = (string[])tempstrarray;
279 RunCmd(cmd, cmdparams);
280 }
281 }
282}
diff --git a/OpenSim/Framework/Console/MainLog.cs b/OpenSim/Framework/Console/MainLog.cs
new file mode 100644
index 0000000..7d52622
--- /dev/null
+++ b/OpenSim/Framework/Console/MainLog.cs
@@ -0,0 +1,47 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28namespace OpenSim.Framework.Console
29{
30 public class MainLog {
31
32 private static LogBase instance;
33
34 public static LogBase Instance
35 {
36 get
37 {
38 return instance;
39 }
40 set
41 {
42 instance = value;
43 }
44 }
45 }
46
47}
diff --git a/OpenSim/Framework/Data.DB4o/DB4oGridData.cs b/OpenSim/Framework/Data.DB4o/DB4oGridData.cs
new file mode 100644
index 0000000..5fec367
--- /dev/null
+++ b/OpenSim/Framework/Data.DB4o/DB4oGridData.cs
@@ -0,0 +1,162 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using System;
30using libsecondlife;
31
32namespace OpenSim.Framework.Data.DB4o
33{
34 /// <summary>
35 /// A grid server storage mechanism employing the DB4o database system
36 /// </summary>
37 class DB4oGridData : IGridData
38 {
39 /// <summary>
40 /// The database manager object
41 /// </summary>
42 DB4oGridManager manager;
43
44 /// <summary>
45 /// Called when the plugin is first loaded (as constructors are not called)
46 /// </summary>
47 public void Initialise() {
48 manager = new DB4oGridManager("gridserver.yap");
49 }
50
51 /// <summary>
52 /// Returns a list of regions within the specified ranges
53 /// </summary>
54 /// <param name="a">minimum X coordinate</param>
55 /// <param name="b">minimum Y coordinate</param>
56 /// <param name="c">maximum X coordinate</param>
57 /// <param name="d">maximum Y coordinate</param>
58 /// <returns>An array of region profiles</returns>
59 public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
60 {
61 return null;
62 }
63
64 /// <summary>
65 /// Returns a region located at the specified regionHandle (warning multiple regions may occupy the one spot, first found is returned)
66 /// </summary>
67 /// <param name="handle">The handle to search for</param>
68 /// <returns>A region profile</returns>
69 public SimProfileData GetProfileByHandle(ulong handle) {
70 lock (manager.simProfiles)
71 {
72 foreach (LLUUID UUID in manager.simProfiles.Keys)
73 {
74 if (manager.simProfiles[UUID].regionHandle == handle)
75 {
76 return manager.simProfiles[UUID];
77 }
78 }
79 }
80 throw new Exception("Unable to find profile with handle (" + handle.ToString() + ")");
81 }
82
83 /// <summary>
84 /// Returns a specific region
85 /// </summary>
86 /// <param name="uuid">The region ID code</param>
87 /// <returns>A region profile</returns>
88 public SimProfileData GetProfileByLLUUID(LLUUID uuid)
89 {
90 lock (manager.simProfiles)
91 {
92 if (manager.simProfiles.ContainsKey(uuid))
93 return manager.simProfiles[uuid];
94 }
95 throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + "). Total Registered Regions: " + manager.simProfiles.Count);
96 }
97
98 /// <summary>
99 /// Adds a new specified region to the database
100 /// </summary>
101 /// <param name="profile">The profile to add</param>
102 /// <returns>A dataresponse enum indicating success</returns>
103 public DataResponse AddProfile(SimProfileData profile)
104 {
105 lock (manager.simProfiles)
106 {
107 if (manager.AddRow(profile))
108 {
109 return DataResponse.RESPONSE_OK;
110 }
111 else
112 {
113 return DataResponse.RESPONSE_ERROR;
114 }
115 }
116 }
117
118 /// <summary>
119 /// Authenticates a new region using the shared secrets. NOT SECURE.
120 /// </summary>
121 /// <param name="uuid">The UUID the region is authenticating with</param>
122 /// <param name="handle">The location the region is logging into (unused in Db4o)</param>
123 /// <param name="key">The shared secret</param>
124 /// <returns>Authenticated?</returns>
125 public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) {
126 if (manager.simProfiles[uuid].regionRecvKey == key)
127 return true;
128 return false;
129 }
130
131 /// <summary>
132 /// Shuts down the database
133 /// </summary>
134 public void Close()
135 {
136 manager = null;
137 }
138
139 /// <summary>
140 /// Returns the providers name
141 /// </summary>
142 /// <returns>The name of the storage system</returns>
143 public string getName()
144 {
145 return "DB4o Grid Provider";
146 }
147
148 /// <summary>
149 /// Returns the providers version
150 /// </summary>
151 /// <returns>The version of the storage system</returns>
152 public string getVersion()
153 {
154 return "0.1";
155 }
156
157 public ReservationData GetReservationAtPoint(uint x, uint y)
158 {
159 return null;
160 }
161 }
162}
diff --git a/OpenSim/Framework/Data.DB4o/DB4oManager.cs b/OpenSim/Framework/Data.DB4o/DB4oManager.cs
new file mode 100644
index 0000000..0df6350
--- /dev/null
+++ b/OpenSim/Framework/Data.DB4o/DB4oManager.cs
@@ -0,0 +1,163 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using Db4objects.Db4o;
31using libsecondlife;
32
33namespace OpenSim.Framework.Data.DB4o
34{
35 /// <summary>
36 /// A Database manager for Db4o
37 /// </summary>
38 class DB4oGridManager
39 {
40 /// <summary>
41 /// A list of the current regions connected (in-memory cache)
42 /// </summary>
43 public Dictionary<LLUUID, SimProfileData> simProfiles = new Dictionary<LLUUID, SimProfileData>();
44 /// <summary>
45 /// Database File Name
46 /// </summary>
47 string dbfl;
48
49 /// <summary>
50 /// Creates a new grid storage manager
51 /// </summary>
52 /// <param name="db4odb">Filename to the database file</param>
53 public DB4oGridManager(string db4odb)
54 {
55 dbfl = db4odb;
56 IObjectContainer database;
57 database = Db4oFactory.OpenFile(dbfl);
58 IObjectSet result = database.Get(typeof(SimProfileData));
59 // Loads the file into the in-memory cache
60 foreach(SimProfileData row in result) {
61 simProfiles.Add(row.UUID, row);
62 }
63 database.Close();
64 }
65
66 /// <summary>
67 /// Adds a new profile to the database (Warning: Probably slow.)
68 /// </summary>
69 /// <param name="row">The profile to add</param>
70 /// <returns>Successful?</returns>
71 public bool AddRow(SimProfileData row)
72 {
73 if (simProfiles.ContainsKey(row.UUID))
74 {
75 simProfiles[row.UUID] = row;
76 }
77 else
78 {
79 simProfiles.Add(row.UUID, row);
80 }
81
82 try
83 {
84 IObjectContainer database;
85 database = Db4oFactory.OpenFile(dbfl);
86 database.Set(row);
87 database.Close();
88 return true;
89 }
90 catch (Exception)
91 {
92 return false;
93 }
94 }
95
96
97 }
98
99 /// <summary>
100 /// A manager for the DB4o database (user profiles)
101 /// </summary>
102 class DB4oUserManager
103 {
104 /// <summary>
105 /// A list of the user profiles (in memory cache)
106 /// </summary>
107 public Dictionary<LLUUID, UserProfileData> userProfiles = new Dictionary<LLUUID, UserProfileData>();
108 /// <summary>
109 /// Database filename
110 /// </summary>
111 string dbfl;
112
113 /// <summary>
114 /// Initialises a new DB manager
115 /// </summary>
116 /// <param name="db4odb">The filename to the database</param>
117 public DB4oUserManager(string db4odb)
118 {
119 dbfl = db4odb;
120 IObjectContainer database;
121 database = Db4oFactory.OpenFile(dbfl);
122 // Load to cache
123 IObjectSet result = database.Get(typeof(UserProfileData));
124 foreach (UserProfileData row in result)
125 {
126 userProfiles.Add(row.UUID, row);
127 }
128 database.Close();
129 }
130
131 /// <summary>
132 /// Adds a new profile to the database (Warning: Probably slow.)
133 /// </summary>
134 /// <param name="row">The profile to add</param>
135 /// <returns>Successful?</returns>
136 public bool AddRow(UserProfileData row)
137 {
138 if (userProfiles.ContainsKey(row.UUID))
139 {
140 userProfiles[row.UUID] = row;
141 }
142 else
143 {
144 userProfiles.Add(row.UUID, row);
145 }
146
147 try
148 {
149 IObjectContainer database;
150 database = Db4oFactory.OpenFile(dbfl);
151 database.Set(row);
152 database.Close();
153 return true;
154 }
155 catch (Exception)
156 {
157 return false;
158 }
159 }
160
161
162 }
163}
diff --git a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs
new file mode 100644
index 0000000..2e33ab0
--- /dev/null
+++ b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs
@@ -0,0 +1,202 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using libsecondlife;
30
31namespace OpenSim.Framework.Data.DB4o
32{
33 /// <summary>
34 /// A User storage interface for the DB4o database system
35 /// </summary>
36 public class DB4oUserData : IUserData
37 {
38 /// <summary>
39 /// The database manager
40 /// </summary>
41 DB4oUserManager manager;
42
43 /// <summary>
44 /// Artificial constructor called upon plugin load
45 /// </summary>
46 public void Initialise()
47 {
48 manager = new DB4oUserManager("userprofiles.yap");
49 }
50
51 /// <summary>
52 /// Loads a specified user profile from a UUID
53 /// </summary>
54 /// <param name="uuid">The users UUID</param>
55 /// <returns>A user profile</returns>
56 public UserProfileData getUserByUUID(LLUUID uuid)
57 {
58 if(manager.userProfiles.ContainsKey(uuid))
59 return manager.userProfiles[uuid];
60 return null;
61 }
62
63 /// <summary>
64 /// Returns a user by searching for its name
65 /// </summary>
66 /// <param name="name">The users account name</param>
67 /// <returns>A matching users profile</returns>
68 public UserProfileData getUserByName(string name)
69 {
70 return getUserByName(name.Split(' ')[0], name.Split(' ')[1]);
71 }
72
73 /// <summary>
74 /// Returns a user by searching for its name
75 /// </summary>
76 /// <param name="fname">The first part of the users account name</param>
77 /// <param name="lname">The second part of the users account name</param>
78 /// <returns>A matching users profile</returns>
79 public UserProfileData getUserByName(string fname, string lname)
80 {
81 foreach (UserProfileData profile in manager.userProfiles.Values)
82 {
83 if (profile.username == fname && profile.surname == lname)
84 return profile;
85 }
86 return null;
87 }
88
89 /// <summary>
90 /// Returns a user by UUID direct
91 /// </summary>
92 /// <param name="uuid">The users account ID</param>
93 /// <returns>A matching users profile</returns>
94 public UserAgentData getAgentByUUID(LLUUID uuid)
95 {
96 try
97 {
98 return getUserByUUID(uuid).currentAgent;
99 }
100 catch (Exception)
101 {
102 return null;
103 }
104 }
105
106 /// <summary>
107 /// Returns a session by account name
108 /// </summary>
109 /// <param name="name">The account name</param>
110 /// <returns>The users session agent</returns>
111 public UserAgentData getAgentByName(string name)
112 {
113 return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]);
114 }
115
116 /// <summary>
117 /// Returns a session by account name
118 /// </summary>
119 /// <param name="fname">The first part of the users account name</param>
120 /// <param name="lname">The second part of the users account name</param>
121 /// <returns>A user agent</returns>
122 public UserAgentData getAgentByName(string fname, string lname)
123 {
124 try
125 {
126 return getUserByName(fname,lname).currentAgent;
127 }
128 catch (Exception)
129 {
130 return null;
131 }
132 }
133
134 /// <summary>
135 /// Creates a new user profile
136 /// </summary>
137 /// <param name="user">The profile to add to the database</param>
138 public void addNewUserProfile(UserProfileData user)
139 {
140 try
141 {
142 manager.AddRow(user);
143 }
144 catch (Exception e)
145 {
146 Console.WriteLine(e.ToString());
147 }
148 }
149
150 /// <summary>
151 /// Creates a new user agent
152 /// </summary>
153 /// <param name="agent">The agent to add to the database</param>
154 public void addNewUserAgent(UserAgentData agent)
155 {
156 // Do nothing. yet.
157 }
158
159 /// <summary>
160 /// Transfers money between two user accounts
161 /// </summary>
162 /// <param name="from">Starting account</param>
163 /// <param name="to">End account</param>
164 /// <param name="amount">The amount to move</param>
165 /// <returns>Success?</returns>
166 public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount)
167 {
168 return true;
169 }
170
171 /// <summary>
172 /// Transfers inventory between two accounts
173 /// </summary>
174 /// <remarks>Move to inventory server</remarks>
175 /// <param name="from">Senders account</param>
176 /// <param name="to">Recievers account</param>
177 /// <param name="item">Inventory item</param>
178 /// <returns>Success?</returns>
179 public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
180 {
181 return true;
182 }
183
184 /// <summary>
185 /// Returns the name of the storage provider
186 /// </summary>
187 /// <returns>Storage provider name</returns>
188 public string getName()
189 {
190 return "DB4o Userdata";
191 }
192
193 /// <summary>
194 /// Returns the version of the storage provider
195 /// </summary>
196 /// <returns>Storage provider version</returns>
197 public string getVersion()
198 {
199 return "0.1";
200 }
201 }
202}
diff --git a/OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..905cd9b
--- /dev/null
+++ b/OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Framework.Data.DB4o")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenSim.Framework.Data.DB4o")]
11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("57991e15-79da-41b7-aa06-2e6b49165a63")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs
new file mode 100644
index 0000000..ca9196a5
--- /dev/null
+++ b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs
@@ -0,0 +1,194 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Data;
31using System.Security.Cryptography;
32using System.Text;
33using libsecondlife;
34
35namespace OpenSim.Framework.Data.MSSQL
36{
37 /// <summary>
38 /// A grid data interface for Microsoft SQL Server
39 /// </summary>
40 public class SqlGridData : IGridData
41 {
42 /// <summary>
43 /// Database manager
44 /// </summary>
45 private MSSqlManager database;
46
47 /// <summary>
48 /// Initialises the Grid Interface
49 /// </summary>
50 public void Initialise()
51 {
52 database = new MSSqlManager("localhost", "db", "user", "password", "false");
53 }
54
55 /// <summary>
56 /// Shuts down the grid interface
57 /// </summary>
58 public void Close()
59 {
60 database.Close();
61 }
62
63 /// <summary>
64 /// Returns the storage system name
65 /// </summary>
66 /// <returns>A string containing the storage system name</returns>
67 public string getName()
68 {
69 return "Sql OpenGridData";
70 }
71
72 /// <summary>
73 /// Returns the storage system version
74 /// </summary>
75 /// <returns>A string containing the storage system version</returns>
76 public string getVersion()
77 {
78 return "0.1";
79 }
80
81 /// <summary>
82 /// Returns a list of regions within the specified ranges
83 /// </summary>
84 /// <param name="a">minimum X coordinate</param>
85 /// <param name="b">minimum Y coordinate</param>
86 /// <param name="c">maximum X coordinate</param>
87 /// <param name="d">maximum Y coordinate</param>
88 /// <returns>An array of region profiles</returns>
89 public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
90 {
91 return null;
92 }
93
94 /// <summary>
95 /// Returns a sim profile from it's location
96 /// </summary>
97 /// <param name="handle">Region location handle</param>
98 /// <returns>Sim profile</returns>
99 public SimProfileData GetProfileByHandle(ulong handle)
100 {
101 Dictionary<string, string> param = new Dictionary<string, string>();
102 param["handle"] = handle.ToString();
103
104 IDbCommand result = database.Query("SELECT * FROM regions WHERE handle = @handle", param);
105 IDataReader reader = result.ExecuteReader();
106
107 SimProfileData row = database.getRow(reader);
108 reader.Close();
109 result.Dispose();
110
111 return row;
112 }
113
114 /// <summary>
115 /// Returns a sim profile from it's UUID
116 /// </summary>
117 /// <param name="uuid">The region UUID</param>
118 /// <returns>The sim profile</returns>
119 public SimProfileData GetProfileByLLUUID(LLUUID uuid)
120 {
121 Dictionary<string, string> param = new Dictionary<string, string>();
122 param["uuid"] = uuid.ToStringHyphenated();
123
124 IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = @uuid", param);
125 IDataReader reader = result.ExecuteReader();
126
127 SimProfileData row = database.getRow(reader);
128 reader.Close();
129 result.Dispose();
130
131 return row;
132 }
133
134 /// <summary>
135 /// Adds a new specified region to the database
136 /// </summary>
137 /// <param name="profile">The profile to add</param>
138 /// <returns>A dataresponse enum indicating success</returns>
139 public DataResponse AddProfile(SimProfileData profile)
140 {
141 if (database.insertRow(profile))
142 {
143 return DataResponse.RESPONSE_OK;
144 }
145 else
146 {
147 return DataResponse.RESPONSE_ERROR;
148 }
149 }
150
151 /// <summary>
152 /// DEPRECIATED. Attempts to authenticate a region by comparing a shared secret.
153 /// </summary>
154 /// <param name="uuid">The UUID of the challenger</param>
155 /// <param name="handle">The attempted regionHandle of the challenger</param>
156 /// <param name="authkey">The secret</param>
157 /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
158 public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey)
159 {
160 bool throwHissyFit = false; // Should be true by 1.0
161
162 if (throwHissyFit)
163 throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
164
165 SimProfileData data = GetProfileByLLUUID(uuid);
166
167 return (handle == data.regionHandle && authkey == data.regionSecret);
168 }
169
170 /// <summary>
171 /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region
172 /// </summary>
173 /// <remarks>This requires a security audit.</remarks>
174 /// <param name="uuid"></param>
175 /// <param name="handle"></param>
176 /// <param name="authhash"></param>
177 /// <param name="challenge"></param>
178 /// <returns></returns>
179 public bool AuthenticateSim(LLUUID uuid, ulong handle, string authhash, string challenge)
180 {
181 SHA512Managed HashProvider = new SHA512Managed();
182 ASCIIEncoding TextProvider = new ASCIIEncoding();
183
184 byte[] stream = TextProvider.GetBytes(uuid.ToStringHyphenated() + ":" + handle.ToString() + ":" + challenge);
185 byte[] hash = HashProvider.ComputeHash(stream);
186 return false;
187 }
188 public ReservationData GetReservationAtPoint(uint x, uint y)
189 {
190 return null;
191 }
192 }
193
194}
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs b/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
new file mode 100644
index 0000000..49bf31c
--- /dev/null
+++ b/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
@@ -0,0 +1,211 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Data;
31using System.Data.SqlClient;
32using libsecondlife;
33
34namespace OpenSim.Framework.Data.MSSQL
35{
36 /// <summary>
37 /// A management class for the MS SQL Storage Engine
38 /// </summary>
39 class MSSqlManager
40 {
41 /// <summary>
42 /// The database connection object
43 /// </summary>
44 IDbConnection dbcon;
45
46 /// <summary>
47 /// Initialises and creates a new Sql connection and maintains it.
48 /// </summary>
49 /// <param name="hostname">The Sql server being connected to</param>
50 /// <param name="database">The name of the Sql database being used</param>
51 /// <param name="username">The username logging into the database</param>
52 /// <param name="password">The password for the user logging in</param>
53 /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param>
54 public MSSqlManager(string hostname, string database, string username, string password, string cpooling)
55 {
56 try
57 {
58 string connectionString = "Server=" + hostname + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";";
59 dbcon = new SqlConnection(connectionString);
60
61 dbcon.Open();
62 }
63 catch (Exception e)
64 {
65 throw new Exception("Error initialising Sql Database: " + e.ToString());
66 }
67 }
68
69 /// <summary>
70 /// Shuts down the database connection
71 /// </summary>
72 public void Close()
73 {
74 dbcon.Close();
75 dbcon = null;
76 }
77
78 /// <summary>
79 /// Runs a query with protection against SQL Injection by using parameterised input.
80 /// </summary>
81 /// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param>
82 /// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param>
83 /// <returns>A Sql DB Command</returns>
84 public IDbCommand Query(string sql, Dictionary<string, string> parameters)
85 {
86 SqlCommand dbcommand = (SqlCommand)dbcon.CreateCommand();
87 dbcommand.CommandText = sql;
88 foreach (KeyValuePair<string, string> param in parameters)
89 {
90 dbcommand.Parameters.AddWithValue(param.Key, param.Value);
91 }
92
93 return (IDbCommand)dbcommand;
94 }
95
96 /// <summary>
97 /// Runs a database reader object and returns a region row
98 /// </summary>
99 /// <param name="reader">An active database reader</param>
100 /// <returns>A region row</returns>
101 public SimProfileData getRow(IDataReader reader)
102 {
103 SimProfileData regionprofile = new SimProfileData();
104
105 if (reader.Read())
106 {
107 // Region Main
108 regionprofile.regionHandle = (ulong)reader["regionHandle"];
109 regionprofile.regionName = (string)reader["regionName"];
110 regionprofile.UUID = new LLUUID((string)reader["uuid"]);
111
112 // Secrets
113 regionprofile.regionRecvKey = (string)reader["regionRecvKey"];
114 regionprofile.regionSecret = (string)reader["regionSecret"];
115 regionprofile.regionSendKey = (string)reader["regionSendKey"];
116
117 // Region Server
118 regionprofile.regionDataURI = (string)reader["regionDataURI"];
119 regionprofile.regionOnline = false; // Needs to be pinged before this can be set.
120 regionprofile.serverIP = (string)reader["serverIP"];
121 regionprofile.serverPort = (uint)reader["serverPort"];
122 regionprofile.serverURI = (string)reader["serverURI"];
123
124 // Location
125 regionprofile.regionLocX = (uint)((int)reader["locX"]);
126 regionprofile.regionLocY = (uint)((int)reader["locY"]);
127 regionprofile.regionLocZ = (uint)((int)reader["locZ"]);
128
129 // Neighbours - 0 = No Override
130 regionprofile.regionEastOverrideHandle = (ulong)reader["eastOverrideHandle"];
131 regionprofile.regionWestOverrideHandle = (ulong)reader["westOverrideHandle"];
132 regionprofile.regionSouthOverrideHandle = (ulong)reader["southOverrideHandle"];
133 regionprofile.regionNorthOverrideHandle = (ulong)reader["northOverrideHandle"];
134
135 // Assets
136 regionprofile.regionAssetURI = (string)reader["regionAssetURI"];
137 regionprofile.regionAssetRecvKey = (string)reader["regionAssetRecvKey"];
138 regionprofile.regionAssetSendKey = (string)reader["regionAssetSendKey"];
139
140 // Userserver
141 regionprofile.regionUserURI = (string)reader["regionUserURI"];
142 regionprofile.regionUserRecvKey = (string)reader["regionUserRecvKey"];
143 regionprofile.regionUserSendKey = (string)reader["regionUserSendKey"];
144 }
145 else
146 {
147 throw new Exception("No rows to return");
148 }
149 return regionprofile;
150 }
151
152 /// <summary>
153 /// Creates a new region in the database
154 /// </summary>
155 /// <param name="profile">The region profile to insert</param>
156 /// <returns>Successful?</returns>
157 public bool insertRow(SimProfileData profile)
158 {
159 string sql = "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
160 sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
161 sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey) VALUES ";
162
163 sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, ";
164 sql += "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, ";
165 sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);";
166
167 Dictionary<string, string> parameters = new Dictionary<string, string>();
168
169 parameters["regionHandle"] = profile.regionHandle.ToString();
170 parameters["regionName"] = profile.regionName;
171 parameters["uuid"] = profile.UUID.ToString();
172 parameters["regionRecvKey"] = profile.regionRecvKey;
173 parameters["regionSendKey"] = profile.regionSendKey;
174 parameters["regionDataURI"] = profile.regionDataURI;
175 parameters["serverIP"] = profile.serverIP;
176 parameters["serverPort"] = profile.serverPort.ToString();
177 parameters["serverURI"] = profile.serverURI;
178 parameters["locX"] = profile.regionLocX.ToString();
179 parameters["locY"] = profile.regionLocY.ToString();
180 parameters["locZ"] = profile.regionLocZ.ToString();
181 parameters["eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString();
182 parameters["westOverrideHandle"] = profile.regionWestOverrideHandle.ToString();
183 parameters["northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString();
184 parameters["southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString();
185 parameters["regionAssetURI"] = profile.regionAssetURI;
186 parameters["regionAssetRecvKey"] = profile.regionAssetRecvKey;
187 parameters["regionAssetSendKey"] = profile.regionAssetSendKey;
188 parameters["regionUserURI"] = profile.regionUserURI;
189 parameters["regionUserRecvKey"] = profile.regionUserRecvKey;
190 parameters["regionUserSendKey"] = profile.regionUserSendKey;
191
192 bool returnval = false;
193
194 try
195 {
196 IDbCommand result = Query(sql, parameters);
197
198 if (result.ExecuteNonQuery() == 1)
199 returnval = true;
200
201 result.Dispose();
202 }
203 catch (Exception)
204 {
205 return false;
206 }
207
208 return returnval;
209 }
210 }
211}
diff --git a/OpenSim/Framework/Data.MSSQL/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.MSSQL/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..066c739
--- /dev/null
+++ b/OpenSim/Framework/Data.MSSQL/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Framework.Data.MSSQL")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenSim.Framework.Data.MSSQL")]
11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("0e1c1ca4-2cf2-4315-b0e7-432c02feea8a")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs
new file mode 100644
index 0000000..ef643d2
--- /dev/null
+++ b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs
@@ -0,0 +1,287 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Data;
31using System.Security.Cryptography;
32using System.Text;
33using libsecondlife;
34
35namespace OpenSim.Framework.Data.MySQL
36{
37 /// <summary>
38 /// A MySQL Interface for the Grid Server
39 /// </summary>
40 public class MySQLGridData : IGridData
41 {
42 /// <summary>
43 /// MySQL Database Manager
44 /// </summary>
45 private MySQLManager database;
46
47 /// <summary>
48 /// Initialises the Grid Interface
49 /// </summary>
50 public void Initialise()
51 {
52 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
53 string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
54 string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
55 string settingUsername = GridDataMySqlFile.ParseFileReadValue("username");
56 string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
57 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
58 string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
59
60 database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
61 }
62
63 /// <summary>
64 /// Shuts down the grid interface
65 /// </summary>
66 public void Close()
67 {
68 database.Close();
69 }
70
71 /// <summary>
72 /// Returns the plugin name
73 /// </summary>
74 /// <returns>Plugin name</returns>
75 public string getName()
76 {
77 return "MySql OpenGridData";
78 }
79
80 /// <summary>
81 /// Returns the plugin version
82 /// </summary>
83 /// <returns>Plugin version</returns>
84 public string getVersion()
85 {
86 return "0.1";
87 }
88
89 /// <summary>
90 /// Returns all the specified region profiles within coordates -- coordinates are inclusive
91 /// </summary>
92 /// <param name="xmin">Minimum X coordinate</param>
93 /// <param name="ymin">Minimum Y coordinate</param>
94 /// <param name="xmax">Maximum X coordinate</param>
95 /// <param name="ymax">Maximum Y coordinate</param>
96 /// <returns></returns>
97 public SimProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax)
98 {
99 try
100 {
101 lock (database)
102 {
103 Dictionary<string, string> param = new Dictionary<string, string>();
104 param["?xmin"] = xmin.ToString();
105 param["?ymin"] = ymin.ToString();
106 param["?xmax"] = xmax.ToString();
107 param["?ymax"] = ymax.ToString();
108
109 IDbCommand result = database.Query("SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", param);
110 IDataReader reader = result.ExecuteReader();
111
112 SimProfileData row;
113
114 List<SimProfileData> rows = new List<SimProfileData>();
115
116 while ((row = database.readSimRow(reader)) != null)
117 {
118 rows.Add(row);
119 }
120 reader.Close();
121 result.Dispose();
122
123 return rows.ToArray();
124
125 }
126 }
127 catch (Exception e)
128 {
129 database.Reconnect();
130 Console.WriteLine(e.ToString());
131 return null;
132 }
133 }
134
135 /// <summary>
136 /// Returns a sim profile from it's location
137 /// </summary>
138 /// <param name="handle">Region location handle</param>
139 /// <returns>Sim profile</returns>
140 public SimProfileData GetProfileByHandle(ulong handle)
141 {
142 try
143 {
144 lock (database)
145 {
146 Dictionary<string, string> param = new Dictionary<string, string>();
147 param["?handle"] = handle.ToString();
148
149 IDbCommand result = database.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param);
150 IDataReader reader = result.ExecuteReader();
151
152 SimProfileData row = database.readSimRow(reader);
153 reader.Close();
154 result.Dispose();
155
156 return row;
157 }
158 }
159 catch (Exception e)
160 {
161 database.Reconnect();
162 Console.WriteLine(e.ToString());
163 return null;
164 }
165 }
166
167 /// <summary>
168 /// Returns a sim profile from it's UUID
169 /// </summary>
170 /// <param name="uuid">The region UUID</param>
171 /// <returns>The sim profile</returns>
172 public SimProfileData GetProfileByLLUUID(LLUUID uuid)
173 {
174 try
175 {
176 lock (database)
177 {
178 Dictionary<string, string> param = new Dictionary<string, string>();
179 param["?uuid"] = uuid.ToStringHyphenated();
180
181 IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = ?uuid", param);
182 IDataReader reader = result.ExecuteReader();
183
184 SimProfileData row = database.readSimRow(reader);
185 reader.Close();
186 result.Dispose();
187
188 return row;
189 }
190 }
191 catch (Exception e)
192 {
193 database.Reconnect();
194 Console.WriteLine(e.ToString());
195 return null;
196 }
197 }
198
199 /// <summary>
200 /// Adds a new profile to the database
201 /// </summary>
202 /// <param name="profile">The profile to add</param>
203 /// <returns>Successful?</returns>
204 public DataResponse AddProfile(SimProfileData profile)
205 {
206 lock (database)
207 {
208 if (database.insertRegion(profile))
209 {
210 return DataResponse.RESPONSE_OK;
211 }
212 else
213 {
214 return DataResponse.RESPONSE_ERROR;
215 }
216 }
217 }
218
219 /// <summary>
220 /// DEPRECIATED. Attempts to authenticate a region by comparing a shared secret.
221 /// </summary>
222 /// <param name="uuid">The UUID of the challenger</param>
223 /// <param name="handle">The attempted regionHandle of the challenger</param>
224 /// <param name="authkey">The secret</param>
225 /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
226 public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey)
227 {
228 bool throwHissyFit = false; // Should be true by 1.0
229
230 if (throwHissyFit)
231 throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
232
233 SimProfileData data = GetProfileByLLUUID(uuid);
234
235 return (handle == data.regionHandle && authkey == data.regionSecret);
236 }
237
238 /// <summary>
239 /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region
240 /// </summary>
241 /// <remarks>This requires a security audit.</remarks>
242 /// <param name="uuid"></param>
243 /// <param name="handle"></param>
244 /// <param name="authhash"></param>
245 /// <param name="challenge"></param>
246 /// <returns></returns>
247 public bool AuthenticateSim(LLUUID uuid, ulong handle, string authhash, string challenge)
248 {
249 SHA512Managed HashProvider = new SHA512Managed();
250 ASCIIEncoding TextProvider = new ASCIIEncoding();
251
252 byte[] stream = TextProvider.GetBytes(uuid.ToStringHyphenated() + ":" + handle.ToString() + ":" + challenge);
253 byte[] hash = HashProvider.ComputeHash(stream);
254
255 return false;
256 }
257
258 public ReservationData GetReservationAtPoint(uint x, uint y)
259 {
260 try
261 {
262 lock (database)
263 {
264 Dictionary<string, string> param = new Dictionary<string, string>();
265 param["?x"] = x.ToString();
266 param["?y"] = y.ToString();
267 IDbCommand result = database.Query("SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", param);
268 IDataReader reader = result.ExecuteReader();
269
270 ReservationData row = database.readReservationRow(reader);
271 reader.Close();
272 result.Dispose();
273
274 return row;
275 }
276 }
277 catch (Exception e)
278 {
279 database.Reconnect();
280 Console.WriteLine(e.ToString());
281 return null;
282 }
283 }
284 }
285
286
287}
diff --git a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs
new file mode 100644
index 0000000..790759a
--- /dev/null
+++ b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs
@@ -0,0 +1,309 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Data;
31using libsecondlife;
32
33namespace OpenSim.Framework.Data.MySQL
34{
35 /// <summary>
36 /// A MySQL interface for the inventory server
37 /// </summary>
38 class MySQLInventoryData : IInventoryData
39 {
40 /// <summary>
41 /// The database manager
42 /// </summary>
43 public MySQLManager database;
44
45 /// <summary>
46 /// Loads and initialises this database plugin
47 /// </summary>
48 public void Initialise()
49 {
50 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
51 string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
52 string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
53 string settingUsername = GridDataMySqlFile.ParseFileReadValue("username");
54 string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
55 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
56 string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
57
58 database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
59 }
60
61 /// <summary>
62 /// The name of this DB provider
63 /// </summary>
64 /// <returns>Name of DB provider</returns>
65 public string getName()
66 {
67 return "MySQL Inventory Data Interface";
68 }
69
70 /// <summary>
71 /// Closes this DB provider
72 /// </summary>
73 public void Close()
74 {
75 // Do nothing.
76 }
77
78 /// <summary>
79 /// Returns the version of this DB provider
80 /// </summary>
81 /// <returns>A string containing the DB provider</returns>
82 public string getVersion()
83 {
84 return "0.1";
85 }
86
87 /// <summary>
88 /// Returns a list of items in a specified folder
89 /// </summary>
90 /// <param name="folderID">The folder to search</param>
91 /// <returns>A list containing inventory items</returns>
92 public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID)
93 {
94 try
95 {
96 lock (database)
97 {
98 Dictionary<string, string> param = new Dictionary<string, string>();
99 param["?uuid"] = folderID.ToStringHyphenated();
100
101 IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", param);
102 IDataReader reader = result.ExecuteReader();
103
104 List<InventoryItemBase> items = database.readInventoryItems(reader);
105
106 reader.Close();
107 result.Dispose();
108
109 return items;
110 }
111 }
112 catch (Exception e)
113 {
114 database.Reconnect();
115 Console.WriteLine(e.ToString());
116 return null;
117 }
118 }
119
120 /// <summary>
121 /// Returns a list of the root folders within a users inventory
122 /// </summary>
123 /// <param name="user">The user whos inventory is to be searched</param>
124 /// <returns>A list of folder objects</returns>
125 public List<InventoryFolderBase> getUserRootFolders(LLUUID user)
126 {
127 try
128 {
129 lock (database)
130 {
131 Dictionary<string, string> param = new Dictionary<string, string>();
132 param["?uuid"] = user.ToStringHyphenated();
133 param["?zero"] = LLUUID.Zero.ToStringHyphenated();
134
135 IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", param);
136 IDataReader reader = result.ExecuteReader();
137
138 List<InventoryFolderBase> items = database.readInventoryFolders(reader);
139
140 reader.Close();
141 result.Dispose();
142
143 return items;
144 }
145 }
146 catch (Exception e)
147 {
148 database.Reconnect();
149 Console.WriteLine(e.ToString());
150 return null;
151 }
152 }
153
154 /// <summary>
155 /// Returns a list of folders in a users inventory contained within the specified folder
156 /// </summary>
157 /// <param name="parentID">The folder to search</param>
158 /// <returns>A list of inventory folders</returns>
159 public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID)
160 {
161 try
162 {
163 lock (database)
164 {
165 Dictionary<string, string> param = new Dictionary<string, string>();
166 param["?uuid"] = parentID.ToStringHyphenated();
167
168 IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", param);
169 IDataReader reader = result.ExecuteReader();
170
171 List<InventoryFolderBase> items = database.readInventoryFolders(reader);
172
173 reader.Close();
174 result.Dispose();
175
176 return items;
177 }
178 }
179 catch (Exception e)
180 {
181 database.Reconnect();
182 Console.WriteLine(e.ToString());
183 return null;
184 }
185 }
186
187 /// <summary>
188 /// Returns a specified inventory item
189 /// </summary>
190 /// <param name="item">The item to return</param>
191 /// <returns>An inventory item</returns>
192 public InventoryItemBase getInventoryItem(LLUUID item)
193 {
194 try
195 {
196 lock (database)
197 {
198 Dictionary<string, string> param = new Dictionary<string, string>();
199 param["?uuid"] = item.ToStringHyphenated();
200
201 IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", param);
202 IDataReader reader = result.ExecuteReader();
203
204 List<InventoryItemBase> items = database.readInventoryItems(reader);
205
206 reader.Close();
207 result.Dispose();
208
209 if (items.Count > 0)
210 {
211 return items[0];
212 }
213 else
214 {
215 return null;
216 }
217 }
218 }
219 catch (Exception e)
220 {
221 database.Reconnect();
222 Console.WriteLine(e.ToString());
223 return null;
224 }
225 }
226
227 /// <summary>
228 /// Returns a specified inventory folder
229 /// </summary>
230 /// <param name="folder">The folder to return</param>
231 /// <returns>A folder class</returns>
232 public InventoryFolderBase getInventoryFolder(LLUUID folder)
233 {
234 try
235 {
236 lock (database)
237 {
238 Dictionary<string, string> param = new Dictionary<string, string>();
239 param["?uuid"] = folder.ToStringHyphenated();
240
241 IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", param);
242 IDataReader reader = result.ExecuteReader();
243
244 List<InventoryFolderBase> items = database.readInventoryFolders(reader);
245
246 reader.Close();
247 result.Dispose();
248
249 if (items.Count > 0)
250 {
251 return items[0];
252 }
253 else
254 {
255 return null;
256 }
257 }
258 }
259 catch (Exception e)
260 {
261 database.Reconnect();
262 Console.WriteLine(e.ToString());
263 return null;
264 }
265 }
266
267 /// <summary>
268 /// Adds a specified item to the database
269 /// </summary>
270 /// <param name="item">The inventory item</param>
271 public void addInventoryItem(InventoryItemBase item)
272 {
273 lock (database)
274 {
275 database.insertItem(item);
276 }
277 }
278
279 /// <summary>
280 /// Updates the specified inventory item
281 /// </summary>
282 /// <param name="item">Inventory item to update</param>
283 public void updateInventoryItem(InventoryItemBase item)
284 {
285 addInventoryItem(item);
286 }
287
288 /// <summary>
289 /// Creates a new inventory folder
290 /// </summary>
291 /// <param name="folder">Folder to create</param>
292 public void addInventoryFolder(InventoryFolderBase folder)
293 {
294 lock (database)
295 {
296 database.insertFolder(folder);
297 }
298 }
299
300 /// <summary>
301 /// Updates an inventory folder
302 /// </summary>
303 /// <param name="folder">Folder to update</param>
304 public void updateInventoryFolder(InventoryFolderBase folder)
305 {
306 addInventoryFolder(folder);
307 }
308 }
309}
diff --git a/OpenSim/Framework/Data.MySQL/MySQLLogData.cs b/OpenSim/Framework/Data.MySQL/MySQLLogData.cs
new file mode 100644
index 0000000..38f9fd3
--- /dev/null
+++ b/OpenSim/Framework/Data.MySQL/MySQLLogData.cs
@@ -0,0 +1,105 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29
30namespace OpenSim.Framework.Data.MySQL
31{
32 /// <summary>
33 /// An interface to the log database for MySQL
34 /// </summary>
35 class MySQLLogData : ILogData
36 {
37 /// <summary>
38 /// The database manager
39 /// </summary>
40 public MySQLManager database;
41
42 /// <summary>
43 /// Artificial constructor called when the plugin is loaded
44 /// </summary>
45 public void Initialise()
46 {
47 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
48 string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
49 string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
50 string settingUsername = GridDataMySqlFile.ParseFileReadValue("username");
51 string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
52 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
53 string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
54
55 database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
56 }
57
58 /// <summary>
59 /// Saves a log item to the database
60 /// </summary>
61 /// <param name="serverDaemon">The daemon triggering the event</param>
62 /// <param name="target">The target of the action (region / agent UUID, etc)</param>
63 /// <param name="methodCall">The method call where the problem occured</param>
64 /// <param name="arguments">The arguments passed to the method</param>
65 /// <param name="priority">How critical is this?</param>
66 /// <param name="logMessage">The message to log</param>
67 public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage)
68 {
69 try
70 {
71 database.insertLogRow(serverDaemon, target, methodCall, arguments, priority, logMessage);
72 }
73 catch
74 {
75 database.Reconnect();
76 }
77 }
78
79 /// <summary>
80 /// Returns the name of this DB provider
81 /// </summary>
82 /// <returns>A string containing the DB provider name</returns>
83 public string getName()
84 {
85 return "MySQL Logdata Interface";
86 }
87
88 /// <summary>
89 /// Closes the database provider
90 /// </summary>
91 public void Close()
92 {
93 // Do nothing.
94 }
95
96 /// <summary>
97 /// Returns the version of this DB provider
98 /// </summary>
99 /// <returns>A string containing the provider version</returns>
100 public string getVersion()
101 {
102 return "0.1";
103 }
104 }
105}
diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs
new file mode 100644
index 0000000..88365a3
--- /dev/null
+++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs
@@ -0,0 +1,602 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Data;
31using libsecondlife;
32using MySql.Data.MySqlClient;
33
34namespace OpenSim.Framework.Data.MySQL
35{
36 /// <summary>
37 /// A MySQL Database manager
38 /// </summary>
39 class MySQLManager
40 {
41 /// <summary>
42 /// The database connection object
43 /// </summary>
44 IDbConnection dbcon;
45 /// <summary>
46 /// Connection string for ADO.net
47 /// </summary>
48 string connectionString;
49
50 /// <summary>
51 /// Initialises and creates a new MySQL connection and maintains it.
52 /// </summary>
53 /// <param name="hostname">The MySQL server being connected to</param>
54 /// <param name="database">The name of the MySQL database being used</param>
55 /// <param name="username">The username logging into the database</param>
56 /// <param name="password">The password for the user logging in</param>
57 /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param>
58 public MySQLManager(string hostname, string database, string username, string password, string cpooling, string port)
59 {
60 try
61 {
62 connectionString = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";";
63 dbcon = new MySqlConnection(connectionString);
64
65 dbcon.Open();
66
67 Console.WriteLine("MySQL connection established");
68 }
69 catch (Exception e)
70 {
71 throw new Exception("Error initialising MySql Database: " + e.ToString());
72 }
73 }
74
75 /// <summary>
76 /// Shuts down the database connection
77 /// </summary>
78 public void Close()
79 {
80 dbcon.Close();
81 dbcon = null;
82 }
83
84 /// <summary>
85 /// Reconnects to the database
86 /// </summary>
87 public void Reconnect()
88 {
89 lock (dbcon)
90 {
91 try
92 {
93 // Close the DB connection
94 dbcon.Close();
95 // Try reopen it
96 dbcon = new MySqlConnection(connectionString);
97 dbcon.Open();
98 }
99 catch (Exception e)
100 {
101 Console.WriteLine("Unable to reconnect to database " + e.ToString());
102 }
103 }
104 }
105
106 /// <summary>
107 /// Runs a query with protection against SQL Injection by using parameterised input.
108 /// </summary>
109 /// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param>
110 /// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param>
111 /// <returns>A MySQL DB Command</returns>
112 public IDbCommand Query(string sql, Dictionary<string, string> parameters)
113 {
114 try
115 {
116 MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand();
117 dbcommand.CommandText = sql;
118 foreach (KeyValuePair<string, string> param in parameters)
119 {
120 dbcommand.Parameters.Add(param.Key, param.Value);
121 }
122
123 return (IDbCommand)dbcommand;
124 }
125 catch
126 {
127 lock (dbcon)
128 {
129 // Close the DB connection
130 try
131 {
132 dbcon.Close();
133 }
134 catch { }
135
136 // Try reopen it
137 try
138 {
139 dbcon = new MySqlConnection(connectionString);
140 dbcon.Open();
141 }
142 catch (Exception e)
143 {
144 Console.WriteLine("Unable to reconnect to database " + e.ToString());
145 }
146
147 // Run the query again
148 try
149 {
150 MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand();
151 dbcommand.CommandText = sql;
152 foreach (KeyValuePair<string, string> param in parameters)
153 {
154 dbcommand.Parameters.Add(param.Key, param.Value);
155 }
156
157 return (IDbCommand)dbcommand;
158 }
159 catch (Exception e)
160 {
161 // Return null if it fails.
162 Console.WriteLine("Failed during Query generation: " + e.ToString());
163 return null;
164 }
165 }
166 }
167 }
168
169 /// <summary>
170 /// Reads a region row from a database reader
171 /// </summary>
172 /// <param name="reader">An active database reader</param>
173 /// <returns>A region profile</returns>
174 public SimProfileData readSimRow(IDataReader reader)
175 {
176 SimProfileData retval = new SimProfileData();
177
178 if (reader.Read())
179 {
180 // Region Main
181 retval.regionHandle = Convert.ToUInt64(reader["regionHandle"].ToString());
182 retval.regionName = (string)reader["regionName"];
183 retval.UUID = new LLUUID((string)reader["uuid"]);
184
185 // Secrets
186 retval.regionRecvKey = (string)reader["regionRecvKey"];
187 retval.regionSecret = (string)reader["regionSecret"];
188 retval.regionSendKey = (string)reader["regionSendKey"];
189
190 // Region Server
191 retval.regionDataURI = (string)reader["regionDataURI"];
192 retval.regionOnline = false; // Needs to be pinged before this can be set.
193 retval.serverIP = (string)reader["serverIP"];
194 retval.serverPort = (uint)reader["serverPort"];
195 retval.serverURI = (string)reader["serverURI"];
196
197 // Location
198 retval.regionLocX = Convert.ToUInt32(reader["locX"].ToString());
199 retval.regionLocY = Convert.ToUInt32(reader["locY"].ToString());
200 retval.regionLocZ = Convert.ToUInt32(reader["locZ"].ToString());
201
202 // Neighbours - 0 = No Override
203 retval.regionEastOverrideHandle = Convert.ToUInt64(reader["eastOverrideHandle"].ToString());
204 retval.regionWestOverrideHandle = Convert.ToUInt64(reader["westOverrideHandle"].ToString());
205 retval.regionSouthOverrideHandle = Convert.ToUInt64(reader["southOverrideHandle"].ToString());
206 retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString());
207
208 // Assets
209 retval.regionAssetURI = (string)reader["regionAssetURI"];
210 retval.regionAssetRecvKey = (string)reader["regionAssetRecvKey"];
211 retval.regionAssetSendKey = (string)reader["regionAssetSendKey"];
212
213 // Userserver
214 retval.regionUserURI = (string)reader["regionUserURI"];
215 retval.regionUserRecvKey = (string)reader["regionUserRecvKey"];
216 retval.regionUserSendKey = (string)reader["regionUserSendKey"];
217
218 // World Map Addition
219 string tempRegionMap = reader["regionMapTexture"].ToString();
220 if (tempRegionMap != "")
221 {
222 retval.regionMapTextureID = new LLUUID(tempRegionMap);
223 }
224 else
225 {
226 retval.regionMapTextureID = new LLUUID();
227 }
228 }
229 else
230 {
231 return null;
232 }
233 return retval;
234 }
235
236 /// <summary>
237 /// Reads a reservation row from a database reader
238 /// </summary>
239 /// <param name="reader">An active database reader</param>
240 /// <returns>A reservation data object</returns>
241 public ReservationData readReservationRow(IDataReader reader)
242 {
243 ReservationData retval = new ReservationData();
244 if (reader.Read())
245 {
246 retval.gridRecvKey = (string)reader["gridRecvKey"];
247 retval.gridSendKey = (string)reader["gridSendKey"];
248 retval.reservationCompany = (string)reader["resCompany"];
249 retval.reservationMaxX = Convert.ToInt32(reader["resXMax"].ToString());
250 retval.reservationMaxY = Convert.ToInt32(reader["resYMax"].ToString());
251 retval.reservationMinX = Convert.ToInt32(reader["resXMin"].ToString());
252 retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString());
253 retval.reservationName = (string)reader["resName"];
254 retval.status = Convert.ToInt32(reader["status"].ToString()) == 1;
255 retval.userUUID = new LLUUID((string)reader["userUUID"]);
256
257 }
258 else
259 {
260 return null;
261 }
262 return retval;
263 }
264 /// <summary>
265 /// Reads an agent row from a database reader
266 /// </summary>
267 /// <param name="reader">An active database reader</param>
268 /// <returns>A user session agent</returns>
269 public UserAgentData readAgentRow(IDataReader reader)
270 {
271 UserAgentData retval = new UserAgentData();
272
273 if (reader.Read())
274 {
275 // Agent IDs
276 retval.UUID = new LLUUID((string)reader["UUID"]);
277 retval.sessionID = new LLUUID((string)reader["sessionID"]);
278 retval.secureSessionID = new LLUUID((string)reader["secureSessionID"]);
279
280 // Agent Who?
281 retval.agentIP = (string)reader["agentIP"];
282 retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString());
283 retval.agentOnline = Convert.ToBoolean(reader["agentOnline"].ToString());
284
285 // Login/Logout times (UNIX Epoch)
286 retval.loginTime = Convert.ToInt32(reader["loginTime"].ToString());
287 retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString());
288
289 // Current position
290 retval.currentRegion = (string)reader["currentRegion"];
291 retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString());
292 LLVector3.TryParse((string)reader["currentPos"], out retval.currentPos);
293 }
294 else
295 {
296 return null;
297 }
298 return retval;
299 }
300
301 /// <summary>
302 /// Reads a user profile from an active data reader
303 /// </summary>
304 /// <param name="reader">An active database reader</param>
305 /// <returns>A user profile</returns>
306 public UserProfileData readUserRow(IDataReader reader)
307 {
308 UserProfileData retval = new UserProfileData();
309
310 if (reader.Read())
311 {
312 retval.UUID = new LLUUID((string)reader["UUID"]);
313 retval.username = (string)reader["username"];
314 retval.surname = (string)reader["lastname"];
315
316 retval.passwordHash = (string)reader["passwordHash"];
317 retval.passwordSalt = (string)reader["passwordSalt"];
318
319 retval.homeRegion = Convert.ToUInt64(reader["homeRegion"].ToString());
320 retval.homeLocation = new LLVector3(
321 Convert.ToSingle(reader["homeLocationX"].ToString()),
322 Convert.ToSingle(reader["homeLocationY"].ToString()),
323 Convert.ToSingle(reader["homeLocationZ"].ToString()));
324 retval.homeLookAt = new LLVector3(
325 Convert.ToSingle(reader["homeLookAtX"].ToString()),
326 Convert.ToSingle(reader["homeLookAtY"].ToString()),
327 Convert.ToSingle(reader["homeLookAtZ"].ToString()));
328
329 retval.created = Convert.ToInt32(reader["created"].ToString());
330 retval.lastLogin = Convert.ToInt32(reader["lastLogin"].ToString());
331
332 retval.userInventoryURI = (string)reader["userInventoryURI"];
333 retval.userAssetURI = (string)reader["userAssetURI"];
334
335 retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString());
336 retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString());
337
338 retval.profileAboutText = (string)reader["profileAboutText"];
339 retval.profileFirstText = (string)reader["profileFirstText"];
340
341 retval.profileImage = new LLUUID((string)reader["profileImage"]);
342 retval.profileFirstImage = new LLUUID((string)reader["profileFirstImage"]);
343
344 }
345 else
346 {
347 return null;
348 }
349 return retval;
350 }
351
352 /// <summary>
353 /// Reads a list of inventory folders returned by a query.
354 /// </summary>
355 /// <param name="reader">A MySQL Data Reader</param>
356 /// <returns>A List containing inventory folders</returns>
357 public List<InventoryFolderBase> readInventoryFolders(IDataReader reader)
358 {
359 List<InventoryFolderBase> rows = new List<InventoryFolderBase>();
360
361 while(reader.Read())
362 {
363 try
364 {
365 InventoryFolderBase folder = new InventoryFolderBase();
366
367 folder.agentID = new LLUUID((string)reader["agentID"]);
368 folder.parentID = new LLUUID((string)reader["parentFolderID"]);
369 folder.folderID = new LLUUID((string)reader["folderID"]);
370 folder.name = (string)reader["folderName"];
371
372 rows.Add(folder);
373 }
374 catch (Exception e)
375 {
376 Console.WriteLine(e.ToString());
377 }
378 }
379
380 return rows;
381 }
382
383 /// <summary>
384 /// Reads a collection of items from an SQL result
385 /// </summary>
386 /// <param name="reader">The SQL Result</param>
387 /// <returns>A List containing Inventory Items</returns>
388 public List<InventoryItemBase> readInventoryItems(IDataReader reader)
389 {
390 List<InventoryItemBase> rows = new List<InventoryItemBase>();
391
392 while (reader.Read())
393 {
394 try
395 {
396 InventoryItemBase item = new InventoryItemBase();
397
398 item.assetID = new LLUUID((string)reader["assetID"]);
399 item.avatarID = new LLUUID((string)reader["avatarID"]);
400 item.inventoryCurrentPermissions = Convert.ToUInt32(reader["inventoryCurrentPermissions"].ToString());
401 item.inventoryDescription = (string)reader["inventoryDescription"];
402 item.inventoryID = new LLUUID((string)reader["inventoryID"]);
403 item.inventoryName = (string)reader["inventoryName"];
404 item.inventoryNextPermissions = Convert.ToUInt32(reader["inventoryNextPermissions"].ToString());
405 item.parentFolderID = new LLUUID((string)reader["parentFolderID"]);
406 item.type = Convert.ToInt32(reader["type"].ToString());
407
408 rows.Add(item);
409 }
410 catch (Exception e)
411 {
412 Console.WriteLine(e.ToString());
413 }
414 }
415
416 return rows;
417 }
418
419 /// <summary>
420 /// Inserts a new row into the log database
421 /// </summary>
422 /// <param name="serverDaemon">The daemon which triggered this event</param>
423 /// <param name="target">Who were we operating on when this occured (region UUID, user UUID, etc)</param>
424 /// <param name="methodCall">The method call where the problem occured</param>
425 /// <param name="arguments">The arguments passed to the method</param>
426 /// <param name="priority">How critical is this?</param>
427 /// <param name="logMessage">Extra message info</param>
428 /// <returns>Saved successfully?</returns>
429 public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage)
430 {
431 string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES ";
432 sql += "(?target, ?server, ?method, ?arguments, ?priority, ?message)";
433
434 Dictionary<string, string> parameters = new Dictionary<string, string>();
435 parameters["?server"] = serverDaemon;
436 parameters["?target"] = target;
437 parameters["?method"] = methodCall;
438 parameters["?arguments"] = arguments;
439 parameters["?priority"] = priority.ToString();
440 parameters["?message"] = logMessage;
441
442 bool returnval = false;
443
444 try
445 {
446 IDbCommand result = Query(sql, parameters);
447
448 if (result.ExecuteNonQuery() == 1)
449 returnval = true;
450
451 result.Dispose();
452 }
453 catch (Exception e)
454 {
455 Console.WriteLine(e.ToString());
456 return false;
457 }
458
459 return returnval;
460 }
461
462 /// <summary>
463 /// Inserts a new item into the database
464 /// </summary>
465 /// <param name="item">The item</param>
466 /// <returns>Success?</returns>
467 public bool insertItem(InventoryItemBase item)
468 {
469 string sql = "REPLACE INTO inventoryitems (inventoryID, assetID, type, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions) VALUES ";
470 sql += "(?inventoryID, ?assetID, ?type, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription, ?inventoryNextPermissions, ?inventoryCurrentPermissions)";
471
472 Dictionary<string, string> parameters = new Dictionary<string, string>();
473 parameters["?inventoryID"] = item.inventoryID.ToStringHyphenated();
474 parameters["?assetID"] = item.assetID.ToStringHyphenated();
475 parameters["?type"] = item.type.ToString();
476 parameters["?parentFolderID"] = item.parentFolderID.ToStringHyphenated();
477 parameters["?avatarID"] = item.avatarID.ToStringHyphenated();
478 parameters["?inventoryName"] = item.inventoryName;
479 parameters["?inventoryDescription"] = item.inventoryDescription;
480 parameters["?inventoryNextPermissions"] = item.inventoryNextPermissions.ToString();
481 parameters["?inventoryCurrentPermissions"] = item.inventoryCurrentPermissions.ToString();
482
483 bool returnval = false;
484
485 try
486 {
487 IDbCommand result = Query(sql, parameters);
488
489 if (result.ExecuteNonQuery() == 1)
490 returnval = true;
491
492 result.Dispose();
493 }
494 catch (Exception e)
495 {
496 Console.WriteLine(e.ToString());
497 return false;
498 }
499
500 return returnval;
501 }
502
503 /// <summary>
504 /// Inserts a new folder into the database
505 /// </summary>
506 /// <param name="folder">The folder</param>
507 /// <returns>Success?</returns>
508 public bool insertFolder(InventoryFolderBase folder)
509 {
510 string sql = "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName) VALUES ";
511 sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName)";
512
513 Dictionary<string, string> parameters = new Dictionary<string, string>();
514 parameters["?folderID"] = folder.folderID.ToStringHyphenated();
515 parameters["?agentID"] = folder.agentID.ToStringHyphenated();
516 parameters["?parentFolderID"] = folder.parentID.ToStringHyphenated();
517 parameters["?folderName"] = folder.name;
518
519 bool returnval = false;
520 try
521 {
522 IDbCommand result = Query(sql, parameters);
523
524 if (result.ExecuteNonQuery() == 1)
525 returnval = true;
526
527 result.Dispose();
528 }
529 catch (Exception e)
530 {
531 Console.WriteLine(e.ToString());
532 return false;
533 }
534 return returnval;
535 }
536
537 /// <summary>
538 /// Inserts a new region into the database
539 /// </summary>
540 /// <param name="profile">The region to insert</param>
541 /// <returns>Success?</returns>
542 public bool insertRegion(SimProfileData regiondata)
543 {
544 string sql = "REPLACE INTO regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
545 sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
546 sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture) VALUES ";
547
548 sql += "(?regionHandle, ?regionName, ?uuid, ?regionRecvKey, ?regionSecret, ?regionSendKey, ?regionDataURI, ";
549 sql += "?serverIP, ?serverPort, ?serverURI, ?locX, ?locY, ?locZ, ?eastOverrideHandle, ?westOverrideHandle, ?southOverrideHandle, ?northOverrideHandle, ?regionAssetURI, ?regionAssetRecvKey, ";
550 sql += "?regionAssetSendKey, ?regionUserURI, ?regionUserRecvKey, ?regionUserSendKey, ?regionMapTexture);";
551
552 Dictionary<string, string> parameters = new Dictionary<string, string>();
553
554 parameters["?regionHandle"] = regiondata.regionHandle.ToString();
555 parameters["?regionName"] = regiondata.regionName.ToString();
556 parameters["?uuid"] = regiondata.UUID.ToStringHyphenated();
557 parameters["?regionRecvKey"] = regiondata.regionRecvKey.ToString();
558 parameters["?regionSecret"] = regiondata.regionSecret.ToString();
559 parameters["?regionSendKey"] = regiondata.regionSendKey.ToString();
560 parameters["?regionDataURI"] = regiondata.regionDataURI.ToString();
561 parameters["?serverIP"] = regiondata.serverIP.ToString();
562 parameters["?serverPort"] = regiondata.serverPort.ToString();
563 parameters["?serverURI"] = regiondata.serverURI.ToString();
564 parameters["?locX"] = regiondata.regionLocX.ToString();
565 parameters["?locY"] = regiondata.regionLocY.ToString();
566 parameters["?locZ"] = regiondata.regionLocZ.ToString();
567 parameters["?eastOverrideHandle"] = regiondata.regionEastOverrideHandle.ToString();
568 parameters["?westOverrideHandle"] = regiondata.regionWestOverrideHandle.ToString();
569 parameters["?northOverrideHandle"] = regiondata.regionNorthOverrideHandle.ToString();
570 parameters["?southOverrideHandle"] = regiondata.regionSouthOverrideHandle.ToString();
571 parameters["?regionAssetURI"] = regiondata.regionAssetURI.ToString();
572 parameters["?regionAssetRecvKey"] = regiondata.regionAssetRecvKey.ToString();
573 parameters["?regionAssetSendKey"] = regiondata.regionAssetSendKey.ToString();
574 parameters["?regionUserURI"] = regiondata.regionUserURI.ToString();
575 parameters["?regionUserRecvKey"] = regiondata.regionUserRecvKey.ToString();
576 parameters["?regionUserSendKey"] = regiondata.regionUserSendKey.ToString();
577 parameters["?regionMapTexture"] = regiondata.regionMapTextureID.ToStringHyphenated();
578
579 bool returnval = false;
580
581 try
582 {
583
584 IDbCommand result = Query(sql, parameters);
585
586 //Console.WriteLine(result.CommandText);
587
588 if (result.ExecuteNonQuery() == 1)
589 returnval = true;
590
591 result.Dispose();
592 }
593 catch (Exception e)
594 {
595 Console.WriteLine(e.ToString());
596 return false;
597 }
598
599 return returnval;
600 }
601 }
602}
diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
new file mode 100644
index 0000000..c116536
--- /dev/null
+++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
@@ -0,0 +1,256 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Data;
31using libsecondlife;
32
33namespace OpenSim.Framework.Data.MySQL
34{
35 /// <summary>
36 /// A database interface class to a user profile storage system
37 /// </summary>
38 class MySQLUserData : IUserData
39 {
40 /// <summary>
41 /// Database manager for MySQL
42 /// </summary>
43 public MySQLManager database;
44
45 /// <summary>
46 /// Loads and initialises the MySQL storage plugin
47 /// </summary>
48 public void Initialise()
49 {
50 // Load from an INI file connection details
51 // TODO: move this to XML?
52 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
53 string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
54 string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
55 string settingUsername = GridDataMySqlFile.ParseFileReadValue("username");
56 string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
57 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
58 string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
59
60 database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
61 }
62
63 /// <summary>
64 /// Searches the database for a specified user profile
65 /// </summary>
66 /// <param name="name">The account name of the user</param>
67 /// <returns>A user profile</returns>
68 public UserProfileData getUserByName(string name)
69 {
70 return getUserByName(name.Split(' ')[0], name.Split(' ')[1]);
71 }
72
73 /// <summary>
74 /// Searches the database for a specified user profile by name components
75 /// </summary>
76 /// <param name="user">The first part of the account name</param>
77 /// <param name="last">The second part of the account name</param>
78 /// <returns>A user profile</returns>
79 public UserProfileData getUserByName(string user, string last)
80 {
81 try
82 {
83 lock (database)
84 {
85 Dictionary<string, string> param = new Dictionary<string, string>();
86 param["?first"] = user;
87 param["?second"] = last;
88
89 IDbCommand result = database.Query("SELECT * FROM users WHERE username = ?first AND lastname = ?second", param);
90 IDataReader reader = result.ExecuteReader();
91
92 UserProfileData row = database.readUserRow(reader);
93
94 reader.Close();
95 result.Dispose();
96
97 return row;
98 }
99 }
100 catch (Exception e)
101 {
102 database.Reconnect();
103 Console.WriteLine(e.ToString());
104 return null;
105 }
106 }
107
108 /// <summary>
109 /// Searches the database for a specified user profile by UUID
110 /// </summary>
111 /// <param name="uuid">The account ID</param>
112 /// <returns>The users profile</returns>
113 public UserProfileData getUserByUUID(LLUUID uuid)
114 {
115 try
116 {
117 lock (database)
118 {
119 Dictionary<string, string> param = new Dictionary<string, string>();
120 param["?uuid"] = uuid.ToStringHyphenated();
121
122 IDbCommand result = database.Query("SELECT * FROM users WHERE UUID = ?uuid", param);
123 IDataReader reader = result.ExecuteReader();
124
125 UserProfileData row = database.readUserRow(reader);
126
127 reader.Close();
128 result.Dispose();
129
130 return row;
131 }
132 }
133 catch (Exception e)
134 {
135 database.Reconnect();
136 Console.WriteLine(e.ToString());
137 return null;
138 }
139 }
140
141 /// <summary>
142 /// Returns a user session searching by name
143 /// </summary>
144 /// <param name="name">The account name</param>
145 /// <returns>The users session</returns>
146 public UserAgentData getAgentByName(string name)
147 {
148 return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]);
149 }
150
151 /// <summary>
152 /// Returns a user session by account name
153 /// </summary>
154 /// <param name="user">First part of the users account name</param>
155 /// <param name="last">Second part of the users account name</param>
156 /// <returns>The users session</returns>
157 public UserAgentData getAgentByName(string user, string last)
158 {
159 UserProfileData profile = getUserByName(user, last);
160 return getAgentByUUID(profile.UUID);
161 }
162
163 /// <summary>
164 /// Returns an agent session by account UUID
165 /// </summary>
166 /// <param name="uuid">The accounts UUID</param>
167 /// <returns>The users session</returns>
168 public UserAgentData getAgentByUUID(LLUUID uuid)
169 {
170 try
171 {
172 lock (database)
173 {
174 Dictionary<string, string> param = new Dictionary<string, string>();
175 param["?uuid"] = uuid.ToStringHyphenated();
176
177 IDbCommand result = database.Query("SELECT * FROM agents WHERE UUID = ?uuid", param);
178 IDataReader reader = result.ExecuteReader();
179
180 UserAgentData row = database.readAgentRow(reader);
181
182 reader.Close();
183 result.Dispose();
184
185 return row;
186 }
187 }
188 catch (Exception e)
189 {
190 database.Reconnect();
191 Console.WriteLine(e.ToString());
192 return null;
193 }
194 }
195
196 /// <summary>
197 /// Creates a new users profile
198 /// </summary>
199 /// <param name="user">The user profile to create</param>
200 public void addNewUserProfile(UserProfileData user)
201 {
202 }
203
204 /// <summary>
205 /// Creates a new agent
206 /// </summary>
207 /// <param name="agent">The agent to create</param>
208 public void addNewUserAgent(UserAgentData agent)
209 {
210 // Do nothing.
211 }
212
213 /// <summary>
214 /// Performs a money transfer request between two accounts
215 /// </summary>
216 /// <param name="from">The senders account ID</param>
217 /// <param name="to">The recievers account ID</param>
218 /// <param name="amount">The amount to transfer</param>
219 /// <returns>Success?</returns>
220 public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount)
221 {
222 return false;
223 }
224
225 /// <summary>
226 /// Performs an inventory transfer request between two accounts
227 /// </summary>
228 /// <remarks>TODO: Move to inventory server</remarks>
229 /// <param name="from">The senders account ID</param>
230 /// <param name="to">The recievers account ID</param>
231 /// <param name="item">The item to transfer</param>
232 /// <returns>Success?</returns>
233 public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
234 {
235 return false;
236 }
237
238 /// <summary>
239 /// Database provider name
240 /// </summary>
241 /// <returns>Provider name</returns>
242 public string getName()
243 {
244 return "MySQL Userdata Interface";
245 }
246
247 /// <summary>
248 /// Database provider version
249 /// </summary>
250 /// <returns>provider version</returns>
251 public string getVersion()
252 {
253 return "0.1";
254 }
255 }
256}
diff --git a/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..52d6a54
--- /dev/null
+++ b/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Framework.Data.MySQL")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenSim.Framework.Data.MySQL")]
11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("e49826b2-dcef-41be-a5bd-596733fa3304")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..9de5edb
--- /dev/null
+++ b/OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Framework.Data.SQLite")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenSim.Framework.Data.SQLite")]
11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("6113d5ce-4547-49f4-9236-0dcc503457b1")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs b/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs
new file mode 100644
index 0000000..511c5f0
--- /dev/null
+++ b/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs
@@ -0,0 +1,197 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Data;
31using System.Security.Cryptography;
32using System.Text;
33using libsecondlife;
34
35namespace OpenSim.Framework.Data.SQLite
36{
37 /// <summary>
38 /// A Grid Interface to the SQLite database
39 /// </summary>
40 public class SQLiteGridData : IGridData
41 {
42 /// <summary>
43 /// A database manager
44 /// </summary>
45 private SQLiteManager database;
46
47 /// <summary>
48 /// Initialises the Grid Interface
49 /// </summary>
50 public void Initialise()
51 {
52 database = new SQLiteManager("localhost", "db", "user", "password", "false");
53 }
54
55 /// <summary>
56 /// Shuts down the grid interface
57 /// </summary>
58 public void Close()
59 {
60 database.Close();
61 }
62
63 /// <summary>
64 /// Returns the name of this grid interface
65 /// </summary>
66 /// <returns>A string containing the grid interface</returns>
67 public string getName()
68 {
69 return "SQLite OpenGridData";
70 }
71
72 /// <summary>
73 /// Returns the version of this grid interface
74 /// </summary>
75 /// <returns>A string containing the version</returns>
76 public string getVersion()
77 {
78 return "0.1";
79 }
80
81 /// <summary>
82 /// Returns a list of regions within the specified ranges
83 /// </summary>
84 /// <param name="a">minimum X coordinate</param>
85 /// <param name="b">minimum Y coordinate</param>
86 /// <param name="c">maximum X coordinate</param>
87 /// <param name="d">maximum Y coordinate</param>
88 /// <returns>An array of region profiles</returns>
89 public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
90 {
91 return null;
92 }
93
94 /// <summary>
95 /// Returns a sim profile from it's location
96 /// </summary>
97 /// <param name="handle">Region location handle</param>
98 /// <returns>Sim profile</returns>
99 public SimProfileData GetProfileByHandle(ulong handle)
100 {
101 Dictionary<string, string> param = new Dictionary<string, string>();
102 param["handle"] = handle.ToString();
103
104 IDbCommand result = database.Query("SELECT * FROM regions WHERE handle = @handle", param);
105 IDataReader reader = result.ExecuteReader();
106
107 SimProfileData row = database.getRow(reader);
108 reader.Close();
109 result.Dispose();
110
111 return row;
112 }
113
114 /// <summary>
115 /// Returns a sim profile from it's UUID
116 /// </summary>
117 /// <param name="uuid">The region UUID</param>
118 /// <returns>The sim profile</returns>
119 public SimProfileData GetProfileByLLUUID(LLUUID uuid)
120 {
121 Dictionary<string, string> param = new Dictionary<string, string>();
122 param["uuid"] = uuid.ToStringHyphenated();
123
124 IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = @uuid", param);
125 IDataReader reader = result.ExecuteReader();
126
127 SimProfileData row = database.getRow(reader);
128 reader.Close();
129 result.Dispose();
130
131 return row;
132 }
133
134 /// <summary>
135 /// Adds a new specified region to the database
136 /// </summary>
137 /// <param name="profile">The profile to add</param>
138 /// <returns>A dataresponse enum indicating success</returns>
139 public DataResponse AddProfile(SimProfileData profile)
140 {
141 if (database.insertRow(profile))
142 {
143 return DataResponse.RESPONSE_OK;
144 }
145 else
146 {
147 return DataResponse.RESPONSE_ERROR;
148 }
149 }
150
151 /// <summary>
152 /// DEPRECIATED. Attempts to authenticate a region by comparing a shared secret.
153 /// </summary>
154 /// <param name="uuid">The UUID of the challenger</param>
155 /// <param name="handle">The attempted regionHandle of the challenger</param>
156 /// <param name="authkey">The secret</param>
157 /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
158 public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey)
159 {
160 bool throwHissyFit = false; // Should be true by 1.0
161
162 if (throwHissyFit)
163 throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
164
165 SimProfileData data = GetProfileByLLUUID(uuid);
166
167 return (handle == data.regionHandle && authkey == data.regionSecret);
168 }
169
170 /// <summary>
171 /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region
172 /// </summary>
173 /// <remarks>This requires a security audit.</remarks>
174 /// <param name="uuid"></param>
175 /// <param name="handle"></param>
176 /// <param name="authhash"></param>
177 /// <param name="challenge"></param>
178 /// <returns></returns>
179 public bool AuthenticateSim(LLUUID uuid, ulong handle, string authhash, string challenge)
180 {
181 SHA512Managed HashProvider = new SHA512Managed();
182 ASCIIEncoding TextProvider = new ASCIIEncoding();
183
184 byte[] stream = TextProvider.GetBytes(uuid.ToStringHyphenated() + ":" + handle.ToString() + ":" + challenge);
185 byte[] hash = HashProvider.ComputeHash(stream);
186
187 return false;
188 }
189
190 public ReservationData GetReservationAtPoint(uint x, uint y)
191 {
192 return null;
193 }
194 }
195
196
197}
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteManager.cs b/OpenSim/Framework/Data.SQLite/SQLiteManager.cs
new file mode 100644
index 0000000..c9931ab
--- /dev/null
+++ b/OpenSim/Framework/Data.SQLite/SQLiteManager.cs
@@ -0,0 +1,206 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Data;
31using System.Data.SQLite;
32using libsecondlife;
33
34namespace OpenSim.Framework.Data.SQLite
35{
36 class SQLiteManager
37 {
38 IDbConnection dbcon;
39
40 /// <summary>
41 /// Initialises and creates a new SQLite connection and maintains it.
42 /// </summary>
43 /// <param name="hostname">The SQLite server being connected to</param>
44 /// <param name="database">The name of the SQLite database being used</param>
45 /// <param name="username">The username logging into the database</param>
46 /// <param name="password">The password for the user logging in</param>
47 /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param>
48 public SQLiteManager(string hostname, string database, string username, string password, string cpooling)
49 {
50 try
51 {
52 string connectionString = "URI=file:GridServerSqlite.db;";
53 dbcon = new SQLiteConnection(connectionString);
54
55 dbcon.Open();
56 }
57 catch (Exception e)
58 {
59 throw new Exception("Error initialising SQLite Database: " + e.ToString());
60 }
61 }
62
63 /// <summary>
64 /// Shuts down the database connection
65 /// </summary>
66 public void Close()
67 {
68 dbcon.Close();
69 dbcon = null;
70 }
71
72 /// <summary>
73 /// Runs a query with protection against SQL Injection by using parameterised input.
74 /// </summary>
75 /// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param>
76 /// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param>
77 /// <returns>A SQLite DB Command</returns>
78 public IDbCommand Query(string sql, Dictionary<string, string> parameters)
79 {
80 SQLiteCommand dbcommand = (SQLiteCommand)dbcon.CreateCommand();
81 dbcommand.CommandText = sql;
82 foreach (KeyValuePair<string, string> param in parameters)
83 {
84 SQLiteParameter paramx = new SQLiteParameter(param.Key,param.Value);
85 dbcommand.Parameters.Add(paramx);
86 }
87
88 return (IDbCommand)dbcommand;
89 }
90
91 /// <summary>
92 /// Reads a region row from a database reader
93 /// </summary>
94 /// <param name="reader">An active database reader</param>
95 /// <returns>A region profile</returns>
96 public SimProfileData getRow(IDataReader reader)
97 {
98 SimProfileData retval = new SimProfileData();
99
100 if (reader.Read())
101 {
102 // Region Main
103 retval.regionHandle = (ulong)reader["regionHandle"];
104 retval.regionName = (string)reader["regionName"];
105 retval.UUID = new LLUUID((string)reader["uuid"]);
106
107 // Secrets
108 retval.regionRecvKey = (string)reader["regionRecvKey"];
109 retval.regionSecret = (string)reader["regionSecret"];
110 retval.regionSendKey = (string)reader["regionSendKey"];
111
112 // Region Server
113 retval.regionDataURI = (string)reader["regionDataURI"];
114 retval.regionOnline = false; // Needs to be pinged before this can be set.
115 retval.serverIP = (string)reader["serverIP"];
116 retval.serverPort = (uint)reader["serverPort"];
117 retval.serverURI = (string)reader["serverURI"];
118
119 // Location
120 retval.regionLocX = (uint)((int)reader["locX"]);
121 retval.regionLocY = (uint)((int)reader["locY"]);
122 retval.regionLocZ = (uint)((int)reader["locZ"]);
123
124 // Neighbours - 0 = No Override
125 retval.regionEastOverrideHandle = (ulong)reader["eastOverrideHandle"];
126 retval.regionWestOverrideHandle = (ulong)reader["westOverrideHandle"];
127 retval.regionSouthOverrideHandle = (ulong)reader["southOverrideHandle"];
128 retval.regionNorthOverrideHandle = (ulong)reader["northOverrideHandle"];
129
130 // Assets
131 retval.regionAssetURI = (string)reader["regionAssetURI"];
132 retval.regionAssetRecvKey = (string)reader["regionAssetRecvKey"];
133 retval.regionAssetSendKey = (string)reader["regionAssetSendKey"];
134
135 // Userserver
136 retval.regionUserURI = (string)reader["regionUserURI"];
137 retval.regionUserRecvKey = (string)reader["regionUserRecvKey"];
138 retval.regionUserSendKey = (string)reader["regionUserSendKey"];
139 }
140 else
141 {
142 throw new Exception("No rows to return");
143 }
144 return retval;
145 }
146
147 /// <summary>
148 /// Inserts a new region into the database
149 /// </summary>
150 /// <param name="profile">The region to insert</param>
151 /// <returns>Success?</returns>
152 public bool insertRow(SimProfileData profile)
153 {
154 string sql = "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
155 sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
156 sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey) VALUES ";
157
158 sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, ";
159 sql += "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, ";
160 sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);";
161
162 Dictionary<string, string> parameters = new Dictionary<string, string>();
163
164 parameters["regionHandle"] = profile.regionHandle.ToString();
165 parameters["regionName"] = profile.regionName;
166 parameters["uuid"] = profile.UUID.ToString();
167 parameters["regionRecvKey"] = profile.regionRecvKey;
168 parameters["regionSendKey"] = profile.regionSendKey;
169 parameters["regionDataURI"] = profile.regionDataURI;
170 parameters["serverIP"] = profile.serverIP;
171 parameters["serverPort"] = profile.serverPort.ToString();
172 parameters["serverURI"] = profile.serverURI;
173 parameters["locX"] = profile.regionLocX.ToString();
174 parameters["locY"] = profile.regionLocY.ToString();
175 parameters["locZ"] = profile.regionLocZ.ToString();
176 parameters["eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString();
177 parameters["westOverrideHandle"] = profile.regionWestOverrideHandle.ToString();
178 parameters["northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString();
179 parameters["southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString();
180 parameters["regionAssetURI"] = profile.regionAssetURI;
181 parameters["regionAssetRecvKey"] = profile.regionAssetRecvKey;
182 parameters["regionAssetSendKey"] = profile.regionAssetSendKey;
183 parameters["regionUserURI"] = profile.regionUserURI;
184 parameters["regionUserRecvKey"] = profile.regionUserRecvKey;
185 parameters["regionUserSendKey"] = profile.regionUserSendKey;
186
187 bool returnval = false;
188
189 try
190 {
191 IDbCommand result = Query(sql, parameters);
192
193 if (result.ExecuteNonQuery() == 1)
194 returnval = true;
195
196 result.Dispose();
197 }
198 catch (Exception)
199 {
200 return false;
201 }
202
203 return returnval;
204 }
205 }
206}
diff --git a/OpenSim/Framework/Data/GridData.cs b/OpenSim/Framework/Data/GridData.cs
new file mode 100644
index 0000000..5a17d20
--- /dev/null
+++ b/OpenSim/Framework/Data/GridData.cs
@@ -0,0 +1,111 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using libsecondlife;
29
30namespace OpenSim.Framework.Data
31{
32 public enum DataResponse
33 {
34 RESPONSE_OK,
35 RESPONSE_AUTHREQUIRED,
36 RESPONSE_INVALIDCREDENTIALS,
37 RESPONSE_ERROR
38 }
39
40 /// <summary>
41 /// A standard grid interface
42 /// </summary>
43 public interface IGridData
44 {
45 /// <summary>
46 /// Returns a sim profile from a regionHandle
47 /// </summary>
48 /// <param name="regionHandle">A 64bit Region Handle</param>
49 /// <returns>A simprofile</returns>
50 SimProfileData GetProfileByHandle(ulong regionHandle);
51
52 /// <summary>
53 /// Returns a sim profile from a UUID
54 /// </summary>
55 /// <param name="UUID">A 128bit UUID</param>
56 /// <returns>A sim profile</returns>
57 SimProfileData GetProfileByLLUUID(LLUUID UUID);
58
59 /// <summary>
60 /// Returns all profiles within the specified range
61 /// </summary>
62 /// <param name="Xmin">Minimum sim coordinate (X)</param>
63 /// <param name="Ymin">Minimum sim coordinate (Y)</param>
64 /// <param name="Xmax">Maximum sim coordinate (X)</param>
65 /// <param name="Ymin">Maximum sim coordinate (Y)</param>
66 /// <returns>An array containing all the sim profiles in the specified range</returns>
67 SimProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
68
69 /// <summary>
70 /// Authenticates a sim by use of it's recv key.
71 /// WARNING: Insecure
72 /// </summary>
73 /// <param name="UUID">The UUID sent by the sim</param>
74 /// <param name="regionHandle">The regionhandle sent by the sim</param>
75 /// <param name="simrecvkey">The recieving key sent by the sim</param>
76 /// <returns>Whether the sim has been authenticated</returns>
77 bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey);
78
79 /// <summary>
80 /// Initialises the interface
81 /// </summary>
82 void Initialise();
83
84 /// <summary>
85 /// Closes the interface
86 /// </summary>
87 void Close();
88
89 /// <summary>
90 /// The plugin being loaded
91 /// </summary>
92 /// <returns>A string containing the plugin name</returns>
93 string getName();
94
95 /// <summary>
96 /// The plugins version
97 /// </summary>
98 /// <returns>A string containing the plugin version</returns>
99 string getVersion();
100
101 /// <summary>
102 /// Adds a new profile to the database
103 /// </summary>
104 /// <param name="profile">The profile to add</param>
105 /// <returns>RESPONSE_OK if successful, error if not.</returns>
106 DataResponse AddProfile(SimProfileData profile);
107
108 ReservationData GetReservationAtPoint(uint x, uint y);
109
110 }
111}
diff --git a/OpenSim/Framework/Data/ILogData.cs b/OpenSim/Framework/Data/ILogData.cs
new file mode 100644
index 0000000..059fef5
--- /dev/null
+++ b/OpenSim/Framework/Data/ILogData.cs
@@ -0,0 +1,90 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28namespace OpenSim.Framework.Data
29{
30 /// <summary>
31 /// The severity of an individual log message
32 /// </summary>
33 public enum LogSeverity : int
34 {
35 /// <summary>
36 /// Critical: systems failure
37 /// </summary>
38 CRITICAL = 1,
39 /// <summary>
40 /// Major: warning prior to systems failure
41 /// </summary>
42 MAJOR = 2,
43 /// <summary>
44 /// Medium: an individual non-critical task failed
45 /// </summary>
46 MEDIUM = 3,
47 /// <summary>
48 /// Low: Informational warning
49 /// </summary>
50 LOW = 4,
51 /// <summary>
52 /// Info: Information
53 /// </summary>
54 INFO = 5,
55 /// <summary>
56 /// Verbose: Debug Information
57 /// </summary>
58 VERBOSE = 6
59 }
60
61 /// <summary>
62 /// An interface to a LogData storage system
63 /// </summary>
64 public interface ILogData
65 {
66 void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,string logMessage);
67 /// <summary>
68 /// Initialises the interface
69 /// </summary>
70 void Initialise();
71
72 /// <summary>
73 /// Closes the interface
74 /// </summary>
75 void Close();
76
77 /// <summary>
78 /// The plugin being loaded
79 /// </summary>
80 /// <returns>A string containing the plugin name</returns>
81 string getName();
82
83 /// <summary>
84 /// The plugins version
85 /// </summary>
86 /// <returns>A string containing the plugin version</returns>
87 string getVersion();
88 }
89
90}
diff --git a/OpenSim/Framework/Data/IniConfig.cs b/OpenSim/Framework/Data/IniConfig.cs
new file mode 100644
index 0000000..2b52fd1
--- /dev/null
+++ b/OpenSim/Framework/Data/IniConfig.cs
@@ -0,0 +1,96 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.IO;
29using System.Text.RegularExpressions;
30/*
31 Taken from public code listing at by Alex Pinsker
32 http://alexpinsker.blogspot.com/2005/12/reading-ini-file-from-c_113432097333021549.html
33 */
34
35namespace OpenSim.Framework.Data
36{
37 /// <summary>
38 /// Parse settings from ini-like files
39 /// </summary>
40 public class IniFile
41 {
42 static IniFile()
43 {
44 _iniKeyValuePatternRegex = new Regex(
45 @"((\s)*(?<Key>([^\=^\s^\n]+))[\s^\n]*
46 # key part (surrounding whitespace stripped)
47 \=
48 (\s)*(?<Value>([^\n^\s]+(\n){0,1})))
49 # value part (surrounding whitespace stripped)
50 ",
51 RegexOptions.IgnorePatternWhitespace |
52 RegexOptions.Compiled |
53 RegexOptions.CultureInvariant);
54 }
55 static private Regex _iniKeyValuePatternRegex;
56
57 public IniFile(string iniFileName)
58 {
59 _iniFileName = iniFileName;
60 }
61
62 public string ParseFileReadValue(string key)
63 {
64 using (StreamReader reader =
65 new StreamReader(_iniFileName))
66 {
67 do
68 {
69 string line = reader.ReadLine();
70 Match match =
71 _iniKeyValuePatternRegex.Match(line);
72 if (match.Success)
73 {
74 string currentKey =
75 match.Groups["Key"].Value as string;
76 if (currentKey != null &&
77 currentKey.Trim().CompareTo(key) == 0)
78 {
79 string value =
80 match.Groups["Value"].Value as string;
81 return value;
82 }
83 }
84
85 }
86 while (reader.Peek() != -1);
87 }
88 return null;
89 }
90
91 public string IniFileName
92 {
93 get { return _iniFileName; }
94 } private string _iniFileName;
95 }
96}
diff --git a/OpenSim/Framework/Data/InventoryData.cs b/OpenSim/Framework/Data/InventoryData.cs
new file mode 100644
index 0000000..c2a1d06
--- /dev/null
+++ b/OpenSim/Framework/Data/InventoryData.cs
@@ -0,0 +1,185 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Collections.Generic;
29using libsecondlife;
30
31namespace OpenSim.Framework.Data
32{
33 /// <summary>
34 /// Inventory Item - contains all the properties associated with an individual inventory piece.
35 /// </summary>
36 public class InventoryItemBase
37 {
38 /// <summary>
39 /// A UUID containing the ID for the inventory item itself
40 /// </summary>
41 public LLUUID inventoryID;
42 /// <summary>
43 /// The UUID of the associated asset on the asset server
44 /// </summary>
45 public LLUUID assetID;
46 /// <summary>
47 /// This is an enumerated value determining the type of asset (eg Notecard, Sound, Object, etc)
48 /// </summary>
49 public int type;
50 /// <summary>
51 /// The folder this item is contained in (NULL_KEY = Inventory Root)
52 /// </summary>
53 public LLUUID parentFolderID;
54 /// <summary>
55 /// The owner of this inventory item
56 /// </summary>
57 public LLUUID avatarID;
58 /// <summary>
59 /// The name of the inventory item (must be less than 64 characters)
60 /// </summary>
61 public string inventoryName;
62 /// <summary>
63 /// The description of the inventory item (must be less than 64 characters)
64 /// </summary>
65 public string inventoryDescription;
66 /// <summary>
67 /// A mask containing the permissions for the next owner (cannot be enforced)
68 /// </summary>
69 public uint inventoryNextPermissions;
70 /// <summary>
71 /// A mask containing permissions for the current owner (cannot be enforced)
72 /// </summary>
73 public uint inventoryCurrentPermissions;
74 }
75
76 /// <summary>
77 /// A Class for folders which contain users inventory
78 /// </summary>
79 public class InventoryFolderBase
80 {
81 /// <summary>
82 /// The name of the folder (64 characters or less)
83 /// </summary>
84 public string name;
85 /// <summary>
86 /// The agent who's inventory this is contained by
87 /// </summary>
88 public LLUUID agentID;
89 /// <summary>
90 /// The folder this folder is contained in (NULL_KEY for root)
91 /// </summary>
92 public LLUUID parentID;
93 /// <summary>
94 /// The UUID for this folder
95 /// </summary>
96 public LLUUID folderID;
97 }
98
99 /// <summary>
100 /// An interface for accessing inventory data from a storage server
101 /// </summary>
102 public interface IInventoryData
103 {
104 /// <summary>
105 /// Initialises the interface
106 /// </summary>
107 void Initialise();
108
109 /// <summary>
110 /// Closes the interface
111 /// </summary>
112 void Close();
113
114 /// <summary>
115 /// The plugin being loaded
116 /// </summary>
117 /// <returns>A string containing the plugin name</returns>
118 string getName();
119
120 /// <summary>
121 /// The plugins version
122 /// </summary>
123 /// <returns>A string containing the plugin version</returns>
124 string getVersion();
125
126 /// <summary>
127 /// Returns a list of inventory items contained within the specified folder
128 /// </summary>
129 /// <param name="folderID">The UUID of the target folder</param>
130 /// <returns>A List of InventoryItemBase items</returns>
131 List<InventoryItemBase> getInventoryInFolder(LLUUID folderID);
132
133 /// <summary>
134 /// Returns a list of folders in the users inventory root.
135 /// </summary>
136 /// <param name="user">The UUID of the user who is having inventory being returned</param>
137 /// <returns>A list of folders</returns>
138 List<InventoryFolderBase> getUserRootFolders(LLUUID user);
139
140 /// <summary>
141 /// Returns a list of inventory folders contained in the folder 'parentID'
142 /// </summary>
143 /// <param name="parentID">The folder to get subfolders for</param>
144 /// <returns>A list of inventory folders</returns>
145 List<InventoryFolderBase> getInventoryFolders(LLUUID parentID);
146
147 /// <summary>
148 /// Returns an inventory item by its UUID
149 /// </summary>
150 /// <param name="item">The UUID of the item to be returned</param>
151 /// <returns>A class containing item information</returns>
152 InventoryItemBase getInventoryItem(LLUUID item);
153
154 /// <summary>
155 /// Returns a specified inventory folder by its UUID
156 /// </summary>
157 /// <param name="folder">The UUID of the folder to be returned</param>
158 /// <returns>A class containing folder information</returns>
159 InventoryFolderBase getInventoryFolder(LLUUID folder);
160
161 /// <summary>
162 /// Creates a new inventory item based on item
163 /// </summary>
164 /// <param name="item">The item to be created</param>
165 void addInventoryItem(InventoryItemBase item);
166
167 /// <summary>
168 /// Updates an inventory item with item (updates based on ID)
169 /// </summary>
170 /// <param name="item">The updated item</param>
171 void updateInventoryItem(InventoryItemBase item);
172
173 /// <summary>
174 /// Adds a new folder specified by folder
175 /// </summary>
176 /// <param name="folder">The inventory folder</param>
177 void addInventoryFolder(InventoryFolderBase folder);
178
179 /// <summary>
180 /// Updates a folder based on its ID with folder
181 /// </summary>
182 /// <param name="folder">The inventory folder</param>
183 void updateInventoryFolder(InventoryFolderBase folder);
184 }
185}
diff --git a/OpenSim/Framework/Data/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..f9260a1
--- /dev/null
+++ b/OpenSim/Framework/Data/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Framework.Data")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenSim.Framework.Data")]
11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("3a711c34-b0c0-4264-b0fe-f366eabf9d7b")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Framework/Data/ReservationData.cs b/OpenSim/Framework/Data/ReservationData.cs
new file mode 100644
index 0000000..0078df0
--- /dev/null
+++ b/OpenSim/Framework/Data/ReservationData.cs
@@ -0,0 +1,47 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using libsecondlife;
29
30namespace OpenSim.Framework.Data
31{
32 public class ReservationData
33 {
34 public LLUUID userUUID = new LLUUID();
35 public int reservationMinX = 0;
36 public int reservationMinY = 0;
37 public int reservationMaxX = 65536;
38 public int reservationMaxY = 65536;
39
40 public string reservationName = "";
41 public string reservationCompany = "";
42 public bool status = true;
43
44 public string gridSendKey = "";
45 public string gridRecvKey = "";
46 }
47}
diff --git a/OpenSim/Framework/Data/SimProfileData.cs b/OpenSim/Framework/Data/SimProfileData.cs
new file mode 100644
index 0000000..b920cab
--- /dev/null
+++ b/OpenSim/Framework/Data/SimProfileData.cs
@@ -0,0 +1,192 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using libsecondlife;
29using Nwc.XmlRpc;
30
31using System;
32using System.Collections;
33
34namespace OpenSim.Framework.Data
35{
36 /// <summary>
37 /// A class which contains information known to the grid server about a region
38 /// </summary>
39 public class SimProfileData
40 {
41 /// <summary>
42 /// The name of the region
43 /// </summary>
44 public string regionName = "";
45
46 /// <summary>
47 /// A 64-bit number combining map position into a (mostly) unique ID
48 /// </summary>
49 public ulong regionHandle;
50
51 /// <summary>
52 /// OGS/OpenSim Specific ID for a region
53 /// </summary>
54 public LLUUID UUID;
55
56 /// <summary>
57 /// Coordinates of the region
58 /// </summary>
59 public uint regionLocX;
60 public uint regionLocY;
61 public uint regionLocZ; // Reserved (round-robin, layers, etc)
62
63 /// <summary>
64 /// Authentication secrets
65 /// </summary>
66 /// <remarks>Not very secure, needs improvement.</remarks>
67 public string regionSendKey = "";
68 public string regionRecvKey = "";
69 public string regionSecret = "";
70
71 /// <summary>
72 /// Whether the region is online
73 /// </summary>
74 public bool regionOnline;
75
76 /// <summary>
77 /// Information about the server that the region is currently hosted on
78 /// </summary>
79 public string serverIP = "";
80 public uint serverPort;
81 public string serverURI = "";
82
83 public uint httpPort;
84 public uint remotingPort;
85 public string httpServerURI = "";
86
87 /// <summary>
88 /// Set of optional overrides. Can be used to create non-eulicidean spaces.
89 /// </summary>
90 public ulong regionNorthOverrideHandle;
91 public ulong regionSouthOverrideHandle;
92 public ulong regionEastOverrideHandle;
93 public ulong regionWestOverrideHandle;
94
95 /// <summary>
96 /// Optional: URI Location of the region database
97 /// </summary>
98 /// <remarks>Used for floating sim pools where the region data is not nessecarily coupled to a specific server</remarks>
99 public string regionDataURI = "";
100
101 /// <summary>
102 /// Region Asset Details
103 /// </summary>
104 public string regionAssetURI = "";
105 public string regionAssetSendKey = "";
106 public string regionAssetRecvKey = "";
107
108 /// <summary>
109 /// Region Userserver Details
110 /// </summary>
111 public string regionUserURI = "";
112 public string regionUserSendKey = "";
113 public string regionUserRecvKey = "";
114
115 /// <summary>
116 /// Region Map Texture Asset
117 /// </summary>
118 public LLUUID regionMapTextureID = new LLUUID("00000000-0000-0000-9999-000000000006");
119
120 /// <summary>
121 /// Get Sim profile data from grid server when in grid mode
122 /// </summary>
123 /// <param name="region_uuid"></param>
124 /// <param name="gridserver_url"></param>
125 /// <param name="?"></param>
126 /// <returns></returns>
127 public SimProfileData RequestSimProfileData(LLUUID region_uuid, string gridserver_url, string gridserver_sendkey, string gridserver_recvkey)
128 {
129 Hashtable requestData = new Hashtable();
130 requestData["region_uuid"] = region_uuid.UUID.ToString();
131 requestData["authkey"] = gridserver_sendkey;
132 ArrayList SendParams = new ArrayList();
133 SendParams.Add(requestData);
134 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
135 XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
136
137 Hashtable responseData = (Hashtable)GridResp.Value;
138
139 if (responseData.ContainsKey("error"))
140 {
141 return null;
142 }
143
144 SimProfileData simData = new SimProfileData();
145 simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]);
146 simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]);
147 simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * 256), (simData.regionLocY * 256));
148 simData.serverIP = (string)responseData["sim_ip"];
149 simData.serverPort = Convert.ToUInt32((string)responseData["sim_port"]);
150 simData.httpPort = Convert.ToUInt32((string)responseData["http_port"]);
151 simData.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
152 simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/";
153 simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/";
154 simData.UUID = new LLUUID((string)responseData["region_UUID"]);
155 simData.regionName = (string)responseData["region_name"];
156
157 return simData;
158 }
159 public SimProfileData RequestSimProfileData(ulong region_handle, string gridserver_url, string gridserver_sendkey, string gridserver_recvkey)
160 {
161 Hashtable requestData = new Hashtable();
162 requestData["region_handle"] = region_handle.ToString();
163 requestData["authkey"] = gridserver_sendkey;
164 ArrayList SendParams = new ArrayList();
165 SendParams.Add(requestData);
166 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
167 XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
168
169 Hashtable responseData = (Hashtable)GridResp.Value;
170
171 if (responseData.ContainsKey("error"))
172 {
173 return null;
174 }
175
176 SimProfileData simData = new SimProfileData();
177 simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]);
178 simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]);
179 simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * 256), (simData.regionLocY * 256));
180 simData.serverIP = (string)responseData["sim_ip"];
181 simData.serverPort = Convert.ToUInt32((string)responseData["sim_port"]);
182 simData.httpPort = Convert.ToUInt32((string)responseData["http_port"]);
183 simData.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
184 simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/";
185 simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/";
186 simData.UUID = new LLUUID((string)responseData["region_UUID"]);
187 simData.regionName = (string)responseData["region_name"];
188
189 return simData;
190 }
191 }
192}
diff --git a/OpenSim/Framework/Data/UserData.cs b/OpenSim/Framework/Data/UserData.cs
new file mode 100644
index 0000000..c65f9fd
--- /dev/null
+++ b/OpenSim/Framework/Data/UserData.cs
@@ -0,0 +1,128 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using libsecondlife;
29
30namespace OpenSim.Framework.Data
31{
32 /// <summary>
33 /// An interface for connecting to user storage servers.
34 /// </summary>
35 public interface IUserData
36 {
37 /// <summary>
38 /// Returns a user profile from a database via their UUID
39 /// </summary>
40 /// <param name="user">The accounts UUID</param>
41 /// <returns>The user data profile</returns>
42 UserProfileData getUserByUUID(LLUUID user);
43
44 /// <summary>
45 /// Returns a users profile by searching their username
46 /// </summary>
47 /// <param name="name">The users username</param>
48 /// <returns>The user data profile</returns>
49 UserProfileData getUserByName(string name);
50
51 /// <summary>
52 /// Returns a users profile by searching their username parts
53 /// </summary>
54 /// <param name="fname">Account firstname</param>
55 /// <param name="lname">Account lastname</param>
56 /// <returns>The user data profile</returns>
57 UserProfileData getUserByName(string fname, string lname);
58
59 /// <summary>
60 /// Returns the current agent for a user searching by it's UUID
61 /// </summary>
62 /// <param name="user">The users UUID</param>
63 /// <returns>The current agent session</returns>
64 UserAgentData getAgentByUUID(LLUUID user);
65
66 /// <summary>
67 /// Returns the current session agent for a user searching by username
68 /// </summary>
69 /// <param name="name">The users account name</param>
70 /// <returns>The current agent session</returns>
71 UserAgentData getAgentByName(string name);
72
73 /// <summary>
74 /// Returns the current session agent for a user searching by username parts
75 /// </summary>
76 /// <param name="fname">The users first account name</param>
77 /// <param name="lname">The users account surname</param>
78 /// <returns>The current agent session</returns>
79 UserAgentData getAgentByName(string fname, string lname);
80
81 /// <summary>
82 /// Adds a new User profile to the database
83 /// </summary>
84 /// <param name="user">UserProfile to add</param>
85 void addNewUserProfile(UserProfileData user);
86
87 /// <summary>
88 /// Adds a new agent to the database
89 /// </summary>
90 /// <param name="agent">The agent to add</param>
91 void addNewUserAgent(UserAgentData agent);
92
93 /// <summary>
94 /// Attempts to move currency units between accounts (NOT RELIABLE / TRUSTWORTHY. DONT TRY RUN YOUR OWN CURRENCY EXCHANGE WITH REAL VALUES)
95 /// </summary>
96 /// <param name="from">The account to transfer from</param>
97 /// <param name="to">The account to transfer to</param>
98 /// <param name="amount">The amount to transfer</param>
99 /// <returns>Successful?</returns>
100 bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount);
101
102 /// <summary>
103 /// Attempts to move inventory between accounts, if inventory is copyable it will be copied into the target account.
104 /// </summary>
105 /// <param name="from">User to transfer from</param>
106 /// <param name="to">User to transfer to</param>
107 /// <param name="inventory">Specified inventory item</param>
108 /// <returns>Successful?</returns>
109 bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID inventory);
110
111 /// <summary>
112 /// Returns the plugin version
113 /// </summary>
114 /// <returns>Plugin version in MAJOR.MINOR.REVISION.BUILD format</returns>
115 string getVersion();
116
117 /// <summary>
118 /// Returns the plugin name
119 /// </summary>
120 /// <returns>Plugin name, eg MySQL User Provider</returns>
121 string getName();
122
123 /// <summary>
124 /// Initialises the plugin (artificial constructor)
125 /// </summary>
126 void Initialise();
127 }
128}
diff --git a/OpenSim/Framework/Data/UserProfileData.cs b/OpenSim/Framework/Data/UserProfileData.cs
new file mode 100644
index 0000000..bb7d48c
--- /dev/null
+++ b/OpenSim/Framework/Data/UserProfileData.cs
@@ -0,0 +1,180 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using libsecondlife;
30
31namespace OpenSim.Framework.Data
32{
33 /// <summary>
34 /// Information about a particular user known to the userserver
35 /// </summary>
36 public class UserProfileData
37 {
38 /// <summary>
39 /// The ID value for this user
40 /// </summary>
41 public LLUUID UUID;
42
43 /// <summary>
44 /// The first component of a users account name
45 /// </summary>
46 public string username;
47 /// <summary>
48 /// The second component of a users account name
49 /// </summary>
50 public string surname;
51
52 /// <summary>
53 /// A salted hash containing the users password, in the format md5(md5(password) + ":" + salt)
54 /// </summary>
55 /// <remarks>This is double MD5'd because the client sends an unsalted MD5 to the loginserver</remarks>
56 public string passwordHash;
57 /// <summary>
58 /// The salt used for the users hash, should be 32 bytes or longer
59 /// </summary>
60 public string passwordSalt;
61
62 /// <summary>
63 /// The regionhandle of the users preffered home region. If multiple sims occupy the same spot, the grid may decide which region the user logs into
64 /// </summary>
65 public ulong homeRegion;
66 /// <summary>
67 /// The coordinates inside the region of the home location
68 /// </summary>
69 public LLVector3 homeLocation;
70 /// <summary>
71 /// Where the user will be looking when they rez.
72 /// </summary>
73 public LLVector3 homeLookAt;
74
75 /// <summary>
76 /// A UNIX Timestamp (seconds since epoch) for the users creation
77 /// </summary>
78 public int created;
79 /// <summary>
80 /// A UNIX Timestamp for the users last login date / time
81 /// </summary>
82 public int lastLogin;
83
84 /// <summary>
85 /// A URI to the users inventory server, used for foreigners and large grids
86 /// </summary>
87 public string userInventoryURI;
88 /// <summary>
89 /// A URI to the users asset server, used for foreigners and large grids.
90 /// </summary>
91 public string userAssetURI;
92
93 /// <summary>
94 /// A uint mask containing the "I can do" fields of the users profile
95 /// </summary>
96 public uint profileCanDoMask;
97 /// <summary>
98 /// A uint mask containing the "I want to do" part of the users profile
99 /// </summary>
100 public uint profileWantDoMask; // Profile window "I want to" mask
101
102 /// <summary>
103 /// The about text listed in a users profile.
104 /// </summary>
105 public string profileAboutText;
106 /// <summary>
107 /// The first life about text listed in a users profile
108 /// </summary>
109 public string profileFirstText;
110
111 /// <summary>
112 /// The profile image for an avatar stored on the asset server
113 /// </summary>
114 public LLUUID profileImage;
115 /// <summary>
116 /// The profile image for the users first life tab
117 /// </summary>
118 public LLUUID profileFirstImage;
119 /// <summary>
120 /// The users last registered agent (filled in on the user server)
121 /// </summary>
122 public UserAgentData currentAgent;
123 }
124
125 /// <summary>
126 /// Information about a users session
127 /// </summary>
128 public class UserAgentData
129 {
130 /// <summary>
131 /// The UUID of the users avatar (not the agent!)
132 /// </summary>
133 public LLUUID UUID;
134 /// <summary>
135 /// The IP address of the user
136 /// </summary>
137 public string agentIP = String.Empty;
138 /// <summary>
139 /// The port of the user
140 /// </summary>
141 public uint agentPort;
142 /// <summary>
143 /// Is the user online?
144 /// </summary>
145 public bool agentOnline;
146 /// <summary>
147 /// The session ID for the user (also the agent ID)
148 /// </summary>
149 public LLUUID sessionID;
150 /// <summary>
151 /// The "secure" session ID for the user
152 /// </summary>
153 /// <remarks>Not very secure. Dont rely on it for anything more than Linden Lab does.</remarks>
154 public LLUUID secureSessionID;
155 /// <summary>
156 /// The region the user logged into initially
157 /// </summary>
158 public LLUUID regionID;
159 /// <summary>
160 /// A unix timestamp from when the user logged in
161 /// </summary>
162 public int loginTime;
163 /// <summary>
164 /// When this agent expired and logged out, 0 if still online
165 /// </summary>
166 public int logoutTime;
167 /// <summary>
168 /// Current region the user is logged into
169 /// </summary>
170 public LLUUID currentRegion;
171 /// <summary>
172 /// Region handle of the current region the user is in
173 /// </summary>
174 public ulong currentHandle;
175 /// <summary>
176 /// The position of the user within the region
177 /// </summary>
178 public LLVector3 currentPos;
179 }
180}
diff --git a/OpenSim/Framework/General/AgentInventory.cs b/OpenSim/Framework/General/AgentInventory.cs
new file mode 100644
index 0000000..e45a0cd
--- /dev/null
+++ b/OpenSim/Framework/General/AgentInventory.cs
@@ -0,0 +1,265 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Collections.Generic;
29using libsecondlife;
30using libsecondlife.Packets;
31using OpenSim.Framework.Types;
32using OpenSim.Framework.Utilities;
33
34namespace OpenSim.Framework.Inventory
35{
36 public class AgentInventory
37 {
38 //Holds the local copy of Inventory info for a agent
39 public Dictionary<LLUUID, InventoryFolder> InventoryFolders;
40 public Dictionary<LLUUID, InventoryItem> InventoryItems;
41 public InventoryFolder InventoryRoot;
42 public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server
43 public LLUUID AgentID;
44 public AvatarWearable[] Wearables;
45
46 public AgentInventory()
47 {
48 InventoryFolders = new Dictionary<LLUUID, InventoryFolder>();
49 InventoryItems = new Dictionary<LLUUID, InventoryItem>();
50 this.Initialise();
51 }
52
53 public virtual void Initialise()
54 {
55 Wearables = new AvatarWearable[13]; //should be 12 of these
56 for (int i = 0; i < 13; i++)
57 {
58 Wearables[i] = new AvatarWearable();
59 }
60
61 }
62
63 public bool CreateNewFolder(LLUUID folderID, ushort type)
64 {
65 InventoryFolder Folder = new InventoryFolder();
66 Folder.FolderID = folderID;
67 Folder.OwnerID = this.AgentID;
68 Folder.DefaultType = type;
69 this.InventoryFolders.Add(Folder.FolderID, Folder);
70 return (true);
71 }
72
73 public void CreateRootFolder(LLUUID newAgentID, bool createTextures)
74 {
75 this.AgentID = newAgentID;
76 InventoryRoot = new InventoryFolder();
77 InventoryRoot.FolderID = LLUUID.Random();
78 InventoryRoot.ParentID = new LLUUID();
79 InventoryRoot.Version = 1;
80 InventoryRoot.DefaultType = 8;
81 InventoryRoot.OwnerID = this.AgentID;
82 InventoryRoot.FolderName = "My Inventory";
83 InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot);
84 InventoryRoot.OwnerID = this.AgentID;
85 if (createTextures)
86 {
87 this.CreateNewFolder(LLUUID.Random(), 0, "Textures", InventoryRoot.FolderID);
88 }
89 }
90
91 public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName)
92 {
93 InventoryFolder Folder = new InventoryFolder();
94 Folder.FolderID = folderID;
95 Folder.OwnerID = this.AgentID;
96 Folder.DefaultType = type;
97 Folder.FolderName = folderName;
98 this.InventoryFolders.Add(Folder.FolderID, Folder);
99
100 return (true);
101 }
102
103 public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parent)
104 {
105 if (!this.InventoryFolders.ContainsKey(folderID))
106 {
107 System.Console.WriteLine("creating new folder called " + folderName + " in agents inventory");
108 InventoryFolder Folder = new InventoryFolder();
109 Folder.FolderID = folderID;
110 Folder.OwnerID = this.AgentID;
111 Folder.DefaultType = type;
112 Folder.FolderName = folderName;
113 Folder.ParentID = parent;
114 this.InventoryFolders.Add(Folder.FolderID, Folder);
115 }
116
117 return (true);
118 }
119
120 public bool HasFolder(LLUUID folderID)
121 {
122 if (this.InventoryFolders.ContainsKey(folderID))
123 {
124 return true;
125 }
126 return false;
127 }
128
129 public LLUUID GetFolderID(string folderName)
130 {
131 foreach (InventoryFolder inv in this.InventoryFolders.Values)
132 {
133 if (inv.FolderName == folderName)
134 {
135 return inv.FolderID;
136 }
137 }
138
139 return LLUUID.Zero;
140 }
141
142 public bool UpdateItemAsset(LLUUID itemID, AssetBase asset)
143 {
144 if(this.InventoryItems.ContainsKey(itemID))
145 {
146 InventoryItem Item = this.InventoryItems[itemID];
147 Item.AssetID = asset.FullID;
148 System.Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated() + " so it now is set to asset " + asset.FullID.ToStringHyphenated());
149 //TODO need to update the rest of the info
150 }
151 return true;
152 }
153
154 public bool UpdateItemDetails(LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet)
155 {
156 System.Console.WriteLine("updating inventory item details");
157 if (this.InventoryItems.ContainsKey(itemID))
158 {
159 System.Console.WriteLine("changing name to "+ Util.FieldToString(packet.Name));
160 InventoryItem Item = this.InventoryItems[itemID];
161 Item.Name = Util.FieldToString(packet.Name);
162 System.Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated());
163 //TODO need to update the rest of the info
164 }
165 return true;
166 }
167
168 public LLUUID AddToInventory(LLUUID folderID, AssetBase asset)
169 {
170 if (this.InventoryFolders.ContainsKey(folderID))
171 {
172 LLUUID NewItemID = LLUUID.Random();
173
174 InventoryItem Item = new InventoryItem();
175 Item.FolderID = folderID;
176 Item.OwnerID = AgentID;
177 Item.AssetID = asset.FullID;
178 Item.ItemID = NewItemID;
179 Item.Type = asset.Type;
180 Item.Name = asset.Name;
181 Item.Description = asset.Description;
182 Item.InvType = asset.InvType;
183 this.InventoryItems.Add(Item.ItemID, Item);
184 InventoryFolder Folder = InventoryFolders[Item.FolderID];
185 Folder.Items.Add(Item);
186 return (Item.ItemID);
187 }
188 else
189 {
190 return (null);
191 }
192 }
193
194 public bool DeleteFromInventory(LLUUID itemID)
195 {
196 bool res = false;
197 if (this.InventoryItems.ContainsKey(itemID))
198 {
199 InventoryItem item = this.InventoryItems[itemID];
200 this.InventoryItems.Remove(itemID);
201 foreach (InventoryFolder fold in InventoryFolders.Values)
202 {
203 if (fold.Items.Contains(item))
204 {
205 fold.Items.Remove(item);
206 break;
207 }
208 }
209 res = true;
210
211 }
212 return res;
213 }
214 }
215
216 public class InventoryFolder
217 {
218 public List<InventoryItem> Items;
219 //public List<InventoryFolder> Subfolders;
220 public LLUUID FolderID;
221 public LLUUID OwnerID;
222 public LLUUID ParentID = LLUUID.Zero;
223 public string FolderName;
224 public ushort DefaultType;
225 public ushort Version;
226
227 public InventoryFolder()
228 {
229 Items = new List<InventoryItem>();
230 //Subfolders = new List<InventoryFolder>();
231 }
232
233 }
234
235 public class InventoryItem
236 {
237 public LLUUID FolderID;
238 public LLUUID OwnerID;
239 public LLUUID ItemID;
240 public LLUUID AssetID;
241 public LLUUID CreatorID;
242 public sbyte InvType;
243 public sbyte Type;
244 public string Name ="";
245 public string Description;
246
247 public InventoryItem()
248 {
249 this.CreatorID = LLUUID.Zero;
250 }
251
252 public string ExportString()
253 {
254 string typ = "notecard";
255 string result = "";
256 result += "\tinv_object\t0\n\t{\n";
257 result += "\t\tobj_id\t%s\n";
258 result += "\t\tparent_id\t"+ ItemID.ToString() +"\n";
259 result += "\t\ttype\t"+ typ +"\n";
260 result += "\t\tname\t" + Name+"|\n";
261 result += "\t}\n";
262 return result;
263 }
264 }
265}
diff --git a/OpenSim/Framework/General/AuthenticateSessionBase.cs b/OpenSim/Framework/General/AuthenticateSessionBase.cs
new file mode 100644
index 0000000..71616e3
--- /dev/null
+++ b/OpenSim/Framework/General/AuthenticateSessionBase.cs
@@ -0,0 +1,130 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Collections.Generic;
29using libsecondlife;
30using OpenSim.Framework.Interfaces;
31using OpenSim.Framework.Types;
32
33namespace OpenSim.Framework
34{
35 public class AuthenticateSessionsBase
36 {
37 public Dictionary<uint, AgentCircuitData> AgentCircuits = new Dictionary<uint, AgentCircuitData>();
38
39 public AuthenticateSessionsBase()
40 {
41
42 }
43
44 public virtual AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode)
45 {
46 AgentCircuitData validcircuit = null;
47 if (this.AgentCircuits.ContainsKey(circuitcode))
48 {
49 validcircuit = this.AgentCircuits[circuitcode];
50 }
51 AuthenticateResponse user = new AuthenticateResponse();
52 if (validcircuit == null)
53 {
54 //don't have this circuit code in our list
55 user.Authorised = false;
56 return (user);
57 }
58
59 if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID))
60 {
61 user.Authorised = true;
62 user.LoginInfo = new Login();
63 user.LoginInfo.Agent = agentID;
64 user.LoginInfo.Session = sessionID;
65 user.LoginInfo.SecureSession = validcircuit.SecureSessionID;
66 user.LoginInfo.First = validcircuit.firstname;
67 user.LoginInfo.Last = validcircuit.lastname;
68 user.LoginInfo.InventoryFolder = validcircuit.InventoryFolder;
69 user.LoginInfo.BaseFolder = validcircuit.BaseFolder;
70 }
71 else
72 {
73 // Invalid
74 user.Authorised = false;
75 }
76
77 return (user);
78 }
79
80 public virtual void AddNewCircuit(uint circuitCode, AgentCircuitData agentData)
81 {
82 if (this.AgentCircuits.ContainsKey(circuitCode))
83 {
84 this.AgentCircuits[circuitCode] = agentData;
85 }
86 else
87 {
88 this.AgentCircuits.Add(circuitCode, agentData);
89 }
90 }
91
92 public LLVector3 GetPosition(uint circuitCode)
93 {
94 LLVector3 vec = new LLVector3();
95 if (this.AgentCircuits.ContainsKey(circuitCode))
96 {
97 vec = this.AgentCircuits[circuitCode].startpos;
98 }
99 return vec;
100 }
101
102 public void UpdateAgentData(AgentCircuitData agentData)
103 {
104 if (this.AgentCircuits.ContainsKey((uint)agentData.circuitcode))
105 {
106 this.AgentCircuits[(uint)agentData.circuitcode].firstname = agentData.firstname;
107 this.AgentCircuits[(uint)agentData.circuitcode].lastname = agentData.lastname;
108 this.AgentCircuits[(uint)agentData.circuitcode].startpos = agentData.startpos;
109 // Console.WriteLine("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z);
110 }
111 }
112
113 public void UpdateAgentChildStatus(uint circuitcode, bool childstatus)
114 {
115 if (this.AgentCircuits.ContainsKey(circuitcode))
116 {
117 this.AgentCircuits[circuitcode].child = childstatus;
118 }
119 }
120
121 public bool GetAgentChildStatus(uint circuitcode)
122 {
123 if (this.AgentCircuits.ContainsKey(circuitcode))
124 {
125 return this.AgentCircuits[circuitcode].child;
126 }
127 return false;
128 }
129 }
130} \ No newline at end of file
diff --git a/OpenSim/Framework/General/BlockingQueue.cs b/OpenSim/Framework/General/BlockingQueue.cs
new file mode 100644
index 0000000..0cc8124
--- /dev/null
+++ b/OpenSim/Framework/General/BlockingQueue.cs
@@ -0,0 +1,58 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Collections.Generic;
29using System.Threading;
30
31namespace OpenSim.Framework.Utilities
32{
33 public class BlockingQueue<T>
34 {
35 private Queue<T> _queue = new Queue<T>();
36 private object _queueSync = new object();
37
38 public void Enqueue(T value)
39 {
40 lock (_queueSync)
41 {
42 _queue.Enqueue(value);
43 Monitor.Pulse(_queueSync);
44 }
45 }
46
47 public T Dequeue()
48 {
49 lock (_queueSync)
50 {
51 if (_queue.Count < 1)
52 Monitor.Wait(_queueSync);
53
54 return _queue.Dequeue();
55 }
56 }
57 }
58}
diff --git a/OpenSim/Framework/General/ClientManager.cs b/OpenSim/Framework/General/ClientManager.cs
new file mode 100644
index 0000000..b560ca8
--- /dev/null
+++ b/OpenSim/Framework/General/ClientManager.cs
@@ -0,0 +1,36 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Framework.Interfaces;
5
6namespace OpenSim.Framework
7{
8 public delegate void ForEachClientDelegate( IClientAPI client );
9 public class ClientManager
10 {
11 private Dictionary<uint, IClientAPI> m_clients;
12
13 public void ForEachClient(ForEachClientDelegate whatToDo)
14 {
15 foreach (IClientAPI client in m_clients.Values)
16 {
17 whatToDo(client);
18 }
19 }
20
21 public ClientManager()
22 {
23 m_clients = new Dictionary<uint, IClientAPI>();
24 }
25
26 public void Remove(uint id)
27 {
28 m_clients.Remove(id);
29 }
30
31 public void Add(uint id, IClientAPI client )
32 {
33 m_clients.Add( id, client );
34 }
35 }
36}
diff --git a/OpenSim/Framework/General/IRegionCommsListener.cs b/OpenSim/Framework/General/IRegionCommsListener.cs
new file mode 100644
index 0000000..32444f9
--- /dev/null
+++ b/OpenSim/Framework/General/IRegionCommsListener.cs
@@ -0,0 +1,46 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Collections.Generic;
29using libsecondlife;
30using OpenSim.Framework.Interfaces;
31using OpenSim.Framework.Types;
32
33namespace OpenSim.Framework
34{
35 public delegate void ExpectUserDelegate(ulong regionHandle, AgentCircuitData agent);
36 public delegate void UpdateNeighbours(List<RegionInfo> neighbours);
37 public delegate void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position);
38
39 public interface IRegionCommsListener
40 {
41 event ExpectUserDelegate OnExpectUser;
42 event GenericCall2 OnExpectChildAgent;
43 event AgentCrossing OnAvatarCrossingIntoRegion;
44 event UpdateNeighbours OnNeighboursUpdate;
45 }
46}
diff --git a/OpenSim/Framework/General/Interfaces/AuthenticateResponse.cs b/OpenSim/Framework/General/Interfaces/AuthenticateResponse.cs
new file mode 100644
index 0000000..508485b
--- /dev/null
+++ b/OpenSim/Framework/General/Interfaces/AuthenticateResponse.cs
@@ -0,0 +1,43 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using OpenSim.Framework.Types;
29
30namespace OpenSim.Framework.Interfaces
31{
32 public class AuthenticateResponse
33 {
34 public bool Authorised;
35 public Login LoginInfo;
36
37 public AuthenticateResponse()
38 {
39
40 }
41
42 }
43}
diff --git a/OpenSim/Framework/General/Interfaces/Config/IGenericConfig.cs b/OpenSim/Framework/General/Interfaces/Config/IGenericConfig.cs
new file mode 100644
index 0000000..2c379dd
--- /dev/null
+++ b/OpenSim/Framework/General/Interfaces/Config/IGenericConfig.cs
@@ -0,0 +1,38 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28namespace OpenSim.Framework.Interfaces
29{
30 public interface IGenericConfig
31 {
32 void LoadData();
33 string GetAttribute(string attributeName);
34 bool SetAttribute(string attributeName, string attributeValue);
35 void Commit();
36 void Close();
37 }
38}
diff --git a/OpenSim/Framework/General/Interfaces/Config/IGridConfig.cs b/OpenSim/Framework/General/Interfaces/Config/IGridConfig.cs
new file mode 100644
index 0000000..81dc293
--- /dev/null
+++ b/OpenSim/Framework/General/Interfaces/Config/IGridConfig.cs
@@ -0,0 +1,59 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29//using OpenSim.world;
30
31namespace OpenSim.Framework.Interfaces
32{
33 /// <summary>
34 /// </summary>
35
36
37 public abstract class GridConfig
38 {
39 public string GridOwner;
40 public string DefaultStartupMsg;
41 public string DefaultAssetServer;
42 public string AssetSendKey;
43 public string AssetRecvKey;
44 public string DefaultUserServer;
45 public string UserSendKey;
46 public string UserRecvKey;
47 public string SimSendKey;
48 public string SimRecvKey;
49
50
51 public abstract void InitConfig();
52
53 }
54
55 public interface IGridConfig
56 {
57 GridConfig GetConfigObject();
58 }
59}
diff --git a/OpenSim/Framework/General/Interfaces/Config/IUserConfig.cs b/OpenSim/Framework/General/Interfaces/Config/IUserConfig.cs
new file mode 100644
index 0000000..ae6cedb
--- /dev/null
+++ b/OpenSim/Framework/General/Interfaces/Config/IUserConfig.cs
@@ -0,0 +1,53 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29//using OpenSim.world;
30
31namespace OpenSim.Framework.Interfaces
32{
33 /// <summary>
34 /// </summary>
35
36
37 public abstract class UserConfig
38 {
39 public string DefaultStartupMsg;
40 public string GridServerURL;
41 public string GridSendKey;
42 public string GridRecvKey;
43
44
45 public abstract void InitConfig();
46
47 }
48
49 public interface IUserConfig
50 {
51 UserConfig GetConfigObject();
52 }
53}
diff --git a/OpenSim/Framework/General/Interfaces/IAssetServer.cs b/OpenSim/Framework/General/Interfaces/IAssetServer.cs
new file mode 100644
index 0000000..ab60dd7
--- /dev/null
+++ b/OpenSim/Framework/General/Interfaces/IAssetServer.cs
@@ -0,0 +1,64 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using libsecondlife;
29using OpenSim.Framework.Types;
30
31namespace OpenSim.Framework.Interfaces
32{
33 /// <summary>
34 /// Description of IAssetServer.
35 /// </summary>
36
37 public interface IAssetServer
38 {
39 void SetReceiver(IAssetReceiver receiver);
40 void RequestAsset(LLUUID assetID, bool isTexture);
41 void UpdateAsset(AssetBase asset);
42 void UploadNewAsset(AssetBase asset);
43 void SetServerInfo(string ServerUrl, string ServerKey);
44 void Close();
45 }
46
47 // could change to delegate?
48 public interface IAssetReceiver
49 {
50 void AssetReceived(AssetBase asset, bool IsTexture);
51 void AssetNotFound(AssetBase asset);
52 }
53
54 public interface IAssetPlugin
55 {
56 IAssetServer GetAssetServer();
57 }
58
59 public struct ARequest
60 {
61 public LLUUID AssetID;
62 public bool IsTexture;
63 }
64}
diff --git a/OpenSim/Framework/General/Interfaces/IClientAPI.cs b/OpenSim/Framework/General/Interfaces/IClientAPI.cs
new file mode 100644
index 0000000..1b0c682
--- /dev/null
+++ b/OpenSim/Framework/General/Interfaces/IClientAPI.cs
@@ -0,0 +1,180 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Collections.Generic;
29using System.Net;
30using libsecondlife;
31using libsecondlife.Packets;
32using OpenSim.Framework.Types;
33
34namespace OpenSim.Framework.Interfaces
35{
36 public delegate void ChatFromViewer(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID);
37 public delegate void ImprovedInstantMessage(LLUUID fromAgentID, LLUUID toAgentID, uint timestamp, string fromAgentName, string message); // Cut down from full list
38 public delegate void RezObject(AssetBase primAsset, LLVector3 pos);
39 public delegate void ModifyTerrain(float height, float seconds, byte size, byte action, float north, float west);
40 public delegate void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam);
41 public delegate void StartAnim(LLUUID animID, int seq);
42 public delegate void LinkObjects(uint parent, List<uint> children);
43 public delegate void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY);
44 public delegate void TeleportLocationRequest(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags);
45
46 public delegate void GenericCall(IClientAPI remoteClient);
47 public delegate void GenericCall2();
48 public delegate void GenericCall3(Packet packet); // really don't want to be passing packets in these events, so this is very temporary.
49 public delegate void GenericCall4(Packet packet, IClientAPI remoteClient);
50 public delegate void GenericCall5(IClientAPI remoteClient, bool status);
51 public delegate void GenericCall6(LLUUID uid);
52 public delegate void GenericCall7(uint localID, string message);
53
54 public delegate void UpdateShape(uint localID, ObjectShapePacket.ObjectDataBlock shapeBlock);
55 public delegate void ObjectSelect(uint localID, IClientAPI remoteClient);
56 public delegate void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient);
57 public delegate void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient);
58 public delegate void UpdateVector(uint localID, LLVector3 pos, IClientAPI remoteClient);
59 public delegate void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient);
60 public delegate void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient);
61 public delegate void UpdatePrimGroupRotation(uint localID,LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient);
62 public delegate void ObjectDuplicate(uint localID, LLVector3 offset, uint dupeFlags);
63 public delegate void StatusChange(bool status);
64 public delegate void NewAvatar(IClientAPI remoteClient, LLUUID agentID, bool status);
65 public delegate void UpdateAgent(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation);
66 public delegate void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 grapPos, IClientAPI remoteClient);
67
68 public delegate void ParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client);
69 public delegate void ParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client);
70 public delegate void ParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client);
71 public delegate void ParcelPropertiesUpdateRequest(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client); // NOTETOSELFremove the packet part
72
73 public delegate void EstateOwnerMessageRequest(EstateOwnerMessagePacket packet, IClientAPI remote_client);
74
75 public delegate void UUIDNameRequest(LLUUID id, IClientAPI remote_client);
76
77 public interface IClientAPI
78 {
79 event ImprovedInstantMessage OnInstantMessage;
80 event ChatFromViewer OnChatFromViewer;
81 event RezObject OnRezObject;
82 event ModifyTerrain OnModifyTerrain;
83 event SetAppearance OnSetAppearance;
84 event StartAnim OnStartAnim;
85 event LinkObjects OnLinkObjects;
86 event RequestMapBlocks OnRequestMapBlocks;
87 event TeleportLocationRequest OnTeleportLocationRequest;
88
89 event GenericCall4 OnDeRezObject;
90 event GenericCall OnRegionHandShakeReply;
91 event GenericCall OnRequestWearables;
92 event GenericCall2 OnCompleteMovementToRegion;
93 event UpdateAgent OnAgentUpdate;
94 event GenericCall OnRequestAvatarsData;
95 event GenericCall4 OnAddPrim;
96 event ObjectDuplicate OnObjectDuplicate;
97 event UpdateVector OnGrapObject;
98 event ObjectSelect OnDeGrapObject;
99 event MoveObject OnGrapUpdate;
100
101 event UpdateShape OnUpdatePrimShape;
102 event ObjectSelect OnObjectSelect;
103 event GenericCall7 OnObjectDescription;
104 event GenericCall7 OnObjectName;
105 event UpdatePrimFlags OnUpdatePrimFlags;
106 event UpdatePrimTexture OnUpdatePrimTexture;
107 event UpdateVector OnUpdatePrimGroupPosition;
108 event UpdateVector OnUpdatePrimSinglePosition;
109 event UpdatePrimRotation OnUpdatePrimGroupRotation;
110 event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
111 event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
112 event UpdateVector OnUpdatePrimScale;
113 event StatusChange OnChildAgentStatus;
114 event GenericCall2 OnStopMovement;
115 event NewAvatar OnNewAvatar;
116 event GenericCall6 OnRemoveAvatar;
117
118 event UUIDNameRequest OnNameFromUUIDRequest;
119
120 event ParcelPropertiesRequest OnParcelPropertiesRequest;
121 event ParcelDivideRequest OnParcelDivideRequest;
122 event ParcelJoinRequest OnParcelJoinRequest;
123 event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
124
125 event EstateOwnerMessageRequest OnEstateOwnerMessage;
126
127 LLVector3 StartPos
128 {
129 get;
130 set;
131 }
132
133 LLUUID AgentId
134 {
135 get;
136 }
137
138 string FirstName
139 {
140 get;
141 }
142
143 string LastName
144 {
145 get;
146 }
147
148 void OutPacket(Packet newPack);
149 void SendWearables(AvatarWearable[] wearables);
150 void SendStartPingCheck(byte seq);
151 void SendKillObject(ulong regionHandle, uint avatarLocalID);
152 void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId);
153 void SendRegionHandshake(RegionInfo regionInfo);
154 void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID);
155 void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID);
156 void SendInstantMessage(string message, LLUUID target);
157 void SendLayerData(float[] map);
158 void SendLayerData(int px, int py, float[] map);
159 void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look);
160 void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint );
161 AgentCircuitData RequestClientInfo();
162 void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint newRegionExternalEndPoint );
163 void SendMapBlock(List<MapBlockData> mapBlocks);
164 void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags);
165 void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags);
166 void SendTeleportCancel();
167 void SendTeleportLocationStart();
168 void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance);
169
170 void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry);
171 void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity);
172
173 void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint);
174 void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID textureID , uint flags);
175 void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLUUID textureID, uint flags);
176 void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID);
177 void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID);
178 void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation);
179 }
180}
diff --git a/OpenSim/Framework/General/Interfaces/ILocalStorage.cs b/OpenSim/Framework/General/Interfaces/ILocalStorage.cs
new file mode 100644
index 0000000..dbdb25d
--- /dev/null
+++ b/OpenSim/Framework/General/Interfaces/ILocalStorage.cs
@@ -0,0 +1,68 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using libsecondlife;
30using OpenSim.Framework.Types;
31
32namespace OpenSim.Framework.Interfaces
33{
34 /// <summary>
35 /// ILocalStorage. Really hacked together right now needs cleaning up
36 /// </summary>
37 public interface ILocalStorage
38 {
39 void Initialise(string datastore);
40
41 void StorePrim(PrimData prim);
42 void RemovePrim(LLUUID primID);
43 void LoadPrimitives(ILocalStorageReceiver receiver);
44
45 float[] LoadWorld();
46 void SaveMap(float[] heightmap);
47
48 void SaveParcels(ParcelData[] parcels);
49 void SaveParcel(ParcelData parcel);
50 void RemoveParcel(ParcelData parcel);
51 void RemoveAllParcels();
52 void LoadParcels(ILocalStorageParcelReceiver recv);
53
54 void ShutDown();
55 }
56
57 public interface ILocalStorageReceiver
58 {
59 void PrimFromStorage(PrimData prim);
60 }
61
62 public interface ILocalStorageParcelReceiver
63 {
64 void ParcelFromStorage(ParcelData data);
65 void NoParcelDataFromStorage();
66 }
67}
68
diff --git a/OpenSim/Framework/General/Interfaces/IUserServer.cs b/OpenSim/Framework/General/Interfaces/IUserServer.cs
new file mode 100644
index 0000000..b3700d2
--- /dev/null
+++ b/OpenSim/Framework/General/Interfaces/IUserServer.cs
@@ -0,0 +1,39 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using libsecondlife;
29using OpenSim.Framework.Inventory;
30
31namespace OpenSim.Framework.Interfaces
32{
33 public interface IUserServer
34 {
35 AgentInventory RequestAgentsInventory(LLUUID agentID);
36 void SetServerInfo(string ServerUrl, string SendKey, string RecvKey);
37 bool UpdateAgentsInventory(LLUUID agentID, AgentInventory inventory);
38 }
39}
diff --git a/OpenSim/Framework/General/Interfaces/IWorld.cs b/OpenSim/Framework/General/Interfaces/IWorld.cs
new file mode 100644
index 0000000..204c01b
--- /dev/null
+++ b/OpenSim/Framework/General/Interfaces/IWorld.cs
@@ -0,0 +1,42 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using libsecondlife;
29using OpenSim.Framework.Types;
30
31namespace OpenSim.Framework.Interfaces
32{
33 public interface IWorld
34 {
35 void AddNewClient(IClientAPI client, bool child);
36 void RemoveClient(LLUUID agentID);
37
38 RegionInfo RegionInfo { get; }
39 object SyncRoot { get; }
40 uint NextLocalId { get; }
41 }
42}
diff --git a/OpenSim/Framework/General/LoginService.cs b/OpenSim/Framework/General/LoginService.cs
new file mode 100644
index 0000000..02efcec
--- /dev/null
+++ b/OpenSim/Framework/General/LoginService.cs
@@ -0,0 +1,34 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28namespace OpenSim.Framework.Grid
29{
30 public abstract class LoginService
31 {
32
33 }
34} \ No newline at end of file
diff --git a/OpenSim/Framework/General/Properties/AssemblyInfo.cs b/OpenSim/Framework/General/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..004040b
--- /dev/null
+++ b/OpenSim/Framework/General/Properties/AssemblyInfo.cs
@@ -0,0 +1,31 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.FrameWork")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenSim.FrameWork")]
11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("a08e20c7-f191-4137-b1f0-9291408fa521")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30[assembly: AssemblyVersion("1.0.0.0")]
31[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Framework/General/RegionCommsListener.cs b/OpenSim/Framework/General/RegionCommsListener.cs
new file mode 100644
index 0000000..2b0bc62
--- /dev/null
+++ b/OpenSim/Framework/General/RegionCommsListener.cs
@@ -0,0 +1,68 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using libsecondlife;
29using OpenSim.Framework.Interfaces;
30using OpenSim.Framework.Types;
31
32namespace OpenSim.Framework
33{
34 public class RegionCommsListener :IRegionCommsListener
35 {
36 public event ExpectUserDelegate OnExpectUser;
37 public event GenericCall2 OnExpectChildAgent;
38 public event AgentCrossing OnAvatarCrossingIntoRegion;
39 public event UpdateNeighbours OnNeighboursUpdate;
40
41 /// <summary>
42 ///
43 /// </summary>
44 /// <param name="agent"></param>
45 /// <returns></returns>
46 public virtual bool TriggerExpectUser(ulong regionHandle, AgentCircuitData agent)
47 {
48 if(OnExpectUser != null)
49 {
50
51 OnExpectUser(regionHandle, agent);
52 return true;
53 }
54
55 return false;
56 }
57
58 public virtual bool TriggerExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position)
59 {
60 if (OnAvatarCrossingIntoRegion != null)
61 {
62 OnAvatarCrossingIntoRegion(regionHandle, agentID, position);
63 return true;
64 }
65 return false;
66 }
67 }
68}
diff --git a/OpenSim/Framework/General/Remoting.cs b/OpenSim/Framework/General/Remoting.cs
new file mode 100644
index 0000000..df32db2
--- /dev/null
+++ b/OpenSim/Framework/General/Remoting.cs
@@ -0,0 +1,135 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Security.Cryptography;
30using System.Text;
31
32namespace OpenSim.Framework
33{
34 /// <summary>
35 /// NEEDS AUDIT.
36 /// </summary>
37 /// <remarks>
38 /// Suggested implementation
39 /// <para>Store two digests for each foreign host. A local copy of the local hash using the local challenge (when issued), and a local copy of the remote hash using the remote challenge.</para>
40 /// <para>When sending data to the foreign host - run 'Sign' on the data and affix the returned byte[] to the message.</para>
41 /// <para>When recieving data from the foreign host - run 'Authenticate' against the data and the attached byte[].</para>
42 /// <para>Both hosts should be performing these operations for this to be effective.</para>
43 /// </remarks>
44 class RemoteDigest
45 {
46 private byte[] currentHash;
47 private byte[] secret;
48
49 private SHA512Managed SHA512;
50
51 /// <summary>
52 /// Initialises a new RemoteDigest authentication mechanism
53 /// </summary>
54 /// <remarks>Needs an audit by a cryptographic professional - was not "roll your own"'d by choice but rather a serious lack of decent authentication mechanisms in .NET remoting</remarks>
55 /// <param name="sharedSecret">The shared secret between systems (for inter-sim, this is provided in encrypted form during connection, for grid this is input manually in setup)</param>
56 /// <param name="salt">Binary salt - some common value - to be decided what</param>
57 /// <param name="challenge">The challenge key provided by the third party</param>
58 public RemoteDigest(string sharedSecret, byte[] salt, string challenge)
59 {
60 SHA512 = new SHA512Managed();
61 Rfc2898DeriveBytes RFC2898 = new Rfc2898DeriveBytes(sharedSecret,salt);
62 secret = RFC2898.GetBytes(512);
63 ASCIIEncoding ASCII = new ASCIIEncoding();
64
65 currentHash = SHA512.ComputeHash(AppendArrays(secret, ASCII.GetBytes(challenge)));
66 }
67
68 /// <summary>
69 /// Authenticates a piece of incoming data against the local digest. Upon successful authentication, digest string is incremented.
70 /// </summary>
71 /// <param name="data">The incoming data</param>
72 /// <param name="digest">The remote digest</param>
73 /// <returns></returns>
74 public bool Authenticate(byte[] data, byte[] digest)
75 {
76 byte[] newHash = SHA512.ComputeHash(AppendArrays(AppendArrays(currentHash, secret), data));
77 if (digest == newHash)
78 {
79 currentHash = newHash;
80 return true;
81 }
82 else
83 {
84 throw new Exception("Hash comparison failed. Key resync required.");
85 }
86 }
87
88 /// <summary>
89 /// Signs a new bit of data with the current hash. Returns a byte array which should be affixed to the message.
90 /// Signing a piece of data will automatically increment the hash - if you sign data and do not send it, the
91 /// hashes will get out of sync and throw an exception when validation is attempted.
92 /// </summary>
93 /// <param name="data">The outgoing data</param>
94 /// <returns>The local digest</returns>
95 public byte[] Sign(byte[] data)
96 {
97 currentHash = SHA512.ComputeHash(AppendArrays(AppendArrays(currentHash, secret), data));
98 return currentHash;
99 }
100
101 /// <summary>
102 /// Generates a new challenge string to be issued to a foreign host. Challenges are 1024-bit (effective strength of less than 512-bits) messages generated using the Crytographic Random Number Generator.
103 /// </summary>
104 /// <returns>A 128-character hexadecimal string containing the challenge.</returns>
105 public static string GenerateChallenge()
106 {
107 RNGCryptoServiceProvider RNG = new RNGCryptoServiceProvider();
108 byte[] bytes = new byte[64];
109 RNG.GetBytes(bytes);
110
111 StringBuilder sb = new StringBuilder(bytes.Length * 2);
112 foreach (byte b in bytes)
113 {
114 sb.AppendFormat("{0:x2}", b);
115 }
116 return sb.ToString();
117 }
118
119 /// <summary>
120 /// Helper function, merges two byte arrays
121 /// </summary>
122 /// <remarks>Sourced from MSDN Forum</remarks>
123 /// <param name="a">A</param>
124 /// <param name="b">B</param>
125 /// <returns>C</returns>
126 private byte[] AppendArrays(byte[] a, byte[] b)
127 {
128 byte[] c = new byte[a.Length + b.Length];
129 Buffer.BlockCopy(a, 0, c, 0, a.Length);
130 Buffer.BlockCopy(b, 0, c, a.Length, b.Length);
131 return c;
132 }
133
134 }
135}
diff --git a/OpenSim/Framework/General/Types/AgentCiruitData.cs b/OpenSim/Framework/General/Types/AgentCiruitData.cs
new file mode 100644
index 0000000..ed9ee3c
--- /dev/null
+++ b/OpenSim/Framework/General/Types/AgentCiruitData.cs
@@ -0,0 +1,49 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using libsecondlife;
29using System;
30
31namespace OpenSim.Framework.Types
32{
33 [Serializable]
34 public class AgentCircuitData
35 {
36 public AgentCircuitData() { }
37 public LLUUID AgentID;
38 public LLUUID SessionID;
39 public LLUUID SecureSessionID;
40 public LLVector3 startpos;
41 public string firstname;
42 public string lastname;
43 public uint circuitcode;
44 public bool child;
45 public LLUUID InventoryFolder;
46 public LLUUID BaseFolder;
47 public string CapsPath = "";
48 }
49}
diff --git a/OpenSim/Framework/General/Types/AgentWearable.cs b/OpenSim/Framework/General/Types/AgentWearable.cs
new file mode 100644
index 0000000..6152b7d
--- /dev/null
+++ b/OpenSim/Framework/General/Types/AgentWearable.cs
@@ -0,0 +1,57 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using libsecondlife;
29
30namespace OpenSim.Framework.Types
31{
32 public class AvatarWearable
33 {
34 public LLUUID AssetID = new LLUUID("00000000-0000-0000-0000-000000000000");
35 public LLUUID ItemID = new LLUUID("00000000-0000-0000-0000-000000000000");
36
37 public AvatarWearable()
38 {
39
40 }
41
42 public static AvatarWearable[] DefaultWearables
43 {
44 get
45 {
46 AvatarWearable[] defaultWearables = new AvatarWearable[13]; //should be 13 of these
47 for (int i = 0; i < 13; i++)
48 {
49 defaultWearables[i] = new AvatarWearable();
50 }
51 defaultWearables[0].AssetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
52 defaultWearables[0].ItemID = LLUUID.Random();
53 return defaultWearables;
54 }
55 }
56 }
57}
diff --git a/OpenSim/Framework/General/Types/AssetBase.cs b/OpenSim/Framework/General/Types/AssetBase.cs
new file mode 100644
index 0000000..c203f51
--- /dev/null
+++ b/OpenSim/Framework/General/Types/AssetBase.cs
@@ -0,0 +1,46 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using libsecondlife;
29
30namespace OpenSim.Framework.Types
31{
32 public class AssetBase
33 {
34 public byte[] Data;
35 public LLUUID FullID;
36 public sbyte Type;
37 public sbyte InvType;
38 public string Name;
39 public string Description;
40
41 public AssetBase()
42 {
43
44 }
45 }
46}
diff --git a/OpenSim/Framework/General/Types/AssetLandmark.cs b/OpenSim/Framework/General/Types/AssetLandmark.cs
new file mode 100644
index 0000000..8aa872e
--- /dev/null
+++ b/OpenSim/Framework/General/Types/AssetLandmark.cs
@@ -0,0 +1,59 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Text;
29using libsecondlife;
30
31namespace OpenSim.Framework.Types
32{
33 public class AssetLandmark : AssetBase
34 {
35 public int Version;
36 public LLVector3 Position;
37 public LLUUID RegionID;
38
39 public AssetLandmark(AssetBase a)
40 {
41 this.Data = a.Data;
42 this.FullID = a.FullID;
43 this.Type = a.Type;
44 this.InvType = a.InvType;
45 this.Name = a.Name;
46 this.Description = a.Description;
47 InternData();
48 }
49
50 private void InternData()
51 {
52 string temp = Encoding.UTF8.GetString(Data).Trim();
53 string[] parts = temp.Split('\n');
54 int.TryParse(parts[0].Substring(17, 1), out Version);
55 LLUUID.TryParse(parts[1].Substring(10, 36), out RegionID);
56 LLVector3.TryParse(parts[2].Substring(11, parts[2].Length - 11), out Position);
57 }
58 }
59}
diff --git a/OpenSim/Framework/General/Types/AssetStorage.cs b/OpenSim/Framework/General/Types/AssetStorage.cs
new file mode 100644
index 0000000..3681336
--- /dev/null
+++ b/OpenSim/Framework/General/Types/AssetStorage.cs
@@ -0,0 +1,47 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using libsecondlife;
29
30namespace OpenSim.Framework.Types
31{
32 public class AssetStorage
33 {
34
35 public AssetStorage() {
36 }
37
38 public AssetStorage(LLUUID assetUUID) {
39 UUID=assetUUID;
40 }
41
42 public byte[] Data;
43 public sbyte Type;
44 public string Name;
45 public LLUUID UUID;
46 }
47}
diff --git a/OpenSim/Framework/General/Types/EstateSettings.cs b/OpenSim/Framework/General/Types/EstateSettings.cs
new file mode 100644
index 0000000..436b109
--- /dev/null
+++ b/OpenSim/Framework/General/Types/EstateSettings.cs
@@ -0,0 +1,93 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using libsecondlife;
30
31namespace OpenSim.Framework.Types
32{
33 public class EstateSettings
34 {
35 //Settings to this island
36 public float billableFactor = (float)0.0;
37 public uint estateID = 0;
38 public uint parentEstateID = 0;
39
40 public byte maxAgents = 40;
41 public float objectBonusFactor = (float)1.0;
42
43 public int redirectGridX = 0; //??
44 public int redirectGridY = 0; //??
45 public Simulator.RegionFlags regionFlags = Simulator.RegionFlags.None; //Booleam values of various region settings
46 public Simulator.SimAccess simAccess = Simulator.SimAccess.Mature; //Is sim PG, Mature, etc? Mature by default.
47 public float sunHour = 0;
48
49 public float terrainRaiseLimit = 0;
50 public float terrainLowerLimit = 0;
51
52 public bool useFixedSun = false;
53 public int pricePerMeter = 1;
54
55 public ushort regionWaterHeight = 20;
56 public bool regionAllowTerraform = true;
57
58 // Region Information
59 // Low resolution 'base' textures. No longer used.
60 public LLUUID terrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); // Default
61 public LLUUID terrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); // Default
62 public LLUUID terrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); // Default
63 public LLUUID terrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); // Default
64
65 // Higher resolution terrain textures
66 public LLUUID terrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000");
67 public LLUUID terrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000");
68 public LLUUID terrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000");
69 public LLUUID terrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000");
70
71 // First quad - each point is bilinearly interpolated at each meter of terrain
72 public float terrainStartHeight0 = 10.0f;
73 public float terrainStartHeight1 = 10.0f;
74 public float terrainStartHeight2 = 10.0f;
75 public float terrainStartHeight3 = 10.0f;
76
77 // Second quad - also bilinearly interpolated.
78 // Terrain texturing is done that:
79 // 0..3 (0 = base0, 3 = base3) = (terrain[x,y] - start[x,y]) / range[x,y]
80 public float terrainHeightRange0 = 60.0f; //00
81 public float terrainHeightRange1 = 60.0f; //01
82 public float terrainHeightRange2 = 60.0f; //10
83 public float terrainHeightRange3 = 60.0f; //11
84
85 // Terrain Default (Must be in F32 Format!)
86 public string terrainFile = "default.r32";
87 public double terrainMultiplier = 60.0;
88 public float waterHeight = (float)20.0;
89
90 public LLUUID terrainImageID = LLUUID.Zero; // the assetID that is the current Map image for this region
91
92 }
93}
diff --git a/OpenSim/Framework/General/Types/Login.cs b/OpenSim/Framework/General/Types/Login.cs
new file mode 100644
index 0000000..d54c019
--- /dev/null
+++ b/OpenSim/Framework/General/Types/Login.cs
@@ -0,0 +1,49 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using libsecondlife;
29
30namespace OpenSim.Framework.Types
31{
32 public class Login
33 {
34 public string First = "Test";
35 public string Last = "User";
36 public LLUUID Agent;
37 public LLUUID Session;
38 public LLUUID SecureSession = LLUUID.Zero;
39 public LLUUID InventoryFolder;
40 public LLUUID BaseFolder;
41 public uint CircuitCode;
42 public string CapsPath ="";
43
44 public Login()
45 {
46
47 }
48 }
49}
diff --git a/OpenSim/Framework/General/Types/MapBlockData.cs b/OpenSim/Framework/General/Types/MapBlockData.cs
new file mode 100644
index 0000000..fbb3b73
--- /dev/null
+++ b/OpenSim/Framework/General/Types/MapBlockData.cs
@@ -0,0 +1,23 @@
1using System;
2using libsecondlife;
3
4namespace OpenSim.Framework.Types
5{
6 public class MapBlockData
7 {
8 public uint Flags;
9 public ushort X;
10 public ushort Y;
11 public byte Agents;
12 public byte Access;
13 public byte WaterHeight;
14 public LLUUID MapImageId;
15 public String Name;
16 public uint RegionFlags;
17
18 public MapBlockData()
19 {
20
21 }
22 }
23}
diff --git a/OpenSim/Framework/General/Types/NeighbourInfo.cs b/OpenSim/Framework/General/Types/NeighbourInfo.cs
new file mode 100644
index 0000000..bb67981
--- /dev/null
+++ b/OpenSim/Framework/General/Types/NeighbourInfo.cs
@@ -0,0 +1,42 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28namespace OpenSim.Framework.Types
29{
30 public class NeighbourInfo
31 {
32 public NeighbourInfo()
33 {
34 }
35
36 public ulong regionhandle;
37 public uint RegionLocX;
38 public uint RegionLocY;
39 public string sim_ip;
40 public uint sim_port;
41 }
42}
diff --git a/OpenSim/Framework/General/Types/NetworkServersInfo.cs b/OpenSim/Framework/General/Types/NetworkServersInfo.cs
new file mode 100644
index 0000000..89ebf94
--- /dev/null
+++ b/OpenSim/Framework/General/Types/NetworkServersInfo.cs
@@ -0,0 +1,219 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using OpenSim.Framework.Console;
30using OpenSim.Framework.Interfaces;
31
32namespace OpenSim.Framework.Types
33{
34 public class NetworkServersInfo
35 {
36 public string AssetURL = "http://127.0.0.1:8003/";
37 public string AssetSendKey = "";
38
39 public string GridURL = "";
40 public string GridSendKey = "";
41 public string GridRecvKey = "";
42 public string UserURL = "";
43 public string UserSendKey = "";
44 public string UserRecvKey = "";
45 public bool isSandbox;
46
47 public uint DefaultHomeLocX = 0;
48 public uint DefaultHomeLocY = 0;
49
50 public int HttpListenerPort = 9000;
51 public int RemotingListenerPort = 8895;
52
53 public void InitConfig(bool sandboxMode, IGenericConfig configData)
54 {
55 this.isSandbox = sandboxMode;
56
57 try
58 {
59 string attri = "";
60
61 attri = "";
62 attri = configData.GetAttribute("HttpListenerPort");
63 if (attri == "")
64 {
65 string location = MainLog.Instance.CmdPrompt("Http Listener Port", "9000");
66 configData.SetAttribute("HttpListenerPort", location);
67 this.HttpListenerPort = Convert.ToInt32(location);
68 }
69 else
70 {
71 this.HttpListenerPort = Convert.ToInt32(attri);
72 }
73
74 attri = "";
75 attri = configData.GetAttribute("RemotingListenerPort");
76 if (attri == "")
77 {
78 string location = MainLog.Instance.CmdPrompt("Remoting Listener Port", "8895");
79 configData.SetAttribute("RemotingListenerPort", location);
80 this.RemotingListenerPort = Convert.ToInt32(location);
81 }
82 else
83 {
84 this.RemotingListenerPort = Convert.ToInt32(attri);
85 }
86
87 if (sandboxMode)
88 {
89 // default home location X
90 attri = "";
91 attri = configData.GetAttribute("DefaultLocationX");
92 if (attri == "")
93 {
94 string location = MainLog.Instance.CmdPrompt("Default Home Location X", "1000");
95 configData.SetAttribute("DefaultLocationX", location);
96 this.DefaultHomeLocX = (uint)Convert.ToUInt32(location);
97 }
98 else
99 {
100 this.DefaultHomeLocX = (uint)Convert.ToUInt32(attri);
101 }
102
103 // default home location Y
104 attri = "";
105 attri = configData.GetAttribute("DefaultLocationY");
106 if (attri == "")
107 {
108 string location = MainLog.Instance.CmdPrompt("Default Home Location Y", "1000");
109 configData.SetAttribute("DefaultLocationY", location);
110 this.DefaultHomeLocY = (uint)Convert.ToUInt32(location);
111 }
112 else
113 {
114 this.DefaultHomeLocY = (uint)Convert.ToUInt32(attri);
115 }
116 }
117 if (!isSandbox)
118 {
119 //Grid Server
120 attri = "";
121 attri = configData.GetAttribute("GridServerURL");
122 if (attri == "")
123 {
124 this.GridURL = MainLog.Instance.CmdPrompt("Grid server URL", "http://127.0.0.1:8001/");
125 configData.SetAttribute("GridServerURL", this.GridURL);
126 }
127 else
128 {
129 this.GridURL = attri;
130 }
131
132 //Grid Send Key
133 attri = "";
134 attri = configData.GetAttribute("GridSendKey");
135 if (attri == "")
136 {
137 this.GridSendKey = MainLog.Instance.CmdPrompt("Key to send to grid server", "null");
138 configData.SetAttribute("GridSendKey", this.GridSendKey);
139 }
140 else
141 {
142 this.GridSendKey = attri;
143 }
144
145 //Grid Receive Key
146 attri = "";
147 attri = configData.GetAttribute("GridRecvKey");
148 if (attri == "")
149 {
150 this.GridRecvKey = MainLog.Instance.CmdPrompt("Key to expect from grid server", "null");
151 configData.SetAttribute("GridRecvKey", this.GridRecvKey);
152 }
153 else
154 {
155 this.GridRecvKey = attri;
156 }
157
158 //Grid Server
159 attri = "";
160 attri = configData.GetAttribute("UserServerURL");
161 if (attri == "")
162 {
163 this.UserURL= MainLog.Instance.CmdPrompt("User server URL", "http://127.0.0.1:8002/");
164 configData.SetAttribute("UserServerURL", this.UserURL);
165 }
166 else
167 {
168 this.UserURL = attri;
169 }
170
171 //Grid Send Key
172 attri = "";
173 attri = configData.GetAttribute("UserSendKey");
174 if (attri == "")
175 {
176 this.UserSendKey = MainLog.Instance.CmdPrompt("Key to send to user server", "null");
177 configData.SetAttribute("UserSendKey", this.UserSendKey);
178 }
179 else
180 {
181 this.UserSendKey = attri;
182 }
183
184 //Grid Receive Key
185 attri = "";
186 attri = configData.GetAttribute("UserRecvKey");
187 if (attri == "")
188 {
189 this.UserRecvKey = MainLog.Instance.CmdPrompt("Key to expect from user server", "null");
190 configData.SetAttribute("GridRecvKey", this.UserRecvKey);
191 }
192 else
193 {
194 this.UserRecvKey = attri;
195 }
196
197 attri = "";
198 attri = configData.GetAttribute("AssetServerURL");
199 if (attri == "")
200 {
201 this.AssetURL = MainLog.Instance.CmdPrompt("Asset server URL", "http://127.0.0.1:8003/");
202 configData.SetAttribute("AssetServerURL", this.GridURL);
203 }
204 else
205 {
206 this.AssetURL = attri;
207 }
208
209 }
210 configData.Commit();
211 }
212 catch (Exception e)
213 {
214 MainLog.Instance.Warn("Config.cs:InitConfig() - Exception occured");
215 MainLog.Instance.Warn(e.ToString());
216 }
217 }
218 }
219}
diff --git a/OpenSim/Framework/General/Types/ParcelData.cs b/OpenSim/Framework/General/Types/ParcelData.cs
new file mode 100644
index 0000000..761d55e
--- /dev/null
+++ b/OpenSim/Framework/General/Types/ParcelData.cs
@@ -0,0 +1,112 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using libsecondlife;
29
30namespace OpenSim.Framework.Types
31{
32
33 public class ParcelData
34 {
35 public byte[] parcelBitmapByteArray = new byte[512];
36 public string parcelName = "";
37 public string parcelDesc = "";
38 public LLUUID ownerID = new LLUUID();
39 public bool isGroupOwned = false;
40 public LLVector3 AABBMin = new LLVector3();
41 public LLVector3 AABBMax = new LLVector3();
42 public int area = 0;
43 public uint auctionID = 0; //Unemplemented. If set to 0, not being auctioned
44 public LLUUID authBuyerID = new LLUUID(); //Unemplemented. Authorized Buyer's UUID
45 public Parcel.ParcelCategory category = new Parcel.ParcelCategory(); //Unemplemented. Parcel's chosen category
46 public int claimDate = 0; //Unemplemented
47 public int claimPrice = 0; //Unemplemented
48 public LLUUID groupID = new LLUUID(); //Unemplemented
49 public int groupPrims = 0; //Unemplemented
50 public int salePrice = 0; //Unemeplemented. Parcels price.
51 public Parcel.ParcelStatus parcelStatus = Parcel.ParcelStatus.None;
52 public Parcel.ParcelFlags parcelFlags = Parcel.ParcelFlags.None;
53 public byte landingType = 0;
54 public byte mediaAutoScale = 0;
55 public LLUUID mediaID = LLUUID.Zero;
56 public int localID = 0;
57 public LLUUID globalID = new LLUUID();
58
59 public string mediaURL = "";
60 public string musicURL = "";
61 public float passHours = 0;
62 public int passPrice = 0;
63 public LLUUID snapshotID = LLUUID.Zero;
64 public LLVector3 userLocation = new LLVector3();
65 public LLVector3 userLookAt = new LLVector3();
66
67 public ParcelData()
68 {
69 globalID = LLUUID.Random();
70 }
71
72 public ParcelData Copy()
73 {
74 ParcelData parcelData = new ParcelData();
75
76 parcelData.AABBMax = this.AABBMax;
77 parcelData.AABBMin = this.AABBMin;
78 parcelData.area = this.area;
79 parcelData.auctionID = this.auctionID;
80 parcelData.authBuyerID = this.authBuyerID;
81 parcelData.category = this.category;
82 parcelData.claimDate = this.claimDate;
83 parcelData.claimPrice = this.claimPrice;
84 parcelData.globalID = this.globalID;
85 parcelData.groupID = this.groupID;
86 parcelData.groupPrims = this.groupPrims;
87 parcelData.isGroupOwned = this.isGroupOwned;
88 parcelData.localID = this.localID;
89 parcelData.landingType = this.landingType;
90 parcelData.mediaAutoScale = this.mediaAutoScale;
91 parcelData.mediaID = this.mediaID;
92 parcelData.mediaURL = this.mediaURL;
93 parcelData.musicURL = this.musicURL;
94 parcelData.ownerID = this.ownerID;
95 parcelData.parcelBitmapByteArray = (byte[])this.parcelBitmapByteArray.Clone();
96 parcelData.parcelDesc = this.parcelDesc;
97 parcelData.parcelFlags = this.parcelFlags;
98 parcelData.parcelName = this.parcelName;
99 parcelData.parcelStatus = this.parcelStatus;
100 parcelData.passHours = this.passHours;
101 parcelData.passPrice = this.passPrice;
102 parcelData.salePrice = this.salePrice;
103 parcelData.snapshotID = this.snapshotID;
104 parcelData.userLocation = this.userLocation;
105 parcelData.userLookAt = this.userLookAt;
106
107 return parcelData;
108
109 }
110 }
111
112}
diff --git a/OpenSim/Framework/General/Types/PrimData.cs b/OpenSim/Framework/General/Types/PrimData.cs
new file mode 100644
index 0000000..ff81bcd
--- /dev/null
+++ b/OpenSim/Framework/General/Types/PrimData.cs
@@ -0,0 +1,228 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using libsecondlife;
30
31namespace OpenSim.Framework.Types
32{
33 public class PrimData
34 {
35 private const uint FULL_MASK_PERMISSIONS = 2147483647;
36
37 public LLUUID OwnerID;
38 public byte PCode;
39 public ushort PathBegin;
40 public ushort PathEnd;
41 public byte PathScaleX;
42 public byte PathScaleY;
43 public byte PathShearX;
44 public byte PathShearY;
45 public sbyte PathSkew;
46 public ushort ProfileBegin;
47 public ushort ProfileEnd;
48 public LLVector3 Scale;
49 public byte PathCurve;
50 public byte ProfileCurve;
51 public uint ParentID = 0;
52 public ushort ProfileHollow;
53 public sbyte PathRadiusOffset;
54 public byte PathRevolutions;
55 public sbyte PathTaperX;
56 public sbyte PathTaperY;
57 public sbyte PathTwist;
58 public sbyte PathTwistBegin;
59 public byte[] TextureEntry; // a LL textureEntry in byte[] format
60
61 public Int32 CreationDate;
62 public uint OwnerMask = FULL_MASK_PERMISSIONS;
63 public uint NextOwnerMask = FULL_MASK_PERMISSIONS;
64 public uint GroupMask = FULL_MASK_PERMISSIONS;
65 public uint EveryoneMask = FULL_MASK_PERMISSIONS;
66 public uint BaseMask = FULL_MASK_PERMISSIONS;
67
68 //following only used during prim storage
69 public LLVector3 Position;
70 public LLQuaternion Rotation = new LLQuaternion(0, 1, 0, 0);
71 public uint LocalID;
72 public LLUUID FullID;
73
74 public PrimData()
75 {
76
77 }
78
79 public PrimData(byte[] data)
80 {
81 int i = 0;
82
83 this.OwnerID = new LLUUID(data, i); i += 16;
84 this.PCode = data[i++];
85 this.PathBegin = (ushort)(data[i++] + (data[i++] << 8));
86 this.PathEnd = (ushort)(data[i++] + (data[i++] << 8));
87 this.PathScaleX = data[i++];
88 this.PathScaleY = data[i++];
89 this.PathShearX = data[i++];
90 this.PathShearY = data[i++];
91 this.PathSkew = (sbyte)data[i++];
92 this.ProfileBegin = (ushort)(data[i++] + (data[i++] << 8));
93 this.ProfileEnd = (ushort)(data[i++] + (data[i++] << 8));
94 this.Scale = new LLVector3(data, i); i += 12;
95 this.PathCurve = data[i++];
96 this.ProfileCurve = data[i++];
97 this.ParentID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
98 this.ProfileHollow = (ushort)(data[i++] + (data[i++] << 8));
99 this.PathRadiusOffset = (sbyte)data[i++];
100 this.PathRevolutions = data[i++];
101 this.PathTaperX = (sbyte)data[i++];
102 this.PathTaperY = (sbyte)data[i++];
103 this.PathTwist = (sbyte)data[i++];
104 this.PathTwistBegin = (sbyte)data[i++];
105 ushort length = (ushort)(data[i++] + (data[i++] << 8));
106 this.TextureEntry = new byte[length];
107 Array.Copy(data, i, TextureEntry, 0, length); i += length;
108 this.CreationDate = (Int32)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
109 this.OwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
110 this.NextOwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
111 this.GroupMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
112 this.EveryoneMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
113 this.BaseMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
114 this.Position = new LLVector3(data, i); i += 12;
115 this.Rotation = new LLQuaternion(data, i, true); i += 12;
116 this.LocalID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
117 this.FullID = new LLUUID(data, i); i += 16;
118
119 }
120
121 public byte[] ToBytes()
122 {
123 int i = 0;
124 byte[] bytes = new byte[126 + TextureEntry.Length];
125 Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16;
126 bytes[i++] = this.PCode;
127 bytes[i++] = (byte)(this.PathBegin % 256);
128 bytes[i++] = (byte)((this.PathBegin >> 8) % 256);
129 bytes[i++] = (byte)(this.PathEnd % 256);
130 bytes[i++] = (byte)((this.PathEnd >> 8) % 256);
131 bytes[i++] = this.PathScaleX;
132 bytes[i++] = this.PathScaleY;
133 bytes[i++] = this.PathShearX;
134 bytes[i++] = this.PathShearY;
135 bytes[i++] = (byte)this.PathSkew;
136 bytes[i++] = (byte)(this.ProfileBegin % 256);
137 bytes[i++] = (byte)((this.ProfileBegin >> 8) % 256);
138 bytes[i++] = (byte)(this.ProfileEnd % 256);
139 bytes[i++] = (byte)((this.ProfileEnd >> 8) % 256);
140 Array.Copy(Scale.GetBytes(), 0, bytes, i, 12); i += 12;
141 bytes[i++] = this.PathCurve;
142 bytes[i++] = this.ProfileCurve;
143 bytes[i++] = (byte)(ParentID % 256);
144 bytes[i++] = (byte)((ParentID >> 8) % 256);
145 bytes[i++] = (byte)((ParentID >> 16) % 256);
146 bytes[i++] = (byte)((ParentID >> 24) % 256);
147 bytes[i++] = (byte)(this.ProfileHollow % 256);
148 bytes[i++] = (byte)((this.ProfileHollow >> 8) % 256);
149 bytes[i++] = ((byte)this.PathRadiusOffset);
150 bytes[i++] = this.PathRevolutions;
151 bytes[i++] = ((byte)this.PathTaperX);
152 bytes[i++] = ((byte)this.PathTaperY);
153 bytes[i++] = ((byte)this.PathTwist);
154 bytes[i++] = ((byte)this.PathTwistBegin);
155 bytes[i++] = (byte)(TextureEntry.Length % 256);
156 bytes[i++] = (byte)((TextureEntry.Length >> 8) % 256);
157 Array.Copy(TextureEntry, 0, bytes, i, TextureEntry.Length); i += TextureEntry.Length;
158 bytes[i++] = (byte)(this.CreationDate % 256);
159 bytes[i++] = (byte)((this.CreationDate >> 8) % 256);
160 bytes[i++] = (byte)((this.CreationDate >> 16) % 256);
161 bytes[i++] = (byte)((this.CreationDate >> 24) % 256);
162 bytes[i++] = (byte)(this.OwnerMask % 256);
163 bytes[i++] = (byte)((this.OwnerMask >> 8) % 256);
164 bytes[i++] = (byte)((this.OwnerMask >> 16) % 256);
165 bytes[i++] = (byte)((this.OwnerMask >> 24) % 256);
166 bytes[i++] = (byte)(this.NextOwnerMask % 256);
167 bytes[i++] = (byte)((this.NextOwnerMask >> 8) % 256);
168 bytes[i++] = (byte)((this.NextOwnerMask >> 16) % 256);
169 bytes[i++] = (byte)((this.NextOwnerMask >> 24) % 256);
170 bytes[i++] = (byte)(this.GroupMask % 256);
171 bytes[i++] = (byte)((this.GroupMask >> 8) % 256);
172 bytes[i++] = (byte)((this.GroupMask >> 16) % 256);
173 bytes[i++] = (byte)((this.GroupMask >> 24) % 256);
174 bytes[i++] = (byte)(this.EveryoneMask % 256);
175 bytes[i++] = (byte)((this.EveryoneMask >> 8) % 256);
176 bytes[i++] = (byte)((this.EveryoneMask >> 16) % 256);
177 bytes[i++] = (byte)((this.EveryoneMask >> 24) % 256);
178 bytes[i++] = (byte)(this.BaseMask % 256);
179 bytes[i++] = (byte)((this.BaseMask >> 8) % 256);
180 bytes[i++] = (byte)((this.BaseMask >> 16) % 256);
181 bytes[i++] = (byte)((this.BaseMask >> 24) % 256);
182 Array.Copy(this.Position.GetBytes(), 0, bytes, i, 12); i += 12;
183 if (this.Rotation == new LLQuaternion(0, 0, 0, 0))
184 {
185 this.Rotation = new LLQuaternion(0, 1, 0, 0);
186 }
187 Array.Copy(this.Rotation.GetBytes(), 0, bytes, i, 12); i += 12;
188 bytes[i++] = (byte)(this.LocalID % 256);
189 bytes[i++] = (byte)((this.LocalID >> 8) % 256);
190 bytes[i++] = (byte)((this.LocalID >> 16) % 256);
191 bytes[i++] = (byte)((this.LocalID >> 24) % 256);
192 Array.Copy(FullID.GetBytes(), 0, bytes, i, 16); i += 16;
193
194 return bytes;
195 }
196
197 public static PrimData DefaultCube()
198 {
199 PrimData primData = new PrimData();
200 primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
201 primData.FullID = LLUUID.Random();
202 primData.Scale = new LLVector3(0.5f, 0.5f, 0.5f);
203 primData.Rotation = new LLQuaternion(0, 0, 0, 1);
204 primData.PCode = 9;
205 primData.ParentID = 0;
206 primData.PathBegin = 0;
207 primData.PathEnd = 0;
208 primData.PathScaleX = 0;
209 primData.PathScaleY = 0;
210 primData.PathShearX = 0;
211 primData.PathShearY = 0;
212 primData.PathSkew = 0;
213 primData.ProfileBegin = 0;
214 primData.ProfileEnd = 0;
215 primData.PathCurve = 16;
216 primData.ProfileCurve = 1;
217 primData.ProfileHollow = 0;
218 primData.PathRadiusOffset = 0;
219 primData.PathRevolutions = 0;
220 primData.PathTaperX = 0;
221 primData.PathTaperY = 0;
222 primData.PathTwist = 0;
223 primData.PathTwistBegin = 0;
224
225 return primData;
226 }
227 }
228}
diff --git a/OpenSim/Framework/General/Types/PrimitiveBaseShape.cs b/OpenSim/Framework/General/Types/PrimitiveBaseShape.cs
new file mode 100644
index 0000000..a6671d1
--- /dev/null
+++ b/OpenSim/Framework/General/Types/PrimitiveBaseShape.cs
@@ -0,0 +1,102 @@
1using libsecondlife;
2
3namespace OpenSim.Framework.Types
4{
5 public enum ShapeType
6 {
7 Box,
8 Sphere,
9 Ring,
10 Tube,
11 Torus,
12 Prism,
13 Scuplted,
14 Cylinder,
15 Foliage,
16 Unknown
17 }
18
19 public class PrimitiveBaseShape
20 {
21 private ShapeType type = ShapeType.Unknown;
22
23 public byte PCode;
24 public ushort PathBegin;
25 public ushort PathEnd;
26 public byte PathScaleX;
27 public byte PathScaleY;
28 public byte PathShearX;
29 public byte PathShearY;
30 public sbyte PathSkew;
31 public ushort ProfileBegin;
32 public ushort ProfileEnd;
33 public LLVector3 Scale;
34 public byte PathCurve;
35 public byte ProfileCurve;
36 public ushort ProfileHollow;
37 public sbyte PathRadiusOffset;
38 public byte PathRevolutions;
39 public sbyte PathTaperX;
40 public sbyte PathTaperY;
41 public sbyte PathTwist;
42 public sbyte PathTwistBegin;
43 public byte[] TextureEntry; // a LL textureEntry in byte[] format
44
45 public ShapeType PrimType
46 {
47 get
48 {
49 return this.type;
50 }
51 }
52
53 public LLVector3 PrimScale
54 {
55 get
56 {
57 return this.Scale;
58 }
59 }
60
61 public PrimitiveBaseShape()
62 {
63
64 }
65
66 //void returns need to change of course
67 public void GetMesh()
68 {
69
70 }
71
72 public static PrimitiveBaseShape DefaultBox()
73 {
74 PrimitiveBaseShape primShape = new PrimitiveBaseShape();
75
76 primShape.type = ShapeType.Box;
77 primShape.Scale = new LLVector3(0.5f, 0.5f, 0.5f);
78 primShape.PCode = 9;
79 primShape.PathBegin = 0;
80 primShape.PathEnd = 0;
81 primShape.PathScaleX = 0;
82 primShape.PathScaleY = 0;
83 primShape.PathShearX = 0;
84 primShape.PathShearY = 0;
85 primShape.PathSkew = 0;
86 primShape.ProfileBegin = 0;
87 primShape.ProfileEnd = 0;
88 primShape.PathCurve = 16;
89 primShape.ProfileCurve = 1;
90 primShape.ProfileHollow = 0;
91 primShape.PathRadiusOffset = 0;
92 primShape.PathRevolutions = 0;
93 primShape.PathTaperX = 0;
94 primShape.PathTaperY = 0;
95 primShape.PathTwist = 0;
96 primShape.PathTwistBegin = 0;
97
98 return primShape;
99 }
100 }
101
102}
diff --git a/OpenSim/Framework/General/Types/RegionHandle.cs b/OpenSim/Framework/General/Types/RegionHandle.cs
new file mode 100644
index 0000000..4a055ad
--- /dev/null
+++ b/OpenSim/Framework/General/Types/RegionHandle.cs
@@ -0,0 +1,121 @@
1using System;
2using System.Net;
3
4namespace OpenSim.Framework.Types
5{
6 /// <summary>
7 /// A class for manipulating RegionHandle coordinates
8 /// </summary>
9 class RegionHandle
10 {
11 private UInt64 handle;
12
13 /// <summary>
14 /// Initialises a new grid-aware RegionHandle
15 /// </summary>
16 /// <param name="ip">IP Address of the Grid Server for this region</param>
17 /// <param name="x">Grid X Coordinate</param>
18 /// <param name="y">Grid Y Coordinate</param>
19 public RegionHandle(string ip, short x, short y)
20 {
21 IPAddress addr = IPAddress.Parse(ip);
22
23 if (addr.AddressFamily != System.Net.Sockets.AddressFamily.InterNetwork)
24 throw new Exception("Bad RegionHandle Parameter - must be an IPv4 address");
25
26 uint baseHandle = BitConverter.ToUInt32(addr.GetAddressBytes(), 0);
27
28 // Split the IP address in half
29 short a = (short)((baseHandle << 16) & 0xFFFF);
30 short b = (short)((baseHandle << 0) & 0xFFFF);
31
32 // Raise the bounds a little
33 uint nx = (uint)x;
34 uint ny = (uint)y;
35
36 // Multiply grid coords to get region coords
37 nx *= 256;
38 ny *= 256;
39
40 // Stuff the IP address in too
41 nx = (uint)a << 16;
42 ny = (uint)b << 16;
43
44 handle = ((UInt64)nx << 32) | (uint)ny;
45 }
46
47 /// <summary>
48 /// Initialises a new RegionHandle that is not inter-grid aware
49 /// </summary>
50 /// <param name="x">Grid X Coordinate</param>
51 /// <param name="y">Grid Y Coordinate</param>
52 public RegionHandle(uint x, uint y)
53 {
54 handle = ((x * 256) << 32) | (y * 256);
55 }
56
57 /// <summary>
58 /// Initialises a new RegionHandle from an existing value
59 /// </summary>
60 /// <param name="Region">A U64 RegionHandle</param>
61 public RegionHandle(UInt64 Region)
62 {
63 handle = Region;
64 }
65
66 /// <summary>
67 /// Returns the Grid Masked RegionHandle - For use in Teleport packets and other packets where sending the grid IP address may be handy.
68 /// </summary>
69 /// <remarks>Do not use for SimulatorEnable packets. The client will choke.</remarks>
70 /// <returns>Region Handle including IP Address encoding</returns>
71 public UInt64 getTeleportHandle()
72 {
73 return handle;
74 }
75
76 /// <summary>
77 /// Returns a RegionHandle which may be used for SimulatorEnable packets. Removes the IP address encoding and returns the lower bounds.
78 /// </summary>
79 /// <returns>A U64 RegionHandle for use in SimulatorEnable packets.</returns>
80 public UInt64 getNeighbourHandle()
81 {
82 UInt64 mask = 0x0000FFFF0000FFFF;
83
84 return handle | mask;
85 }
86
87 /// <summary>
88 /// Returns the IP Address of the GridServer from a Grid-Encoded RegionHandle
89 /// </summary>
90 /// <returns>Grid Server IP Address</returns>
91 public IPAddress getGridIP()
92 {
93 uint a = (uint)((handle >> 16) & 0xFFFF);
94 uint b = (uint)((handle >> 48) & 0xFFFF);
95
96 return new IPAddress((long)(a << 16) | (long)b);
97 }
98
99 /// <summary>
100 /// Returns the X Coordinate from a Grid-Encoded RegionHandle
101 /// </summary>
102 /// <returns>X Coordinate</returns>
103 public uint getGridX()
104 {
105 uint x = (uint)((handle >> 32) & 0xFFFF);
106
107 return x;
108 }
109
110 /// <summary>
111 /// Returns the Y Coordinate from a Grid-Encoded RegionHandle
112 /// </summary>
113 /// <returns>Y Coordinate</returns>
114 public uint getGridY()
115 {
116 uint y = (uint)((handle >> 0) & 0xFFFF);
117
118 return y;
119 }
120 }
121}
diff --git a/OpenSim/Framework/General/Types/RegionInfo.cs b/OpenSim/Framework/General/Types/RegionInfo.cs
new file mode 100644
index 0000000..cfc0925
--- /dev/null
+++ b/OpenSim/Framework/General/Types/RegionInfo.cs
@@ -0,0 +1,342 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Globalization;
30using System.Net;
31using System.Net.Sockets;
32using libsecondlife;
33using OpenSim.Framework.Console;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Utilities;
36
37namespace OpenSim.Framework.Types
38{
39 public class RegionInfo
40 {
41 public LLUUID SimUUID = new LLUUID();
42 public string RegionName = "";
43
44 private IPEndPoint m_internalEndPoint;
45 public IPEndPoint InternalEndPoint
46 {
47 get
48 {
49 return m_internalEndPoint;
50 }
51 }
52
53 public IPEndPoint ExternalEndPoint
54 {
55 get
56 {
57 // Old one defaults to IPv6
58 //return new IPEndPoint( Dns.GetHostAddresses( m_externalHostName )[0], m_internalEndPoint.Port );
59
60 // New method favors IPv4
61 IPAddress ia = null;
62 foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName))
63 {
64 if (ia == null)
65 ia = Adr;
66
67 if (Adr.AddressFamily == AddressFamily.InterNetwork)
68 {
69 ia = Adr;
70 break;
71 }
72
73 }
74
75 return new IPEndPoint(ia, m_internalEndPoint.Port);
76 }
77 }
78
79 private string m_externalHostName;
80 public string ExternalHostName
81 {
82 get
83 {
84 return m_externalHostName;
85 }
86 }
87
88 private uint? m_regionLocX;
89 public uint RegionLocX
90 {
91 get
92 {
93 return m_regionLocX.Value;
94 }
95 }
96
97 private uint? m_regionLocY;
98 public uint RegionLocY
99 {
100 get
101 {
102 return m_regionLocY.Value;
103 }
104 }
105
106 private ulong? m_regionHandle;
107 public ulong RegionHandle
108 {
109 get
110 {
111 if (!m_regionHandle.HasValue)
112 {
113 m_regionHandle = Util.UIntsToLong((RegionLocX * 256), (RegionLocY * 256));
114 }
115
116 return m_regionHandle.Value;
117 }
118 }
119
120 // Only used for remote regions , ie ones not in the current instance
121 private uint m_remotingPort;
122 public uint RemotingPort
123 {
124 get
125 {
126 return m_remotingPort;
127 }
128 set
129 {
130 m_remotingPort = value;
131 }
132 }
133 public string RemotingAddress;
134
135 public string DataStore = "";
136 public bool isSandbox = false;
137
138 public LLUUID MasterAvatarAssignedUUID = new LLUUID();
139 public string MasterAvatarFirstName = "";
140 public string MasterAvatarLastName = "";
141 public string MasterAvatarSandboxPassword = "";
142
143 public EstateSettings estateSettings;
144
145 public RegionInfo()
146 {
147 estateSettings = new EstateSettings();
148 }
149
150 public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri)
151 : this()
152 {
153 m_regionLocX = regionLocX;
154 m_regionLocY = regionLocY;
155
156 m_internalEndPoint = internalEndPoint;
157 m_externalHostName = externalUri;
158 }
159
160 public void InitConfig(bool sandboxMode, IGenericConfig configData)
161 {
162 this.isSandbox = sandboxMode;
163 try
164 {
165 string attri = "";
166
167 // Sim UUID
168 string simId = configData.GetAttribute("SimUUID");
169 if (String.IsNullOrEmpty( simId ))
170 {
171 this.SimUUID = LLUUID.Random();
172 }
173 else
174 {
175 this.SimUUID = new LLUUID(simId);
176 }
177 configData.SetAttribute("SimUUID", this.SimUUID.ToString());
178
179 this.RegionName = GetString(configData, "SimName", "OpenSim test", "Region Name");
180
181 //m_regionLocX = (uint) GetInt(configData, "SimLocationX", 1000, "Grid Location X");
182
183 attri = "";
184 attri = configData.GetAttribute("SimLocationX");
185 if (attri == "")
186 {
187 string location = MainLog.Instance.CmdPrompt("Grid Location X", "1000");
188 configData.SetAttribute("SimLocationX", location);
189 m_regionLocX = (uint)Convert.ToUInt32(location);
190 }
191 else
192 {
193 m_regionLocX = (uint)Convert.ToUInt32(attri);
194 }
195 // Sim/Grid location Y
196 attri = "";
197 attri = configData.GetAttribute("SimLocationY");
198 if (attri == "")
199 {
200 string location = MainLog.Instance.CmdPrompt("Grid Location Y", "1000");
201 configData.SetAttribute("SimLocationY", location);
202 m_regionLocY = (uint)Convert.ToUInt32(location);
203 }
204 else
205 {
206 m_regionLocY = (uint)Convert.ToUInt32(attri);
207 }
208
209 m_regionHandle = null;
210
211 this.DataStore = GetString(configData, "Datastore", "localworld.yap", "Filename for local storage");
212
213 IPAddress internalAddress = GetIPAddress(configData, "InternalIPAddress", "0.0.0.0", "Internal IP Address for UDP client connections");
214 int internalPort = GetIPPort(configData, "InternalIPPort", "9000", "Internal IP Port for UDP client connections");
215 m_internalEndPoint = new IPEndPoint(internalAddress, internalPort);
216
217 m_externalHostName = GetString(configData, "ExternalHostName", "127.0.0.1", "External Host Name");
218
219 estateSettings.terrainFile =
220 GetString(configData, "TerrainFile", "default.r32", "GENERAL SETTING: Default Terrain File");
221
222 attri = "";
223 attri = configData.GetAttribute("TerrainMultiplier");
224 if (attri == "")
225 {
226 string re = MainLog.Instance.CmdPrompt("GENERAL SETTING: Terrain Height Multiplier", "60.0");
227 this.estateSettings.terrainMultiplier = Convert.ToDouble(re, CultureInfo.InvariantCulture);
228 configData.SetAttribute("TerrainMultiplier", this.estateSettings.terrainMultiplier.ToString());
229 }
230 else
231 {
232 this.estateSettings.terrainMultiplier = Convert.ToDouble(attri);
233 }
234
235 attri = "";
236 attri = configData.GetAttribute("MasterAvatarFirstName");
237 if (attri == "")
238 {
239 this.MasterAvatarFirstName = MainLog.Instance.CmdPrompt("First name of Master Avatar (Land and Region Owner)", "Test");
240
241 configData.SetAttribute("MasterAvatarFirstName", this.MasterAvatarFirstName);
242 }
243 else
244 {
245 this.MasterAvatarFirstName = attri;
246 }
247
248 attri = "";
249 attri = configData.GetAttribute("MasterAvatarLastName");
250 if (attri == "")
251 {
252 this.MasterAvatarLastName = MainLog.Instance.CmdPrompt("Last name of Master Avatar (Land and Region Owner)", "User");
253
254 configData.SetAttribute("MasterAvatarLastName", this.MasterAvatarLastName);
255 }
256 else
257 {
258 this.MasterAvatarLastName = attri;
259 }
260
261 if (isSandbox) //Sandbox Mode Specific Settings
262 {
263 attri = "";
264 attri = configData.GetAttribute("MasterAvatarSandboxPassword");
265 if (attri == "")
266 {
267 this.MasterAvatarSandboxPassword = MainLog.Instance.CmdPrompt("Password of Master Avatar (Needed for sandbox mode account creation only)", "test");
268
269 //Should I store this?
270 configData.SetAttribute("MasterAvatarSandboxPassword", this.MasterAvatarSandboxPassword);
271 }
272 else
273 {
274 this.MasterAvatarSandboxPassword = attri;
275 }
276 }
277
278 configData.Commit();
279 }
280 catch (Exception e)
281 {
282 MainLog.Instance.Warn("Config.cs:InitConfig() - Exception occured");
283 MainLog.Instance.Warn(e.ToString());
284 }
285
286 MainLog.Instance.Verbose("Sim settings loaded:");
287 MainLog.Instance.Verbose("UUID: " + this.SimUUID.ToStringHyphenated());
288 MainLog.Instance.Verbose("Name: " + this.RegionName);
289 MainLog.Instance.Verbose("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]");
290 MainLog.Instance.Verbose("Region Handle: " + this.RegionHandle.ToString());
291 MainLog.Instance.Verbose("Listening on IP end point: " + m_internalEndPoint.ToString() );
292 MainLog.Instance.Verbose("Sandbox Mode? " + isSandbox.ToString());
293
294 }
295
296 private uint GetInt(IGenericConfig configData, string p, int p_3, string p_4)
297 {
298 throw new Exception("The method or operation is not implemented.");
299 }
300
301 private string GetString(IGenericConfig configData, string attrName, string defaultvalue, string prompt)
302 {
303 string s = configData.GetAttribute(attrName);
304
305 if (String.IsNullOrEmpty( s ))
306 {
307 s = MainLog.Instance.CmdPrompt(prompt, defaultvalue);
308 configData.SetAttribute(attrName, s );
309 }
310 return s;
311 }
312
313 private IPAddress GetIPAddress(IGenericConfig configData, string attrName, string defaultvalue, string prompt)
314 {
315 string addressStr = configData.GetAttribute(attrName);
316
317 IPAddress address;
318
319 if (!IPAddress.TryParse(addressStr, out address))
320 {
321 address = MainLog.Instance.CmdPromptIPAddress(prompt, defaultvalue);
322 configData.SetAttribute(attrName, address.ToString());
323 }
324 return address;
325 }
326
327 private int GetIPPort(IGenericConfig configData, string attrName, string defaultvalue, string prompt)
328 {
329 string portStr = configData.GetAttribute(attrName);
330
331 int port;
332
333 if (!int.TryParse(portStr, out port))
334 {
335 port = MainLog.Instance.CmdPromptIPPort(prompt, defaultvalue);
336 configData.SetAttribute(attrName, port.ToString());
337 }
338
339 return port;
340 }
341 }
342}
diff --git a/OpenSim/Framework/General/Types/UUID.cs b/OpenSim/Framework/General/Types/UUID.cs
new file mode 100644
index 0000000..9cde18e
--- /dev/null
+++ b/OpenSim/Framework/General/Types/UUID.cs
@@ -0,0 +1,127 @@
1using System;
2using libsecondlife;
3
4namespace OpenSim.Framework.Types
5{
6 class UUID
7 {
8 public LLUUID llUUID;
9
10 public UUID(string uuid)
11 {
12 llUUID = new LLUUID(uuid);
13 }
14
15 public UUID(byte[] uuid)
16 {
17 llUUID = new LLUUID(uuid, 0);
18 }
19
20 public UUID(byte[] uuid, int offset)
21 {
22 llUUID = new LLUUID(uuid, offset);
23 }
24
25 public UUID()
26 {
27 llUUID = LLUUID.Zero;
28 }
29
30 public UUID(ulong uuid)
31 {
32 llUUID = new LLUUID(uuid);
33 }
34
35 public UUID(UInt32 first, UInt32 second, UInt32 third, UInt32 fourth)
36 {
37 byte[] uuid = new byte[16];
38
39 byte[] n = BitConverter.GetBytes(first);
40 n.CopyTo(uuid, 0);
41 n = BitConverter.GetBytes(second);
42 n.CopyTo(uuid, 4);
43 n = BitConverter.GetBytes(third);
44 n.CopyTo(uuid, 8);
45 n = BitConverter.GetBytes(fourth);
46 n.CopyTo(uuid, 12);
47
48 llUUID = new LLUUID(uuid,0);
49 }
50
51 public override string ToString()
52 {
53 return llUUID.ToString();
54 }
55
56 public string ToStringHyphenated()
57 {
58 return llUUID.ToStringHyphenated();
59 }
60
61 public byte[] GetBytes()
62 {
63 return llUUID.GetBytes();
64 }
65
66 public UInt32[] GetInts()
67 {
68 UInt32[] ints = new UInt32[4];
69 ints[0] = BitConverter.ToUInt32(llUUID.Data, 0);
70 ints[1] = BitConverter.ToUInt32(llUUID.Data, 4);
71 ints[2] = BitConverter.ToUInt32(llUUID.Data, 8);
72 ints[3] = BitConverter.ToUInt32(llUUID.Data, 12);
73
74 return ints;
75 }
76
77 public LLUUID GetLLUUID()
78 {
79 return llUUID;
80 }
81
82 public uint CRC()
83 {
84 return llUUID.CRC();
85 }
86
87 public override int GetHashCode()
88 {
89 return llUUID.GetHashCode();
90 }
91
92 public void Combine(UUID other)
93 {
94 llUUID.Combine(other.GetLLUUID());
95 }
96
97 public void Combine(LLUUID other)
98 {
99 llUUID.Combine(other);
100 }
101
102 public override bool Equals(Object other)
103 {
104 return llUUID.Equals(other);
105 }
106
107 public static bool operator ==(UUID a, UUID b)
108 {
109 return a.llUUID.Equals(b.GetLLUUID());
110 }
111
112 public static bool operator !=(UUID a, UUID b)
113 {
114 return !a.llUUID.Equals(b.GetLLUUID());
115 }
116
117 public static bool operator ==(UUID a, LLUUID b)
118 {
119 return a.Equals(b);
120 }
121
122 public static bool operator !=(UUID a, LLUUID b)
123 {
124 return !a.Equals(b);
125 }
126 }
127}
diff --git a/OpenSim/Framework/General/UserProfile.cs b/OpenSim/Framework/General/UserProfile.cs
new file mode 100644
index 0000000..243208a
--- /dev/null
+++ b/OpenSim/Framework/General/UserProfile.cs
@@ -0,0 +1,87 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Collections.Generic;
29using System.Security.Cryptography;
30using libsecondlife;
31using OpenSim.Framework.Inventory;
32
33namespace OpenSim.Framework.User
34{
35 public class UserProfile
36 {
37
38 public string firstname;
39 public string lastname;
40 public ulong homeregionhandle;
41 public LLVector3 homepos;
42 public LLVector3 homelookat;
43
44 public bool IsGridGod = false;
45 public bool IsLocal = true; // will be used in future for visitors from foreign grids
46 public string AssetURL;
47 public string MD5passwd;
48
49 public LLUUID CurrentSessionID;
50 public LLUUID CurrentSecureSessionID;
51 public LLUUID UUID;
52 public Dictionary<LLUUID, uint> Circuits = new Dictionary<LLUUID, uint>(); // tracks circuit codes
53
54 public AgentInventory Inventory;
55
56 public UserProfile()
57 {
58 Circuits = new Dictionary<LLUUID, uint>();
59 Inventory = new AgentInventory();
60 homeregionhandle = Helpers.UIntsToLong((1000 * 256), (1000 * 256));
61 homepos = new LLVector3();
62 homelookat = new LLVector3();
63 }
64
65 public void InitSessionData()
66 {
67 RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
68
69 byte[] randDataS = new byte[16];
70 byte[] randDataSS = new byte[16];
71
72 rand.GetBytes(randDataS);
73 rand.GetBytes(randDataSS);
74
75 CurrentSecureSessionID = new LLUUID(randDataSS,0);
76 CurrentSessionID = new LLUUID(randDataS,0);
77
78 }
79
80 public void AddSimCircuit(uint circuitCode, LLUUID regionUUID)
81 {
82 if (this.Circuits.ContainsKey(regionUUID) == false)
83 this.Circuits.Add(regionUUID, circuitCode);
84 }
85
86 }
87}
diff --git a/OpenSim/Framework/General/Util.cs b/OpenSim/Framework/General/Util.cs
new file mode 100644
index 0000000..13e3af2
--- /dev/null
+++ b/OpenSim/Framework/General/Util.cs
@@ -0,0 +1,184 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Security.Cryptography;
30using System.Text;
31using libsecondlife;
32
33namespace OpenSim.Framework.Utilities
34{
35 public class Util
36 {
37 private static Random randomClass = new Random();
38 private static uint nextXferID = 5000;
39 private static object XferLock = new object();
40
41 public static ulong UIntsToLong(uint X, uint Y)
42 {
43 return Helpers.UIntsToLong(X, Y);
44 }
45
46 public static Random RandomClass
47 {
48 get
49 {
50 return randomClass;
51 }
52 }
53
54 public static uint GetNextXferID()
55 {
56 uint id = 0;
57 lock(XferLock)
58 {
59 id = nextXferID;
60 nextXferID++;
61 }
62 return id;
63 }
64
65 public static int UnixTimeSinceEpoch()
66 {
67 TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));
68 int timestamp = (int)t.TotalSeconds;
69 return timestamp;
70 }
71
72 public static string Md5Hash(string pass)
73 {
74 MD5 md5 = MD5CryptoServiceProvider.Create();
75 byte[] dataMd5 = md5.ComputeHash(Encoding.Default.GetBytes(pass));
76 StringBuilder sb = new StringBuilder();
77 for (int i = 0; i < dataMd5.Length; i++)
78 sb.AppendFormat("{0:x2}", dataMd5[i]);
79 return sb.ToString();
80 }
81
82 public static string GetRandomCapsPath()
83 {
84 LLUUID caps = LLUUID.Random();
85 string capsPath = caps.ToStringHyphenated();
86 capsPath = capsPath.Remove(capsPath.Length - 4, 4);
87 return capsPath;
88 }
89
90 //public static int fast_distance2d(int x, int y)
91 //{
92 // x = System.Math.Abs(x);
93 // y = System.Math.Abs(y);
94
95 // int min = System.Math.Min(x, y);
96
97 // return (x + y - (min >> 1) - (min >> 2) + (min >> 4));
98 //}
99
100 public static string FieldToString(byte[] bytes)
101 {
102 return FieldToString(bytes, String.Empty);
103 }
104
105 /// <summary>
106 /// Convert a variable length field (byte array) to a string, with a
107 /// field name prepended to each line of the output
108 /// </summary>
109 /// <remarks>If the byte array has unprintable characters in it, a
110 /// hex dump will be put in the string instead</remarks>
111 /// <param name="bytes">The byte array to convert to a string</param>
112 /// <param name="fieldName">A field name to prepend to each line of output</param>
113 /// <returns>An ASCII string or a string containing a hex dump, minus
114 /// the null terminator</returns>
115 public static string FieldToString(byte[] bytes, string fieldName)
116 {
117 // Check for a common case
118 if (bytes.Length == 0) return String.Empty;
119
120 StringBuilder output = new StringBuilder();
121 bool printable = true;
122
123 for (int i = 0; i < bytes.Length; ++i)
124 {
125 // Check if there are any unprintable characters in the array
126 if ((bytes[i] < 0x20 || bytes[i] > 0x7E) && bytes[i] != 0x09
127 && bytes[i] != 0x0D && bytes[i] != 0x0A && bytes[i] != 0x00)
128 {
129 printable = false;
130 break;
131 }
132 }
133
134 if (printable)
135 {
136 if (fieldName.Length > 0)
137 {
138 output.Append(fieldName);
139 output.Append(": ");
140 }
141
142 if (bytes[bytes.Length - 1] == 0x00)
143 output.Append(UTF8Encoding.UTF8.GetString(bytes, 0, bytes.Length - 1));
144 else
145 output.Append(UTF8Encoding.UTF8.GetString(bytes));
146 }
147 else
148 {
149 for (int i = 0; i < bytes.Length; i += 16)
150 {
151 if (i != 0)
152 output.Append(Environment.NewLine);
153 if (fieldName.Length > 0)
154 {
155 output.Append(fieldName);
156 output.Append(": ");
157 }
158
159 for (int j = 0; j < 16; j++)
160 {
161 if ((i + j) < bytes.Length)
162 output.Append(String.Format("{0:X2} ", bytes[i + j]));
163 else
164 output.Append(" ");
165 }
166
167 for (int j = 0; j < 16 && (i + j) < bytes.Length; j++)
168 {
169 if (bytes[i + j] >= 0x20 && bytes[i + j] < 0x7E)
170 output.Append((char)bytes[i + j]);
171 else
172 output.Append(".");
173 }
174 }
175 }
176
177 return output.ToString();
178 }
179 public Util()
180 {
181
182 }
183 }
184}
diff --git a/OpenSim/Framework/GenericConfig/Xml/Properties/AssemblyInfo.cs b/OpenSim/Framework/GenericConfig/Xml/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..fcffd67
--- /dev/null
+++ b/OpenSim/Framework/GenericConfig/Xml/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.GenericConfig")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenSim.GenericConfig")]
11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("285a3047-f165-46c8-8767-b51428738a09")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Framework/GenericConfig/Xml/XmlConfig.cs b/OpenSim/Framework/GenericConfig/Xml/XmlConfig.cs
new file mode 100644
index 0000000..7fa085d
--- /dev/null
+++ b/OpenSim/Framework/GenericConfig/Xml/XmlConfig.cs
@@ -0,0 +1,122 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.IO;
30using System.Xml;
31using OpenSim.Framework.Interfaces;
32
33namespace OpenSim.GenericConfig
34{
35 public class XmlConfig : IGenericConfig
36 {
37 private XmlDocument doc;
38 private XmlNode rootNode;
39 private XmlNode configNode;
40 private string fileName;
41 private bool createdFile = false;
42
43 public XmlConfig(string filename)
44 {
45 fileName = filename;
46 }
47
48 public void LoadData()
49 {
50 doc = new XmlDocument();
51
52 if (File.Exists(fileName))
53 {
54 XmlTextReader reader = new XmlTextReader(fileName);
55 reader.WhitespaceHandling = WhitespaceHandling.None;
56 doc.Load(reader);
57 reader.Close();
58 }
59 else
60 {
61 createdFile = true;
62 rootNode = doc.CreateNode(XmlNodeType.Element, "Root", "");
63 doc.AppendChild(rootNode);
64 configNode = doc.CreateNode(XmlNodeType.Element, "Config", "");
65 rootNode.AppendChild(configNode);
66 }
67
68
69 rootNode = doc.FirstChild;
70 if (rootNode.Name != "Root")
71 throw new Exception("Error: Invalid .xml File. Missing <Root>");
72
73 configNode = rootNode.FirstChild;
74 if (configNode.Name != "Config")
75 throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>");
76
77 if (createdFile)
78 {
79 this.Commit();
80 }
81 }
82
83 public string GetAttribute(string attributeName)
84 {
85 string result = "";
86 if (configNode.Attributes[attributeName] != null)
87 {
88 result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value;
89 }
90 return result;
91 }
92
93 public bool SetAttribute(string attributeName, string attributeValue)
94 {
95 if (configNode.Attributes[attributeName] != null)
96 {
97 ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue;
98 }
99 else
100 {
101 XmlAttribute attri;
102 attri = doc.CreateAttribute(attributeName);
103 attri.Value = attributeValue;
104 configNode.Attributes.Append(attri);
105 }
106 return true;
107 }
108
109 public void Commit()
110 {
111 doc.Save(fileName);
112 }
113
114 public void Close()
115 {
116 configNode = null;
117 rootNode = null;
118 doc = null;
119 }
120
121 }
122}
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs
new file mode 100644
index 0000000..f790477
--- /dev/null
+++ b/OpenSim/Framework/Servers/BaseHttpServer.cs
@@ -0,0 +1,224 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.IO;
32using System.Net;
33using System.Text;
34using System.Text.RegularExpressions;
35using System.Threading;
36using Nwc.XmlRpc;
37using OpenSim.Framework.Console;
38
39namespace OpenSim.Framework.Servers
40{
41 public class BaseHttpServer
42 {
43 protected Thread m_workerThread;
44 protected HttpListener m_httpListener;
45 protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>();
46 protected Dictionary<string, IStreamHandler> m_streamHandlers = new Dictionary<string, IStreamHandler>();
47 protected int m_port;
48 protected bool m_firstcaps = true;
49
50 public BaseHttpServer(int port)
51 {
52 m_port = port;
53 }
54
55 public void AddStreamHandler( IStreamHandler handler)
56 {
57 string httpMethod = handler.HttpMethod;
58 string path = handler.Path;
59
60 string handlerKey = GetHandlerKey(httpMethod, path);
61 m_streamHandlers.Add(handlerKey, handler);
62 }
63
64 private static string GetHandlerKey(string httpMethod, string path)
65 {
66 return httpMethod + ":" + path;
67 }
68
69 public bool AddXmlRPCHandler(string method, XmlRpcMethod handler)
70 {
71 if (!this.m_rpcHandlers.ContainsKey(method))
72 {
73 this.m_rpcHandlers.Add(method, handler);
74 return true;
75 }
76
77 //must already have a handler for that path so return false
78 return false;
79 }
80
81
82 public virtual void HandleRequest(Object stateinfo)
83 {
84 HttpListenerContext context = (HttpListenerContext)stateinfo;
85
86 HttpListenerRequest request = context.Request;
87 HttpListenerResponse response = context.Response;
88
89 response.KeepAlive = false;
90 response.SendChunked = false;
91
92 string path = request.RawUrl;
93 string handlerKey = GetHandlerKey( request.HttpMethod, path );
94
95 IStreamHandler streamHandler;
96
97 if (TryGetStreamHandler( handlerKey, out streamHandler))
98 {
99 byte[] buffer = streamHandler.Handle(path, request.InputStream);
100 request.InputStream.Close();
101
102 response.ContentType = streamHandler.ContentType;
103 response.ContentLength64 = buffer.LongLength;
104 response.OutputStream.Write(buffer, 0, buffer.Length);
105 response.OutputStream.Close();
106 }
107 else
108 {
109 HandleXmlRpcRequests(request, response);
110 }
111 }
112
113 private bool TryGetStreamHandler(string handlerKey, out IStreamHandler streamHandler)
114 {
115 string bestMatch = null;
116
117 foreach (string pattern in m_streamHandlers.Keys)
118 {
119 if (handlerKey.StartsWith(pattern))
120 {
121 if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length)
122 {
123 bestMatch = pattern;
124 }
125 }
126 }
127
128 if (String.IsNullOrEmpty(bestMatch))
129 {
130 streamHandler = null;
131 return false;
132 }
133 else
134 {
135 streamHandler = m_streamHandlers[bestMatch];
136 return true;
137 }
138 }
139
140 private void HandleXmlRpcRequests(HttpListenerRequest request, HttpListenerResponse response)
141 {
142 Stream requestStream = request.InputStream;
143
144 Encoding encoding = Encoding.UTF8;
145 StreamReader reader = new StreamReader(requestStream, encoding);
146
147 string requestBody = reader.ReadToEnd();
148 reader.Close();
149 requestStream.Close();
150
151 XmlRpcRequest xmlRprcRequest = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody);
152
153 string methodName = xmlRprcRequest.MethodName;
154
155 XmlRpcResponse xmlRpcResponse;
156
157 XmlRpcMethod method;
158 if (this.m_rpcHandlers.TryGetValue(methodName, out method))
159 {
160 xmlRpcResponse = method(xmlRprcRequest);
161 }
162 else
163 {
164 xmlRpcResponse = new XmlRpcResponse();
165 Hashtable unknownMethodError = new Hashtable();
166 unknownMethodError["reason"] = "XmlRequest"; ;
167 unknownMethodError["message"] = "Unknown Rpc Request ["+methodName+"]";
168 unknownMethodError["login"] = "false";
169 xmlRpcResponse.Value = unknownMethodError;
170 }
171
172 response.AddHeader("Content-type", "text/xml");
173
174 string responseString = XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse);
175
176 byte[] buffer = Encoding.UTF8.GetBytes(responseString);
177
178 response.SendChunked = false;
179 response.ContentLength64 = buffer.Length;
180 response.ContentEncoding = Encoding.UTF8;
181
182 response.OutputStream.Write(buffer, 0, buffer.Length);
183 response.OutputStream.Close();
184 }
185
186 public void Start()
187 {
188 MainLog.Instance.WriteLine(LogPriority.LOW, "BaseHttpServer.cs: Starting up HTTP Server");
189
190 m_workerThread = new Thread(new ThreadStart(StartHTTP));
191 m_workerThread.IsBackground = true;
192 m_workerThread.Start();
193 }
194
195 private void StartHTTP()
196 {
197 try
198 {
199 MainLog.Instance.WriteLine(LogPriority.LOW, "BaseHttpServer.cs: StartHTTP() - Spawned main thread OK");
200 m_httpListener = new HttpListener();
201
202 m_httpListener.Prefixes.Add("http://+:" + m_port + "/");
203 m_httpListener.Start();
204
205 HttpListenerContext context;
206 while (true)
207 {
208 context = m_httpListener.GetContext();
209 ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
210 }
211 }
212 catch (Exception e)
213 {
214 MainLog.Instance.WriteLine(LogPriority.MEDIUM, e.Message);
215 }
216 }
217
218
219 public void RemoveStreamHandler(string httpMethod, string path)
220 {
221 m_streamHandlers.Remove(GetHandlerKey(httpMethod, path));
222 }
223 }
224}
diff --git a/OpenSim/Framework/Servers/BaseStreamHandler.cs b/OpenSim/Framework/Servers/BaseStreamHandler.cs
new file mode 100644
index 0000000..0d9c674
--- /dev/null
+++ b/OpenSim/Framework/Servers/BaseStreamHandler.cs
@@ -0,0 +1,40 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.IO;
5
6namespace OpenSim.Framework.Servers
7{
8 public abstract class BaseStreamHandler : IStreamHandler
9 {
10 virtual public string ContentType
11 {
12 get { return "application/xml"; }
13 }
14
15 private string m_httpMethod;
16 virtual public string HttpMethod
17 {
18 get { return m_httpMethod; }
19 }
20
21 private string m_path;
22 virtual public string Path
23 {
24 get { return m_path; }
25 }
26
27 protected string GetParam( string path )
28 {
29 return path.Substring( m_path.Length );
30 }
31
32 public abstract byte[] Handle(string path, Stream request);
33
34 protected BaseStreamHandler(string httpMethod, string path)
35 {
36 m_httpMethod = httpMethod;
37 m_path = path;
38 }
39 }
40}
diff --git a/OpenSim/Framework/Servers/CheckSumServer.cs b/OpenSim/Framework/Servers/CheckSumServer.cs
new file mode 100644
index 0000000..89ec095
--- /dev/null
+++ b/OpenSim/Framework/Servers/CheckSumServer.cs
@@ -0,0 +1,127 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28namespace OpenSim.Framework.Servers
29{/*
30 public class CheckSumServer : UDPServerBase
31 {
32 //protected ConsoleBase m_log;
33
34 public CheckSumServer(int port)
35 : base(port)
36 {
37 }
38
39 protected override void OnReceivedData(IAsyncResult result)
40 {
41 ipeSender = new IPEndPoint(IPAddress.Any, 0);
42 epSender = (EndPoint)ipeSender;
43 Packet packet = null;
44 int numBytes = Server.EndReceiveFrom(result, ref epSender);
45 int packetEnd = numBytes - 1;
46
47 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
48
49 if (packet.Type == PacketType.SecuredTemplateChecksumRequest)
50 {
51 SecuredTemplateChecksumRequestPacket checksum = (SecuredTemplateChecksumRequestPacket)packet;
52 TemplateChecksumReplyPacket checkreply = new TemplateChecksumReplyPacket();
53 checkreply.DataBlock.Checksum = 3220703154;//180572585;
54 checkreply.DataBlock.Flags = 0;
55 checkreply.DataBlock.MajorVersion = 1;
56 checkreply.DataBlock.MinorVersion = 15;
57 checkreply.DataBlock.PatchVersion = 0;
58 checkreply.DataBlock.ServerVersion = 0;
59 checkreply.TokenBlock.Token = checksum.TokenBlock.Token;
60 this.SendPacket(checkreply, epSender);
61
62 /*
63 //if we wanted to echo the the checksum/ version from the client (so that any client worked)
64 SecuredTemplateChecksumRequestPacket checkrequest = new SecuredTemplateChecksumRequestPacket();
65 checkrequest.TokenBlock.Token = checksum.TokenBlock.Token;
66 this.SendPacket(checkrequest, epSender);
67
68 }
69 else if (packet.Type == PacketType.TemplateChecksumReply)
70 {
71 //echo back the client checksum reply (Hegemon's method)
72 TemplateChecksumReplyPacket checksum2 = (TemplateChecksumReplyPacket)packet;
73 TemplateChecksumReplyPacket checkreply2 = new TemplateChecksumReplyPacket();
74 checkreply2.DataBlock.Checksum = checksum2.DataBlock.Checksum;
75 checkreply2.DataBlock.Flags = checksum2.DataBlock.Flags;
76 checkreply2.DataBlock.MajorVersion = checksum2.DataBlock.MajorVersion;
77 checkreply2.DataBlock.MinorVersion = checksum2.DataBlock.MinorVersion;
78 checkreply2.DataBlock.PatchVersion = checksum2.DataBlock.PatchVersion;
79 checkreply2.DataBlock.ServerVersion = checksum2.DataBlock.ServerVersion;
80 checkreply2.TokenBlock.Token = checksum2.TokenBlock.Token;
81 this.SendPacket(checkreply2, epSender);
82 }
83 else
84 {
85 }
86
87 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
88 }
89
90 private void SendPacket(Packet Pack, EndPoint endp)
91 {
92 if (!Pack.Header.Resent)
93 {
94 Pack.Header.Sequence = 1;
95 }
96
97 byte[] ZeroOutBuffer = new byte[4096];
98 byte[] sendbuffer;
99 sendbuffer = Pack.ToBytes();
100
101 try
102 {
103 if (Pack.Header.Zerocoded)
104 {
105 int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
106 this.SendPackTo(ZeroOutBuffer, packetsize, SocketFlags.None, endp);
107 }
108 else
109 {
110 this.SendPackTo(sendbuffer, sendbuffer.Length, SocketFlags.None, endp);
111 }
112 }
113 catch (Exception)
114 {
115 OpenSim.Framework.Console.MainLog.Instance.Warn("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection ");
116
117 }
118 }
119
120 private void SendPackTo(byte[] buffer, int size, SocketFlags flags, EndPoint endp)
121 {
122 this.Server.SendTo(buffer, size, flags, endp);
123 }
124 * }
125 */
126
127} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/IStreamHandler.cs b/OpenSim/Framework/Servers/IStreamHandler.cs
new file mode 100644
index 0000000..6cab40d
--- /dev/null
+++ b/OpenSim/Framework/Servers/IStreamHandler.cs
@@ -0,0 +1,22 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.IO;
5
6namespace OpenSim.Framework.Servers
7{
8 public interface IStreamHandler
9 {
10 // Handle request stream, return byte array
11 byte[] Handle(string path, Stream request );
12
13 // Return response content type
14 string ContentType { get; }
15
16 // Return required http method
17 string HttpMethod { get;}
18
19 // Return path
20 string Path { get; }
21 }
22}
diff --git a/OpenSim/Framework/Servers/RestMethod.cs b/OpenSim/Framework/Servers/RestMethod.cs
new file mode 100644
index 0000000..c6cb230
--- /dev/null
+++ b/OpenSim/Framework/Servers/RestMethod.cs
@@ -0,0 +1,31 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28namespace OpenSim.Framework.Servers
29{
30 public delegate string RestMethod( string request, string path, string param );
31}
diff --git a/OpenSim/Framework/Servers/RestStreamHandler.cs b/OpenSim/Framework/Servers/RestStreamHandler.cs
new file mode 100644
index 0000000..1b3b41c
--- /dev/null
+++ b/OpenSim/Framework/Servers/RestStreamHandler.cs
@@ -0,0 +1,31 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.IO;
5
6namespace OpenSim.Framework.Servers
7{
8 public class RestStreamHandler : BaseStreamHandler
9 {
10 RestMethod m_restMethod;
11
12 override public byte[] Handle(string path, Stream request )
13 {
14 Encoding encoding = Encoding.UTF8;
15 StreamReader streamReader = new StreamReader(request, encoding);
16
17 string requestBody = streamReader.ReadToEnd();
18 streamReader.Close();
19
20 string param = GetParam(path);
21 string responseString = m_restMethod(requestBody, path, param );
22
23 return Encoding.UTF8.GetBytes(responseString);
24 }
25
26 public RestStreamHandler(string httpMethod, string path, RestMethod restMethod) : base( httpMethod, path )
27 {
28 m_restMethod = restMethod;
29 }
30 }
31}
diff --git a/OpenSim/Framework/Servers/UDPServerBase.cs b/OpenSim/Framework/Servers/UDPServerBase.cs
new file mode 100644
index 0000000..508eb9d
--- /dev/null
+++ b/OpenSim/Framework/Servers/UDPServerBase.cs
@@ -0,0 +1,87 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Net;
30using System.Net.Sockets;
31using libsecondlife.Packets;
32
33namespace OpenSim.Framework.Servers
34{
35 public class UDPServerBase
36 {
37 public Socket Server;
38 protected IPEndPoint ServerIncoming;
39 protected byte[] RecvBuffer = new byte[4096];
40 protected byte[] ZeroBuffer = new byte[8192];
41 protected IPEndPoint ipeSender;
42 protected EndPoint epSender;
43 protected AsyncCallback ReceivedData;
44 protected int listenPort;
45
46 public UDPServerBase(int port)
47 {
48 listenPort = port;
49 }
50
51 protected virtual void OnReceivedData(IAsyncResult result)
52 {
53 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
54 epSender = (EndPoint)ipeSender;
55 Packet packet = null;
56 int numBytes = Server.EndReceiveFrom(result, ref epSender);
57 int packetEnd = numBytes - 1;
58
59 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
60
61 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
62 }
63
64 protected virtual void AddNewClient(Packet packet)
65 {
66 }
67
68 public virtual void ServerListener()
69 {
70
71 ServerIncoming = new IPEndPoint(IPAddress.Parse("0.0.0.0"), listenPort);
72 Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
73 Server.Bind(ServerIncoming);
74
75 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
76 epSender = (EndPoint)ipeSender;
77 ReceivedData = new AsyncCallback(this.OnReceivedData);
78 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
79 }
80
81 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
82 {
83
84 }
85 }
86}
87
diff --git a/OpenSim/Framework/Servers/XmlRpcMethod.cs b/OpenSim/Framework/Servers/XmlRpcMethod.cs
new file mode 100644
index 0000000..b76ac51
--- /dev/null
+++ b/OpenSim/Framework/Servers/XmlRpcMethod.cs
@@ -0,0 +1,33 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using Nwc.XmlRpc;
29
30namespace OpenSim.Framework.Servers
31{
32 public delegate XmlRpcResponse XmlRpcMethod( XmlRpcRequest request );
33}
diff --git a/OpenSim/Framework/UserManager/LoginResponse.cs b/OpenSim/Framework/UserManager/LoginResponse.cs
new file mode 100644
index 0000000..abcbd48
--- /dev/null
+++ b/OpenSim/Framework/UserManager/LoginResponse.cs
@@ -0,0 +1,643 @@
1using System;
2using System.Collections;
3using libsecondlife;
4using Nwc.XmlRpc;
5using OpenSim.Framework.Console;
6
7namespace OpenSim.Framework.UserManagement
8{
9
10 /// <summary>
11 /// A temp class to handle login response.
12 /// Should make use of UserProfileManager where possible.
13 /// </summary>
14
15 public class LoginResponse
16 {
17 private Hashtable loginFlagsHash;
18 private Hashtable globalTexturesHash;
19 private Hashtable loginError;
20 private Hashtable eventCategoriesHash;
21 private Hashtable uiConfigHash;
22 private Hashtable classifiedCategoriesHash;
23
24 private ArrayList loginFlags;
25 private ArrayList globalTextures;
26 private ArrayList eventCategories;
27 private ArrayList uiConfig;
28 private ArrayList classifiedCategories;
29 private ArrayList inventoryRoot;
30 private ArrayList initialOutfit;
31 private ArrayList agentInventory;
32
33 private UserInfo userProfile;
34
35 private LLUUID agentID;
36 private LLUUID sessionID;
37 private LLUUID secureSessionID;
38
39 // Login Flags
40 private string dst;
41 private string stipendSinceLogin;
42 private string gendered;
43 private string everLoggedIn;
44 private string login;
45 private int simPort;
46 private string simAddress;
47 private string agentAccess;
48 private Int32 circuitCode;
49 private uint regionX;
50 private uint regionY;
51
52 // Login
53 private string firstname;
54 private string lastname;
55
56 // Global Textures
57 private string sunTexture;
58 private string cloudTexture;
59 private string moonTexture;
60
61 // Error Flags
62 private string errorReason;
63 private string errorMessage;
64
65 // Response
66 private XmlRpcResponse xmlRpcResponse;
67 private XmlRpcResponse defaultXmlRpcResponse;
68
69 private string welcomeMessage;
70 private string startLocation;
71 private string allowFirstLife;
72 private string home;
73 private string seedCapability;
74 private string lookAt;
75
76 public LoginResponse()
77 {
78 this.loginFlags = new ArrayList();
79 this.globalTextures = new ArrayList();
80 this.eventCategories = new ArrayList();
81 this.uiConfig = new ArrayList();
82 this.classifiedCategories = new ArrayList();
83
84 this.loginError = new Hashtable();
85 this.eventCategoriesHash = new Hashtable();
86 this.classifiedCategoriesHash = new Hashtable();
87 this.uiConfigHash = new Hashtable();
88
89 this.defaultXmlRpcResponse = new XmlRpcResponse();
90 this.userProfile = new UserInfo();
91 this.inventoryRoot = new ArrayList();
92 this.initialOutfit = new ArrayList();
93 this.agentInventory = new ArrayList();
94
95 this.xmlRpcResponse = new XmlRpcResponse();
96 this.defaultXmlRpcResponse = new XmlRpcResponse();
97
98 this.SetDefaultValues();
99 } // LoginServer
100
101 public void SetDefaultValues()
102 {
103 this.DST = "N";
104 this.StipendSinceLogin = "N";
105 this.Gendered = "Y";
106 this.EverLoggedIn = "Y";
107 this.login = "false";
108 this.firstname = "Test";
109 this.lastname = "User";
110 this.agentAccess = "M";
111 this.startLocation = "last";
112 this.allowFirstLife = "Y";
113
114 this.SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271";
115 this.CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
116 this.MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
117
118 this.ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock.";
119 this.ErrorReason = "key";
120 this.welcomeMessage = "Welcome to OpenSim!";
121 this.seedCapability = "";
122 this.home = "{'region_handle':[r" + (1000 * 256).ToString() + ",r" + (1000 * 256).ToString() + "], 'position':[r" + this.userProfile.homepos.X.ToString() + ",r" + this.userProfile.homepos.Y.ToString() + ",r" + this.userProfile.homepos.Z.ToString() + "], 'look_at':[r" + this.userProfile.homelookat.X.ToString() + ",r" + this.userProfile.homelookat.Y.ToString() + ",r" + this.userProfile.homelookat.Z.ToString() + "]}";
123 this.lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]";
124 this.RegionX = (uint)255232;
125 this.RegionY = (uint)254976;
126
127 // Classifieds;
128 this.AddClassifiedCategory((Int32)1, "Shopping");
129 this.AddClassifiedCategory((Int32)2, "Land Rental");
130 this.AddClassifiedCategory((Int32)3, "Property Rental");
131 this.AddClassifiedCategory((Int32)4, "Special Attraction");
132 this.AddClassifiedCategory((Int32)5, "New Products");
133 this.AddClassifiedCategory((Int32)6, "Employment");
134 this.AddClassifiedCategory((Int32)7, "Wanted");
135 this.AddClassifiedCategory((Int32)8, "Service");
136 this.AddClassifiedCategory((Int32)9, "Personal");
137
138
139 this.SessionID = LLUUID.Random();
140 this.SecureSessionID = LLUUID.Random();
141 this.AgentID = LLUUID.Random();
142
143 Hashtable InitialOutfitHash = new Hashtable();
144 InitialOutfitHash["folder_name"] = "Nightclub Female";
145 InitialOutfitHash["gender"] = "female";
146 this.initialOutfit.Add(InitialOutfitHash);
147
148
149 } // SetDefaultValues
150
151 #region Login Failure Methods
152 public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login)
153 {
154 // Overwrite any default values;
155 this.xmlRpcResponse = new XmlRpcResponse();
156
157 // Ensure Login Failed message/reason;
158 this.ErrorMessage = message;
159 this.ErrorReason = reason;
160
161 this.loginError["reason"] = this.ErrorReason;
162 this.loginError["message"] = this.ErrorMessage;
163 this.loginError["login"] = login;
164 this.xmlRpcResponse.Value = this.loginError;
165 return (this.xmlRpcResponse);
166 } // GenerateResponse
167
168 public XmlRpcResponse CreateFailedResponse()
169 {
170 return (this.CreateLoginFailedResponse());
171 } // CreateErrorConnectingToGridResponse()
172
173 public XmlRpcResponse CreateLoginFailedResponse()
174 {
175 return (this.GenerateFailureResponse("key", "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", "false"));
176 } // LoginFailedResponse
177
178 public XmlRpcResponse CreateAlreadyLoggedInResponse()
179 {
180 return (this.GenerateFailureResponse("presence", "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner", "false"));
181 } // CreateAlreadyLoggedInResponse()
182
183 public XmlRpcResponse CreateDeadRegionResponse()
184 {
185 return (this.GenerateFailureResponse("key", "The region you are attempting to log into is not responding. Please select another region and try again.", "false"));
186 }
187
188 public XmlRpcResponse CreateGridErrorResponse()
189 {
190 return (this.GenerateFailureResponse("key", "Error connecting to grid. Could not percieve credentials from login XML.", "false"));
191 }
192
193 #endregion
194
195 public XmlRpcResponse ToXmlRpcResponse()
196 {
197 try
198 {
199
200 Hashtable responseData = new Hashtable();
201
202 this.loginFlagsHash = new Hashtable();
203 this.loginFlagsHash["daylight_savings"] = this.DST;
204 this.loginFlagsHash["stipend_since_login"] = this.StipendSinceLogin;
205 this.loginFlagsHash["gendered"] = this.Gendered;
206 this.loginFlagsHash["ever_logged_in"] = this.EverLoggedIn;
207 this.loginFlags.Add(this.loginFlagsHash);
208
209 responseData["first_name"] = this.Firstname;
210 responseData["last_name"] = this.Lastname;
211 responseData["agent_access"] = this.agentAccess;
212
213 this.globalTexturesHash = new Hashtable();
214 this.globalTexturesHash["sun_texture_id"] = this.SunTexture;
215 this.globalTexturesHash["cloud_texture_id"] = this.CloudTexture;
216 this.globalTexturesHash["moon_texture_id"] = this.MoonTexture;
217 this.globalTextures.Add(this.globalTexturesHash);
218 this.eventCategories.Add(this.eventCategoriesHash);
219
220 this.AddToUIConfig("allow_first_life", this.allowFirstLife);
221 this.uiConfig.Add(this.uiConfigHash);
222
223 responseData["sim_port"] =(Int32) this.SimPort;
224 responseData["sim_ip"] = this.SimAddress;
225
226 MainLog.Instance.Warn("SIM IP: " + responseData["sim_ip"] + "; SIM PORT: " + responseData["sim_port"]);
227
228 responseData["agent_id"] = this.AgentID.ToStringHyphenated();
229 responseData["session_id"] = this.SessionID.ToStringHyphenated();
230 responseData["secure_session_id"] = this.SecureSessionID.ToStringHyphenated();
231 responseData["circuit_code"] = this.CircuitCode;
232 responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
233 responseData["login-flags"] = this.loginFlags;
234 responseData["global-textures"] = this.globalTextures;
235 responseData["seed_capability"] = this.seedCapability;
236
237 responseData["event_categories"] = this.eventCategories;
238 responseData["event_notifications"] = new ArrayList(); // todo
239 responseData["classified_categories"] = this.classifiedCategories;
240 responseData["ui-config"] = this.uiConfig;
241
242 responseData["inventory-skeleton"] = this.agentInventory;
243 responseData["inventory-skel-lib"] = new ArrayList(); // todo
244 responseData["inventory-root"] = this.inventoryRoot;
245 responseData["gestures"] = new ArrayList(); // todo
246 responseData["inventory-lib-owner"] = new ArrayList(); // todo
247 responseData["initial-outfit"] = this.initialOutfit;
248 responseData["start_location"] = this.startLocation;
249 responseData["seed_capability"] = this.seedCapability;
250 responseData["home"] = this.home;
251 responseData["look_at"] = this.lookAt;
252 responseData["message"] = this.welcomeMessage;
253 responseData["region_x"] = (Int32)this.RegionX * 256;
254 responseData["region_y"] = (Int32)this.RegionY * 256;
255
256 //responseData["inventory-lib-root"] = new ArrayList(); // todo
257 //responseData["buddy-list"] = new ArrayList(); // todo
258
259 responseData["login"] = "true";
260 this.xmlRpcResponse.Value = responseData;
261
262 return (this.xmlRpcResponse);
263 }
264 catch (Exception e)
265 {
266 MainLog.Instance.WriteLine(
267 LogPriority.LOW,
268 "LoginResponse: Error creating XML-RPC Response: " + e.Message
269 );
270 return (this.GenerateFailureResponse("Internal Error", "Error generating Login Response", "false"));
271
272 }
273
274 } // ToXmlRpcResponse
275
276 public void SetEventCategories(string category, string value)
277 {
278 this.eventCategoriesHash[category] = value;
279 } // SetEventCategories
280
281 public void AddToUIConfig(string itemName, string item)
282 {
283 this.uiConfigHash[itemName] = item;
284 } // SetUIConfig
285
286 public void AddClassifiedCategory(Int32 ID, string categoryName)
287 {
288 this.classifiedCategoriesHash["category_name"] = categoryName;
289 this.classifiedCategoriesHash["category_id"] = ID;
290 this.classifiedCategories.Add(this.classifiedCategoriesHash);
291 // this.classifiedCategoriesHash.Clear();
292 } // SetClassifiedCategory
293
294 #region Properties
295 public string Login
296 {
297 get
298 {
299 return this.login;
300 }
301 set
302 {
303 this.login = value;
304 }
305 } // Login
306
307 public string DST
308 {
309 get
310 {
311 return this.dst;
312 }
313 set
314 {
315 this.dst = value;
316 }
317 } // DST
318
319 public string StipendSinceLogin
320 {
321 get
322 {
323 return this.stipendSinceLogin;
324 }
325 set
326 {
327 this.stipendSinceLogin = value;
328 }
329 } // StipendSinceLogin
330
331 public string Gendered
332 {
333 get
334 {
335 return this.gendered;
336 }
337 set
338 {
339 this.gendered = value;
340 }
341 } // Gendered
342
343 public string EverLoggedIn
344 {
345 get
346 {
347 return this.everLoggedIn;
348 }
349 set
350 {
351 this.everLoggedIn = value;
352 }
353 } // EverLoggedIn
354
355 public int SimPort
356 {
357 get
358 {
359 return this.simPort;
360 }
361 set
362 {
363 this.simPort = value;
364 }
365 } // SimPort
366
367 public string SimAddress
368 {
369 get
370 {
371 return this.simAddress;
372 }
373 set
374 {
375 this.simAddress = value;
376 }
377 } // SimAddress
378
379 public LLUUID AgentID
380 {
381 get
382 {
383 return this.agentID;
384 }
385 set
386 {
387 this.agentID = value;
388 }
389 } // AgentID
390
391 public LLUUID SessionID
392 {
393 get
394 {
395 return this.sessionID;
396 }
397 set
398 {
399 this.sessionID = value;
400 }
401 } // SessionID
402
403 public LLUUID SecureSessionID
404 {
405 get
406 {
407 return this.secureSessionID;
408 }
409 set
410 {
411 this.secureSessionID = value;
412 }
413 } // SecureSessionID
414
415 public Int32 CircuitCode
416 {
417 get
418 {
419 return this.circuitCode;
420 }
421 set
422 {
423 this.circuitCode = value;
424 }
425 } // CircuitCode
426
427 public uint RegionX
428 {
429 get
430 {
431 return this.regionX;
432 }
433 set
434 {
435 this.regionX = value;
436 }
437 } // RegionX
438
439 public uint RegionY
440 {
441 get
442 {
443 return this.regionY;
444 }
445 set
446 {
447 this.regionY = value;
448 }
449 } // RegionY
450
451 public string SunTexture
452 {
453 get
454 {
455 return this.sunTexture;
456 }
457 set
458 {
459 this.sunTexture = value;
460 }
461 } // SunTexture
462
463 public string CloudTexture
464 {
465 get
466 {
467 return this.cloudTexture;
468 }
469 set
470 {
471 this.cloudTexture = value;
472 }
473 } // CloudTexture
474
475 public string MoonTexture
476 {
477 get
478 {
479 return this.moonTexture;
480 }
481 set
482 {
483 this.moonTexture = value;
484 }
485 } // MoonTexture
486
487 public string Firstname
488 {
489 get
490 {
491 return this.firstname;
492 }
493 set
494 {
495 this.firstname = value;
496 }
497 } // Firstname
498
499 public string Lastname
500 {
501 get
502 {
503 return this.lastname;
504 }
505 set
506 {
507 this.lastname = value;
508 }
509 } // Lastname
510
511 public string AgentAccess
512 {
513 get
514 {
515 return this.agentAccess;
516 }
517 set
518 {
519 this.agentAccess = value;
520 }
521 }
522
523 public string StartLocation
524 {
525 get
526 {
527 return this.startLocation;
528 }
529 set
530 {
531 this.startLocation = value;
532 }
533 } // StartLocation
534
535 public string LookAt
536 {
537 get
538 {
539 return this.lookAt;
540 }
541 set
542 {
543 this.lookAt = value;
544 }
545 }
546
547 public string SeedCapability
548 {
549 get
550 {
551 return this.seedCapability;
552 }
553 set
554 {
555 this.seedCapability = value;
556 }
557 } // SeedCapability
558
559 public string ErrorReason
560 {
561 get
562 {
563 return this.errorReason;
564 }
565 set
566 {
567 this.errorReason = value;
568 }
569 } // ErrorReason
570
571 public string ErrorMessage
572 {
573 get
574 {
575 return this.errorMessage;
576 }
577 set
578 {
579 this.errorMessage = value;
580 }
581 } // ErrorMessage
582
583 public ArrayList InventoryRoot
584 {
585 get
586 {
587 return this.inventoryRoot;
588 }
589 set
590 {
591 this.inventoryRoot = value;
592 }
593 }
594
595 public ArrayList InventorySkeleton
596 {
597 get
598 {
599 return this.agentInventory;
600 }
601 set
602 {
603 this.agentInventory = value;
604 }
605 }
606
607 public string Home
608 {
609 get
610 {
611 return this.home;
612 }
613 set
614 {
615 this.home = value;
616 }
617 }
618
619 public string Message
620 {
621 get
622 {
623 return this.welcomeMessage;
624 }
625 set
626 {
627 this.welcomeMessage = value;
628 }
629 }
630 #endregion
631
632
633 public class UserInfo
634 {
635 public string firstname;
636 public string lastname;
637 public ulong homeregionhandle;
638 public LLVector3 homepos;
639 public LLVector3 homelookat;
640 }
641 }
642}
643
diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs
new file mode 100644
index 0000000..df6fbb2
--- /dev/null
+++ b/OpenSim/Framework/UserManager/UserManagerBase.cs
@@ -0,0 +1,630 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using System.Security.Cryptography;
33using libsecondlife;
34using Nwc.XmlRpc;
35using OpenSim.Framework.Console;
36using OpenSim.Framework.Data;
37using OpenSim.Framework.Interfaces;
38using OpenSim.Framework.Inventory;
39using OpenSim.Framework.Utilities;
40
41namespace OpenSim.Framework.UserManagement
42{
43 public abstract class UserManagerBase
44 {
45 public UserConfig _config;
46 Dictionary<string, IUserData> _plugins = new Dictionary<string, IUserData>();
47
48 /// <summary>
49 /// Adds a new user server plugin - user servers will be requested in the order they were loaded.
50 /// </summary>
51 /// <param name="FileName">The filename to the user server plugin DLL</param>
52 public void AddPlugin(string FileName)
53 {
54 MainLog.Instance.Verbose( "Userstorage: Attempting to load " + FileName);
55 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
56
57 MainLog.Instance.Verbose( "Userstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
58 foreach (Type pluginType in pluginAssembly.GetTypes())
59 {
60 if (!pluginType.IsAbstract)
61 {
62 Type typeInterface = pluginType.GetInterface("IUserData", true);
63
64 if (typeInterface != null)
65 {
66 IUserData plug = (IUserData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
67 plug.Initialise();
68 this._plugins.Add(plug.getName(), plug);
69 MainLog.Instance.Verbose( "Userstorage: Added IUserData Interface");
70 }
71
72 typeInterface = null;
73 }
74 }
75
76 pluginAssembly = null;
77 }
78
79 #region Get UserProfile
80 /// <summary>
81 /// Loads a user profile from a database by UUID
82 /// </summary>
83 /// <param name="uuid">The target UUID</param>
84 /// <returns>A user profile</returns>
85 public UserProfileData getUserProfile(LLUUID uuid)
86 {
87 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
88 {
89 try
90 {
91 UserProfileData profile = plugin.Value.getUserByUUID(uuid);
92 profile.currentAgent = getUserAgent(profile.UUID);
93 return profile;
94 }
95 catch (Exception e)
96 {
97 MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
98 }
99 }
100
101 return null;
102 }
103
104
105 /// <summary>
106 /// Loads a user profile by name
107 /// </summary>
108 /// <param name="name">The target name</param>
109 /// <returns>A user profile</returns>
110 public UserProfileData getUserProfile(string name)
111 {
112 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
113 {
114 try
115 {
116 UserProfileData profile = plugin.Value.getUserByName(name);
117 profile.currentAgent = getUserAgent(profile.UUID);
118 return profile;
119 }
120 catch (Exception e)
121 {
122 MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
123 }
124 }
125
126 return null;
127 }
128
129 /// <summary>
130 /// Loads a user profile by name
131 /// </summary>
132 /// <param name="fname">First name</param>
133 /// <param name="lname">Last name</param>
134 /// <returns>A user profile</returns>
135 public UserProfileData getUserProfile(string fname, string lname)
136 {
137 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
138 {
139 try
140 {
141 UserProfileData profile = plugin.Value.getUserByName(fname,lname);
142
143 profile.currentAgent = getUserAgent(profile.UUID);
144
145 return profile;
146 }
147 catch (Exception e)
148 {
149 MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
150 }
151 }
152
153 return null;
154 }
155 #endregion
156
157 #region Get UserAgent
158 /// <summary>
159 /// Loads a user agent by uuid (not called directly)
160 /// </summary>
161 /// <param name="uuid">The agents UUID</param>
162 /// <returns>Agent profiles</returns>
163 public UserAgentData getUserAgent(LLUUID uuid)
164 {
165 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
166 {
167 try
168 {
169 return plugin.Value.getAgentByUUID(uuid);
170 }
171 catch (Exception e)
172 {
173 MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
174 }
175 }
176
177 return null;
178 }
179
180 /// <summary>
181 /// Loads a user agent by name (not called directly)
182 /// </summary>
183 /// <param name="name">The agents name</param>
184 /// <returns>A user agent</returns>
185 public UserAgentData getUserAgent(string name)
186 {
187 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
188 {
189 try
190 {
191 return plugin.Value.getAgentByName(name);
192 }
193 catch (Exception e)
194 {
195 MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
196 }
197 }
198
199 return null;
200 }
201
202 /// <summary>
203 /// Loads a user agent by name (not called directly)
204 /// </summary>
205 /// <param name="fname">The agents firstname</param>
206 /// <param name="lname">The agents lastname</param>
207 /// <returns>A user agent</returns>
208 public UserAgentData getUserAgent(string fname, string lname)
209 {
210 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
211 {
212 try
213 {
214 return plugin.Value.getAgentByName(fname,lname);
215 }
216 catch (Exception e)
217 {
218 MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
219 }
220 }
221
222 return null;
223 }
224
225 #endregion
226
227 #region CreateAgent
228 /// <summary>
229 /// Creates and initialises a new user agent - make sure to use CommitAgent when done to submit to the DB
230 /// </summary>
231 /// <param name="profile">The users profile</param>
232 /// <param name="request">The users loginrequest</param>
233 public void CreateAgent(UserProfileData profile, XmlRpcRequest request)
234 {
235 Hashtable requestData = (Hashtable)request.Params[0];
236
237 UserAgentData agent = new UserAgentData();
238
239 // User connection
240 agent.agentOnline = true;
241
242 // Generate sessions
243 RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
244 byte[] randDataS = new byte[16];
245 byte[] randDataSS = new byte[16];
246 rand.GetBytes(randDataS);
247 rand.GetBytes(randDataSS);
248
249 agent.secureSessionID = new LLUUID(randDataSS, 0);
250 agent.sessionID = new LLUUID(randDataS, 0);
251
252 // Profile UUID
253 agent.UUID = profile.UUID;
254
255 // Current position (from Home)
256 agent.currentHandle = profile.homeRegion;
257 agent.currentPos = profile.homeLocation;
258
259 // If user specified additional start, use that
260 if (requestData.ContainsKey("start"))
261 {
262 string startLoc = ((string)requestData["start"]).Trim();
263 if (!(startLoc == "last" || startLoc == "home"))
264 {
265 // Format: uri:Ahern&162&213&34
266 try
267 {
268 string[] parts = startLoc.Remove(0, 4).Split('&');
269 string region = parts[0];
270
271 ////////////////////////////////////////////////////
272 //SimProfile SimInfo = new SimProfile();
273 //SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey);
274 }
275 catch (Exception)
276 {
277
278 }
279 }
280 }
281
282 // What time did the user login?
283 agent.loginTime = Util.UnixTimeSinceEpoch();
284 agent.logoutTime = 0;
285
286 // Current location
287 agent.regionID = new LLUUID(); // Fill in later
288 agent.currentRegion = new LLUUID(); // Fill in later
289
290 profile.currentAgent = agent;
291 }
292
293 /// <summary>
294 /// Saves a target agent to the database
295 /// </summary>
296 /// <param name="profile">The users profile</param>
297 /// <returns>Successful?</returns>
298 public bool CommitAgent(ref UserProfileData profile)
299 {
300 // Saves the agent to database
301 return true;
302 }
303
304 #endregion
305
306 /// <summary>
307 /// Checks a user against it's password hash
308 /// </summary>
309 /// <param name="profile">The users profile</param>
310 /// <param name="password">The supplied password</param>
311 /// <returns>Authenticated?</returns>
312 public virtual bool AuthenticateUser(UserProfileData profile, string password)
313 {
314 MainLog.Instance.Verbose(
315 "Authenticating " + profile.username + " " + profile.surname);
316
317 password = password.Remove(0, 3); //remove $1$
318
319 string s = Util.Md5Hash(password + ":" + profile.passwordSalt);
320
321 return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase);
322 }
323
324 #region Xml Response
325
326 /// <summary>
327 ///
328 /// </summary>
329 /// <param name="firstname"></param>
330 /// <param name="lastname"></param>
331 /// <returns></returns>
332 public virtual UserProfileData GetTheUser(string firstname, string lastname)
333 {
334 return getUserProfile(firstname, lastname);
335 }
336
337 /// <summary>
338 ///
339 /// </summary>
340 /// <returns></returns>
341 public virtual string GetMessage()
342 {
343 return _config.DefaultStartupMsg;
344 }
345
346 /// <summary>
347 /// Customises the login response and fills in missing values.
348 /// </summary>
349 /// <param name="response">The existing response</param>
350 /// <param name="theUser">The user profile</param>
351 public abstract void CustomiseResponse( LoginResponse response, UserProfileData theUser);
352
353 /// <summary>
354 /// Main user login function
355 /// </summary>
356 /// <param name="request">The XMLRPC request</param>
357 /// <returns>The response to send</returns>
358 public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
359 {
360
361 System.Console.WriteLine("Attempting login now...");
362 XmlRpcResponse response = new XmlRpcResponse();
363 Hashtable requestData = (Hashtable)request.Params[0];
364
365 bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd"));
366 bool GoodLogin = false;
367 string firstname = "";
368 string lastname = "";
369 string passwd = "";
370
371 UserProfileData userProfile;
372 LoginResponse logResponse = new LoginResponse();
373
374 if (GoodXML)
375 {
376 firstname = (string)requestData["first"];
377 lastname = (string)requestData["last"];
378 passwd = (string)requestData["passwd"];
379
380 userProfile = GetTheUser(firstname, lastname);
381 if (userProfile == null)
382 return logResponse.CreateLoginFailedResponse();
383
384 GoodLogin = AuthenticateUser(userProfile, passwd);
385 }
386 else
387 {
388 return logResponse.CreateGridErrorResponse();
389 }
390
391 if (!GoodLogin)
392 {
393 return logResponse.CreateLoginFailedResponse();
394 }
395 else
396 {
397 // If we already have a session...
398 if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline)
399 {
400 // Reject the login
401 return logResponse.CreateAlreadyLoggedInResponse();
402 }
403 // Otherwise...
404 // Create a new agent session
405 CreateAgent( userProfile, request);
406
407 try
408 {
409
410 LLUUID AgentID = userProfile.UUID;
411
412 // Inventory Library Section
413 ArrayList AgentInventoryArray = new ArrayList();
414 Hashtable TempHash;
415
416 AgentInventory Library = new AgentInventory();
417 Library.CreateRootFolder(AgentID, true);
418
419 foreach (InventoryFolder InvFolder in Library.InventoryFolders.Values)
420 {
421 TempHash = new Hashtable();
422 TempHash["name"] = InvFolder.FolderName;
423 TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
424 TempHash["version"] = (Int32)InvFolder.Version;
425 TempHash["type_default"] = (Int32)InvFolder.DefaultType;
426 TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
427 AgentInventoryArray.Add(TempHash);
428 }
429
430 Hashtable InventoryRootHash = new Hashtable();
431 InventoryRootHash["folder_id"] = Library.InventoryRoot.FolderID.ToStringHyphenated();
432 ArrayList InventoryRoot = new ArrayList();
433 InventoryRoot.Add(InventoryRootHash);
434
435 // Circuit Code
436 uint circode = (uint)(Util.RandomClass.Next());
437
438 logResponse.Lastname = userProfile.surname;
439 logResponse.Firstname = userProfile.username;
440 logResponse.AgentID = AgentID.ToStringHyphenated();
441 logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated();
442 logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated();
443 logResponse.InventoryRoot = InventoryRoot;
444 logResponse.InventorySkeleton = AgentInventoryArray;
445 logResponse.CircuitCode = (Int32)circode;
446 //logResponse.RegionX = 0; //overwritten
447 //logResponse.RegionY = 0; //overwritten
448 logResponse.Home = "!!null temporary value {home}!!"; // Overwritten
449 //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n";
450 //logResponse.SimAddress = "127.0.0.1"; //overwritten
451 //logResponse.SimPort = 0; //overwritten
452 logResponse.Message = this.GetMessage();
453
454 try
455 {
456 this.CustomiseResponse( logResponse, userProfile);
457 }
458 catch (Exception e)
459 {
460 System.Console.WriteLine(e.ToString());
461 return logResponse.CreateDeadRegionResponse();
462 //return logResponse.ToXmlRpcResponse();
463 }
464 CommitAgent(ref userProfile);
465 return logResponse.ToXmlRpcResponse();
466
467 }
468
469 catch (Exception E)
470 {
471 System.Console.WriteLine(E.ToString());
472 }
473 //}
474 }
475 return response;
476
477 }
478
479 #endregion
480
481 /// <summary>
482 /// Deletes an active agent session
483 /// </summary>
484 /// <param name="request">The request</param>
485 /// <param name="path">The path (eg /bork/narf/test)</param>
486 /// <param name="param">Parameters sent</param>
487 /// <returns>Success "OK" else error</returns>
488 public string RestDeleteUserSessionMethod(string request, string path, string param)
489 {
490 // TODO! Important!
491
492 return "OK";
493 }
494
495 /// <summary>
496 ///
497 /// </summary>
498 /// <param name="user"></param>
499 public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY)
500 {
501 UserProfileData user = new UserProfileData();
502 user.homeLocation = new LLVector3(128, 128, 100);
503 user.UUID = LLUUID.Random();
504 user.username = firstName;
505 user.surname = lastName;
506 user.passwordHash = pass;
507 user.passwordSalt = "";
508 user.created = Util.UnixTimeSinceEpoch();
509 user.homeLookAt = new LLVector3(100, 100, 100);
510 user.homeRegion = Util.UIntsToLong((regX * 256), (regY * 256));
511
512 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
513 {
514 try
515 {
516 plugin.Value.addNewUserProfile(user);
517
518 }
519 catch (Exception e)
520 {
521 MainLog.Instance.Verbose("Unable to add user via " + plugin.Key + "(" + e.ToString() + ")");
522 }
523 }
524 }
525
526 /// <summary>
527 /// Returns an error message that the user could not be found in the database
528 /// </summary>
529 /// <returns>XML string consisting of a error element containing individual error(s)</returns>
530 public XmlRpcResponse CreateUnknownUserErrorResponse()
531 {
532 XmlRpcResponse response = new XmlRpcResponse();
533 Hashtable responseData = new Hashtable();
534 responseData["error_type"] = "unknown_user";
535 responseData["error_desc"] = "The user requested is not in the database";
536
537 response.Value = responseData;
538 return response;
539 }
540
541 /// <summary>
542 /// Converts a user profile to an XML element which can be returned
543 /// </summary>
544 /// <param name="profile">The user profile</param>
545 /// <returns>A string containing an XML Document of the user profile</returns>
546 public XmlRpcResponse ProfileToXmlRPCResponse(UserProfileData profile)
547 {
548 XmlRpcResponse response = new XmlRpcResponse();
549 Hashtable responseData = new Hashtable();
550
551 // Account information
552 responseData["firstname"] = profile.username;
553 responseData["lastname"] = profile.surname;
554 responseData["uuid"] = profile.UUID.ToStringHyphenated();
555 // Server Information
556 responseData["server_inventory"] = profile.userInventoryURI;
557 responseData["server_asset"] = profile.userAssetURI;
558 // Profile Information
559 responseData["profile_about"] = profile.profileAboutText;
560 responseData["profile_firstlife_about"] = profile.profileFirstText;
561 responseData["profile_firstlife_image"] = profile.profileFirstImage.ToStringHyphenated();
562 responseData["profile_can_do"] = profile.profileCanDoMask.ToString();
563 responseData["profile_want_do"] = profile.profileWantDoMask.ToString();
564 responseData["profile_image"] = profile.profileImage.ToStringHyphenated();
565 responseData["profile_created"] = profile.created.ToString();
566 responseData["profile_lastlogin"] = profile.lastLogin.ToString();
567 // Home region information
568 responseData["home_coordinates_x"] = profile.homeLocation.X.ToString();
569 responseData["home_coordinates_y"] = profile.homeLocation.Y.ToString();
570 responseData["home_coordinates_z"] = profile.homeLocation.Z.ToString();
571
572 responseData["home_region"] = profile.homeRegion.ToString();
573
574 responseData["home_look_x"] = profile.homeLookAt.X.ToString();
575 responseData["home_look_y"] = profile.homeLookAt.Y.ToString();
576 responseData["home_look_z"] = profile.homeLookAt.Z.ToString();
577 response.Value = responseData;
578 return response;
579 }
580
581 #region XMLRPC User Methods
582 //should most likely move out of here and into the grid's userserver sub class
583 public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request)
584 {
585 XmlRpcResponse response = new XmlRpcResponse();
586 Hashtable requestData = (Hashtable)request.Params[0];
587 UserProfileData userProfile;
588
589 if (requestData.Contains("avatar_name"))
590 {
591 userProfile = getUserProfile((string)requestData["avatar_name"]);
592 if (userProfile == null)
593 {
594 return CreateUnknownUserErrorResponse();
595 }
596 }
597 else
598 {
599 return CreateUnknownUserErrorResponse();
600 }
601
602
603 return ProfileToXmlRPCResponse(userProfile);
604 }
605
606 public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request)
607 {
608 XmlRpcResponse response = new XmlRpcResponse();
609 Hashtable requestData = (Hashtable)request.Params[0];
610 UserProfileData userProfile;
611 if (requestData.Contains("avatar_uuid"))
612 {
613 userProfile = getUserProfile((LLUUID)requestData["avatar_uuid"]);
614 if (userProfile == null)
615 {
616 return CreateUnknownUserErrorResponse();
617 }
618 }
619 else
620 {
621 return CreateUnknownUserErrorResponse();
622 }
623
624
625 return ProfileToXmlRPCResponse(userProfile);
626 }
627 #endregion
628
629 }
630}