From 3c9cba162739b93a07067d8a286f6dad55e02217 Mon Sep 17 00:00:00 2001 From: diva Date: Sun, 5 Apr 2009 03:27:50 +0000 Subject: [PATCH] Added CreateObject(regionhandle, userID, itemID) to post objects that are to be fetched from the user's inventory server and rezzed in the region. Added all code necessary to fetch the item and the asset, and rez it inworld. The access to the item is uncap-ed and unverified -- I may place it later either under a cap or with auth verification. But in this model regions don't have the user's inventory, so they would have to guess the item IDs. Added safemode config to Standalone Hypergrid, similar effect to AllowRegionAccessToInventory in Inventory Server. Everyone should have these vars set to their default values except me! --- .../Communications/Clients/InventoryClient.cs | 78 +++++++++++++++++++ .../Communications/Clients/RegionClient.cs | 76 ++++++++++++++++++ .../Services/HGInventoryService.cs | 18 ++++- OpenSim/Grid/InventoryServer/Main.cs | 74 +++++++++--------- .../Hypergrid/HGInventoryService.cs | 11 +++ .../Local/LocalInterregionComms.cs | 13 ++++ .../REST/RESTInterregionComms.cs | 53 ++++++++++--- .../Hypergrid/HGStandaloneInventoryModule.cs | 40 +++++----- .../Framework/Interfaces/IInterregionComms.cs | 10 +++ .../Scenes/Hypergrid/HGAssetMapper.cs | 66 +++++++++++++--- .../Scenes/Hypergrid/HGScene.Inventory.cs | 7 ++ OpenSim/Region/Framework/Scenes/Scene.cs | 11 +++ bin/OpenSim.ini.example | 4 + 13 files changed, 384 insertions(+), 77 deletions(-) create mode 100644 OpenSim/Framework/Communications/Clients/InventoryClient.cs diff --git a/OpenSim/Framework/Communications/Clients/InventoryClient.cs b/OpenSim/Framework/Communications/Clients/InventoryClient.cs new file mode 100644 index 0000000000..8fe4268dc9 --- /dev/null +++ b/OpenSim/Framework/Communications/Clients/InventoryClient.cs @@ -0,0 +1,78 @@ +/** + * Copyright (c), Contributors. All rights reserved. + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the Organizations nor the names of Individual + * Contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +using System; +using OpenSim.Framework.Servers; + +using OpenMetaverse; + +namespace OpenSim.Framework.Communications.Clients +{ + public class InventoryClient + { + private string ServerURL; + + public InventoryClient(string url) + { + ServerURL = url; + } + + public void GetInventoryItemAsync(InventoryItemBase item, ReturnResponse callBack) + { + System.Console.WriteLine("[HGrid] GetInventory from " + ServerURL); + try + { + RestSessionObjectPosterResponse requester + = new RestSessionObjectPosterResponse(); + requester.ResponseCallback = callBack; + + requester.BeginPostObject(ServerURL + "/GetItem/", item, string.Empty, string.Empty); + } + catch (Exception e) + { + System.Console.WriteLine("[HGrid]: Exception posting to inventory: " + e); + } + } + + public InventoryItemBase GetInventoryItem(InventoryItemBase item) + { + System.Console.WriteLine("[HGrid] GetInventory " + item.ID + " from " + ServerURL); + try + { + item = SynchronousRestSessionObjectPoster.BeginPostObject("POST", ServerURL + "/GetItem/", item.ID.Guid, "", ""); + return item; + } + catch (Exception e) + { + System.Console.WriteLine("[HGrid]: Exception posting to inventory: " + e); + } + return null; + } + + } +} diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index d98852b628..196bcf9d45 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -417,6 +417,82 @@ namespace OpenSim.Framework.Communications.Clients } + public bool DoCreateObjectCall(RegionInfo region, UUID userID, UUID itemID) + { + ulong regionHandle = GetRegionHandle(region.RegionHandle); + string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/"; + //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); + + WebRequest ObjectCreateRequest = WebRequest.Create(uri); + ObjectCreateRequest.Method = "PUT"; + ObjectCreateRequest.ContentType = "application/json"; + ObjectCreateRequest.Timeout = 10000; + + OSDMap args = new OSDMap(2); + args["userid"] = OSD.FromUUID(userID); + args["itemid"] = OSD.FromUUID(itemID); + + string strBuffer = ""; + byte[] buffer = new byte[1]; + try + { + strBuffer = OSDParser.SerializeJsonString(args); + UTF8Encoding str = new UTF8Encoding(); + buffer = str.GetBytes(strBuffer); + + } + catch (Exception e) + { + m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); + // ignore. buffer will be empty, caller should check. + } + + Stream os = null; + try + { // send the Post + ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send + os = ObjectCreateRequest.GetRequestStream(); + os.Write(buffer, 0, strBuffer.Length); //Send it + os.Close(); + //m_log.InfoFormat("[REST COMMS]: Posted CreateObject request to remote sim {0}", uri); + } + //catch (WebException ex) + catch + { + // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); + + return false; + } + + // Let's wait for the response + //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); + + try + { + WebResponse webResponse = ObjectCreateRequest.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); + } + + StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + + //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); + // ignore, really + } + + return true; + + } + public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion) { string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; diff --git a/OpenSim/Framework/Communications/Services/HGInventoryService.cs b/OpenSim/Framework/Communications/Services/HGInventoryService.cs index abb9b92389..a3234bf8a6 100644 --- a/OpenSim/Framework/Communications/Services/HGInventoryService.cs +++ b/OpenSim/Framework/Communications/Services/HGInventoryService.cs @@ -107,6 +107,17 @@ namespace OpenSim.Framework.Communications.Services public virtual void AddHttpHandlers() { httpServer.AddHTTPHandler("/InvCap/", CapHandler); + + // Un-cap'ed for now + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", "/GetItem/", GetInventoryItem, CheckAuthSession)); + + } + + public InventoryItemBase GetInventoryItem(Guid id) + { + UUID itemID = new UUID(id); + return m_inventoryService.GetInventoryItem(itemID); } public bool CheckAuthSession(string session_id, string avatar_id) @@ -353,10 +364,15 @@ namespace OpenSim.Framework.Communications.Services m_log.DebugFormat("[HGStandaloneInvService]: client with uuid {0} is trying to get an item of owner {1}", item.Owner, item2.Owner); return asset; } + UUID assetID = item2.AssetID; + if (assetID != item.AssetID) + { + m_log.WarnFormat("[HGStandaloneInvService]: asset IDs don't match {0}, {1}", item.AssetID, item2.AssetID); + } // All good, get the asset //AssetBase theasset = m_assetProvider.FetchAsset(item.AssetID); - AssetBase theasset = FetchAsset(item.AssetID, (item.InvType == (int)InventoryType.Texture)); + AssetBase theasset = FetchAsset(assetID, (item.InvType == (int)InventoryType.Texture)); m_log.Debug("[HGStandaloneInvService] Found asset " + ((theasset == null) ? "NULL" : "Not Null")); if (theasset != null) diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs index 07fb19c7c0..70efb850bf 100644 --- a/OpenSim/Grid/InventoryServer/Main.cs +++ b/OpenSim/Grid/InventoryServer/Main.cs @@ -76,8 +76,8 @@ namespace OpenSim.Grid.InventoryServer m_log.Info("[" + LogName + "]: Starting HTTP server ..."); m_httpServer = new BaseHttpServer(config.HttpPort); - if (config.RegionAccessToAgentsInventory) - AddHttpHandlers(); + + AddHttpHandlers(config.RegionAccessToAgentsInventory); m_httpServer.Start(); @@ -92,11 +92,39 @@ namespace OpenSim.Grid.InventoryServer "Add a random user inventory", HandleAddUser); } - protected void AddHttpHandlers() + protected void AddHttpHandlers(bool regionAccess) { - m_httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/GetInventory/", m_inventoryService.GetUserInventory, m_inventoryService.CheckAuthSession)); + if (regionAccess) + { + m_httpServer.AddStreamHandler( + new RestDeserialiseSecureHandler( + "POST", "/GetInventory/", m_inventoryService.GetUserInventory, m_inventoryService.CheckAuthSession)); + + m_httpServer.AddStreamHandler( + new RestDeserialiseSecureHandler( + "POST", "/UpdateFolder/", m_inventoryService.UpdateFolder, m_inventoryService.CheckAuthSession)); + + m_httpServer.AddStreamHandler( + new RestDeserialiseSecureHandler( + "POST", "/MoveFolder/", m_inventoryService.MoveFolder, m_inventoryService.CheckAuthSession)); + + m_httpServer.AddStreamHandler( + new RestDeserialiseSecureHandler( + "POST", "/PurgeFolder/", m_inventoryService.PurgeFolder, m_inventoryService.CheckAuthSession)); + + m_httpServer.AddStreamHandler( + new RestDeserialiseSecureHandler( + "POST", "/DeleteItem/", m_inventoryService.DeleteItem, m_inventoryService.CheckAuthSession)); + + m_httpServer.AddStreamHandler( + new RestDeserialiseSecureHandler( + "POST", "/QueryItem/", m_inventoryService.QueryItem, m_inventoryService.CheckAuthSession)); + + m_httpServer.AddStreamHandler( + new RestDeserialiseSecureHandler( + "POST", "/QueryFolder/", m_inventoryService.QueryFolder, m_inventoryService.CheckAuthSession)); + + } m_httpServer.AddStreamHandler( new RestDeserialiseTrustedHandler( @@ -106,41 +134,22 @@ namespace OpenSim.Grid.InventoryServer new RestDeserialiseSecureHandler( "POST", "/NewFolder/", m_inventoryService.AddFolder, m_inventoryService.CheckAuthSession)); - m_httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/UpdateFolder/", m_inventoryService.UpdateFolder, m_inventoryService.CheckAuthSession)); - - m_httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/MoveFolder/", m_inventoryService.MoveFolder, m_inventoryService.CheckAuthSession)); - - m_httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/PurgeFolder/", m_inventoryService.PurgeFolder, m_inventoryService.CheckAuthSession)); - m_httpServer.AddStreamHandler( new RestDeserialiseSecureHandler( "POST", "/NewItem/", m_inventoryService.AddItem, m_inventoryService.CheckAuthSession)); - m_httpServer.AddStreamHandler( - new RestDeserialiseTrustedHandler>( - "POST", "/GetItems/", m_inventoryService.GetFolderItems, m_inventoryService.CheckTrustSource)); - m_httpServer.AddStreamHandler( new RestDeserialiseTrustedHandler( "POST", "/AddNewItem/", m_inventoryService.AddItem, m_inventoryService.CheckTrustSource)); m_httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/DeleteItem/", m_inventoryService.DeleteItem, m_inventoryService.CheckAuthSession)); + new RestDeserialiseTrustedHandler>( + "POST", "/GetItems/", m_inventoryService.GetFolderItems, m_inventoryService.CheckTrustSource)); + // for persistent active gestures m_httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/QueryItem/", m_inventoryService.QueryItem, m_inventoryService.CheckAuthSession)); - - m_httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/QueryFolder/", m_inventoryService.QueryFolder, m_inventoryService.CheckAuthSession)); + new RestDeserialiseTrustedHandler> + ("POST", "/ActiveGestures/", m_inventoryService.GetActiveGestures, m_inventoryService.CheckTrustSource)); // WARNING: Root folders no longer just delivers the root and immediate child folders (e.g // system folders such as Objects, Textures), but it now returns the entire inventory skeleton. @@ -150,11 +159,6 @@ namespace OpenSim.Grid.InventoryServer m_httpServer.AddStreamHandler( new RestDeserialiseTrustedHandler> ("POST", "/RootFolders/", m_inventoryService.GetInventorySkeleton, m_inventoryService.CheckTrustSource)); - - // for persistent active gestures - m_httpServer.AddStreamHandler( - new RestDeserialiseTrustedHandler> - ("POST", "/ActiveGestures/", m_inventoryService.GetActiveGestures, m_inventoryService.CheckTrustSource)); } private void Work() diff --git a/OpenSim/Region/Communications/Hypergrid/HGInventoryService.cs b/OpenSim/Region/Communications/Hypergrid/HGInventoryService.cs index 2e402a4e1b..a2b2c84f7d 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGInventoryService.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGInventoryService.cs @@ -113,6 +113,17 @@ namespace OpenSim.Region.Communications.Hypergrid m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Request inventory operation failed, {0} {1}", e.Source, e.Message); + + // Well, let's synthesize one + InventoryCollection icol = new InventoryCollection(); + icol.UserID = userID; + icol.Items = new List(); + icol.Folders = new List(); + InventoryFolderBase rootFolder = new InventoryFolderBase(); + rootFolder.ID = UUID.Random(); + rootFolder.Owner = userID; + icol.Folders.Add(rootFolder); + InventoryResponse(icol); } } else diff --git a/OpenSim/Region/CoreModules/Communications/Local/LocalInterregionComms.cs b/OpenSim/Region/CoreModules/Communications/Local/LocalInterregionComms.cs index fb293e8610..1e430e5e6f 100644 --- a/OpenSim/Region/CoreModules/Communications/Local/LocalInterregionComms.cs +++ b/OpenSim/Region/CoreModules/Communications/Local/LocalInterregionComms.cs @@ -244,6 +244,19 @@ namespace OpenSim.Region.CoreModules.Communications.Local return false; } + public bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID) + { + foreach (Scene s in m_sceneList) + { + if (s.RegionInfo.RegionHandle == regionHandle) + { + return s.IncomingCreateObject(userID, itemID); + } + } + return false; + } + + /** * Region-related communications */ diff --git a/OpenSim/Region/CoreModules/Communications/REST/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/Communications/REST/RESTInterregionComms.cs index b507bdd54a..90104f24b9 100644 --- a/OpenSim/Region/CoreModules/Communications/REST/RESTInterregionComms.cs +++ b/OpenSim/Region/CoreModules/Communications/REST/RESTInterregionComms.cs @@ -276,6 +276,12 @@ namespace OpenSim.Region.CoreModules.Communications.REST return false; } + public bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID) + { + // Not Implemented + return false; + } + /** * Region-related communications */ @@ -527,13 +533,13 @@ namespace OpenSim.Region.CoreModules.Communications.REST public Hashtable ObjectHandler(Hashtable request) { - //m_log.Debug("[CONNECTION DEBUGGING]: ObjectHandler Called"); + m_log.Debug("[CONNECTION DEBUGGING]: ObjectHandler Called"); - //m_log.Debug("---------------------------"); - //m_log.Debug(" >> uri=" + request["uri"]); - //m_log.Debug(" >> content-type=" + request["content-type"]); - //m_log.Debug(" >> http-method=" + request["http-method"]); - //m_log.Debug("---------------------------\n"); + m_log.Debug("---------------------------"); + m_log.Debug(" >> uri=" + request["uri"]); + m_log.Debug(" >> content-type=" + request["content-type"]); + m_log.Debug(" >> http-method=" + request["http-method"]); + m_log.Debug("---------------------------\n"); Hashtable responsedata = new Hashtable(); responsedata["content_type"] = "text/html"; @@ -557,11 +563,11 @@ namespace OpenSim.Region.CoreModules.Communications.REST DoObjectPost(request, responsedata, regionHandle); return responsedata; } - //else if (method.Equals("PUT")) - //{ - // DoObjectPut(request, responsedata, agentID); - // return responsedata; - //} + else if (method.Equals("PUT")) + { + DoObjectPut(request, responsedata, regionHandle); + return responsedata; + } //else if (method.Equals("DELETE")) //{ // DoObjectDelete(request, responsedata, agentID, action, regionHandle); @@ -632,6 +638,31 @@ namespace OpenSim.Region.CoreModules.Communications.REST responsedata["str_response_string"] = result.ToString(); } + protected virtual void DoObjectPut(Hashtable request, Hashtable responsedata, ulong regionhandle) + { + OSDMap args = RegionClient.GetOSDMap((string)request["body"]); + if (args == null) + { + responsedata["int_response_code"] = 400; + responsedata["str_response_string"] = "false"; + return; + } + + UUID userID = UUID.Zero, itemID = UUID.Zero; + if (args["userid"] != null) + userID = args["userid"].AsUUID(); + if (args["itemid"] != null) + itemID = args["itemid"].AsUUID(); + + UUID regionID = m_localBackend.GetRegionID(regionhandle); + + // This is the meaning of PUT object + bool result = m_localBackend.SendCreateObject(regionhandle, userID, itemID); + + responsedata["int_response_code"] = 200; + responsedata["str_response_string"] = result.ToString(); + } + /* * Region-related incoming calls * diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs index 741075c408..3675583a65 100644 --- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs +++ b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs @@ -54,6 +54,7 @@ namespace OpenSim.Region.CoreModules.Hypergrid private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static bool initialized = false; private static bool enabled = false; + private static bool safemode = false; private bool m_doLookup = false; Scene m_scene; @@ -77,6 +78,8 @@ namespace OpenSim.Region.CoreModules.Hypergrid // This module is only on for standalones enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); + if (config.Configs["Hypergrid"] != null) + safemode = config.Configs["Hypergrid"].GetBoolean("safemode", false); } } @@ -116,34 +119,35 @@ namespace OpenSim.Region.CoreModules.Hypergrid public virtual void AddHttpHandlers(IHttpServer httpServer) { + if (!safemode) + { + httpServer.AddStreamHandler( + new RestDeserialiseSecureHandler( + "POST", "/GetInventory/", m_inventoryService.GetUserInventory, CheckAuthSession)); + httpServer.AddStreamHandler( + new RestDeserialiseSecureHandler( + "POST", "/DeleteItem/", m_inventoryBase.DeleteItem, CheckAuthSession)); + httpServer.AddStreamHandler( + new RestDeserialiseSecureHandler( + "POST", "/UpdateFolder/", m_inventoryBase.UpdateFolder, CheckAuthSession)); - httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/GetInventory/", m_inventoryService.GetUserInventory, CheckAuthSession)); + httpServer.AddStreamHandler( + new RestDeserialiseSecureHandler( + "POST", "/MoveFolder/", m_inventoryBase.MoveFolder, CheckAuthSession)); + + httpServer.AddStreamHandler( + new RestDeserialiseSecureHandler( + "POST", "/PurgeFolder/", m_inventoryBase.PurgeFolder, CheckAuthSession)); + } httpServer.AddStreamHandler( new RestDeserialiseSecureHandler( "POST", "/NewFolder/", m_inventoryBase.AddFolder, CheckAuthSession)); - httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/UpdateFolder/", m_inventoryBase.UpdateFolder, CheckAuthSession)); - - httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/MoveFolder/", m_inventoryBase.MoveFolder, CheckAuthSession)); - - httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/PurgeFolder/", m_inventoryBase.PurgeFolder, CheckAuthSession)); - httpServer.AddStreamHandler( new RestDeserialiseSecureHandler( "POST", "/NewItem/", m_inventoryBase.AddItem, CheckAuthSession)); - httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/DeleteItem/", m_inventoryBase.DeleteItem, CheckAuthSession)); } diff --git a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs index ef3cb517c7..b57b5edf68 100644 --- a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs +++ b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs @@ -89,6 +89,16 @@ namespace OpenSim.Region.Framework.Interfaces /// bool SendCreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall); + /// + /// Create an object from the user's inventory in the destination region. + /// This message is used primarily for prim crossing. + /// + /// + /// + /// + /// + bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID); + #endregion Objects #region Regions diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs index e9106e503c..b192101a7c 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs @@ -33,6 +33,7 @@ using log4net; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Communications.Clients; //using HyperGrid.Framework; //using OpenSim.Region.Communications.Hypergrid; @@ -50,6 +51,10 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid // This maps between asset UUIDs and asset servers private Dictionary m_assetMap = new Dictionary(); + // This maps between inventory server urls and inventory server clients + private Dictionary m_inventoryServers = new Dictionary(); + + private Scene m_scene; #endregion @@ -72,6 +77,14 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid return null; } + private string UserInventoryURL(UUID userID) + { + CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); + if (uinfo != null) + return (uinfo.UserProfile.UserInventoryURI == "") ? null : uinfo.UserProfile.UserInventoryURI; + return null; + } + private bool IsLocalUser(UUID userID) { CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); @@ -275,9 +288,9 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid #region Public interface - public void Get(UUID itemID, UUID ownerID) + public void Get(UUID assetID, UUID ownerID) { - if (!IsInAssetMap(itemID) && !IsLocalUser(ownerID)) + if (!IsInAssetMap(assetID) && !IsLocalUser(ownerID)) { // Get the item from the remote asset server onto the local AssetCache // and place an entry in m_assetMap @@ -295,11 +308,11 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid m_assetServers.Add(userAssetURL, asscli); } - m_log.Debug("[HGScene]: Fetching object " + itemID + " to asset server " + userAssetURL); - bool success = FetchAsset(asscli, itemID, false); // asscli.RequestAsset(item.ItemID, false); + m_log.Debug("[HGScene]: Fetching object " + assetID + " to asset server " + userAssetURL); + bool success = FetchAsset(asscli, assetID, false); // asscli.RequestAsset(item.ItemID, false); // OK, now fetch the inside. - Dictionary ids = SniffUUIDs(itemID); + Dictionary ids = SniffUUIDs(assetID); Dump(ids); foreach (KeyValuePair kvp in ids) FetchAsset(asscli, kvp.Key, kvp.Value); @@ -308,7 +321,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid if (success) { m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL); - m_assetMap.Add(itemID, asscli); + m_assetMap.Add(assetID, asscli); } else m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL); @@ -318,7 +331,36 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid } } - public void Post(UUID itemID, UUID ownerID) + public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo) + { + if (!IsLocalUser(item.Owner)) + { + InventoryClient invCli = null; + string inventoryURL = UserInventoryURL(item.Owner); + if (!m_inventoryServers.TryGetValue(inventoryURL, out invCli)) + { + m_log.Debug("[HGScene]: Starting new InventorytClient for " + inventoryURL); + invCli = new InventoryClient(inventoryURL); + m_inventoryServers.Add(inventoryURL, invCli); + } + + item = invCli.GetInventoryItem(item); + if (item != null) + { + // Change the folder, stick it in root folder, all items flattened out here in this region cache + item.Folder = rootFolder; + //userInfo.AddItem(item); don't use this, it calls back to the inventory server + lock (userInfo.RootFolder.Items) + { + userInfo.RootFolder.Items[item.ID] = item; + } + + } + } + return item; + } + + public void Post(UUID assetID, UUID ownerID) { if (!IsLocalUser(ownerID)) { @@ -337,11 +379,11 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid asscli.SetReceiver(m_scene.CommsManager.AssetCache); // Straight to the asset cache! m_assetServers.Add(userAssetURL, asscli); } - m_log.Debug("[HGScene]: Posting object " + itemID + " to asset server " + userAssetURL); - bool success = PostAsset(asscli, itemID); + m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL); + bool success = PostAsset(asscli, assetID); // Now the inside - Dictionary ids = SniffUUIDs(itemID); + Dictionary ids = SniffUUIDs(assetID); Dump(ids); foreach (KeyValuePair kvp in ids) PostAsset(asscli, kvp.Key); @@ -349,8 +391,8 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid if (success) { m_log.Debug("[HGScene]: Successfully posted item to remote asset server " + userAssetURL); - if (!m_assetMap.ContainsKey(itemID)) - m_assetMap.Add(itemID, asscli); + if (!m_assetMap.ContainsKey(assetID)) + m_assetMap.Add(assetID, asscli); } else m_log.Warn("[HGScene]: Could not post asset to remote asset server " + userAssetURL); diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs index 93b81e0e7f..4fde9bb497 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs @@ -120,6 +120,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid { InventoryItemBase item = userInfo.RootFolder.FindItem(itemID); + if (item == null) + { // Fetch the item + item = new InventoryItemBase(); + item.Owner = remoteClient.AgentId; + item.ID = itemID; + item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo); + } if (item != null) { m_assMapper.Get(item.AssetID, remoteClient.AgentId); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 5f68ccb9c0..30257f1016 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1731,6 +1731,17 @@ namespace OpenSim.Region.Framework.Scenes return true; } + public virtual bool IncomingCreateObject(UUID userID, UUID itemID) + { + ScenePresence sp = GetScenePresence(userID); + if (sp != null) + { + uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID); + SceneObjectGroup sog = m_sceneGraph.RezSingleAttachment(sp.ControllingClient, itemID, attPt); + } + return false; + } + public bool AddSceneObject(UUID primID, SceneObjectGroup sceneObject) { // If the user is banned, we won't let any of their objects diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index fe49549e2f..30efaaf793 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -1147,3 +1147,7 @@ ; Enables the Mini Region Modules Script Engine. WARNING: SECURITY RISK. ; default is false Enabled = false + +[Hypergrid] + ; Keep it false for now. Making it true requires the use of a special client in order to access inventory + safemode = false