aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
diff options
context:
space:
mode:
authorDiva Canto2010-01-30 09:23:07 -0800
committerDiva Canto2010-01-30 09:23:07 -0800
commit42f978a478093da579907e15dc29680a3711b27e (patch)
tree89cf2e484d8b9e3c0c0607cb5625acda4afd858e /OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
parentOn the way to making HG inventory work. Inventory can now be accessed again. ... (diff)
downloadopensim-SC_OLD-42f978a478093da579907e15dc29680a3711b27e.zip
opensim-SC_OLD-42f978a478093da579907e15dc29680a3711b27e.tar.gz
opensim-SC_OLD-42f978a478093da579907e15dc29680a3711b27e.tar.bz2
opensim-SC_OLD-42f978a478093da579907e15dc29680a3711b27e.tar.xz
* HGScene is no more.
* Moved a few key inventory access methods from Scene.Inventory to an IInventoryAccessModule module
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs (renamed from OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs)125
1 files changed, 77 insertions, 48 deletions
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}