diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs (renamed from OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs) | 129 |
1 files changed, 81 insertions, 48 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index 6f7f34f..09798aa 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,55 +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 | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
28 | using System.Reflection; | 30 | using System.Reflection; |
29 | using log4net; | 31 | |
30 | using Nini.Config; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Framework.Communications; | ||
34 | using OpenSim.Framework.Communications.Cache; | ||
35 | using OpenSim.Region.Framework.Interfaces; | 33 | using OpenSim.Region.Framework.Interfaces; |
34 | using OpenSim.Region.Framework.Scenes; | ||
35 | using OpenSim.Services.Connectors.Hypergrid; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | using OpenSim.Server.Base; | ||
36 | 38 | ||
37 | namespace OpenSim.Region.Framework.Scenes.Hypergrid | 39 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
40 | |||
41 | using OpenMetaverse; | ||
42 | using log4net; | ||
43 | using Nini.Config; | ||
44 | |||
45 | namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | ||
38 | { | 46 | { |
39 | public partial class HGScene : Scene | 47 | public class HGInventoryAccessModule : InventoryAccessModule, INonSharedRegionModule, IInventoryAccessModule |
40 | { | 48 | { |
41 | #region Fields | ||
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
43 | 50 | ||
44 | private HGAssetMapper m_assMapper; | 51 | private static HGAssetMapper m_assMapper; |
45 | public HGAssetMapper AssetMapper | 52 | public static HGAssetMapper AssetMapper |
46 | { | 53 | { |
47 | get { return m_assMapper; } | 54 | get { return m_assMapper; } |
48 | } | 55 | } |
49 | 56 | ||
50 | private IHyperAssetService m_hyper; | 57 | private bool m_Initialized = false; |
51 | 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) | ||
52 | { | 67 | { |
53 | get | 68 | IConfig moduleConfig = source.Configs["Modules"]; |
69 | if (moduleConfig != null) | ||
54 | { | 70 | { |
55 | if (m_hyper == null) | 71 | string name = moduleConfig.GetString("InventoryAccessModule", ""); |
56 | m_hyper = RequestModuleInterface<IHyperAssetService>(); | 72 | if (name == Name) |
57 | return m_hyper; | 73 | { |
74 | m_Enabled = true; | ||
75 | m_log.InfoFormat("[HG INVENTORY ACCESS MODULE]: {0} enabled.", Name); | ||
76 | } | ||
58 | } | 77 | } |
59 | } | 78 | } |
60 | 79 | ||
61 | #endregion | 80 | public override void AddRegion(Scene scene) |
62 | |||
63 | #region Constructors | ||
64 | |||
65 | public HGScene(RegionInfo regInfo, AgentCircuitManager authen, | ||
66 | CommunicationsManager commsMan, SceneCommunicationService sceneGridService, | ||
67 | StorageManager storeManager, | ||
68 | ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, | ||
69 | bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) | ||
70 | : base(regInfo, authen, commsMan, sceneGridService, storeManager, moduleLoader, | ||
71 | dumpAssetsToFile, physicalPrim, SeeIntoRegionFromNeighbor, config, simulatorVersion) | ||
72 | { | 81 | { |
73 | m_log.Info("[HGScene]: Starting HGScene."); | 82 | if (!m_Enabled) |
74 | m_assMapper = new HGAssetMapper(this); | 83 | return; |
84 | |||
85 | base.AddRegion(scene); | ||
86 | m_assMapper = new HGAssetMapper(scene); | ||
87 | scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; | ||
75 | 88 | ||
76 | EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; | ||
77 | } | 89 | } |
78 | 90 | ||
79 | #endregion | 91 | #endregion |
@@ -82,17 +94,16 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
82 | 94 | ||
83 | public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) | 95 | public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) |
84 | { | 96 | { |
85 | CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(avatarID); | 97 | string userAssetServer = string.Empty; |
86 | if (userInfo != null) | 98 | if (IsForeignUser(avatarID, out userAssetServer)) |
87 | { | 99 | { |
88 | m_assMapper.Post(assetID, avatarID); | 100 | m_assMapper.Post(assetID, avatarID, userAssetServer); |
89 | } | 101 | } |
90 | } | 102 | } |
91 | 103 | ||
92 | #endregion | 104 | #endregion |
93 | 105 | ||
94 | #region Overrides of Scene.Inventory methods | 106 | #region Overrides of Basic Inventory Access methods |
95 | |||
96 | /// | 107 | /// |
97 | /// CapsUpdateInventoryItemAsset | 108 | /// CapsUpdateInventoryItemAsset |
98 | /// | 109 | /// |
@@ -135,7 +146,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
135 | //{ | 146 | //{ |
136 | InventoryItemBase item = new InventoryItemBase(itemID); | 147 | InventoryItemBase item = new InventoryItemBase(itemID); |
137 | item.Owner = remoteClient.AgentId; | 148 | item.Owner = remoteClient.AgentId; |
138 | item = InventoryService.GetItem(item); | 149 | item = m_Scene.InventoryService.GetItem(item); |
139 | //if (item == null) | 150 | //if (item == null) |
140 | //{ // Fetch the item | 151 | //{ // Fetch the item |
141 | // item = new InventoryItemBase(); | 152 | // item = new InventoryItemBase(); |
@@ -143,32 +154,54 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
143 | // item.ID = itemID; | 154 | // item.ID = itemID; |
144 | // item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo); | 155 | // item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo); |
145 | //} | 156 | //} |
146 | if (item != null) | 157 | string userAssetServer = string.Empty; |
158 | if (item != null && IsForeignUser(remoteClient.AgentId, out userAssetServer)) | ||
147 | { | 159 | { |
148 | m_assMapper.Get(item.AssetID, remoteClient.AgentId); | 160 | m_assMapper.Get(item.AssetID, remoteClient.AgentId, userAssetServer); |
149 | 161 | ||
150 | } | 162 | } |
151 | //} | 163 | //} |
152 | 164 | ||
153 | // 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 |
154 | return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, | 166 | return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, |
155 | RezSelected, RemoveItem, fromTaskID, attachment); | 167 | RezSelected, RemoveItem, fromTaskID, attachment); |
156 | 168 | ||
157 | } | 169 | } |
158 | 170 | ||
159 | protected override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) | 171 | public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) |
160 | { | 172 | { |
161 | string userAssetServer = HyperAssets.GetUserAssetServer(sender); | 173 | string userAssetServer = string.Empty; |
162 | if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer())) | 174 | if (IsForeignUser(sender, out userAssetServer)) |
163 | m_assMapper.Get(item.AssetID, sender); | 175 | m_assMapper.Get(item.AssetID, sender, userAssetServer); |
164 | 176 | ||
165 | userAssetServer = HyperAssets.GetUserAssetServer(receiver); | 177 | if (IsForeignUser(receiver, out userAssetServer)) |
166 | if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer())) | 178 | m_assMapper.Post(item.AssetID, receiver, userAssetServer); |
167 | m_assMapper.Post(item.AssetID, receiver); | ||
168 | } | 179 | } |
169 | 180 | ||
170 | #endregion | 181 | #endregion |
171 | 182 | ||
172 | } | 183 | public bool IsForeignUser(UUID userID, out string assetServerURL) |
184 | { | ||
185 | assetServerURL = string.Empty; | ||
186 | UserAccount account = null; | ||
187 | if (m_Scene.UserAccountService != null) | ||
188 | account = m_Scene.UserAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, userID); | ||
189 | |||
190 | if (account == null) // foreign | ||
191 | { | ||
192 | ScenePresence sp = null; | ||
193 | if (m_Scene.TryGetAvatar(userID, out sp)) | ||
194 | { | ||
195 | AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | ||
196 | if (aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) | ||
197 | { | ||
198 | assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); | ||
199 | assetServerURL = assetServerURL.Trim(new char[] { '/' }); return true; | ||
200 | } | ||
201 | } | ||
202 | } | ||
173 | 203 | ||
204 | return false; | ||
205 | } | ||
206 | } | ||
174 | } | 207 | } |