aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
diff options
context:
space:
mode:
authorubit2012-07-17 02:07:21 +0200
committerubit2012-07-17 02:07:21 +0200
commite925b0654d12c534ff9f837355ad43483dbd22cb (patch)
treee8a05e918e55ec8034dd724c38f143aac31493b2 /OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
parentMerge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork (diff)
parentMerge branch 'avination' into ubitwork (diff)
downloadopensim-SC-e925b0654d12c534ff9f837355ad43483dbd22cb.zip
opensim-SC-e925b0654d12c534ff9f837355ad43483dbd22cb.tar.gz
opensim-SC-e925b0654d12c534ff9f837355ad43483dbd22cb.tar.bz2
opensim-SC-e925b0654d12c534ff9f837355ad43483dbd22cb.tar.xz
Merge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork
Diffstat (limited to 'OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs')
-rw-r--r--OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs132
1 files changed, 79 insertions, 53 deletions
diff --git a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
index d5c062b..9a6ca86 100644
--- a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
+++ b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
@@ -156,11 +156,12 @@ namespace OpenSim.Capabilities.Handlers
156 inv.Folders = new List<InventoryFolderBase>(); 156 inv.Folders = new List<InventoryFolderBase>();
157 inv.Items = new List<InventoryItemBase>(); 157 inv.Items = new List<InventoryItemBase>();
158 int version = 0; 158 int version = 0;
159 int descendents = 0;
159 160
160 inv 161 inv
161 = Fetch( 162 = Fetch(
162 invFetch.owner_id, invFetch.folder_id, invFetch.owner_id, 163 invFetch.owner_id, invFetch.folder_id, invFetch.owner_id,
163 invFetch.fetch_folders, invFetch.fetch_items, invFetch.sort_order, out version); 164 invFetch.fetch_folders, invFetch.fetch_items, invFetch.sort_order, out version, out descendents);
164 165
165 if (inv != null && inv.Folders != null) 166 if (inv != null && inv.Folders != null)
166 { 167 {
@@ -168,6 +169,8 @@ namespace OpenSim.Capabilities.Handlers
168 { 169 {
169 contents.categories.Array.Add(ConvertInventoryFolder(invFolder)); 170 contents.categories.Array.Add(ConvertInventoryFolder(invFolder));
170 } 171 }
172
173 descendents += inv.Folders.Count;
171 } 174 }
172 175
173 if (inv != null && inv.Items != null) 176 if (inv != null && inv.Items != null)
@@ -178,7 +181,7 @@ namespace OpenSim.Capabilities.Handlers
178 } 181 }
179 } 182 }
180 183
181 contents.descendents = contents.items.Array.Count + contents.categories.Array.Count; 184 contents.descendents = descendents;
182 contents.version = version; 185 contents.version = version;
183 186
184// m_log.DebugFormat( 187// m_log.DebugFormat(
@@ -206,7 +209,7 @@ namespace OpenSim.Capabilities.Handlers
206 /// <returns>An empty InventoryCollection if the inventory look up failed</returns> 209 /// <returns>An empty InventoryCollection if the inventory look up failed</returns>
207 private InventoryCollection Fetch( 210 private InventoryCollection Fetch(
208 UUID agentID, UUID folderID, UUID ownerID, 211 UUID agentID, UUID folderID, UUID ownerID,
209 bool fetchFolders, bool fetchItems, int sortOrder, out int version) 212 bool fetchFolders, bool fetchItems, int sortOrder, out int version, out int descendents)
210 { 213 {
211// m_log.DebugFormat( 214// m_log.DebugFormat(
212// "[WEB FETCH INV DESC HANDLER]: Fetching folders ({0}), items ({1}) from {2} for agent {3}", 215// "[WEB FETCH INV DESC HANDLER]: Fetching folders ({0}), items ({1}) from {2} for agent {3}",
@@ -215,6 +218,8 @@ namespace OpenSim.Capabilities.Handlers
215 // FIXME MAYBE: We're not handling sortOrder! 218 // FIXME MAYBE: We're not handling sortOrder!
216 219
217 version = 0; 220 version = 0;
221 descendents = 0;
222
218 InventoryFolderImpl fold; 223 InventoryFolderImpl fold;
219 if (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null && agentID == m_LibraryService.LibraryRootFolder.Owner) 224 if (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null && agentID == m_LibraryService.LibraryRootFolder.Owner)
220 { 225 {
@@ -223,6 +228,7 @@ namespace OpenSim.Capabilities.Handlers
223 InventoryCollection ret = new InventoryCollection(); 228 InventoryCollection ret = new InventoryCollection();
224 ret.Folders = new List<InventoryFolderBase>(); 229 ret.Folders = new List<InventoryFolderBase>();
225 ret.Items = fold.RequestListOfItems(); 230 ret.Items = fold.RequestListOfItems();
231 descendents = ret.Folders.Count + ret.Items.Count;
226 232
227 return ret; 233 return ret;
228 } 234 }
@@ -246,24 +252,72 @@ namespace OpenSim.Capabilities.Handlers
246 252
247 version = containingFolder.Version; 253 version = containingFolder.Version;
248 254
249// if (fetchItems) 255 if (fetchItems)
256 {
257 List<InventoryItemBase> itemsToReturn = contents.Items;
258 List<InventoryItemBase> originalItems = new List<InventoryItemBase>(itemsToReturn);
259
260 // descendents must only include the links, not the linked items we add
261 descendents = originalItems.Count;
262
263 // Add target items for links in this folder before the links themselves.
264 foreach (InventoryItemBase item in originalItems)
265 {
266 if (item.AssetType == (int)AssetType.Link)
267 {
268 InventoryItemBase linkedItem = m_InventoryService.GetItem(new InventoryItemBase(item.AssetID));
269
270 // Take care of genuinely broken links where the target doesn't exist
271 // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate,
272 // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles
273 // rather than having to keep track of every folder requested in the recursion.
274 if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link)
275 itemsToReturn.Insert(0, linkedItem);
276 }
277 }
278
279 // Now scan for folder links and insert the items they target and those links at the head of the return data
280 foreach (InventoryItemBase item in originalItems)
281 {
282 if (item.AssetType == (int)AssetType.LinkFolder)
283 {
284 InventoryCollection linkedFolderContents = m_InventoryService.GetFolderContent(ownerID, item.AssetID);
285 List<InventoryItemBase> links = linkedFolderContents.Items;
286
287 itemsToReturn.InsertRange(0, links);
288
289 foreach (InventoryItemBase link in linkedFolderContents.Items)
290 {
291 // Take care of genuinely broken links where the target doesn't exist
292 // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate,
293 // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles
294 // rather than having to keep track of every folder requested in the recursion.
295 if (link != null)
296 {
297// m_log.DebugFormat(
298// "[WEB FETCH INV DESC HANDLER]: Adding item {0} {1} from folder {2} linked from {3}",
299// link.Name, (AssetType)link.AssetType, item.AssetID, containingFolder.Name);
300
301 InventoryItemBase linkedItem
302 = m_InventoryService.GetItem(new InventoryItemBase(link.AssetID));
303
304 if (linkedItem != null)
305 itemsToReturn.Insert(0, linkedItem);
306 }
307 }
308 }
309 }
310 }
311
312// foreach (InventoryItemBase item in contents.Items)
250// { 313// {
251// List<InventoryItemBase> linkedItemsToAdd = new List<InventoryItemBase>(); 314// m_log.DebugFormat(
252// 315// "[WEB FETCH INV DESC HANDLER]: Returning item {0}, type {1}, parent {2} in {3} {4}",
253// foreach (InventoryItemBase item in contents.Items) 316// item.Name, (AssetType)item.AssetType, item.Folder, containingFolder.Name, containingFolder.ID);
254// { 317// }
255// if (item.AssetType == (int)AssetType.Link) 318
256// { 319 // =====
257// InventoryItemBase linkedItem = m_InventoryService.GetItem(new InventoryItemBase(item.AssetID)); 320
258//
259// // Take care of genuinely broken links where the target doesn't exist
260// // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate,
261// // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles
262// // rather than having to keep track of every folder requested in the recursion.
263// if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link)
264// linkedItemsToAdd.Insert(0, linkedItem);
265// }
266// }
267// 321//
268// foreach (InventoryItemBase linkedItem in linkedItemsToAdd) 322// foreach (InventoryItemBase linkedItem in linkedItemsToAdd)
269// { 323// {
@@ -340,12 +394,8 @@ namespace OpenSim.Capabilities.Handlers
340 llsdFolder.folder_id = invFolder.ID; 394 llsdFolder.folder_id = invFolder.ID;
341 llsdFolder.parent_id = invFolder.ParentID; 395 llsdFolder.parent_id = invFolder.ParentID;
342 llsdFolder.name = invFolder.Name; 396 llsdFolder.name = invFolder.Name;
343 397 llsdFolder.type = invFolder.Type;
344 if (invFolder.Type == (short)AssetType.Unknown || !Enum.IsDefined(typeof(AssetType), (sbyte)invFolder.Type)) 398 llsdFolder.preferred_type = -1;
345 llsdFolder.type = "-1";
346 else
347 llsdFolder.type = Utils.AssetTypeToString((AssetType)invFolder.Type);
348 llsdFolder.preferred_type = "-1";
349 399
350 return llsdFolder; 400 return llsdFolder;
351 } 401 }
@@ -365,18 +415,8 @@ namespace OpenSim.Capabilities.Handlers
365 llsdItem.item_id = invItem.ID; 415 llsdItem.item_id = invItem.ID;
366 llsdItem.name = invItem.Name; 416 llsdItem.name = invItem.Name;
367 llsdItem.parent_id = invItem.Folder; 417 llsdItem.parent_id = invItem.Folder;
368 418 llsdItem.type = invItem.AssetType;
369 try 419 llsdItem.inv_type = invItem.InvType;
370 {
371 llsdItem.type = Utils.AssetTypeToString((AssetType)invItem.AssetType);
372 llsdItem.inv_type = Utils.InventoryTypeToString((InventoryType)invItem.InvType);
373 }
374 catch (Exception e)
375 {
376 m_log.ErrorFormat(
377 "[WEB FETCH INV DESC HANDLER]: Problem setting asset {0} inventory {1} types while converting inventory item {2}: {3}",
378 invItem.AssetType, invItem.InvType, invItem.Name, e.Message);
379 }
380 420
381 llsdItem.permissions = new LLSDPermissions(); 421 llsdItem.permissions = new LLSDPermissions();
382 llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid; 422 llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid;
@@ -390,21 +430,7 @@ namespace OpenSim.Capabilities.Handlers
390 llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions; 430 llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions;
391 llsdItem.sale_info = new LLSDSaleInfo(); 431 llsdItem.sale_info = new LLSDSaleInfo();
392 llsdItem.sale_info.sale_price = invItem.SalePrice; 432 llsdItem.sale_info.sale_price = invItem.SalePrice;
393 switch (invItem.SaleType) 433 llsdItem.sale_info.sale_type = invItem.SaleType;
394 {
395 default:
396 llsdItem.sale_info.sale_type = "not";
397 break;
398 case 1:
399 llsdItem.sale_info.sale_type = "original";
400 break;
401 case 2:
402 llsdItem.sale_info.sale_type = "copy";
403 break;
404 case 3:
405 llsdItem.sale_info.sale_type = "contents";
406 break;
407 }
408 434
409 return llsdItem; 435 return llsdItem;
410 } 436 }