aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Hypergrid
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/Framework/Scenes/Hypergrid
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 'OpenSim/Region/Framework/Scenes/Hypergrid')
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs264
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs175
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs56
3 files changed, 0 insertions, 495 deletions
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/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
deleted file mode 100644
index c5f8921..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
+++ /dev/null
@@ -1,175 +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.Reflection;
29using log4net;
30using Nini.Config;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Framework.Communications;
34
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Services.Interfaces;
37
38namespace OpenSim.Region.Framework.Scenes.Hypergrid
39{
40 public partial class HGScene : Scene
41 {
42 #region Fields
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44
45 private HGAssetMapper m_assMapper;
46 public HGAssetMapper AssetMapper
47 {
48 get { return m_assMapper; }
49 }
50
51 private IHyperAssetService m_hyper;
52 private IHyperAssetService HyperAssets
53 {
54 get
55 {
56 if (m_hyper == null)
57 m_hyper = RequestModuleInterface<IHyperAssetService>();
58 return m_hyper;
59 }
60 }
61
62 #endregion
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 {
74 m_log.Info("[HGScene]: Starting HGScene.");
75 m_assMapper = new HGAssetMapper(this);
76
77 EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem;
78 }
79
80 #endregion
81
82 #region Event handlers
83
84 public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel)
85 {
86 UserAccount userInfo = UserAccountService.GetUserAccount(RegionInfo.ScopeID, avatarID);
87 if (userInfo != null)
88 {
89 m_assMapper.Post(assetID, avatarID);
90 }
91 }
92
93 #endregion
94
95 #region Overrides of Scene.Inventory methods
96
97 ///
98 /// CapsUpdateInventoryItemAsset
99 ///
100 public override UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data)
101 {
102 UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data);
103
104 UploadInventoryItem(remoteClient.AgentId, newAssetID, "", 0);
105
106 return newAssetID;
107 }
108
109 ///
110 /// DeleteToInventory
111 ///
112 public override UUID DeleteToInventory(DeRezAction action, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient)
113 {
114 UUID assetID = base.DeleteToInventory(action, folderID, objectGroup, remoteClient);
115
116 if (!assetID.Equals(UUID.Zero))
117 {
118 UploadInventoryItem(remoteClient.AgentId, assetID, "", 0);
119 }
120 else
121 m_log.Debug("[HGScene]: Scene.Inventory did not create asset");
122
123 return assetID;
124 }
125
126 ///
127 /// RezObject
128 ///
129 public override SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart,
130 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
131 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
132 {
133 m_log.DebugFormat("[HGScene] RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID);
134
135 //if (fromTaskID.Equals(UUID.Zero))
136 //{
137 InventoryItemBase item = new InventoryItemBase(itemID);
138 item.Owner = remoteClient.AgentId;
139 item = InventoryService.GetItem(item);
140 //if (item == null)
141 //{ // Fetch the item
142 // item = new InventoryItemBase();
143 // item.Owner = remoteClient.AgentId;
144 // item.ID = itemID;
145 // item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo);
146 //}
147 if (item != null)
148 {
149 m_assMapper.Get(item.AssetID, remoteClient.AgentId);
150
151 }
152 //}
153
154 // OK, we're done fetching. Pass it up to the default RezObject
155 return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
156 RezSelected, RemoveItem, fromTaskID, attachment);
157
158 }
159
160 protected override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
161 {
162 string userAssetServer = HyperAssets.GetUserAssetServer(sender);
163 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer()))
164 m_assMapper.Get(item.AssetID, sender);
165
166 userAssetServer = HyperAssets.GetUserAssetServer(receiver);
167 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer()))
168 m_assMapper.Post(item.AssetID, receiver);
169 }
170
171 #endregion
172
173 }
174
175}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs
deleted file mode 100644
index 5d4e7ac..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs
+++ /dev/null
@@ -1,56 +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;
30
31using OpenSim.Framework;
32using OpenSim.Services.Interfaces;
33using OpenMetaverse;
34
35namespace OpenSim.Region.Framework.Scenes.Hypergrid
36{
37 public class HGUuidGatherer : UuidGatherer
38 {
39 protected string m_assetServerURL;
40 protected HGAssetMapper m_assetMapper;
41
42 public HGUuidGatherer(HGAssetMapper assMap, IAssetService assetCache, string assetServerURL) : base(assetCache)
43 {
44 m_assetMapper = assMap;
45 m_assetServerURL = assetServerURL;
46 }
47
48 protected override AssetBase GetAsset(UUID uuid)
49 {
50 if (string.Empty == m_assetServerURL)
51 return m_assetCache.Get(uuid.ToString());
52 else
53 return m_assetMapper.FetchAsset(m_assetServerURL, uuid);
54 }
55 }
56}