aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
diff options
context:
space:
mode:
authorBlueWall2011-11-26 17:20:20 -0500
committerBlueWall2011-11-26 17:20:20 -0500
commit19c10c892adc7168107e8866cf4d7d20b876e2a8 (patch)
tree6c6ed57160a010a17c95dbda6901f97dd845b9e4 /OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
parentAdd missing property to llGetLinkPrimitiveParams (diff)
parentWhen removing an LSL sensor for a script (e.g. through llResetScript() or sta... (diff)
downloadopensim-SC_OLD-19c10c892adc7168107e8866cf4d7d20b876e2a8.zip
opensim-SC_OLD-19c10c892adc7168107e8866cf4d7d20b876e2a8.tar.gz
opensim-SC_OLD-19c10c892adc7168107e8866cf4d7d20b876e2a8.tar.bz2
opensim-SC_OLD-19c10c892adc7168107e8866cf4d7d20b876e2a8.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs')
-rw-r--r--OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs113
1 files changed, 65 insertions, 48 deletions
diff --git a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
index 17dbcd5..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,39 +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// m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Received request"); 62// lock (m_fetchLock)
64 63// {
65 // nasty temporary hack here, the linden client falsely 64// m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Received request {0}", request);
66 // identifies the uuid 00000000-0000-0000-0000-000000000000 65
67 // as a string which breaks us 66 // nasty temporary hack here, the linden client falsely
68 // 67 // identifies the uuid 00000000-0000-0000-0000-000000000000
69 // correctly mark it as a uuid 68 // as a string which breaks us
70 // 69 //
71 request = request.Replace("<string>00000000-0000-0000-0000-000000000000</string>", "<uuid>00000000-0000-0000-0000-000000000000</uuid>"); 70 // correctly mark it as a uuid
72 71 //
73 // another hack <integer>1</integer> results in a 72 request = request.Replace("<string>00000000-0000-0000-0000-000000000000</string>", "<uuid>00000000-0000-0000-0000-000000000000</uuid>");
74 // System.ArgumentException: Object type System.Int32 cannot 73
75 // be converted to target type: System.Boolean 74 // another hack <integer>1</integer> results in a
76 // 75 // System.ArgumentException: Object type System.Int32 cannot
77 request = request.Replace("<key>fetch_folders</key><integer>0</integer>", "<key>fetch_folders</key><boolean>0</boolean>"); 76 // be converted to target type: System.Boolean
78 request = request.Replace("<key>fetch_folders</key><integer>1</integer>", "<key>fetch_folders</key><boolean>1</boolean>"); 77 //
79 78 request = request.Replace("<key>fetch_folders</key><integer>0</integer>", "<key>fetch_folders</key><boolean>0</boolean>");
80 Hashtable hash = new Hashtable(); 79 request = request.Replace("<key>fetch_folders</key><integer>1</integer>", "<key>fetch_folders</key><boolean>1</boolean>");
81 try 80
82 { 81 Hashtable hash = new Hashtable();
83 hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); 82 try
84 } 83 {
85 catch (LLSD.LLSDParseException pe) 84 hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request));
86 { 85 }
87 m_log.Error("[AGENT INVENTORY]: Fetch error: " + pe.Message); 86 catch (LLSD.LLSDParseException e)
88 m_log.Error("Request: " + request.ToString()); 87 {
89 } 88 m_log.ErrorFormat("[WEB FETCH INV DESC HANDLER]: Fetch error: {0}{1}" + e.Message, e.StackTrace);
90 89 m_log.Error("Request: " + request);
91 ArrayList foldersrequested = (ArrayList)hash["folders"]; 90 }
91
92 ArrayList foldersrequested = (ArrayList)hash["folders"];
93
94 string response = "";
92 95
93 string response = "";
94 lock (m_fetchLock)
95 {
96 for (int i = 0; i < foldersrequested.Count; i++) 96 for (int i = 0; i < foldersrequested.Count; i++)
97 { 97 {
98 string inventoryitemstr = ""; 98 string inventoryitemstr = "";
@@ -106,7 +106,7 @@ namespace OpenSim.Capabilities.Handlers
106 } 106 }
107 catch (Exception e) 107 catch (Exception e)
108 { 108 {
109 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);
110 } 110 }
111 LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest); 111 LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest);
112 112
@@ -117,7 +117,6 @@ namespace OpenSim.Capabilities.Handlers
117 response += inventoryitemstr; 117 response += inventoryitemstr;
118 } 118 }
119 119
120
121 if (response.Length == 0) 120 if (response.Length == 0)
122 { 121 {
123 // 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.
@@ -131,11 +130,12 @@ namespace OpenSim.Capabilities.Handlers
131 response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>"; 130 response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>";
132 } 131 }
133 132
134 //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");
135 //m_log.Debug("[CAPS] "+response); 134 //m_log.Debug("[WEB FETCH INV DESC HANDLER] "+response);
136 135
137 } 136 return response;
138 return response; 137
138// }
139 } 139 }
140 140
141 /// <summary> 141 /// <summary>
@@ -184,16 +184,31 @@ namespace OpenSim.Capabilities.Handlers
184 return reply; 184 return reply;
185 } 185 }
186 186
187 public InventoryCollection Fetch(UUID agentID, UUID folderID, UUID ownerID, 187 /// <summary>
188 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)
189 { 201 {
190 m_log.DebugFormat( 202// m_log.DebugFormat(
191 "[WEB FETCH INV DESC HANDLER]: 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}",
192 fetchFolders, fetchItems, folderID, agentID); 204// fetchFolders, fetchItems, folderID, agentID);
205
206 // FIXME MAYBE: We're not handling sortOrder!
193 207
194 version = 0; 208 version = 0;
195 InventoryFolderImpl fold; 209 InventoryFolderImpl fold;
196 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 {
197 if ((fold = m_LibraryService.LibraryRootFolder.FindFolder(folderID)) != null) 212 if ((fold = m_LibraryService.LibraryRootFolder.FindFolder(folderID)) != null)
198 { 213 {
199 InventoryCollection ret = new InventoryCollection(); 214 InventoryCollection ret = new InventoryCollection();
@@ -202,6 +217,7 @@ namespace OpenSim.Capabilities.Handlers
202 217
203 return ret; 218 return ret;
204 } 219 }
220 }
205 221
206 InventoryCollection contents = new InventoryCollection(); 222 InventoryCollection contents = new InventoryCollection();
207 223
@@ -217,7 +233,7 @@ namespace OpenSim.Capabilities.Handlers
217 } 233 }
218 else 234 else
219 { 235 {
220 // Lost itemsm don't really need a version 236 // Lost items don't really need a version
221 version = 1; 237 version = 1;
222 } 238 }
223 239
@@ -235,10 +251,11 @@ namespace OpenSim.Capabilities.Handlers
235 llsdFolder.folder_id = invFolder.ID; 251 llsdFolder.folder_id = invFolder.ID;
236 llsdFolder.parent_id = invFolder.ParentID; 252 llsdFolder.parent_id = invFolder.ParentID;
237 llsdFolder.name = invFolder.Name; 253 llsdFolder.name = invFolder.Name;
238 if (invFolder.Type < 0 || invFolder.Type >= TaskInventoryItem.Types.Length) 254
255 if (invFolder.Type == (short)AssetType.Unknown || !Enum.IsDefined(typeof(AssetType), (sbyte)invFolder.Type))
239 llsdFolder.type = "-1"; 256 llsdFolder.type = "-1";
240 else 257 else
241 llsdFolder.type = TaskInventoryItem.Types[invFolder.Type]; 258 llsdFolder.type = Utils.AssetTypeToString((AssetType)invFolder.Type);
242 llsdFolder.preferred_type = "-1"; 259 llsdFolder.preferred_type = "-1";
243 260
244 return llsdFolder; 261 return llsdFolder;