aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryService.cs133
1 files changed, 107 insertions, 26 deletions
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryService.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryService.cs
index b67f6f3..3665a4b 100644
--- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryService.cs
+++ b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryService.cs
@@ -37,6 +37,8 @@ using OpenSim.Data;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Cache; 39using OpenSim.Framework.Communications.Cache;
40using Caps = OpenSim.Framework.Communications.Capabilities.Caps;
41using LLSDHelpers = OpenSim.Framework.Communications.Capabilities.LLSDHelpers;
40using OpenSim.Framework.Servers; 42using OpenSim.Framework.Servers;
41using OpenSim.Framework.Servers.Interfaces; 43using OpenSim.Framework.Servers.Interfaces;
42using OpenSim.Region.Framework.Interfaces; 44using OpenSim.Region.Framework.Interfaces;
@@ -108,6 +110,8 @@ namespace OpenSim.Region.CoreModules.Hypergrid
108 private Scene m_scene; 110 private Scene m_scene;
109 private bool m_doLookup = false; 111 private bool m_doLookup = false;
110 private string m_thisInventoryUrl = "http://localhost:9000"; 112 private string m_thisInventoryUrl = "http://localhost:9000";
113 private string m_thisHostname = "127.0.0.1";
114 private uint m_thisPort = 9000;
111 115
112 public bool DoLookup 116 public bool DoLookup
113 { 117 {
@@ -124,6 +128,13 @@ namespace OpenSim.Region.CoreModules.Hypergrid
124 if (!m_thisInventoryUrl.EndsWith("/")) 128 if (!m_thisInventoryUrl.EndsWith("/"))
125 m_thisInventoryUrl += "/"; 129 m_thisInventoryUrl += "/";
126 130
131 Uri uri = new Uri(m_thisInventoryUrl);
132 if (uri != null)
133 {
134 m_thisHostname = uri.Host;
135 m_thisPort = (uint)uri.Port;
136 }
137
127 m_assetProvider = ((AssetServerBase)m_scene.CommsManager.AssetCache.AssetServer).AssetProviderPlugin; 138 m_assetProvider = ((AssetServerBase)m_scene.CommsManager.AssetCache.AssetServer).AssetProviderPlugin;
128 139
129 AddHttpHandlers(); 140 AddHttpHandlers();
@@ -494,9 +505,63 @@ namespace OpenSim.Region.CoreModules.Hypergrid
494 return true; 505 return true;
495 } 506 }
496 507
508 /// <summary>
509 /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see>
510 /// </summary>
511 public UUID UpdateInventoryItemAsset(UUID userID, UUID itemID, byte[] data)
512 {
513 m_log.Debug("[HGStandaloneInvService]: UpdateInventoryitemAsset for user " + userID + " item " + itemID);
514 InventoryItemBase item = m_inventoryService.GetInventoryItem(itemID);
515
516 if (item != null)
517 {
518 // We're still not dealing with permissions
519 //if ((InventoryType)item.InvType == InventoryType.Notecard)
520 //{
521 // if (!Permissions.CanEditNotecard(itemID, UUID.Zero, userID))
522 // {
523 // //remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false);
524 // return UUID.Zero;
525 // }
526
527 // //remoteClient.SendAgentAlertMessage("Notecard saved", false);
528 //}
529 //else if ((InventoryType)item.InvType == InventoryType.LSL)
530 //{
531 // if (!Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId))
532 // {
533 // //remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false);
534 // return UUID.Zero;
535 // }
536
537 // //remoteClient.SendAgentAlertMessage("Script saved", false);
538 //}
539
540 AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data);
541 PostAsset(asset);
542
543 item.AssetID = asset.FullID;
544
545 return (asset.FullID);
546 }
547 return UUID.Zero;
548 }
549
550 private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data)
551 {
552 AssetBase asset = new AssetBase();
553 asset.Name = name;
554 asset.Description = description;
555 asset.Type = assetType;
556 asset.FullID = UUID.Random();
557 asset.Data = (data == null) ? new byte[1] : data;
558
559 return asset;
560 }
561
497 #region Caps 562 #region Caps
498 563
499 Dictionary<UUID, List<string>> invCaps = new Dictionary<UUID, List<string>>(); 564 Dictionary<UUID, Hashtable> invCaps = new Dictionary<UUID, Hashtable>();
500 565
501 public Hashtable CapHandler(Hashtable request) 566 public Hashtable CapHandler(Hashtable request)
502 { 567 {
@@ -573,10 +638,11 @@ namespace OpenSim.Region.CoreModules.Hypergrid
573 638
574 // Then establish secret service handlers 639 // Then establish secret service handlers
575 640
576 RegisterCaps(userID, authToken); 641 Hashtable usercaps = RegisterCaps(userID, authToken);
577 642
578 responsedata["int_response_code"] = 200; 643 responsedata["int_response_code"] = 200;
579 responsedata["str_response_string"] = "OK"; 644 //responsedata["str_response_string"] = "OK";
645 responsedata["str_response_string"] = SerializeHashtable(usercaps);
580 } 646 }
581 else 647 else
582 { 648 {
@@ -638,7 +704,17 @@ namespace OpenSim.Region.CoreModules.Hypergrid
638 return false; 704 return false;
639 } 705 }
640 706
641 void RegisterCaps(UUID userID, string authToken) 707 string SerializeHashtable(Hashtable hash)
708 {
709 string result = string.Empty;
710 foreach (object key in hash.Keys)
711 {
712 result += key.ToString() + "," + hash[key].ToString() + ";";
713 }
714 return result;
715 }
716
717 Hashtable RegisterCaps(UUID userID, string authToken)
642 { 718 {
643 IHttpServer httpServer = m_scene.CommsManager.HttpServer; 719 IHttpServer httpServer = m_scene.CommsManager.HttpServer;
644 720
@@ -652,58 +728,63 @@ namespace OpenSim.Region.CoreModules.Hypergrid
652 } 728 }
653 } 729 }
654 730
655 List<string> caps = new List<string>(); 731 Caps caps = new Caps(null, httpServer, m_thisHostname, m_thisPort, authToken, userID, false, "Inventory");
732 caps.RegisterInventoryServiceHandlers("/" + authToken + "/InventoryCap/");
733 caps.ItemUpdatedCall = UpdateInventoryItemAsset;
734 Hashtable capsHandlers = caps.CapsHandlers.CapsDetails;
656 735
657 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<Guid, InventoryCollection>( 736 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<Guid, InventoryCollection>(
658 "POST", AddAndGetCapUrl(authToken, "/GetInventory/", caps), GetUserInventory, CheckAuthSession)); 737 "POST", AddAndGetCapUrl(authToken, "GetInventory", capsHandlers), GetUserInventory, CheckAuthSession));
659 738
660 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, InventoryCollection>( 739 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, InventoryCollection>(
661 "POST", AddAndGetCapUrl(authToken, "/FetchDescendants/", caps), FetchDescendants, CheckAuthSession)); 740 "POST", AddAndGetCapUrl(authToken, "FetchDescendants", capsHandlers), FetchDescendants, CheckAuthSession));
662 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( 741 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
663 "POST", AddAndGetCapUrl(authToken, "/NewFolder/", caps), m_inventoryService.AddFolder, CheckAuthSession)); 742 "POST", AddAndGetCapUrl(authToken, "NewFolder", capsHandlers), m_inventoryService.AddFolder, CheckAuthSession));
664 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( 743 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
665 "POST", AddAndGetCapUrl(authToken, "/UpdateFolder/", caps), m_inventoryService.UpdateFolder, CheckAuthSession)); 744 "POST", AddAndGetCapUrl(authToken, "UpdateFolder", capsHandlers), m_inventoryService.UpdateFolder, CheckAuthSession));
666 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( 745 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
667 "POST", AddAndGetCapUrl(authToken, "/MoveFolder/", caps), m_inventoryService.MoveFolder, CheckAuthSession)); 746 "POST", AddAndGetCapUrl(authToken, "MoveFolder", capsHandlers), m_inventoryService.MoveFolder, CheckAuthSession));
668 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( 747 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
669 "POST", AddAndGetCapUrl(authToken, "/PurgeFolder/", caps), m_inventoryService.PurgeFolder, CheckAuthSession)); 748 "POST", AddAndGetCapUrl(authToken, "PurgeFolder", capsHandlers), m_inventoryService.PurgeFolder, CheckAuthSession));
670 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( 749 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
671 "POST", AddAndGetCapUrl(authToken, "/RemoveFolder/", caps), RemoveFolder, CheckAuthSession)); 750 "POST", AddAndGetCapUrl(authToken, "RemoveFolder", capsHandlers), RemoveFolder, CheckAuthSession));
672 751
673 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( 752 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>(
674 "POST", AddAndGetCapUrl(authToken, "/GetItem/", caps), GetInventoryItem, CheckAuthSession)); 753 "POST", AddAndGetCapUrl(authToken, "GetItem", capsHandlers), GetInventoryItem, CheckAuthSession));
675 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( 754 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>(
676 "POST", AddAndGetCapUrl(authToken, "/NewItem/", caps), AddItem, CheckAuthSession)); 755 "POST", AddAndGetCapUrl(authToken, "NewItem", capsHandlers), AddItem, CheckAuthSession));
677 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( 756 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>(
678 "POST", AddAndGetCapUrl(authToken, "/UpdateItem/", caps), UpdateItem, CheckAuthSession)); 757 "POST", AddAndGetCapUrl(authToken, "UpdateItem", capsHandlers), UpdateItem, CheckAuthSession));
679 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( 758 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>(
680 "POST", AddAndGetCapUrl(authToken, "/MoveItem/", caps), MoveItem, CheckAuthSession)); 759 "POST", AddAndGetCapUrl(authToken, "MoveItem", capsHandlers), MoveItem, CheckAuthSession));
681 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( 760 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>(
682 "POST", AddAndGetCapUrl(authToken, "/DeleteItem/", caps), DeleteItem, CheckAuthSession)); 761 "POST", AddAndGetCapUrl(authToken, "DeleteItem", capsHandlers), DeleteItem, CheckAuthSession));
683 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( 762 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>(
684 "POST", AddAndGetCapUrl(authToken, "/CopyItem/", caps), CopyItem, CheckAuthSession)); 763 "POST", AddAndGetCapUrl(authToken, "CopyItem", capsHandlers), CopyItem, CheckAuthSession));
685 764
686 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, AssetBase>( 765 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, AssetBase>(
687 "POST", AddAndGetCapUrl(authToken, "/GetAsset/", caps), GetAsset, CheckAuthSession)); 766 "POST", AddAndGetCapUrl(authToken, "GetAsset", capsHandlers), GetAsset, CheckAuthSession));
688 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<AssetBase, bool>( 767 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<AssetBase, bool>(
689 "POST", AddAndGetCapUrl(authToken, "/PostAsset/", caps), PostAsset, CheckAuthSession)); 768 "POST", AddAndGetCapUrl(authToken, "PostAsset", capsHandlers), PostAsset, CheckAuthSession));
690 769
691 lock (invCaps) 770 lock (invCaps)
692 invCaps.Add(userID, caps); 771 invCaps.Add(userID, capsHandlers);
772
773 return capsHandlers;
693 } 774 }
694 775
695 string AddAndGetCapUrl(string authToken, string capType, List<string> caps) 776 string AddAndGetCapUrl(string authToken, string capType, Hashtable caps)
696 { 777 {
697 string capUrl = "/" + authToken + capType; 778 string capUrl = "/" + authToken + "/" + capType + "/";
698 779
699 m_log.Debug("[HGStandaloneInvService] Adding inventory cap " + capUrl); 780 m_log.Debug("[HGStandaloneInvService] Adding inventory cap " + capUrl);
700 caps.Add(capUrl); 781 caps.Add(capType, capUrl);
701 return capUrl; 782 return capUrl;
702 } 783 }
703 784
704 void DeregisterCaps(IHttpServer httpServer, List<string> caps) 785 void DeregisterCaps(IHttpServer httpServer, Hashtable caps)
705 { 786 {
706 foreach (string capUrl in caps) 787 foreach (string capUrl in caps.Values)
707 { 788 {
708 m_log.Debug("[HGStandaloneInvService] Removing inventory cap " + capUrl); 789 m_log.Debug("[HGStandaloneInvService] Removing inventory cap " + capUrl);
709 httpServer.RemoveStreamHandler("POST", capUrl); 790 httpServer.RemoveStreamHandler("POST", capUrl);