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