aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server
diff options
context:
space:
mode:
authorDiva Canto2010-02-07 16:41:41 -0800
committerDiva Canto2010-02-07 16:41:41 -0800
commit16f77fa1f1342f2de306c9b4fb7e3c1cd0478c32 (patch)
tree6ffcd1ea9818102f90776cc7d2191870fb56b9f6 /OpenSim/Server
parentMerge branch 'presence-refactor' of melanie@opensimulator.org:/var/git/opensi... (diff)
downloadopensim-SC-16f77fa1f1342f2de306c9b4fb7e3c1cd0478c32.zip
opensim-SC-16f77fa1f1342f2de306c9b4fb7e3c1cd0478c32.tar.gz
opensim-SC-16f77fa1f1342f2de306c9b4fb7e3c1cd0478c32.tar.bz2
opensim-SC-16f77fa1f1342f2de306c9b4fb7e3c1cd0478c32.tar.xz
Finished implementing the XInventory connector. Untested.
Diffstat (limited to 'OpenSim/Server')
-rw-r--r--OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs236
1 files changed, 174 insertions, 62 deletions
diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
index ccaf5c4..a944972 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);
@@ -234,10 +245,9 @@ namespace OpenSim.Server.Handlers.Asset
234 UUID principal = UUID.Zero; 245 UUID principal = UUID.Zero;
235 UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); 246 UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
236 InventoryFolderBase rfolder = m_InventoryService.GetRootFolder(principal); 247 InventoryFolderBase rfolder = m_InventoryService.GetRootFolder(principal);
237 if (rfolder == null) 248 if (rfolder != null)
238 return FailureResult(); 249 result[rfolder.ID.ToString()] = EncodeFolder(rfolder);
239 250
240 result[rfolder.ID.ToString()] = EncodeFolder(rfolder);
241 string xmlString = ServerUtils.BuildXmlResponse(result); 251 string xmlString = ServerUtils.BuildXmlResponse(result);
242 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 252 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
243 UTF8Encoding encoding = new UTF8Encoding(); 253 UTF8Encoding encoding = new UTF8Encoding();
@@ -252,10 +262,9 @@ namespace OpenSim.Server.Handlers.Asset
252 int type = 0; 262 int type = 0;
253 Int32.TryParse(request["TYPE"].ToString(), out type); 263 Int32.TryParse(request["TYPE"].ToString(), out type);
254 InventoryFolderBase folder = m_InventoryService.GetFolderForType(principal, (AssetType)type); 264 InventoryFolderBase folder = m_InventoryService.GetFolderForType(principal, (AssetType)type);
255 if (folder == null) 265 if (folder != null)
256 return FailureResult(); 266 result[folder.ID.ToString()] = EncodeFolder(folder);
257 267
258 result[folder.ID.ToString()] = EncodeFolder(folder);
259 string xmlString = ServerUtils.BuildXmlResponse(result); 268 string xmlString = ServerUtils.BuildXmlResponse(result);
260 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 269 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
261 UTF8Encoding encoding = new UTF8Encoding(); 270 UTF8Encoding encoding = new UTF8Encoding();
@@ -271,19 +280,19 @@ namespace OpenSim.Server.Handlers.Asset
271 UUID.TryParse(request["FOLDER"].ToString(), out folderID); 280 UUID.TryParse(request["FOLDER"].ToString(), out folderID);
272 281
273 InventoryCollection icoll = m_InventoryService.GetFolderContent(principal, folderID); 282 InventoryCollection icoll = m_InventoryService.GetFolderContent(principal, folderID);
274 if (icoll == null) 283 if (icoll != null)
275 return FailureResult(); 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;
276 289
277 Dictionary<string, object> folders = new Dictionary<string,object>(); 290 Dictionary<string, object> items = new Dictionary<string, object>();
278 foreach (InventoryFolderBase f in icoll.Folders) 291 foreach (InventoryItemBase i in icoll.Items)
279 folders[f.ID.ToString()] = EncodeFolder(f); 292 items[i.ID.ToString()] = EncodeItem(i);
280 result["FOLDERS"] = folders; 293 result["ITEMS"] = items;
294 }
281 295
282 Dictionary<string, object> items = new Dictionary<string, object>();
283 foreach (InventoryItemBase i in icoll.Items)
284 items[i.ID.ToString()] = EncodeItem(i);
285 result["ITEMS"] = folders;
286
287 string xmlString = ServerUtils.BuildXmlResponse(result); 296 string xmlString = ServerUtils.BuildXmlResponse(result);
288 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 297 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
289 UTF8Encoding encoding = new UTF8Encoding(); 298 UTF8Encoding encoding = new UTF8Encoding();
@@ -293,7 +302,16 @@ namespace OpenSim.Server.Handlers.Asset
293 byte[] HandleGetFolderItems(Dictionary<string,object> request) 302 byte[] HandleGetFolderItems(Dictionary<string,object> request)
294 { 303 {
295 Dictionary<string,object> result = new Dictionary<string,object>(); 304 Dictionary<string,object> result = new Dictionary<string,object>();
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);
296 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
297 string xmlString = ServerUtils.BuildXmlResponse(result); 315 string xmlString = ServerUtils.BuildXmlResponse(result);
298 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 316 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
299 UTF8Encoding encoding = new UTF8Encoding(); 317 UTF8Encoding encoding = new UTF8Encoding();
@@ -303,96 +321,169 @@ namespace OpenSim.Server.Handlers.Asset
303 byte[] HandleAddFolder(Dictionary<string,object> request) 321 byte[] HandleAddFolder(Dictionary<string,object> request)
304 { 322 {
305 Dictionary<string,object> result = new Dictionary<string,object>(); 323 Dictionary<string,object> result = new Dictionary<string,object>();
324 InventoryFolderBase folder = BuildFolder(request);
306 325
307 string xmlString = ServerUtils.BuildXmlResponse(result); 326 if (m_InventoryService.AddFolder(folder))
308 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 327 return SuccessResult();
309 UTF8Encoding encoding = new UTF8Encoding(); 328 else
310 return encoding.GetBytes(xmlString); 329 return FailureResult();
311 } 330 }
312 331
313 byte[] HandleUpdateFolder(Dictionary<string,object> request) 332 byte[] HandleUpdateFolder(Dictionary<string,object> request)
314 { 333 {
315 Dictionary<string,object> result = new Dictionary<string,object>(); 334 Dictionary<string, object> result = new Dictionary<string, object>();
335 InventoryFolderBase folder = BuildFolder(request);
316 336
317 string xmlString = ServerUtils.BuildXmlResponse(result); 337 if (m_InventoryService.UpdateFolder(folder))
318 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 338 return SuccessResult();
319 UTF8Encoding encoding = new UTF8Encoding(); 339 else
320 return encoding.GetBytes(xmlString); 340 return FailureResult();
321 } 341 }
322 342
323 byte[] HandleMoveFolder(Dictionary<string,object> request) 343 byte[] HandleMoveFolder(Dictionary<string,object> request)
324 { 344 {
325 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();
326 358
327 string xmlString = ServerUtils.BuildXmlResponse(result);
328 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
329 UTF8Encoding encoding = new UTF8Encoding();
330 return encoding.GetBytes(xmlString);
331 } 359 }
332 360
333 byte[] HandleDeleteFolders(Dictionary<string,object> request) 361 byte[] HandleDeleteFolders(Dictionary<string,object> request)
334 { 362 {
335 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 }
336 374
337 string xmlString = ServerUtils.BuildXmlResponse(result); 375 if (m_InventoryService.DeleteFolders(principal, uuids))
338 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 376 return SuccessResult();
339 UTF8Encoding encoding = new UTF8Encoding(); 377 else
340 return encoding.GetBytes(xmlString); 378 return
379 FailureResult();
341 } 380 }
342 381
343 byte[] HandlePurgeFolder(Dictionary<string,object> request) 382 byte[] HandlePurgeFolder(Dictionary<string,object> request)
344 { 383 {
345 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);
346 387
347 string xmlString = ServerUtils.BuildXmlResponse(result); 388 InventoryFolderBase folder = new InventoryFolderBase(folderID);
348 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 389 if (m_InventoryService.PurgeFolder(folder))
349 UTF8Encoding encoding = new UTF8Encoding(); 390 return SuccessResult();
350 return encoding.GetBytes(xmlString); 391 else
392 return FailureResult();
351 } 393 }
352 394
353 byte[] HandleAddItem(Dictionary<string,object> request) 395 byte[] HandleAddItem(Dictionary<string,object> request)
354 { 396 {
355 Dictionary<string,object> result = new Dictionary<string,object>(); 397 Dictionary<string, object> result = new Dictionary<string, object>();
398 InventoryItemBase item = BuildItem(request);
356 399
357 string xmlString = ServerUtils.BuildXmlResponse(result); 400 if (m_InventoryService.AddItem(item))
358 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 401 return SuccessResult();
359 UTF8Encoding encoding = new UTF8Encoding(); 402 else
360 return encoding.GetBytes(xmlString); 403 return FailureResult();
361 } 404 }
362 405
363 byte[] HandleUpdateItem(Dictionary<string,object> request) 406 byte[] HandleUpdateItem(Dictionary<string,object> request)
364 { 407 {
365 Dictionary<string,object> result = new Dictionary<string,object>(); 408 Dictionary<string, object> result = new Dictionary<string, object>();
409 InventoryItemBase item = BuildItem(request);
366 410
367 string xmlString = ServerUtils.BuildXmlResponse(result); 411 if (m_InventoryService.UpdateItem(item))
368 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 412 return SuccessResult();
369 UTF8Encoding encoding = new UTF8Encoding(); 413 else
370 return encoding.GetBytes(xmlString); 414 return FailureResult();
371 } 415 }
372 416
373 byte[] HandleMoveItems(Dictionary<string,object> request) 417 byte[] HandleMoveItems(Dictionary<string,object> request)
374 { 418 {
375 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);
376 424
377 string xmlString = ServerUtils.BuildXmlResponse(result); 425 List<InventoryItemBase> items = new List<InventoryItemBase>();
378 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 426 int n = 0;
379 UTF8Encoding encoding = new UTF8Encoding(); 427 try
380 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();
381 } 454 }
382 455
383 byte[] HandleDeleteItems(Dictionary<string,object> request) 456 byte[] HandleDeleteItems(Dictionary<string,object> request)
384 { 457 {
385 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 }
386 469
387 string xmlString = ServerUtils.BuildXmlResponse(result); 470 if (m_InventoryService.DeleteItems(principal, uuids))
388 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 471 return SuccessResult();
389 UTF8Encoding encoding = new UTF8Encoding(); 472 else
390 return encoding.GetBytes(xmlString); 473 return
474 FailureResult();
391 } 475 }
392 476
393 byte[] HandleGetItem(Dictionary<string,object> request) 477 byte[] HandleGetItem(Dictionary<string,object> request)
394 { 478 {
395 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);
396 487
397 string xmlString = ServerUtils.BuildXmlResponse(result); 488 string xmlString = ServerUtils.BuildXmlResponse(result);
398 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 489 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
@@ -402,7 +493,14 @@ namespace OpenSim.Server.Handlers.Asset
402 493
403 byte[] HandleGetFolder(Dictionary<string,object> request) 494 byte[] HandleGetFolder(Dictionary<string,object> request)
404 { 495 {
405 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);
406 504
407 string xmlString = ServerUtils.BuildXmlResponse(result); 505 string xmlString = ServerUtils.BuildXmlResponse(result);
408 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 506 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
@@ -413,6 +511,13 @@ namespace OpenSim.Server.Handlers.Asset
413 byte[] HandleGetActiveGestures(Dictionary<string,object> request) 511 byte[] HandleGetActiveGestures(Dictionary<string,object> request)
414 { 512 {
415 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);
416 521
417 string xmlString = ServerUtils.BuildXmlResponse(result); 522 string xmlString = ServerUtils.BuildXmlResponse(result);
418 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 523 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
@@ -423,7 +528,14 @@ namespace OpenSim.Server.Handlers.Asset
423 byte[] HandleGetAssetPermissions(Dictionary<string,object> request) 528 byte[] HandleGetAssetPermissions(Dictionary<string,object> request)
424 { 529 {
425 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);
535
536 int perms = m_InventoryService.GetAssetPermissions(principal, assetID);
426 537
538 result["RESULT"] = perms.ToString();
427 string xmlString = ServerUtils.BuildXmlResponse(result); 539 string xmlString = ServerUtils.BuildXmlResponse(result);
428 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); 540 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
429 UTF8Encoding encoding = new UTF8Encoding(); 541 UTF8Encoding encoding = new UTF8Encoding();