diff options
Diffstat (limited to 'OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs')
-rw-r--r-- | OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs index 7197049..53ed115 100644 --- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs +++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs | |||
@@ -43,7 +43,7 @@ using Caps = OpenSim.Framework.Capabilities.Caps; | |||
43 | 43 | ||
44 | namespace OpenSim.Capabilities.Handlers | 44 | namespace OpenSim.Capabilities.Handlers |
45 | { | 45 | { |
46 | public class FetchInvDescHandler | 46 | public class FetchInvDescHandler |
47 | { | 47 | { |
48 | private static readonly ILog m_log = | 48 | private static readonly ILog m_log = |
49 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -53,14 +53,14 @@ namespace OpenSim.Capabilities.Handlers | |||
53 | private IScene m_Scene; | 53 | private IScene m_Scene; |
54 | // private object m_fetchLock = new Object(); | 54 | // private object m_fetchLock = new Object(); |
55 | 55 | ||
56 | public FetchInvDescHandler(IInventoryService invService, ILibraryService libService, IScene s) | 56 | public FetchInvDescHandler(IInventoryService invService, ILibraryService libService, IScene s) |
57 | { | 57 | { |
58 | m_InventoryService = invService; | 58 | m_InventoryService = invService; |
59 | m_LibraryService = libService; | 59 | m_LibraryService = libService; |
60 | m_Scene = s; | 60 | m_Scene = s; |
61 | } | 61 | } |
62 | 62 | ||
63 | 63 | ||
64 | public string FetchInventoryDescendentsRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 64 | public string FetchInventoryDescendentsRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
65 | { | 65 | { |
66 | //m_log.DebugFormat("[XXX]: FetchInventoryDescendentsRequest in {0}, {1}", (m_Scene == null) ? "none" : m_Scene.Name, request); | 66 | //m_log.DebugFormat("[XXX]: FetchInventoryDescendentsRequest in {0}, {1}", (m_Scene == null) ? "none" : m_Scene.Name, request); |
@@ -72,14 +72,14 @@ namespace OpenSim.Capabilities.Handlers | |||
72 | // correctly mark it as a uuid | 72 | // correctly mark it as a uuid |
73 | // | 73 | // |
74 | request = request.Replace("<string>00000000-0000-0000-0000-000000000000</string>", "<uuid>00000000-0000-0000-0000-000000000000</uuid>"); | 74 | request = request.Replace("<string>00000000-0000-0000-0000-000000000000</string>", "<uuid>00000000-0000-0000-0000-000000000000</uuid>"); |
75 | 75 | ||
76 | // another hack <integer>1</integer> results in a | 76 | // another hack <integer>1</integer> results in a |
77 | // System.ArgumentException: Object type System.Int32 cannot | 77 | // System.ArgumentException: Object type System.Int32 cannot |
78 | // be converted to target type: System.Boolean | 78 | // be converted to target type: System.Boolean |
79 | // | 79 | // |
80 | request = request.Replace("<key>fetch_folders</key><integer>0</integer>", "<key>fetch_folders</key><boolean>0</boolean>"); | 80 | request = request.Replace("<key>fetch_folders</key><integer>0</integer>", "<key>fetch_folders</key><boolean>0</boolean>"); |
81 | request = request.Replace("<key>fetch_folders</key><integer>1</integer>", "<key>fetch_folders</key><boolean>1</boolean>"); | 81 | request = request.Replace("<key>fetch_folders</key><integer>1</integer>", "<key>fetch_folders</key><boolean>1</boolean>"); |
82 | 82 | ||
83 | Hashtable hash = new Hashtable(); | 83 | Hashtable hash = new Hashtable(); |
84 | try | 84 | try |
85 | { | 85 | { |
@@ -90,9 +90,9 @@ namespace OpenSim.Capabilities.Handlers | |||
90 | m_log.ErrorFormat("[WEB FETCH INV DESC HANDLER]: Fetch error: {0}{1}" + e.Message, e.StackTrace); | 90 | m_log.ErrorFormat("[WEB FETCH INV DESC HANDLER]: Fetch error: {0}{1}" + e.Message, e.StackTrace); |
91 | m_log.Error("Request: " + request); | 91 | m_log.Error("Request: " + request); |
92 | } | 92 | } |
93 | 93 | ||
94 | ArrayList foldersrequested = (ArrayList)hash["folders"]; | 94 | ArrayList foldersrequested = (ArrayList)hash["folders"]; |
95 | 95 | ||
96 | string response = ""; | 96 | string response = ""; |
97 | string bad_folders_response = ""; | 97 | string bad_folders_response = ""; |
98 | 98 | ||
@@ -403,10 +403,7 @@ namespace OpenSim.Capabilities.Handlers | |||
403 | return contents; | 403 | return contents; |
404 | } | 404 | } |
405 | contents = fetchedContents; | 405 | contents = fetchedContents; |
406 | InventoryFolderBase containingFolder = new InventoryFolderBase(); | 406 | InventoryFolderBase containingFolder = m_InventoryService.GetFolder(agentID, folderID); |
407 | containingFolder.ID = folderID; | ||
408 | containingFolder.Owner = agentID; | ||
409 | containingFolder = m_InventoryService.GetFolder(containingFolder); | ||
410 | 407 | ||
411 | if (containingFolder != null) | 408 | if (containingFolder != null) |
412 | { | 409 | { |
@@ -416,7 +413,7 @@ namespace OpenSim.Capabilities.Handlers | |||
416 | 413 | ||
417 | version = containingFolder.Version; | 414 | version = containingFolder.Version; |
418 | 415 | ||
419 | if (fetchItems) | 416 | if (fetchItems && containingFolder.Type != (short)FolderType.Trash) |
420 | { | 417 | { |
421 | List<InventoryItemBase> itemsToReturn = contents.Items; | 418 | List<InventoryItemBase> itemsToReturn = contents.Items; |
422 | List<InventoryItemBase> originalItems = new List<InventoryItemBase>(itemsToReturn); | 419 | List<InventoryItemBase> originalItems = new List<InventoryItemBase>(itemsToReturn); |
@@ -429,7 +426,7 @@ namespace OpenSim.Capabilities.Handlers | |||
429 | { | 426 | { |
430 | if (item.AssetType == (int)AssetType.Link) | 427 | if (item.AssetType == (int)AssetType.Link) |
431 | { | 428 | { |
432 | InventoryItemBase linkedItem = m_InventoryService.GetItem(new InventoryItemBase(item.AssetID)); | 429 | InventoryItemBase linkedItem = m_InventoryService.GetItem(agentID, item.AssetID); |
433 | 430 | ||
434 | // Take care of genuinely broken links where the target doesn't exist | 431 | // Take care of genuinely broken links where the target doesn't exist |
435 | // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate, | 432 | // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate, |
@@ -441,6 +438,10 @@ namespace OpenSim.Capabilities.Handlers | |||
441 | } | 438 | } |
442 | 439 | ||
443 | // Now scan for folder links and insert the items they target and those links at the head of the return data | 440 | // Now scan for folder links and insert the items they target and those links at the head of the return data |
441 | |||
442 | /* dont send contents of LinkFolders. | ||
443 | from docs seems this was never a spec | ||
444 | |||
444 | foreach (InventoryItemBase item in originalItems) | 445 | foreach (InventoryItemBase item in originalItems) |
445 | { | 446 | { |
446 | if (item.AssetType == (int)AssetType.LinkFolder) | 447 | if (item.AssetType == (int)AssetType.LinkFolder) |
@@ -471,6 +472,7 @@ namespace OpenSim.Capabilities.Handlers | |||
471 | } | 472 | } |
472 | } | 473 | } |
473 | } | 474 | } |
475 | */ | ||
474 | } | 476 | } |
475 | 477 | ||
476 | // foreach (InventoryItemBase item in contents.Items) | 478 | // foreach (InventoryItemBase item in contents.Items) |
@@ -514,7 +516,7 @@ namespace OpenSim.Capabilities.Handlers | |||
514 | // } | 516 | // } |
515 | // } | 517 | // } |
516 | // } | 518 | // } |
517 | // | 519 | // |
518 | // foreach (UUID linkedItemFolderId in linkedItemFolderIdsToSend) | 520 | // foreach (UUID linkedItemFolderId in linkedItemFolderIdsToSend) |
519 | // { | 521 | // { |
520 | // m_log.DebugFormat( | 522 | // m_log.DebugFormat( |
@@ -654,10 +656,7 @@ namespace OpenSim.Capabilities.Handlers | |||
654 | // Must fetch it individually | 656 | // Must fetch it individually |
655 | else if (contents.FolderID == UUID.Zero) | 657 | else if (contents.FolderID == UUID.Zero) |
656 | { | 658 | { |
657 | InventoryFolderBase containingFolder = new InventoryFolderBase(); | 659 | InventoryFolderBase containingFolder = m_InventoryService.GetFolder(freq.owner_id, freq.folder_id); |
658 | containingFolder.ID = freq.folder_id; | ||
659 | containingFolder.Owner = freq.owner_id; | ||
660 | containingFolder = m_InventoryService.GetFolder(containingFolder); | ||
661 | 660 | ||
662 | if (containingFolder != null) | 661 | if (containingFolder != null) |
663 | { | 662 | { |
@@ -723,8 +722,8 @@ namespace OpenSim.Capabilities.Handlers | |||
723 | if (item.AssetType == (int)AssetType.Link) | 722 | if (item.AssetType == (int)AssetType.Link) |
724 | itemIDs.Add(item.AssetID); | 723 | itemIDs.Add(item.AssetID); |
725 | 724 | ||
726 | else if (item.AssetType == (int)AssetType.LinkFolder) | 725 | // else if (item.AssetType == (int)AssetType.LinkFolder) |
727 | folderIDs.Add(item.AssetID); | 726 | // folderIDs.Add(item.AssetID); |
728 | } | 727 | } |
729 | 728 | ||
730 | //m_log.DebugFormat("[XXX]: folder {0} has {1} links and {2} linkfolders", contents.FolderID, itemIDs.Count, folderIDs.Count); | 729 | //m_log.DebugFormat("[XXX]: folder {0} has {1} links and {2} linkfolders", contents.FolderID, itemIDs.Count, folderIDs.Count); |
@@ -754,12 +753,9 @@ namespace OpenSim.Capabilities.Handlers | |||
754 | m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: GetMultipleItems failed. Falling back to fetching inventory items one by one."); | 753 | m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: GetMultipleItems failed. Falling back to fetching inventory items one by one."); |
755 | linked = new InventoryItemBase[itemIDs.Count]; | 754 | linked = new InventoryItemBase[itemIDs.Count]; |
756 | int i = 0; | 755 | int i = 0; |
757 | InventoryItemBase item = new InventoryItemBase(); | ||
758 | item.Owner = freq.owner_id; | ||
759 | foreach (UUID id in itemIDs) | 756 | foreach (UUID id in itemIDs) |
760 | { | 757 | { |
761 | item.ID = id; | 758 | linked[i++] = m_InventoryService.GetItem(freq.owner_id, id); |
762 | linked[i++] = m_InventoryService.GetItem(item); | ||
763 | } | 759 | } |
764 | } | 760 | } |
765 | 761 | ||
@@ -845,4 +841,4 @@ namespace OpenSim.Capabilities.Handlers | |||
845 | public InventoryCollection Collection; | 841 | public InventoryCollection Collection; |
846 | public int Descendents; | 842 | public int Descendents; |
847 | } | 843 | } |
848 | } \ No newline at end of file | 844 | } |