aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.SQLite
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs88
1 files changed, 74 insertions, 14 deletions
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs b/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs
index d664e98..4c9c467 100644
--- a/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs
+++ b/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs
@@ -195,7 +195,7 @@ namespace OpenSim.Framework.Data.SQLite
195 /// <returns>A list of folder objects</returns> 195 /// <returns>A list of folder objects</returns>
196 public List<InventoryFolderBase> getUserRootFolders(LLUUID user) 196 public List<InventoryFolderBase> getUserRootFolders(LLUUID user)
197 { 197 {
198 return null; 198 return new List<InventoryFolderBase>();
199 } 199 }
200 200
201 /// <summary> 201 /// <summary>
@@ -235,21 +235,46 @@ namespace OpenSim.Framework.Data.SQLite
235 } 235 }
236 236
237 /// <summary> 237 /// <summary>
238 /// Returns a list of inventory folders contained in the folder 'parentID' 238 /// Append a list of all the child folders of a parent folder
239 /// </summary> 239 /// </summary>
240 /// <param name="parentID">The folder to get subfolders for</param> 240 /// <param name="folders">list where folders will be appended</param>
241 /// <returns>A list of inventory folders</returns> 241 /// <param name="parentID">ID of parent</param>
242 public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID) 242 protected void getInventoryFolders(ref List<InventoryFolderBase> folders, LLUUID parentID)
243 { 243 {
244 List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
245 DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; 244 DataTable inventoryFolderTable = ds.Tables["inventoryfolders"];
246 string selectExp = "parentID = '" + parentID.ToString() + "'"; 245 string selectExp = "parentID = '" + parentID.ToString() + "'";
247 DataRow[] rows = inventoryFolderTable.Select(selectExp); 246 DataRow[] rows = inventoryFolderTable.Select(selectExp);
248 foreach (DataRow row in rows) 247 foreach (DataRow row in rows)
249 { 248 {
250 folders.Add(this.buildFolder(row)); 249 folders.Add(buildFolder(row));
251 } 250 }
252 // System.Console.WriteLine("found " + folders.Count + " inventory folders"); 251 }
252
253 /// <summary>
254 /// Returns a list of inventory folders contained in the folder 'parentID'
255 /// </summary>
256 /// <param name="parentID">The folder to get subfolders for</param>
257 /// <returns>A list of inventory folders</returns>
258 public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID)
259 {
260 List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
261 getInventoryFolders(ref folders, parentID);
262 return folders;
263 }
264
265 /// <summary>
266 /// Returns all child folders in the hierarchy from the parent folder and down
267 /// </summary>
268 /// <param name="parentID">The folder to get subfolders for</param>
269 /// <returns>A list of inventory folders</returns>
270 protected List<InventoryFolderBase> getFolderHierarchy(LLUUID parentID)
271 {
272 List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
273 getInventoryFolders(ref folders, parentID);
274
275 for(int i=0; i<folders.Count; i++)
276 getInventoryFolders(ref folders, folders[i].folderID);
277
253 return folders; 278 return folders;
254 } 279 }
255 280
@@ -282,12 +307,12 @@ namespace OpenSim.Framework.Data.SQLite
282 // that you don't get to see system textures why creating 307 // that you don't get to see system textures why creating
283 // clothes and the like. :( 308 // clothes and the like. :(
284 309
285 // DataRow row = ds.Tables["inventoryfolders"].Rows.Find(folder); 310 DataRow row = ds.Tables["inventoryfolders"].Rows.Find(folder);
286 // if (row != null) { 311 if (row != null) {
287 // return buildFolder(row); 312 return buildFolder(row);
288 // } else { 313 } else {
289 return null; 314 return null;
290 // } 315 }
291 } 316 }
292 317
293 /// <summary> 318 /// <summary>
@@ -344,6 +369,40 @@ namespace OpenSim.Framework.Data.SQLite
344 } 369 }
345 370
346 371
372 /// <summary>
373 /// Delete a folder
374 /// </summary>
375 /// <remarks>
376 /// This will clean-up any child folders and child items as well
377 /// </remarks>
378 /// <param name="item"></param>
379 public void deleteInventoryFolder(LLUUID folderID)
380 {
381 List<InventoryFolderBase> subFolders = getFolderHierarchy(folderID);
382
383 DataTable inventoryFolderTable = ds.Tables["inventoryfolders"];
384 DataRow inventoryRow;
385
386 //Delete all sub-folders
387 foreach (InventoryFolderBase f in subFolders)
388 {
389 inventoryRow = inventoryFolderTable.Rows.Find(f.folderID);
390 if (inventoryRow != null)
391 {
392 inventoryRow.Delete();
393 }
394 }
395
396 //Delete the actual row
397 inventoryRow = inventoryFolderTable.Rows.Find(folderID);
398 if (inventoryRow != null)
399 {
400 inventoryRow.Delete();
401 }
402
403 this.invFoldersDa.Update(ds, "inventoryfolders");
404 }
405
347 /*********************************************************************** 406 /***********************************************************************
348 * 407 *
349 * Data Table definitions 408 * Data Table definitions
@@ -494,3 +553,4 @@ namespace OpenSim.Framework.Data.SQLite
494 } 553 }
495} 554}
496 555
556