aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs')
-rw-r--r--OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs74
1 files changed, 59 insertions, 15 deletions
diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
index 8269d36..3de2330 100644
--- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
@@ -156,9 +156,9 @@ namespace OpenSim.Services.HypergridService
156 if (suitcase == null) 156 if (suitcase == null)
157 { 157 {
158 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder. Creating it...", principalID); 158 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder. Creating it...", principalID);
159 // make one, and let's add it to the user's inventory as a direct child of the root folder 159 // Create the My Suitcase folder under the user's root folder.
160 // In the DB we tag it as type 100, but we use -1 (Unknown) outside 160 // In the DB we tag it as type 100, but we use type 8 (Folder) outside, as this affects the sort order.
161 suitcase = CreateFolder(principalID, root.folderID, 100, "My Suitcase"); 161 suitcase = CreateFolder(principalID, root.folderID, InventoryItemBase.SUITCASE_FOLDER_TYPE, InventoryItemBase.SUITCASE_FOLDER_NAME);
162 if (suitcase == null) 162 if (suitcase == null)
163 { 163 {
164 m_log.ErrorFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to create suitcase folder"); 164 m_log.ErrorFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to create suitcase folder");
@@ -248,7 +248,10 @@ namespace OpenSim.Services.HypergridService
248 InventoryCollection coll = null; 248 InventoryCollection coll = null;
249 249
250 if (!IsWithinSuitcaseTree(principalID, folderID)) 250 if (!IsWithinSuitcaseTree(principalID, folderID))
251 {
252 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderContent: folder {0} is not within Suitcase tree", folderID);
251 return new InventoryCollection(); 253 return new InventoryCollection();
254 }
252 255
253 coll = base.GetFolderContent(principalID, folderID); 256 coll = base.GetFolderContent(principalID, folderID);
254 257
@@ -265,7 +268,10 @@ namespace OpenSim.Services.HypergridService
265 // Let's do a bit of sanity checking, more than the base service does 268 // Let's do a bit of sanity checking, more than the base service does
266 // make sure the given folder exists under the suitcase tree of this user 269 // make sure the given folder exists under the suitcase tree of this user
267 if (!IsWithinSuitcaseTree(principalID, folderID)) 270 if (!IsWithinSuitcaseTree(principalID, folderID))
271 {
272 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderItems: folder {0} is not within Suitcase tree", folderID);
268 return new List<InventoryItemBase>(); 273 return new List<InventoryItemBase>();
274 }
269 275
270 return base.GetFolderItems(principalID, folderID); 276 return base.GetFolderItems(principalID, folderID);
271 } 277 }
@@ -277,7 +283,10 @@ namespace OpenSim.Services.HypergridService
277 // make sure the given folder's parent folder exists under the suitcase tree of this user 283 // make sure the given folder's parent folder exists under the suitcase tree of this user
278 284
279 if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID)) 285 if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID))
286 {
287 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder: folder {0} is not within Suitcase tree", folder.ParentID);
280 return false; 288 return false;
289 }
281 290
282 // OK, it's legit 291 // OK, it's legit
283 if (base.AddFolder(folder)) 292 if (base.AddFolder(folder))
@@ -297,7 +306,7 @@ namespace OpenSim.Services.HypergridService
297 //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version); 306 //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version);
298 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID)) 307 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID))
299 { 308 {
300 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: folder {0} not within Suitcase tree", folder.Name); 309 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: UpdateFolder: folder {0}/{1} is not within Suitcase tree", folder.Name, folder.ID);
301 return false; 310 return false;
302 } 311 }
303 312
@@ -307,9 +316,17 @@ namespace OpenSim.Services.HypergridService
307 316
308 public override bool MoveFolder(InventoryFolderBase folder) 317 public override bool MoveFolder(InventoryFolderBase folder)
309 { 318 {
310 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID) || 319 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID))
311 !IsWithinSuitcaseTree(folder.Owner, folder.ParentID)) 320 {
321 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} is not within Suitcase tree", folder.ID);
312 return false; 322 return false;
323 }
324
325 if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID))
326 {
327 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} is not within Suitcase tree", folder.ParentID);
328 return false;
329 }
313 330
314 return base.MoveFolder(folder); 331 return base.MoveFolder(folder);
315 } 332 }
@@ -331,7 +348,10 @@ namespace OpenSim.Services.HypergridService
331 // Let's do a bit of sanity checking, more than the base service does 348 // Let's do a bit of sanity checking, more than the base service does
332 // make sure the given folder's parent folder exists under the suitcase tree of this user 349 // make sure the given folder's parent folder exists under the suitcase tree of this user
333 if (!IsWithinSuitcaseTree(item.Owner, item.Folder)) 350 if (!IsWithinSuitcaseTree(item.Owner, item.Folder))
351 {
352 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddItem: folder {0} is not within Suitcase tree", item.Folder);
334 return false; 353 return false;
354 }
335 355
336 // OK, it's legit 356 // OK, it's legit
337 return base.AddItem(item); 357 return base.AddItem(item);
@@ -341,7 +361,10 @@ namespace OpenSim.Services.HypergridService
341 public override bool UpdateItem(InventoryItemBase item) 361 public override bool UpdateItem(InventoryItemBase item)
342 { 362 {
343 if (!IsWithinSuitcaseTree(item.Owner, item.Folder)) 363 if (!IsWithinSuitcaseTree(item.Owner, item.Folder))
364 {
365 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: UpdateItem: folder {0} is not within Suitcase tree", item.Folder);
344 return false; 366 return false;
367 }
345 368
346 return base.UpdateItem(item); 369 return base.UpdateItem(item);
347 } 370 }
@@ -350,11 +373,28 @@ namespace OpenSim.Services.HypergridService
350 { 373 {
351 // Principal is b0rked. *sigh* 374 // Principal is b0rked. *sigh*
352 375
353 if (!IsWithinSuitcaseTree(items[0].Owner, items[0].Folder)) 376 // Check the items' destination folders
354 return false; 377 foreach (InventoryItemBase item in items)
378 {
379 if (!IsWithinSuitcaseTree(item.Owner, item.Folder))
380 {
381 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} is not within Suitcase tree", item.Folder);
382 return false;
383 }
384 }
355 385
356 return base.MoveItems(principalID, items); 386 // Check the items' current folders
387 foreach (InventoryItemBase item in items)
388 {
389 InventoryItemBase originalItem = base.GetItem(item);
390 if (!IsWithinSuitcaseTree(originalItem.Owner, originalItem.Folder))
391 {
392 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} is not within Suitcase tree", originalItem.Folder);
393 return false;
394 }
395 }
357 396
397 return base.MoveItems(principalID, items);
358 } 398 }
359 399
360 public override bool DeleteItems(UUID principalID, List<UUID> itemIDs) 400 public override bool DeleteItems(UUID principalID, List<UUID> itemIDs)
@@ -374,8 +414,8 @@ namespace OpenSim.Services.HypergridService
374 414
375 if (!IsWithinSuitcaseTree(it.Owner, it.Folder) && !IsPartOfAppearance(it.Owner, it.ID)) 415 if (!IsWithinSuitcaseTree(it.Owner, it.Folder) && !IsPartOfAppearance(it.Owner, it.ID))
376 { 416 {
377 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase", 417 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0}/{1} (folder {2}) is not within Suitcase tree or Appearance",
378 it.Name, it.Folder); 418 it.Name, it.ID, it.Folder);
379 return null; 419 return null;
380 } 420 }
381 421
@@ -396,7 +436,11 @@ namespace OpenSim.Services.HypergridService
396 if (f != null) 436 if (f != null)
397 { 437 {
398 if (!IsWithinSuitcaseTree(f.Owner, f.ID)) 438 if (!IsWithinSuitcaseTree(f.Owner, f.ID))
439 {
440 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Folder {0}/{1} is not within Suitcase tree",
441 f.Name, f.ID);
399 return null; 442 return null;
443 }
400 } 444 }
401 445
402 return f; 446 return f;
@@ -464,7 +508,7 @@ namespace OpenSim.Services.HypergridService
464 // Warp! Root folder for travelers 508 // Warp! Root folder for travelers
465 XInventoryFolder[] folders = m_Database.GetFolders( 509 XInventoryFolder[] folders = m_Database.GetFolders(
466 new string[] { "agentID", "type" }, 510 new string[] { "agentID", "type" },
467 new string[] { principalID.ToString(), "100" }); // This is a special folder type... 511 new string[] { principalID.ToString(), InventoryItemBase.SUITCASE_FOLDER_TYPE.ToString() }); // This is a special folder type...
468 512
469 if (folders != null && folders.Length > 0) 513 if (folders != null && folders.Length > 0)
470 return folders[0]; 514 return folders[0];
@@ -472,13 +516,13 @@ namespace OpenSim.Services.HypergridService
472 // check to see if we have the old Suitcase folder 516 // check to see if we have the old Suitcase folder
473 folders = m_Database.GetFolders( 517 folders = m_Database.GetFolders(
474 new string[] { "agentID", "folderName", "parentFolderID" }, 518 new string[] { "agentID", "folderName", "parentFolderID" },
475 new string[] { principalID.ToString(), "My Suitcase", UUID.Zero.ToString() }); 519 new string[] { principalID.ToString(), InventoryItemBase.SUITCASE_FOLDER_NAME, UUID.Zero.ToString() });
476 if (folders != null && folders.Length > 0) 520 if (folders != null && folders.Length > 0)
477 { 521 {
478 // Move it to under the root folder 522 // Move it to under the root folder
479 XInventoryFolder root = GetRootXFolder(principalID); 523 XInventoryFolder root = GetRootXFolder(principalID);
480 folders[0].parentFolderID = root.folderID; 524 folders[0].parentFolderID = root.folderID;
481 folders[0].type = 100; 525 folders[0].type = InventoryItemBase.SUITCASE_FOLDER_TYPE;
482 m_Database.StoreFolder(folders[0]); 526 m_Database.StoreFolder(folders[0]);
483 return folders[0]; 527 return folders[0];
484 } 528 }
@@ -488,7 +532,7 @@ namespace OpenSim.Services.HypergridService
488 532
489 private void SetAsNormalFolder(XInventoryFolder suitcase) 533 private void SetAsNormalFolder(XInventoryFolder suitcase)
490 { 534 {
491 suitcase.type = (short)AssetType.Folder; 535 suitcase.type = InventoryItemBase.SUITCASE_FOLDER_FAKE_TYPE;
492 } 536 }
493 537
494 private List<XInventoryFolder> GetFolderTree(UUID principalID, UUID folder) 538 private List<XInventoryFolder> GetFolderTree(UUID principalID, UUID folder)