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