aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorDiva Canto2009-10-12 17:00:01 -0700
committerDiva Canto2009-10-12 17:00:01 -0700
commitc0beeb929e22509329781cdf85f7a5d90c4b0e36 (patch)
tree42f724d921f08b0d2d14c8f7eb872a118a9adadd /OpenSim/Region
parent0004246: [Patch] FlotsamAssetCache deep scan & cache (diff)
downloadopensim-SC-c0beeb929e22509329781cdf85f7a5d90c4b0e36.zip
opensim-SC-c0beeb929e22509329781cdf85f7a5d90c4b0e36.tar.gz
opensim-SC-c0beeb929e22509329781cdf85f7a5d90c4b0e36.tar.bz2
opensim-SC-c0beeb929e22509329781cdf85f7a5d90c4b0e36.tar.xz
* Fixes http://opensimulator.org/mantis/view.php?id=4225
* Fixes http://opensimulator.org/mantis/view.php?id=3959 * Allows for viewing inventory textures outside home grid
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs14
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs21
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs5
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs44
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs3
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs98
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs26
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs9
10 files changed, 161 insertions, 62 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
index 5877779..1bbe00f 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
@@ -31,6 +31,7 @@ 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;
34using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
35using log4net; 36using log4net;
36using System.Reflection; 37using System.Reflection;
@@ -54,6 +55,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
54 public UUID TextureID; 55 public UUID TextureID;
55 public IJ2KDecoder J2KDecoder; 56 public IJ2KDecoder J2KDecoder;
56 public IAssetService AssetService; 57 public IAssetService AssetService;
58 public UUID AgentID;
59 public IHyperAssetService HyperAssets;
57 public OpenJPEG.J2KLayerInfo[] Layers; 60 public OpenJPEG.J2KLayerInfo[] Layers;
58 public bool IsDecoded; 61 public bool IsDecoded;
59 public bool HasAsset; 62 public bool HasAsset;
@@ -370,6 +373,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
370 UUID assetID = UUID.Zero; 373 UUID assetID = UUID.Zero;
371 if (asset != null) 374 if (asset != null)
372 assetID = asset.FullID; 375 assetID = asset.FullID;
376 else if (HyperAssets != null)
377 {
378 // Try the user's inventory, but only if it's different from the regions'
379 string userAssets = HyperAssets.GetUserAssetServer(AgentID);
380 if ((userAssets != string.Empty) && (userAssets != HyperAssets.GetSimAssetServer()))
381 {
382 m_log.DebugFormat("[J2KIMAGE]: texture {0} not found in local asset storage. Trying user's storage.", id);
383 AssetService.Get(userAssets + "/" + id, this, AssetReceived);
384 return;
385 }
386 }
373 387
374 AssetDataCallback(assetID, asset); 388 AssetDataCallback(assetID, asset);
375 389
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 84e705a..25eb5cd 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -43,6 +43,7 @@ using OpenSim.Framework.Communications.Cache;
43using OpenSim.Framework.Statistics; 43using OpenSim.Framework.Statistics;
44using OpenSim.Region.Framework.Interfaces; 44using OpenSim.Region.Framework.Interfaces;
45using OpenSim.Region.Framework.Scenes; 45using OpenSim.Region.Framework.Scenes;
46using OpenSim.Region.Framework.Scenes.Hypergrid;
46using OpenSim.Services.Interfaces; 47using OpenSim.Services.Interfaces;
47using Timer=System.Timers.Timer; 48using Timer=System.Timers.Timer;
48using AssetLandmark = OpenSim.Framework.AssetLandmark; 49using AssetLandmark = OpenSim.Framework.AssetLandmark;
@@ -117,6 +118,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
117 protected int m_packetMTU = 1400; 118 protected int m_packetMTU = 1400;
118 protected IAssetService m_assetService; 119 protected IAssetService m_assetService;
119 120
121
120 #region Properties 122 #region Properties
121 123
122 public UUID SecureSessionId { get { return m_secureSessionId; } } 124 public UUID SecureSessionId { get { return m_secureSessionId; } }
@@ -7013,7 +7015,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7013 #endregion 7015 #endregion
7014 7016
7015 //handlerTextureRequest = null; 7017 //handlerTextureRequest = null;
7016
7017 for (int i = 0; i < imageRequest.RequestImage.Length; i++) 7018 for (int i = 0; i < imageRequest.RequestImage.Length; i++)
7018 { 7019 {
7019 if (OnRequestTexture != null) 7020 if (OnRequestTexture != null)
@@ -7024,7 +7025,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7024 args.PacketNumber = imageRequest.RequestImage[i].Packet; 7025 args.PacketNumber = imageRequest.RequestImage[i].Packet;
7025 args.Priority = imageRequest.RequestImage[i].DownloadPriority; 7026 args.Priority = imageRequest.RequestImage[i].DownloadPriority;
7026 args.requestSequence = imageRequest.Header.Sequence; 7027 args.requestSequence = imageRequest.Header.Sequence;
7027
7028 //handlerTextureRequest = OnRequestTexture; 7028 //handlerTextureRequest = OnRequestTexture;
7029 7029
7030 //if (handlerTextureRequest != null) 7030 //if (handlerTextureRequest != null)
@@ -7047,10 +7047,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7047 // Validate inventory transfers 7047 // Validate inventory transfers
7048 // Has to be done here, because AssetCache can't do it 7048 // Has to be done here, because AssetCache can't do it
7049 // 7049 //
7050 7050 UUID taskID = UUID.Zero;
7051 if (transfer.TransferInfo.SourceType == 3) 7051 if (transfer.TransferInfo.SourceType == 3)
7052 { 7052 {
7053 UUID taskID = new UUID(transfer.TransferInfo.Params, 48); 7053 taskID = new UUID(transfer.TransferInfo.Params, 48);
7054 UUID itemID = new UUID(transfer.TransferInfo.Params, 64); 7054 UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
7055 UUID requestID = new UUID(transfer.TransferInfo.Params, 80); 7055 UUID requestID = new UUID(transfer.TransferInfo.Params, 80);
7056 if (!(((Scene)m_scene).Permissions.BypassPermissions())) 7056 if (!(((Scene)m_scene).Permissions.BypassPermissions()))
@@ -7121,7 +7121,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7121 7121
7122 //m_assetCache.AddAssetRequest(this, transfer); 7122 //m_assetCache.AddAssetRequest(this, transfer);
7123 7123
7124 MakeAssetRequest(transfer); 7124 MakeAssetRequest(transfer, taskID);
7125 7125
7126 /* RequestAsset = OnRequestAsset; 7126 /* RequestAsset = OnRequestAsset;
7127 if (RequestAsset != null) 7127 if (RequestAsset != null)
@@ -10330,7 +10330,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
10330 return String.Empty; 10330 return String.Empty;
10331 } 10331 }
10332 10332
10333 public void MakeAssetRequest(TransferRequestPacket transferRequest) 10333 public void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID)
10334 { 10334 {
10335 UUID requestID = UUID.Zero; 10335 UUID requestID = UUID.Zero;
10336 if (transferRequest.TransferInfo.SourceType == 2) 10336 if (transferRequest.TransferInfo.SourceType == 2)
@@ -10343,11 +10343,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
10343 //inventory asset request 10343 //inventory asset request
10344 requestID = new UUID(transferRequest.TransferInfo.Params, 80); 10344 requestID = new UUID(transferRequest.TransferInfo.Params, 80);
10345 //m_log.Debug("asset request " + requestID); 10345 //m_log.Debug("asset request " + requestID);
10346 if (taskID == UUID.Zero) // Agent
10347 if (m_scene is HGScene)
10348 {
10349 // We may need to fetch the asset from the user's asset server into the local asset server
10350 HGAssetMapper mapper = ((HGScene)m_scene).AssetMapper;
10351 mapper.Get(requestID, AgentId);
10352 }
10346 } 10353 }
10347 10354
10348 //check to see if asset is in local cache, if not we need to request it from asset server. 10355 //check to see if asset is in local cache, if not we need to request it from asset server.
10349 //m_log.Debug("asset request " + requestID); 10356 //m_log.Debug("asset request " + requestID);
10350 10357
10351 m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived); 10358 m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
10352 10359
10353 } 10360 }
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs
index 343f537..56d34e6 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs
@@ -59,6 +59,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
59 private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer()); 59 private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer());
60 private object m_syncRoot = new object(); 60 private object m_syncRoot = new object();
61 61
62 private IHyperAssetService m_hyperAssets;
63
62 public LLClientView Client { get { return m_client; } } 64 public LLClientView Client { get { return m_client; } }
63 public AssetBase MissingImage { get { return m_missingImage; } } 65 public AssetBase MissingImage { get { return m_missingImage; } }
64 66
@@ -74,6 +76,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
74 m_log.Error("[ClientView] - Couldn't set missing image asset, falling back to missing image packet. This is known to crash the client"); 76 m_log.Error("[ClientView] - Couldn't set missing image asset, falling back to missing image packet. This is known to crash the client");
75 77
76 m_j2kDecodeModule = pJ2kDecodeModule; 78 m_j2kDecodeModule = pJ2kDecodeModule;
79 m_hyperAssets = client.Scene.RequestModuleInterface<IHyperAssetService>();
77 } 80 }
78 81
79 /// <summary> 82 /// <summary>
@@ -146,6 +149,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
146 imgrequest = new J2KImage(this); 149 imgrequest = new J2KImage(this);
147 imgrequest.J2KDecoder = m_j2kDecodeModule; 150 imgrequest.J2KDecoder = m_j2kDecodeModule;
148 imgrequest.AssetService = m_assetCache; 151 imgrequest.AssetService = m_assetCache;
152 imgrequest.AgentID = m_client.AgentId;
153 imgrequest.HyperAssets = m_hyperAssets;
149 imgrequest.DiscardLevel = newRequest.DiscardLevel; 154 imgrequest.DiscardLevel = newRequest.DiscardLevel;
150 imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber); 155 imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber);
151 imgrequest.Priority = newRequest.Priority; 156 imgrequest.Priority = newRequest.Priority;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
index 7b4e374..0aa753d 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
@@ -31,6 +31,7 @@ using System;
31using System.Collections.Generic; 31using System.Collections.Generic;
32using System.Reflection; 32using System.Reflection;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications.Cache;
34using OpenSim.Server.Base; 35using OpenSim.Server.Base;
35using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
@@ -40,7 +41,7 @@ using OpenMetaverse;
40namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset 41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
41{ 42{
42 public class HGAssetBroker : 43 public class HGAssetBroker :
43 ISharedRegionModule, IAssetService 44 ISharedRegionModule, IAssetService, IHyperAssetService
44 { 45 {
45 private static readonly ILog m_log = 46 private static readonly ILog m_log =
46 LogManager.GetLogger( 47 LogManager.GetLogger(
@@ -50,6 +51,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
50 private IAssetService m_GridService; 51 private IAssetService m_GridService;
51 private IAssetService m_HGService; 52 private IAssetService m_HGService;
52 53
54 private Scene m_aScene;
55 private string m_LocalAssetServiceURI;
56
53 private bool m_Enabled = false; 57 private bool m_Enabled = false;
54 58
55 public Type ReplaceableInterface 59 public Type ReplaceableInterface
@@ -114,6 +118,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
114 return; 118 return;
115 } 119 }
116 120
121 m_LocalAssetServiceURI = assetConfig.GetString("AssetServerURI", string.Empty);
122 if (m_LocalAssetServiceURI == string.Empty)
123 {
124 IConfig netConfig = source.Configs["Network"];
125 m_LocalAssetServiceURI = netConfig.GetString("asset_server_url", string.Empty);
126 }
127
128 if (m_LocalAssetServiceURI != string.Empty)
129 m_LocalAssetServiceURI = m_LocalAssetServiceURI.Trim('/');
130
117 m_Enabled = true; 131 m_Enabled = true;
118 m_log.Info("[HG ASSET CONNECTOR]: HG asset broker enabled"); 132 m_log.Info("[HG ASSET CONNECTOR]: HG asset broker enabled");
119 } 133 }
@@ -132,8 +146,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
132 { 146 {
133 if (!m_Enabled) 147 if (!m_Enabled)
134 return; 148 return;
149
150 m_aScene = scene;
135 151
136 scene.RegisterModuleInterface<IAssetService>(this); 152 scene.RegisterModuleInterface<IAssetService>(this);
153 scene.RegisterModuleInterface<IHyperAssetService>(this);
137 } 154 }
138 155
139 public void RemoveRegion(Scene scene) 156 public void RemoveRegion(Scene scene)
@@ -344,5 +361,30 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
344 else 361 else
345 return m_GridService.Delete(id); 362 return m_GridService.Delete(id);
346 } 363 }
364
365 #region IHyperAssetService
366
367 public string GetUserAssetServer(UUID userID)
368 {
369 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
370 if ((uinfo != null) && (uinfo.UserProfile != null))
371 {
372 if ((uinfo.UserProfile.UserAssetURI == string.Empty) || (uinfo.UserProfile.UserAssetURI == ""))
373 return m_LocalAssetServiceURI;
374 return uinfo.UserProfile.UserAssetURI.Trim('/');
375 }
376 else
377 {
378 // we don't know anyting about this user
379 return string.Empty;
380 }
381 }
382
383 public string GetSimAssetServer()
384 {
385 return m_LocalAssetServiceURI;
386 }
387
388 #endregion
347 } 389 }
348} 390}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
index 148331b..1422add 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
@@ -759,6 +759,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
759 759
760 } 760 }
761 761
762
762 protected bool IsLocalRegion(ulong handle) 763 protected bool IsLocalRegion(ulong handle)
763 { 764 {
764 return m_LocalScenes.ContainsKey(handle); 765 return m_LocalScenes.ContainsKey(handle);
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs
index bd32f3b..811569f 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs
@@ -159,6 +159,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
159 /// <returns>true if the item was successfully added</returns> 159 /// <returns>true if the item was successfully added</returns>
160 public bool AddItem(InventoryItemBase item) 160 public bool AddItem(InventoryItemBase item)
161 { 161 {
162 if (item == null)
163 return false;
164
162 if (item.Folder == UUID.Zero) 165 if (item.Folder == UUID.Zero)
163 { 166 {
164 InventoryFolderBase f = GetFolderForType(item.Owner, (AssetType)item.AssetType); 167 InventoryFolderBase f = GetFolderForType(item.Owner, (AssetType)item.AssetType);
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index fd1a759..f073f32 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -386,7 +386,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
386 return false; 386 return false;
387 387
388 if (IsLocalGridUser(item.Owner)) 388 if (IsLocalGridUser(item.Owner))
389 {
389 return m_GridService.AddItem(item); 390 return m_GridService.AddItem(item);
391 }
390 else 392 else
391 { 393 {
392 UUID sessionID = GetSessionID(item.Owner); 394 UUID sessionID = GetSessionID(item.Owner);
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
index b6fa41d..244ac3b 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
@@ -35,6 +35,7 @@ using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache; 35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Communications.Clients; 36using OpenSim.Framework.Communications.Clients;
37using OpenSim.Region.Framework.Scenes.Serialization; 37using OpenSim.Region.Framework.Scenes.Serialization;
38using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Services.Interfaces; 39using OpenSim.Services.Interfaces;
39 40
40//using HyperGrid.Framework; 41//using HyperGrid.Framework;
@@ -52,13 +53,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
52 53
53 private Scene m_scene; 54 private Scene m_scene;
54 55
55 private IHyperlinkService m_hyper; 56 private IHyperAssetService m_hyper;
56 IHyperlinkService HyperlinkService 57 IHyperAssetService HyperlinkAssets
57 { 58 {
58 get 59 get
59 { 60 {
60 if (m_hyper == null) 61 if (m_hyper == null)
61 m_hyper = m_scene.RequestModuleInterface<IHyperlinkService>(); 62 m_hyper = m_scene.RequestModuleInterface<IHyperAssetService>();
62 return m_hyper; 63 return m_hyper;
63 } 64 }
64 } 65 }
@@ -99,7 +100,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
99 100
100 if (asset != null) 101 if (asset != null)
101 { 102 {
102 m_log.Debug("[HGScene]: Asset made it to asset cache. " + asset.Name + " " + assetID); 103 m_log.DebugFormat("[HGScene]: Copied asset {0} from {1} to local asset server. ", asset.ID, url);
103 return asset; 104 return asset;
104 } 105 }
105 return null; 106 return null;
@@ -129,6 +130,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
129 } 130 }
130 131
131 m_scene.AssetService.Store(asset1); 132 m_scene.AssetService.Store(asset1);
133 m_log.DebugFormat("[HGScene]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url);
132 } 134 }
133 return true; 135 return true;
134 } 136 }
@@ -167,34 +169,32 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
167 169
168 public void Get(UUID assetID, UUID ownerID) 170 public void Get(UUID assetID, UUID ownerID)
169 { 171 {
170 if (!HyperlinkService.IsLocalUser(ownerID)) 172 // Get the item from the remote asset server onto the local AssetCache
173 // and place an entry in m_assetMap
174
175 string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID);
176 if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer()))
171 { 177 {
172 // Get the item from the remote asset server onto the local AssetCache 178 m_log.Debug("[HGScene]: Fetching object " + assetID + " from asset server " + userAssetURL);
173 // and place an entry in m_assetMap 179 AssetBase asset = FetchAsset(userAssetURL, assetID);
174 180
175 string userAssetURL = UserAssetURL(ownerID); 181 if (asset != null)
176 if (userAssetURL != null)
177 { 182 {
178 m_log.Debug("[HGScene]: Fetching object " + assetID + " to asset server " + userAssetURL); 183 // OK, now fetch the inside.
179 AssetBase asset = FetchAsset(userAssetURL, assetID); 184 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
185 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
186 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
187 foreach (UUID uuid in ids.Keys)
188 FetchAsset(userAssetURL, uuid);
189
190 m_log.DebugFormat("[HGScene]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL);
180 191
181 if (asset != null)
182 {
183 m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL);
184
185 // OK, now fetch the inside.
186 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
187 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
188 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
189 foreach (UUID uuid in ids.Keys)
190 FetchAsset(userAssetURL, uuid);
191 }
192 else
193 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL);
194 } 192 }
195 else 193 else
196 m_log.Warn("[HGScene]: Unable to locate foreign user's asset server"); 194 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL);
197 } 195 }
196 else
197 m_log.Debug("[HGScene]: user's asset server is the local region's asset server");
198 } 198 }
199 199
200 //public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo) 200 //public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo)
@@ -225,44 +225,38 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
225 225
226 public void Post(UUID assetID, UUID ownerID) 226 public void Post(UUID assetID, UUID ownerID)
227 { 227 {
228 if (!HyperlinkService.IsLocalUser(ownerID))
229 {
230 // Post the item from the local AssetCache onto the remote asset server 228 // Post the item from the local AssetCache onto the remote asset server
231 // and place an entry in m_assetMap 229 // and place an entry in m_assetMap
232 230
233 string userAssetURL = UserAssetURL(ownerID); 231 string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID);
234 if (userAssetURL != null) 232 if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer()))
233 {
234 m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL);
235 AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
236 if (asset != null)
235 { 237 {
236 m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL); 238 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
237 AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); 239 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty);
238 if (asset != null) 240 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
241 foreach (UUID uuid in ids.Keys)
239 { 242 {
240 Dictionary<UUID, int> ids = new Dictionary<UUID, int>(); 243 asset = m_scene.AssetService.Get(uuid.ToString());
241 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty); 244 if (asset == null)
242 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); 245 m_log.DebugFormat("[HGScene]: Could not find asset {0}", uuid);
243 foreach (UUID uuid in ids.Keys) 246 else
244 {
245 asset = m_scene.AssetService.Get(uuid.ToString());
246 if (asset != null)
247 m_log.DebugFormat("[HGScene]: Posting {0} {1}", asset.Type.ToString(), asset.Name);
248 else
249 m_log.DebugFormat("[HGScene]: Could not find asset {0}", uuid);
250 PostAsset(userAssetURL, asset); 247 PostAsset(userAssetURL, asset);
251 } 248 }
252 249
253 if (ids.Count > 0) // maybe it succeeded... 250 // maybe all pieces got there...
254 m_log.DebugFormat("[HGScene]: Successfully posted item {0} to remote asset server {1}", assetID, userAssetURL); 251 m_log.DebugFormat("[HGScene]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL);
255 else
256 m_log.WarnFormat("[HGScene]: Could not post asset {0} to remote asset server {1}", assetID, userAssetURL);
257 252
258 }
259 else
260 m_log.Debug("[HGScene]: Something wrong with asset, it could not be found");
261 } 253 }
262 else 254 else
263 m_log.Warn("[HGScene]: Unable to locate foreign user's asset server"); 255 m_log.DebugFormat("[HGScene]: Something wrong with asset {0}, it could not be found", assetID);
264
265 } 256 }
257 else
258 m_log.Debug("[HGScene]: user's asset server is local region's asset server");
259
266 } 260 }
267 261
268 #endregion 262 #endregion
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
index 8fe3565..6f7f34f 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
@@ -32,6 +32,7 @@ using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Communications; 33using OpenSim.Framework.Communications;
34using OpenSim.Framework.Communications.Cache; 34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Region.Framework.Interfaces;
35 36
36namespace OpenSim.Region.Framework.Scenes.Hypergrid 37namespace OpenSim.Region.Framework.Scenes.Hypergrid
37{ 38{
@@ -41,6 +42,21 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 43
43 private HGAssetMapper m_assMapper; 44 private HGAssetMapper m_assMapper;
45 public HGAssetMapper AssetMapper
46 {
47 get { return m_assMapper; }
48 }
49
50 private IHyperAssetService m_hyper;
51 private IHyperAssetService HyperAssets
52 {
53 get
54 {
55 if (m_hyper == null)
56 m_hyper = RequestModuleInterface<IHyperAssetService>();
57 return m_hyper;
58 }
59 }
44 60
45 #endregion 61 #endregion
46 62
@@ -140,6 +156,16 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
140 156
141 } 157 }
142 158
159 protected override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
160 {
161 string userAssetServer = HyperAssets.GetUserAssetServer(sender);
162 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer()))
163 m_assMapper.Get(item.AssetID, sender);
164
165 userAssetServer = HyperAssets.GetUserAssetServer(receiver);
166 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer()))
167 m_assMapper.Post(item.AssetID, receiver);
168 }
143 169
144 #endregion 170 #endregion
145 171
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 1917228..0cb5682 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -408,7 +408,7 @@ namespace OpenSim.Region.Framework.Scenes
408 public virtual InventoryItemBase GiveInventoryItem( 408 public virtual InventoryItemBase GiveInventoryItem(
409 UUID recipient, UUID senderId, UUID itemId, UUID recipientFolderId) 409 UUID recipient, UUID senderId, UUID itemId, UUID recipientFolderId)
410 { 410 {
411 Console.WriteLine("Scene.Inventory.cs: GiveInventoryItem"); 411 //Console.WriteLine("Scene.Inventory.cs: GiveInventoryItem");
412 412
413 InventoryItemBase item = new InventoryItemBase(itemId, senderId); 413 InventoryItemBase item = new InventoryItemBase(itemId, senderId);
414 item = InventoryService.GetItem(item); 414 item = InventoryService.GetItem(item);
@@ -472,7 +472,8 @@ namespace OpenSim.Region.Framework.Scenes
472 itemCopy.SalePrice = item.SalePrice; 472 itemCopy.SalePrice = item.SalePrice;
473 itemCopy.SaleType = item.SaleType; 473 itemCopy.SaleType = item.SaleType;
474 474
475 InventoryService.AddItem(itemCopy); 475 if (InventoryService.AddItem(itemCopy))
476 TransferInventoryAssets(itemCopy, senderId, recipient);
476 477
477 if (!Permissions.BypassPermissions()) 478 if (!Permissions.BypassPermissions())
478 { 479 {
@@ -494,6 +495,10 @@ namespace OpenSim.Region.Framework.Scenes
494 495
495 } 496 }
496 497
498 protected virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
499 {
500 }
501
497 /// <summary> 502 /// <summary>
498 /// Give an entire inventory folder from one user to another. The entire contents (including all descendent 503 /// Give an entire inventory folder from one user to another. The entire contents (including all descendent
499 /// folders) is given. 504 /// folders) is given.