Merge branch 'master' into careminster-presence-refactor

avinationmerge
Melanie 2010-07-08 17:32:57 +01:00
commit 5f400a50be
18 changed files with 157 additions and 148 deletions

View File

@ -73,7 +73,18 @@ namespace OpenSim.Framework.Servers.HttpServer
{
if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id))
{
StreamReader str = new StreamReader(req.Request.Body);
StreamReader str;
try
{
str = new StreamReader(req.Request.Body);
}
catch (System.ArgumentException)
{
// Stream was not readable means a child agent
// was closed due to logout, leaving the
// Event Queue request orphaned.
continue;
}
Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd());
m_server.DoHTTPGruntWork(responsedata,

View File

@ -55,7 +55,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public IJ2KDecoder J2KDecoder;
public IAssetService AssetService;
public UUID AgentID;
public IHyperAssetService HyperAssets;
public IInventoryAccessModule InventoryAccessModule;
public OpenJPEG.J2KLayerInfo[] Layers;
public bool IsDecoded;
public bool HasAsset;
@ -378,14 +378,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
UUID assetID = UUID.Zero;
if (asset != null)
assetID = asset.FullID;
else if ((HyperAssets != null) && (sender != HyperAssets))
else if ((InventoryAccessModule != null) && (sender != InventoryAccessModule))
{
// Try the user's inventory, but only if it's different from the regions'
string userAssets = HyperAssets.GetUserAssetServer(AgentID);
if ((userAssets != string.Empty) && (userAssets != HyperAssets.GetSimAssetServer()))
// Unfortunately we need this here, there's no other way.
// This is due to the fact that textures opened directly from the agent's inventory
// don't have any distinguishing feature. As such, in order to serve those when the
// foreign user is visiting, we need to try again after the first fail to the local
// asset service.
string assetServerURL = string.Empty;
if (InventoryAccessModule.IsForeignUser(AgentID, out assetServerURL))
{
m_log.DebugFormat("[J2KIMAGE]: texture {0} not found in local asset storage. Trying user's storage.", id);
AssetService.Get(userAssets + "/" + id, HyperAssets, AssetReceived);
AssetService.Get(assetServerURL + "/" + id, InventoryAccessModule, AssetReceived);
return;
}
}

View File

@ -358,7 +358,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
protected uint m_agentFOVCounter;
protected IAssetService m_assetService;
private IHyperAssetService m_hyperAssets;
private const bool m_checkPackets = true;
private Timer m_propertiesPacketTimer;
@ -435,7 +434,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// m_attachmentsSent = new HashSet<uint>();
m_assetService = m_scene.RequestModuleInterface<IAssetService>();
m_hyperAssets = m_scene.RequestModuleInterface<IHyperAssetService>();
m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>();
m_imageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>());
m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion());
@ -7209,59 +7207,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
else // Agent
{
IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>();
InventoryItemBase assetRequestItem = new InventoryItemBase(itemID, AgentId);
assetRequestItem = invService.GetItem(assetRequestItem);
if (assetRequestItem == null)
IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
if (invAccess != null)
{
ILibraryService lib = m_scene.RequestModuleInterface<ILibraryService>();
if (lib != null)
assetRequestItem = lib.LibraryRootFolder.FindItem(itemID);
if (assetRequestItem == null)
return true;
}
if (!invAccess.GetAgentInventoryItem(this, itemID, requestID))
return false;
// At this point, we need to apply perms
// only to notecards and scripts. All
// other asset types are always available
//
if (assetRequestItem.AssetType == (int)AssetType.LSLText)
{
if (!((Scene)m_scene).Permissions.CanViewScript(itemID, UUID.Zero, AgentId))
{
SendAgentAlertMessage("Insufficient permissions to view script", false);
return true;
}
}
else if (assetRequestItem.AssetType == (int)AssetType.Notecard)
{
if (!((Scene)m_scene).Permissions.CanViewNotecard(itemID, UUID.Zero, AgentId))
{
SendAgentAlertMessage("Insufficient permissions to view notecard", false);
return true;
}
}
else
return false;
if (assetRequestItem.AssetID != requestID)
{
m_log.WarnFormat(
"[CLIENT]: {0} requested asset {1} from item {2} but this does not match item's asset {3}",
Name, requestID, itemID, assetRequestItem.AssetID);
return true;
}
}
}
}
//m_assetCache.AddAssetRequest(this, transfer);
MakeAssetRequest(transfer, taskID);
/* RequestAsset = OnRequestAsset;
if (RequestAsset != null)
{
RequestAsset(this, transfer);
}*/
return true;
}
@ -11498,15 +11459,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
{
requestID = new UUID(transferRequest.TransferInfo.Params, 80);
//m_log.Debug("[XXX] inventory asset request " + requestID);
//if (taskID == UUID.Zero) // Agent
// if (m_scene is HGScene)
// {
// m_log.Debug("[XXX] hg asset request " + requestID);
// // We may need to fetch the asset from the user's asset server into the local asset server
// HGAssetMapper mapper = ((HGScene)m_scene).AssetMapper;
// mapper.Get(requestID, AgentId);
// }
}
// m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID);
@ -11525,18 +11477,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="asset"></param>
protected void AssetReceived(string id, Object sender, AssetBase asset)
{
if (asset == null)
return;
TransferRequestPacket transferRequest = (TransferRequestPacket)sender;
UUID requestID = UUID.Zero;
byte source = (byte)SourceType.Asset;
if ((transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
|| (transferRequest.TransferInfo.SourceType == 2222))
if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
{
requestID = new UUID(transferRequest.TransferInfo.Params, 0);
}
else if ((transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
|| (transferRequest.TransferInfo.SourceType == 3333))
else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
{
requestID = new UUID(transferRequest.TransferInfo.Params, 80);
source = (byte)SourceType.SimInventoryItem;

View File

@ -58,8 +58,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer());
private object m_syncRoot = new object();
private IHyperAssetService m_hyperAssets;
public LLClientView Client { get { return m_client; } }
public AssetBase MissingImage { get { return m_missingImage; } }
@ -75,7 +73,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_log.Error("[ClientView] - Couldn't set missing image asset, falling back to missing image packet. This is known to crash the client");
m_j2kDecodeModule = pJ2kDecodeModule;
m_hyperAssets = client.Scene.RequestModuleInterface<IHyperAssetService>();
}
/// <summary>
@ -149,7 +146,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
imgrequest.J2KDecoder = m_j2kDecodeModule;
imgrequest.AssetService = m_assetCache;
imgrequest.AgentID = m_client.AgentId;
imgrequest.HyperAssets = m_hyperAssets;
imgrequest.InventoryAccessModule = m_client.Scene.RequestModuleInterface<IInventoryAccessModule>();
imgrequest.DiscardLevel = newRequest.DiscardLevel;
imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber);
imgrequest.Priority = newRequest.Priority;

View File

@ -157,6 +157,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>();
HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
if (ids.ContainsKey(assetID))
ids.Remove(assetID);
foreach (UUID uuid in ids.Keys)
FetchAsset(userAssetURL, uuid);

View File

@ -131,7 +131,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
return ret;
}
// DO NOT OVERRIDE THIS METHOD
// DO NOT OVERRIDE THE BASE METHOD
public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
SceneObjectGroup objectGroup, IClientAPI remoteClient)
{
@ -139,6 +139,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
if (!assetID.Equals(UUID.Zero))
{
if (remoteClient != null)
UploadInventoryItem(remoteClient.AgentId, assetID, "", 0);
}
else
@ -192,9 +193,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
m_assMapper.Post(item.AssetID, receiver, userAssetServer);
}
#endregion
public bool IsForeignUser(UUID userID, out string assetServerURL)
public override bool IsForeignUser(UUID userID, out string assetServerURL)
{
assetServerURL = string.Empty;
UserAccount account = null;
@ -217,5 +216,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
return false;
}
#endregion
protected override InventoryItemBase GetItem(UUID agentID, UUID itemID)
{
InventoryItemBase item = base.GetItem(agentID, itemID);
string userAssetServer = string.Empty;
if (IsForeignUser(agentID, out userAssetServer))
m_assMapper.Get(item.AssetID, agentID, userAssetServer);
return item;
}
}
}

