aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs')
-rw-r--r--OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs265
1 files changed, 219 insertions, 46 deletions
diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
index 03d4d7a..3ab1622 100644
--- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
+++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
@@ -159,6 +159,16 @@ namespace OpenSim.Server.Handlers.Asset
159 159
160 private byte[] FailureResult() 160 private byte[] FailureResult()
161 { 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 {
162 XmlDocument doc = new XmlDocument(); 172 XmlDocument doc = new XmlDocument();
163 173
164 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, 174 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
@@ -172,7 +182,7 @@ namespace OpenSim.Server.Handlers.Asset
172 doc.AppendChild(rootElement); 182 doc.AppendChild(rootElement);
173 183
174 XmlElement result = doc.CreateElement("", "RESULT", ""); 184 XmlElement result = doc.CreateElement("", "RESULT", "");
175 result.AppendChild(doc.CreateTextNode("False")); 185 result.AppendChild(doc.CreateTextNode(value.ToString()));
176 186
177 rootElement.AppendChild(result); 187 rootElement.AppendChild(result);
178 188
@@ -218,8 +228,9 @@ namespace OpenSim.Server.Handlers.Asset
218 228
219 List<InventoryFolderBase> folders = m_InventoryService.GetInventorySkeleton(new UUID(request["PRINCIPAL"].ToString())); 229 List<InventoryFolderBase> folders = m_InventoryService.GetInventorySkeleton(new UUID(request["PRINCIPAL"].ToString()));
220 230
221 foreach (InventoryFolderBase f in folders) 231 if (folders != null)
222 result[f.ID.ToString()] = EncodeFolder(f); 232 foreach (InventoryFolderBase f in folders)
233 result[f.ID.ToString()] = EncodeFolder(f);
223 234
224 string xmlString = ServerUtils.BuildXmlResponse(result); 235 string xmlString = ServerUtils.BuildXmlResponse(result);
225 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 236 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
@@ -231,6 +242,12 @@ namespace OpenSim.Server.Handlers.Asset
231 { 242 {
232 Dictionary<string,object> result = new Dictionary<string,object>(); 243 Dictionary<string,object> result = new Dictionary<string,object>();
233 244
245 UUID principal = UUID.Zero;
246 UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
247 InventoryFolderBase rfolder = m_InventoryService.GetRootFolder(principal);
248 if (rfolder != null)
249 result[rfolder.ID.ToString()] = EncodeFolder(rfolder);
250
234 string xmlString = ServerUtils.BuildXmlResponse(result); 251 string xmlString = ServerUtils.BuildXmlResponse(result);
235 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 252 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
236 UTF8Encoding encoding = new UTF8Encoding(); 253 UTF8Encoding encoding = new UTF8Encoding();
@@ -240,6 +257,13 @@ namespace OpenSim.Server.Handlers.Asset
240 byte[] HandleGetFolderForType(Dictionary<string,object> request) 257 byte[] HandleGetFolderForType(Dictionary<string,object> request)
241 { 258 {
242 Dictionary<string,object> result = new Dictionary<string,object>(); 259 Dictionary<string,object> result = new Dictionary<string,object>();
260 UUID principal = UUID.Zero;
261 UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
262 int type = 0;
263 Int32.TryParse(request["TYPE"].ToString(), out type);
264 InventoryFolderBase folder = m_InventoryService.GetFolderForType(principal, (AssetType)type);
265 if (folder != null)
266 result[folder.ID.ToString()] = EncodeFolder(folder);
243 267
244 string xmlString = ServerUtils.BuildXmlResponse(result); 268 string xmlString = ServerUtils.BuildXmlResponse(result);
245 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 269 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
@@ -250,6 +274,24 @@ namespace OpenSim.Server.Handlers.Asset
250 byte[] HandleGetFolderContent(Dictionary<string,object> request) 274 byte[] HandleGetFolderContent(Dictionary<string,object> request)
251 { 275 {
252 Dictionary<string,object> result = new Dictionary<string,object>(); 276 Dictionary<string,object> result = new Dictionary<string,object>();
277 UUID principal = UUID.Zero;
278 UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
279 UUID folderID = UUID.Zero;
280 UUID.TryParse(request["FOLDER"].ToString(), out folderID);
281
282 InventoryCollection icoll = m_InventoryService.GetFolderContent(principal, folderID);
283 if (icoll != null)
284 {
285 Dictionary<string, object> folders = new Dictionary<string, object>();
286 foreach (InventoryFolderBase f in icoll.Folders)
287 folders[f.ID.ToString()] = EncodeFolder(f);
288 result["FOLDERS"] = folders;
289
290 Dictionary<string, object> items = new Dictionary<string, object>();
291 foreach (InventoryItemBase i in icoll.Items)
292 items[i.ID.ToString()] = EncodeItem(i);
293 result["ITEMS"] = items;
294 }
253 295
254 string xmlString = ServerUtils.BuildXmlResponse(result); 296 string xmlString = ServerUtils.BuildXmlResponse(result);
255 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 297 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
@@ -260,7 +302,16 @@ namespace OpenSim.Server.Handlers.Asset
260 byte[] HandleGetFolderItems(Dictionary<string,object> request) 302 byte[] HandleGetFolderItems(Dictionary<string,object> request)
261 { 303 {
262 Dictionary<string,object> result = new Dictionary<string,object>(); 304 Dictionary<string,object> result = new Dictionary<string,object>();
263 305 UUID principal = UUID.Zero;
306 UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
307 UUID folderID = UUID.Zero;
308 UUID.TryParse(request["FOLDER"].ToString(), out folderID);
309
310 List<InventoryItemBase> items = m_InventoryService.GetFolderItems(principal, folderID);
311 if (items != null)
312 foreach (InventoryItemBase item in items)
313 result[item.ID.ToString()] = EncodeItem(item);
314
264 string xmlString = ServerUtils.BuildXmlResponse(result); 315 string xmlString = ServerUtils.BuildXmlResponse(result);
265 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 316 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
266 UTF8Encoding encoding = new UTF8Encoding(); 317 UTF8Encoding encoding = new UTF8Encoding();
@@ -270,96 +321,169 @@ namespace OpenSim.Server.Handlers.Asset
270 byte[] HandleAddFolder(Dictionary<string,object> request) 321 byte[] HandleAddFolder(Dictionary<string,object> request)
271 { 322 {
272 Dictionary<string,object> result = new Dictionary<string,object>(); 323 Dictionary<string,object> result = new Dictionary<string,object>();
324 InventoryFolderBase folder = BuildFolder(request);
273 325
274 string xmlString = ServerUtils.BuildXmlResponse(result); 326 if (m_InventoryService.AddFolder(folder))
275 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 327 return SuccessResult();
276 UTF8Encoding encoding = new UTF8Encoding(); 328 else
277 return encoding.GetBytes(xmlString); 329 return FailureResult();
278 } 330 }
279 331
280 byte[] HandleUpdateFolder(Dictionary<string,object> request) 332 byte[] HandleUpdateFolder(Dictionary<string,object> request)
281 { 333 {
282 Dictionary<string,object> result = new Dictionary<string,object>(); 334 Dictionary<string, object> result = new Dictionary<string, object>();
335 InventoryFolderBase folder = BuildFolder(request);
283 336
284 string xmlString = ServerUtils.BuildXmlResponse(result); 337 if (m_InventoryService.UpdateFolder(folder))
285 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 338 return SuccessResult();
286 UTF8Encoding encoding = new UTF8Encoding(); 339 else
287 return encoding.GetBytes(xmlString); 340 return FailureResult();
288 } 341 }
289 342
290 byte[] HandleMoveFolder(Dictionary<string,object> request) 343 byte[] HandleMoveFolder(Dictionary<string,object> request)
291 { 344 {
292 Dictionary<string,object> result = new Dictionary<string,object>(); 345 Dictionary<string, object> result = new Dictionary<string, object>();
346 UUID parentID = UUID.Zero;
347 UUID.TryParse(request["ParentID"].ToString(), out parentID);
348 UUID folderID = UUID.Zero;
349 UUID.TryParse(request["ID"].ToString(), out folderID);
350 UUID principal = UUID.Zero;
351 UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
352
353 InventoryFolderBase folder = new InventoryFolderBase(folderID, "", principal, parentID);
354 if (m_InventoryService.MoveFolder(folder))
355 return SuccessResult();
356 else
357 return FailureResult();
293 358
294 string xmlString = ServerUtils.BuildXmlResponse(result);
295 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
296 UTF8Encoding encoding = new UTF8Encoding();
297 return encoding.GetBytes(xmlString);
298 } 359 }
299 360
300 byte[] HandleDeleteFolders(Dictionary<string,object> request) 361 byte[] HandleDeleteFolders(Dictionary<string,object> request)
301 { 362 {
302 Dictionary<string,object> result = new Dictionary<string,object>(); 363 Dictionary<string,object> result = new Dictionary<string,object>();
364 UUID principal = UUID.Zero;
365 UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
366 List<string> slist = (List<string>)request["FOLDERS"];
367 List<UUID> uuids = new List<UUID>();
368 foreach (string s in slist)
369 {
370 UUID u = UUID.Zero;
371 if (UUID.TryParse(s, out u))
372 uuids.Add(u);
373 }
303 374
304 string xmlString = ServerUtils.BuildXmlResponse(result); 375 if (m_InventoryService.DeleteFolders(principal, uuids))
305 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 376 return SuccessResult();
306 UTF8Encoding encoding = new UTF8Encoding(); 377 else
307 return encoding.GetBytes(xmlString); 378 return
379 FailureResult();
308 } 380 }
309 381
310 byte[] HandlePurgeFolder(Dictionary<string,object> request) 382 byte[] HandlePurgeFolder(Dictionary<string,object> request)
311 { 383 {
312 Dictionary<string,object> result = new Dictionary<string,object>(); 384 Dictionary<string,object> result = new Dictionary<string,object>();
385 UUID folderID = UUID.Zero;
386 UUID.TryParse(request["ID"].ToString(), out folderID);
313 387
314 string xmlString = ServerUtils.BuildXmlResponse(result); 388 InventoryFolderBase folder = new InventoryFolderBase(folderID);
315 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 389 if (m_InventoryService.PurgeFolder(folder))
316 UTF8Encoding encoding = new UTF8Encoding(); 390 return SuccessResult();
317 return encoding.GetBytes(xmlString); 391 else
392 return FailureResult();
318 } 393 }
319 394
320 byte[] HandleAddItem(Dictionary<string,object> request) 395 byte[] HandleAddItem(Dictionary<string,object> request)
321 { 396 {
322 Dictionary<string,object> result = new Dictionary<string,object>(); 397 Dictionary<string, object> result = new Dictionary<string, object>();
398 InventoryItemBase item = BuildItem(request);
323 399
324 string xmlString = ServerUtils.BuildXmlResponse(result); 400 if (m_InventoryService.AddItem(item))
325 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 401 return SuccessResult();
326 UTF8Encoding encoding = new UTF8Encoding(); 402 else
327 return encoding.GetBytes(xmlString); 403 return FailureResult();
328 } 404 }
329 405
330 byte[] HandleUpdateItem(Dictionary<string,object> request) 406 byte[] HandleUpdateItem(Dictionary<string,object> request)
331 { 407 {
332 Dictionary<string,object> result = new Dictionary<string,object>(); 408 Dictionary<string, object> result = new Dictionary<string, object>();
409 InventoryItemBase item = BuildItem(request);
333 410
334 string xmlString = ServerUtils.BuildXmlResponse(result); 411 if (m_InventoryService.UpdateItem(item))
335 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 412 return SuccessResult();
336 UTF8Encoding encoding = new UTF8Encoding(); 413 else
337 return encoding.GetBytes(xmlString); 414 return FailureResult();
338 } 415 }
339 416
340 byte[] HandleMoveItems(Dictionary<string,object> request) 417 byte[] HandleMoveItems(Dictionary<string,object> request)
341 { 418 {
342 Dictionary<string,object> result = new Dictionary<string,object>(); 419 Dictionary<string,object> result = new Dictionary<string,object>();
420 List<string> idlist = (List<string>)request["IDLIST"];
421 List<string> destlist = (List<string>)request["DESTLIST"];
422 UUID principal = UUID.Zero;
423 UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
343 424
344 string xmlString = ServerUtils.BuildXmlResponse(result); 425 List<InventoryItemBase> items = new List<InventoryItemBase>();
345 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 426 int n = 0;
346 UTF8Encoding encoding = new UTF8Encoding(); 427 try
347 return encoding.GetBytes(xmlString); 428 {
429 foreach (string s in idlist)
430 {
431 UUID u = UUID.Zero;
432 if (UUID.TryParse(s, out u))
433 {
434 UUID fid = UUID.Zero;
435 if (UUID.TryParse(destlist[n++], out fid))
436 {
437 InventoryItemBase item = new InventoryItemBase(u, principal);
438 item.Folder = fid;
439 items.Add(item);
440 }
441 }
442 }
443 }
444 catch (Exception e)
445 {
446 m_log.DebugFormat("[XINVENTORY IN CONNECTOR]: Exception in HandleMoveItems: {0}", e.Message);
447 return FailureResult();
448 }
449
450 if (m_InventoryService.MoveItems(principal, items))
451 return SuccessResult();
452 else
453 return FailureResult();
348 } 454 }
349 455
350 byte[] HandleDeleteItems(Dictionary<string,object> request) 456 byte[] HandleDeleteItems(Dictionary<string,object> request)
351 { 457 {
352 Dictionary<string,object> result = new Dictionary<string,object>(); 458 Dictionary<string, object> result = new Dictionary<string, object>();
459 UUID principal = UUID.Zero;
460 UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
461 List<string> slist = (List<string>)request["ITEMS"];
462 List<UUID> uuids = new List<UUID>();
463 foreach (string s in slist)
464 {
465 UUID u = UUID.Zero;
466 if (UUID.TryParse(s, out u))
467 uuids.Add(u);
468 }
353 469
354 string xmlString = ServerUtils.BuildXmlResponse(result); 470 if (m_InventoryService.DeleteItems(principal, uuids))
355 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 471 return SuccessResult();
356 UTF8Encoding encoding = new UTF8Encoding(); 472 else
357 return encoding.GetBytes(xmlString); 473 return
474 FailureResult();
358 } 475 }
359 476
360 byte[] HandleGetItem(Dictionary<string,object> request) 477 byte[] HandleGetItem(Dictionary<string,object> request)
361 { 478 {
362 Dictionary<string,object> result = new Dictionary<string,object>(); 479 Dictionary<string,object> result = new Dictionary<string,object>();
480 UUID id = UUID.Zero;
481 UUID.TryParse(request["ID"].ToString(), out id);
482
483 InventoryItemBase item = new InventoryItemBase(id);
484 item = m_InventoryService.GetItem(item);
485 if (item != null)
486 result[item.ID.ToString()] = EncodeItem(item);
363 487
364 string xmlString = ServerUtils.BuildXmlResponse(result); 488 string xmlString = ServerUtils.BuildXmlResponse(result);
365 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 489 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
@@ -369,7 +493,14 @@ namespace OpenSim.Server.Handlers.Asset
369 493
370 byte[] HandleGetFolder(Dictionary<string,object> request) 494 byte[] HandleGetFolder(Dictionary<string,object> request)
371 { 495 {
372 Dictionary<string,object> result = new Dictionary<string,object>(); 496 Dictionary<string, object> result = new Dictionary<string, object>();
497 UUID id = UUID.Zero;
498 UUID.TryParse(request["ID"].ToString(), out id);
499
500 InventoryFolderBase folder = new InventoryFolderBase(id);
501 folder = m_InventoryService.GetFolder(folder);
502 if (folder != null)
503 result[folder.ID.ToString()] = EncodeFolder(folder);
373 504
374 string xmlString = ServerUtils.BuildXmlResponse(result); 505 string xmlString = ServerUtils.BuildXmlResponse(result);
375 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 506 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
@@ -380,6 +511,13 @@ namespace OpenSim.Server.Handlers.Asset
380 byte[] HandleGetActiveGestures(Dictionary<string,object> request) 511 byte[] HandleGetActiveGestures(Dictionary<string,object> request)
381 { 512 {
382 Dictionary<string,object> result = new Dictionary<string,object>(); 513 Dictionary<string,object> result = new Dictionary<string,object>();
514 UUID principal = UUID.Zero;
515 UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
516
517 List<InventoryItemBase> gestures = m_InventoryService.GetActiveGestures(principal);
518 if (gestures != null)
519 foreach (InventoryItemBase item in gestures)
520 result[item.ID.ToString()] = EncodeItem(item);
383 521
384 string xmlString = ServerUtils.BuildXmlResponse(result); 522 string xmlString = ServerUtils.BuildXmlResponse(result);
385 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 523 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
@@ -390,7 +528,14 @@ namespace OpenSim.Server.Handlers.Asset
390 byte[] HandleGetAssetPermissions(Dictionary<string,object> request) 528 byte[] HandleGetAssetPermissions(Dictionary<string,object> request)
391 { 529 {
392 Dictionary<string,object> result = new Dictionary<string,object>(); 530 Dictionary<string,object> result = new Dictionary<string,object>();
531 UUID principal = UUID.Zero;
532 UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
533 UUID assetID = UUID.Zero;
534 UUID.TryParse(request["ASSET"].ToString(), out assetID);
393 535
536 int perms = m_InventoryService.GetAssetPermissions(principal, assetID);
537
538 result["RESULT"] = perms.ToString();
394 string xmlString = ServerUtils.BuildXmlResponse(result); 539 string xmlString = ServerUtils.BuildXmlResponse(result);
395 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 540 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
396 UTF8Encoding encoding = new UTF8Encoding(); 541 UTF8Encoding encoding = new UTF8Encoding();
@@ -411,6 +556,34 @@ namespace OpenSim.Server.Handlers.Asset
411 return ret; 556 return ret;
412 } 557 }
413 558
559 private Dictionary<string, object> EncodeItem(InventoryItemBase item)
560 {
561 Dictionary<string, object> ret = new Dictionary<string, object>();
562
563 ret["AssetID"] = item.AssetID.ToString();
564 ret["AssetType"] = item.AssetType.ToString();
565 ret["BasePermissions"] = item.BasePermissions.ToString();
566 ret["CreationDate"] = item.CreationDate.ToString();
567 ret["CreatorId"] = item.CreatorId.ToString();
568 ret["CurrentPermissions"] = item.CurrentPermissions.ToString();
569 ret["Description"] = item.Description.ToString();
570 ret["EveryOnePermissions"] = item.EveryOnePermissions.ToString();
571 ret["Flags"] = item.Flags.ToString();
572 ret["Folder"] = item.Folder.ToString();
573 ret["GroupID"] = item.GroupID.ToString();
574 ret["GroupedOwned"] = item.GroupOwned.ToString();
575 ret["GroupPermissions"] = item.GroupPermissions.ToString();
576 ret["ID"] = item.ID.ToString();
577 ret["InvType"] = item.InvType.ToString();
578 ret["Name"] = item.Name.ToString();
579 ret["NextPermissions"] = item.NextPermissions.ToString();
580 ret["Owner"] = item.Owner.ToString();
581 ret["SalePrice"] = item.SalePrice.ToString();
582 ret["SaleType"] = item.SaleType.ToString();
583
584 return ret;
585 }
586
414 private InventoryFolderBase BuildFolder(Dictionary<string,object> data) 587 private InventoryFolderBase BuildFolder(Dictionary<string,object> data)
415 { 588 {
416 InventoryFolderBase folder = new InventoryFolderBase(); 589 InventoryFolderBase folder = new InventoryFolderBase();