diff options
author | MW | 2007-10-08 10:30:15 +0000 |
---|---|---|
committer | MW | 2007-10-08 10:30:15 +0000 |
commit | 4c25008850f92bcc79502c71a0e4d34c883d27d0 (patch) | |
tree | c5dd571fb11699675c80d363b3261c5be477c018 /OpenSim | |
parent | small bug fix (diff) | |
download | opensim-SC_OLD-4c25008850f92bcc79502c71a0e4d34c883d27d0.zip opensim-SC_OLD-4c25008850f92bcc79502c71a0e4d34c883d27d0.tar.gz opensim-SC_OLD-4c25008850f92bcc79502c71a0e4d34c883d27d0.tar.bz2 opensim-SC_OLD-4c25008850f92bcc79502c71a0e4d34c883d27d0.tar.xz |
Applied patch 485, inventory patch from tleiades (thanks again).
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Communications/InventoryServiceBase.cs | 4 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLGridData.cs | 10 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs | 414 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLManager.cs | 164 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLUserData.cs | 9 | ||||
-rw-r--r-- | OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs | 29 | ||||
-rw-r--r-- | OpenSim/Framework/General/Types/InventoryItemBase.cs | 5 |
8 files changed, 406 insertions, 231 deletions
diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 7536429..366b110 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs | |||
@@ -128,7 +128,7 @@ namespace OpenSim.Framework.Communications | |||
128 | { | 128 | { |
129 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | 129 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) |
130 | { | 130 | { |
131 | plugin.Value.deleteInventoryItem(item); | 131 | plugin.Value.deleteInventoryItem(item.inventoryID); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | 134 | ||
@@ -208,4 +208,4 @@ namespace OpenSim.Framework.Communications | |||
208 | public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); | 208 | public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); |
209 | public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); | 209 | public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); |
210 | } | 210 | } |
211 | } \ No newline at end of file | 211 | } |
diff --git a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs index 452434a..5709bf0 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs | |||
@@ -32,6 +32,8 @@ using System.Security.Cryptography; | |||
32 | using System.Text; | 32 | using System.Text; |
33 | using libsecondlife; | 33 | using libsecondlife; |
34 | 34 | ||
35 | using OpenSim.Framework.Console; | ||
36 | |||
35 | namespace OpenSim.Framework.Data.MySQL | 37 | namespace OpenSim.Framework.Data.MySQL |
36 | { | 38 | { |
37 | /// <summary> | 39 | /// <summary> |
@@ -127,7 +129,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
127 | catch (Exception e) | 129 | catch (Exception e) |
128 | { | 130 | { |
129 | database.Reconnect(); | 131 | database.Reconnect(); |
130 | Console.WriteLine(e.ToString()); | 132 | MainLog.Instance.Error(e.ToString()); |
131 | return null; | 133 | return null; |
132 | } | 134 | } |
133 | } | 135 | } |
@@ -159,7 +161,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
159 | catch (Exception e) | 161 | catch (Exception e) |
160 | { | 162 | { |
161 | database.Reconnect(); | 163 | database.Reconnect(); |
162 | Console.WriteLine(e.ToString()); | 164 | MainLog.Instance.Error(e.ToString()); |
163 | return null; | 165 | return null; |
164 | } | 166 | } |
165 | } | 167 | } |
@@ -191,7 +193,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
191 | catch (Exception e) | 193 | catch (Exception e) |
192 | { | 194 | { |
193 | database.Reconnect(); | 195 | database.Reconnect(); |
194 | Console.WriteLine(e.ToString()); | 196 | MainLog.Instance.Error(e.ToString()); |
195 | return null; | 197 | return null; |
196 | } | 198 | } |
197 | } | 199 | } |
@@ -277,7 +279,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
277 | catch (Exception e) | 279 | catch (Exception e) |
278 | { | 280 | { |
279 | database.Reconnect(); | 281 | database.Reconnect(); |
280 | Console.WriteLine(e.ToString()); | 282 | MainLog.Instance.Error(e.ToString()); |
281 | return null; | 283 | return null; |
282 | } | 284 | } |
283 | } | 285 | } |
diff --git a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs index 478e8b5..804fd5f 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs | |||
@@ -26,22 +26,26 @@ | |||
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.IO; |
30 | using System.Data; | 30 | using System.Data; |
31 | using System.Reflection; | ||
32 | using System.Collections.Generic; | ||
31 | using libsecondlife; | 33 | using libsecondlife; |
32 | using OpenSim.Framework.Types; | 34 | using OpenSim.Framework.Types; |
35 | using OpenSim.Framework.Console; | ||
36 | using MySql.Data.MySqlClient; | ||
33 | 37 | ||
34 | namespace OpenSim.Framework.Data.MySQL | 38 | namespace OpenSim.Framework.Data.MySQL |
35 | { | 39 | { |
36 | /// <summary> | 40 | /// <summary> |
37 | /// A MySQL interface for the inventory server | 41 | /// A MySQL interface for the inventory server |
38 | /// </summary> | 42 | /// </summary> |
39 | class MySQLInventoryData : IInventoryData | 43 | public class MySQLInventoryData : IInventoryData |
40 | { | 44 | { |
41 | /// <summary> | 45 | /// <summary> |
42 | /// The database manager | 46 | /// The database manager |
43 | /// </summary> | 47 | /// </summary> |
44 | public MySQLManager database; | 48 | private MySQLManager database; |
45 | 49 | ||
46 | /// <summary> | 50 | /// <summary> |
47 | /// Loads and initialises this database plugin | 51 | /// Loads and initialises this database plugin |
@@ -57,8 +61,101 @@ namespace OpenSim.Framework.Data.MySQL | |||
57 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); | 61 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); |
58 | 62 | ||
59 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); | 63 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); |
64 | TestTables(database.Connection); | ||
60 | } | 65 | } |
61 | 66 | ||
67 | #region Test and initialization code | ||
68 | /// <summary> | ||
69 | /// Extract a named string resource from the embedded resources | ||
70 | /// </summary> | ||
71 | /// <param name="name">name of embedded resource</param> | ||
72 | /// <returns>string contained within the embedded resource</returns> | ||
73 | private string getResourceString(string name) | ||
74 | { | ||
75 | Assembly assem = this.GetType().Assembly; | ||
76 | string[] names = assem.GetManifestResourceNames(); | ||
77 | |||
78 | foreach(string s in names) | ||
79 | if(s.EndsWith(name)) | ||
80 | using (Stream resource = assem.GetManifestResourceStream(s)) | ||
81 | { | ||
82 | using (StreamReader resourceReader = new StreamReader(resource)) | ||
83 | { | ||
84 | string resourceString = resourceReader.ReadToEnd(); | ||
85 | return resourceString; | ||
86 | } | ||
87 | } | ||
88 | throw new Exception(string.Format("Resource '{0}' was not found", name)); | ||
89 | } | ||
90 | |||
91 | private void ExecuteResourceSql(MySqlConnection conn, string name) | ||
92 | { | ||
93 | MySqlCommand cmd = new MySqlCommand(getResourceString(name), conn); | ||
94 | cmd.ExecuteNonQuery(); | ||
95 | } | ||
96 | |||
97 | private void UpgradeFoldersTable(MySqlConnection conn, string oldVersion) | ||
98 | { | ||
99 | // null as the version, indicates that the table didn't exist | ||
100 | if (oldVersion == null) | ||
101 | { | ||
102 | ExecuteResourceSql(conn, "CreateFoldersTable.sql"); | ||
103 | return; | ||
104 | } | ||
105 | |||
106 | // if the table is already at the current version, then we can exit immediately | ||
107 | if (oldVersion == "Rev. 2") | ||
108 | return; | ||
109 | |||
110 | ExecuteResourceSql(conn, "UpgradeFoldersTableToVersion2.sql"); | ||
111 | } | ||
112 | |||
113 | private void UpgradeItemsTable(MySqlConnection conn, string oldVersion) | ||
114 | { | ||
115 | // null as the version, indicates that the table didn't exist | ||
116 | if (oldVersion == null) | ||
117 | { | ||
118 | ExecuteResourceSql(conn, "CreateItemsTable.sql"); | ||
119 | return; | ||
120 | } | ||
121 | |||
122 | // if the table is already at the current version, then we can exit immediately | ||
123 | if (oldVersion == "Rev. 2") | ||
124 | return; | ||
125 | |||
126 | ExecuteResourceSql(conn, "UpgradeItemsTableToVersion2.sql"); | ||
127 | } | ||
128 | |||
129 | private void TestTables(MySqlConnection conn) | ||
130 | { | ||
131 | |||
132 | Dictionary<string, string> tableList = new Dictionary<string, string>(); | ||
133 | |||
134 | tableList["inventoryfolders"] = null; | ||
135 | tableList["inventoryitems"] = null; | ||
136 | |||
137 | MySqlCommand tablesCmd = new MySqlCommand("SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='opensim'", conn); | ||
138 | MySqlDataReader tables = tablesCmd.ExecuteReader(); | ||
139 | while (tables.Read()) | ||
140 | { | ||
141 | try | ||
142 | { | ||
143 | string tableName = (string)tables["TABLE_NAME"]; | ||
144 | string comment = (string)tables["TABLE_COMMENT"]; | ||
145 | tableList[tableName] = comment; | ||
146 | } | ||
147 | catch (Exception e) | ||
148 | { | ||
149 | MainLog.Instance.Error(e.ToString()); | ||
150 | } | ||
151 | } | ||
152 | tables.Close(); | ||
153 | |||
154 | UpgradeFoldersTable(conn, tableList["inventoryfolders"]); | ||
155 | UpgradeItemsTable(conn, tableList["inventoryitems"]); | ||
156 | } | ||
157 | #endregion | ||
158 | |||
62 | /// <summary> | 159 | /// <summary> |
63 | /// The name of this DB provider | 160 | /// The name of this DB provider |
64 | /// </summary> | 161 | /// </summary> |
@@ -82,7 +179,12 @@ namespace OpenSim.Framework.Data.MySQL | |||
82 | /// <returns>A string containing the DB provider</returns> | 179 | /// <returns>A string containing the DB provider</returns> |
83 | public string getVersion() | 180 | public string getVersion() |
84 | { | 181 | { |
85 | return "0.1"; | 182 | System.Reflection.Module module = this.GetType().Module; |
183 | string dllName = module.Assembly.ManifestModule.Name; | ||
184 | Version dllVersion = module.Assembly.GetName().Version; | ||
185 | |||
186 | |||
187 | return string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, dllVersion.Revision); | ||
86 | } | 188 | } |
87 | 189 | ||
88 | /// <summary> | 190 | /// <summary> |
@@ -96,13 +198,14 @@ namespace OpenSim.Framework.Data.MySQL | |||
96 | { | 198 | { |
97 | lock (database) | 199 | lock (database) |
98 | { | 200 | { |
99 | Dictionary<string, string> param = new Dictionary<string, string>(); | 201 | List<InventoryItemBase> items = new List<InventoryItemBase>(); |
100 | param["?uuid"] = folderID.ToStringHyphenated(); | ||
101 | 202 | ||
102 | IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", param); | 203 | MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", database.Connection); |
103 | IDataReader reader = result.ExecuteReader(); | 204 | result.Parameters.Add("?uuid", folderID.ToStringHyphenated()); |
205 | MySqlDataReader reader = result.ExecuteReader(); | ||
104 | 206 | ||
105 | List<InventoryItemBase> items = database.readInventoryItems(reader); | 207 | while(reader.Read()) |
208 | items.Add(readInventoryItem(reader)); | ||
106 | 209 | ||
107 | reader.Close(); | 210 | reader.Close(); |
108 | result.Dispose(); | 211 | result.Dispose(); |
@@ -113,7 +216,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
113 | catch (Exception e) | 216 | catch (Exception e) |
114 | { | 217 | { |
115 | database.Reconnect(); | 218 | database.Reconnect(); |
116 | Console.WriteLine(e.ToString()); | 219 | MainLog.Instance.Error(e.ToString()); |
117 | return null; | 220 | return null; |
118 | } | 221 | } |
119 | } | 222 | } |
@@ -129,14 +232,15 @@ namespace OpenSim.Framework.Data.MySQL | |||
129 | { | 232 | { |
130 | lock (database) | 233 | lock (database) |
131 | { | 234 | { |
132 | Dictionary<string, string> param = new Dictionary<string, string>(); | 235 | MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", database.Connection); |
133 | param["?uuid"] = user.ToStringHyphenated(); | 236 | result.Parameters.Add("?uuid", user.ToStringHyphenated()); |
134 | param["?zero"] = LLUUID.Zero.ToStringHyphenated(); | 237 | result.Parameters.Add("?zero", LLUUID.Zero.ToStringHyphenated()); |
238 | MySqlDataReader reader = result.ExecuteReader(); | ||
135 | 239 | ||
136 | IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", param); | 240 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); |
137 | IDataReader reader = result.ExecuteReader(); | 241 | while(reader.Read()) |
242 | items.Add(readInventoryFolder(reader)); | ||
138 | 243 | ||
139 | List<InventoryFolderBase> items = database.readInventoryFolders(reader); | ||
140 | 244 | ||
141 | reader.Close(); | 245 | reader.Close(); |
142 | result.Dispose(); | 246 | result.Dispose(); |
@@ -147,7 +251,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
147 | catch (Exception e) | 251 | catch (Exception e) |
148 | { | 252 | { |
149 | database.Reconnect(); | 253 | database.Reconnect(); |
150 | Console.WriteLine(e.ToString()); | 254 | MainLog.Instance.Error(e.ToString()); |
151 | return null; | 255 | return null; |
152 | } | 256 | } |
153 | } | 257 | } |
@@ -167,10 +271,16 @@ namespace OpenSim.Framework.Data.MySQL | |||
167 | param["?uuid"] = user.ToStringHyphenated(); | 271 | param["?uuid"] = user.ToStringHyphenated(); |
168 | param["?zero"] = LLUUID.Zero.ToStringHyphenated(); | 272 | param["?zero"] = LLUUID.Zero.ToStringHyphenated(); |
169 | 273 | ||
170 | IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", param); | 274 | MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", database.Connection); |
171 | IDataReader reader = result.ExecuteReader(); | 275 | result.Parameters.Add("?uuid", user.ToStringHyphenated()); |
276 | result.Parameters.Add("?zero", LLUUID.Zero.ToStringHyphenated()); | ||
277 | |||
278 | MySqlDataReader reader = result.ExecuteReader(); | ||
279 | |||
280 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); | ||
281 | while(reader.Read()) | ||
282 | items.Add(readInventoryFolder(reader)); | ||
172 | 283 | ||
173 | List<InventoryFolderBase> items = database.readInventoryFolders(reader); | ||
174 | InventoryFolderBase rootFolder = items[0]; //should only be one folder with parent set to zero (the root one). | 284 | InventoryFolderBase rootFolder = items[0]; //should only be one folder with parent set to zero (the root one). |
175 | reader.Close(); | 285 | reader.Close(); |
176 | result.Dispose(); | 286 | result.Dispose(); |
@@ -181,7 +291,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
181 | catch (Exception e) | 291 | catch (Exception e) |
182 | { | 292 | { |
183 | database.Reconnect(); | 293 | database.Reconnect(); |
184 | Console.WriteLine(e.ToString()); | 294 | MainLog.Instance.Error(e.ToString()); |
185 | return null; | 295 | return null; |
186 | } | 296 | } |
187 | } | 297 | } |
@@ -197,13 +307,14 @@ namespace OpenSim.Framework.Data.MySQL | |||
197 | { | 307 | { |
198 | lock (database) | 308 | lock (database) |
199 | { | 309 | { |
200 | Dictionary<string, string> param = new Dictionary<string, string>(); | 310 | MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", database.Connection); |
201 | param["?uuid"] = parentID.ToStringHyphenated(); | 311 | result.Parameters.Add("?uuid", parentID.ToStringHyphenated()); |
312 | MySqlDataReader reader = result.ExecuteReader(); | ||
202 | 313 | ||
203 | IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", param); | 314 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); |
204 | IDataReader reader = result.ExecuteReader(); | 315 | |
205 | 316 | while(reader.Read()) | |
206 | List<InventoryFolderBase> items = database.readInventoryFolders(reader); | 317 | items.Add(readInventoryFolder(reader)); |
207 | 318 | ||
208 | reader.Close(); | 319 | reader.Close(); |
209 | result.Dispose(); | 320 | result.Dispose(); |
@@ -214,87 +325,134 @@ namespace OpenSim.Framework.Data.MySQL | |||
214 | catch (Exception e) | 325 | catch (Exception e) |
215 | { | 326 | { |
216 | database.Reconnect(); | 327 | database.Reconnect(); |
217 | Console.WriteLine(e.ToString()); | 328 | MainLog.Instance.Error(e.ToString()); |
218 | return null; | 329 | return null; |
219 | } | 330 | } |
220 | } | 331 | } |
221 | 332 | ||
222 | /// <summary> | 333 | /// <summary> |
334 | /// Reads a one item from an SQL result | ||
335 | /// </summary> | ||
336 | /// <param name="reader">The SQL Result</param> | ||
337 | /// <returns>the item read</returns> | ||
338 | public InventoryItemBase readInventoryItem(MySqlDataReader reader) | ||
339 | { | ||
340 | try | ||
341 | { | ||
342 | InventoryItemBase item = new InventoryItemBase(); | ||
343 | |||
344 | item.inventoryID = new LLUUID((string)reader["inventoryID"]); | ||
345 | item.assetID = new LLUUID((string)reader["assetID"]); | ||
346 | item.assetType = (int)reader["assetType"]; | ||
347 | item.parentFolderID = new LLUUID((string)reader["parentFolderID"]); | ||
348 | item.avatarID = new LLUUID((string)reader["avatarID"]); | ||
349 | item.inventoryName = (string)reader["inventoryName"]; | ||
350 | item.inventoryDescription = (string)reader["inventoryDescription"]; | ||
351 | item.inventoryNextPermissions = (uint)reader["inventoryNextPermissions"]; | ||
352 | item.inventoryCurrentPermissions = (uint)reader["inventoryCurrentPermissions"]; | ||
353 | item.invType = (int)reader["invType"]; | ||
354 | item.creatorsID = new LLUUID((string)reader["creatorID"]); | ||
355 | item.inventoryBasePermissions = (uint)reader["inventoryBasePermissions"]; | ||
356 | item.inventoryEveryOnePermissions = (uint)reader["inventoryEveryOnePermissions"]; | ||
357 | return item; | ||
358 | } | ||
359 | catch (MySqlException e) | ||
360 | { | ||
361 | MainLog.Instance.Error(e.ToString()); | ||
362 | } | ||
363 | |||
364 | return null; | ||
365 | } | ||
366 | |||
367 | /// <summary> | ||
223 | /// Returns a specified inventory item | 368 | /// Returns a specified inventory item |
224 | /// </summary> | 369 | /// </summary> |
225 | /// <param name="item">The item to return</param> | 370 | /// <param name="item">The item to return</param> |
226 | /// <returns>An inventory item</returns> | 371 | /// <returns>An inventory item</returns> |
227 | public InventoryItemBase getInventoryItem(LLUUID item) | 372 | public InventoryItemBase getInventoryItem(LLUUID itemID) |
228 | { | 373 | { |
229 | try | 374 | try |
230 | { | 375 | { |
231 | lock (database) | 376 | lock (database) |
232 | { | 377 | { |
233 | Dictionary<string, string> param = new Dictionary<string, string>(); | 378 | Dictionary<string, string> param = new Dictionary<string, string>(); |
234 | param["?uuid"] = item.ToStringHyphenated(); | ||
235 | 379 | ||
236 | IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", param); | 380 | MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection); |
237 | IDataReader reader = result.ExecuteReader(); | 381 | result.Parameters.Add("?uuid", itemID.ToStringHyphenated()); |
382 | MySqlDataReader reader = result.ExecuteReader(); | ||
238 | 383 | ||
239 | List<InventoryItemBase> items = database.readInventoryItems(reader); | 384 | InventoryItemBase item = null; |
385 | if(reader.Read()) | ||
386 | item = readInventoryItem(reader); | ||
240 | 387 | ||
241 | reader.Close(); | 388 | reader.Close(); |
242 | result.Dispose(); | 389 | result.Dispose(); |
243 | 390 | ||
244 | if (items.Count > 0) | 391 | return item; |
245 | { | ||
246 | return items[0]; | ||
247 | } | ||
248 | else | ||
249 | { | ||
250 | return null; | ||
251 | } | ||
252 | } | 392 | } |
253 | } | 393 | } |
254 | catch (Exception e) | 394 | catch (Exception e) |
255 | { | 395 | { |
256 | database.Reconnect(); | 396 | database.Reconnect(); |
257 | Console.WriteLine(e.ToString()); | 397 | MainLog.Instance.Error(e.ToString()); |
258 | return null; | ||
259 | } | 398 | } |
399 | return null; | ||
260 | } | 400 | } |
261 | 401 | ||
262 | /// <summary> | 402 | /// <summary> |
403 | /// Reads a list of inventory folders returned by a query. | ||
404 | /// </summary> | ||
405 | /// <param name="reader">A MySQL Data Reader</param> | ||
406 | /// <returns>A List containing inventory folders</returns> | ||
407 | protected InventoryFolderBase readInventoryFolder(MySqlDataReader reader) | ||
408 | { | ||
409 | try | ||
410 | { | ||
411 | InventoryFolderBase folder = new InventoryFolderBase(); | ||
412 | folder.agentID = new LLUUID((string)reader["agentID"]); | ||
413 | folder.parentID = new LLUUID((string)reader["parentFolderID"]); | ||
414 | folder.folderID = new LLUUID((string)reader["folderID"]); | ||
415 | folder.name = (string)reader["folderName"]; | ||
416 | folder.type = (short)reader["type"]; | ||
417 | folder.version = (ushort)((int)reader["version"]); | ||
418 | return folder; | ||
419 | } | ||
420 | catch (Exception e) | ||
421 | { | ||
422 | MainLog.Instance.Error(e.ToString()); | ||
423 | } | ||
424 | |||
425 | return null; | ||
426 | } | ||
427 | |||
428 | |||
429 | /// <summary> | ||
263 | /// Returns a specified inventory folder | 430 | /// Returns a specified inventory folder |
264 | /// </summary> | 431 | /// </summary> |
265 | /// <param name="folder">The folder to return</param> | 432 | /// <param name="folder">The folder to return</param> |
266 | /// <returns>A folder class</returns> | 433 | /// <returns>A folder class</returns> |
267 | public InventoryFolderBase getInventoryFolder(LLUUID folder) | 434 | public InventoryFolderBase getInventoryFolder(LLUUID folderID) |
268 | { | 435 | { |
269 | try | 436 | try |
270 | { | 437 | { |
271 | lock (database) | 438 | lock (database) |
272 | { | 439 | { |
273 | Dictionary<string, string> param = new Dictionary<string, string>(); | 440 | MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection); |
274 | param["?uuid"] = folder.ToStringHyphenated(); | 441 | result.Parameters.Add("?uuid", folderID.ToStringHyphenated()); |
275 | 442 | MySqlDataReader reader = result.ExecuteReader(); | |
276 | IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", param); | ||
277 | IDataReader reader = result.ExecuteReader(); | ||
278 | |||
279 | List<InventoryFolderBase> items = database.readInventoryFolders(reader); | ||
280 | 443 | ||
444 | reader.Read(); | ||
445 | InventoryFolderBase folder = readInventoryFolder(reader); | ||
281 | reader.Close(); | 446 | reader.Close(); |
282 | result.Dispose(); | 447 | result.Dispose(); |
283 | 448 | ||
284 | if (items.Count > 0) | 449 | return folder; |
285 | { | ||
286 | return items[0]; | ||
287 | } | ||
288 | else | ||
289 | { | ||
290 | return null; | ||
291 | } | ||
292 | } | 450 | } |
293 | } | 451 | } |
294 | catch (Exception e) | 452 | catch (Exception e) |
295 | { | 453 | { |
296 | database.Reconnect(); | 454 | database.Reconnect(); |
297 | Console.WriteLine(e.ToString()); | 455 | MainLog.Instance.Error(e.ToString()); |
298 | return null; | 456 | return null; |
299 | } | 457 | } |
300 | } | 458 | } |
@@ -305,9 +463,31 @@ namespace OpenSim.Framework.Data.MySQL | |||
305 | /// <param name="item">The inventory item</param> | 463 | /// <param name="item">The inventory item</param> |
306 | public void addInventoryItem(InventoryItemBase item) | 464 | public void addInventoryItem(InventoryItemBase item) |
307 | { | 465 | { |
308 | lock (database) | 466 | string sql = "REPLACE INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType, creatorID, inventoryBasePermissions, inventoryEveryOnePermissions) VALUES "; |
467 | sql += "(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription, ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID, ?inventoryBasePermissions, ?inventoryEveryOnePermissions)"; | ||
468 | |||
469 | try | ||
309 | { | 470 | { |
310 | database.insertItem(item); | 471 | MySqlCommand result = new MySqlCommand(sql, database.Connection); |
472 | result.Parameters.Add("?inventoryID", item.inventoryID.ToStringHyphenated()); | ||
473 | result.Parameters.Add("?assetID", item.assetID.ToStringHyphenated()); | ||
474 | result.Parameters.Add("?assetType", item.assetType.ToString()); | ||
475 | result.Parameters.Add("?parentFolderID", item.parentFolderID.ToStringHyphenated()); | ||
476 | result.Parameters.Add("?avatarID", item.avatarID.ToStringHyphenated()); | ||
477 | result.Parameters.Add("?inventoryName", item.inventoryName); | ||
478 | result.Parameters.Add("?inventoryDescription", item.inventoryDescription); | ||
479 | result.Parameters.Add("?inventoryNextPermissions", item.inventoryNextPermissions.ToString()); | ||
480 | result.Parameters.Add("?inventoryCurrentPermissions", item.inventoryCurrentPermissions.ToString()); | ||
481 | result.Parameters.Add("?invType", item.invType); | ||
482 | result.Parameters.Add("?creatorID", item.creatorsID.ToStringHyphenated()); | ||
483 | result.Parameters.Add("?inventoryBasePermissions", item.inventoryBasePermissions); | ||
484 | result.Parameters.Add("?inventoryEveryOnePermissions", item.inventoryEveryOnePermissions); | ||
485 | result.ExecuteNonQuery(); | ||
486 | result.Dispose(); | ||
487 | } | ||
488 | catch (MySqlException e) | ||
489 | { | ||
490 | MainLog.Instance.Error(e.ToString()); | ||
311 | } | 491 | } |
312 | } | 492 | } |
313 | 493 | ||
@@ -324,9 +504,19 @@ namespace OpenSim.Framework.Data.MySQL | |||
324 | /// | 504 | /// |
325 | /// </summary> | 505 | /// </summary> |
326 | /// <param name="item"></param> | 506 | /// <param name="item"></param> |
327 | public void deleteInventoryItem(InventoryItemBase item) | 507 | public void deleteInventoryItem(LLUUID itemID) |
328 | { | 508 | { |
329 | 509 | try | |
510 | { | ||
511 | MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", database.Connection); | ||
512 | cmd.Parameters.Add("?uuid", itemID.ToStringHyphenated()); | ||
513 | cmd.ExecuteNonQuery(); | ||
514 | } | ||
515 | catch (MySqlException e) | ||
516 | { | ||
517 | database.Reconnect(); | ||
518 | MainLog.Instance.Error(e.ToString()); | ||
519 | } | ||
330 | } | 520 | } |
331 | 521 | ||
332 | /// <summary> | 522 | /// <summary> |
@@ -335,9 +525,24 @@ namespace OpenSim.Framework.Data.MySQL | |||
335 | /// <param name="folder">Folder to create</param> | 525 | /// <param name="folder">Folder to create</param> |
336 | public void addInventoryFolder(InventoryFolderBase folder) | 526 | public void addInventoryFolder(InventoryFolderBase folder) |
337 | { | 527 | { |
338 | lock (database) | 528 | string sql = "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version) VALUES "; |
529 | sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName, ?type, ?version)"; | ||
530 | |||
531 | MySqlCommand cmd = new MySqlCommand(sql, database.Connection); | ||
532 | cmd.Parameters.Add("?folderID", folder.folderID.ToStringHyphenated()); | ||
533 | cmd.Parameters.Add("?agentID", folder.agentID.ToStringHyphenated()); | ||
534 | cmd.Parameters.Add("?parentFolderID", folder.parentID.ToStringHyphenated()); | ||
535 | cmd.Parameters.Add("?folderName", folder.name); | ||
536 | cmd.Parameters.Add("?type", (short)folder.type); | ||
537 | cmd.Parameters.Add("?version", folder.version); | ||
538 | |||
539 | try | ||
540 | { | ||
541 | cmd.ExecuteNonQuery(); | ||
542 | } | ||
543 | catch (Exception e) | ||
339 | { | 544 | { |
340 | database.insertFolder(folder); | 545 | MainLog.Instance.Error(e.ToString()); |
341 | } | 546 | } |
342 | } | 547 | } |
343 | 548 | ||
@@ -352,11 +557,86 @@ namespace OpenSim.Framework.Data.MySQL | |||
352 | 557 | ||
353 | 558 | ||
354 | /// <summary> | 559 | /// <summary> |
560 | /// Append a list of all the child folders of a parent folder | ||
561 | /// </summary> | ||
562 | /// <param name="folders">list where folders will be appended</param> | ||
563 | /// <param name="parentID">ID of parent</param> | ||
564 | protected void getInventoryFolders(ref List<InventoryFolderBase> folders, LLUUID parentID) | ||
565 | { | ||
566 | List<InventoryFolderBase> subfolderList = getInventoryFolders(parentID); | ||
567 | |||
568 | foreach (InventoryFolderBase f in subfolderList) | ||
569 | folders.Add(f); | ||
570 | } | ||
571 | |||
572 | /// <summary> | ||
573 | /// Returns all child folders in the hierarchy from the parent folder and down | ||
574 | /// </summary> | ||
575 | /// <param name="parentID">The folder to get subfolders for</param> | ||
576 | /// <returns>A list of inventory folders</returns> | ||
577 | protected List<InventoryFolderBase> getFolderHierarchy(LLUUID parentID) | ||
578 | { | ||
579 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); | ||
580 | getInventoryFolders(ref folders, parentID); | ||
581 | |||
582 | for (int i = 0; i < folders.Count; i++) | ||
583 | getInventoryFolders(ref folders, folders[i].folderID); | ||
584 | |||
585 | return folders; | ||
586 | } | ||
587 | |||
588 | protected void deleteOneFolder(LLUUID folderID) | ||
589 | { | ||
590 | try | ||
591 | { | ||
592 | MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection); | ||
593 | cmd.Parameters.Add("?uuid", folderID.ToStringHyphenated()); | ||
594 | cmd.ExecuteNonQuery(); | ||
595 | } | ||
596 | catch (MySqlException e) | ||
597 | { | ||
598 | database.Reconnect(); | ||
599 | MainLog.Instance.Error(e.ToString()); | ||
600 | } | ||
601 | } | ||
602 | |||
603 | protected void deleteItemsInFolder(LLUUID folderID) | ||
604 | { | ||
605 | try | ||
606 | { | ||
607 | MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection); | ||
608 | cmd.Parameters.Add("?uuid", folderID.ToStringHyphenated()); | ||
609 | cmd.ExecuteNonQuery(); | ||
610 | } | ||
611 | catch (MySqlException e) | ||
612 | { | ||
613 | database.Reconnect(); | ||
614 | MainLog.Instance.Error(e.ToString()); | ||
615 | } | ||
616 | } | ||
617 | |||
618 | |||
619 | /// <summary> | ||
355 | /// Delete an inventory folder | 620 | /// Delete an inventory folder |
356 | /// </summary> | 621 | /// </summary> |
357 | /// <param name="folderId">Id of folder to delete</param> | 622 | /// <param name="folderId">Id of folder to delete</param> |
358 | public void deleteInventoryFolder(LLUUID folderID) | 623 | public void deleteInventoryFolder(LLUUID folderID) |
359 | { | 624 | { |
625 | lock (database) | ||
626 | { | ||
627 | List<InventoryFolderBase> subFolders = getFolderHierarchy(folderID); | ||
628 | |||
629 | //Delete all sub-folders | ||
630 | foreach (InventoryFolderBase f in subFolders) | ||
631 | { | ||
632 | deleteOneFolder(f.folderID); | ||
633 | deleteItemsInFolder(f.folderID); | ||
634 | } | ||
635 | |||
636 | //Delete the actual row | ||
637 | deleteOneFolder(folderID); | ||
638 | deleteItemsInFolder(folderID); | ||
639 | } | ||
360 | } | 640 | } |
361 | } | 641 | } |
362 | } | 642 | } |
diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs index a83ee45..ea174b2 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs | |||
@@ -31,6 +31,7 @@ using System.Data; | |||
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | using MySql.Data.MySqlClient; | 32 | using MySql.Data.MySqlClient; |
33 | using OpenSim.Framework.Types; | 33 | using OpenSim.Framework.Types; |
34 | using OpenSim.Framework.Console; | ||
34 | 35 | ||
35 | namespace OpenSim.Framework.Data.MySQL | 36 | namespace OpenSim.Framework.Data.MySQL |
36 | { | 37 | { |
@@ -42,7 +43,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
42 | /// <summary> | 43 | /// <summary> |
43 | /// The database connection object | 44 | /// The database connection object |
44 | /// </summary> | 45 | /// </summary> |
45 | IDbConnection dbcon; | 46 | MySqlConnection dbcon; |
46 | /// <summary> | 47 | /// <summary> |
47 | /// Connection string for ADO.net | 48 | /// Connection string for ADO.net |
48 | /// </summary> | 49 | /// </summary> |
@@ -65,7 +66,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
65 | 66 | ||
66 | dbcon.Open(); | 67 | dbcon.Open(); |
67 | 68 | ||
68 | Console.WriteLine("MySQL connection established"); | 69 | MainLog.Instance.Verbose("MySQL connection established"); |
69 | } | 70 | } |
70 | catch (Exception e) | 71 | catch (Exception e) |
71 | { | 72 | { |
@@ -74,6 +75,14 @@ namespace OpenSim.Framework.Data.MySQL | |||
74 | } | 75 | } |
75 | 76 | ||
76 | /// <summary> | 77 | /// <summary> |
78 | /// Get the connection being used | ||
79 | /// </summary> | ||
80 | public MySqlConnection Connection | ||
81 | { | ||
82 | get { return dbcon; } | ||
83 | } | ||
84 | |||
85 | /// <summary> | ||
77 | /// Shuts down the database connection | 86 | /// Shuts down the database connection |
78 | /// </summary> | 87 | /// </summary> |
79 | public void Close() | 88 | public void Close() |
@@ -99,7 +108,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
99 | } | 108 | } |
100 | catch (Exception e) | 109 | catch (Exception e) |
101 | { | 110 | { |
102 | Console.WriteLine("Unable to reconnect to database " + e.ToString()); | 111 | MainLog.Instance.Error("Unable to reconnect to database " + e.ToString()); |
103 | } | 112 | } |
104 | } | 113 | } |
105 | } | 114 | } |
@@ -142,7 +151,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
142 | } | 151 | } |
143 | catch (Exception e) | 152 | catch (Exception e) |
144 | { | 153 | { |
145 | Console.WriteLine("Unable to reconnect to database " + e.ToString()); | 154 | MainLog.Instance.Error("Unable to reconnect to database " + e.ToString()); |
146 | } | 155 | } |
147 | 156 | ||
148 | // Run the query again | 157 | // Run the query again |
@@ -160,7 +169,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
160 | catch (Exception e) | 169 | catch (Exception e) |
161 | { | 170 | { |
162 | // Return null if it fails. | 171 | // Return null if it fails. |
163 | Console.WriteLine("Failed during Query generation: " + e.ToString()); | 172 | MainLog.Instance.Error("Failed during Query generation: " + e.ToString()); |
164 | return null; | 173 | return null; |
165 | } | 174 | } |
166 | } | 175 | } |
@@ -352,72 +361,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
352 | return retval; | 361 | return retval; |
353 | } | 362 | } |
354 | 363 | ||
355 | /// <summary> | ||
356 | /// Reads a list of inventory folders returned by a query. | ||
357 | /// </summary> | ||
358 | /// <param name="reader">A MySQL Data Reader</param> | ||
359 | /// <returns>A List containing inventory folders</returns> | ||
360 | public List<InventoryFolderBase> readInventoryFolders(IDataReader reader) | ||
361 | { | ||
362 | List<InventoryFolderBase> rows = new List<InventoryFolderBase>(); | ||
363 | |||
364 | while(reader.Read()) | ||
365 | { | ||
366 | try | ||
367 | { | ||
368 | InventoryFolderBase folder = new InventoryFolderBase(); | ||
369 | |||
370 | folder.agentID = new LLUUID((string)reader["agentID"]); | ||
371 | folder.parentID = new LLUUID((string)reader["parentFolderID"]); | ||
372 | folder.folderID = new LLUUID((string)reader["folderID"]); | ||
373 | folder.name = (string)reader["folderName"]; | ||
374 | |||
375 | rows.Add(folder); | ||
376 | } | ||
377 | catch (Exception e) | ||
378 | { | ||
379 | Console.WriteLine(e.ToString()); | ||
380 | } | ||
381 | } | ||
382 | |||
383 | return rows; | ||
384 | } | ||
385 | |||
386 | /// <summary> | ||
387 | /// Reads a collection of items from an SQL result | ||
388 | /// </summary> | ||
389 | /// <param name="reader">The SQL Result</param> | ||
390 | /// <returns>A List containing Inventory Items</returns> | ||
391 | public List<InventoryItemBase> readInventoryItems(IDataReader reader) | ||
392 | { | ||
393 | List<InventoryItemBase> rows = new List<InventoryItemBase>(); | ||
394 | 364 | ||
395 | while (reader.Read()) | ||
396 | { | ||
397 | try | ||
398 | { | ||
399 | InventoryItemBase item = new InventoryItemBase(); | ||
400 | |||
401 | item.assetID = new LLUUID((string)reader["assetID"]); | ||
402 | item.avatarID = new LLUUID((string)reader["avatarID"]); | ||
403 | item.inventoryCurrentPermissions = Convert.ToUInt32(reader["inventoryCurrentPermissions"].ToString()); | ||
404 | item.inventoryDescription = (string)reader["inventoryDescription"]; | ||
405 | item.inventoryID = new LLUUID((string)reader["inventoryID"]); | ||
406 | item.inventoryName = (string)reader["inventoryName"]; | ||
407 | item.inventoryNextPermissions = Convert.ToUInt32(reader["inventoryNextPermissions"].ToString()); | ||
408 | item.parentFolderID = new LLUUID((string)reader["parentFolderID"]); | ||
409 | item.assetType = Convert.ToInt32(reader["type"].ToString()); | ||
410 | |||
411 | rows.Add(item); | ||
412 | } | ||
413 | catch (Exception e) | ||
414 | { | ||
415 | Console.WriteLine(e.ToString()); | ||
416 | } | ||
417 | } | ||
418 | |||
419 | return rows; | ||
420 | } | ||
421 | 365 | ||
422 | /// <summary> | 366 | /// <summary> |
423 | /// Inserts a new row into the log database | 367 | /// Inserts a new row into the log database |
@@ -455,87 +399,13 @@ namespace OpenSim.Framework.Data.MySQL | |||
455 | } | 399 | } |
456 | catch (Exception e) | 400 | catch (Exception e) |
457 | { | 401 | { |
458 | Console.WriteLine(e.ToString()); | 402 | MainLog.Instance.Error(e.ToString()); |
459 | return false; | ||
460 | } | ||
461 | |||
462 | return returnval; | ||
463 | } | ||
464 | |||
465 | /// <summary> | ||
466 | /// Inserts a new item into the database | ||
467 | /// </summary> | ||
468 | /// <param name="item">The item</param> | ||
469 | /// <returns>Success?</returns> | ||
470 | public bool insertItem(InventoryItemBase item) | ||
471 | { | ||
472 | string sql = "REPLACE INTO inventoryitems (inventoryID, assetID, type, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions) VALUES "; | ||
473 | sql += "(?inventoryID, ?assetID, ?type, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription, ?inventoryNextPermissions, ?inventoryCurrentPermissions)"; | ||
474 | |||
475 | Dictionary<string, string> parameters = new Dictionary<string, string>(); | ||
476 | parameters["?inventoryID"] = item.inventoryID.ToStringHyphenated(); | ||
477 | parameters["?assetID"] = item.assetID.ToStringHyphenated(); | ||
478 | parameters["?type"] = item.assetType.ToString(); | ||
479 | parameters["?parentFolderID"] = item.parentFolderID.ToStringHyphenated(); | ||
480 | parameters["?avatarID"] = item.avatarID.ToStringHyphenated(); | ||
481 | parameters["?inventoryName"] = item.inventoryName; | ||
482 | parameters["?inventoryDescription"] = item.inventoryDescription; | ||
483 | parameters["?inventoryNextPermissions"] = item.inventoryNextPermissions.ToString(); | ||
484 | parameters["?inventoryCurrentPermissions"] = item.inventoryCurrentPermissions.ToString(); | ||
485 | |||
486 | bool returnval = false; | ||
487 | |||
488 | try | ||
489 | { | ||
490 | IDbCommand result = Query(sql, parameters); | ||
491 | |||
492 | if (result.ExecuteNonQuery() == 1) | ||
493 | returnval = true; | ||
494 | |||
495 | result.Dispose(); | ||
496 | } | ||
497 | catch (Exception e) | ||
498 | { | ||
499 | Console.WriteLine(e.ToString()); | ||
500 | return false; | 403 | return false; |
501 | } | 404 | } |
502 | 405 | ||
503 | return returnval; | 406 | return returnval; |
504 | } | 407 | } |
505 | 408 | ||
506 | /// <summary> | ||
507 | /// Inserts a new folder into the database | ||
508 | /// </summary> | ||
509 | /// <param name="folder">The folder</param> | ||
510 | /// <returns>Success?</returns> | ||
511 | public bool insertFolder(InventoryFolderBase folder) | ||
512 | { | ||
513 | string sql = "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName) VALUES "; | ||
514 | sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName)"; | ||
515 | |||
516 | Dictionary<string, string> parameters = new Dictionary<string, string>(); | ||
517 | parameters["?folderID"] = folder.folderID.ToStringHyphenated(); | ||
518 | parameters["?agentID"] = folder.agentID.ToStringHyphenated(); | ||
519 | parameters["?parentFolderID"] = folder.parentID.ToStringHyphenated(); | ||
520 | parameters["?folderName"] = folder.name; | ||
521 | |||
522 | bool returnval = false; | ||
523 | try | ||
524 | { | ||
525 | IDbCommand result = Query(sql, parameters); | ||
526 | |||
527 | if (result.ExecuteNonQuery() == 1) | ||
528 | returnval = true; | ||
529 | |||
530 | result.Dispose(); | ||
531 | } | ||
532 | catch (Exception e) | ||
533 | { | ||
534 | Console.WriteLine(e.ToString()); | ||
535 | return false; | ||
536 | } | ||
537 | return returnval; | ||
538 | } | ||
539 | 409 | ||
540 | /// <summary> | 410 | /// <summary> |
541 | /// Creates a new user and inserts it into the database | 411 | /// Creates a new user and inserts it into the database |
@@ -614,7 +484,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
614 | } | 484 | } |
615 | catch (Exception e) | 485 | catch (Exception e) |
616 | { | 486 | { |
617 | Console.WriteLine(e.ToString()); | 487 | MainLog.Instance.Error(e.ToString()); |
618 | return false; | 488 | return false; |
619 | } | 489 | } |
620 | 490 | ||
@@ -683,7 +553,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
683 | } | 553 | } |
684 | catch (Exception e) | 554 | catch (Exception e) |
685 | { | 555 | { |
686 | Console.WriteLine(e.ToString()); | 556 | MainLog.Instance.Error(e.ToString()); |
687 | return false; | 557 | return false; |
688 | } | 558 | } |
689 | 559 | ||
diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs index 301550f..915f54b 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs | |||
@@ -30,6 +30,7 @@ using System.Collections.Generic; | |||
30 | using System.Data; | 30 | using System.Data; |
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | using OpenSim.Framework.Types; | 32 | using OpenSim.Framework.Types; |
33 | using OpenSim.Framework.Console; | ||
33 | 34 | ||
34 | namespace OpenSim.Framework.Data.MySQL | 35 | namespace OpenSim.Framework.Data.MySQL |
35 | { | 36 | { |
@@ -101,7 +102,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
101 | catch (Exception e) | 102 | catch (Exception e) |
102 | { | 103 | { |
103 | database.Reconnect(); | 104 | database.Reconnect(); |
104 | Console.WriteLine(e.ToString()); | 105 | MainLog.Instance.Error(e.ToString()); |
105 | return null; | 106 | return null; |
106 | } | 107 | } |
107 | } | 108 | } |
@@ -134,7 +135,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
134 | catch (Exception e) | 135 | catch (Exception e) |
135 | { | 136 | { |
136 | database.Reconnect(); | 137 | database.Reconnect(); |
137 | Console.WriteLine(e.ToString()); | 138 | MainLog.Instance.Error(e.ToString()); |
138 | return null; | 139 | return null; |
139 | } | 140 | } |
140 | } | 141 | } |
@@ -189,7 +190,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
189 | catch (Exception e) | 190 | catch (Exception e) |
190 | { | 191 | { |
191 | database.Reconnect(); | 192 | database.Reconnect(); |
192 | Console.WriteLine(e.ToString()); | 193 | MainLog.Instance.Error(e.ToString()); |
193 | return null; | 194 | return null; |
194 | } | 195 | } |
195 | } | 196 | } |
@@ -212,7 +213,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
212 | catch (Exception e) | 213 | catch (Exception e) |
213 | { | 214 | { |
214 | database.Reconnect(); | 215 | database.Reconnect(); |
215 | Console.WriteLine(e.ToString()); | 216 | MainLog.Instance.Error(e.ToString()); |
216 | } | 217 | } |
217 | 218 | ||
218 | } | 219 | } |
diff --git a/OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs index 8136bc1..75bb53d 100644 --- a/OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs | |||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices; | |||
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("0.4.0.0")] |
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | 33 | [assembly: AssemblyFileVersion("1.0.0.0")] |
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs b/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs index 4c9c467..1688b709 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs | |||
@@ -1,6 +1,7 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using System.Reflection; | ||
4 | 5 | ||
5 | using OpenSim.Framework.Console; | 6 | using OpenSim.Framework.Console; |
6 | using OpenSim.Framework.Types; | 7 | using OpenSim.Framework.Types; |
@@ -166,7 +167,12 @@ namespace OpenSim.Framework.Data.SQLite | |||
166 | /// <returns>A string containing the plugin version</returns> | 167 | /// <returns>A string containing the plugin version</returns> |
167 | public string getVersion() | 168 | public string getVersion() |
168 | { | 169 | { |
169 | return "0.1"; | 170 | System.Reflection.Module module = this.GetType().Module; |
171 | string dllName = module.Assembly.ManifestModule.Name; | ||
172 | Version dllVersion = module.Assembly.GetName().Version; | ||
173 | |||
174 | |||
175 | return string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, dllVersion.Revision); | ||
170 | } | 176 | } |
171 | 177 | ||
172 | /// <summary> | 178 | /// <summary> |
@@ -337,11 +343,11 @@ namespace OpenSim.Framework.Data.SQLite | |||
337 | /// | 343 | /// |
338 | /// </summary> | 344 | /// </summary> |
339 | /// <param name="item"></param> | 345 | /// <param name="item"></param> |
340 | public void deleteInventoryItem(InventoryItemBase item) | 346 | public void deleteInventoryItem(LLUUID itemID) |
341 | { | 347 | { |
342 | DataTable inventoryItemTable = ds.Tables["inventoryitems"]; | 348 | DataTable inventoryItemTable = ds.Tables["inventoryitems"]; |
343 | 349 | ||
344 | DataRow inventoryRow = inventoryItemTable.Rows.Find(item.inventoryID); | 350 | DataRow inventoryRow = inventoryItemTable.Rows.Find(itemID); |
345 | if (inventoryRow != null) | 351 | if (inventoryRow != null) |
346 | { | 352 | { |
347 | inventoryRow.Delete(); | 353 | inventoryRow.Delete(); |
@@ -350,6 +356,20 @@ namespace OpenSim.Framework.Data.SQLite | |||
350 | this.invItemsDa.Update(ds, "inventoryitems"); | 356 | this.invItemsDa.Update(ds, "inventoryitems"); |
351 | } | 357 | } |
352 | 358 | ||
359 | |||
360 | /// <summary> | ||
361 | /// Delete all items in the specified folder | ||
362 | /// </summary> | ||
363 | /// <param name="folderId">id of the folder, whose item content should be deleted</param> | ||
364 | //!TODO, this is horribly inefficient, but I don't want to ruin the overall structure of this implementatio | ||
365 | private void deleteItemsInFolder(LLUUID folderId) | ||
366 | { | ||
367 | List<InventoryItemBase> items = getInventoryInFolder(folderId); | ||
368 | |||
369 | foreach(InventoryItemBase i in items) | ||
370 | deleteInventoryItem(i.inventoryID); | ||
371 | } | ||
372 | |||
353 | /// <summary> | 373 | /// <summary> |
354 | /// Adds a new folder specified by folder | 374 | /// Adds a new folder specified by folder |
355 | /// </summary> | 375 | /// </summary> |
@@ -389,6 +409,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
389 | inventoryRow = inventoryFolderTable.Rows.Find(f.folderID); | 409 | inventoryRow = inventoryFolderTable.Rows.Find(f.folderID); |
390 | if (inventoryRow != null) | 410 | if (inventoryRow != null) |
391 | { | 411 | { |
412 | deleteItemsInFolder(f.folderID); | ||
392 | inventoryRow.Delete(); | 413 | inventoryRow.Delete(); |
393 | } | 414 | } |
394 | } | 415 | } |
@@ -397,6 +418,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
397 | inventoryRow = inventoryFolderTable.Rows.Find(folderID); | 418 | inventoryRow = inventoryFolderTable.Rows.Find(folderID); |
398 | if (inventoryRow != null) | 419 | if (inventoryRow != null) |
399 | { | 420 | { |
421 | deleteItemsInFolder(folderID); | ||
400 | inventoryRow.Delete(); | 422 | inventoryRow.Delete(); |
401 | } | 423 | } |
402 | 424 | ||
@@ -554,3 +576,4 @@ namespace OpenSim.Framework.Data.SQLite | |||
554 | } | 576 | } |
555 | 577 | ||
556 | 578 | ||
579 | |||
diff --git a/OpenSim/Framework/General/Types/InventoryItemBase.cs b/OpenSim/Framework/General/Types/InventoryItemBase.cs index 7f59bcc..fed7e50 100644 --- a/OpenSim/Framework/General/Types/InventoryItemBase.cs +++ b/OpenSim/Framework/General/Types/InventoryItemBase.cs | |||
@@ -205,7 +205,7 @@ namespace OpenSim.Framework.Types | |||
205 | /// | 205 | /// |
206 | /// </summary> | 206 | /// </summary> |
207 | /// <param name="item"></param> | 207 | /// <param name="item"></param> |
208 | void deleteInventoryItem(InventoryItemBase item); | 208 | void deleteInventoryItem(LLUUID item); |
209 | 209 | ||
210 | /// <summary> | 210 | /// <summary> |
211 | /// Adds a new folder specified by folder | 211 | /// Adds a new folder specified by folder |
@@ -224,6 +224,5 @@ namespace OpenSim.Framework.Types | |||
224 | /// </summary> | 224 | /// </summary> |
225 | /// <param name="folder">The id of the folder</param> | 225 | /// <param name="folder">The id of the folder</param> |
226 | void deleteInventoryFolder(LLUUID folder); | 226 | void deleteInventoryFolder(LLUUID folder); |
227 | |||
228 | } | 227 | } |
229 | } \ No newline at end of file | 228 | } |