diff options
Diffstat (limited to 'OpenSim/Server/Handlers/Inventory')
-rw-r--r-- | OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs | 48 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs | 372 |
2 files changed, 322 insertions, 98 deletions
diff --git a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs index 3c92209..1d422a7 100644 --- a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs | |||
@@ -46,7 +46,7 @@ namespace OpenSim.Server.Handlers.Inventory | |||
46 | { | 46 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 48 | ||
49 | private IInventoryService m_InventoryService; | 49 | protected IInventoryService m_InventoryService; |
50 | 50 | ||
51 | private bool m_doLookup = false; | 51 | private bool m_doLookup = false; |
52 | 52 | ||
@@ -54,11 +54,14 @@ namespace OpenSim.Server.Handlers.Inventory | |||
54 | //private AuthedSessionCache m_session_cache = new AuthedSessionCache(INVENTORY_DEFAULT_SESSION_TIME); | 54 | //private AuthedSessionCache m_session_cache = new AuthedSessionCache(INVENTORY_DEFAULT_SESSION_TIME); |
55 | 55 | ||
56 | private string m_userserver_url; | 56 | private string m_userserver_url; |
57 | private string m_ConfigName = "InventoryService"; | 57 | protected string m_ConfigName = "InventoryService"; |
58 | 58 | ||
59 | public InventoryServiceInConnector(IConfigSource config, IHttpServer server, string configName) : | 59 | public InventoryServiceInConnector(IConfigSource config, IHttpServer server, string configName) : |
60 | base(config, server, configName) | 60 | base(config, server, configName) |
61 | { | 61 | { |
62 | if (configName != string.Empty) | ||
63 | m_ConfigName = configName; | ||
64 | |||
62 | IConfig serverConfig = config.Configs[m_ConfigName]; | 65 | IConfig serverConfig = config.Configs[m_ConfigName]; |
63 | if (serverConfig == null) | 66 | if (serverConfig == null) |
64 | throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName)); | 67 | throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName)); |
@@ -328,46 +331,9 @@ namespace OpenSim.Server.Handlers.Inventory | |||
328 | /// <param name="session_id"></param> | 331 | /// <param name="session_id"></param> |
329 | /// <param name="avatar_id"></param> | 332 | /// <param name="avatar_id"></param> |
330 | /// <returns></returns> | 333 | /// <returns></returns> |
331 | public bool CheckAuthSession(string session_id, string avatar_id) | 334 | public virtual bool CheckAuthSession(string session_id, string avatar_id) |
332 | { | 335 | { |
333 | if (m_doLookup) | 336 | return true; |
334 | { | ||
335 | m_log.InfoFormat("[INVENTORY IN CONNECTOR]: checking authed session {0} {1}", session_id, avatar_id); | ||
336 | |||
337 | //if (m_session_cache.getCachedSession(session_id, avatar_id) == null) | ||
338 | //{ | ||
339 | // cache miss, ask userserver | ||
340 | Hashtable requestData = new Hashtable(); | ||
341 | requestData["avatar_uuid"] = avatar_id; | ||
342 | requestData["session_id"] = session_id; | ||
343 | ArrayList SendParams = new ArrayList(); | ||
344 | SendParams.Add(requestData); | ||
345 | XmlRpcRequest UserReq = new XmlRpcRequest("check_auth_session", SendParams); | ||
346 | XmlRpcResponse UserResp = UserReq.Send(m_userserver_url, 3000); | ||
347 | |||
348 | Hashtable responseData = (Hashtable)UserResp.Value; | ||
349 | if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE") | ||
350 | { | ||
351 | m_log.Info("[INVENTORY IN CONNECTOR]: got authed session from userserver"); | ||
352 | //// add to cache; the session time will be automatically renewed | ||
353 | //m_session_cache.Add(session_id, avatar_id); | ||
354 | return true; | ||
355 | } | ||
356 | //} | ||
357 | //else | ||
358 | //{ | ||
359 | // // cache hits | ||
360 | // m_log.Info("[GRID AGENT INVENTORY]: got authed session from cache"); | ||
361 | // return true; | ||
362 | //} | ||
363 | |||
364 | m_log.Warn("[INVENTORY IN CONNECTOR]: unknown session_id, request rejected"); | ||
365 | return false; | ||
366 | } | ||
367 | else | ||
368 | { | ||
369 | return true; | ||
370 | } | ||
371 | } | 337 | } |
372 | 338 | ||
373 | } | 339 | } |
diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index 7e3e68b..16b05df 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs | |||
@@ -91,7 +91,7 @@ namespace OpenSim.Server.Handlers.Asset | |||
91 | sr.Close(); | 91 | sr.Close(); |
92 | body = body.Trim(); | 92 | body = body.Trim(); |
93 | 93 | ||
94 | m_log.DebugFormat("[XXX]: query String: {0}", body); | 94 | //m_log.DebugFormat("[XXX]: query String: {0}", body); |
95 | 95 | ||
96 | try | 96 | try |
97 | { | 97 | { |
@@ -144,6 +144,8 @@ namespace OpenSim.Server.Handlers.Asset | |||
144 | return HandleGetActiveGestures(request); | 144 | return HandleGetActiveGestures(request); |
145 | case "GETASSETPERMISSIONS": | 145 | case "GETASSETPERMISSIONS": |
146 | return HandleGetAssetPermissions(request); | 146 | return HandleGetAssetPermissions(request); |
147 | case "GETSYSTEMFOLDERS": | ||
148 | return HandleGetSystemFolders(request); | ||
147 | } | 149 | } |
148 | m_log.DebugFormat("[XINVENTORY HANDLER]: unknown method request: {0}", method); | 150 | m_log.DebugFormat("[XINVENTORY HANDLER]: unknown method request: {0}", method); |
149 | } | 151 | } |
@@ -157,6 +159,16 @@ namespace OpenSim.Server.Handlers.Asset | |||
157 | 159 | ||
158 | private byte[] FailureResult() | 160 | private byte[] FailureResult() |
159 | { | 161 | { |
162 | return BoolResult(false); | ||
163 | } | ||
164 | |||
165 | private byte[] SuccessResult() | ||
166 | { | ||
167 | return BoolResult(true); | ||
168 | } | ||
169 | |||
170 | private byte[] BoolResult(bool value) | ||
171 | { | ||
160 | XmlDocument doc = new XmlDocument(); | 172 | XmlDocument doc = new XmlDocument(); |
161 | 173 | ||
162 | XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, | 174 | XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, |
@@ -170,7 +182,7 @@ namespace OpenSim.Server.Handlers.Asset | |||
170 | doc.AppendChild(rootElement); | 182 | doc.AppendChild(rootElement); |
171 | 183 | ||
172 | XmlElement result = doc.CreateElement("", "RESULT", ""); | 184 | XmlElement result = doc.CreateElement("", "RESULT", ""); |
173 | result.AppendChild(doc.CreateTextNode("False")); | 185 | result.AppendChild(doc.CreateTextNode(value.ToString())); |
174 | 186 | ||
175 | rootElement.AppendChild(result); | 187 | rootElement.AppendChild(result); |
176 | 188 | ||
@@ -187,7 +199,7 @@ namespace OpenSim.Server.Handlers.Asset | |||
187 | 199 | ||
188 | return ms.ToArray(); | 200 | return ms.ToArray(); |
189 | } | 201 | } |
190 | 202 | ||
191 | byte[] HandleCreateUserInventory(Dictionary<string,object> request) | 203 | byte[] HandleCreateUserInventory(Dictionary<string,object> request) |
192 | { | 204 | { |
193 | Dictionary<string,object> result = new Dictionary<string,object>(); | 205 | Dictionary<string,object> result = new Dictionary<string,object>(); |
@@ -201,7 +213,7 @@ namespace OpenSim.Server.Handlers.Asset | |||
201 | result["RESULT"] = "False"; | 213 | result["RESULT"] = "False"; |
202 | 214 | ||
203 | string xmlString = ServerUtils.BuildXmlResponse(result); | 215 | string xmlString = ServerUtils.BuildXmlResponse(result); |
204 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | 216 | //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); |
205 | UTF8Encoding encoding = new UTF8Encoding(); | 217 | UTF8Encoding encoding = new UTF8Encoding(); |
206 | return encoding.GetBytes(xmlString); | 218 | return encoding.GetBytes(xmlString); |
207 | } | 219 | } |
@@ -216,11 +228,20 @@ namespace OpenSim.Server.Handlers.Asset | |||
216 | 228 | ||
217 | List<InventoryFolderBase> folders = m_InventoryService.GetInventorySkeleton(new UUID(request["PRINCIPAL"].ToString())); | 229 | List<InventoryFolderBase> folders = m_InventoryService.GetInventorySkeleton(new UUID(request["PRINCIPAL"].ToString())); |
218 | 230 | ||
219 | foreach (InventoryFolderBase f in folders) | 231 | Dictionary<string, object> sfolders = new Dictionary<string, object>(); |
220 | result[f.ID.ToString()] = EncodeFolder(f); | 232 | if (folders != null) |
233 | { | ||
234 | int i = 0; | ||
235 | foreach (InventoryFolderBase f in folders) | ||
236 | { | ||
237 | sfolders["folder_" + i.ToString()] = EncodeFolder(f); | ||
238 | i++; | ||
239 | } | ||
240 | } | ||
241 | result["FOLDERS"] = sfolders; | ||
221 | 242 | ||
222 | string xmlString = ServerUtils.BuildXmlResponse(result); | 243 | string xmlString = ServerUtils.BuildXmlResponse(result); |
223 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | 244 | //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); |
224 | UTF8Encoding encoding = new UTF8Encoding(); | 245 | UTF8Encoding encoding = new UTF8Encoding(); |
225 | return encoding.GetBytes(xmlString); | 246 | return encoding.GetBytes(xmlString); |
226 | } | 247 | } |
@@ -229,8 +250,14 @@ namespace OpenSim.Server.Handlers.Asset | |||
229 | { | 250 | { |
230 | Dictionary<string,object> result = new Dictionary<string,object>(); | 251 | Dictionary<string,object> result = new Dictionary<string,object>(); |
231 | 252 | ||
253 | UUID principal = UUID.Zero; | ||
254 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
255 | InventoryFolderBase rfolder = m_InventoryService.GetRootFolder(principal); | ||
256 | if (rfolder != null) | ||
257 | result["folder"] = EncodeFolder(rfolder); | ||
258 | |||
232 | string xmlString = ServerUtils.BuildXmlResponse(result); | 259 | string xmlString = ServerUtils.BuildXmlResponse(result); |
233 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | 260 | //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); |
234 | UTF8Encoding encoding = new UTF8Encoding(); | 261 | UTF8Encoding encoding = new UTF8Encoding(); |
235 | return encoding.GetBytes(xmlString); | 262 | return encoding.GetBytes(xmlString); |
236 | } | 263 | } |
@@ -238,9 +265,16 @@ namespace OpenSim.Server.Handlers.Asset | |||
238 | byte[] HandleGetFolderForType(Dictionary<string,object> request) | 265 | byte[] HandleGetFolderForType(Dictionary<string,object> request) |
239 | { | 266 | { |
240 | Dictionary<string,object> result = new Dictionary<string,object>(); | 267 | Dictionary<string,object> result = new Dictionary<string,object>(); |
268 | UUID principal = UUID.Zero; | ||
269 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
270 | int type = 0; | ||
271 | Int32.TryParse(request["TYPE"].ToString(), out type); | ||
272 | InventoryFolderBase folder = m_InventoryService.GetFolderForType(principal, (AssetType)type); | ||
273 | if (folder != null) | ||
274 | result["folder"] = EncodeFolder(folder); | ||
241 | 275 | ||
242 | string xmlString = ServerUtils.BuildXmlResponse(result); | 276 | string xmlString = ServerUtils.BuildXmlResponse(result); |
243 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | 277 | //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); |
244 | UTF8Encoding encoding = new UTF8Encoding(); | 278 | UTF8Encoding encoding = new UTF8Encoding(); |
245 | return encoding.GetBytes(xmlString); | 279 | return encoding.GetBytes(xmlString); |
246 | } | 280 | } |
@@ -248,9 +282,35 @@ namespace OpenSim.Server.Handlers.Asset | |||
248 | byte[] HandleGetFolderContent(Dictionary<string,object> request) | 282 | byte[] HandleGetFolderContent(Dictionary<string,object> request) |
249 | { | 283 | { |
250 | Dictionary<string,object> result = new Dictionary<string,object>(); | 284 | Dictionary<string,object> result = new Dictionary<string,object>(); |
285 | UUID principal = UUID.Zero; | ||
286 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
287 | UUID folderID = UUID.Zero; | ||
288 | UUID.TryParse(request["FOLDER"].ToString(), out folderID); | ||
289 | |||
290 | InventoryCollection icoll = m_InventoryService.GetFolderContent(principal, folderID); | ||
291 | if (icoll != null) | ||
292 | { | ||
293 | Dictionary<string, object> folders = new Dictionary<string, object>(); | ||
294 | int i = 0; | ||
295 | foreach (InventoryFolderBase f in icoll.Folders) | ||
296 | { | ||
297 | folders["folder_" + i.ToString()] = EncodeFolder(f); | ||
298 | i++; | ||
299 | } | ||
300 | result["FOLDERS"] = folders; | ||
301 | |||
302 | i = 0; | ||
303 | Dictionary<string, object> items = new Dictionary<string, object>(); | ||
304 | foreach (InventoryItemBase it in icoll.Items) | ||
305 | { | ||
306 | items["item_" + i.ToString()] = EncodeItem(it); | ||
307 | i++; | ||
308 | } | ||
309 | result["ITEMS"] = items; | ||
310 | } | ||
251 | 311 | ||
252 | string xmlString = ServerUtils.BuildXmlResponse(result); | 312 | string xmlString = ServerUtils.BuildXmlResponse(result); |
253 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | 313 | //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); |
254 | UTF8Encoding encoding = new UTF8Encoding(); | 314 | UTF8Encoding encoding = new UTF8Encoding(); |
255 | return encoding.GetBytes(xmlString); | 315 | return encoding.GetBytes(xmlString); |
256 | } | 316 | } |
@@ -258,9 +318,27 @@ namespace OpenSim.Server.Handlers.Asset | |||
258 | byte[] HandleGetFolderItems(Dictionary<string,object> request) | 318 | byte[] HandleGetFolderItems(Dictionary<string,object> request) |
259 | { | 319 | { |
260 | Dictionary<string,object> result = new Dictionary<string,object>(); | 320 | Dictionary<string,object> result = new Dictionary<string,object>(); |
321 | UUID principal = UUID.Zero; | ||
322 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
323 | UUID folderID = UUID.Zero; | ||
324 | UUID.TryParse(request["FOLDER"].ToString(), out folderID); | ||
261 | 325 | ||
326 | List<InventoryItemBase> items = m_InventoryService.GetFolderItems(principal, folderID); | ||
327 | Dictionary<string, object> sitems = new Dictionary<string, object>(); | ||
328 | |||
329 | if (items != null) | ||
330 | { | ||
331 | int i = 0; | ||
332 | foreach (InventoryItemBase item in items) | ||
333 | { | ||
334 | sitems["item_" + i.ToString()] = EncodeItem(item); | ||
335 | i++; | ||
336 | } | ||
337 | } | ||
338 | result["ITEMS"] = sitems; | ||
339 | |||
262 | string xmlString = ServerUtils.BuildXmlResponse(result); | 340 | string xmlString = ServerUtils.BuildXmlResponse(result); |
263 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | 341 | //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); |
264 | UTF8Encoding encoding = new UTF8Encoding(); | 342 | UTF8Encoding encoding = new UTF8Encoding(); |
265 | return encoding.GetBytes(xmlString); | 343 | return encoding.GetBytes(xmlString); |
266 | } | 344 | } |
@@ -268,109 +346,189 @@ namespace OpenSim.Server.Handlers.Asset | |||
268 | byte[] HandleAddFolder(Dictionary<string,object> request) | 346 | byte[] HandleAddFolder(Dictionary<string,object> request) |
269 | { | 347 | { |
270 | Dictionary<string,object> result = new Dictionary<string,object>(); | 348 | Dictionary<string,object> result = new Dictionary<string,object>(); |
349 | InventoryFolderBase folder = BuildFolder(request); | ||
271 | 350 | ||
272 | string xmlString = ServerUtils.BuildXmlResponse(result); | 351 | if (m_InventoryService.AddFolder(folder)) |
273 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | 352 | return SuccessResult(); |
274 | UTF8Encoding encoding = new UTF8Encoding(); | 353 | else |
275 | return encoding.GetBytes(xmlString); | 354 | return FailureResult(); |
276 | } | 355 | } |
277 | 356 | ||
278 | byte[] HandleUpdateFolder(Dictionary<string,object> request) | 357 | byte[] HandleUpdateFolder(Dictionary<string,object> request) |
279 | { | 358 | { |
280 | Dictionary<string,object> result = new Dictionary<string,object>(); | 359 | Dictionary<string, object> result = new Dictionary<string, object>(); |
360 | InventoryFolderBase folder = BuildFolder(request); | ||
281 | 361 | ||
282 | string xmlString = ServerUtils.BuildXmlResponse(result); | 362 | if (m_InventoryService.UpdateFolder(folder)) |
283 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | 363 | return SuccessResult(); |
284 | UTF8Encoding encoding = new UTF8Encoding(); | 364 | else |
285 | return encoding.GetBytes(xmlString); | 365 | return FailureResult(); |
286 | } | 366 | } |
287 | 367 | ||
288 | byte[] HandleMoveFolder(Dictionary<string,object> request) | 368 | byte[] HandleMoveFolder(Dictionary<string,object> request) |
289 | { | 369 | { |
290 | Dictionary<string,object> result = new Dictionary<string,object>(); | 370 | Dictionary<string, object> result = new Dictionary<string, object>(); |
371 | UUID parentID = UUID.Zero; | ||
372 | UUID.TryParse(request["ParentID"].ToString(), out parentID); | ||
373 | UUID folderID = UUID.Zero; | ||
374 | UUID.TryParse(request["ID"].ToString(), out folderID); | ||
375 | UUID principal = UUID.Zero; | ||
376 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
377 | |||
378 | InventoryFolderBase folder = new InventoryFolderBase(folderID, "", principal, parentID); | ||
379 | if (m_InventoryService.MoveFolder(folder)) | ||
380 | return SuccessResult(); | ||
381 | else | ||
382 | return FailureResult(); | ||
291 | 383 | ||
292 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
293 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | ||
294 | UTF8Encoding encoding = new UTF8Encoding(); | ||
295 | return encoding.GetBytes(xmlString); | ||
296 | } | 384 | } |
297 | 385 | ||
298 | byte[] HandleDeleteFolders(Dictionary<string,object> request) | 386 | byte[] HandleDeleteFolders(Dictionary<string,object> request) |
299 | { | 387 | { |
300 | Dictionary<string,object> result = new Dictionary<string,object>(); | 388 | Dictionary<string,object> result = new Dictionary<string,object>(); |
389 | UUID principal = UUID.Zero; | ||
390 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
391 | List<string> slist = (List<string>)request["FOLDERS"]; | ||
392 | List<UUID> uuids = new List<UUID>(); | ||
393 | foreach (string s in slist) | ||
394 | { | ||
395 | UUID u = UUID.Zero; | ||
396 | if (UUID.TryParse(s, out u)) | ||
397 | uuids.Add(u); | ||
398 | } | ||
301 | 399 | ||
302 | string xmlString = ServerUtils.BuildXmlResponse(result); | 400 | if (m_InventoryService.DeleteFolders(principal, uuids)) |
303 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | 401 | return SuccessResult(); |
304 | UTF8Encoding encoding = new UTF8Encoding(); | 402 | else |
305 | return encoding.GetBytes(xmlString); | 403 | return |
404 | FailureResult(); | ||
306 | } | 405 | } |
307 | 406 | ||
308 | byte[] HandlePurgeFolder(Dictionary<string,object> request) | 407 | byte[] HandlePurgeFolder(Dictionary<string,object> request) |
309 | { | 408 | { |
310 | Dictionary<string,object> result = new Dictionary<string,object>(); | 409 | Dictionary<string,object> result = new Dictionary<string,object>(); |
410 | UUID folderID = UUID.Zero; | ||
411 | UUID.TryParse(request["ID"].ToString(), out folderID); | ||
311 | 412 | ||
312 | string xmlString = ServerUtils.BuildXmlResponse(result); | 413 | InventoryFolderBase folder = new InventoryFolderBase(folderID); |
313 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | 414 | if (m_InventoryService.PurgeFolder(folder)) |
314 | UTF8Encoding encoding = new UTF8Encoding(); | 415 | return SuccessResult(); |
315 | return encoding.GetBytes(xmlString); | 416 | else |
417 | return FailureResult(); | ||
316 | } | 418 | } |
317 | 419 | ||
318 | byte[] HandleAddItem(Dictionary<string,object> request) | 420 | byte[] HandleAddItem(Dictionary<string,object> request) |
319 | { | 421 | { |
320 | Dictionary<string,object> result = new Dictionary<string,object>(); | 422 | Dictionary<string, object> result = new Dictionary<string, object>(); |
423 | InventoryItemBase item = BuildItem(request); | ||
321 | 424 | ||
322 | string xmlString = ServerUtils.BuildXmlResponse(result); | 425 | if (m_InventoryService.AddItem(item)) |
323 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | 426 | return SuccessResult(); |
324 | UTF8Encoding encoding = new UTF8Encoding(); | 427 | else |
325 | return encoding.GetBytes(xmlString); | 428 | return FailureResult(); |
326 | } | 429 | } |
327 | 430 | ||
328 | byte[] HandleUpdateItem(Dictionary<string,object> request) | 431 | byte[] HandleUpdateItem(Dictionary<string,object> request) |
329 | { | 432 | { |
330 | Dictionary<string,object> result = new Dictionary<string,object>(); | 433 | Dictionary<string, object> result = new Dictionary<string, object>(); |
434 | InventoryItemBase item = BuildItem(request); | ||
331 | 435 | ||
332 | string xmlString = ServerUtils.BuildXmlResponse(result); | 436 | if (m_InventoryService.UpdateItem(item)) |
333 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | 437 | return SuccessResult(); |
334 | UTF8Encoding encoding = new UTF8Encoding(); | 438 | else |
335 | return encoding.GetBytes(xmlString); | 439 | return FailureResult(); |
336 | } | 440 | } |
337 | 441 | ||
338 | byte[] HandleMoveItems(Dictionary<string,object> request) | 442 | byte[] HandleMoveItems(Dictionary<string,object> request) |
339 | { | 443 | { |
340 | Dictionary<string,object> result = new Dictionary<string,object>(); | 444 | Dictionary<string,object> result = new Dictionary<string,object>(); |
445 | List<string> idlist = (List<string>)request["IDLIST"]; | ||
446 | List<string> destlist = (List<string>)request["DESTLIST"]; | ||
447 | UUID principal = UUID.Zero; | ||
448 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
341 | 449 | ||
342 | string xmlString = ServerUtils.BuildXmlResponse(result); | 450 | List<InventoryItemBase> items = new List<InventoryItemBase>(); |
343 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | 451 | int n = 0; |
344 | UTF8Encoding encoding = new UTF8Encoding(); | 452 | try |
345 | return encoding.GetBytes(xmlString); | 453 | { |
454 | foreach (string s in idlist) | ||
455 | { | ||
456 | UUID u = UUID.Zero; | ||
457 | if (UUID.TryParse(s, out u)) | ||
458 | { | ||
459 | UUID fid = UUID.Zero; | ||
460 | if (UUID.TryParse(destlist[n++], out fid)) | ||
461 | { | ||
462 | InventoryItemBase item = new InventoryItemBase(u, principal); | ||
463 | item.Folder = fid; | ||
464 | items.Add(item); | ||
465 | } | ||
466 | } | ||
467 | } | ||
468 | } | ||
469 | catch (Exception e) | ||
470 | { | ||
471 | m_log.DebugFormat("[XINVENTORY IN CONNECTOR]: Exception in HandleMoveItems: {0}", e.Message); | ||
472 | return FailureResult(); | ||
473 | } | ||
474 | |||
475 | if (m_InventoryService.MoveItems(principal, items)) | ||
476 | return SuccessResult(); | ||
477 | else | ||
478 | return FailureResult(); | ||
346 | } | 479 | } |
347 | 480 | ||
348 | byte[] HandleDeleteItems(Dictionary<string,object> request) | 481 | byte[] HandleDeleteItems(Dictionary<string,object> request) |
349 | { | 482 | { |
350 | Dictionary<string,object> result = new Dictionary<string,object>(); | 483 | Dictionary<string, object> result = new Dictionary<string, object>(); |
484 | UUID principal = UUID.Zero; | ||
485 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
486 | List<string> slist = (List<string>)request["ITEMS"]; | ||
487 | List<UUID> uuids = new List<UUID>(); | ||
488 | foreach (string s in slist) | ||
489 | { | ||
490 | UUID u = UUID.Zero; | ||
491 | if (UUID.TryParse(s, out u)) | ||
492 | uuids.Add(u); | ||
493 | } | ||
351 | 494 | ||
352 | string xmlString = ServerUtils.BuildXmlResponse(result); | 495 | if (m_InventoryService.DeleteItems(principal, uuids)) |
353 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | 496 | return SuccessResult(); |
354 | UTF8Encoding encoding = new UTF8Encoding(); | 497 | else |
355 | return encoding.GetBytes(xmlString); | 498 | return |
499 | FailureResult(); | ||
356 | } | 500 | } |
357 | 501 | ||
358 | byte[] HandleGetItem(Dictionary<string,object> request) | 502 | byte[] HandleGetItem(Dictionary<string,object> request) |
359 | { | 503 | { |
360 | Dictionary<string,object> result = new Dictionary<string,object>(); | 504 | Dictionary<string,object> result = new Dictionary<string,object>(); |
505 | UUID id = UUID.Zero; | ||
506 | UUID.TryParse(request["ID"].ToString(), out id); | ||
507 | |||
508 | InventoryItemBase item = new InventoryItemBase(id); | ||
509 | item = m_InventoryService.GetItem(item); | ||
510 | if (item != null) | ||
511 | result["item"] = EncodeItem(item); | ||
361 | 512 | ||
362 | string xmlString = ServerUtils.BuildXmlResponse(result); | 513 | string xmlString = ServerUtils.BuildXmlResponse(result); |
363 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | 514 | //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); |
364 | UTF8Encoding encoding = new UTF8Encoding(); | 515 | UTF8Encoding encoding = new UTF8Encoding(); |
365 | return encoding.GetBytes(xmlString); | 516 | return encoding.GetBytes(xmlString); |
366 | } | 517 | } |
367 | 518 | ||
368 | byte[] HandleGetFolder(Dictionary<string,object> request) | 519 | byte[] HandleGetFolder(Dictionary<string,object> request) |
369 | { | 520 | { |
370 | Dictionary<string,object> result = new Dictionary<string,object>(); | 521 | Dictionary<string, object> result = new Dictionary<string, object>(); |
522 | UUID id = UUID.Zero; | ||
523 | UUID.TryParse(request["ID"].ToString(), out id); | ||
524 | |||
525 | InventoryFolderBase folder = new InventoryFolderBase(id); | ||
526 | folder = m_InventoryService.GetFolder(folder); | ||
527 | if (folder != null) | ||
528 | result["folder"] = EncodeFolder(folder); | ||
371 | 529 | ||
372 | string xmlString = ServerUtils.BuildXmlResponse(result); | 530 | string xmlString = ServerUtils.BuildXmlResponse(result); |
373 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | 531 | //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); |
374 | UTF8Encoding encoding = new UTF8Encoding(); | 532 | UTF8Encoding encoding = new UTF8Encoding(); |
375 | return encoding.GetBytes(xmlString); | 533 | return encoding.GetBytes(xmlString); |
376 | } | 534 | } |
@@ -378,9 +536,24 @@ namespace OpenSim.Server.Handlers.Asset | |||
378 | byte[] HandleGetActiveGestures(Dictionary<string,object> request) | 536 | byte[] HandleGetActiveGestures(Dictionary<string,object> request) |
379 | { | 537 | { |
380 | Dictionary<string,object> result = new Dictionary<string,object>(); | 538 | Dictionary<string,object> result = new Dictionary<string,object>(); |
539 | UUID principal = UUID.Zero; | ||
540 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
541 | |||
542 | List<InventoryItemBase> gestures = m_InventoryService.GetActiveGestures(principal); | ||
543 | Dictionary<string, object> items = new Dictionary<string, object>(); | ||
544 | if (gestures != null) | ||
545 | { | ||
546 | int i = 0; | ||
547 | foreach (InventoryItemBase item in gestures) | ||
548 | { | ||
549 | items["item_" + i.ToString()] = EncodeItem(item); | ||
550 | i++; | ||
551 | } | ||
552 | } | ||
553 | result["ITEMS"] = items; | ||
381 | 554 | ||
382 | string xmlString = ServerUtils.BuildXmlResponse(result); | 555 | string xmlString = ServerUtils.BuildXmlResponse(result); |
383 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | 556 | //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); |
384 | UTF8Encoding encoding = new UTF8Encoding(); | 557 | UTF8Encoding encoding = new UTF8Encoding(); |
385 | return encoding.GetBytes(xmlString); | 558 | return encoding.GetBytes(xmlString); |
386 | } | 559 | } |
@@ -388,9 +561,40 @@ namespace OpenSim.Server.Handlers.Asset | |||
388 | byte[] HandleGetAssetPermissions(Dictionary<string,object> request) | 561 | byte[] HandleGetAssetPermissions(Dictionary<string,object> request) |
389 | { | 562 | { |
390 | Dictionary<string,object> result = new Dictionary<string,object>(); | 563 | Dictionary<string,object> result = new Dictionary<string,object>(); |
564 | UUID principal = UUID.Zero; | ||
565 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
566 | UUID assetID = UUID.Zero; | ||
567 | UUID.TryParse(request["ASSET"].ToString(), out assetID); | ||
391 | 568 | ||
569 | int perms = m_InventoryService.GetAssetPermissions(principal, assetID); | ||
570 | |||
571 | result["RESULT"] = perms.ToString(); | ||
572 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
573 | //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | ||
574 | UTF8Encoding encoding = new UTF8Encoding(); | ||
575 | return encoding.GetBytes(xmlString); | ||
576 | } | ||
577 | |||
578 | byte[] HandleGetSystemFolders(Dictionary<string, object> request) | ||
579 | { | ||
580 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
581 | UUID principal = UUID.Zero; | ||
582 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
583 | |||
584 | Dictionary<AssetType, InventoryFolderBase> sfolders = GetSystemFolders(principal); | ||
585 | //m_log.DebugFormat("[XXX]: SystemFolders got {0} folders", sfolders.Count); | ||
586 | |||
587 | Dictionary<string, object> folders = new Dictionary<string, object>(); | ||
588 | int i = 0; | ||
589 | foreach (KeyValuePair<AssetType, InventoryFolderBase> kvp in sfolders) | ||
590 | { | ||
591 | folders["folder_" + i.ToString()] = EncodeFolder(kvp.Value); | ||
592 | i++; | ||
593 | } | ||
594 | result["FOLDERS"] = folders; | ||
595 | |||
392 | string xmlString = ServerUtils.BuildXmlResponse(result); | 596 | string xmlString = ServerUtils.BuildXmlResponse(result); |
393 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | 597 | //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); |
394 | UTF8Encoding encoding = new UTF8Encoding(); | 598 | UTF8Encoding encoding = new UTF8Encoding(); |
395 | return encoding.GetBytes(xmlString); | 599 | return encoding.GetBytes(xmlString); |
396 | } | 600 | } |
@@ -409,6 +613,34 @@ namespace OpenSim.Server.Handlers.Asset | |||
409 | return ret; | 613 | return ret; |
410 | } | 614 | } |
411 | 615 | ||
616 | private Dictionary<string, object> EncodeItem(InventoryItemBase item) | ||
617 | { | ||
618 | Dictionary<string, object> ret = new Dictionary<string, object>(); | ||
619 | |||
620 | ret["AssetID"] = item.AssetID.ToString(); | ||
621 | ret["AssetType"] = item.AssetType.ToString(); | ||
622 | ret["BasePermissions"] = item.BasePermissions.ToString(); | ||
623 | ret["CreationDate"] = item.CreationDate.ToString(); | ||
624 | ret["CreatorId"] = item.CreatorId.ToString(); | ||
625 | ret["CurrentPermissions"] = item.CurrentPermissions.ToString(); | ||
626 | ret["Description"] = item.Description.ToString(); | ||
627 | ret["EveryOnePermissions"] = item.EveryOnePermissions.ToString(); | ||
628 | ret["Flags"] = item.Flags.ToString(); | ||
629 | ret["Folder"] = item.Folder.ToString(); | ||
630 | ret["GroupID"] = item.GroupID.ToString(); | ||
631 | ret["GroupOwned"] = item.GroupOwned.ToString(); | ||
632 | ret["GroupPermissions"] = item.GroupPermissions.ToString(); | ||
633 | ret["ID"] = item.ID.ToString(); | ||
634 | ret["InvType"] = item.InvType.ToString(); | ||
635 | ret["Name"] = item.Name.ToString(); | ||
636 | ret["NextPermissions"] = item.NextPermissions.ToString(); | ||
637 | ret["Owner"] = item.Owner.ToString(); | ||
638 | ret["SalePrice"] = item.SalePrice.ToString(); | ||
639 | ret["SaleType"] = item.SaleType.ToString(); | ||
640 | |||
641 | return ret; | ||
642 | } | ||
643 | |||
412 | private InventoryFolderBase BuildFolder(Dictionary<string,object> data) | 644 | private InventoryFolderBase BuildFolder(Dictionary<string,object> data) |
413 | { | 645 | { |
414 | InventoryFolderBase folder = new InventoryFolderBase(); | 646 | InventoryFolderBase folder = new InventoryFolderBase(); |
@@ -450,5 +682,31 @@ namespace OpenSim.Server.Handlers.Asset | |||
450 | 682 | ||
451 | return item; | 683 | return item; |
452 | } | 684 | } |
685 | |||
686 | #region Extra | ||
687 | private Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID) | ||
688 | { | ||
689 | InventoryFolderBase root = m_InventoryService.GetRootFolder(userID); | ||
690 | if (root != null) | ||
691 | { | ||
692 | InventoryCollection content = m_InventoryService.GetFolderContent(userID, root.ID); | ||
693 | if (content != null) | ||
694 | { | ||
695 | Dictionary<AssetType, InventoryFolderBase> folders = new Dictionary<AssetType, InventoryFolderBase>(); | ||
696 | foreach (InventoryFolderBase folder in content.Folders) | ||
697 | { | ||
698 | if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown)) | ||
699 | folders[(AssetType)folder.Type] = folder; | ||
700 | } | ||
701 | // Put the root folder there, as type Folder | ||
702 | folders[AssetType.Folder] = root; | ||
703 | return folders; | ||
704 | } | ||
705 | } | ||
706 | m_log.WarnFormat("[XINVENTORY SERVICE]: System folders for {0} not found", userID); | ||
707 | return new Dictionary<AssetType, InventoryFolderBase>(); | ||
708 | } | ||
709 | #endregion | ||
710 | |||
453 | } | 711 | } |
454 | } | 712 | } |