View File

@ -639,6 +639,57 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
{
}
public virtual bool GetAgentInventoryItem(IClientAPI remoteClient, UUID itemID, UUID requestID)
{
InventoryItemBase assetRequestItem = GetItem(remoteClient.AgentId, itemID);
if (assetRequestItem == null)
{
ILibraryService lib = m_Scene.RequestModuleInterface<ILibraryService>();
if (lib != null)
assetRequestItem = lib.LibraryRootFolder.FindItem(itemID);
if (assetRequestItem == null)
return false;
}
// At this point, we need to apply perms
// only to notecards and scripts. All
// other asset types are always available
//
if (assetRequestItem.AssetType == (int)AssetType.LSLText)
{
if (!m_Scene.Permissions.CanViewScript(itemID, UUID.Zero, remoteClient.AgentId))
{
remoteClient.SendAgentAlertMessage("Insufficient permissions to view script", false);
return false;
}
}
else if (assetRequestItem.AssetType == (int)AssetType.Notecard)
{
if (!m_Scene.Permissions.CanViewNotecard(itemID, UUID.Zero, remoteClient.AgentId))
{
remoteClient.SendAgentAlertMessage("Insufficient permissions to view notecard", false);
return false;
}
}
if (assetRequestItem.AssetID != requestID)
{
m_log.WarnFormat(
"[CLIENT]: {0} requested asset {1} from item {2} but this does not match item's asset {3}",
Name, requestID, itemID, assetRequestItem.AssetID);
return false;
}
return true;
}
public virtual bool IsForeignUser(UUID userID, out string assetServerURL)
{
assetServerURL = string.Empty;
return false;
}
#endregion
#region Misc
@ -661,6 +712,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
return asset;
}
protected virtual InventoryItemBase GetItem(UUID agentID, UUID itemID)
{
IInventoryService invService = m_Scene.RequestModuleInterface<IInventoryService>();
InventoryItemBase assetRequestItem = new InventoryItemBase(itemID, agentID);
assetRequestItem = invService.GetItem(assetRequestItem);
return assetRequestItem;
}
#endregion
}
}

