diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs | 75 |
1 files changed, 71 insertions, 4 deletions
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs b/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs index 811a355..045fbee 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs | |||
@@ -91,7 +91,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
91 | data.Add("inventoryCurrentPermissions", DbType.Int32); | 91 | data.Add("inventoryCurrentPermissions", DbType.Int32); |
92 | data.Add("inventoryBasePermissions", DbType.Int32); | 92 | data.Add("inventoryBasePermissions", DbType.Int32); |
93 | data.Add("inventoryEveryOnePermissions", DbType.Int32); | 93 | data.Add("inventoryEveryOnePermissions", DbType.Int32); |
94 | 94 | ||
95 | return data; | 95 | return data; |
96 | } | 96 | } |
97 | 97 | ||
@@ -219,6 +219,44 @@ namespace OpenSim.Framework.Data.SQLite | |||
219 | row["version"] = folder.version; | 219 | row["version"] = folder.version; |
220 | } | 220 | } |
221 | 221 | ||
222 | public InventoryItemBase BuildItem(DataRow row) | ||
223 | { | ||
224 | InventoryItemBase item = new InventoryItemBase(); | ||
225 | item.inventoryID = new LLUUID((string)row["UUID"]); | ||
226 | item.assetID = new LLUUID((string)row["assetID"]); | ||
227 | item.assetType = Convert.ToInt32(row["assetType"]); | ||
228 | item.invType = Convert.ToInt32(row["invType"]); | ||
229 | item.parentFolderID = new LLUUID((string)row["parentFolderID"]); | ||
230 | item.avatarID = new LLUUID((string)row["avatarID"]); | ||
231 | item.creatorsID = new LLUUID((string)row["creatorsID"]); | ||
232 | item.inventoryName =(string) row["inventoryName"]; | ||
233 | item.inventoryDescription = (string) row["inventoryDescription"]; | ||
234 | |||
235 | item.inventoryNextPermissions = Convert.ToUInt32(row["inventoryNextPermissions"]); | ||
236 | item.inventoryCurrentPermissions = Convert.ToUInt32(row["inventoryCurrentPermissions"]); | ||
237 | item.inventoryBasePermissions = Convert.ToUInt32(row["inventoryBasePermissions"]); | ||
238 | item.inventoryEveryOnePermissions = Convert.ToUInt32(row["inventoryEveryOnePermissions"]); | ||
239 | return item; | ||
240 | } | ||
241 | |||
242 | private void fillItemRow(DataRow row, InventoryItemBase item) | ||
243 | { | ||
244 | row["UUID"] = item.inventoryID; | ||
245 | row["assetID"] = item.assetID; | ||
246 | row["assetType"] = item.assetType; | ||
247 | row["invType"] = item.invType; | ||
248 | row["parentFolderID"] = item.parentFolderID; | ||
249 | row["avatarID"] = item.avatarID; | ||
250 | row["creatorsID"] = item.creatorsID; | ||
251 | row["inventoryName"] = item.inventoryName; | ||
252 | row["inventoryDescription"] = item.inventoryDescription; | ||
253 | |||
254 | row["inventoryNextPermissions"] = item.inventoryNextPermissions; | ||
255 | row["inventoryCurrentPermissions"] = item.inventoryCurrentPermissions; | ||
256 | row["inventoryBasePermissions"] = item.inventoryBasePermissions; | ||
257 | row["inventoryEveryOnePermissions"] = item.inventoryEveryOnePermissions; | ||
258 | } | ||
259 | |||
222 | private void addFolder(InventoryFolderBase folder) | 260 | private void addFolder(InventoryFolderBase folder) |
223 | { | 261 | { |
224 | DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; | 262 | DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; |
@@ -238,6 +276,24 @@ namespace OpenSim.Framework.Data.SQLite | |||
238 | this.invFoldersDa.Update(ds, "inventoryfolders"); | 276 | this.invFoldersDa.Update(ds, "inventoryfolders"); |
239 | } | 277 | } |
240 | 278 | ||
279 | private void addItem(InventoryItemBase item) | ||
280 | { | ||
281 | DataTable inventoryItemTable = ds.Tables["inventoryitems"]; | ||
282 | |||
283 | DataRow inventoryRow = inventoryItemTable.Rows.Find(item.inventoryID); | ||
284 | if (inventoryRow == null) | ||
285 | { | ||
286 | inventoryRow = inventoryItemTable.NewRow(); | ||
287 | fillItemRow(inventoryRow, item); | ||
288 | inventoryItemTable.Rows.Add(inventoryRow); | ||
289 | } | ||
290 | else | ||
291 | { | ||
292 | fillItemRow(inventoryRow, item); | ||
293 | } | ||
294 | this.invItemsDa.Update(ds, "inventoryitems"); | ||
295 | } | ||
296 | |||
241 | public void Shutdown() | 297 | public void Shutdown() |
242 | { | 298 | { |
243 | // TODO: DataSet commit | 299 | // TODO: DataSet commit |
@@ -275,7 +331,16 @@ namespace OpenSim.Framework.Data.SQLite | |||
275 | /// <returns>A List of InventoryItemBase items</returns> | 331 | /// <returns>A List of InventoryItemBase items</returns> |
276 | public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID) | 332 | public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID) |
277 | { | 333 | { |
278 | return null; | 334 | List<InventoryItemBase> retval = new List<InventoryItemBase>(); |
335 | DataTable inventoryItemTable = ds.Tables["inventoryitems"]; | ||
336 | string selectExp = "parentFolderID = '" + folderID.ToString() + "'"; | ||
337 | DataRow[] rows = inventoryItemTable.Select(selectExp); | ||
338 | foreach (DataRow row in rows) | ||
339 | { | ||
340 | retval.Add(BuildItem(row)); | ||
341 | } | ||
342 | |||
343 | return retval; | ||
279 | } | 344 | } |
280 | 345 | ||
281 | /// <summary> | 346 | /// <summary> |
@@ -297,7 +362,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
297 | { | 362 | { |
298 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); | 363 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); |
299 | DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; | 364 | DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; |
300 | string selectExp = "agentID = '"+ user.ToString()+"' AND parentID = '"+ LLUUID.Zero.ToString()+"'"; | 365 | string selectExp = "agentID = '" + user.ToString() + "' AND parentID = '" + LLUUID.Zero.ToString() + "'"; |
301 | DataRow[] rows = inventoryFolderTable.Select(selectExp); | 366 | DataRow[] rows = inventoryFolderTable.Select(selectExp); |
302 | foreach (DataRow row in rows) | 367 | foreach (DataRow row in rows) |
303 | { | 368 | { |
@@ -339,7 +404,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
339 | { | 404 | { |
340 | folders.Add(this.buildFolder(row)); | 405 | folders.Add(this.buildFolder(row)); |
341 | } | 406 | } |
342 | // System.Console.WriteLine("found " + folders.Count + " inventory folders"); | 407 | // System.Console.WriteLine("found " + folders.Count + " inventory folders"); |
343 | return folders; | 408 | return folders; |
344 | } | 409 | } |
345 | 410 | ||
@@ -369,6 +434,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
369 | /// <param name="item">The item to be created</param> | 434 | /// <param name="item">The item to be created</param> |
370 | public void addInventoryItem(InventoryItemBase item) | 435 | public void addInventoryItem(InventoryItemBase item) |
371 | { | 436 | { |
437 | this.addItem(item); | ||
372 | } | 438 | } |
373 | 439 | ||
374 | /// <summary> | 440 | /// <summary> |
@@ -377,6 +443,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
377 | /// <param name="item">The updated item</param> | 443 | /// <param name="item">The updated item</param> |
378 | public void updateInventoryItem(InventoryItemBase item) | 444 | public void updateInventoryItem(InventoryItemBase item) |
379 | { | 445 | { |
446 | this.addItem(item); | ||
380 | } | 447 | } |
381 | 448 | ||
382 | /// <summary> | 449 | /// <summary> |