diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs | 85 |
1 files changed, 84 insertions, 1 deletions
diff --git a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs index a086c0e..e91a4b8 100644 --- a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs +++ b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs | |||
@@ -181,6 +181,15 @@ namespace OpenSim.Capabilities.Handlers | |||
181 | contents.descendents = contents.items.Array.Count + contents.categories.Array.Count; | 181 | contents.descendents = contents.items.Array.Count + contents.categories.Array.Count; |
182 | contents.version = version; | 182 | contents.version = version; |
183 | 183 | ||
184 | // m_log.DebugFormat( | ||
185 | // "[WEB FETCH INV DESC HANDLER]: Replying to request for folder {0} (fetch items {1}, fetch folders {2}) with {3} items and {4} folders for agent {5}", | ||
186 | // invFetch.folder_id, | ||
187 | // invFetch.fetch_items, | ||
188 | // invFetch.fetch_folders, | ||
189 | // contents.items.Array.Count, | ||
190 | // contents.categories.Array.Count, | ||
191 | // invFetch.owner_id); | ||
192 | |||
184 | return reply; | 193 | return reply; |
185 | } | 194 | } |
186 | 195 | ||
@@ -195,7 +204,7 @@ namespace OpenSim.Capabilities.Handlers | |||
195 | /// <param name="sortOrder"></param> | 204 | /// <param name="sortOrder"></param> |
196 | /// <param name="version"></param> | 205 | /// <param name="version"></param> |
197 | /// <returns>An empty InventoryCollection if the inventory look up failed</returns> | 206 | /// <returns>An empty InventoryCollection if the inventory look up failed</returns> |
198 | public InventoryCollection Fetch( | 207 | private InventoryCollection Fetch( |
199 | UUID agentID, UUID folderID, UUID ownerID, | 208 | UUID agentID, UUID folderID, UUID ownerID, |
200 | bool fetchFolders, bool fetchItems, int sortOrder, out int version) | 209 | bool fetchFolders, bool fetchItems, int sortOrder, out int version) |
201 | { | 210 | { |
@@ -228,8 +237,82 @@ namespace OpenSim.Capabilities.Handlers | |||
228 | containingFolder.ID = folderID; | 237 | containingFolder.ID = folderID; |
229 | containingFolder.Owner = agentID; | 238 | containingFolder.Owner = agentID; |
230 | containingFolder = m_InventoryService.GetFolder(containingFolder); | 239 | containingFolder = m_InventoryService.GetFolder(containingFolder); |
240 | |||
231 | if (containingFolder != null) | 241 | if (containingFolder != null) |
242 | { | ||
232 | version = containingFolder.Version; | 243 | version = containingFolder.Version; |
244 | |||
245 | if (fetchItems) | ||
246 | { | ||
247 | /* | ||
248 | List<InventoryItemBase> linkedItemsToAdd = new List<InventoryItemBase>(); | ||
249 | |||
250 | foreach (InventoryItemBase item in contents.Items) | ||
251 | { | ||
252 | if (item.AssetType == (int)AssetType.Link) | ||
253 | { | ||
254 | InventoryItemBase linkedItem = m_InventoryService.GetItem(new InventoryItemBase(item.AssetID)); | ||
255 | |||
256 | // Take care of genuinely broken links where the target doesn't exist | ||
257 | // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate, | ||
258 | // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles | ||
259 | // rather than having to keep track of every folder requested in the recursion. | ||
260 | if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link && linkedItem.AssetType == (int)AssetType.Object) | ||
261 | linkedItemsToAdd.Add(linkedItem); | ||
262 | } | ||
263 | } | ||
264 | |||
265 | foreach (InventoryItemBase linkedItem in linkedItemsToAdd) | ||
266 | { | ||
267 | m_log.DebugFormat( | ||
268 | "[WEB FETCH INV DESC HANDLER]: Inserted linked item {0} for link in folder {1} for agent {2}", | ||
269 | linkedItem.Name, folderID, agentID); | ||
270 | |||
271 | contents.Items.Insert(0, linkedItem); | ||
272 | } | ||
273 | */ | ||
274 | |||
275 | /* | ||
276 | // If the folder requested contains links, then we need to send those folders first, otherwise the links | ||
277 | // will be broken in the viewer. | ||
278 | HashSet<UUID> linkedItemFolderIdsToSend = new HashSet<UUID>(); | ||
279 | foreach (InventoryItemBase item in contents.Items) | ||
280 | { | ||
281 | if (item.AssetType == (int)AssetType.Link) | ||
282 | { | ||
283 | InventoryItemBase linkedItem = m_InventoryService.GetItem(new InventoryItemBase(item.AssetID)); | ||
284 | |||
285 | // Take care of genuinely broken links where the target doesn't exist | ||
286 | // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate, | ||
287 | // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles | ||
288 | // rather than having to keep track of every folder requested in the recursion. | ||
289 | if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link) | ||
290 | { | ||
291 | // We don't need to send the folder if source and destination of the link are in the same | ||
292 | // folder. | ||
293 | if (linkedItem.Folder != containingFolder.ID) | ||
294 | linkedItemFolderIdsToSend.Add(linkedItem.Folder); | ||
295 | } | ||
296 | } | ||
297 | } | ||
298 | |||
299 | foreach (UUID linkedItemFolderId in linkedItemFolderIdsToSend) | ||
300 | { | ||
301 | m_log.DebugFormat( | ||
302 | "[WEB FETCH INV DESC HANDLER]: Recursively fetching folder {0} linked by item in folder {1} for agent {2}", | ||
303 | linkedItemFolderId, folderID, agentID); | ||
304 | |||
305 | int dummyVersion; | ||
306 | InventoryCollection linkedCollection | ||
307 | = Fetch( | ||
308 | agentID, linkedItemFolderId, ownerID, fetchFolders, fetchItems, sortOrder, out dummyVersion); | ||
309 | |||
310 | contents.Folders.AddRange(linkedCollection.Folders); | ||
311 | contents.Items.AddRange(linkedCollection.Items); | ||
312 | } | ||
313 | */ | ||
314 | } | ||
315 | } | ||
233 | } | 316 | } |
234 | else | 317 | else |
235 | { | 318 | { |