View File

@ -41,7 +41,7 @@ using OpenMetaverse;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
{
public class HGAssetBroker :
ISharedRegionModule, IAssetService, IHyperAssetService
ISharedRegionModule, IAssetService
{
private static readonly ILog m_log =
LogManager.GetLogger(
@ -150,7 +150,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
m_aScene = scene;
scene.RegisterModuleInterface<IAssetService>(this);
scene.RegisterModuleInterface<IHyperAssetService>(this);
}
public void RemoveRegion(Scene scene)

View File

@ -202,9 +202,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
}
}
}
// else put a null; it means that the methods should forward to local grid's inventory
m_InventoryURLs.Add(userID, null);
}
private void DropInventoryServiceURL(UUID userID)
@ -223,10 +220,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
if (m_InventoryURLs.ContainsKey(userID))
return m_InventoryURLs[userID];
else
CacheInventoryServiceURL(userID);
if (m_InventoryURLs.ContainsKey(userID))
return m_InventoryURLs[userID];
return null; //it means that the methods should forward to local grid's inventory
}
#endregion

View File

@ -258,22 +258,17 @@ namespace OpenSim.Region.DataSnapshot
private String GetRegionCategory(Scene scene)
{
//Boolean choice between:
// "PG" - Mormontown
// "Mature" - Sodom and Gomorrah
if (scene.RegionInfo.RegionSettings.Maturity == 1)
{
return "Mature";
}
else if (scene.RegionInfo.RegionSettings.Maturity == 0)
{
if (scene.RegionInfo.RegionSettings.Maturity == 0)
return "PG";
}
else
{
if (scene.RegionInfo.RegionSettings.Maturity == 1)
return "Mature";
if (scene.RegionInfo.RegionSettings.Maturity == 2)
return "Adult";
return "Unknown";
}
}
private XmlNode GetGridSnapshotData(XmlDocument factory)
{

View File

@ -1,37 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using OpenMetaverse;
namespace OpenSim.Region.Framework.Interfaces
{
public interface IHyperAssetService
{
string GetUserAssetServer(UUID userID);
string GetSimAssetServer();
}
}

View File

@ -43,5 +43,9 @@ namespace OpenSim.Region.Framework.Interfaces
UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment);
void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver);
bool GetAgentInventoryItem(IClientAPI remoteClient, UUID itemID, UUID requestID);
// Must be here because of textures in user's inventory
bool IsForeignUser(UUID userID, out string assetServerURL);
}
}

View File

@ -1622,7 +1622,7 @@ namespace OpenSim.Region.Framework.Scenes
}
// Handle god perms
if (remoteClient != null && Permissions.IsGod(remoteClient.AgentId))
if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId))
{
permissionToTake = true;
permissionToTakeCopy = true;

View File

@ -519,12 +519,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Vector llVecNorm(LSL_Vector v)
{
m_host.AddScriptLPS(1);
double mag = LSL_Vector.Mag(v);
LSL_Vector nor = new LSL_Vector();
nor.x = v.x / mag;
nor.y = v.y / mag;
nor.z = v.z / mag;
return nor;
return LSL_Vector.Norm(v);
}
public LSL_Float llVecDist(LSL_Vector a, LSL_Vector b)

View File

@ -262,7 +262,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
public static Vector3 Norm(Vector3 vector)
{
double mag = Mag(vector);
return new Vector3(vector.x / mag, vector.y / mag, vector.z / mag);
if (mag > 0.0)
{
double invMag = 1.0 / mag;
return vector * invMag;
}
return new Vector3(0, 0, 0);
}
#endregion

View File

@ -278,7 +278,11 @@ namespace OpenSim.Services.GridService
foreach (RegionData rdata in rdatas)
if (rdata.RegionID != regionID)
{
int flags = Convert.ToInt32(rdata.Data["flags"]);
if ((flags & (int)Data.RegionFlags.Hyperlink) == 0) // no hyperlinks as neighbours
rinfos.Add(RegionData2RegionInfo(rdata));
}
}
m_log.DebugFormat("[GRID SERVICE]: region {0} has {1} neighours", region.RegionName, rinfos.Count);

View File

@ -7,6 +7,9 @@
[Includes]
Include-Common = "config-include/GridCommon.ini"
[Startup]
WorldMapModule = "HGWorldMap"
[Modules]
AssetServices = "HGAssetBroker"
InventoryServices = "HGInventoryBroker"

View File

@ -4,6 +4,9 @@
;; which you can copy and change.
;;
[Startup]
WorldMapModule = "HGWorldMap"
[Modules]
AssetServices = "HGAssetBroker"
InventoryServices = "HGInventoryBroker"