aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
diff options
context:
space:
mode:
authorMelanie2011-11-28 11:06:38 +0000
committerMelanie2011-11-28 11:06:38 +0000
commitdc612d0f08ff8740c1942270f22eb79f0310c8fd (patch)
tree4c621d499eecbc176c6eb28a4bad4f8f4872e7f5 /OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
parentMerge branch 'master' into bigmerge (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-dc612d0f08ff8740c1942270f22eb79f0310c8fd.zip
opensim-SC_OLD-dc612d0f08ff8740c1942270f22eb79f0310c8fd.tar.gz
opensim-SC_OLD-dc612d0f08ff8740c1942270f22eb79f0310c8fd.tar.bz2
opensim-SC_OLD-dc612d0f08ff8740c1942270f22eb79f0310c8fd.tar.xz
Merge branch 'master' into bigmerge
Conflicts: OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
Diffstat (limited to 'OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs')
-rw-r--r--OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs130
1 files changed, 77 insertions, 53 deletions
diff --git a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
index 6fd7946..2dade5b 100644
--- a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
+++ b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
@@ -42,7 +42,6 @@ using Caps = OpenSim.Framework.Capabilities.Caps;
42 42
43namespace OpenSim.Capabilities.Handlers 43namespace OpenSim.Capabilities.Handlers
44{ 44{
45
46 public class WebFetchInvDescHandler 45 public class WebFetchInvDescHandler
47 { 46 {
48 private static readonly ILog m_log = 47 private static readonly ILog m_log =
@@ -50,7 +49,7 @@ namespace OpenSim.Capabilities.Handlers
50 49
51 private IInventoryService m_InventoryService; 50 private IInventoryService m_InventoryService;
52 private ILibraryService m_LibraryService; 51 private ILibraryService m_LibraryService;
53 private object m_fetchLock = new Object(); 52// private object m_fetchLock = new Object();
54 53
55 public WebFetchInvDescHandler(IInventoryService invService, ILibraryService libService) 54 public WebFetchInvDescHandler(IInventoryService invService, ILibraryService libService)
56 { 55 {
@@ -60,37 +59,40 @@ namespace OpenSim.Capabilities.Handlers
60 59
61 public string FetchInventoryDescendentsRequest(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) 60 public string FetchInventoryDescendentsRequest(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
62 { 61 {
63 // nasty temporary hack here, the linden client falsely 62// lock (m_fetchLock)
64 // identifies the uuid 00000000-0000-0000-0000-000000000000 63// {
65 // as a string which breaks us 64// m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Received request {0}", request);
66 // 65
67 // correctly mark it as a uuid 66 // nasty temporary hack here, the linden client falsely
68 // 67 // identifies the uuid 00000000-0000-0000-0000-000000000000
69 request = request.Replace("<string>00000000-0000-0000-0000-000000000000</string>", "<uuid>00000000-0000-0000-0000-000000000000</uuid>"); 68 // as a string which breaks us
70 69 //
71 // another hack <integer>1</integer> results in a 70 // correctly mark it as a uuid
72 // System.ArgumentException: Object type System.Int32 cannot 71 //
73 // be converted to target type: System.Boolean 72 request = request.Replace("<string>00000000-0000-0000-0000-000000000000</string>", "<uuid>00000000-0000-0000-0000-000000000000</uuid>");
74 // 73
75 request = request.Replace("<key>fetch_folders</key><integer>0</integer>", "<key>fetch_folders</key><boolean>0</boolean>"); 74 // another hack <integer>1</integer> results in a
76 request = request.Replace("<key>fetch_folders</key><integer>1</integer>", "<key>fetch_folders</key><boolean>1</boolean>"); 75 // System.ArgumentException: Object type System.Int32 cannot
77 76 // be converted to target type: System.Boolean
78 Hashtable hash = new Hashtable(); 77 //
79 try 78 request = request.Replace("<key>fetch_folders</key><integer>0</integer>", "<key>fetch_folders</key><boolean>0</boolean>");
80 { 79 request = request.Replace("<key>fetch_folders</key><integer>1</integer>", "<key>fetch_folders</key><boolean>1</boolean>");
81 hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); 80
82 } 81 Hashtable hash = new Hashtable();
83 catch (LLSD.LLSDParseException pe) 82 try
84 { 83 {
85 m_log.Error("[AGENT INVENTORY]: Fetch error: " + pe.Message); 84 hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request));
86 m_log.Error("Request: " + request.ToString()); 85 }
87 } 86 catch (LLSD.LLSDParseException e)
88 87 {
89 ArrayList foldersrequested = (ArrayList)hash["folders"]; 88 m_log.ErrorFormat("[WEB FETCH INV DESC HANDLER]: Fetch error: {0}{1}" + e.Message, e.StackTrace);
89 m_log.Error("Request: " + request);
90 }
91
92 ArrayList foldersrequested = (ArrayList)hash["folders"];
93
94 string response = "";
90 95
91 string response = "";
92 lock (m_fetchLock)
93 {
94 for (int i = 0; i < foldersrequested.Count; i++) 96 for (int i = 0; i < foldersrequested.Count; i++)
95 { 97 {
96 string inventoryitemstr = ""; 98 string inventoryitemstr = "";
@@ -104,7 +106,7 @@ namespace OpenSim.Capabilities.Handlers
104 } 106 }
105 catch (Exception e) 107 catch (Exception e)
106 { 108 {
107 m_log.Debug("[CAPS]: caught exception doing OSD deserialize" + e); 109 m_log.Debug("[WEB FETCH INV DESC HANDLER]: caught exception doing OSD deserialize" + e);
108 } 110 }
109 LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest); 111 LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest);
110 112
@@ -115,7 +117,6 @@ namespace OpenSim.Capabilities.Handlers
115 response += inventoryitemstr; 117 response += inventoryitemstr;
116 } 118 }
117 119
118
119 if (response.Length == 0) 120 if (response.Length == 0)
120 { 121 {
121 // Ter-guess: If requests fail a lot, the client seems to stop requesting descendants. 122 // Ter-guess: If requests fail a lot, the client seems to stop requesting descendants.
@@ -129,11 +130,12 @@ namespace OpenSim.Capabilities.Handlers
129 response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>"; 130 response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>";
130 } 131 }
131 132
132 //m_log.DebugFormat("[CAPS]: Replying to CAPS fetch inventory request with following xml"); 133// m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Replying to CAPS fetch inventory request");
133 //m_log.Debug("[CAPS] "+response); 134 //m_log.Debug("[WEB FETCH INV DESC HANDLER] "+response);
134 135
135 } 136 return response;
136 return response; 137
138// }
137 } 139 }
138 140
139 /// <summary> 141 /// <summary>
@@ -155,7 +157,10 @@ namespace OpenSim.Capabilities.Handlers
155 inv.Items = new List<InventoryItemBase>(); 157 inv.Items = new List<InventoryItemBase>();
156 int version = 0; 158 int version = 0;
157 159
158 inv = Fetch(invFetch.owner_id, invFetch.folder_id, invFetch.owner_id, invFetch.fetch_folders, invFetch.fetch_items, invFetch.sort_order, out version); 160 inv
161 = Fetch(
162 invFetch.owner_id, invFetch.folder_id, invFetch.owner_id,
163 invFetch.fetch_folders, invFetch.fetch_items, invFetch.sort_order, out version);
159 164
160 if (inv.Folders != null) 165 if (inv.Folders != null)
161 { 166 {
@@ -179,16 +184,31 @@ namespace OpenSim.Capabilities.Handlers
179 return reply; 184 return reply;
180 } 185 }
181 186
182 public InventoryCollection Fetch(UUID agentID, UUID folderID, UUID ownerID, 187 /// <summary>
183 bool fetchFolders, bool fetchItems, int sortOrder, out int version) 188 /// Handle the caps inventory descendents fetch.
189 /// </summary>
190 /// <param name="agentID"></param>
191 /// <param name="folderID"></param>
192 /// <param name="ownerID"></param>
193 /// <param name="fetchFolders"></param>
194 /// <param name="fetchItems"></param>
195 /// <param name="sortOrder"></param>
196 /// <param name="version"></param>
197 /// <returns>An empty InventoryCollection if the inventory look up failed</returns>
198 public InventoryCollection Fetch(
199 UUID agentID, UUID folderID, UUID ownerID,
200 bool fetchFolders, bool fetchItems, int sortOrder, out int version)
184 { 201 {
185 m_log.DebugFormat( 202// m_log.DebugFormat(
186 "[WEBFETCHINVENTORYDESCENDANTS]: Fetching folders ({0}), items ({1}) from {2} for agent {3}", 203// "[WEB FETCH INV DESC HANDLER]: Fetching folders ({0}), items ({1}) from {2} for agent {3}",
187 fetchFolders, fetchItems, folderID, agentID); 204// fetchFolders, fetchItems, folderID, agentID);
205
206 // FIXME MAYBE: We're not handling sortOrder!
188 207
189 version = 0; 208 version = 0;
190 InventoryFolderImpl fold; 209 InventoryFolderImpl fold;
191 if (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null && agentID == m_LibraryService.LibraryRootFolder.Owner) 210 if (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null && agentID == m_LibraryService.LibraryRootFolder.Owner)
211 {
192 if ((fold = m_LibraryService.LibraryRootFolder.FindFolder(folderID)) != null) 212 if ((fold = m_LibraryService.LibraryRootFolder.FindFolder(folderID)) != null)
193 { 213 {
194 InventoryCollection ret = new InventoryCollection(); 214 InventoryCollection ret = new InventoryCollection();
@@ -197,6 +217,7 @@ namespace OpenSim.Capabilities.Handlers
197 217
198 return ret; 218 return ret;
199 } 219 }
220 }
200 221
201 InventoryCollection contents = new InventoryCollection(); 222 InventoryCollection contents = new InventoryCollection();
202 223
@@ -212,7 +233,7 @@ namespace OpenSim.Capabilities.Handlers
212 } 233 }
213 else 234 else
214 { 235 {
215 // Lost itemsm don't really need a version 236 // Lost items don't really need a version
216 version = 1; 237 version = 1;
217 } 238 }
218 239
@@ -230,10 +251,11 @@ namespace OpenSim.Capabilities.Handlers
230 llsdFolder.folder_id = invFolder.ID; 251 llsdFolder.folder_id = invFolder.ID;
231 llsdFolder.parent_id = invFolder.ParentID; 252 llsdFolder.parent_id = invFolder.ParentID;
232 llsdFolder.name = invFolder.Name; 253 llsdFolder.name = invFolder.Name;
233 if (invFolder.Type < 0 || invFolder.Type >= TaskInventoryItem.Types.Length) 254
255 if (invFolder.Type == (short)AssetType.Unknown || !Enum.IsDefined(typeof(AssetType), (sbyte)invFolder.Type))
234 llsdFolder.type = "-1"; 256 llsdFolder.type = "-1";
235 else 257 else
236 llsdFolder.type = TaskInventoryItem.Types[invFolder.Type]; 258 llsdFolder.type = Utils.AssetTypeToString((AssetType)invFolder.Type);
237 llsdFolder.preferred_type = "-1"; 259 llsdFolder.preferred_type = "-1";
238 260
239 return llsdFolder; 261 return llsdFolder;
@@ -254,16 +276,19 @@ namespace OpenSim.Capabilities.Handlers
254 llsdItem.item_id = invItem.ID; 276 llsdItem.item_id = invItem.ID;
255 llsdItem.name = invItem.Name; 277 llsdItem.name = invItem.Name;
256 llsdItem.parent_id = invItem.Folder; 278 llsdItem.parent_id = invItem.Folder;
279
257 try 280 try
258 { 281 {
259 // TODO reevaluate after upgrade to libomv >= r2566. Probably should use UtilsConversions. 282 llsdItem.type = Utils.AssetTypeToString((AssetType)invItem.AssetType);
260 llsdItem.type = TaskInventoryItem.Types[invItem.AssetType]; 283 llsdItem.inv_type = Utils.InventoryTypeToString((InventoryType)invItem.InvType);
261 llsdItem.inv_type = TaskInventoryItem.InvTypes[invItem.InvType];
262 } 284 }
263 catch (Exception e) 285 catch (Exception e)
264 { 286 {
265 m_log.ErrorFormat("[CAPS]: Problem setting asset {0} inventory {1} types while converting inventory item {2}: {3}", invItem.AssetType, invItem.InvType, invItem.Name, e.Message); 287 m_log.ErrorFormat(
288 "[WEB FETCH INV DESC HANDLER]: Problem setting asset {0} inventory {1} types while converting inventory item {2}: {3}",
289 invItem.AssetType, invItem.InvType, invItem.Name, e.Message);
266 } 290 }
291
267 llsdItem.permissions = new LLSDPermissions(); 292 llsdItem.permissions = new LLSDPermissions();
268 llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid; 293 llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid;
269 llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions; 294 llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions;
@@ -294,6 +319,5 @@ namespace OpenSim.Capabilities.Handlers
294 319
295 return llsdItem; 320 return llsdItem;
296 } 321 }
297
298 } 322 }
299} 323} \ No newline at end of file