diff options
Diffstat (limited to '')
25 files changed, 4088 insertions, 0 deletions
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 | |||
29 | using System; | ||
30 | using libsecondlife; | ||
31 | |||
32 | namespace 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 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using Db4objects.Db4o; | ||
31 | using libsecondlife; | ||
32 | |||
33 | namespace 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 | */ | ||
28 | using System; | ||
29 | using libsecondlife; | ||
30 | |||
31 | namespace 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 @@ | |||
1 | using System.Reflection; | ||
2 | using 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 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using System.Security.Cryptography; | ||
32 | using System.Text; | ||
33 | using libsecondlife; | ||
34 | |||
35 | namespace 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 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using System.Data.SqlClient; | ||
32 | using libsecondlife; | ||
33 | |||
34 | namespace 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 @@ | |||
1 | using System.Reflection; | ||
2 | using 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 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using System.Security.Cryptography; | ||
32 | using System.Text; | ||
33 | using libsecondlife; | ||
34 | |||
35 | namespace 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 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using libsecondlife; | ||
32 | |||
33 | namespace 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 | */ | ||
28 | using System; | ||
29 | |||
30 | namespace 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 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using libsecondlife; | ||
32 | using MySql.Data.MySqlClient; | ||
33 | |||
34 | namespace 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 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using libsecondlife; | ||
32 | |||
33 | namespace 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 @@ | |||
1 | using System.Reflection; | ||
2 | using 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 @@ | |||
1 | using System.Reflection; | ||
2 | using 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 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using System.Security.Cryptography; | ||
32 | using System.Text; | ||
33 | using libsecondlife; | ||
34 | |||
35 | namespace 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 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using System.Data.SQLite; | ||
32 | using libsecondlife; | ||
33 | |||
34 | namespace 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 | */ | ||
28 | using libsecondlife; | ||
29 | |||
30 | namespace 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 | */ | ||
28 | namespace 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 | */ | ||
28 | using System.IO; | ||
29 | using 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 | |||
35 | namespace 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 | */ | ||
28 | using System.Collections.Generic; | ||
29 | using libsecondlife; | ||
30 | |||
31 | namespace 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 @@ | |||
1 | using System.Reflection; | ||
2 | using 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 | */ | ||
28 | using libsecondlife; | ||
29 | |||
30 | namespace 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 | */ | ||
28 | using libsecondlife; | ||
29 | using Nwc.XmlRpc; | ||
30 | |||
31 | using System; | ||
32 | using System.Collections; | ||
33 | |||
34 | namespace 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 | */ | ||
28 | using libsecondlife; | ||
29 | |||
30 | namespace 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 | */ | ||
28 | using System; | ||
29 | using libsecondlife; | ||
30 | |||
31 | namespace 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 | } | ||