aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/Application/HGCommands.cs60
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs5
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs1
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs1
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs200
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs (renamed from OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs)125
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs (renamed from OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs)3
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs654
-rw-r--r--OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml2
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs1
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs264
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs519
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs40
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs1
-rw-r--r--bin/config-include/StandaloneHypergrid.ini1
17 files changed, 976 insertions, 907 deletions
diff --git a/OpenSim/Region/Application/HGCommands.cs b/OpenSim/Region/Application/HGCommands.cs
deleted file mode 100644
index 5b99d7d..0000000
--- a/OpenSim/Region/Application/HGCommands.cs
+++ /dev/null
@@ -1,60 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Xml;
32using log4net;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Console;
37using OpenSim.Region.Framework;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.Framework.Scenes.Hypergrid;
40
41namespace OpenSim
42{
43 public class HGCommands
44 {
45// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
47 public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager,
48 StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version)
49 {
50 SceneCommunicationService sceneGridService = new SceneCommunicationService();
51
52 return
53 new HGScene(
54 regionInfo, circuitManager, sceneGridService, storageManager,
55 m_moduleLoader, false, m_configSettings.PhysicalPrim,
56 m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version);
57 }
58
59 }
60}
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index f265769..06ffa91 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -574,11 +574,6 @@ namespace OpenSim
574 protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, 574 protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager,
575 AgentCircuitManager circuitManager) 575 AgentCircuitManager circuitManager)
576 { 576 {
577 bool hgrid = ConfigSource.Source.Configs["Startup"].GetBoolean("hypergrid", false);
578 if (hgrid)
579 return HGCommands.CreateScene(regionInfo, circuitManager,
580 storageManager, m_moduleLoader, m_configSettings, m_config, m_version);
581
582 SceneCommunicationService sceneGridService = new SceneCommunicationService(); 577 SceneCommunicationService sceneGridService = new SceneCommunicationService();
583 578
584 return new Scene( 579 return new Scene(
diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
index b53a2fb..9869a99 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
@@ -31,7 +31,6 @@ using OpenMetaverse;
31using OpenMetaverse.Imaging; 31using OpenMetaverse.Imaging;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes.Hypergrid;
35using OpenSim.Services.Interfaces; 34using OpenSim.Services.Interfaces;
36using log4net; 35using log4net;
37using System.Reflection; 36using System.Reflection;
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 79bea26..b888017 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -44,7 +44,6 @@ using OpenSim.Framework.Client;
44using OpenSim.Framework.Statistics; 44using OpenSim.Framework.Statistics;
45using OpenSim.Region.Framework.Interfaces; 45using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Region.Framework.Scenes; 46using OpenSim.Region.Framework.Scenes;
47using OpenSim.Region.Framework.Scenes.Hypergrid;
48using OpenSim.Services.Interfaces; 47using OpenSim.Services.Interfaces;
49using Timer = System.Timers.Timer; 48using Timer = System.Timers.Timer;
50using AssetLandmark = OpenSim.Framework.AssetLandmark; 49using AssetLandmark = OpenSim.Framework.AssetLandmark;
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs
new file mode 100644
index 0000000..e303a1f
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs
@@ -0,0 +1,200 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Threading;
32using log4net;
33using OpenMetaverse;
34using OpenSim.Framework;
35
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Region.Framework.Scenes.Serialization;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Services.Interfaces;
40
41//using HyperGrid.Framework;
42//using OpenSim.Region.Communications.Hypergrid;
43
44namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
45{
46 public class HGAssetMapper
47 {
48 #region Fields
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 // This maps between inventory server urls and inventory server clients
52// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
53
54 private Scene m_scene;
55
56 #endregion
57
58 #region Constructor
59
60 public HGAssetMapper(Scene scene)
61 {
62 m_scene = scene;
63 }
64
65 #endregion
66
67 #region Internal functions
68
69 public AssetBase FetchAsset(string url, UUID assetID)
70 {
71 AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString());
72
73 if (asset != null)
74 {
75 m_log.DebugFormat("[HG ASSET MAPPER]: Copied asset {0} from {1} to local asset server. ", asset.ID, url);
76 return asset;
77 }
78 return null;
79 }
80
81 public bool PostAsset(string url, AssetBase asset)
82 {
83 if (asset != null)
84 {
85 // See long comment in AssetCache.AddAsset
86 if (!asset.Temporary || asset.Local)
87 {
88 // We need to copy the asset into a new asset, because
89 // we need to set its ID to be URL+UUID, so that the
90 // HGAssetService dispatches it to the remote grid.
91 // It's not pretty, but the best that can be done while
92 // not having a global naming infrastructure
93 AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type);
94 Copy(asset, asset1);
95 try
96 {
97 asset1.ID = url + "/" + asset.ID;
98 }
99 catch
100 {
101 m_log.Warn("[HG ASSET MAPPER]: Oops.");
102 }
103
104 m_scene.AssetService.Store(asset1);
105 m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url);
106 }
107 return true;
108 }
109 else
110 m_log.Warn("[HG ASSET MAPPER]: Tried to post asset to remote server, but asset not in local cache.");
111
112 return false;
113 }
114
115 private void Copy(AssetBase from, AssetBase to)
116 {
117 to.Data = from.Data;
118 to.Description = from.Description;
119 to.FullID = from.FullID;
120 to.ID = from.ID;
121 to.Local = from.Local;
122 to.Name = from.Name;
123 to.Temporary = from.Temporary;
124 to.Type = from.Type;
125
126 }
127
128 // TODO: unused
129 // private void Dump(Dictionary<UUID, bool> lst)
130 // {
131 // m_log.Debug("XXX -------- UUID DUMP ------- XXX");
132 // foreach (KeyValuePair<UUID, bool> kvp in lst)
133 // m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")");
134 // m_log.Debug("XXX -------- UUID DUMP ------- XXX");
135 // }
136
137 #endregion
138
139
140 #region Public interface
141
142 public void Get(UUID assetID, UUID ownerID, string userAssetURL)
143 {
144 // Get the item from the remote asset server onto the local AssetCache
145 // and place an entry in m_assetMap
146
147 m_log.Debug("[HG ASSET MAPPER]: Fetching object " + assetID + " from asset server " + userAssetURL);
148 AssetBase asset = FetchAsset(userAssetURL, assetID);
149
150 if (asset != null)
151 {
152 // OK, now fetch the inside.
153 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
154 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
155 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
156 foreach (UUID uuid in ids.Keys)
157 FetchAsset(userAssetURL, uuid);
158
159 m_log.DebugFormat("[HG ASSET MAPPER]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL);
160
161 }
162 else
163 m_log.Warn("[HG ASSET MAPPER]: Could not fetch asset from remote asset server " + userAssetURL);
164 }
165
166
167 public void Post(UUID assetID, UUID ownerID, string userAssetURL)
168 {
169 // Post the item from the local AssetCache onto the remote asset server
170 // and place an entry in m_assetMap
171
172 m_log.Debug("[HG ASSET MAPPER]: Posting object " + assetID + " to asset server " + userAssetURL);
173 AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
174 if (asset != null)
175 {
176 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
177 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty);
178 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
179 foreach (UUID uuid in ids.Keys)
180 {
181 asset = m_scene.AssetService.Get(uuid.ToString());
182 if (asset == null)
183 m_log.DebugFormat("[HG ASSET MAPPER]: Could not find asset {0}", uuid);
184 else
185 PostAsset(userAssetURL, asset);
186 }
187
188 // maybe all pieces got there...
189 m_log.DebugFormat("[HG ASSET MAPPER]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL);
190
191 }
192 else
193 m_log.DebugFormat("[HG ASSET MAPPER]: Something wrong with asset {0}, it could not be found", assetID);
194
195 }
196
197 #endregion
198
199 }
200}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
index c5f8921..ecd7002 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -25,56 +25,67 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
29using System.Collections.Generic;
28using System.Reflection; 30using System.Reflection;
29using log4net;
30using Nini.Config;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Framework.Communications;
34 31
32using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Services.Connectors.Hypergrid;
36using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
37using OpenSim.Server.Base;
38
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
37 40
38namespace OpenSim.Region.Framework.Scenes.Hypergrid 41using OpenMetaverse;
42using log4net;
43using Nini.Config;
44
45namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
39{ 46{
40 public partial class HGScene : Scene 47 public class HGInventoryAccessModule : InventoryAccessModule, INonSharedRegionModule, IInventoryAccessModule
41 { 48 {
42 #region Fields
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 50
45 private HGAssetMapper m_assMapper; 51 private static HGAssetMapper m_assMapper;
46 public HGAssetMapper AssetMapper 52 public static HGAssetMapper AssetMapper
47 { 53 {
48 get { return m_assMapper; } 54 get { return m_assMapper; }
49 } 55 }
50 56
51 private IHyperAssetService m_hyper; 57 private bool m_Initialized = false;
52 private IHyperAssetService HyperAssets 58
59 #region INonSharedRegionModule
60
61 public override string Name
62 {
63 get { return "HGInventoryAccessModule"; }
64 }
65
66 public override void Initialise(IConfigSource source)
53 { 67 {
54 get 68 IConfig moduleConfig = source.Configs["Modules"];
69 if (moduleConfig != null)
55 { 70 {
56 if (m_hyper == null) 71 string name = moduleConfig.GetString("InventoryAccessModule", "");
57 m_hyper = RequestModuleInterface<IHyperAssetService>(); 72 if (name == Name)
58 return m_hyper; 73 {
74 m_Enabled = true;
75 m_log.InfoFormat("[HG INVENTORY ACCESS MODULE]: {0} enabled.", Name);
76 }
59 } 77 }
60 } 78 }
61 79
62 #endregion 80 public override void AddRegion(Scene scene)
63
64 #region Constructors
65
66 public HGScene(RegionInfo regInfo, AgentCircuitManager authen,
67 SceneCommunicationService sceneGridService,
68 StorageManager storeManager,
69 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim,
70 bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion)
71 : base(regInfo, authen, sceneGridService, storeManager, moduleLoader,
72 dumpAssetsToFile, physicalPrim, SeeIntoRegionFromNeighbor, config, simulatorVersion)
73 { 81 {
74 m_log.Info("[HGScene]: Starting HGScene."); 82 if (!m_Enabled)
75 m_assMapper = new HGAssetMapper(this); 83 return;
84
85 base.AddRegion(scene);
86 m_assMapper = new HGAssetMapper(scene);
87 scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem;
76 88
77 EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem;
78 } 89 }
79 90
80 #endregion 91 #endregion
@@ -83,17 +94,16 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
83 94
84 public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) 95 public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel)
85 { 96 {
86 UserAccount userInfo = UserAccountService.GetUserAccount(RegionInfo.ScopeID, avatarID); 97 string userAssetServer = string.Empty;
87 if (userInfo != null) 98 if (IsForeignUser(avatarID, out userAssetServer))
88 { 99 {
89 m_assMapper.Post(assetID, avatarID); 100 m_assMapper.Post(assetID, avatarID, userAssetServer);
90 } 101 }
91 } 102 }
92 103
93 #endregion 104 #endregion
94 105
95 #region Overrides of Scene.Inventory methods 106 #region Overrides of Basic Inventory Access methods
96
97 /// 107 ///
98 /// CapsUpdateInventoryItemAsset 108 /// CapsUpdateInventoryItemAsset
99 /// 109 ///
@@ -136,7 +146,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
136 //{ 146 //{
137 InventoryItemBase item = new InventoryItemBase(itemID); 147 InventoryItemBase item = new InventoryItemBase(itemID);
138 item.Owner = remoteClient.AgentId; 148 item.Owner = remoteClient.AgentId;
139 item = InventoryService.GetItem(item); 149 item = m_Scene.InventoryService.GetItem(item);
140 //if (item == null) 150 //if (item == null)
141 //{ // Fetch the item 151 //{ // Fetch the item
142 // item = new InventoryItemBase(); 152 // item = new InventoryItemBase();
@@ -144,32 +154,51 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
144 // item.ID = itemID; 154 // item.ID = itemID;
145 // item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo); 155 // item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo);
146 //} 156 //}
147 if (item != null) 157 string userAssetServer = string.Empty;
158 if (item != null && IsForeignUser(remoteClient.AgentId, out userAssetServer))
148 { 159 {
149 m_assMapper.Get(item.AssetID, remoteClient.AgentId); 160 m_assMapper.Get(item.AssetID, remoteClient.AgentId, userAssetServer);
150 161
151 } 162 }
152 //} 163 //}
153 164
154 // OK, we're done fetching. Pass it up to the default RezObject 165 // OK, we're done fetching. Pass it up to the default RezObject
155 return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, 166 return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
156 RezSelected, RemoveItem, fromTaskID, attachment); 167 RezSelected, RemoveItem, fromTaskID, attachment);
157 168
158 } 169 }
159 170
160 protected override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) 171 public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
161 { 172 {
162 string userAssetServer = HyperAssets.GetUserAssetServer(sender); 173 string userAssetServer = string.Empty;
163 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer())) 174 if (IsForeignUser(sender, out userAssetServer))
164 m_assMapper.Get(item.AssetID, sender); 175 m_assMapper.Get(item.AssetID, sender, userAssetServer);
165 176
166 userAssetServer = HyperAssets.GetUserAssetServer(receiver); 177 if (IsForeignUser(receiver, out userAssetServer))
167 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer())) 178 m_assMapper.Post(item.AssetID, receiver, userAssetServer);
168 m_assMapper.Post(item.AssetID, receiver);
169 } 179 }
170 180
171 #endregion 181 #endregion
172 182
173 } 183 public bool IsForeignUser(UUID userID, out string assetServerURL)
184 {
185 assetServerURL = string.Empty;
186 UserAccount account = m_Scene.UserAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, userID);
187 if (account == null) // foreign
188 {
189 ScenePresence sp = null;
190 if (m_Scene.TryGetAvatar(userID, out sp))
191 {
192 AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
193 if (aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
194 {
195 assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString();
196 return true;
197 }
198 }
199 }
174 200
201 return false;
202 }
203 }
175} 204}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs
index 5d4e7ac..fcb544f 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs
@@ -29,10 +29,11 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30 30
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes;
32using OpenSim.Services.Interfaces; 33using OpenSim.Services.Interfaces;
33using OpenMetaverse; 34using OpenMetaverse;
34 35
35namespace OpenSim.Region.Framework.Scenes.Hypergrid 36namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
36{ 37{
37 public class HGUuidGatherer : UuidGatherer 38 public class HGUuidGatherer : UuidGatherer
38 { 39 {
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
new file mode 100644
index 0000000..d242a34
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -0,0 +1,654 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Reflection;
32using System.Threading;
33
34using OpenSim.Framework;
35using OpenSim.Framework.Capabilities;
36using OpenSim.Framework.Client;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.Framework.Scenes.Serialization;
40using OpenSim.Services.Interfaces;
41
42using GridRegion = OpenSim.Services.Interfaces.GridRegion;
43
44using OpenMetaverse;
45using log4net;
46using Nini.Config;
47
48namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
49{
50 public class InventoryAccessModule : INonSharedRegionModule, IInventoryAccessModule
51 {
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53
54 protected bool m_Enabled = false;
55 protected Scene m_Scene;
56
57 #region INonSharedRegionModule
58
59 public Type ReplaceableInterface
60 {
61 get { return null; }
62 }
63
64 public virtual string Name
65 {
66 get { return "BasicInventoryAcessModule"; }
67 }
68
69 public virtual void Initialise(IConfigSource source)
70 {
71 IConfig moduleConfig = source.Configs["Modules"];
72 if (moduleConfig != null)
73 {
74 string name = moduleConfig.GetString("InventoryAccessModule", "");
75 if (name == Name)
76 {
77 m_Enabled = true;
78 m_log.InfoFormat("[INVENTORY ACCESS MODULE]: {0} enabled.", Name);
79 }
80 }
81 }
82
83 public virtual void PostInitialise()
84 {
85 }
86
87 public virtual void AddRegion(Scene scene)
88 {
89 if (!m_Enabled)
90 return;
91
92 m_Scene = scene;
93
94 scene.RegisterModuleInterface<IInventoryAccessModule>(this);
95 scene.EventManager.OnNewClient += OnNewClient;
96 }
97
98 protected virtual void OnNewClient(IClientAPI client)
99 {
100
101 }
102
103 public virtual void Close()
104 {
105 if (!m_Enabled)
106 return;
107 }
108
109
110 public virtual void RemoveRegion(Scene scene)
111 {
112 if (!m_Enabled)
113 return;
114 m_Scene = null;
115 }
116
117 public virtual void RegionLoaded(Scene scene)
118 {
119 if (!m_Enabled)
120 return;
121
122 }
123
124 #endregion
125
126 #region Inventory Access
127
128 /// <summary>
129 /// Capability originating call to update the asset of an item in an agent's inventory
130 /// </summary>
131 /// <param name="remoteClient"></param>
132 /// <param name="itemID"></param>
133 /// <param name="data"></param>
134 /// <returns></returns>
135 public virtual UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data)
136 {
137 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
138 item = m_Scene.InventoryService.GetItem(item);
139
140 if (item != null)
141 {
142 if ((InventoryType)item.InvType == InventoryType.Notecard)
143 {
144 if (!m_Scene.Permissions.CanEditNotecard(itemID, UUID.Zero, remoteClient.AgentId))
145 {
146 remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false);
147 return UUID.Zero;
148 }
149
150 remoteClient.SendAgentAlertMessage("Notecard saved", false);
151 }
152 else if ((InventoryType)item.InvType == InventoryType.LSL)
153 {
154 if (!m_Scene.Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId))
155 {
156 remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false);
157 return UUID.Zero;
158 }
159
160 remoteClient.SendAgentAlertMessage("Script saved", false);
161 }
162
163 AssetBase asset =
164 CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data);
165 item.AssetID = asset.FullID;
166 m_Scene.AssetService.Store(asset);
167
168 m_Scene.InventoryService.UpdateItem(item);
169
170 // remoteClient.SendInventoryItemCreateUpdate(item);
171 return (asset.FullID);
172 }
173 else
174 {
175 m_log.ErrorFormat(
176 "[AGENT INVENTORY]: Could not find item {0} for caps inventory update",
177 itemID);
178 }
179
180 return UUID.Zero;
181 }
182
183 /// <summary>
184 /// Delete a scene object from a scene and place in the given avatar's inventory.
185 /// Returns the UUID of the newly created asset.
186 /// </summary>
187 /// <param name="action"></param>
188 /// <param name="folderID"></param>
189 /// <param name="objectGroup"></param>
190 /// <param name="remoteClient"> </param>
191 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
192 SceneObjectGroup objectGroup, IClientAPI remoteClient)
193 {
194 UUID assetID = UUID.Zero;
195
196 Vector3 inventoryStoredPosition = new Vector3
197 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
198 ? 250
199 : objectGroup.AbsolutePosition.X)
200 ,
201 (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
202 ? 250
203 : objectGroup.AbsolutePosition.X,
204 objectGroup.AbsolutePosition.Z);
205
206 Vector3 originalPosition = objectGroup.AbsolutePosition;
207
208 objectGroup.AbsolutePosition = inventoryStoredPosition;
209
210 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
211
212 objectGroup.AbsolutePosition = originalPosition;
213
214 // Get the user info of the item destination
215 //
216 UUID userID = UUID.Zero;
217
218 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
219 action == DeRezAction.SaveToExistingUserInventoryItem)
220 {
221 // Take or take copy require a taker
222 // Saving changes requires a local user
223 //
224 if (remoteClient == null)
225 return UUID.Zero;
226
227 userID = remoteClient.AgentId;
228 }
229 else
230 {
231 // All returns / deletes go to the object owner
232 //
233
234 userID = objectGroup.RootPart.OwnerID;
235 }
236
237 if (userID == UUID.Zero) // Can't proceed
238 {
239 return UUID.Zero;
240 }
241
242 // If we're returning someone's item, it goes back to the
243 // owner's Lost And Found folder.
244 // Delete is treated like return in this case
245 // Deleting your own items makes them go to trash
246 //
247
248 InventoryFolderBase folder = null;
249 InventoryItemBase item = null;
250
251 if (DeRezAction.SaveToExistingUserInventoryItem == action)
252 {
253 item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID);
254 item = m_Scene.InventoryService.GetItem(item);
255
256 //item = userInfo.RootFolder.FindItem(
257 // objectGroup.RootPart.FromUserInventoryItemID);
258
259 if (null == item)
260 {
261 m_log.DebugFormat(
262 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
263 objectGroup.Name, objectGroup.UUID);
264 return UUID.Zero;
265 }
266 }
267 else
268 {
269 // Folder magic
270 //
271 if (action == DeRezAction.Delete)
272 {
273 // Deleting someone else's item
274 //
275
276
277 if (remoteClient == null ||
278 objectGroup.OwnerID != remoteClient.AgentId)
279 {
280 // Folder skeleton may not be loaded and we
281 // have to wait for the inventory to find
282 // the destination folder
283 //
284 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
285 }
286 else
287 {
288 // Assume inventory skeleton was loaded during login
289 // and all folders can be found
290 //
291 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
292 }
293 }
294 else if (action == DeRezAction.Return)
295 {
296
297 // Dump to lost + found unconditionally
298 //
299 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
300 }
301
302 if (folderID == UUID.Zero && folder == null)
303 {
304 if (action == DeRezAction.Delete)
305 {
306 // Deletes go to trash by default
307 //
308 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
309 }
310 else
311 {
312 // Catch all. Use lost & found
313 //
314
315 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
316 }
317 }
318
319 if (folder == null) // None of the above
320 {
321 //folder = userInfo.RootFolder.FindFolder(folderID);
322 folder = new InventoryFolderBase(folderID);
323
324 if (folder == null) // Nowhere to put it
325 {
326 return UUID.Zero;
327 }
328 }
329
330 item = new InventoryItemBase();
331 item.CreatorId = objectGroup.RootPart.CreatorID.ToString();
332 item.ID = UUID.Random();
333 item.InvType = (int)InventoryType.Object;
334 item.Folder = folder.ID;
335 item.Owner = userID;
336 }
337
338 AssetBase asset = CreateAsset(
339 objectGroup.GetPartName(objectGroup.RootPart.LocalId),
340 objectGroup.GetPartDescription(objectGroup.RootPart.LocalId),
341 (sbyte)AssetType.Object,
342 Utils.StringToBytes(sceneObjectXml));
343 m_Scene.AssetService.Store(asset);
344 assetID = asset.FullID;
345
346 if (DeRezAction.SaveToExistingUserInventoryItem == action)
347 {
348 item.AssetID = asset.FullID;
349 m_Scene.InventoryService.UpdateItem(item);
350 }
351 else
352 {
353 item.AssetID = asset.FullID;
354
355 if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
356 {
357 uint perms = objectGroup.GetEffectivePermissions();
358 uint nextPerms = (perms & 7) << 13;
359 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
360 perms &= ~(uint)PermissionMask.Copy;
361 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
362 perms &= ~(uint)PermissionMask.Transfer;
363 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
364 perms &= ~(uint)PermissionMask.Modify;
365
366 item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask;
367 item.CurrentPermissions = item.BasePermissions;
368 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
369 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
370 item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask;
371 item.CurrentPermissions |= 8; // Slam!
372 }
373 else
374 {
375 item.BasePermissions = objectGroup.GetEffectivePermissions();
376 item.CurrentPermissions = objectGroup.GetEffectivePermissions();
377 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
378 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
379 item.GroupPermissions = objectGroup.RootPart.GroupMask;
380
381 item.CurrentPermissions |= 8; // Slam!
382 }
383
384 // TODO: add the new fields (Flags, Sale info, etc)
385 item.CreationDate = Util.UnixTimeSinceEpoch();
386 item.Description = asset.Description;
387 item.Name = asset.Name;
388 item.AssetType = asset.Type;
389
390 m_Scene.InventoryService.AddItem(item);
391
392 if (remoteClient != null && item.Owner == remoteClient.AgentId)
393 {
394 remoteClient.SendInventoryItemCreateUpdate(item, 0);
395 }
396 else
397 {
398 ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner);
399 if (notifyUser != null)
400 {
401 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
402 }
403 }
404 }
405
406 return assetID;
407 }
408
409
410 /// <summary>
411 /// Rez an object into the scene from the user's inventory
412 /// </summary>
413 /// <param name="remoteClient"></param>
414 /// <param name="itemID"></param>
415 /// <param name="RayEnd"></param>
416 /// <param name="RayStart"></param>
417 /// <param name="RayTargetID"></param>
418 /// <param name="BypassRayCast"></param>
419 /// <param name="RayEndIsIntersection"></param>
420 /// <param name="RezSelected"></param>
421 /// <param name="RemoveItem"></param>
422 /// <param name="fromTaskID"></param>
423 /// <param name="attachment"></param>
424 /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful.</returns>
425 public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart,
426 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
427 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
428 {
429 // Work out position details
430 byte bRayEndIsIntersection = (byte)0;
431
432 if (RayEndIsIntersection)
433 {
434 bRayEndIsIntersection = (byte)1;
435 }
436 else
437 {
438 bRayEndIsIntersection = (byte)0;
439 }
440
441 Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f);
442
443
444 Vector3 pos = m_Scene.GetNewRezLocation(
445 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
446 BypassRayCast, bRayEndIsIntersection, true, scale, false);
447
448 // Rez object
449 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
450 item = m_Scene.InventoryService.GetItem(item);
451
452 if (item != null)
453 {
454 AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString());
455
456 if (rezAsset != null)
457 {
458 UUID itemId = UUID.Zero;
459
460 // If we have permission to copy then link the rezzed object back to the user inventory
461 // item that it came from. This allows us to enable 'save object to inventory'
462 if (!m_Scene.Permissions.BypassPermissions())
463 {
464 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy)
465 {
466 itemId = item.ID;
467 }
468 }
469 else
470 {
471 // Brave new fullperm world
472 //
473 itemId = item.ID;
474 }
475
476 string xmlData = Utils.BytesToString(rezAsset.Data);
477 SceneObjectGroup group
478 = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData);
479
480 if (!m_Scene.Permissions.CanRezObject(
481 group.Children.Count, remoteClient.AgentId, pos)
482 && !attachment)
483 {
484 // The client operates in no fail mode. It will
485 // have already removed the item from the folder
486 // if it's no copy.
487 // Put it back if it's not an attachment
488 //
489 if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment))
490 remoteClient.SendBulkUpdateInventory(item);
491 return null;
492 }
493
494 group.ResetIDs();
495
496 if (attachment)
497 {
498 group.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom;
499 group.RootPart.IsAttachment = true;
500 }
501
502 m_Scene.AddNewSceneObject(group, true);
503
504 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z);
505 // if attachment we set it's asset id so object updates can reflect that
506 // if not, we set it's position in world.
507 if (!attachment)
508 {
509 float offsetHeight = 0;
510 pos = m_Scene.GetNewRezLocation(
511 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
512 BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false);
513 pos.Z += offsetHeight;
514 group.AbsolutePosition = pos;
515 // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight);
516
517 }
518 else
519 {
520 group.SetFromItemID(itemID);
521 }
522
523 SceneObjectPart rootPart = null;
524 try
525 {
526 rootPart = group.GetChildPart(group.UUID);
527 }
528 catch (NullReferenceException)
529 {
530 string isAttachment = "";
531
532 if (attachment)
533 isAttachment = " Object was an attachment";
534
535 m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment);
536 }
537
538 // Since renaming the item in the inventory does not affect the name stored
539 // in the serialization, transfer the correct name from the inventory to the
540 // object itself before we rez.
541 rootPart.Name = item.Name;
542 rootPart.Description = item.Description;
543
544 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values);
545
546 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
547 if (rootPart.OwnerID != item.Owner)
548 {
549 //Need to kill the for sale here
550 rootPart.ObjectSaleType = 0;
551 rootPart.SalePrice = 10;
552
553 if (m_Scene.Permissions.PropagatePermissions())
554 {
555 if ((item.CurrentPermissions & 8) != 0)
556 {
557 foreach (SceneObjectPart part in partList)
558 {
559 part.EveryoneMask = item.EveryOnePermissions;
560 part.NextOwnerMask = item.NextPermissions;
561 part.GroupMask = 0; // DO NOT propagate here
562 }
563 }
564 group.ApplyNextOwnerPermissions();
565 }
566 }
567
568 foreach (SceneObjectPart part in partList)
569 {
570 if (part.OwnerID != item.Owner)
571 {
572 part.LastOwnerID = part.OwnerID;
573 part.OwnerID = item.Owner;
574 part.Inventory.ChangeInventoryOwner(item.Owner);
575 }
576 else if (((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam!
577 {
578 part.EveryoneMask = item.EveryOnePermissions;
579 part.NextOwnerMask = item.NextPermissions;
580
581 part.GroupMask = 0; // DO NOT propagate here
582 }
583 }
584
585 rootPart.TrimPermissions();
586
587 if (!attachment)
588 {
589 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
590 {
591 group.ClearPartAttachmentData();
592 }
593 }
594
595 if (!attachment)
596 {
597 // Fire on_rez
598 group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 0);
599
600 rootPart.ScheduleFullUpdate();
601 }
602
603 if (!m_Scene.Permissions.BypassPermissions())
604 {
605 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
606 {
607 // If this is done on attachments, no
608 // copy ones will be lost, so avoid it
609 //
610 if (!attachment)
611 {
612 List<UUID> uuids = new List<UUID>();
613 uuids.Add(item.ID);
614 m_Scene.InventoryService.DeleteItems(item.Owner, uuids);
615 }
616 }
617 }
618
619 return rootPart.ParentGroup;
620 }
621 }
622
623 return null;
624 }
625
626 public virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
627 {
628 }
629
630 #endregion
631
632 #region Misc
633
634 /// <summary>
635 /// Create a new asset data structure.
636 /// </summary>
637 /// <param name="name"></param>
638 /// <param name="description"></param>
639 /// <param name="invType"></param>
640 /// <param name="assetType"></param>
641 /// <param name="data"></param>
642 /// <returns></returns>
643 private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data)
644 {
645 AssetBase asset = new AssetBase(UUID.Random(), name, assetType);
646 asset.Description = description;
647 asset.Data = (data == null) ? new byte[1] : data;
648
649 return asset;
650 }
651
652 #endregion
653 }
654}
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
index e10fa60..bdacc10 100644
--- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
+++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
@@ -10,6 +10,8 @@
10 <Extension path = "/OpenSim/RegionModules"> 10 <Extension path = "/OpenSim/RegionModules">
11 <RegionModule id="EntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule" /> 11 <RegionModule id="EntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule" />
12 <RegionModule id="HGEntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.HGEntityTransferModule" /> 12 <RegionModule id="HGEntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.HGEntityTransferModule" />
13 <RegionModule id="InventoryAccessModule" type="OpenSim.Region.CoreModules.Framework.InventoryAccess.InventoryAccessModule" />
14 <RegionModule id="HGInventoryAccessModule" type="OpenSim.Region.CoreModules.Framework.InventoryAccess.HGInventoryAccessModule" />
13 <RegionModule id="LandManagementModule" type="OpenSim.Region.CoreModules.World.Land.LandManagementModule" /> 15 <RegionModule id="LandManagementModule" type="OpenSim.Region.CoreModules.World.Land.LandManagementModule" />
14 <RegionModule id="ExportSerialisationModule" type="OpenSim.Region.CoreModules.World.Serialiser.SerialiserModule" /> 16 <RegionModule id="ExportSerialisationModule" type="OpenSim.Region.CoreModules.World.Serialiser.SerialiserModule" />
15 <RegionModule id="ArchiverModule" type="OpenSim.Region.CoreModules.World.Archiver.ArchiverModule" /> 17 <RegionModule id="ArchiverModule" type="OpenSim.Region.CoreModules.World.Archiver.ArchiverModule" />
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
index 24b5d6c..2b1f815 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -39,7 +39,6 @@ using OpenSim.Framework;
39using OpenSim.Framework.Communications; 39using OpenSim.Framework.Communications;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Scenes.Hypergrid;
43using OpenSim.Region.Framework.Scenes.Serialization; 42using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Services.Interfaces; 43using OpenSim.Services.Interfaces;
45using OpenSim.Services.Connectors.Simulation; 44using OpenSim.Services.Connectors.Simulation;
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index 56200ec..56b50dc 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -32,7 +32,6 @@ using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Region.Framework.Scenes.Hypergrid;
36using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
37using GridRegion = OpenSim.Services.Interfaces.GridRegion; 36using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38 37
diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
index 9a7863b..c08b961 100644
--- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
+++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
@@ -32,6 +32,7 @@ using System.Timers;
32using log4net; 32using log4net;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
35 36
36namespace OpenSim.Region.Framework.Scenes 37namespace OpenSim.Region.Framework.Scenes
37{ 38{
@@ -137,7 +138,9 @@ namespace OpenSim.Region.Framework.Scenes
137 138
138 try 139 try
139 { 140 {
140 m_scene.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient); 141 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
142 if (invAccess != null)
143 invAccess.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient);
141 if (x.permissionToDelete) 144 if (x.permissionToDelete)
142 m_scene.DeleteSceneObject(x.objectGroup, false); 145 m_scene.DeleteSceneObject(x.objectGroup, false);
143 } 146 }
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
deleted file mode 100644
index fdda150..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ /dev/null
@@ -1,264 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Threading;
32using log4net;
33using OpenMetaverse;
34using OpenSim.Framework;
35
36using OpenSim.Region.Framework.Scenes.Serialization;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Services.Interfaces;
39
40//using HyperGrid.Framework;
41//using OpenSim.Region.Communications.Hypergrid;
42
43namespace OpenSim.Region.Framework.Scenes.Hypergrid
44{
45 public class HGAssetMapper
46 {
47 #region Fields
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 // This maps between inventory server urls and inventory server clients
51// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
52
53 private Scene m_scene;
54
55 private IHyperAssetService m_hyper;
56 IHyperAssetService HyperlinkAssets
57 {
58 get
59 {
60 if (m_hyper == null)
61 m_hyper = m_scene.RequestModuleInterface<IHyperAssetService>();
62 return m_hyper;
63 }
64 }
65
66 #endregion
67
68 #region Constructor
69
70 public HGAssetMapper(Scene scene)
71 {
72 m_scene = scene;
73 }
74
75 #endregion
76
77 #region Internal functions
78
79// private string UserAssetURL(UUID userID)
80// {
81// CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
82// if (uinfo != null)
83// return (uinfo.UserProfile.UserAssetURI == "") ? null : uinfo.UserProfile.UserAssetURI;
84// return null;
85// }
86
87// private string UserInventoryURL(UUID userID)
88// {
89// CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
90// if (uinfo != null)
91// return (uinfo.UserProfile.UserInventoryURI == "") ? null : uinfo.UserProfile.UserInventoryURI;
92// return null;
93// }
94
95
96 public AssetBase FetchAsset(string url, UUID assetID)
97 {
98 AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString());
99
100 if (asset != null)
101 {
102 m_log.DebugFormat("[HGScene]: Copied asset {0} from {1} to local asset server. ", asset.ID, url);
103 return asset;
104 }
105 return null;
106 }
107
108 public bool PostAsset(string url, AssetBase asset)
109 {
110 if (asset != null)
111 {
112 // See long comment in AssetCache.AddAsset
113 if (!asset.Temporary || asset.Local)
114 {
115 // We need to copy the asset into a new asset, because
116 // we need to set its ID to be URL+UUID, so that the
117 // HGAssetService dispatches it to the remote grid.
118 // It's not pretty, but the best that can be done while
119 // not having a global naming infrastructure
120 AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type);
121 Copy(asset, asset1);
122 try
123 {
124 asset1.ID = url + "/" + asset.ID;
125 }
126 catch
127 {
128 m_log.Warn("[HGScene]: Oops.");
129 }
130
131 m_scene.AssetService.Store(asset1);
132 m_log.DebugFormat("[HGScene]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url);
133 }
134 return true;
135 }
136 else
137 m_log.Warn("[HGScene]: Tried to post asset to remote server, but asset not in local cache.");
138
139 return false;
140 }
141
142 private void Copy(AssetBase from, AssetBase to)
143 {
144 to.Data = from.Data;
145 to.Description = from.Description;
146 to.FullID = from.FullID;
147 to.ID = from.ID;
148 to.Local = from.Local;
149 to.Name = from.Name;
150 to.Temporary = from.Temporary;
151 to.Type = from.Type;
152
153 }
154
155 // TODO: unused
156 // private void Dump(Dictionary<UUID, bool> lst)
157 // {
158 // m_log.Debug("XXX -------- UUID DUMP ------- XXX");
159 // foreach (KeyValuePair<UUID, bool> kvp in lst)
160 // m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")");
161 // m_log.Debug("XXX -------- UUID DUMP ------- XXX");
162 // }
163
164 #endregion
165
166
167 #region Public interface
168
169 public void Get(UUID assetID, UUID ownerID)
170 {
171 // Get the item from the remote asset server onto the local AssetCache
172 // and place an entry in m_assetMap
173
174 string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID);
175 if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer()))
176 {
177 m_log.Debug("[HGScene]: Fetching object " + assetID + " from asset server " + userAssetURL);
178 AssetBase asset = FetchAsset(userAssetURL, assetID);
179
180 if (asset != null)
181 {
182 // OK, now fetch the inside.
183 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
184 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
185 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
186 foreach (UUID uuid in ids.Keys)
187 FetchAsset(userAssetURL, uuid);
188
189 m_log.DebugFormat("[HGScene]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL);
190
191 }
192 else
193 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL);
194 }
195 else
196 m_log.Debug("[HGScene]: user's asset server is the local region's asset server");
197 }
198
199 //public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo)
200 //{
201 // InventoryClient invCli = null;
202 // string inventoryURL = UserInventoryURL(item.Owner);
203 // if (!m_inventoryServers.TryGetValue(inventoryURL, out invCli))
204 // {
205 // m_log.Debug("[HGScene]: Starting new InventorytClient for " + inventoryURL);
206 // invCli = new InventoryClient(inventoryURL);
207 // m_inventoryServers.Add(inventoryURL, invCli);
208 // }
209
210 // item = invCli.GetInventoryItem(item);
211 // if (item != null)
212 // {
213 // // Change the folder, stick it in root folder, all items flattened out here in this region cache
214 // item.Folder = rootFolder;
215 // //userInfo.AddItem(item); don't use this, it calls back to the inventory server
216 // lock (userInfo.RootFolder.Items)
217 // {
218 // userInfo.RootFolder.Items[item.ID] = item;
219 // }
220
221 // }
222 // return item;
223 //}
224
225 public void Post(UUID assetID, UUID ownerID)
226 {
227 // Post the item from the local AssetCache onto the remote asset server
228 // and place an entry in m_assetMap
229
230 string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID);
231 if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer()))
232 {
233 m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL);
234 AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
235 if (asset != null)
236 {
237 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
238 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty);
239 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
240 foreach (UUID uuid in ids.Keys)
241 {
242 asset = m_scene.AssetService.Get(uuid.ToString());
243 if (asset == null)
244 m_log.DebugFormat("[HGScene]: Could not find asset {0}", uuid);
245 else
246 PostAsset(userAssetURL, asset);
247 }
248
249 // maybe all pieces got there...
250 m_log.DebugFormat("[HGScene]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL);
251
252 }
253 else
254 m_log.DebugFormat("[HGScene]: Something wrong with asset {0}, it could not be found", assetID);
255 }
256 else
257 m_log.Debug("[HGScene]: user's asset server is local region's asset server");
258
259 }
260
261 #endregion
262
263 }
264}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 62a831e..45806dd 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -126,61 +126,6 @@ namespace OpenSim.Region.Framework.Scenes
126 } 126 }
127 127
128 /// <summary> 128 /// <summary>
129 /// Capability originating call to update the asset of an item in an agent's inventory
130 /// </summary>
131 /// <param name="remoteClient"></param>
132 /// <param name="itemID"></param>
133 /// <param name="data"></param>
134 /// <returns></returns>
135 public virtual UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data)
136 {
137 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
138 item = InventoryService.GetItem(item);
139
140 if (item != null)
141 {
142 if ((InventoryType)item.InvType == InventoryType.Notecard)
143 {
144 if (!Permissions.CanEditNotecard(itemID, UUID.Zero, remoteClient.AgentId))
145 {
146 remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false);
147 return UUID.Zero;
148 }
149
150 remoteClient.SendAgentAlertMessage("Notecard saved", false);
151 }
152 else if ((InventoryType)item.InvType == InventoryType.LSL)
153 {
154 if (!Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId))
155 {
156 remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false);
157 return UUID.Zero;
158 }
159
160 remoteClient.SendAgentAlertMessage("Script saved", false);
161 }
162
163 AssetBase asset =
164 CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data);
165 item.AssetID = asset.FullID;
166 AssetService.Store(asset);
167
168 InventoryService.UpdateItem(item);
169
170 // remoteClient.SendInventoryItemCreateUpdate(item);
171 return (asset.FullID);
172 }
173 else
174 {
175 m_log.ErrorFormat(
176 "[AGENT INVENTORY]: Could not find item {0} for caps inventory update",
177 itemID);
178 }
179
180 return UUID.Zero;
181 }
182
183 /// <summary>
184 /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see> 129 /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see>
185 /// </summary> 130 /// </summary>
186 public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data) 131 public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data)
@@ -189,7 +134,9 @@ namespace OpenSim.Region.Framework.Scenes
189 134
190 if (TryGetAvatar(avatarId, out avatar)) 135 if (TryGetAvatar(avatarId, out avatar))
191 { 136 {
192 return CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data); 137 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
138 if (invAccess != null)
139 return invAccess.CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data);
193 } 140 }
194 else 141 else
195 { 142 {
@@ -472,7 +419,11 @@ namespace OpenSim.Region.Framework.Scenes
472 itemCopy.SaleType = item.SaleType; 419 itemCopy.SaleType = item.SaleType;
473 420
474 if (InventoryService.AddItem(itemCopy)) 421 if (InventoryService.AddItem(itemCopy))
475 TransferInventoryAssets(itemCopy, senderId, recipient); 422 {
423 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
424 if (invAccess != null)
425 invAccess.TransferInventoryAssets(itemCopy, senderId, recipient);
426 }
476 427
477 if (!Permissions.BypassPermissions()) 428 if (!Permissions.BypassPermissions())
478 { 429 {
@@ -494,10 +445,6 @@ namespace OpenSim.Region.Framework.Scenes
494 445
495 } 446 }
496 447
497 protected virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
498 {
499 }
500
501 /// <summary> 448 /// <summary>
502 /// Give an entire inventory folder from one user to another. The entire contents (including all descendent 449 /// Give an entire inventory folder from one user to another. The entire contents (including all descendent
503 /// folders) is given. 450 /// folders) is given.
@@ -1605,232 +1552,6 @@ namespace OpenSim.Region.Framework.Scenes
1605 } 1552 }
1606 } 1553 }
1607 1554
1608 /// <summary>
1609 /// Delete a scene object from a scene and place in the given avatar's inventory.
1610 /// Returns the UUID of the newly created asset.
1611 /// </summary>
1612 /// <param name="action"></param>
1613 /// <param name="folderID"></param>
1614 /// <param name="objectGroup"></param>
1615 /// <param name="remoteClient"> </param>
1616 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
1617 SceneObjectGroup objectGroup, IClientAPI remoteClient)
1618 {
1619 UUID assetID = UUID.Zero;
1620
1621 Vector3 inventoryStoredPosition = new Vector3
1622 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
1623 ? 250
1624 : objectGroup.AbsolutePosition.X)
1625 ,
1626 (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
1627 ? 250
1628 : objectGroup.AbsolutePosition.X,
1629 objectGroup.AbsolutePosition.Z);
1630
1631 Vector3 originalPosition = objectGroup.AbsolutePosition;
1632
1633 objectGroup.AbsolutePosition = inventoryStoredPosition;
1634
1635 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
1636
1637 objectGroup.AbsolutePosition = originalPosition;
1638
1639 // Get the user info of the item destination
1640 //
1641 UUID userID = UUID.Zero;
1642
1643 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
1644 action == DeRezAction.SaveToExistingUserInventoryItem)
1645 {
1646 // Take or take copy require a taker
1647 // Saving changes requires a local user
1648 //
1649 if (remoteClient == null)
1650 return UUID.Zero;
1651
1652 userID = remoteClient.AgentId;
1653 }
1654 else
1655 {
1656 // All returns / deletes go to the object owner
1657 //
1658
1659 userID = objectGroup.RootPart.OwnerID;
1660 }
1661
1662 if (userID == UUID.Zero) // Can't proceed
1663 {
1664 return UUID.Zero;
1665 }
1666
1667 // If we're returning someone's item, it goes back to the
1668 // owner's Lost And Found folder.
1669 // Delete is treated like return in this case
1670 // Deleting your own items makes them go to trash
1671 //
1672
1673 InventoryFolderBase folder = null;
1674 InventoryItemBase item = null;
1675
1676 if (DeRezAction.SaveToExistingUserInventoryItem == action)
1677 {
1678 item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID);
1679 item = InventoryService.GetItem(item);
1680
1681 //item = userInfo.RootFolder.FindItem(
1682 // objectGroup.RootPart.FromUserInventoryItemID);
1683
1684 if (null == item)
1685 {
1686 m_log.DebugFormat(
1687 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
1688 objectGroup.Name, objectGroup.UUID);
1689 return UUID.Zero;
1690 }
1691 }
1692 else
1693 {
1694 // Folder magic
1695 //
1696 if (action == DeRezAction.Delete)
1697 {
1698 // Deleting someone else's item
1699 //
1700
1701
1702 if (remoteClient == null ||
1703 objectGroup.OwnerID != remoteClient.AgentId)
1704 {
1705 // Folder skeleton may not be loaded and we
1706 // have to wait for the inventory to find
1707 // the destination folder
1708 //
1709 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1710 }
1711 else
1712 {
1713 // Assume inventory skeleton was loaded during login
1714 // and all folders can be found
1715 //
1716 folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
1717 }
1718 }
1719 else if (action == DeRezAction.Return)
1720 {
1721
1722 // Dump to lost + found unconditionally
1723 //
1724 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1725 }
1726
1727 if (folderID == UUID.Zero && folder == null)
1728 {
1729 if (action == DeRezAction.Delete)
1730 {
1731 // Deletes go to trash by default
1732 //
1733 folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
1734 }
1735 else
1736 {
1737 // Catch all. Use lost & found
1738 //
1739
1740 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1741 }
1742 }
1743
1744 if (folder == null) // None of the above
1745 {
1746 //folder = userInfo.RootFolder.FindFolder(folderID);
1747 folder = new InventoryFolderBase(folderID);
1748
1749 if (folder == null) // Nowhere to put it
1750 {
1751 return UUID.Zero;
1752 }
1753 }
1754
1755 item = new InventoryItemBase();
1756 item.CreatorId = objectGroup.RootPart.CreatorID.ToString();
1757 item.ID = UUID.Random();
1758 item.InvType = (int)InventoryType.Object;
1759 item.Folder = folder.ID;
1760 item.Owner = userID;
1761 }
1762
1763 AssetBase asset = CreateAsset(
1764 objectGroup.GetPartName(objectGroup.RootPart.LocalId),
1765 objectGroup.GetPartDescription(objectGroup.RootPart.LocalId),
1766 (sbyte)AssetType.Object,
1767 Utils.StringToBytes(sceneObjectXml));
1768 AssetService.Store(asset);
1769 assetID = asset.FullID;
1770
1771 if (DeRezAction.SaveToExistingUserInventoryItem == action)
1772 {
1773 item.AssetID = asset.FullID;
1774 InventoryService.UpdateItem(item);
1775 }
1776 else
1777 {
1778 item.AssetID = asset.FullID;
1779
1780 if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && Permissions.PropagatePermissions())
1781 {
1782 uint perms=objectGroup.GetEffectivePermissions();
1783 uint nextPerms=(perms & 7) << 13;
1784 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
1785 perms &= ~(uint)PermissionMask.Copy;
1786 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
1787 perms &= ~(uint)PermissionMask.Transfer;
1788 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
1789 perms &= ~(uint)PermissionMask.Modify;
1790
1791 item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask;
1792 item.CurrentPermissions = item.BasePermissions;
1793 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1794 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
1795 item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask;
1796 item.CurrentPermissions |= 8; // Slam!
1797 }
1798 else
1799 {
1800 item.BasePermissions = objectGroup.GetEffectivePermissions();
1801 item.CurrentPermissions = objectGroup.GetEffectivePermissions();
1802 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1803 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
1804 item.GroupPermissions = objectGroup.RootPart.GroupMask;
1805
1806 item.CurrentPermissions |= 8; // Slam!
1807 }
1808
1809 // TODO: add the new fields (Flags, Sale info, etc)
1810 item.CreationDate = Util.UnixTimeSinceEpoch();
1811 item.Description = asset.Description;
1812 item.Name = asset.Name;
1813 item.AssetType = asset.Type;
1814
1815 InventoryService.AddItem(item);
1816
1817 if (remoteClient != null && item.Owner == remoteClient.AgentId)
1818 {
1819 remoteClient.SendInventoryItemCreateUpdate(item, 0);
1820 }
1821 else
1822 {
1823 ScenePresence notifyUser = GetScenePresence(item.Owner);
1824 if (notifyUser != null)
1825 {
1826 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
1827 }
1828 }
1829 }
1830
1831 return assetID;
1832 }
1833
1834 public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID) 1555 public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
1835 { 1556 {
1836 SceneObjectGroup objectGroup = grp; 1557 SceneObjectGroup objectGroup = grp;
@@ -1971,225 +1692,11 @@ namespace OpenSim.Region.Framework.Scenes
1971 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 1692 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
1972 bool RezSelected, bool RemoveItem, UUID fromTaskID) 1693 bool RezSelected, bool RemoveItem, UUID fromTaskID)
1973 { 1694 {
1974 RezObject( 1695 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
1975 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, 1696 if (invAccess != null)
1976 RezSelected, RemoveItem, fromTaskID, false); 1697 invAccess.RezObject(
1977 } 1698 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
1978 1699 RezSelected, RemoveItem, fromTaskID, false);
1979 /// <summary>
1980 /// Rez an object into the scene from the user's inventory
1981 /// </summary>
1982 /// <param name="remoteClient"></param>
1983 /// <param name="itemID"></param>
1984 /// <param name="RayEnd"></param>
1985 /// <param name="RayStart"></param>
1986 /// <param name="RayTargetID"></param>
1987 /// <param name="BypassRayCast"></param>
1988 /// <param name="RayEndIsIntersection"></param>
1989 /// <param name="RezSelected"></param>
1990 /// <param name="RemoveItem"></param>
1991 /// <param name="fromTaskID"></param>
1992 /// <param name="attachment"></param>
1993 /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful.</returns>
1994 public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart,
1995 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
1996 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
1997 {
1998 // Work out position details
1999 byte bRayEndIsIntersection = (byte)0;
2000
2001 if (RayEndIsIntersection)
2002 {
2003 bRayEndIsIntersection = (byte)1;
2004 }
2005 else
2006 {
2007 bRayEndIsIntersection = (byte)0;
2008 }
2009
2010 Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f);
2011
2012
2013 Vector3 pos = GetNewRezLocation(
2014 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
2015 BypassRayCast, bRayEndIsIntersection,true,scale, false);
2016
2017 // Rez object
2018 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2019 item = InventoryService.GetItem(item);
2020
2021 if (item != null)
2022 {
2023 AssetBase rezAsset = AssetService.Get(item.AssetID.ToString());
2024
2025 if (rezAsset != null)
2026 {
2027 UUID itemId = UUID.Zero;
2028
2029 // If we have permission to copy then link the rezzed object back to the user inventory
2030 // item that it came from. This allows us to enable 'save object to inventory'
2031 if (!Permissions.BypassPermissions())
2032 {
2033 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy)
2034 {
2035 itemId = item.ID;
2036 }
2037 }
2038 else
2039 {
2040 // Brave new fullperm world
2041 //
2042 itemId = item.ID;
2043 }
2044
2045 string xmlData = Utils.BytesToString(rezAsset.Data);
2046 SceneObjectGroup group
2047 = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData);
2048
2049 if (!Permissions.CanRezObject(
2050 group.Children.Count, remoteClient.AgentId, pos)
2051 && !attachment)
2052 {
2053 // The client operates in no fail mode. It will
2054 // have already removed the item from the folder
2055 // if it's no copy.
2056 // Put it back if it's not an attachment
2057 //
2058 if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment))
2059 remoteClient.SendBulkUpdateInventory(item);
2060 return null;
2061 }
2062
2063 group.ResetIDs();
2064
2065 if (attachment)
2066 {
2067 group.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom;
2068 group.RootPart.IsAttachment = true;
2069 }
2070
2071 AddNewSceneObject(group, true);
2072
2073 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z);
2074 // if attachment we set it's asset id so object updates can reflect that
2075 // if not, we set it's position in world.
2076 if (!attachment)
2077 {
2078 float offsetHeight = 0;
2079 pos = GetNewRezLocation(
2080 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
2081 BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false);
2082 pos.Z += offsetHeight;
2083 group.AbsolutePosition = pos;
2084 // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight);
2085
2086 }
2087 else
2088 {
2089 group.SetFromItemID(itemID);
2090 }
2091
2092 SceneObjectPart rootPart = null;
2093 try
2094 {
2095 rootPart = group.GetChildPart(group.UUID);
2096 }
2097 catch (NullReferenceException)
2098 {
2099 string isAttachment = "";
2100
2101 if (attachment)
2102 isAttachment = " Object was an attachment";
2103
2104 m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment);
2105 }
2106
2107 // Since renaming the item in the inventory does not affect the name stored
2108 // in the serialization, transfer the correct name from the inventory to the
2109 // object itself before we rez.
2110 rootPart.Name = item.Name;
2111 rootPart.Description = item.Description;
2112
2113 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values);
2114
2115 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
2116 if (rootPart.OwnerID != item.Owner)
2117 {
2118 //Need to kill the for sale here
2119 rootPart.ObjectSaleType = 0;
2120 rootPart.SalePrice = 10;
2121
2122 if (Permissions.PropagatePermissions())
2123 {
2124 if ((item.CurrentPermissions & 8) != 0)
2125 {
2126 foreach (SceneObjectPart part in partList)
2127 {
2128 part.EveryoneMask = item.EveryOnePermissions;
2129 part.NextOwnerMask = item.NextPermissions;
2130 part.GroupMask = 0; // DO NOT propagate here
2131 }
2132 }
2133 group.ApplyNextOwnerPermissions();
2134 }
2135 }
2136
2137 foreach (SceneObjectPart part in partList)
2138 {
2139 if (part.OwnerID != item.Owner)
2140 {
2141 part.LastOwnerID = part.OwnerID;
2142 part.OwnerID = item.Owner;
2143 part.Inventory.ChangeInventoryOwner(item.Owner);
2144 }
2145 else if (((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam!
2146 {
2147 part.EveryoneMask = item.EveryOnePermissions;
2148 part.NextOwnerMask = item.NextPermissions;
2149
2150 part.GroupMask = 0; // DO NOT propagate here
2151 }
2152 }
2153
2154 rootPart.TrimPermissions();
2155
2156 if (!attachment)
2157 {
2158 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
2159 {
2160 group.ClearPartAttachmentData();
2161 }
2162 }
2163
2164 if (!attachment)
2165 {
2166 // Fire on_rez
2167 group.CreateScriptInstances(0, true, DefaultScriptEngine, 0);
2168
2169 rootPart.ScheduleFullUpdate();
2170 }
2171
2172 if (!Permissions.BypassPermissions())
2173 {
2174 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
2175 {
2176 // If this is done on attachments, no
2177 // copy ones will be lost, so avoid it
2178 //
2179 if (!attachment)
2180 {
2181 List<UUID> uuids = new List<UUID>();
2182 uuids.Add(item.ID);
2183 InventoryService.DeleteItems(item.Owner, uuids);
2184 }
2185 }
2186 }
2187
2188 return rootPart.ParentGroup;
2189 }
2190 }
2191
2192 return null;
2193 } 1700 }
2194 1701
2195 /// <summary> 1702 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index f74fd5d..fbd11c6 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -35,6 +35,7 @@ using log4net;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Region.Framework.Scenes.Types; 36using OpenSim.Region.Framework.Scenes.Types;
37using OpenSim.Region.Physics.Manager; 37using OpenSim.Region.Physics.Manager;
38using OpenSim.Region.Framework.Interfaces;
38 39
39namespace OpenSim.Region.Framework.Scenes 40namespace OpenSim.Region.Framework.Scenes
40{ 41{
@@ -498,27 +499,32 @@ namespace OpenSim.Region.Framework.Scenes
498 public SceneObjectGroup RezSingleAttachment( 499 public SceneObjectGroup RezSingleAttachment(
499 IClientAPI remoteClient, UUID itemID, uint AttachmentPt) 500 IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
500 { 501 {
501 SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient, 502 IInventoryAccessModule invAccess = m_parentScene.RequestModuleInterface<IInventoryAccessModule>();
502 itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, 503 if (invAccess != null)
503 false, false, remoteClient.AgentId, true);
504
505
506 if (objatt != null)
507 { 504 {
508 bool tainted = false; 505 SceneObjectGroup objatt = invAccess.RezObject(remoteClient,
509 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) 506 itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
510 tainted = true; 507 false, false, remoteClient.AgentId, true);
511 508
512 AttachObject(remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false);
513 objatt.ScheduleGroupForFullUpdate();
514 if (tainted)
515 objatt.HasGroupChanged = true;
516 509
517 // Fire after attach, so we don't get messy perms dialogs 510 if (objatt != null)
518 // 3 == AttachedRez 511 {
519 objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3); 512 bool tainted = false;
513 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint())
514 tainted = true;
515
516 AttachObject(remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false);
517 objatt.ScheduleGroupForFullUpdate();
518 if (tainted)
519 objatt.HasGroupChanged = true;
520
521 // Fire after attach, so we don't get messy perms dialogs
522 // 3 == AttachedRez
523 objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3);
524 }
525 return objatt;
520 } 526 }
521 return objatt; 527 return null;
522 } 528 }
523 529
524 // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. 530 // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index b28976e..fccd07e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -41,7 +41,6 @@ using OpenSim.Framework.Console;
41using OpenSim.Region.CoreModules.Avatar.NPC; 41using OpenSim.Region.CoreModules.Avatar.NPC;
42using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Scenes.Hypergrid;
45using OpenSim.Region.ScriptEngine.Shared; 44using OpenSim.Region.ScriptEngine.Shared;
46using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; 45using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
47using OpenSim.Region.ScriptEngine.Shared.ScriptBase; 46using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini
index 395537d..686d2a4 100644
--- a/bin/config-include/StandaloneHypergrid.ini
+++ b/bin/config-include/StandaloneHypergrid.ini
@@ -21,6 +21,7 @@
21 SimulationServices = "RemoteSimulationConnectorModule" 21 SimulationServices = "RemoteSimulationConnectorModule"
22 AvatarServices = "LocalAvatarServicesConnector" 22 AvatarServices = "LocalAvatarServicesConnector"
23 EntityTransferModule = "HGEntityTransferModule" 23 EntityTransferModule = "HGEntityTransferModule"
24 InventoryAccessModule = "HGInventoryAccessModule"
24 InventoryServiceInConnector = true 25 InventoryServiceInConnector = true
25 AssetServiceInConnector = true 26 AssetServiceInConnector = true
26 HGAuthServiceInConnector = true 27 HGAuthServiceInConnector = true