aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Capabilities
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-06-02 04:57:10 +0100
committerJustin Clark-Casey (justincc)2012-06-02 04:57:10 +0100
commit01a2b0b289933febc95523de02275c9bd573b10e (patch)
tree3ad8193876370cf4db30738d97c0b01f123100a8 /OpenSim/Capabilities
parentInstead of updating sim stats root agent, child, objects and scripts accounts... (diff)
downloadopensim-SC_OLD-01a2b0b289933febc95523de02275c9bd573b10e.zip
opensim-SC_OLD-01a2b0b289933febc95523de02275c9bd573b10e.tar.gz
opensim-SC_OLD-01a2b0b289933febc95523de02275c9bd573b10e.tar.bz2
opensim-SC_OLD-01a2b0b289933febc95523de02275c9bd573b10e.tar.xz
Fix various issues with http inventory
1) The return messages were being wrongly populated with the names of asset, inventory and sale types when their corresponding integers should have been used instead. 2) Folders with links were including the linked items in the descendents figure, when only the links should be included. 3) Links and linked items in link folders were not being included in the return data, and not in the correct order. Now that these issues have been addressed, outfits and attachments appear to work consistently when HTTP inventory is enabled (as is now the default).
Diffstat (limited to 'OpenSim/Capabilities')
-rw-r--r--OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs30
-rw-r--r--OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs125
-rw-r--r--OpenSim/Capabilities/LLSDInventoryItem.cs6
3 files changed, 84 insertions, 77 deletions
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs b/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs
index 717a097..c0ca1e1 100644
--- a/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs
+++ b/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs
@@ -101,18 +101,8 @@ namespace OpenSim.Capabilities.Handlers
101 llsdItem.item_id = invItem.ID; 101 llsdItem.item_id = invItem.ID;
102 llsdItem.name = invItem.Name; 102 llsdItem.name = invItem.Name;
103 llsdItem.parent_id = invItem.Folder; 103 llsdItem.parent_id = invItem.Folder;
104 104 llsdItem.type = invItem.AssetType;
105 try 105 llsdItem.inv_type = invItem.InvType;
106 {
107 llsdItem.type = Utils.AssetTypeToString((AssetType)invItem.AssetType);
108 llsdItem.inv_type = Utils.InventoryTypeToString((InventoryType)invItem.InvType);
109 }
110 catch (Exception e)
111 {
112 m_log.ErrorFormat(
113 "[WEB FETCH INV DESC HANDLER]: Problem setting asset {0} inventory {1} types while converting inventory item {2}: {3}",
114 invItem.AssetType, invItem.InvType, invItem.Name, e.Message);
115 }
116 106
117 llsdItem.permissions = new LLSDPermissions(); 107 llsdItem.permissions = new LLSDPermissions();
118 llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid; 108 llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid;
@@ -126,21 +116,7 @@ namespace OpenSim.Capabilities.Handlers
126 llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions; 116 llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions;
127 llsdItem.sale_info = new LLSDSaleInfo(); 117 llsdItem.sale_info = new LLSDSaleInfo();
128 llsdItem.sale_info.sale_price = invItem.SalePrice; 118 llsdItem.sale_info.sale_price = invItem.SalePrice;
129 switch (invItem.SaleType) 119 llsdItem.sale_info.sale_type = invItem.SaleType;
130 {
131 default:
132 llsdItem.sale_info.sale_type = "not";
133 break;
134 case 1:
135 llsdItem.sale_info.sale_type = "original";
136 break;
137 case 2:
138 llsdItem.sale_info.sale_type = "copy";
139 break;
140 case 3:
141 llsdItem.sale_info.sale_type = "contents";
142 break;
143 }
144 120
145 return llsdItem; 121 return llsdItem;
146 } 122 }
diff --git a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
index d5c062b..b3196d9 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;
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,73 @@ 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 // Second, add target items for links in this folder
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 // First, scan for folder links and add target items in those folders.
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 // Second, insert the links contained in this linked folder.
288 itemsToReturn.InsertRange(0, links);
289
290 // Third, insert the real items linked by the links in this linked folder.
291 foreach (InventoryItemBase link in linkedFolderContents.Items)
292 {
293 // Take care of genuinely broken links where the target doesn't exist
294 // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate,
295 // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles
296 // rather than having to keep track of every folder requested in the recursion.
297 if (link != null)
298 {
299// m_log.DebugFormat(
300// "[WEB FETCH INV DESC HANDLER]: Adding item {0} {1} from folder {2} linked from {3}",
301// link.Name, (AssetType)link.AssetType, item.AssetID, containingFolder.Name);
302
303 InventoryItemBase linkedItem
304 = m_InventoryService.GetItem(new InventoryItemBase(link.AssetID));
305
306 itemsToReturn.Insert(0, linkedItem);
307 }
308 }
309 }
310 }
311 }
312
313// foreach (InventoryItemBase item in contents.Items)
250// { 314// {
251// List<InventoryItemBase> linkedItemsToAdd = new List<InventoryItemBase>(); 315// m_log.DebugFormat(
252// 316// "[WEB FETCH INV DESC HANDLER]: Returning item {0}, type {1}, parent {2} in {3} {4}",
253// foreach (InventoryItemBase item in contents.Items) 317// item.Name, (AssetType)item.AssetType, item.Folder, containingFolder.Name, containingFolder.ID);
254// { 318// }
255// if (item.AssetType == (int)AssetType.Link) 319
256// { 320 // =====
257// InventoryItemBase linkedItem = m_InventoryService.GetItem(new InventoryItemBase(item.AssetID)); 321
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// 322//
268// foreach (InventoryItemBase linkedItem in linkedItemsToAdd) 323// foreach (InventoryItemBase linkedItem in linkedItemsToAdd)
269// { 324// {
@@ -365,18 +420,8 @@ namespace OpenSim.Capabilities.Handlers
365 llsdItem.item_id = invItem.ID; 420 llsdItem.item_id = invItem.ID;
366 llsdItem.name = invItem.Name; 421 llsdItem.name = invItem.Name;
367 llsdItem.parent_id = invItem.Folder; 422 llsdItem.parent_id = invItem.Folder;
368 423 llsdItem.type = invItem.AssetType;
369 try 424 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 425
381 llsdItem.permissions = new LLSDPermissions(); 426 llsdItem.permissions = new LLSDPermissions();
382 llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid; 427 llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid;
@@ -390,21 +435,7 @@ namespace OpenSim.Capabilities.Handlers
390 llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions; 435 llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions;
391 llsdItem.sale_info = new LLSDSaleInfo(); 436 llsdItem.sale_info = new LLSDSaleInfo();
392 llsdItem.sale_info.sale_price = invItem.SalePrice; 437 llsdItem.sale_info.sale_price = invItem.SalePrice;
393 switch (invItem.SaleType) 438 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 439
409 return llsdItem; 440 return llsdItem;
410 } 441 }
diff --git a/OpenSim/Capabilities/LLSDInventoryItem.cs b/OpenSim/Capabilities/LLSDInventoryItem.cs
index 426a6cb..958e807 100644
--- a/OpenSim/Capabilities/LLSDInventoryItem.cs
+++ b/OpenSim/Capabilities/LLSDInventoryItem.cs
@@ -37,8 +37,8 @@ namespace OpenSim.Framework.Capabilities
37 public UUID asset_id; 37 public UUID asset_id;
38 public UUID item_id; 38 public UUID item_id;
39 public LLSDPermissions permissions; 39 public LLSDPermissions permissions;
40 public string type; 40 public int type;
41 public string inv_type; 41 public int inv_type;
42 public int flags; 42 public int flags;
43 43
44 public LLSDSaleInfo sale_info; 44 public LLSDSaleInfo sale_info;
@@ -65,7 +65,7 @@ namespace OpenSim.Framework.Capabilities
65 public class LLSDSaleInfo 65 public class LLSDSaleInfo
66 { 66 {
67 public int sale_price; 67 public int sale_price;
68 public string sale_type; 68 public int sale_type;
69 } 69 }
70 70
71 [OSDMap] 71 [OSDMap]