diff options
author | Sean Dague | 2007-07-16 15:40:11 +0000 |
---|---|---|
committer | Sean Dague | 2007-07-16 15:40:11 +0000 |
commit | 2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6 (patch) | |
tree | e3f80ad51736cf17e856547b1bcf956010927434 /OpenSim/Framework/Data.MySQL | |
parent | *Trunk compiles now (diff) | |
download | opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.zip opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.gz opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.bz2 opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.xz |
changed to native line ending encoding
Diffstat (limited to 'OpenSim/Framework/Data.MySQL')
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLGridData.cs | 574 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs | 618 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLLogData.cs | 210 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLManager.cs | 1212 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLUserData.cs | 512 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs | 66 |
6 files changed, 1596 insertions, 1596 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs index ef643d2..09f5e83 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs | |||
@@ -1,287 +1,287 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Data; | 30 | using System.Data; |
31 | using System.Security.Cryptography; | 31 | using System.Security.Cryptography; |
32 | using System.Text; | 32 | using System.Text; |
33 | using libsecondlife; | 33 | using libsecondlife; |
34 | 34 | ||
35 | namespace OpenSim.Framework.Data.MySQL | 35 | namespace OpenSim.Framework.Data.MySQL |
36 | { | 36 | { |
37 | /// <summary> | 37 | /// <summary> |
38 | /// A MySQL Interface for the Grid Server | 38 | /// A MySQL Interface for the Grid Server |
39 | /// </summary> | 39 | /// </summary> |
40 | public class MySQLGridData : IGridData | 40 | public class MySQLGridData : IGridData |
41 | { | 41 | { |
42 | /// <summary> | 42 | /// <summary> |
43 | /// MySQL Database Manager | 43 | /// MySQL Database Manager |
44 | /// </summary> | 44 | /// </summary> |
45 | private MySQLManager database; | 45 | private MySQLManager database; |
46 | 46 | ||
47 | /// <summary> | 47 | /// <summary> |
48 | /// Initialises the Grid Interface | 48 | /// Initialises the Grid Interface |
49 | /// </summary> | 49 | /// </summary> |
50 | public void Initialise() | 50 | public void Initialise() |
51 | { | 51 | { |
52 | IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); | 52 | IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); |
53 | string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); | 53 | string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); |
54 | string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); | 54 | string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); |
55 | string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); | 55 | string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); |
56 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); | 56 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); |
57 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); | 57 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); |
58 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); | 58 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); |
59 | 59 | ||
60 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); | 60 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); |
61 | } | 61 | } |
62 | 62 | ||
63 | /// <summary> | 63 | /// <summary> |
64 | /// Shuts down the grid interface | 64 | /// Shuts down the grid interface |
65 | /// </summary> | 65 | /// </summary> |
66 | public void Close() | 66 | public void Close() |
67 | { | 67 | { |
68 | database.Close(); | 68 | database.Close(); |
69 | } | 69 | } |
70 | 70 | ||
71 | /// <summary> | 71 | /// <summary> |
72 | /// Returns the plugin name | 72 | /// Returns the plugin name |
73 | /// </summary> | 73 | /// </summary> |
74 | /// <returns>Plugin name</returns> | 74 | /// <returns>Plugin name</returns> |
75 | public string getName() | 75 | public string getName() |
76 | { | 76 | { |
77 | return "MySql OpenGridData"; | 77 | return "MySql OpenGridData"; |
78 | } | 78 | } |
79 | 79 | ||
80 | /// <summary> | 80 | /// <summary> |
81 | /// Returns the plugin version | 81 | /// Returns the plugin version |
82 | /// </summary> | 82 | /// </summary> |
83 | /// <returns>Plugin version</returns> | 83 | /// <returns>Plugin version</returns> |
84 | public string getVersion() | 84 | public string getVersion() |
85 | { | 85 | { |
86 | return "0.1"; | 86 | return "0.1"; |
87 | } | 87 | } |
88 | 88 | ||
89 | /// <summary> | 89 | /// <summary> |
90 | /// Returns all the specified region profiles within coordates -- coordinates are inclusive | 90 | /// Returns all the specified region profiles within coordates -- coordinates are inclusive |
91 | /// </summary> | 91 | /// </summary> |
92 | /// <param name="xmin">Minimum X coordinate</param> | 92 | /// <param name="xmin">Minimum X coordinate</param> |
93 | /// <param name="ymin">Minimum Y coordinate</param> | 93 | /// <param name="ymin">Minimum Y coordinate</param> |
94 | /// <param name="xmax">Maximum X coordinate</param> | 94 | /// <param name="xmax">Maximum X coordinate</param> |
95 | /// <param name="ymax">Maximum Y coordinate</param> | 95 | /// <param name="ymax">Maximum Y coordinate</param> |
96 | /// <returns></returns> | 96 | /// <returns></returns> |
97 | public SimProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax) | 97 | public SimProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax) |
98 | { | 98 | { |
99 | try | 99 | try |
100 | { | 100 | { |
101 | lock (database) | 101 | lock (database) |
102 | { | 102 | { |
103 | Dictionary<string, string> param = new Dictionary<string, string>(); | 103 | Dictionary<string, string> param = new Dictionary<string, string>(); |
104 | param["?xmin"] = xmin.ToString(); | 104 | param["?xmin"] = xmin.ToString(); |
105 | param["?ymin"] = ymin.ToString(); | 105 | param["?ymin"] = ymin.ToString(); |
106 | param["?xmax"] = xmax.ToString(); | 106 | param["?xmax"] = xmax.ToString(); |
107 | param["?ymax"] = ymax.ToString(); | 107 | param["?ymax"] = ymax.ToString(); |
108 | 108 | ||
109 | IDbCommand result = database.Query("SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", param); | 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(); | 110 | IDataReader reader = result.ExecuteReader(); |
111 | 111 | ||
112 | SimProfileData row; | 112 | SimProfileData row; |
113 | 113 | ||
114 | List<SimProfileData> rows = new List<SimProfileData>(); | 114 | List<SimProfileData> rows = new List<SimProfileData>(); |
115 | 115 | ||
116 | while ((row = database.readSimRow(reader)) != null) | 116 | while ((row = database.readSimRow(reader)) != null) |
117 | { | 117 | { |
118 | rows.Add(row); | 118 | rows.Add(row); |
119 | } | 119 | } |
120 | reader.Close(); | 120 | reader.Close(); |
121 | result.Dispose(); | 121 | result.Dispose(); |
122 | 122 | ||
123 | return rows.ToArray(); | 123 | return rows.ToArray(); |
124 | 124 | ||
125 | } | 125 | } |
126 | } | 126 | } |
127 | catch (Exception e) | 127 | catch (Exception e) |
128 | { | 128 | { |
129 | database.Reconnect(); | 129 | database.Reconnect(); |
130 | Console.WriteLine(e.ToString()); | 130 | Console.WriteLine(e.ToString()); |
131 | return null; | 131 | return null; |
132 | } | 132 | } |
133 | } | 133 | } |
134 | 134 | ||
135 | /// <summary> | 135 | /// <summary> |
136 | /// Returns a sim profile from it's location | 136 | /// Returns a sim profile from it's location |
137 | /// </summary> | 137 | /// </summary> |
138 | /// <param name="handle">Region location handle</param> | 138 | /// <param name="handle">Region location handle</param> |
139 | /// <returns>Sim profile</returns> | 139 | /// <returns>Sim profile</returns> |
140 | public SimProfileData GetProfileByHandle(ulong handle) | 140 | public SimProfileData GetProfileByHandle(ulong handle) |
141 | { | 141 | { |
142 | try | 142 | try |
143 | { | 143 | { |
144 | lock (database) | 144 | lock (database) |
145 | { | 145 | { |
146 | Dictionary<string, string> param = new Dictionary<string, string>(); | 146 | Dictionary<string, string> param = new Dictionary<string, string>(); |
147 | param["?handle"] = handle.ToString(); | 147 | param["?handle"] = handle.ToString(); |
148 | 148 | ||
149 | IDbCommand result = database.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param); | 149 | IDbCommand result = database.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param); |
150 | IDataReader reader = result.ExecuteReader(); | 150 | IDataReader reader = result.ExecuteReader(); |
151 | 151 | ||
152 | SimProfileData row = database.readSimRow(reader); | 152 | SimProfileData row = database.readSimRow(reader); |
153 | reader.Close(); | 153 | reader.Close(); |
154 | result.Dispose(); | 154 | result.Dispose(); |
155 | 155 | ||
156 | return row; | 156 | return row; |
157 | } | 157 | } |
158 | } | 158 | } |
159 | catch (Exception e) | 159 | catch (Exception e) |
160 | { | 160 | { |
161 | database.Reconnect(); | 161 | database.Reconnect(); |
162 | Console.WriteLine(e.ToString()); | 162 | Console.WriteLine(e.ToString()); |
163 | return null; | 163 | return null; |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | /// <summary> | 167 | /// <summary> |
168 | /// Returns a sim profile from it's UUID | 168 | /// Returns a sim profile from it's UUID |
169 | /// </summary> | 169 | /// </summary> |
170 | /// <param name="uuid">The region UUID</param> | 170 | /// <param name="uuid">The region UUID</param> |
171 | /// <returns>The sim profile</returns> | 171 | /// <returns>The sim profile</returns> |
172 | public SimProfileData GetProfileByLLUUID(LLUUID uuid) | 172 | public SimProfileData GetProfileByLLUUID(LLUUID uuid) |
173 | { | 173 | { |
174 | try | 174 | try |
175 | { | 175 | { |
176 | lock (database) | 176 | lock (database) |
177 | { | 177 | { |
178 | Dictionary<string, string> param = new Dictionary<string, string>(); | 178 | Dictionary<string, string> param = new Dictionary<string, string>(); |
179 | param["?uuid"] = uuid.ToStringHyphenated(); | 179 | param["?uuid"] = uuid.ToStringHyphenated(); |
180 | 180 | ||
181 | IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = ?uuid", param); | 181 | IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = ?uuid", param); |
182 | IDataReader reader = result.ExecuteReader(); | 182 | IDataReader reader = result.ExecuteReader(); |
183 | 183 | ||
184 | SimProfileData row = database.readSimRow(reader); | 184 | SimProfileData row = database.readSimRow(reader); |
185 | reader.Close(); | 185 | reader.Close(); |
186 | result.Dispose(); | 186 | result.Dispose(); |
187 | 187 | ||
188 | return row; | 188 | return row; |
189 | } | 189 | } |
190 | } | 190 | } |
191 | catch (Exception e) | 191 | catch (Exception e) |
192 | { | 192 | { |
193 | database.Reconnect(); | 193 | database.Reconnect(); |
194 | Console.WriteLine(e.ToString()); | 194 | Console.WriteLine(e.ToString()); |
195 | return null; | 195 | return null; |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
199 | /// <summary> | 199 | /// <summary> |
200 | /// Adds a new profile to the database | 200 | /// Adds a new profile to the database |
201 | /// </summary> | 201 | /// </summary> |
202 | /// <param name="profile">The profile to add</param> | 202 | /// <param name="profile">The profile to add</param> |
203 | /// <returns>Successful?</returns> | 203 | /// <returns>Successful?</returns> |
204 | public DataResponse AddProfile(SimProfileData profile) | 204 | public DataResponse AddProfile(SimProfileData profile) |
205 | { | 205 | { |
206 | lock (database) | 206 | lock (database) |
207 | { | 207 | { |
208 | if (database.insertRegion(profile)) | 208 | if (database.insertRegion(profile)) |
209 | { | 209 | { |
210 | return DataResponse.RESPONSE_OK; | 210 | return DataResponse.RESPONSE_OK; |
211 | } | 211 | } |
212 | else | 212 | else |
213 | { | 213 | { |
214 | return DataResponse.RESPONSE_ERROR; | 214 | return DataResponse.RESPONSE_ERROR; |
215 | } | 215 | } |
216 | } | 216 | } |
217 | } | 217 | } |
218 | 218 | ||
219 | /// <summary> | 219 | /// <summary> |
220 | /// DEPRECIATED. Attempts to authenticate a region by comparing a shared secret. | 220 | /// DEPRECIATED. Attempts to authenticate a region by comparing a shared secret. |
221 | /// </summary> | 221 | /// </summary> |
222 | /// <param name="uuid">The UUID of the challenger</param> | 222 | /// <param name="uuid">The UUID of the challenger</param> |
223 | /// <param name="handle">The attempted regionHandle of the challenger</param> | 223 | /// <param name="handle">The attempted regionHandle of the challenger</param> |
224 | /// <param name="authkey">The secret</param> | 224 | /// <param name="authkey">The secret</param> |
225 | /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns> | 225 | /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns> |
226 | public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey) | 226 | public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey) |
227 | { | 227 | { |
228 | bool throwHissyFit = false; // Should be true by 1.0 | 228 | bool throwHissyFit = false; // Should be true by 1.0 |
229 | 229 | ||
230 | if (throwHissyFit) | 230 | if (throwHissyFit) |
231 | throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential."); | 231 | throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential."); |
232 | 232 | ||
233 | SimProfileData data = GetProfileByLLUUID(uuid); | 233 | SimProfileData data = GetProfileByLLUUID(uuid); |
234 | 234 | ||
235 | return (handle == data.regionHandle && authkey == data.regionSecret); | 235 | return (handle == data.regionHandle && authkey == data.regionSecret); |
236 | } | 236 | } |
237 | 237 | ||
238 | /// <summary> | 238 | /// <summary> |
239 | /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region | 239 | /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region |
240 | /// </summary> | 240 | /// </summary> |
241 | /// <remarks>This requires a security audit.</remarks> | 241 | /// <remarks>This requires a security audit.</remarks> |
242 | /// <param name="uuid"></param> | 242 | /// <param name="uuid"></param> |
243 | /// <param name="handle"></param> | 243 | /// <param name="handle"></param> |
244 | /// <param name="authhash"></param> | 244 | /// <param name="authhash"></param> |
245 | /// <param name="challenge"></param> | 245 | /// <param name="challenge"></param> |
246 | /// <returns></returns> | 246 | /// <returns></returns> |
247 | public bool AuthenticateSim(LLUUID uuid, ulong handle, string authhash, string challenge) | 247 | public bool AuthenticateSim(LLUUID uuid, ulong handle, string authhash, string challenge) |
248 | { | 248 | { |
249 | SHA512Managed HashProvider = new SHA512Managed(); | 249 | SHA512Managed HashProvider = new SHA512Managed(); |
250 | ASCIIEncoding TextProvider = new ASCIIEncoding(); | 250 | ASCIIEncoding TextProvider = new ASCIIEncoding(); |
251 | 251 | ||
252 | byte[] stream = TextProvider.GetBytes(uuid.ToStringHyphenated() + ":" + handle.ToString() + ":" + challenge); | 252 | byte[] stream = TextProvider.GetBytes(uuid.ToStringHyphenated() + ":" + handle.ToString() + ":" + challenge); |
253 | byte[] hash = HashProvider.ComputeHash(stream); | 253 | byte[] hash = HashProvider.ComputeHash(stream); |
254 | 254 | ||
255 | return false; | 255 | return false; |
256 | } | 256 | } |
257 | 257 | ||
258 | public ReservationData GetReservationAtPoint(uint x, uint y) | 258 | public ReservationData GetReservationAtPoint(uint x, uint y) |
259 | { | 259 | { |
260 | try | 260 | try |
261 | { | 261 | { |
262 | lock (database) | 262 | lock (database) |
263 | { | 263 | { |
264 | Dictionary<string, string> param = new Dictionary<string, string>(); | 264 | Dictionary<string, string> param = new Dictionary<string, string>(); |
265 | param["?x"] = x.ToString(); | 265 | param["?x"] = x.ToString(); |
266 | param["?y"] = y.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); | 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(); | 268 | IDataReader reader = result.ExecuteReader(); |
269 | 269 | ||
270 | ReservationData row = database.readReservationRow(reader); | 270 | ReservationData row = database.readReservationRow(reader); |
271 | reader.Close(); | 271 | reader.Close(); |
272 | result.Dispose(); | 272 | result.Dispose(); |
273 | 273 | ||
274 | return row; | 274 | return row; |
275 | } | 275 | } |
276 | } | 276 | } |
277 | catch (Exception e) | 277 | catch (Exception e) |
278 | { | 278 | { |
279 | database.Reconnect(); | 279 | database.Reconnect(); |
280 | Console.WriteLine(e.ToString()); | 280 | Console.WriteLine(e.ToString()); |
281 | return null; | 281 | return null; |
282 | } | 282 | } |
283 | } | 283 | } |
284 | } | 284 | } |
285 | 285 | ||
286 | 286 | ||
287 | } | 287 | } |
diff --git a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs index 790759a..d32db1b 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs | |||
@@ -1,309 +1,309 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Data; | 30 | using System.Data; |
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | 32 | ||
33 | namespace OpenSim.Framework.Data.MySQL | 33 | namespace OpenSim.Framework.Data.MySQL |
34 | { | 34 | { |
35 | /// <summary> | 35 | /// <summary> |
36 | /// A MySQL interface for the inventory server | 36 | /// A MySQL interface for the inventory server |
37 | /// </summary> | 37 | /// </summary> |
38 | class MySQLInventoryData : IInventoryData | 38 | class MySQLInventoryData : IInventoryData |
39 | { | 39 | { |
40 | /// <summary> | 40 | /// <summary> |
41 | /// The database manager | 41 | /// The database manager |
42 | /// </summary> | 42 | /// </summary> |
43 | public MySQLManager database; | 43 | public MySQLManager database; |
44 | 44 | ||
45 | /// <summary> | 45 | /// <summary> |
46 | /// Loads and initialises this database plugin | 46 | /// Loads and initialises this database plugin |
47 | /// </summary> | 47 | /// </summary> |
48 | public void Initialise() | 48 | public void Initialise() |
49 | { | 49 | { |
50 | IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); | 50 | IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); |
51 | string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); | 51 | string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); |
52 | string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); | 52 | string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); |
53 | string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); | 53 | string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); |
54 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); | 54 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); |
55 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); | 55 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); |
56 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); | 56 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); |
57 | 57 | ||
58 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); | 58 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); |
59 | } | 59 | } |
60 | 60 | ||
61 | /// <summary> | 61 | /// <summary> |
62 | /// The name of this DB provider | 62 | /// The name of this DB provider |
63 | /// </summary> | 63 | /// </summary> |
64 | /// <returns>Name of DB provider</returns> | 64 | /// <returns>Name of DB provider</returns> |
65 | public string getName() | 65 | public string getName() |
66 | { | 66 | { |
67 | return "MySQL Inventory Data Interface"; | 67 | return "MySQL Inventory Data Interface"; |
68 | } | 68 | } |
69 | 69 | ||
70 | /// <summary> | 70 | /// <summary> |
71 | /// Closes this DB provider | 71 | /// Closes this DB provider |
72 | /// </summary> | 72 | /// </summary> |
73 | public void Close() | 73 | public void Close() |
74 | { | 74 | { |
75 | // Do nothing. | 75 | // Do nothing. |
76 | } | 76 | } |
77 | 77 | ||
78 | /// <summary> | 78 | /// <summary> |
79 | /// Returns the version of this DB provider | 79 | /// Returns the version of this DB provider |
80 | /// </summary> | 80 | /// </summary> |
81 | /// <returns>A string containing the DB provider</returns> | 81 | /// <returns>A string containing the DB provider</returns> |
82 | public string getVersion() | 82 | public string getVersion() |
83 | { | 83 | { |
84 | return "0.1"; | 84 | return "0.1"; |
85 | } | 85 | } |
86 | 86 | ||
87 | /// <summary> | 87 | /// <summary> |
88 | /// Returns a list of items in a specified folder | 88 | /// Returns a list of items in a specified folder |
89 | /// </summary> | 89 | /// </summary> |
90 | /// <param name="folderID">The folder to search</param> | 90 | /// <param name="folderID">The folder to search</param> |
91 | /// <returns>A list containing inventory items</returns> | 91 | /// <returns>A list containing inventory items</returns> |
92 | public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID) | 92 | public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID) |
93 | { | 93 | { |
94 | try | 94 | try |
95 | { | 95 | { |
96 | lock (database) | 96 | lock (database) |
97 | { | 97 | { |
98 | Dictionary<string, string> param = new Dictionary<string, string>(); | 98 | Dictionary<string, string> param = new Dictionary<string, string>(); |
99 | param["?uuid"] = folderID.ToStringHyphenated(); | 99 | param["?uuid"] = folderID.ToStringHyphenated(); |
100 | 100 | ||
101 | IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", param); | 101 | IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", param); |
102 | IDataReader reader = result.ExecuteReader(); | 102 | IDataReader reader = result.ExecuteReader(); |
103 | 103 | ||
104 | List<InventoryItemBase> items = database.readInventoryItems(reader); | 104 | List<InventoryItemBase> items = database.readInventoryItems(reader); |
105 | 105 | ||
106 | reader.Close(); | 106 | reader.Close(); |
107 | result.Dispose(); | 107 | result.Dispose(); |
108 | 108 | ||
109 | return items; | 109 | return items; |
110 | } | 110 | } |
111 | } | 111 | } |
112 | catch (Exception e) | 112 | catch (Exception e) |
113 | { | 113 | { |
114 | database.Reconnect(); | 114 | database.Reconnect(); |
115 | Console.WriteLine(e.ToString()); | 115 | Console.WriteLine(e.ToString()); |
116 | return null; | 116 | return null; |
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||
120 | /// <summary> | 120 | /// <summary> |
121 | /// Returns a list of the root folders within a users inventory | 121 | /// Returns a list of the root folders within a users inventory |
122 | /// </summary> | 122 | /// </summary> |
123 | /// <param name="user">The user whos inventory is to be searched</param> | 123 | /// <param name="user">The user whos inventory is to be searched</param> |
124 | /// <returns>A list of folder objects</returns> | 124 | /// <returns>A list of folder objects</returns> |
125 | public List<InventoryFolderBase> getUserRootFolders(LLUUID user) | 125 | public List<InventoryFolderBase> getUserRootFolders(LLUUID user) |
126 | { | 126 | { |
127 | try | 127 | try |
128 | { | 128 | { |
129 | lock (database) | 129 | lock (database) |
130 | { | 130 | { |
131 | Dictionary<string, string> param = new Dictionary<string, string>(); | 131 | Dictionary<string, string> param = new Dictionary<string, string>(); |
132 | param["?uuid"] = user.ToStringHyphenated(); | 132 | param["?uuid"] = user.ToStringHyphenated(); |
133 | param["?zero"] = LLUUID.Zero.ToStringHyphenated(); | 133 | param["?zero"] = LLUUID.Zero.ToStringHyphenated(); |
134 | 134 | ||
135 | IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", param); | 135 | IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", param); |
136 | IDataReader reader = result.ExecuteReader(); | 136 | IDataReader reader = result.ExecuteReader(); |
137 | 137 | ||
138 | List<InventoryFolderBase> items = database.readInventoryFolders(reader); | 138 | List<InventoryFolderBase> items = database.readInventoryFolders(reader); |
139 | 139 | ||
140 | reader.Close(); | 140 | reader.Close(); |
141 | result.Dispose(); | 141 | result.Dispose(); |
142 | 142 | ||
143 | return items; | 143 | return items; |
144 | } | 144 | } |
145 | } | 145 | } |
146 | catch (Exception e) | 146 | catch (Exception e) |
147 | { | 147 | { |
148 | database.Reconnect(); | 148 | database.Reconnect(); |
149 | Console.WriteLine(e.ToString()); | 149 | Console.WriteLine(e.ToString()); |
150 | return null; | 150 | return null; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | 153 | ||
154 | /// <summary> | 154 | /// <summary> |
155 | /// Returns a list of folders in a users inventory contained within the specified folder | 155 | /// Returns a list of folders in a users inventory contained within the specified folder |
156 | /// </summary> | 156 | /// </summary> |
157 | /// <param name="parentID">The folder to search</param> | 157 | /// <param name="parentID">The folder to search</param> |
158 | /// <returns>A list of inventory folders</returns> | 158 | /// <returns>A list of inventory folders</returns> |
159 | public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID) | 159 | public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID) |
160 | { | 160 | { |
161 | try | 161 | try |
162 | { | 162 | { |
163 | lock (database) | 163 | lock (database) |
164 | { | 164 | { |
165 | Dictionary<string, string> param = new Dictionary<string, string>(); | 165 | Dictionary<string, string> param = new Dictionary<string, string>(); |
166 | param["?uuid"] = parentID.ToStringHyphenated(); | 166 | param["?uuid"] = parentID.ToStringHyphenated(); |
167 | 167 | ||
168 | IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", param); | 168 | IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", param); |
169 | IDataReader reader = result.ExecuteReader(); | 169 | IDataReader reader = result.ExecuteReader(); |
170 | 170 | ||
171 | List<InventoryFolderBase> items = database.readInventoryFolders(reader); | 171 | List<InventoryFolderBase> items = database.readInventoryFolders(reader); |
172 | 172 | ||
173 | reader.Close(); | 173 | reader.Close(); |
174 | result.Dispose(); | 174 | result.Dispose(); |
175 | 175 | ||
176 | return items; | 176 | return items; |
177 | } | 177 | } |
178 | } | 178 | } |
179 | catch (Exception e) | 179 | catch (Exception e) |
180 | { | 180 | { |
181 | database.Reconnect(); | 181 | database.Reconnect(); |
182 | Console.WriteLine(e.ToString()); | 182 | Console.WriteLine(e.ToString()); |
183 | return null; | 183 | return null; |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | /// <summary> | 187 | /// <summary> |
188 | /// Returns a specified inventory item | 188 | /// Returns a specified inventory item |
189 | /// </summary> | 189 | /// </summary> |
190 | /// <param name="item">The item to return</param> | 190 | /// <param name="item">The item to return</param> |
191 | /// <returns>An inventory item</returns> | 191 | /// <returns>An inventory item</returns> |
192 | public InventoryItemBase getInventoryItem(LLUUID item) | 192 | public InventoryItemBase getInventoryItem(LLUUID item) |
193 | { | 193 | { |
194 | try | 194 | try |
195 | { | 195 | { |
196 | lock (database) | 196 | lock (database) |
197 | { | 197 | { |
198 | Dictionary<string, string> param = new Dictionary<string, string>(); | 198 | Dictionary<string, string> param = new Dictionary<string, string>(); |
199 | param["?uuid"] = item.ToStringHyphenated(); | 199 | param["?uuid"] = item.ToStringHyphenated(); |
200 | 200 | ||
201 | IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", param); | 201 | IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", param); |
202 | IDataReader reader = result.ExecuteReader(); | 202 | IDataReader reader = result.ExecuteReader(); |
203 | 203 | ||
204 | List<InventoryItemBase> items = database.readInventoryItems(reader); | 204 | List<InventoryItemBase> items = database.readInventoryItems(reader); |
205 | 205 | ||
206 | reader.Close(); | 206 | reader.Close(); |
207 | result.Dispose(); | 207 | result.Dispose(); |
208 | 208 | ||
209 | if (items.Count > 0) | 209 | if (items.Count > 0) |
210 | { | 210 | { |
211 | return items[0]; | 211 | return items[0]; |
212 | } | 212 | } |
213 | else | 213 | else |
214 | { | 214 | { |
215 | return null; | 215 | return null; |
216 | } | 216 | } |
217 | } | 217 | } |
218 | } | 218 | } |
219 | catch (Exception e) | 219 | catch (Exception e) |
220 | { | 220 | { |
221 | database.Reconnect(); | 221 | database.Reconnect(); |
222 | Console.WriteLine(e.ToString()); | 222 | Console.WriteLine(e.ToString()); |
223 | return null; | 223 | return null; |
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
227 | /// <summary> | 227 | /// <summary> |
228 | /// Returns a specified inventory folder | 228 | /// Returns a specified inventory folder |
229 | /// </summary> | 229 | /// </summary> |
230 | /// <param name="folder">The folder to return</param> | 230 | /// <param name="folder">The folder to return</param> |
231 | /// <returns>A folder class</returns> | 231 | /// <returns>A folder class</returns> |
232 | public InventoryFolderBase getInventoryFolder(LLUUID folder) | 232 | public InventoryFolderBase getInventoryFolder(LLUUID folder) |
233 | { | 233 | { |
234 | try | 234 | try |
235 | { | 235 | { |
236 | lock (database) | 236 | lock (database) |
237 | { | 237 | { |
238 | Dictionary<string, string> param = new Dictionary<string, string>(); | 238 | Dictionary<string, string> param = new Dictionary<string, string>(); |
239 | param["?uuid"] = folder.ToStringHyphenated(); | 239 | param["?uuid"] = folder.ToStringHyphenated(); |
240 | 240 | ||
241 | IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", param); | 241 | IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", param); |
242 | IDataReader reader = result.ExecuteReader(); | 242 | IDataReader reader = result.ExecuteReader(); |
243 | 243 | ||
244 | List<InventoryFolderBase> items = database.readInventoryFolders(reader); | 244 | List<InventoryFolderBase> items = database.readInventoryFolders(reader); |
245 | 245 | ||
246 | reader.Close(); | 246 | reader.Close(); |
247 | result.Dispose(); | 247 | result.Dispose(); |
248 | 248 | ||
249 | if (items.Count > 0) | 249 | if (items.Count > 0) |
250 | { | 250 | { |
251 | return items[0]; | 251 | return items[0]; |
252 | } | 252 | } |
253 | else | 253 | else |
254 | { | 254 | { |
255 | return null; | 255 | return null; |
256 | } | 256 | } |
257 | } | 257 | } |
258 | } | 258 | } |
259 | catch (Exception e) | 259 | catch (Exception e) |
260 | { | 260 | { |
261 | database.Reconnect(); | 261 | database.Reconnect(); |
262 | Console.WriteLine(e.ToString()); | 262 | Console.WriteLine(e.ToString()); |
263 | return null; | 263 | return null; |
264 | } | 264 | } |
265 | } | 265 | } |
266 | 266 | ||
267 | /// <summary> | 267 | /// <summary> |
268 | /// Adds a specified item to the database | 268 | /// Adds a specified item to the database |
269 | /// </summary> | 269 | /// </summary> |
270 | /// <param name="item">The inventory item</param> | 270 | /// <param name="item">The inventory item</param> |
271 | public void addInventoryItem(InventoryItemBase item) | 271 | public void addInventoryItem(InventoryItemBase item) |
272 | { | 272 | { |
273 | lock (database) | 273 | lock (database) |
274 | { | 274 | { |
275 | database.insertItem(item); | 275 | database.insertItem(item); |
276 | } | 276 | } |
277 | } | 277 | } |
278 | 278 | ||
279 | /// <summary> | 279 | /// <summary> |
280 | /// Updates the specified inventory item | 280 | /// Updates the specified inventory item |
281 | /// </summary> | 281 | /// </summary> |
282 | /// <param name="item">Inventory item to update</param> | 282 | /// <param name="item">Inventory item to update</param> |
283 | public void updateInventoryItem(InventoryItemBase item) | 283 | public void updateInventoryItem(InventoryItemBase item) |
284 | { | 284 | { |
285 | addInventoryItem(item); | 285 | addInventoryItem(item); |
286 | } | 286 | } |
287 | 287 | ||
288 | /// <summary> | 288 | /// <summary> |
289 | /// Creates a new inventory folder | 289 | /// Creates a new inventory folder |
290 | /// </summary> | 290 | /// </summary> |
291 | /// <param name="folder">Folder to create</param> | 291 | /// <param name="folder">Folder to create</param> |
292 | public void addInventoryFolder(InventoryFolderBase folder) | 292 | public void addInventoryFolder(InventoryFolderBase folder) |
293 | { | 293 | { |
294 | lock (database) | 294 | lock (database) |
295 | { | 295 | { |
296 | database.insertFolder(folder); | 296 | database.insertFolder(folder); |
297 | } | 297 | } |
298 | } | 298 | } |
299 | 299 | ||
300 | /// <summary> | 300 | /// <summary> |
301 | /// Updates an inventory folder | 301 | /// Updates an inventory folder |
302 | /// </summary> | 302 | /// </summary> |
303 | /// <param name="folder">Folder to update</param> | 303 | /// <param name="folder">Folder to update</param> |
304 | public void updateInventoryFolder(InventoryFolderBase folder) | 304 | public void updateInventoryFolder(InventoryFolderBase folder) |
305 | { | 305 | { |
306 | addInventoryFolder(folder); | 306 | addInventoryFolder(folder); |
307 | } | 307 | } |
308 | } | 308 | } |
309 | } | 309 | } |
diff --git a/OpenSim/Framework/Data.MySQL/MySQLLogData.cs b/OpenSim/Framework/Data.MySQL/MySQLLogData.cs index 38f9fd3..2ba9c3d 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLLogData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLLogData.cs | |||
@@ -1,105 +1,105 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | 29 | ||
30 | namespace OpenSim.Framework.Data.MySQL | 30 | namespace OpenSim.Framework.Data.MySQL |
31 | { | 31 | { |
32 | /// <summary> | 32 | /// <summary> |
33 | /// An interface to the log database for MySQL | 33 | /// An interface to the log database for MySQL |
34 | /// </summary> | 34 | /// </summary> |
35 | class MySQLLogData : ILogData | 35 | class MySQLLogData : ILogData |
36 | { | 36 | { |
37 | /// <summary> | 37 | /// <summary> |
38 | /// The database manager | 38 | /// The database manager |
39 | /// </summary> | 39 | /// </summary> |
40 | public MySQLManager database; | 40 | public MySQLManager database; |
41 | 41 | ||
42 | /// <summary> | 42 | /// <summary> |
43 | /// Artificial constructor called when the plugin is loaded | 43 | /// Artificial constructor called when the plugin is loaded |
44 | /// </summary> | 44 | /// </summary> |
45 | public void Initialise() | 45 | public void Initialise() |
46 | { | 46 | { |
47 | IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); | 47 | IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); |
48 | string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); | 48 | string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); |
49 | string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); | 49 | string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); |
50 | string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); | 50 | string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); |
51 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); | 51 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); |
52 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); | 52 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); |
53 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); | 53 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); |
54 | 54 | ||
55 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); | 55 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); |
56 | } | 56 | } |
57 | 57 | ||
58 | /// <summary> | 58 | /// <summary> |
59 | /// Saves a log item to the database | 59 | /// Saves a log item to the database |
60 | /// </summary> | 60 | /// </summary> |
61 | /// <param name="serverDaemon">The daemon triggering the event</param> | 61 | /// <param name="serverDaemon">The daemon triggering the event</param> |
62 | /// <param name="target">The target of the action (region / agent UUID, etc)</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> | 63 | /// <param name="methodCall">The method call where the problem occured</param> |
64 | /// <param name="arguments">The arguments passed to the method</param> | 64 | /// <param name="arguments">The arguments passed to the method</param> |
65 | /// <param name="priority">How critical is this?</param> | 65 | /// <param name="priority">How critical is this?</param> |
66 | /// <param name="logMessage">The message to log</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) | 67 | public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage) |
68 | { | 68 | { |
69 | try | 69 | try |
70 | { | 70 | { |
71 | database.insertLogRow(serverDaemon, target, methodCall, arguments, priority, logMessage); | 71 | database.insertLogRow(serverDaemon, target, methodCall, arguments, priority, logMessage); |
72 | } | 72 | } |
73 | catch | 73 | catch |
74 | { | 74 | { |
75 | database.Reconnect(); | 75 | database.Reconnect(); |
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
79 | /// <summary> | 79 | /// <summary> |
80 | /// Returns the name of this DB provider | 80 | /// Returns the name of this DB provider |
81 | /// </summary> | 81 | /// </summary> |
82 | /// <returns>A string containing the DB provider name</returns> | 82 | /// <returns>A string containing the DB provider name</returns> |
83 | public string getName() | 83 | public string getName() |
84 | { | 84 | { |
85 | return "MySQL Logdata Interface"; | 85 | return "MySQL Logdata Interface"; |
86 | } | 86 | } |
87 | 87 | ||
88 | /// <summary> | 88 | /// <summary> |
89 | /// Closes the database provider | 89 | /// Closes the database provider |
90 | /// </summary> | 90 | /// </summary> |
91 | public void Close() | 91 | public void Close() |
92 | { | 92 | { |
93 | // Do nothing. | 93 | // Do nothing. |
94 | } | 94 | } |
95 | 95 | ||
96 | /// <summary> | 96 | /// <summary> |
97 | /// Returns the version of this DB provider | 97 | /// Returns the version of this DB provider |
98 | /// </summary> | 98 | /// </summary> |
99 | /// <returns>A string containing the provider version</returns> | 99 | /// <returns>A string containing the provider version</returns> |
100 | public string getVersion() | 100 | public string getVersion() |
101 | { | 101 | { |
102 | return "0.1"; | 102 | return "0.1"; |
103 | } | 103 | } |
104 | } | 104 | } |
105 | } | 105 | } |
diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs index ab7f277..a5434c8 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs | |||
@@ -1,606 +1,606 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Data; | 30 | using System.Data; |
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | using MySql.Data.MySqlClient; | 32 | using MySql.Data.MySqlClient; |
33 | 33 | ||
34 | namespace OpenSim.Framework.Data.MySQL | 34 | namespace OpenSim.Framework.Data.MySQL |
35 | { | 35 | { |
36 | /// <summary> | 36 | /// <summary> |
37 | /// A MySQL Database manager | 37 | /// A MySQL Database manager |
38 | /// </summary> | 38 | /// </summary> |
39 | class MySQLManager | 39 | class MySQLManager |
40 | { | 40 | { |
41 | /// <summary> | 41 | /// <summary> |
42 | /// The database connection object | 42 | /// The database connection object |
43 | /// </summary> | 43 | /// </summary> |
44 | IDbConnection dbcon; | 44 | IDbConnection dbcon; |
45 | /// <summary> | 45 | /// <summary> |
46 | /// Connection string for ADO.net | 46 | /// Connection string for ADO.net |
47 | /// </summary> | 47 | /// </summary> |
48 | string connectionString; | 48 | string connectionString; |
49 | 49 | ||
50 | /// <summary> | 50 | /// <summary> |
51 | /// Initialises and creates a new MySQL connection and maintains it. | 51 | /// Initialises and creates a new MySQL connection and maintains it. |
52 | /// </summary> | 52 | /// </summary> |
53 | /// <param name="hostname">The MySQL server being connected to</param> | 53 | /// <param name="hostname">The MySQL server being connected to</param> |
54 | /// <param name="database">The name of the MySQL database being used</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> | 55 | /// <param name="username">The username logging into the database</param> |
56 | /// <param name="password">The password for the user logging in</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> | 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) | 58 | public MySQLManager(string hostname, string database, string username, string password, string cpooling, string port) |
59 | { | 59 | { |
60 | try | 60 | try |
61 | { | 61 | { |
62 | connectionString = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";"; | 62 | connectionString = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";"; |
63 | dbcon = new MySqlConnection(connectionString); | 63 | dbcon = new MySqlConnection(connectionString); |
64 | 64 | ||
65 | dbcon.Open(); | 65 | dbcon.Open(); |
66 | 66 | ||
67 | Console.WriteLine("MySQL connection established"); | 67 | Console.WriteLine("MySQL connection established"); |
68 | } | 68 | } |
69 | catch (Exception e) | 69 | catch (Exception e) |
70 | { | 70 | { |
71 | throw new Exception("Error initialising MySql Database: " + e.ToString()); | 71 | throw new Exception("Error initialising MySql Database: " + e.ToString()); |
72 | } | 72 | } |
73 | } | 73 | } |
74 | 74 | ||
75 | /// <summary> | 75 | /// <summary> |
76 | /// Shuts down the database connection | 76 | /// Shuts down the database connection |
77 | /// </summary> | 77 | /// </summary> |
78 | public void Close() | 78 | public void Close() |
79 | { | 79 | { |
80 | dbcon.Close(); | 80 | dbcon.Close(); |
81 | dbcon = null; | 81 | dbcon = null; |
82 | } | 82 | } |
83 | 83 | ||
84 | /// <summary> | 84 | /// <summary> |
85 | /// Reconnects to the database | 85 | /// Reconnects to the database |
86 | /// </summary> | 86 | /// </summary> |
87 | public void Reconnect() | 87 | public void Reconnect() |
88 | { | 88 | { |
89 | lock (dbcon) | 89 | lock (dbcon) |
90 | { | 90 | { |
91 | try | 91 | try |
92 | { | 92 | { |
93 | // Close the DB connection | 93 | // Close the DB connection |
94 | dbcon.Close(); | 94 | dbcon.Close(); |
95 | // Try reopen it | 95 | // Try reopen it |
96 | dbcon = new MySqlConnection(connectionString); | 96 | dbcon = new MySqlConnection(connectionString); |
97 | dbcon.Open(); | 97 | dbcon.Open(); |
98 | } | 98 | } |
99 | catch (Exception e) | 99 | catch (Exception e) |
100 | { | 100 | { |
101 | Console.WriteLine("Unable to reconnect to database " + e.ToString()); | 101 | Console.WriteLine("Unable to reconnect to database " + e.ToString()); |
102 | } | 102 | } |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | /// <summary> | 106 | /// <summary> |
107 | /// Runs a query with protection against SQL Injection by using parameterised input. | 107 | /// Runs a query with protection against SQL Injection by using parameterised input. |
108 | /// </summary> | 108 | /// </summary> |
109 | /// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param> | 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> | 110 | /// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param> |
111 | /// <returns>A MySQL DB Command</returns> | 111 | /// <returns>A MySQL DB Command</returns> |
112 | public IDbCommand Query(string sql, Dictionary<string, string> parameters) | 112 | public IDbCommand Query(string sql, Dictionary<string, string> parameters) |
113 | { | 113 | { |
114 | try | 114 | try |
115 | { | 115 | { |
116 | MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); | 116 | MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); |
117 | dbcommand.CommandText = sql; | 117 | dbcommand.CommandText = sql; |
118 | foreach (KeyValuePair<string, string> param in parameters) | 118 | foreach (KeyValuePair<string, string> param in parameters) |
119 | { | 119 | { |
120 | dbcommand.Parameters.Add(param.Key, param.Value); | 120 | dbcommand.Parameters.Add(param.Key, param.Value); |
121 | } | 121 | } |
122 | 122 | ||
123 | return (IDbCommand)dbcommand; | 123 | return (IDbCommand)dbcommand; |
124 | } | 124 | } |
125 | catch | 125 | catch |
126 | { | 126 | { |
127 | lock (dbcon) | 127 | lock (dbcon) |
128 | { | 128 | { |
129 | // Close the DB connection | 129 | // Close the DB connection |
130 | try | 130 | try |
131 | { | 131 | { |
132 | dbcon.Close(); | 132 | dbcon.Close(); |
133 | } | 133 | } |
134 | catch { } | 134 | catch { } |
135 | 135 | ||
136 | // Try reopen it | 136 | // Try reopen it |
137 | try | 137 | try |
138 | { | 138 | { |
139 | dbcon = new MySqlConnection(connectionString); | 139 | dbcon = new MySqlConnection(connectionString); |
140 | dbcon.Open(); | 140 | dbcon.Open(); |
141 | } | 141 | } |
142 | catch (Exception e) | 142 | catch (Exception e) |
143 | { | 143 | { |
144 | Console.WriteLine("Unable to reconnect to database " + e.ToString()); | 144 | Console.WriteLine("Unable to reconnect to database " + e.ToString()); |
145 | } | 145 | } |
146 | 146 | ||
147 | // Run the query again | 147 | // Run the query again |
148 | try | 148 | try |
149 | { | 149 | { |
150 | MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); | 150 | MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); |
151 | dbcommand.CommandText = sql; | 151 | dbcommand.CommandText = sql; |
152 | foreach (KeyValuePair<string, string> param in parameters) | 152 | foreach (KeyValuePair<string, string> param in parameters) |
153 | { | 153 | { |
154 | dbcommand.Parameters.Add(param.Key, param.Value); | 154 | dbcommand.Parameters.Add(param.Key, param.Value); |
155 | } | 155 | } |
156 | 156 | ||
157 | return (IDbCommand)dbcommand; | 157 | return (IDbCommand)dbcommand; |
158 | } | 158 | } |
159 | catch (Exception e) | 159 | catch (Exception e) |
160 | { | 160 | { |
161 | // Return null if it fails. | 161 | // Return null if it fails. |
162 | Console.WriteLine("Failed during Query generation: " + e.ToString()); | 162 | Console.WriteLine("Failed during Query generation: " + e.ToString()); |
163 | return null; | 163 | return null; |
164 | } | 164 | } |
165 | } | 165 | } |
166 | } | 166 | } |
167 | } | 167 | } |
168 | 168 | ||
169 | /// <summary> | 169 | /// <summary> |
170 | /// Reads a region row from a database reader | 170 | /// Reads a region row from a database reader |
171 | /// </summary> | 171 | /// </summary> |
172 | /// <param name="reader">An active database reader</param> | 172 | /// <param name="reader">An active database reader</param> |
173 | /// <returns>A region profile</returns> | 173 | /// <returns>A region profile</returns> |
174 | public SimProfileData readSimRow(IDataReader reader) | 174 | public SimProfileData readSimRow(IDataReader reader) |
175 | { | 175 | { |
176 | SimProfileData retval = new SimProfileData(); | 176 | SimProfileData retval = new SimProfileData(); |
177 | 177 | ||
178 | if (reader.Read()) | 178 | if (reader.Read()) |
179 | { | 179 | { |
180 | // Region Main | 180 | // Region Main |
181 | retval.regionHandle = Convert.ToUInt64(reader["regionHandle"].ToString()); | 181 | retval.regionHandle = Convert.ToUInt64(reader["regionHandle"].ToString()); |
182 | retval.regionName = (string)reader["regionName"]; | 182 | retval.regionName = (string)reader["regionName"]; |
183 | retval.UUID = new LLUUID((string)reader["uuid"]); | 183 | retval.UUID = new LLUUID((string)reader["uuid"]); |
184 | 184 | ||
185 | // Secrets | 185 | // Secrets |
186 | retval.regionRecvKey = (string)reader["regionRecvKey"]; | 186 | retval.regionRecvKey = (string)reader["regionRecvKey"]; |
187 | retval.regionSecret = (string)reader["regionSecret"]; | 187 | retval.regionSecret = (string)reader["regionSecret"]; |
188 | retval.regionSendKey = (string)reader["regionSendKey"]; | 188 | retval.regionSendKey = (string)reader["regionSendKey"]; |
189 | 189 | ||
190 | // Region Server | 190 | // Region Server |
191 | retval.regionDataURI = (string)reader["regionDataURI"]; | 191 | retval.regionDataURI = (string)reader["regionDataURI"]; |
192 | retval.regionOnline = false; // Needs to be pinged before this can be set. | 192 | retval.regionOnline = false; // Needs to be pinged before this can be set. |
193 | retval.serverIP = (string)reader["serverIP"]; | 193 | retval.serverIP = (string)reader["serverIP"]; |
194 | retval.serverPort = (uint)reader["serverPort"]; | 194 | retval.serverPort = (uint)reader["serverPort"]; |
195 | retval.serverURI = (string)reader["serverURI"]; | 195 | retval.serverURI = (string)reader["serverURI"]; |
196 | retval.httpPort = Convert.ToUInt32(reader["serverHttpPort"].ToString()); | 196 | retval.httpPort = Convert.ToUInt32(reader["serverHttpPort"].ToString()); |
197 | retval.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"].ToString()); | 197 | retval.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"].ToString()); |
198 | 198 | ||
199 | // Location | 199 | // Location |
200 | retval.regionLocX = Convert.ToUInt32(reader["locX"].ToString()); | 200 | retval.regionLocX = Convert.ToUInt32(reader["locX"].ToString()); |
201 | retval.regionLocY = Convert.ToUInt32(reader["locY"].ToString()); | 201 | retval.regionLocY = Convert.ToUInt32(reader["locY"].ToString()); |
202 | retval.regionLocZ = Convert.ToUInt32(reader["locZ"].ToString()); | 202 | retval.regionLocZ = Convert.ToUInt32(reader["locZ"].ToString()); |
203 | 203 | ||
204 | // Neighbours - 0 = No Override | 204 | // Neighbours - 0 = No Override |
205 | retval.regionEastOverrideHandle = Convert.ToUInt64(reader["eastOverrideHandle"].ToString()); | 205 | retval.regionEastOverrideHandle = Convert.ToUInt64(reader["eastOverrideHandle"].ToString()); |
206 | retval.regionWestOverrideHandle = Convert.ToUInt64(reader["westOverrideHandle"].ToString()); | 206 | retval.regionWestOverrideHandle = Convert.ToUInt64(reader["westOverrideHandle"].ToString()); |
207 | retval.regionSouthOverrideHandle = Convert.ToUInt64(reader["southOverrideHandle"].ToString()); | 207 | retval.regionSouthOverrideHandle = Convert.ToUInt64(reader["southOverrideHandle"].ToString()); |
208 | retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString()); | 208 | retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString()); |
209 | 209 | ||
210 | // Assets | 210 | // Assets |
211 | retval.regionAssetURI = (string)reader["regionAssetURI"]; | 211 | retval.regionAssetURI = (string)reader["regionAssetURI"]; |
212 | retval.regionAssetRecvKey = (string)reader["regionAssetRecvKey"]; | 212 | retval.regionAssetRecvKey = (string)reader["regionAssetRecvKey"]; |
213 | retval.regionAssetSendKey = (string)reader["regionAssetSendKey"]; | 213 | retval.regionAssetSendKey = (string)reader["regionAssetSendKey"]; |
214 | 214 | ||
215 | // Userserver | 215 | // Userserver |
216 | retval.regionUserURI = (string)reader["regionUserURI"]; | 216 | retval.regionUserURI = (string)reader["regionUserURI"]; |
217 | retval.regionUserRecvKey = (string)reader["regionUserRecvKey"]; | 217 | retval.regionUserRecvKey = (string)reader["regionUserRecvKey"]; |
218 | retval.regionUserSendKey = (string)reader["regionUserSendKey"]; | 218 | retval.regionUserSendKey = (string)reader["regionUserSendKey"]; |
219 | 219 | ||
220 | // World Map Addition | 220 | // World Map Addition |
221 | string tempRegionMap = reader["regionMapTexture"].ToString(); | 221 | string tempRegionMap = reader["regionMapTexture"].ToString(); |
222 | if (tempRegionMap != "") | 222 | if (tempRegionMap != "") |
223 | { | 223 | { |
224 | retval.regionMapTextureID = new LLUUID(tempRegionMap); | 224 | retval.regionMapTextureID = new LLUUID(tempRegionMap); |
225 | } | 225 | } |
226 | else | 226 | else |
227 | { | 227 | { |
228 | retval.regionMapTextureID = new LLUUID(); | 228 | retval.regionMapTextureID = new LLUUID(); |
229 | } | 229 | } |
230 | } | 230 | } |
231 | else | 231 | else |
232 | { | 232 | { |
233 | return null; | 233 | return null; |
234 | } | 234 | } |
235 | return retval; | 235 | return retval; |
236 | } | 236 | } |
237 | 237 | ||
238 | /// <summary> | 238 | /// <summary> |
239 | /// Reads a reservation row from a database reader | 239 | /// Reads a reservation row from a database reader |
240 | /// </summary> | 240 | /// </summary> |
241 | /// <param name="reader">An active database reader</param> | 241 | /// <param name="reader">An active database reader</param> |
242 | /// <returns>A reservation data object</returns> | 242 | /// <returns>A reservation data object</returns> |
243 | public ReservationData readReservationRow(IDataReader reader) | 243 | public ReservationData readReservationRow(IDataReader reader) |
244 | { | 244 | { |
245 | ReservationData retval = new ReservationData(); | 245 | ReservationData retval = new ReservationData(); |
246 | if (reader.Read()) | 246 | if (reader.Read()) |
247 | { | 247 | { |
248 | retval.gridRecvKey = (string)reader["gridRecvKey"]; | 248 | retval.gridRecvKey = (string)reader["gridRecvKey"]; |
249 | retval.gridSendKey = (string)reader["gridSendKey"]; | 249 | retval.gridSendKey = (string)reader["gridSendKey"]; |
250 | retval.reservationCompany = (string)reader["resCompany"]; | 250 | retval.reservationCompany = (string)reader["resCompany"]; |
251 | retval.reservationMaxX = Convert.ToInt32(reader["resXMax"].ToString()); | 251 | retval.reservationMaxX = Convert.ToInt32(reader["resXMax"].ToString()); |
252 | retval.reservationMaxY = Convert.ToInt32(reader["resYMax"].ToString()); | 252 | retval.reservationMaxY = Convert.ToInt32(reader["resYMax"].ToString()); |
253 | retval.reservationMinX = Convert.ToInt32(reader["resXMin"].ToString()); | 253 | retval.reservationMinX = Convert.ToInt32(reader["resXMin"].ToString()); |
254 | retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString()); | 254 | retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString()); |
255 | retval.reservationName = (string)reader["resName"]; | 255 | retval.reservationName = (string)reader["resName"]; |
256 | retval.status = Convert.ToInt32(reader["status"].ToString()) == 1; | 256 | retval.status = Convert.ToInt32(reader["status"].ToString()) == 1; |
257 | retval.userUUID = new LLUUID((string)reader["userUUID"]); | 257 | retval.userUUID = new LLUUID((string)reader["userUUID"]); |
258 | 258 | ||
259 | } | 259 | } |
260 | else | 260 | else |
261 | { | 261 | { |
262 | return null; | 262 | return null; |
263 | } | 263 | } |
264 | return retval; | 264 | return retval; |
265 | } | 265 | } |
266 | /// <summary> | 266 | /// <summary> |
267 | /// Reads an agent row from a database reader | 267 | /// Reads an agent row from a database reader |
268 | /// </summary> | 268 | /// </summary> |
269 | /// <param name="reader">An active database reader</param> | 269 | /// <param name="reader">An active database reader</param> |
270 | /// <returns>A user session agent</returns> | 270 | /// <returns>A user session agent</returns> |
271 | public UserAgentData readAgentRow(IDataReader reader) | 271 | public UserAgentData readAgentRow(IDataReader reader) |
272 | { | 272 | { |
273 | UserAgentData retval = new UserAgentData(); | 273 | UserAgentData retval = new UserAgentData(); |
274 | 274 | ||
275 | if (reader.Read()) | 275 | if (reader.Read()) |
276 | { | 276 | { |
277 | // Agent IDs | 277 | // Agent IDs |
278 | retval.UUID = new LLUUID((string)reader["UUID"]); | 278 | retval.UUID = new LLUUID((string)reader["UUID"]); |
279 | retval.sessionID = new LLUUID((string)reader["sessionID"]); | 279 | retval.sessionID = new LLUUID((string)reader["sessionID"]); |
280 | retval.secureSessionID = new LLUUID((string)reader["secureSessionID"]); | 280 | retval.secureSessionID = new LLUUID((string)reader["secureSessionID"]); |
281 | 281 | ||
282 | // Agent Who? | 282 | // Agent Who? |
283 | retval.agentIP = (string)reader["agentIP"]; | 283 | retval.agentIP = (string)reader["agentIP"]; |
284 | retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString()); | 284 | retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString()); |
285 | retval.agentOnline = Convert.ToBoolean(reader["agentOnline"].ToString()); | 285 | retval.agentOnline = Convert.ToBoolean(reader["agentOnline"].ToString()); |
286 | 286 | ||
287 | // Login/Logout times (UNIX Epoch) | 287 | // Login/Logout times (UNIX Epoch) |
288 | retval.loginTime = Convert.ToInt32(reader["loginTime"].ToString()); | 288 | retval.loginTime = Convert.ToInt32(reader["loginTime"].ToString()); |
289 | retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); | 289 | retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); |
290 | 290 | ||
291 | // Current position | 291 | // Current position |
292 | retval.currentRegion = (string)reader["currentRegion"]; | 292 | retval.currentRegion = (string)reader["currentRegion"]; |
293 | retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString()); | 293 | retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString()); |
294 | LLVector3.TryParse((string)reader["currentPos"], out retval.currentPos); | 294 | LLVector3.TryParse((string)reader["currentPos"], out retval.currentPos); |
295 | } | 295 | } |
296 | else | 296 | else |
297 | { | 297 | { |
298 | return null; | 298 | return null; |
299 | } | 299 | } |
300 | return retval; | 300 | return retval; |
301 | } | 301 | } |
302 | 302 | ||
303 | /// <summary> | 303 | /// <summary> |
304 | /// Reads a user profile from an active data reader | 304 | /// Reads a user profile from an active data reader |
305 | /// </summary> | 305 | /// </summary> |
306 | /// <param name="reader">An active database reader</param> | 306 | /// <param name="reader">An active database reader</param> |
307 | /// <returns>A user profile</returns> | 307 | /// <returns>A user profile</returns> |
308 | public UserProfileData readUserRow(IDataReader reader) | 308 | public UserProfileData readUserRow(IDataReader reader) |
309 | { | 309 | { |
310 | UserProfileData retval = new UserProfileData(); | 310 | UserProfileData retval = new UserProfileData(); |
311 | 311 | ||
312 | if (reader.Read()) | 312 | if (reader.Read()) |
313 | { | 313 | { |
314 | retval.UUID = new LLUUID((string)reader["UUID"]); | 314 | retval.UUID = new LLUUID((string)reader["UUID"]); |
315 | retval.username = (string)reader["username"]; | 315 | retval.username = (string)reader["username"]; |
316 | retval.surname = (string)reader["lastname"]; | 316 | retval.surname = (string)reader["lastname"]; |
317 | 317 | ||
318 | retval.passwordHash = (string)reader["passwordHash"]; | 318 | retval.passwordHash = (string)reader["passwordHash"]; |
319 | retval.passwordSalt = (string)reader["passwordSalt"]; | 319 | retval.passwordSalt = (string)reader["passwordSalt"]; |
320 | 320 | ||
321 | retval.homeRegion = Convert.ToUInt64(reader["homeRegion"].ToString()); | 321 | retval.homeRegion = Convert.ToUInt64(reader["homeRegion"].ToString()); |
322 | retval.homeLocation = new LLVector3( | 322 | retval.homeLocation = new LLVector3( |
323 | Convert.ToSingle(reader["homeLocationX"].ToString()), | 323 | Convert.ToSingle(reader["homeLocationX"].ToString()), |
324 | Convert.ToSingle(reader["homeLocationY"].ToString()), | 324 | Convert.ToSingle(reader["homeLocationY"].ToString()), |
325 | Convert.ToSingle(reader["homeLocationZ"].ToString())); | 325 | Convert.ToSingle(reader["homeLocationZ"].ToString())); |
326 | retval.homeLookAt = new LLVector3( | 326 | retval.homeLookAt = new LLVector3( |
327 | Convert.ToSingle(reader["homeLookAtX"].ToString()), | 327 | Convert.ToSingle(reader["homeLookAtX"].ToString()), |
328 | Convert.ToSingle(reader["homeLookAtY"].ToString()), | 328 | Convert.ToSingle(reader["homeLookAtY"].ToString()), |
329 | Convert.ToSingle(reader["homeLookAtZ"].ToString())); | 329 | Convert.ToSingle(reader["homeLookAtZ"].ToString())); |
330 | 330 | ||
331 | retval.created = Convert.ToInt32(reader["created"].ToString()); | 331 | retval.created = Convert.ToInt32(reader["created"].ToString()); |
332 | retval.lastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); | 332 | retval.lastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); |
333 | 333 | ||
334 | retval.userInventoryURI = (string)reader["userInventoryURI"]; | 334 | retval.userInventoryURI = (string)reader["userInventoryURI"]; |
335 | retval.userAssetURI = (string)reader["userAssetURI"]; | 335 | retval.userAssetURI = (string)reader["userAssetURI"]; |
336 | 336 | ||
337 | retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString()); | 337 | retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString()); |
338 | retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString()); | 338 | retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString()); |
339 | 339 | ||
340 | retval.profileAboutText = (string)reader["profileAboutText"]; | 340 | retval.profileAboutText = (string)reader["profileAboutText"]; |
341 | retval.profileFirstText = (string)reader["profileFirstText"]; | 341 | retval.profileFirstText = (string)reader["profileFirstText"]; |
342 | 342 | ||
343 | retval.profileImage = new LLUUID((string)reader["profileImage"]); | 343 | retval.profileImage = new LLUUID((string)reader["profileImage"]); |
344 | retval.profileFirstImage = new LLUUID((string)reader["profileFirstImage"]); | 344 | retval.profileFirstImage = new LLUUID((string)reader["profileFirstImage"]); |
345 | 345 | ||
346 | } | 346 | } |
347 | else | 347 | else |
348 | { | 348 | { |
349 | return null; | 349 | return null; |
350 | } | 350 | } |
351 | return retval; | 351 | return retval; |
352 | } | 352 | } |
353 | 353 | ||
354 | /// <summary> | 354 | /// <summary> |
355 | /// Reads a list of inventory folders returned by a query. | 355 | /// Reads a list of inventory folders returned by a query. |
356 | /// </summary> | 356 | /// </summary> |
357 | /// <param name="reader">A MySQL Data Reader</param> | 357 | /// <param name="reader">A MySQL Data Reader</param> |
358 | /// <returns>A List containing inventory folders</returns> | 358 | /// <returns>A List containing inventory folders</returns> |
359 | public List<InventoryFolderBase> readInventoryFolders(IDataReader reader) | 359 | public List<InventoryFolderBase> readInventoryFolders(IDataReader reader) |
360 | { | 360 | { |
361 | List<InventoryFolderBase> rows = new List<InventoryFolderBase>(); | 361 | List<InventoryFolderBase> rows = new List<InventoryFolderBase>(); |
362 | 362 | ||
363 | while(reader.Read()) | 363 | while(reader.Read()) |
364 | { | 364 | { |
365 | try | 365 | try |
366 | { | 366 | { |
367 | InventoryFolderBase folder = new InventoryFolderBase(); | 367 | InventoryFolderBase folder = new InventoryFolderBase(); |
368 | 368 | ||
369 | folder.agentID = new LLUUID((string)reader["agentID"]); | 369 | folder.agentID = new LLUUID((string)reader["agentID"]); |
370 | folder.parentID = new LLUUID((string)reader["parentFolderID"]); | 370 | folder.parentID = new LLUUID((string)reader["parentFolderID"]); |
371 | folder.folderID = new LLUUID((string)reader["folderID"]); | 371 | folder.folderID = new LLUUID((string)reader["folderID"]); |
372 | folder.name = (string)reader["folderName"]; | 372 | folder.name = (string)reader["folderName"]; |
373 | 373 | ||
374 | rows.Add(folder); | 374 | rows.Add(folder); |
375 | } | 375 | } |
376 | catch (Exception e) | 376 | catch (Exception e) |
377 | { | 377 | { |
378 | Console.WriteLine(e.ToString()); | 378 | Console.WriteLine(e.ToString()); |
379 | } | 379 | } |
380 | } | 380 | } |
381 | 381 | ||
382 | return rows; | 382 | return rows; |
383 | } | 383 | } |
384 | 384 | ||
385 | /// <summary> | 385 | /// <summary> |
386 | /// Reads a collection of items from an SQL result | 386 | /// Reads a collection of items from an SQL result |
387 | /// </summary> | 387 | /// </summary> |
388 | /// <param name="reader">The SQL Result</param> | 388 | /// <param name="reader">The SQL Result</param> |
389 | /// <returns>A List containing Inventory Items</returns> | 389 | /// <returns>A List containing Inventory Items</returns> |
390 | public List<InventoryItemBase> readInventoryItems(IDataReader reader) | 390 | public List<InventoryItemBase> readInventoryItems(IDataReader reader) |
391 | { | 391 | { |
392 | List<InventoryItemBase> rows = new List<InventoryItemBase>(); | 392 | List<InventoryItemBase> rows = new List<InventoryItemBase>(); |
393 | 393 | ||
394 | while (reader.Read()) | 394 | while (reader.Read()) |
395 | { | 395 | { |
396 | try | 396 | try |
397 | { | 397 | { |
398 | InventoryItemBase item = new InventoryItemBase(); | 398 | InventoryItemBase item = new InventoryItemBase(); |
399 | 399 | ||
400 | item.assetID = new LLUUID((string)reader["assetID"]); | 400 | item.assetID = new LLUUID((string)reader["assetID"]); |
401 | item.avatarID = new LLUUID((string)reader["avatarID"]); | 401 | item.avatarID = new LLUUID((string)reader["avatarID"]); |
402 | item.inventoryCurrentPermissions = Convert.ToUInt32(reader["inventoryCurrentPermissions"].ToString()); | 402 | item.inventoryCurrentPermissions = Convert.ToUInt32(reader["inventoryCurrentPermissions"].ToString()); |
403 | item.inventoryDescription = (string)reader["inventoryDescription"]; | 403 | item.inventoryDescription = (string)reader["inventoryDescription"]; |
404 | item.inventoryID = new LLUUID((string)reader["inventoryID"]); | 404 | item.inventoryID = new LLUUID((string)reader["inventoryID"]); |
405 | item.inventoryName = (string)reader["inventoryName"]; | 405 | item.inventoryName = (string)reader["inventoryName"]; |
406 | item.inventoryNextPermissions = Convert.ToUInt32(reader["inventoryNextPermissions"].ToString()); | 406 | item.inventoryNextPermissions = Convert.ToUInt32(reader["inventoryNextPermissions"].ToString()); |
407 | item.parentFolderID = new LLUUID((string)reader["parentFolderID"]); | 407 | item.parentFolderID = new LLUUID((string)reader["parentFolderID"]); |
408 | item.type = Convert.ToInt32(reader["type"].ToString()); | 408 | item.type = Convert.ToInt32(reader["type"].ToString()); |
409 | 409 | ||
410 | rows.Add(item); | 410 | rows.Add(item); |
411 | } | 411 | } |
412 | catch (Exception e) | 412 | catch (Exception e) |
413 | { | 413 | { |
414 | Console.WriteLine(e.ToString()); | 414 | Console.WriteLine(e.ToString()); |
415 | } | 415 | } |
416 | } | 416 | } |
417 | 417 | ||
418 | return rows; | 418 | return rows; |
419 | } | 419 | } |
420 | 420 | ||
421 | /// <summary> | 421 | /// <summary> |
422 | /// Inserts a new row into the log database | 422 | /// Inserts a new row into the log database |
423 | /// </summary> | 423 | /// </summary> |
424 | /// <param name="serverDaemon">The daemon which triggered this event</param> | 424 | /// <param name="serverDaemon">The daemon which triggered this event</param> |
425 | /// <param name="target">Who were we operating on when this occured (region UUID, user UUID, etc)</param> | 425 | /// <param name="target">Who were we operating on when this occured (region UUID, user UUID, etc)</param> |
426 | /// <param name="methodCall">The method call where the problem occured</param> | 426 | /// <param name="methodCall">The method call where the problem occured</param> |
427 | /// <param name="arguments">The arguments passed to the method</param> | 427 | /// <param name="arguments">The arguments passed to the method</param> |
428 | /// <param name="priority">How critical is this?</param> | 428 | /// <param name="priority">How critical is this?</param> |
429 | /// <param name="logMessage">Extra message info</param> | 429 | /// <param name="logMessage">Extra message info</param> |
430 | /// <returns>Saved successfully?</returns> | 430 | /// <returns>Saved successfully?</returns> |
431 | public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage) | 431 | public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage) |
432 | { | 432 | { |
433 | string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES "; | 433 | string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES "; |
434 | sql += "(?target, ?server, ?method, ?arguments, ?priority, ?message)"; | 434 | sql += "(?target, ?server, ?method, ?arguments, ?priority, ?message)"; |
435 | 435 | ||
436 | Dictionary<string, string> parameters = new Dictionary<string, string>(); | 436 | Dictionary<string, string> parameters = new Dictionary<string, string>(); |
437 | parameters["?server"] = serverDaemon; | 437 | parameters["?server"] = serverDaemon; |
438 | parameters["?target"] = target; | 438 | parameters["?target"] = target; |
439 | parameters["?method"] = methodCall; | 439 | parameters["?method"] = methodCall; |
440 | parameters["?arguments"] = arguments; | 440 | parameters["?arguments"] = arguments; |
441 | parameters["?priority"] = priority.ToString(); | 441 | parameters["?priority"] = priority.ToString(); |
442 | parameters["?message"] = logMessage; | 442 | parameters["?message"] = logMessage; |
443 | 443 | ||
444 | bool returnval = false; | 444 | bool returnval = false; |
445 | 445 | ||
446 | try | 446 | try |
447 | { | 447 | { |
448 | IDbCommand result = Query(sql, parameters); | 448 | IDbCommand result = Query(sql, parameters); |
449 | 449 | ||
450 | if (result.ExecuteNonQuery() == 1) | 450 | if (result.ExecuteNonQuery() == 1) |
451 | returnval = true; | 451 | returnval = true; |
452 | 452 | ||
453 | result.Dispose(); | 453 | result.Dispose(); |
454 | } | 454 | } |
455 | catch (Exception e) | 455 | catch (Exception e) |
456 | { | 456 | { |
457 | Console.WriteLine(e.ToString()); | 457 | Console.WriteLine(e.ToString()); |
458 | return false; | 458 | return false; |
459 | } | 459 | } |
460 | 460 | ||
461 | return returnval; | 461 | return returnval; |
462 | } | 462 | } |
463 | 463 | ||
464 | /// <summary> | 464 | /// <summary> |
465 | /// Inserts a new item into the database | 465 | /// Inserts a new item into the database |
466 | /// </summary> | 466 | /// </summary> |
467 | /// <param name="item">The item</param> | 467 | /// <param name="item">The item</param> |
468 | /// <returns>Success?</returns> | 468 | /// <returns>Success?</returns> |
469 | public bool insertItem(InventoryItemBase item) | 469 | public bool insertItem(InventoryItemBase item) |
470 | { | 470 | { |
471 | string sql = "REPLACE INTO inventoryitems (inventoryID, assetID, type, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions) VALUES "; | 471 | string sql = "REPLACE INTO inventoryitems (inventoryID, assetID, type, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions) VALUES "; |
472 | sql += "(?inventoryID, ?assetID, ?type, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription, ?inventoryNextPermissions, ?inventoryCurrentPermissions)"; | 472 | sql += "(?inventoryID, ?assetID, ?type, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription, ?inventoryNextPermissions, ?inventoryCurrentPermissions)"; |
473 | 473 | ||
474 | Dictionary<string, string> parameters = new Dictionary<string, string>(); | 474 | Dictionary<string, string> parameters = new Dictionary<string, string>(); |
475 | parameters["?inventoryID"] = item.inventoryID.ToStringHyphenated(); | 475 | parameters["?inventoryID"] = item.inventoryID.ToStringHyphenated(); |
476 | parameters["?assetID"] = item.assetID.ToStringHyphenated(); | 476 | parameters["?assetID"] = item.assetID.ToStringHyphenated(); |
477 | parameters["?type"] = item.type.ToString(); | 477 | parameters["?type"] = item.type.ToString(); |
478 | parameters["?parentFolderID"] = item.parentFolderID.ToStringHyphenated(); | 478 | parameters["?parentFolderID"] = item.parentFolderID.ToStringHyphenated(); |
479 | parameters["?avatarID"] = item.avatarID.ToStringHyphenated(); | 479 | parameters["?avatarID"] = item.avatarID.ToStringHyphenated(); |
480 | parameters["?inventoryName"] = item.inventoryName; | 480 | parameters["?inventoryName"] = item.inventoryName; |
481 | parameters["?inventoryDescription"] = item.inventoryDescription; | 481 | parameters["?inventoryDescription"] = item.inventoryDescription; |
482 | parameters["?inventoryNextPermissions"] = item.inventoryNextPermissions.ToString(); | 482 | parameters["?inventoryNextPermissions"] = item.inventoryNextPermissions.ToString(); |
483 | parameters["?inventoryCurrentPermissions"] = item.inventoryCurrentPermissions.ToString(); | 483 | parameters["?inventoryCurrentPermissions"] = item.inventoryCurrentPermissions.ToString(); |
484 | 484 | ||
485 | bool returnval = false; | 485 | bool returnval = false; |
486 | 486 | ||
487 | try | 487 | try |
488 | { | 488 | { |
489 | IDbCommand result = Query(sql, parameters); | 489 | IDbCommand result = Query(sql, parameters); |
490 | 490 | ||
491 | if (result.ExecuteNonQuery() == 1) | 491 | if (result.ExecuteNonQuery() == 1) |
492 | returnval = true; | 492 | returnval = true; |
493 | 493 | ||
494 | result.Dispose(); | 494 | result.Dispose(); |
495 | } | 495 | } |
496 | catch (Exception e) | 496 | catch (Exception e) |
497 | { | 497 | { |
498 | Console.WriteLine(e.ToString()); | 498 | Console.WriteLine(e.ToString()); |
499 | return false; | 499 | return false; |
500 | } | 500 | } |
501 | 501 | ||
502 | return returnval; | 502 | return returnval; |
503 | } | 503 | } |
504 | 504 | ||
505 | /// <summary> | 505 | /// <summary> |
506 | /// Inserts a new folder into the database | 506 | /// Inserts a new folder into the database |
507 | /// </summary> | 507 | /// </summary> |
508 | /// <param name="folder">The folder</param> | 508 | /// <param name="folder">The folder</param> |
509 | /// <returns>Success?</returns> | 509 | /// <returns>Success?</returns> |
510 | public bool insertFolder(InventoryFolderBase folder) | 510 | public bool insertFolder(InventoryFolderBase folder) |
511 | { | 511 | { |
512 | string sql = "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName) VALUES "; | 512 | string sql = "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName) VALUES "; |
513 | sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName)"; | 513 | sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName)"; |
514 | 514 | ||
515 | Dictionary<string, string> parameters = new Dictionary<string, string>(); | 515 | Dictionary<string, string> parameters = new Dictionary<string, string>(); |
516 | parameters["?folderID"] = folder.folderID.ToStringHyphenated(); | 516 | parameters["?folderID"] = folder.folderID.ToStringHyphenated(); |
517 | parameters["?agentID"] = folder.agentID.ToStringHyphenated(); | 517 | parameters["?agentID"] = folder.agentID.ToStringHyphenated(); |
518 | parameters["?parentFolderID"] = folder.parentID.ToStringHyphenated(); | 518 | parameters["?parentFolderID"] = folder.parentID.ToStringHyphenated(); |
519 | parameters["?folderName"] = folder.name; | 519 | parameters["?folderName"] = folder.name; |
520 | 520 | ||
521 | bool returnval = false; | 521 | bool returnval = false; |
522 | try | 522 | try |
523 | { | 523 | { |
524 | IDbCommand result = Query(sql, parameters); | 524 | IDbCommand result = Query(sql, parameters); |
525 | 525 | ||
526 | if (result.ExecuteNonQuery() == 1) | 526 | if (result.ExecuteNonQuery() == 1) |
527 | returnval = true; | 527 | returnval = true; |
528 | 528 | ||
529 | result.Dispose(); | 529 | result.Dispose(); |
530 | } | 530 | } |
531 | catch (Exception e) | 531 | catch (Exception e) |
532 | { | 532 | { |
533 | Console.WriteLine(e.ToString()); | 533 | Console.WriteLine(e.ToString()); |
534 | return false; | 534 | return false; |
535 | } | 535 | } |
536 | return returnval; | 536 | return returnval; |
537 | } | 537 | } |
538 | 538 | ||
539 | /// <summary> | 539 | /// <summary> |
540 | /// Inserts a new region into the database | 540 | /// Inserts a new region into the database |
541 | /// </summary> | 541 | /// </summary> |
542 | /// <param name="profile">The region to insert</param> | 542 | /// <param name="profile">The region to insert</param> |
543 | /// <returns>Success?</returns> | 543 | /// <returns>Success?</returns> |
544 | public bool insertRegion(SimProfileData regiondata) | 544 | public bool insertRegion(SimProfileData regiondata) |
545 | { | 545 | { |
546 | string sql = "REPLACE INTO regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; | 546 | string sql = "REPLACE INTO regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; |
547 | sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; | 547 | sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; |
548 | sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort) VALUES "; | 548 | sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort) VALUES "; |
549 | 549 | ||
550 | sql += "(?regionHandle, ?regionName, ?uuid, ?regionRecvKey, ?regionSecret, ?regionSendKey, ?regionDataURI, "; | 550 | sql += "(?regionHandle, ?regionName, ?uuid, ?regionRecvKey, ?regionSecret, ?regionSendKey, ?regionDataURI, "; |
551 | sql += "?serverIP, ?serverPort, ?serverURI, ?locX, ?locY, ?locZ, ?eastOverrideHandle, ?westOverrideHandle, ?southOverrideHandle, ?northOverrideHandle, ?regionAssetURI, ?regionAssetRecvKey, "; | 551 | sql += "?serverIP, ?serverPort, ?serverURI, ?locX, ?locY, ?locZ, ?eastOverrideHandle, ?westOverrideHandle, ?southOverrideHandle, ?northOverrideHandle, ?regionAssetURI, ?regionAssetRecvKey, "; |
552 | sql += "?regionAssetSendKey, ?regionUserURI, ?regionUserRecvKey, ?regionUserSendKey, ?regionMapTexture, ?serverHttpPort, ?serverRemotingPort);"; | 552 | sql += "?regionAssetSendKey, ?regionUserURI, ?regionUserRecvKey, ?regionUserSendKey, ?regionMapTexture, ?serverHttpPort, ?serverRemotingPort);"; |
553 | 553 | ||
554 | Dictionary<string, string> parameters = new Dictionary<string, string>(); | 554 | Dictionary<string, string> parameters = new Dictionary<string, string>(); |
555 | 555 | ||
556 | parameters["?regionHandle"] = regiondata.regionHandle.ToString(); | 556 | parameters["?regionHandle"] = regiondata.regionHandle.ToString(); |
557 | parameters["?regionName"] = regiondata.regionName.ToString(); | 557 | parameters["?regionName"] = regiondata.regionName.ToString(); |
558 | parameters["?uuid"] = regiondata.UUID.ToStringHyphenated(); | 558 | parameters["?uuid"] = regiondata.UUID.ToStringHyphenated(); |
559 | parameters["?regionRecvKey"] = regiondata.regionRecvKey.ToString(); | 559 | parameters["?regionRecvKey"] = regiondata.regionRecvKey.ToString(); |
560 | parameters["?regionSecret"] = regiondata.regionSecret.ToString(); | 560 | parameters["?regionSecret"] = regiondata.regionSecret.ToString(); |
561 | parameters["?regionSendKey"] = regiondata.regionSendKey.ToString(); | 561 | parameters["?regionSendKey"] = regiondata.regionSendKey.ToString(); |
562 | parameters["?regionDataURI"] = regiondata.regionDataURI.ToString(); | 562 | parameters["?regionDataURI"] = regiondata.regionDataURI.ToString(); |
563 | parameters["?serverIP"] = regiondata.serverIP.ToString(); | 563 | parameters["?serverIP"] = regiondata.serverIP.ToString(); |
564 | parameters["?serverPort"] = regiondata.serverPort.ToString(); | 564 | parameters["?serverPort"] = regiondata.serverPort.ToString(); |
565 | parameters["?serverURI"] = regiondata.serverURI.ToString(); | 565 | parameters["?serverURI"] = regiondata.serverURI.ToString(); |
566 | parameters["?locX"] = regiondata.regionLocX.ToString(); | 566 | parameters["?locX"] = regiondata.regionLocX.ToString(); |
567 | parameters["?locY"] = regiondata.regionLocY.ToString(); | 567 | parameters["?locY"] = regiondata.regionLocY.ToString(); |
568 | parameters["?locZ"] = regiondata.regionLocZ.ToString(); | 568 | parameters["?locZ"] = regiondata.regionLocZ.ToString(); |
569 | parameters["?eastOverrideHandle"] = regiondata.regionEastOverrideHandle.ToString(); | 569 | parameters["?eastOverrideHandle"] = regiondata.regionEastOverrideHandle.ToString(); |
570 | parameters["?westOverrideHandle"] = regiondata.regionWestOverrideHandle.ToString(); | 570 | parameters["?westOverrideHandle"] = regiondata.regionWestOverrideHandle.ToString(); |
571 | parameters["?northOverrideHandle"] = regiondata.regionNorthOverrideHandle.ToString(); | 571 | parameters["?northOverrideHandle"] = regiondata.regionNorthOverrideHandle.ToString(); |
572 | parameters["?southOverrideHandle"] = regiondata.regionSouthOverrideHandle.ToString(); | 572 | parameters["?southOverrideHandle"] = regiondata.regionSouthOverrideHandle.ToString(); |
573 | parameters["?regionAssetURI"] = regiondata.regionAssetURI.ToString(); | 573 | parameters["?regionAssetURI"] = regiondata.regionAssetURI.ToString(); |
574 | parameters["?regionAssetRecvKey"] = regiondata.regionAssetRecvKey.ToString(); | 574 | parameters["?regionAssetRecvKey"] = regiondata.regionAssetRecvKey.ToString(); |
575 | parameters["?regionAssetSendKey"] = regiondata.regionAssetSendKey.ToString(); | 575 | parameters["?regionAssetSendKey"] = regiondata.regionAssetSendKey.ToString(); |
576 | parameters["?regionUserURI"] = regiondata.regionUserURI.ToString(); | 576 | parameters["?regionUserURI"] = regiondata.regionUserURI.ToString(); |
577 | parameters["?regionUserRecvKey"] = regiondata.regionUserRecvKey.ToString(); | 577 | parameters["?regionUserRecvKey"] = regiondata.regionUserRecvKey.ToString(); |
578 | parameters["?regionUserSendKey"] = regiondata.regionUserSendKey.ToString(); | 578 | parameters["?regionUserSendKey"] = regiondata.regionUserSendKey.ToString(); |
579 | parameters["?regionMapTexture"] = regiondata.regionMapTextureID.ToStringHyphenated(); | 579 | parameters["?regionMapTexture"] = regiondata.regionMapTextureID.ToStringHyphenated(); |
580 | parameters["?serverHttpPort"] = regiondata.httpPort.ToString(); | 580 | parameters["?serverHttpPort"] = regiondata.httpPort.ToString(); |
581 | parameters["?serverRemotingPort"] = regiondata.remotingPort.ToString(); | 581 | parameters["?serverRemotingPort"] = regiondata.remotingPort.ToString(); |
582 | 582 | ||
583 | bool returnval = false; | 583 | bool returnval = false; |
584 | 584 | ||
585 | try | 585 | try |
586 | { | 586 | { |
587 | 587 | ||
588 | IDbCommand result = Query(sql, parameters); | 588 | IDbCommand result = Query(sql, parameters); |
589 | 589 | ||
590 | //Console.WriteLine(result.CommandText); | 590 | //Console.WriteLine(result.CommandText); |
591 | 591 | ||
592 | if (result.ExecuteNonQuery() == 1) | 592 | if (result.ExecuteNonQuery() == 1) |
593 | returnval = true; | 593 | returnval = true; |
594 | 594 | ||
595 | result.Dispose(); | 595 | result.Dispose(); |
596 | } | 596 | } |
597 | catch (Exception e) | 597 | catch (Exception e) |
598 | { | 598 | { |
599 | Console.WriteLine(e.ToString()); | 599 | Console.WriteLine(e.ToString()); |
600 | return false; | 600 | return false; |
601 | } | 601 | } |
602 | 602 | ||
603 | return returnval; | 603 | return returnval; |
604 | } | 604 | } |
605 | } | 605 | } |
606 | } | 606 | } |
diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs index c116536..b044bdd 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs | |||
@@ -1,256 +1,256 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Data; | 30 | using System.Data; |
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | 32 | ||
33 | namespace OpenSim.Framework.Data.MySQL | 33 | namespace OpenSim.Framework.Data.MySQL |
34 | { | 34 | { |
35 | /// <summary> | 35 | /// <summary> |
36 | /// A database interface class to a user profile storage system | 36 | /// A database interface class to a user profile storage system |
37 | /// </summary> | 37 | /// </summary> |
38 | class MySQLUserData : IUserData | 38 | class MySQLUserData : IUserData |
39 | { | 39 | { |
40 | /// <summary> | 40 | /// <summary> |
41 | /// Database manager for MySQL | 41 | /// Database manager for MySQL |
42 | /// </summary> | 42 | /// </summary> |
43 | public MySQLManager database; | 43 | public MySQLManager database; |
44 | 44 | ||
45 | /// <summary> | 45 | /// <summary> |
46 | /// Loads and initialises the MySQL storage plugin | 46 | /// Loads and initialises the MySQL storage plugin |
47 | /// </summary> | 47 | /// </summary> |
48 | public void Initialise() | 48 | public void Initialise() |
49 | { | 49 | { |
50 | // Load from an INI file connection details | 50 | // Load from an INI file connection details |
51 | // TODO: move this to XML? | 51 | // TODO: move this to XML? |
52 | IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); | 52 | IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); |
53 | string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); | 53 | string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); |
54 | string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); | 54 | string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); |
55 | string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); | 55 | string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); |
56 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); | 56 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); |
57 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); | 57 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); |
58 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); | 58 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); |
59 | 59 | ||
60 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); | 60 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); |
61 | } | 61 | } |
62 | 62 | ||
63 | /// <summary> | 63 | /// <summary> |
64 | /// Searches the database for a specified user profile | 64 | /// Searches the database for a specified user profile |
65 | /// </summary> | 65 | /// </summary> |
66 | /// <param name="name">The account name of the user</param> | 66 | /// <param name="name">The account name of the user</param> |
67 | /// <returns>A user profile</returns> | 67 | /// <returns>A user profile</returns> |
68 | public UserProfileData getUserByName(string name) | 68 | public UserProfileData getUserByName(string name) |
69 | { | 69 | { |
70 | return getUserByName(name.Split(' ')[0], name.Split(' ')[1]); | 70 | return getUserByName(name.Split(' ')[0], name.Split(' ')[1]); |
71 | } | 71 | } |
72 | 72 | ||
73 | /// <summary> | 73 | /// <summary> |
74 | /// Searches the database for a specified user profile by name components | 74 | /// Searches the database for a specified user profile by name components |
75 | /// </summary> | 75 | /// </summary> |
76 | /// <param name="user">The first part of the account name</param> | 76 | /// <param name="user">The first part of the account name</param> |
77 | /// <param name="last">The second part of the account name</param> | 77 | /// <param name="last">The second part of the account name</param> |
78 | /// <returns>A user profile</returns> | 78 | /// <returns>A user profile</returns> |
79 | public UserProfileData getUserByName(string user, string last) | 79 | public UserProfileData getUserByName(string user, string last) |
80 | { | 80 | { |
81 | try | 81 | try |
82 | { | 82 | { |
83 | lock (database) | 83 | lock (database) |
84 | { | 84 | { |
85 | Dictionary<string, string> param = new Dictionary<string, string>(); | 85 | Dictionary<string, string> param = new Dictionary<string, string>(); |
86 | param["?first"] = user; | 86 | param["?first"] = user; |
87 | param["?second"] = last; | 87 | param["?second"] = last; |
88 | 88 | ||
89 | IDbCommand result = database.Query("SELECT * FROM users WHERE username = ?first AND lastname = ?second", param); | 89 | IDbCommand result = database.Query("SELECT * FROM users WHERE username = ?first AND lastname = ?second", param); |
90 | IDataReader reader = result.ExecuteReader(); | 90 | IDataReader reader = result.ExecuteReader(); |
91 | 91 | ||
92 | UserProfileData row = database.readUserRow(reader); | 92 | UserProfileData row = database.readUserRow(reader); |
93 | 93 | ||
94 | reader.Close(); | 94 | reader.Close(); |
95 | result.Dispose(); | 95 | result.Dispose(); |
96 | 96 | ||
97 | return row; | 97 | return row; |
98 | } | 98 | } |
99 | } | 99 | } |
100 | catch (Exception e) | 100 | catch (Exception e) |
101 | { | 101 | { |
102 | database.Reconnect(); | 102 | database.Reconnect(); |
103 | Console.WriteLine(e.ToString()); | 103 | Console.WriteLine(e.ToString()); |
104 | return null; | 104 | return null; |
105 | } | 105 | } |
106 | } | 106 | } |
107 | 107 | ||
108 | /// <summary> | 108 | /// <summary> |
109 | /// Searches the database for a specified user profile by UUID | 109 | /// Searches the database for a specified user profile by UUID |
110 | /// </summary> | 110 | /// </summary> |
111 | /// <param name="uuid">The account ID</param> | 111 | /// <param name="uuid">The account ID</param> |
112 | /// <returns>The users profile</returns> | 112 | /// <returns>The users profile</returns> |
113 | public UserProfileData getUserByUUID(LLUUID uuid) | 113 | public UserProfileData getUserByUUID(LLUUID uuid) |
114 | { | 114 | { |
115 | try | 115 | try |
116 | { | 116 | { |
117 | lock (database) | 117 | lock (database) |
118 | { | 118 | { |
119 | Dictionary<string, string> param = new Dictionary<string, string>(); | 119 | Dictionary<string, string> param = new Dictionary<string, string>(); |
120 | param["?uuid"] = uuid.ToStringHyphenated(); | 120 | param["?uuid"] = uuid.ToStringHyphenated(); |
121 | 121 | ||
122 | IDbCommand result = database.Query("SELECT * FROM users WHERE UUID = ?uuid", param); | 122 | IDbCommand result = database.Query("SELECT * FROM users WHERE UUID = ?uuid", param); |
123 | IDataReader reader = result.ExecuteReader(); | 123 | IDataReader reader = result.ExecuteReader(); |
124 | 124 | ||
125 | UserProfileData row = database.readUserRow(reader); | 125 | UserProfileData row = database.readUserRow(reader); |
126 | 126 | ||
127 | reader.Close(); | 127 | reader.Close(); |
128 | result.Dispose(); | 128 | result.Dispose(); |
129 | 129 | ||
130 | return row; | 130 | return row; |
131 | } | 131 | } |
132 | } | 132 | } |
133 | catch (Exception e) | 133 | catch (Exception e) |
134 | { | 134 | { |
135 | database.Reconnect(); | 135 | database.Reconnect(); |
136 | Console.WriteLine(e.ToString()); | 136 | Console.WriteLine(e.ToString()); |
137 | return null; | 137 | return null; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | /// <summary> | 141 | /// <summary> |
142 | /// Returns a user session searching by name | 142 | /// Returns a user session searching by name |
143 | /// </summary> | 143 | /// </summary> |
144 | /// <param name="name">The account name</param> | 144 | /// <param name="name">The account name</param> |
145 | /// <returns>The users session</returns> | 145 | /// <returns>The users session</returns> |
146 | public UserAgentData getAgentByName(string name) | 146 | public UserAgentData getAgentByName(string name) |
147 | { | 147 | { |
148 | return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]); | 148 | return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]); |
149 | } | 149 | } |
150 | 150 | ||
151 | /// <summary> | 151 | /// <summary> |
152 | /// Returns a user session by account name | 152 | /// Returns a user session by account name |
153 | /// </summary> | 153 | /// </summary> |
154 | /// <param name="user">First part of the users account name</param> | 154 | /// <param name="user">First part of the users account name</param> |
155 | /// <param name="last">Second 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> | 156 | /// <returns>The users session</returns> |
157 | public UserAgentData getAgentByName(string user, string last) | 157 | public UserAgentData getAgentByName(string user, string last) |
158 | { | 158 | { |
159 | UserProfileData profile = getUserByName(user, last); | 159 | UserProfileData profile = getUserByName(user, last); |
160 | return getAgentByUUID(profile.UUID); | 160 | return getAgentByUUID(profile.UUID); |
161 | } | 161 | } |
162 | 162 | ||
163 | /// <summary> | 163 | /// <summary> |
164 | /// Returns an agent session by account UUID | 164 | /// Returns an agent session by account UUID |
165 | /// </summary> | 165 | /// </summary> |
166 | /// <param name="uuid">The accounts UUID</param> | 166 | /// <param name="uuid">The accounts UUID</param> |
167 | /// <returns>The users session</returns> | 167 | /// <returns>The users session</returns> |
168 | public UserAgentData getAgentByUUID(LLUUID uuid) | 168 | public UserAgentData getAgentByUUID(LLUUID uuid) |
169 | { | 169 | { |
170 | try | 170 | try |
171 | { | 171 | { |
172 | lock (database) | 172 | lock (database) |
173 | { | 173 | { |
174 | Dictionary<string, string> param = new Dictionary<string, string>(); | 174 | Dictionary<string, string> param = new Dictionary<string, string>(); |
175 | param["?uuid"] = uuid.ToStringHyphenated(); | 175 | param["?uuid"] = uuid.ToStringHyphenated(); |
176 | 176 | ||
177 | IDbCommand result = database.Query("SELECT * FROM agents WHERE UUID = ?uuid", param); | 177 | IDbCommand result = database.Query("SELECT * FROM agents WHERE UUID = ?uuid", param); |
178 | IDataReader reader = result.ExecuteReader(); | 178 | IDataReader reader = result.ExecuteReader(); |
179 | 179 | ||
180 | UserAgentData row = database.readAgentRow(reader); | 180 | UserAgentData row = database.readAgentRow(reader); |
181 | 181 | ||
182 | reader.Close(); | 182 | reader.Close(); |
183 | result.Dispose(); | 183 | result.Dispose(); |
184 | 184 | ||
185 | return row; | 185 | return row; |
186 | } | 186 | } |
187 | } | 187 | } |
188 | catch (Exception e) | 188 | catch (Exception e) |
189 | { | 189 | { |
190 | database.Reconnect(); | 190 | database.Reconnect(); |
191 | Console.WriteLine(e.ToString()); | 191 | Console.WriteLine(e.ToString()); |
192 | return null; | 192 | return null; |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | /// <summary> | 196 | /// <summary> |
197 | /// Creates a new users profile | 197 | /// Creates a new users profile |
198 | /// </summary> | 198 | /// </summary> |
199 | /// <param name="user">The user profile to create</param> | 199 | /// <param name="user">The user profile to create</param> |
200 | public void addNewUserProfile(UserProfileData user) | 200 | public void addNewUserProfile(UserProfileData user) |
201 | { | 201 | { |
202 | } | 202 | } |
203 | 203 | ||
204 | /// <summary> | 204 | /// <summary> |
205 | /// Creates a new agent | 205 | /// Creates a new agent |
206 | /// </summary> | 206 | /// </summary> |
207 | /// <param name="agent">The agent to create</param> | 207 | /// <param name="agent">The agent to create</param> |
208 | public void addNewUserAgent(UserAgentData agent) | 208 | public void addNewUserAgent(UserAgentData agent) |
209 | { | 209 | { |
210 | // Do nothing. | 210 | // Do nothing. |
211 | } | 211 | } |
212 | 212 | ||
213 | /// <summary> | 213 | /// <summary> |
214 | /// Performs a money transfer request between two accounts | 214 | /// Performs a money transfer request between two accounts |
215 | /// </summary> | 215 | /// </summary> |
216 | /// <param name="from">The senders account ID</param> | 216 | /// <param name="from">The senders account ID</param> |
217 | /// <param name="to">The recievers account ID</param> | 217 | /// <param name="to">The recievers account ID</param> |
218 | /// <param name="amount">The amount to transfer</param> | 218 | /// <param name="amount">The amount to transfer</param> |
219 | /// <returns>Success?</returns> | 219 | /// <returns>Success?</returns> |
220 | public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount) | 220 | public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount) |
221 | { | 221 | { |
222 | return false; | 222 | return false; |
223 | } | 223 | } |
224 | 224 | ||
225 | /// <summary> | 225 | /// <summary> |
226 | /// Performs an inventory transfer request between two accounts | 226 | /// Performs an inventory transfer request between two accounts |
227 | /// </summary> | 227 | /// </summary> |
228 | /// <remarks>TODO: Move to inventory server</remarks> | 228 | /// <remarks>TODO: Move to inventory server</remarks> |
229 | /// <param name="from">The senders account ID</param> | 229 | /// <param name="from">The senders account ID</param> |
230 | /// <param name="to">The recievers account ID</param> | 230 | /// <param name="to">The recievers account ID</param> |
231 | /// <param name="item">The item to transfer</param> | 231 | /// <param name="item">The item to transfer</param> |
232 | /// <returns>Success?</returns> | 232 | /// <returns>Success?</returns> |
233 | public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) | 233 | public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) |
234 | { | 234 | { |
235 | return false; | 235 | return false; |
236 | } | 236 | } |
237 | 237 | ||
238 | /// <summary> | 238 | /// <summary> |
239 | /// Database provider name | 239 | /// Database provider name |
240 | /// </summary> | 240 | /// </summary> |
241 | /// <returns>Provider name</returns> | 241 | /// <returns>Provider name</returns> |
242 | public string getName() | 242 | public string getName() |
243 | { | 243 | { |
244 | return "MySQL Userdata Interface"; | 244 | return "MySQL Userdata Interface"; |
245 | } | 245 | } |
246 | 246 | ||
247 | /// <summary> | 247 | /// <summary> |
248 | /// Database provider version | 248 | /// Database provider version |
249 | /// </summary> | 249 | /// </summary> |
250 | /// <returns>provider version</returns> | 250 | /// <returns>provider version</returns> |
251 | public string getVersion() | 251 | public string getVersion() |
252 | { | 252 | { |
253 | return "0.1"; | 253 | return "0.1"; |
254 | } | 254 | } |
255 | } | 255 | } |
256 | } | 256 | } |
diff --git a/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs index 52d6a54..46c0ae0 100644 --- a/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs | |||
@@ -1,33 +1,33 @@ | |||
1 | using System.Reflection; | 1 | using System.Reflection; |
2 | using System.Runtime.InteropServices; | 2 | using System.Runtime.InteropServices; |
3 | // General Information about an assembly is controlled through the following | 3 | // General Information about an assembly is controlled through the following |
4 | // set of attributes. Change these attribute values to modify the information | 4 | // set of attributes. Change these attribute values to modify the information |
5 | // associated with an assembly. | 5 | // associated with an assembly. |
6 | [assembly: AssemblyTitle("OpenSim.Framework.Data.MySQL")] | 6 | [assembly: AssemblyTitle("OpenSim.Framework.Data.MySQL")] |
7 | [assembly: AssemblyDescription("")] | 7 | [assembly: AssemblyDescription("")] |
8 | [assembly: AssemblyConfiguration("")] | 8 | [assembly: AssemblyConfiguration("")] |
9 | [assembly: AssemblyCompany("")] | 9 | [assembly: AssemblyCompany("")] |
10 | [assembly: AssemblyProduct("OpenSim.Framework.Data.MySQL")] | 10 | [assembly: AssemblyProduct("OpenSim.Framework.Data.MySQL")] |
11 | [assembly: AssemblyCopyright("Copyright © 2007")] | 11 | [assembly: AssemblyCopyright("Copyright © 2007")] |
12 | [assembly: AssemblyTrademark("")] | 12 | [assembly: AssemblyTrademark("")] |
13 | [assembly: AssemblyCulture("")] | 13 | [assembly: AssemblyCulture("")] |
14 | 14 | ||
15 | // Setting ComVisible to false makes the types in this assembly not visible | 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 | 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. | 17 | // COM, set the ComVisible attribute to true on that type. |
18 | [assembly: ComVisible(false)] | 18 | [assembly: ComVisible(false)] |
19 | 19 | ||
20 | // The following GUID is for the ID of the typelib if this project is exposed to COM | 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")] | 21 | [assembly: Guid("e49826b2-dcef-41be-a5bd-596733fa3304")] |
22 | 22 | ||
23 | // Version information for an assembly consists of the following four values: | 23 | // Version information for an assembly consists of the following four values: |
24 | // | 24 | // |
25 | // Major Version | 25 | // Major Version |
26 | // Minor Version | 26 | // Minor Version |
27 | // Build Number | 27 | // Build Number |
28 | // Revision | 28 | // Revision |
29 | // | 29 | // |
30 | // You can specify all the values or you can default the Revision and Build Numbers | 30 | // You can specify all the values or you can default the Revision and Build Numbers |
31 | // by using the '*' as shown below: | 31 | // by using the '*' as shown below: |
32 | [assembly: AssemblyVersion("1.0.0.0")] | 32 | [assembly: AssemblyVersion("1.0.0.0")] |
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | 33 | [assembly: AssemblyFileVersion("1.0.0.0")] |