Compare commits
58 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d065bd327 | ||
|
|
81c484d713 | ||
|
|
335687c846 | ||
|
|
cdbf39ddba | ||
|
|
269e20ca11 | ||
|
|
0bcd3860cf | ||
|
|
94b5ea1b5a | ||
|
|
9106d82382 | ||
|
|
5d3d600b2e | ||
|
|
31a43c7fbc | ||
|
|
82fd8c46ea | ||
|
|
0ce8a5f76a | ||
|
|
34114c4e28 | ||
|
|
f839385af9 | ||
|
|
a6bce45692 | ||
|
|
7615d12148 | ||
|
|
0365fec926 | ||
|
|
53d21bcb50 | ||
|
|
c45392c17e | ||
|
|
7ac437987a | ||
|
|
9e17b07e8b | ||
|
|
8600ea2763 | ||
|
|
cd6fe5c4e6 | ||
|
|
64884bf65c | ||
|
|
c01db95f48 | ||
|
|
3fbadb79ba | ||
|
|
6eeba80d2a | ||
|
|
04431fcb01 | ||
|
|
bbe9af5576 | ||
|
|
6b4e4da89e | ||
|
|
b6e963c830 | ||
|
|
8ea08cf4b4 | ||
|
|
d92fc1dfb3 | ||
|
|
83c018ebcd | ||
|
|
cf763b8306 | ||
|
|
5cda6ab754 | ||
|
|
6f6e05d775 | ||
|
|
c07fdc6ac4 | ||
|
|
2e6f5f6bcd | ||
|
|
705b3fe414 | ||
|
|
55aaea8b91 | ||
|
|
f4e32350ed | ||
|
|
58f5e4b47a | ||
|
|
ddacc87617 | ||
|
|
c5d1d6c47b | ||
|
|
23ebe65add | ||
|
|
c611966828 | ||
|
|
b9fa9a801e | ||
|
|
ec38593674 | ||
|
|
f018047460 | ||
|
|
60a0395837 | ||
|
|
d27ed42897 | ||
|
|
8bdc238ca4 | ||
|
|
6903b60a0f | ||
|
|
46dec8666c | ||
|
|
352774d5bf | ||
|
|
34c0bd212a | ||
|
|
3032b49ec4 |
@@ -1,67 +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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Data;
|
||||
|
||||
namespace OpenSim.Data.Null
|
||||
{
|
||||
/// <summary>
|
||||
/// Not a proper generic data handler yet - probably needs to actually store the data as well instead of relying
|
||||
/// on descendent classes
|
||||
/// </summary>
|
||||
public class NullGenericDataHandler
|
||||
{
|
||||
protected List<T> Get<T>(string[] fields, string[] vals, List<T> inputEntities)
|
||||
{
|
||||
List<T> entities = inputEntities;
|
||||
|
||||
for (int i = 0; i < fields.Length; i++)
|
||||
{
|
||||
entities
|
||||
= entities.Where(
|
||||
e =>
|
||||
{
|
||||
FieldInfo fi = typeof(T).GetField(fields[i]);
|
||||
if (fi == null)
|
||||
throw new NotImplementedException(string.Format("No field {0} for val {1}", fields[i], vals[i]));
|
||||
|
||||
return fi.GetValue(e).ToString() == vals[i];
|
||||
}
|
||||
).ToList();
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,90 +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 System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Data;
|
||||
|
||||
namespace OpenSim.Data.Null
|
||||
{
|
||||
public class NullXGroupData : NullGenericDataHandler, IXGroupData
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private Dictionary<UUID, XGroup> m_groups = new Dictionary<UUID, XGroup>();
|
||||
|
||||
public NullXGroupData(string connectionString, string realm) {}
|
||||
|
||||
public bool StoreGroup(XGroup group)
|
||||
{
|
||||
lock (m_groups)
|
||||
{
|
||||
m_groups[group.groupID] = group.Clone();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public XGroup[] GetGroups(string field, string val)
|
||||
{
|
||||
return GetGroups(new string[] { field }, new string[] { val });
|
||||
}
|
||||
|
||||
public XGroup[] GetGroups(string[] fields, string[] vals)
|
||||
{
|
||||
lock (m_groups)
|
||||
{
|
||||
List<XGroup> origGroups = Get<XGroup>(fields, vals, m_groups.Values.ToList());
|
||||
|
||||
return origGroups.Select(g => g.Clone()).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public bool DeleteGroups(string field, string val)
|
||||
{
|
||||
return DeleteGroups(new string[] { field }, new string[] { val });
|
||||
}
|
||||
|
||||
public bool DeleteGroups(string[] fields, string[] vals)
|
||||
{
|
||||
lock (m_groups)
|
||||
{
|
||||
XGroup[] groupsToDelete = GetGroups(fields, vals);
|
||||
Array.ForEach(groupsToDelete, g => m_groups.Remove(g.groupID));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
using Nini.Config;
|
||||
using log4net;
|
||||
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
public class AssetPermissions
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private bool[] m_DisallowExport, m_DisallowImport;
|
||||
private string[] m_AssetTypeNames;
|
||||
|
||||
public AssetPermissions(IConfig config)
|
||||
{
|
||||
Type enumType = typeof(AssetType);
|
||||
m_AssetTypeNames = Enum.GetNames(enumType);
|
||||
for (int i = 0; i < m_AssetTypeNames.Length; i++)
|
||||
m_AssetTypeNames[i] = m_AssetTypeNames[i].ToLower();
|
||||
int n = Enum.GetValues(enumType).Length;
|
||||
m_DisallowExport = new bool[n];
|
||||
m_DisallowImport = new bool[n];
|
||||
|
||||
LoadPermsFromConfig(config, "DisallowExport", m_DisallowExport);
|
||||
LoadPermsFromConfig(config, "DisallowImport", m_DisallowImport);
|
||||
|
||||
}
|
||||
|
||||
private void LoadPermsFromConfig(IConfig assetConfig, string variable, bool[] bitArray)
|
||||
{
|
||||
if (assetConfig == null)
|
||||
return;
|
||||
|
||||
string perms = assetConfig.GetString(variable, String.Empty);
|
||||
string[] parts = perms.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string s in parts)
|
||||
{
|
||||
int index = Array.IndexOf(m_AssetTypeNames, s.Trim().ToLower());
|
||||
if (index >= 0)
|
||||
bitArray[index] = true;
|
||||
else
|
||||
m_log.WarnFormat("[Asset Permissions]: Invalid AssetType {0}", s);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool AllowedExport(sbyte type)
|
||||
{
|
||||
string assetTypeName = ((AssetType)type).ToString();
|
||||
|
||||
int index = Array.IndexOf(m_AssetTypeNames, assetTypeName.ToLower());
|
||||
if (index >= 0 && m_DisallowExport[index])
|
||||
{
|
||||
m_log.DebugFormat("[Asset Permissions]: Export denied: configuration does not allow export of AssetType {0}", assetTypeName);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool AllowedImport(sbyte type)
|
||||
{
|
||||
string assetTypeName = ((AssetType)type).ToString();
|
||||
|
||||
int index = Array.IndexOf(m_AssetTypeNames, assetTypeName.ToLower());
|
||||
if (index >= 0 && m_DisallowImport[index])
|
||||
{
|
||||
m_log.DebugFormat("[Asset Permissions]: Import denied: configuration does not allow import of AssetType {0}", assetTypeName);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,88 +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 System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework.Monitoring
|
||||
{
|
||||
public class PercentageStat : Stat
|
||||
{
|
||||
public long Antecedent { get; set; }
|
||||
public long Consequent { get; set; }
|
||||
|
||||
public override double Value
|
||||
{
|
||||
get
|
||||
{
|
||||
// Asking for an update here means that the updater cannot access this value without infinite recursion.
|
||||
// XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being
|
||||
// called by the pull action and just return the value.
|
||||
if (StatType == StatType.Pull)
|
||||
PullAction(this);
|
||||
|
||||
long c = Consequent;
|
||||
|
||||
// Avoid any chance of a multi-threaded divide-by-zero
|
||||
if (c == 0)
|
||||
return 0;
|
||||
|
||||
return (double)Antecedent / c * 100;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
throw new InvalidOperationException("Cannot set value on a PercentageStat");
|
||||
}
|
||||
}
|
||||
|
||||
public PercentageStat(
|
||||
string shortName,
|
||||
string name,
|
||||
string description,
|
||||
string category,
|
||||
string container,
|
||||
StatType type,
|
||||
Action<Stat> pullAction,
|
||||
StatVerbosity verbosity)
|
||||
: base(shortName, name, description, "%", category, container, type, pullAction, verbosity) {}
|
||||
|
||||
public override string ToConsoleString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.AppendFormat(
|
||||
"{0}.{1}.{2} : {3:0.##}{4} ({5}/{6})",
|
||||
Category, Container, ShortName, Value, UnitName, Antecedent, Consequent);
|
||||
|
||||
AppendMeasuresOfInterest(sb);
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,91 +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 System.Collections.Generic;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Naive pool implementation.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Currently assumes that objects are in a useable state when returned.
|
||||
/// </remarks>
|
||||
public class Pool<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Number of objects in the pool.
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_pool)
|
||||
return m_pool.Count;
|
||||
}
|
||||
}
|
||||
|
||||
private Stack<T> m_pool;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum pool size. Beyond this, any returned objects are not pooled.
|
||||
/// </summary>
|
||||
private int m_maxPoolSize;
|
||||
|
||||
private Func<T> m_createFunction;
|
||||
|
||||
public Pool(Func<T> createFunction, int maxSize)
|
||||
{
|
||||
m_maxPoolSize = maxSize;
|
||||
m_createFunction = createFunction;
|
||||
m_pool = new Stack<T>(m_maxPoolSize);
|
||||
}
|
||||
|
||||
public T GetObject()
|
||||
{
|
||||
lock (m_pool)
|
||||
{
|
||||
if (m_pool.Count > 0)
|
||||
return m_pool.Pop();
|
||||
else
|
||||
return m_createFunction();
|
||||
}
|
||||
}
|
||||
|
||||
public void ReturnObject(T obj)
|
||||
{
|
||||
lock (m_pool)
|
||||
{
|
||||
if (m_pool.Count >= m_maxPoolSize)
|
||||
return;
|
||||
else
|
||||
m_pool.Push(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +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;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Region flags used internally by OpenSimulator to store installation specific information about regions.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Don't confuse with OpenMetaverse.RegionFlags which are client facing flags (i.e. they go over the wire).
|
||||
/// Returned by IGridService.GetRegionFlags()
|
||||
/// </remarks>
|
||||
[Flags]
|
||||
public enum RegionFlags : int
|
||||
{
|
||||
DefaultRegion = 1, // Used for new Rez. Random if multiple defined
|
||||
FallbackRegion = 2, // Regions we redirect to when the destination is down
|
||||
RegionOnline = 4, // Set when a region comes online, unset when it unregisters and DeleteOnUnregister is false
|
||||
NoDirectLogin = 8, // Region unavailable for direct logins (by name)
|
||||
Persistent = 16, // Don't remove on unregister
|
||||
LockedOut = 32, // Don't allow registration
|
||||
NoMove = 64, // Don't allow moving this region
|
||||
Reservation = 128, // This is an inactive reservation
|
||||
Authenticate = 256, // Require authentication
|
||||
Hyperlink = 512 // Record represents a HG link
|
||||
}
|
||||
}
|
||||
@@ -1,306 +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 System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
using log4net;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
|
||||
namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
{
|
||||
public sealed class PacketPool
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private static readonly PacketPool instance = new PacketPool();
|
||||
|
||||
/// <summary>
|
||||
/// Pool of packets available for reuse.
|
||||
/// </summary>
|
||||
private readonly Dictionary<PacketType, Stack<Packet>> pool = new Dictionary<PacketType, Stack<Packet>>();
|
||||
|
||||
private static Dictionary<Type, Stack<Object>> DataBlocks = new Dictionary<Type, Stack<Object>>();
|
||||
|
||||
public static PacketPool Instance
|
||||
{
|
||||
get { return instance; }
|
||||
}
|
||||
|
||||
public bool RecyclePackets { get; set; }
|
||||
|
||||
public bool RecycleDataBlocks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of packets pooled
|
||||
/// </summary>
|
||||
public int PacketsPooled
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (pool)
|
||||
return pool.Count;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of blocks pooled.
|
||||
/// </summary>
|
||||
public int BlocksPooled
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (DataBlocks)
|
||||
return DataBlocks.Count;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of packets requested.
|
||||
/// </summary>
|
||||
public long PacketsRequested { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of packets reused.
|
||||
/// </summary>
|
||||
public long PacketsReused { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of packet blocks requested.
|
||||
/// </summary>
|
||||
public long BlocksRequested { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of packet blocks reused.
|
||||
/// </summary>
|
||||
public long BlocksReused { get; private set; }
|
||||
|
||||
private PacketPool()
|
||||
{
|
||||
// defaults
|
||||
RecyclePackets = true;
|
||||
RecycleDataBlocks = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a packet of the given type.
|
||||
/// </summary>
|
||||
/// <param name='type'></param>
|
||||
/// <returns>Guaranteed to always return a packet, whether from the pool or newly constructed.</returns>
|
||||
public Packet GetPacket(PacketType type)
|
||||
{
|
||||
PacketsRequested++;
|
||||
|
||||
Packet packet;
|
||||
|
||||
if (!RecyclePackets)
|
||||
return Packet.BuildPacket(type);
|
||||
|
||||
lock (pool)
|
||||
{
|
||||
if (!pool.ContainsKey(type) || pool[type] == null || (pool[type]).Count == 0)
|
||||
{
|
||||
// m_log.DebugFormat("[PACKETPOOL]: Building {0} packet", type);
|
||||
|
||||
// Creating a new packet if we cannot reuse an old package
|
||||
packet = Packet.BuildPacket(type);
|
||||
}
|
||||
else
|
||||
{
|
||||
// m_log.DebugFormat("[PACKETPOOL]: Pulling {0} packet", type);
|
||||
|
||||
// Recycle old packages
|
||||
PacketsReused++;
|
||||
|
||||
packet = pool[type].Pop();
|
||||
}
|
||||
}
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
// private byte[] decoded_header = new byte[10];
|
||||
private static PacketType GetType(byte[] bytes)
|
||||
{
|
||||
byte[] decoded_header = new byte[10 + 8];
|
||||
ushort id;
|
||||
PacketFrequency freq;
|
||||
|
||||
if ((bytes[0] & Helpers.MSG_ZEROCODED) != 0)
|
||||
{
|
||||
Helpers.ZeroDecode(bytes, 16, decoded_header);
|
||||
}
|
||||
else
|
||||
{
|
||||
Buffer.BlockCopy(bytes, 0, decoded_header, 0, 10);
|
||||
}
|
||||
|
||||
if (decoded_header[6] == 0xFF)
|
||||
{
|
||||
if (decoded_header[7] == 0xFF)
|
||||
{
|
||||
id = (ushort) ((decoded_header[8] << 8) + decoded_header[9]);
|
||||
freq = PacketFrequency.Low;
|
||||
}
|
||||
else
|
||||
{
|
||||
id = decoded_header[7];
|
||||
freq = PacketFrequency.Medium;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
id = decoded_header[6];
|
||||
freq = PacketFrequency.High;
|
||||
}
|
||||
|
||||
return Packet.GetType(id, freq);
|
||||
}
|
||||
|
||||
public Packet GetPacket(byte[] bytes, ref int packetEnd, byte[] zeroBuffer)
|
||||
{
|
||||
PacketType type = GetType(bytes);
|
||||
|
||||
// Array.Clear(zeroBuffer, 0, zeroBuffer.Length);
|
||||
|
||||
int i = 0;
|
||||
Packet packet = GetPacket(type);
|
||||
if (packet == null)
|
||||
m_log.WarnFormat("[PACKETPOOL]: Failed to get packet of type {0}", type);
|
||||
else
|
||||
packet.FromBytes(bytes, ref i, ref packetEnd, zeroBuffer);
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a packet to the packet pool
|
||||
/// </summary>
|
||||
/// <param name="packet"></param>
|
||||
public void ReturnPacket(Packet packet)
|
||||
{
|
||||
if (RecycleDataBlocks)
|
||||
{
|
||||
switch (packet.Type)
|
||||
{
|
||||
case PacketType.ObjectUpdate:
|
||||
ObjectUpdatePacket oup = (ObjectUpdatePacket)packet;
|
||||
|
||||
foreach (ObjectUpdatePacket.ObjectDataBlock oupod in oup.ObjectData)
|
||||
ReturnDataBlock<ObjectUpdatePacket.ObjectDataBlock>(oupod);
|
||||
|
||||
oup.ObjectData = null;
|
||||
break;
|
||||
|
||||
case PacketType.ImprovedTerseObjectUpdate:
|
||||
ImprovedTerseObjectUpdatePacket itoup = (ImprovedTerseObjectUpdatePacket)packet;
|
||||
|
||||
foreach (ImprovedTerseObjectUpdatePacket.ObjectDataBlock itoupod in itoup.ObjectData)
|
||||
ReturnDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(itoupod);
|
||||
|
||||
itoup.ObjectData = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (RecyclePackets)
|
||||
{
|
||||
switch (packet.Type)
|
||||
{
|
||||
// List pooling packets here
|
||||
case PacketType.AgentUpdate:
|
||||
case PacketType.PacketAck:
|
||||
case PacketType.ObjectUpdate:
|
||||
case PacketType.ImprovedTerseObjectUpdate:
|
||||
lock (pool)
|
||||
{
|
||||
PacketType type = packet.Type;
|
||||
|
||||
if (!pool.ContainsKey(type))
|
||||
{
|
||||
pool[type] = new Stack<Packet>();
|
||||
}
|
||||
|
||||
if ((pool[type]).Count < 50)
|
||||
{
|
||||
// m_log.DebugFormat("[PACKETPOOL]: Pushing {0} packet", type);
|
||||
|
||||
pool[type].Push(packet);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Other packets wont pool
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public T GetDataBlock<T>() where T: new()
|
||||
{
|
||||
lock (DataBlocks)
|
||||
{
|
||||
BlocksRequested++;
|
||||
|
||||
Stack<Object> s;
|
||||
|
||||
if (DataBlocks.TryGetValue(typeof(T), out s))
|
||||
{
|
||||
if (s.Count > 0)
|
||||
{
|
||||
BlocksReused++;
|
||||
return (T)s.Pop();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DataBlocks[typeof(T)] = new Stack<Object>();
|
||||
}
|
||||
|
||||
return new T();
|
||||
}
|
||||
}
|
||||
|
||||
public void ReturnDataBlock<T>(T block) where T: new()
|
||||
{
|
||||
if (block == null)
|
||||
return;
|
||||
|
||||
lock (DataBlocks)
|
||||
{
|
||||
if (!DataBlocks.ContainsKey(typeof(T)))
|
||||
DataBlocks[typeof(T)] = new Stack<Object>();
|
||||
|
||||
if (DataBlocks[typeof(T)].Count < 50)
|
||||
DataBlocks[typeof(T)].Push(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,137 +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 System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using Mono.Addins;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
|
||||
{
|
||||
public class BasePresenceServiceConnector : IPresenceService
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected bool m_Enabled;
|
||||
|
||||
protected PresenceDetector m_PresenceDetector;
|
||||
|
||||
/// <summary>
|
||||
/// Underlying presence service. Do not use directly.
|
||||
/// </summary>
|
||||
public IPresenceService m_PresenceService;
|
||||
|
||||
public Type ReplaceableInterface
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[LOCAL PRESENCE CONNECTOR]: Registering IPresenceService to scene {0}", scene.RegionInfo.RegionName);
|
||||
|
||||
scene.RegisterModuleInterface<IPresenceService>(this);
|
||||
m_PresenceDetector.AddRegion(scene);
|
||||
|
||||
m_log.InfoFormat("[BASE PRESENCE SERVICE CONNECTOR]: Enabled for region {0}", scene.Name);
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
|
||||
m_PresenceDetector.RemoveRegion(scene);
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
}
|
||||
|
||||
#region IPresenceService
|
||||
|
||||
public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID)
|
||||
{
|
||||
m_log.Warn("[BASE PRESENCE SERVICE CONNECTOR]: LoginAgent connector not implemented at the simulators");
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool LogoutAgent(UUID sessionID)
|
||||
{
|
||||
return m_PresenceService.LogoutAgent(sessionID);
|
||||
}
|
||||
|
||||
public bool LogoutRegionAgents(UUID regionID)
|
||||
{
|
||||
return m_PresenceService.LogoutRegionAgents(regionID);
|
||||
}
|
||||
|
||||
public bool ReportAgent(UUID sessionID, UUID regionID)
|
||||
{
|
||||
return m_PresenceService.ReportAgent(sessionID, regionID);
|
||||
}
|
||||
|
||||
public PresenceInfo GetAgent(UUID sessionID)
|
||||
{
|
||||
return m_PresenceService.GetAgent(sessionID);
|
||||
}
|
||||
|
||||
public PresenceInfo[] GetAgents(string[] userIDs)
|
||||
{
|
||||
// Don't bother potentially making a useless network call if we not going to ask for any users anyway.
|
||||
if (userIDs.Length == 0)
|
||||
return new PresenceInfo[0];
|
||||
|
||||
return m_PresenceService.GetAgents(userIDs);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,112 +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 System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenMetaverse.Messages.Linden;
|
||||
using Mono.Addins;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Capabilities;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Physics.Manager;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using Caps = OpenSim.Framework.Capabilities.Caps;
|
||||
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.World.Land
|
||||
{
|
||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DwellModule")]
|
||||
public class DwellModule : IDwellModule, INonSharedRegionModule
|
||||
{
|
||||
private Scene m_scene;
|
||||
|
||||
public Type ReplaceableInterface
|
||||
{
|
||||
get { return typeof(IDwellModule); }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "DwellModule"; }
|
||||
}
|
||||
|
||||
public void Initialise(IConfigSource source)
|
||||
{
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
|
||||
m_scene.EventManager.OnNewClient += OnNewClient;
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnNewClient(IClientAPI client)
|
||||
{
|
||||
client.OnParcelDwellRequest += ClientOnParcelDwellRequest;
|
||||
}
|
||||
|
||||
private void ClientOnParcelDwellRequest(int localID, IClientAPI client)
|
||||
{
|
||||
ILandObject parcel = m_scene.LandChannel.GetLandObject(localID);
|
||||
if (parcel == null)
|
||||
return;
|
||||
|
||||
client.SendParcelDwellReply(localID, parcel.LandData.GlobalID, parcel.LandData.Dwell);
|
||||
}
|
||||
|
||||
public int GetDwell(UUID parcelID)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,224 +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 System.Reflection;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Capabilities;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using Mono.Addins;
|
||||
|
||||
using Caps = OpenSim.Framework.Capabilities.Caps;
|
||||
|
||||
|
||||
namespace OpenSim.Region.CoreModules.World.LightShare
|
||||
{
|
||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EnvironmentModule")]
|
||||
|
||||
public class EnvironmentModule : INonSharedRegionModule, IEnvironmentModule
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private Scene m_scene = null;
|
||||
private UUID regionID = UUID.Zero;
|
||||
private static bool Enabled = false;
|
||||
|
||||
private static readonly string capsName = "EnvironmentSettings";
|
||||
private static readonly string capsBase = "/CAPS/0020/";
|
||||
|
||||
private LLSDEnvironmentSetResponse setResponse = null;
|
||||
|
||||
#region INonSharedRegionModule
|
||||
public void Initialise(IConfigSource source)
|
||||
{
|
||||
IConfig config = source.Configs["ClientStack.LindenCaps"];
|
||||
|
||||
if (null == config)
|
||||
return;
|
||||
|
||||
if (config.GetString("Cap_EnvironmentSettings", String.Empty) != "localhost")
|
||||
{
|
||||
m_log.InfoFormat("[{0}]: Module is disabled.", Name);
|
||||
return;
|
||||
}
|
||||
|
||||
Enabled = true;
|
||||
|
||||
m_log.InfoFormat("[{0}]: Module is enabled.", Name);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "EnvironmentModule"; }
|
||||
}
|
||||
|
||||
public Type ReplaceableInterface
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
{
|
||||
if (!Enabled)
|
||||
return;
|
||||
|
||||
scene.RegisterModuleInterface<IEnvironmentModule>(this);
|
||||
m_scene = scene;
|
||||
regionID = scene.RegionInfo.RegionID;
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
if (!Enabled)
|
||||
return;
|
||||
|
||||
setResponse = new LLSDEnvironmentSetResponse();
|
||||
scene.EventManager.OnRegisterCaps += OnRegisterCaps;
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
if (Enabled)
|
||||
return;
|
||||
|
||||
scene.EventManager.OnRegisterCaps -= OnRegisterCaps;
|
||||
m_scene = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IEnvironmentModule
|
||||
public void ResetEnvironmentSettings(UUID regionUUID)
|
||||
{
|
||||
if (!Enabled)
|
||||
return;
|
||||
|
||||
m_scene.SimulationDataService.RemoveRegionEnvironmentSettings(regionUUID);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
private void OnRegisterCaps(UUID agentID, Caps caps)
|
||||
{
|
||||
// m_log.DebugFormat("[{0}]: Register capability for agentID {1} in region {2}",
|
||||
// Name, agentID, caps.RegionName);
|
||||
|
||||
string capsPath = capsBase + UUID.Random();
|
||||
|
||||
// Get handler
|
||||
caps.RegisterHandler(
|
||||
capsName,
|
||||
new RestStreamHandler(
|
||||
"GET",
|
||||
capsPath,
|
||||
(request, path, param, httpRequest, httpResponse)
|
||||
=> GetEnvironmentSettings(request, path, param, agentID, caps),
|
||||
capsName,
|
||||
agentID.ToString()));
|
||||
|
||||
// Set handler
|
||||
caps.HttpListener.AddStreamHandler(
|
||||
new RestStreamHandler(
|
||||
"POST",
|
||||
capsPath,
|
||||
(request, path, param, httpRequest, httpResponse)
|
||||
=> SetEnvironmentSettings(request, path, param, agentID, caps),
|
||||
capsName,
|
||||
agentID.ToString()));
|
||||
}
|
||||
#endregion
|
||||
|
||||
private string GetEnvironmentSettings(string request, string path, string param,
|
||||
UUID agentID, Caps caps)
|
||||
{
|
||||
// m_log.DebugFormat("[{0}]: Environment GET handle for agentID {1} in region {2}",
|
||||
// Name, agentID, caps.RegionName);
|
||||
|
||||
string env = String.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
env = m_scene.SimulationDataService.LoadRegionEnvironmentSettings(regionID);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[{0}]: Unable to load environment settings for region {1}, Exception: {2} - {3}",
|
||||
Name, caps.RegionName, e.Message, e.StackTrace);
|
||||
}
|
||||
|
||||
if (String.IsNullOrEmpty(env))
|
||||
env = EnvironmentSettings.EmptySettings(UUID.Zero, regionID);
|
||||
|
||||
return env;
|
||||
}
|
||||
|
||||
private string SetEnvironmentSettings(string request, string path, string param,
|
||||
UUID agentID, Caps caps)
|
||||
{
|
||||
|
||||
// m_log.DebugFormat("[{0}]: Environment SET handle from agentID {1} in region {2}",
|
||||
// Name, agentID, caps.RegionName);
|
||||
|
||||
setResponse.regionID = regionID;
|
||||
setResponse.success = false;
|
||||
|
||||
if (!m_scene.Permissions.CanIssueEstateCommand(agentID, false))
|
||||
{
|
||||
setResponse.fail_reason = "Insufficient estate permissions, settings has not been saved.";
|
||||
return LLSDHelpers.SerialiseLLSDReply(setResponse);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
m_scene.SimulationDataService.StoreRegionEnvironmentSettings(regionID, request);
|
||||
setResponse.success = true;
|
||||
|
||||
m_log.InfoFormat("[{0}]: New Environment settings has been saved from agentID {1} in region {2}",
|
||||
Name, agentID, caps.RegionName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[{0}]: Environment settings has not been saved for region {1}, Exception: {2} - {3}",
|
||||
Name, caps.RegionName, e.Message, e.StackTrace);
|
||||
|
||||
setResponse.success = false;
|
||||
setResponse.fail_reason = String.Format("Environment Set for region {0} has failed, settings has not been saved.", caps.RegionName);
|
||||
}
|
||||
|
||||
return LLSDHelpers.SerialiseLLSDReply(setResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,297 +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 System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using Mono.Addins;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.World.LightShare
|
||||
{
|
||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LightShareModule")]
|
||||
public class LightShareModule : INonSharedRegionModule, ILightShareModule, ICommandableModule
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private readonly Commander m_commander = new Commander("windlight");
|
||||
private Scene m_scene;
|
||||
private static bool m_enableWindlight;
|
||||
|
||||
#region ICommandableModule Members
|
||||
|
||||
public ICommander CommandInterface
|
||||
{
|
||||
get { return m_commander; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region INonSharedRegionModule Members
|
||||
|
||||
public void Initialise(IConfigSource config)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_enableWindlight = config.Configs["LightShare"].GetBoolean("enable_windlight", false);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
m_log.Debug("[WINDLIGHT]: ini failure for enable_windlight - using default");
|
||||
}
|
||||
|
||||
m_log.DebugFormat("[WINDLIGHT]: windlight module {0}", (m_enableWindlight ? "enabled" : "disabled"));
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
{
|
||||
if (!m_enableWindlight)
|
||||
return;
|
||||
|
||||
m_scene = scene;
|
||||
m_scene.RegisterModuleInterface<ILightShareModule>(this);
|
||||
m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
|
||||
|
||||
m_scene.EventManager.OnMakeRootAgent += EventManager_OnMakeRootAgent;
|
||||
m_scene.EventManager.OnSaveNewWindlightProfile += EventManager_OnSaveNewWindlightProfile;
|
||||
m_scene.EventManager.OnSendNewWindlightProfileTargeted += EventManager_OnSendNewWindlightProfileTargeted;
|
||||
m_scene.LoadWindlightProfile();
|
||||
|
||||
InstallCommands();
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
if (!m_enableWindlight)
|
||||
return;
|
||||
|
||||
m_scene.EventManager.OnPluginConsole -= EventManager_OnPluginConsole;
|
||||
|
||||
m_scene.EventManager.OnMakeRootAgent -= EventManager_OnMakeRootAgent;
|
||||
m_scene.EventManager.OnSaveNewWindlightProfile -= EventManager_OnSaveNewWindlightProfile;
|
||||
m_scene.EventManager.OnSendNewWindlightProfileTargeted -= EventManager_OnSendNewWindlightProfileTargeted;
|
||||
|
||||
m_scene = null;
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "LightShareModule"; }
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
}
|
||||
|
||||
public Type ReplaceableInterface
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public static bool EnableWindlight
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_enableWindlight;
|
||||
}
|
||||
set
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
#region events
|
||||
|
||||
private List<byte[]> compileWindlightSettings(RegionLightShareData wl)
|
||||
{
|
||||
byte[] mBlock = new Byte[249];
|
||||
int pos = 0;
|
||||
|
||||
wl.waterColor.ToBytes(mBlock, 0); pos += 12;
|
||||
Utils.FloatToBytes(wl.waterFogDensityExponent).CopyTo(mBlock, pos); pos += 4;
|
||||
Utils.FloatToBytes(wl.underwaterFogModifier).CopyTo(mBlock, pos); pos += 4;
|
||||
wl.reflectionWaveletScale.ToBytes(mBlock, pos); pos += 12;
|
||||
Utils.FloatToBytes(wl.fresnelScale).CopyTo(mBlock, pos); pos += 4;
|
||||
Utils.FloatToBytes(wl.fresnelOffset).CopyTo(mBlock, pos); pos += 4;
|
||||
Utils.FloatToBytes(wl.refractScaleAbove).CopyTo(mBlock, pos); pos += 4;
|
||||
Utils.FloatToBytes(wl.refractScaleBelow).CopyTo(mBlock, pos); pos += 4;
|
||||
Utils.FloatToBytes(wl.blurMultiplier).CopyTo(mBlock, pos); pos += 4;
|
||||
wl.bigWaveDirection.ToBytes(mBlock, pos); pos += 8;
|
||||
wl.littleWaveDirection.ToBytes(mBlock, pos); pos += 8;
|
||||
wl.normalMapTexture.ToBytes(mBlock, pos); pos += 16;
|
||||
wl.horizon.ToBytes(mBlock, pos); pos += 16;
|
||||
Utils.FloatToBytes(wl.hazeHorizon).CopyTo(mBlock, pos); pos += 4;
|
||||
wl.blueDensity.ToBytes(mBlock, pos); pos += 16;
|
||||
Utils.FloatToBytes(wl.hazeDensity).CopyTo(mBlock, pos); pos += 4;
|
||||
Utils.FloatToBytes(wl.densityMultiplier).CopyTo(mBlock, pos); pos += 4;
|
||||
Utils.FloatToBytes(wl.distanceMultiplier).CopyTo(mBlock, pos); pos += 4;
|
||||
wl.sunMoonColor.ToBytes(mBlock, pos); pos += 16;
|
||||
Utils.FloatToBytes(wl.sunMoonPosition).CopyTo(mBlock, pos); pos += 4;
|
||||
wl.ambient.ToBytes(mBlock, pos); pos += 16;
|
||||
Utils.FloatToBytes(wl.eastAngle).CopyTo(mBlock, pos); pos += 4;
|
||||
Utils.FloatToBytes(wl.sunGlowFocus).CopyTo(mBlock, pos); pos += 4;
|
||||
Utils.FloatToBytes(wl.sunGlowSize).CopyTo(mBlock, pos); pos += 4;
|
||||
Utils.FloatToBytes(wl.sceneGamma).CopyTo(mBlock, pos); pos += 4;
|
||||
Utils.FloatToBytes(wl.starBrightness).CopyTo(mBlock, pos); pos += 4;
|
||||
wl.cloudColor.ToBytes(mBlock, pos); pos += 16;
|
||||
wl.cloudXYDensity.ToBytes(mBlock, pos); pos += 12;
|
||||
Utils.FloatToBytes(wl.cloudCoverage).CopyTo(mBlock, pos); pos += 4;
|
||||
Utils.FloatToBytes(wl.cloudScale).CopyTo(mBlock, pos); pos += 4;
|
||||
wl.cloudDetailXYDensity.ToBytes(mBlock, pos); pos += 12;
|
||||
Utils.FloatToBytes(wl.cloudScrollX).CopyTo(mBlock, pos); pos += 4;
|
||||
Utils.FloatToBytes(wl.cloudScrollY).CopyTo(mBlock, pos); pos += 4;
|
||||
Utils.UInt16ToBytes(wl.maxAltitude).CopyTo(mBlock, pos); pos += 2;
|
||||
mBlock[pos] = Convert.ToByte(wl.cloudScrollXLock); pos++;
|
||||
mBlock[pos] = Convert.ToByte(wl.cloudScrollYLock); pos++;
|
||||
mBlock[pos] = Convert.ToByte(wl.drawClassicClouds); pos++;
|
||||
List<byte[]> param = new List<byte[]>();
|
||||
param.Add(mBlock);
|
||||
return param;
|
||||
}
|
||||
|
||||
public void SendProfileToClient(IClientAPI client)
|
||||
{
|
||||
SendProfileToClient(client, m_scene.RegionInfo.WindlightSettings);
|
||||
}
|
||||
|
||||
public void SendProfileToClient(IClientAPI client, RegionLightShareData wl)
|
||||
{
|
||||
if (m_enableWindlight)
|
||||
{
|
||||
if (m_scene.RegionInfo.WindlightSettings.valid)
|
||||
{
|
||||
List<byte[]> param = compileWindlightSettings(wl);
|
||||
client.SendGenericMessage("Windlight", UUID.Random(), param);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<byte[]> param = new List<byte[]>();
|
||||
client.SendGenericMessage("WindlightReset", UUID.Random(), param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EventManager_OnMakeRootAgent(ScenePresence presence)
|
||||
{
|
||||
m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client");
|
||||
SendProfileToClient(presence.ControllingClient);
|
||||
}
|
||||
|
||||
private void EventManager_OnSendNewWindlightProfileTargeted(RegionLightShareData wl, UUID pUUID)
|
||||
{
|
||||
IClientAPI client;
|
||||
m_scene.TryGetClient(pUUID, out client);
|
||||
SendProfileToClient(client, wl);
|
||||
}
|
||||
|
||||
private void EventManager_OnSaveNewWindlightProfile()
|
||||
{
|
||||
m_scene.ForEachRootClient(SendProfileToClient);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ICommandableModule Members
|
||||
|
||||
private void InstallCommands()
|
||||
{
|
||||
Command wlload = new Command("load", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleLoad, "Load windlight profile from the database and broadcast");
|
||||
Command wlenable = new Command("enable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleEnable, "Enable the windlight plugin");
|
||||
Command wldisable = new Command("disable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleDisable, "Disable the windlight plugin");
|
||||
|
||||
m_commander.RegisterCommand("load", wlload);
|
||||
m_commander.RegisterCommand("enable", wlenable);
|
||||
m_commander.RegisterCommand("disable", wldisable);
|
||||
|
||||
m_scene.RegisterModuleCommander(m_commander);
|
||||
}
|
||||
|
||||
private void HandleLoad(Object[] args)
|
||||
{
|
||||
if (!m_enableWindlight)
|
||||
{
|
||||
m_log.InfoFormat("[WINDLIGHT]: Cannot load windlight profile, module disabled. Use 'windlight enable' first.");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.InfoFormat("[WINDLIGHT]: Loading Windlight profile from database");
|
||||
m_scene.LoadWindlightProfile();
|
||||
m_log.InfoFormat("[WINDLIGHT]: Load complete");
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleDisable(Object[] args)
|
||||
{
|
||||
m_log.InfoFormat("[WINDLIGHT]: Plugin now disabled");
|
||||
m_enableWindlight = false;
|
||||
}
|
||||
|
||||
private void HandleEnable(Object[] args)
|
||||
{
|
||||
m_log.InfoFormat("[WINDLIGHT]: Plugin now enabled");
|
||||
m_enableWindlight = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes commandline input. Do not call directly.
|
||||
/// </summary>
|
||||
/// <param name="args">Commandline arguments</param>
|
||||
private void EventManager_OnPluginConsole(string[] args)
|
||||
{
|
||||
if (args[0] == "windlight")
|
||||
{
|
||||
if (args.Length == 1)
|
||||
{
|
||||
m_commander.ProcessConsoleCommand("add", new string[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
string[] tmpArgs = new string[args.Length - 2];
|
||||
int i;
|
||||
for (i = 2; i < args.Length; i++)
|
||||
{
|
||||
tmpArgs[i - 2] = args[i];
|
||||
}
|
||||
|
||||
m_commander.ProcessConsoleCommand(args[1], tmpArgs);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +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.
|
||||
*/
|
||||
|
||||
namespace OpenSim.Region.Framework.Interfaces
|
||||
{
|
||||
public interface ILightShareModule
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,58 +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 System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using NUnit.Framework;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Tests.Common;
|
||||
using OpenSim.Tests.Common.Mock;
|
||||
|
||||
namespace OpenSim.Region.Framework.Scenes.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class SceneManagerTests : OpenSimTestCase
|
||||
{
|
||||
[Test]
|
||||
public void TestClose()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
|
||||
SceneHelpers sh = new SceneHelpers();
|
||||
Scene scene = sh.SetupScene();
|
||||
|
||||
sh.SceneManager.Close();
|
||||
Assert.That(scene.ShuttingDown, Is.True);
|
||||
}
|
||||
}
|
||||
}
|
||||
0
OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
Executable file → Normal file
0
OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
Executable file → Normal file
@@ -1,167 +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 copyrightD
|
||||
* 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 System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Region.Physics.BulletSPlugin
|
||||
{
|
||||
|
||||
public sealed class BSConstraint6Dof : BSConstraint
|
||||
{
|
||||
private static string LogHeader = "[BULLETSIM 6DOF CONSTRAINT]";
|
||||
|
||||
public override ConstraintType Type { get { return ConstraintType.D6_CONSTRAINT_TYPE; } }
|
||||
|
||||
// Create a btGeneric6DofConstraint
|
||||
public BSConstraint6Dof(BulletWorld world, BulletBody obj1, BulletBody obj2,
|
||||
Vector3 frame1, Quaternion frame1rot,
|
||||
Vector3 frame2, Quaternion frame2rot,
|
||||
bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
|
||||
: base(world)
|
||||
{
|
||||
m_body1 = obj1;
|
||||
m_body2 = obj2;
|
||||
m_constraint = PhysicsScene.PE.Create6DofConstraint(m_world, m_body1, m_body2,
|
||||
frame1, frame1rot,
|
||||
frame2, frame2rot,
|
||||
useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies);
|
||||
m_enabled = true;
|
||||
world.physicsScene.DetailLog("{0},BS6DofConstraint,createFrame,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}",
|
||||
BSScene.DetailLogZero, world.worldID,
|
||||
obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString);
|
||||
}
|
||||
|
||||
// 6 Dof constraint based on a midpoint between the two constrained bodies
|
||||
public BSConstraint6Dof(BulletWorld world, BulletBody obj1, BulletBody obj2,
|
||||
Vector3 joinPoint,
|
||||
bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
|
||||
: base(world)
|
||||
{
|
||||
m_body1 = obj1;
|
||||
m_body2 = obj2;
|
||||
if (!obj1.HasPhysicalBody || !obj2.HasPhysicalBody)
|
||||
{
|
||||
world.physicsScene.DetailLog("{0},BS6DOFConstraint,badBodyPtr,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}",
|
||||
BSScene.DetailLogZero, world.worldID,
|
||||
obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString);
|
||||
world.physicsScene.Logger.ErrorFormat("{0} Attempt to build 6DOF constraint with missing bodies: wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}",
|
||||
LogHeader, world.worldID, obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString);
|
||||
m_enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_constraint = PhysicsScene.PE.Create6DofConstraintToPoint(m_world, m_body1, m_body2,
|
||||
joinPoint,
|
||||
useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies);
|
||||
PhysicsScene.DetailLog("{0},BS6DofConstraint,createMidPoint,wID={1}, csrt={2}, rID={3}, rBody={4}, cID={5}, cBody={6}",
|
||||
BSScene.DetailLogZero, world.worldID, m_constraint.AddrString,
|
||||
obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString);
|
||||
if (!m_constraint.HasPhysicalConstraint)
|
||||
{
|
||||
world.physicsScene.Logger.ErrorFormat("{0} Failed creation of 6Dof constraint. rootID={1}, childID={2}",
|
||||
LogHeader, obj1.ID, obj2.ID);
|
||||
m_enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A 6 Dof constraint that is fixed in the world and constrained to a on-the-fly created static object
|
||||
public BSConstraint6Dof(BulletWorld world, BulletBody obj1, Vector3 frameInBloc, Quaternion frameInBrot,
|
||||
bool useLinearReferenceFrameB, bool disableCollisionsBetweenLinkedBodies)
|
||||
: base(world)
|
||||
{
|
||||
m_body1 = obj1;
|
||||
m_body2 = obj1; // Look out for confusion down the road
|
||||
m_constraint = PhysicsScene.PE.Create6DofConstraintFixed(m_world, m_body1,
|
||||
frameInBloc, frameInBrot,
|
||||
useLinearReferenceFrameB, disableCollisionsBetweenLinkedBodies);
|
||||
m_enabled = true;
|
||||
world.physicsScene.DetailLog("{0},BS6DofConstraint,createFixed,wID={1},rID={2},rBody={3}",
|
||||
BSScene.DetailLogZero, world.worldID, obj1.ID, obj1.AddrString);
|
||||
}
|
||||
|
||||
public bool SetFrames(Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot)
|
||||
{
|
||||
bool ret = false;
|
||||
if (m_enabled)
|
||||
{
|
||||
PhysicsScene.PE.SetFrames(m_constraint, frameA, frameArot, frameB, frameBrot);
|
||||
ret = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public bool SetCFMAndERP(float cfm, float erp)
|
||||
{
|
||||
bool ret = false;
|
||||
if (m_enabled)
|
||||
{
|
||||
PhysicsScene.PE.SetConstraintParam(m_constraint, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL);
|
||||
PhysicsScene.PE.SetConstraintParam(m_constraint, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL);
|
||||
PhysicsScene.PE.SetConstraintParam(m_constraint, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL);
|
||||
ret = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public bool UseFrameOffset(bool useOffset)
|
||||
{
|
||||
bool ret = false;
|
||||
float onOff = useOffset ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse;
|
||||
if (m_enabled)
|
||||
ret = PhysicsScene.PE.UseFrameOffset(m_constraint, onOff);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public bool TranslationalLimitMotor(bool enable, float targetVelocity, float maxMotorForce)
|
||||
{
|
||||
bool ret = false;
|
||||
float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse;
|
||||
if (m_enabled)
|
||||
{
|
||||
ret = PhysicsScene.PE.TranslationalLimitMotor(m_constraint, onOff, targetVelocity, maxMotorForce);
|
||||
m_world.physicsScene.DetailLog("{0},BS6DOFConstraint,TransLimitMotor,enable={1},vel={2},maxForce={3}",
|
||||
BSScene.DetailLogZero, enable, targetVelocity, maxMotorForce);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public bool SetBreakingImpulseThreshold(float threshold)
|
||||
{
|
||||
bool ret = false;
|
||||
if (m_enabled)
|
||||
ret = PhysicsScene.PE.SetBreakingImpulseThreshold(m_constraint, threshold);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
0
OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
Executable file → Normal file
0
OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
Executable file → Normal file
0
OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
Executable file → Normal file
0
OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
Executable file → Normal file
0
OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
Executable file → Normal file
0
OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
Executable file → Normal file
0
OpenSim/Region/Physics/BulletSPlugin/BSMaterials.cs
Executable file → Normal file
0
OpenSim/Region/Physics/BulletSPlugin/BSMaterials.cs
Executable file → Normal file
0
OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
Executable file → Normal file
0
OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
Executable file → Normal file
0
OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
Executable file → Normal file
0
OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
Executable file → Normal file
0
OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
Executable file → Normal file
0
OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
Executable file → Normal file
0
OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
Executable file → Normal file
0
OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
Executable file → Normal file
0
OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs
Executable file → Normal file
0
OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs
Executable file → Normal file
@@ -1,44 +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 System.Runtime.Serialization;
|
||||
|
||||
namespace OpenSim.Region.ScriptEngine.Shared
|
||||
{
|
||||
[Serializable]
|
||||
public class ScriptException : Exception
|
||||
{
|
||||
public ScriptException() : base() {}
|
||||
|
||||
public ScriptException(string message) : base(message) {}
|
||||
|
||||
public ScriptException(string message, Exception innerException) : base(message, innerException) {}
|
||||
|
||||
public ScriptException(SerializationInfo info, StreamingContext context) :base(info, context) {}
|
||||
}
|
||||
}
|
||||
@@ -1,110 +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 System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using Nini.Config;
|
||||
using NUnit.Framework;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Server.Handlers.Asset;
|
||||
using OpenSim.Services.AssetService;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Tests.Common;
|
||||
using OpenSim.Tests.Common.Mock;
|
||||
|
||||
namespace OpenSim.Server.Handlers.Asset.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class AssetServerPostHandlerTests : OpenSimTestCase
|
||||
{
|
||||
[Test]
|
||||
public void TestGoodAssetStoreRequest()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
|
||||
UUID assetId = TestHelpers.ParseTail(0x1);
|
||||
|
||||
IConfigSource config = new IniConfigSource();
|
||||
config.AddConfig("AssetService");
|
||||
config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
|
||||
|
||||
AssetService assetService = new AssetService(config);
|
||||
|
||||
AssetServerPostHandler asph = new AssetServerPostHandler(assetService);
|
||||
|
||||
AssetBase asset = AssetHelpers.CreateNotecardAsset(assetId, "Hello World");
|
||||
|
||||
MemoryStream buffer = new MemoryStream();
|
||||
|
||||
XmlWriterSettings settings = new XmlWriterSettings();
|
||||
settings.Encoding = Encoding.UTF8;
|
||||
|
||||
using (XmlWriter writer = XmlWriter.Create(buffer, settings))
|
||||
{
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(AssetBase));
|
||||
serializer.Serialize(writer, asset);
|
||||
writer.Flush();
|
||||
}
|
||||
|
||||
buffer.Position = 0;
|
||||
asph.Handle(null, buffer, null, null);
|
||||
|
||||
AssetBase retrievedAsset = assetService.Get(assetId.ToString());
|
||||
|
||||
Assert.That(retrievedAsset, Is.Not.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBadXmlAssetStoreRequest()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
|
||||
IConfigSource config = new IniConfigSource();
|
||||
config.AddConfig("AssetService");
|
||||
config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
|
||||
|
||||
AssetService assetService = new AssetService(config);
|
||||
|
||||
AssetServerPostHandler asph = new AssetServerPostHandler(assetService);
|
||||
|
||||
MemoryStream buffer = new MemoryStream();
|
||||
byte[] badData = new byte[] { 0x48, 0x65, 0x6c, 0x6c, 0x6f };
|
||||
buffer.Write(badData, 0, badData.Length);
|
||||
buffer.Position = 0;
|
||||
|
||||
TestOSHttpResponse response = new TestOSHttpResponse();
|
||||
asph.Handle(null, buffer, null, response);
|
||||
|
||||
Assert.That(response.StatusCode, Is.EqualTo((int)HttpStatusCode.BadRequest));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,177 +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 Nini.Config;
|
||||
using NUnit.Framework;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Tests.Common;
|
||||
|
||||
namespace OpenSim.Services.InventoryService.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests for the XInventoryService
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// TODO: Fill out more tests.
|
||||
/// </remarks>
|
||||
[TestFixture]
|
||||
public class XInventoryServiceTests : OpenSimTestCase
|
||||
{
|
||||
private IInventoryService CreateXInventoryService()
|
||||
{
|
||||
IConfigSource config = new IniConfigSource();
|
||||
config.AddConfig("InventoryService");
|
||||
config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
|
||||
|
||||
return ServerUtils.LoadPlugin<IInventoryService>(
|
||||
"OpenSim.Services.InventoryService.dll:XInventoryService", new Object[] { config });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests add item operation.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// TODO: Test all operations.
|
||||
/// </remarks>
|
||||
[Test]
|
||||
public void TestAddItem()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
|
||||
string creatorId = TestHelpers.ParseTail(0x1).ToString();
|
||||
UUID ownerId = TestHelpers.ParseTail(0x2);
|
||||
UUID itemId = TestHelpers.ParseTail(0x10);
|
||||
UUID assetId = TestHelpers.ParseTail(0x20);
|
||||
UUID folderId = TestHelpers.ParseTail(0x30);
|
||||
int invType = (int)InventoryType.Animation;
|
||||
int assetType = (int)AssetType.Animation;
|
||||
string itemName = "item1";
|
||||
|
||||
IInventoryService xis = CreateXInventoryService();
|
||||
|
||||
InventoryItemBase itemToStore
|
||||
= new InventoryItemBase(itemId, ownerId)
|
||||
{
|
||||
CreatorIdentification = creatorId.ToString(),
|
||||
AssetID = assetId,
|
||||
Name = itemName,
|
||||
Folder = folderId,
|
||||
InvType = invType,
|
||||
AssetType = assetType
|
||||
};
|
||||
|
||||
Assert.That(xis.AddItem(itemToStore), Is.True);
|
||||
|
||||
InventoryItemBase itemRetrieved = new InventoryItemBase(itemId);
|
||||
itemRetrieved = xis.GetItem(itemRetrieved);
|
||||
|
||||
Assert.That(itemRetrieved, Is.Not.Null);
|
||||
Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId));
|
||||
Assert.That(itemRetrieved.Owner, Is.EqualTo(ownerId));
|
||||
Assert.That(itemRetrieved.AssetID, Is.EqualTo(assetId));
|
||||
Assert.That(itemRetrieved.Folder, Is.EqualTo(folderId));
|
||||
Assert.That(itemRetrieved.InvType, Is.EqualTo(invType));
|
||||
Assert.That(itemRetrieved.AssetType, Is.EqualTo(assetType));
|
||||
Assert.That(itemRetrieved.Name, Is.EqualTo(itemName));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUpdateItem()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
string creatorId = TestHelpers.ParseTail(0x1).ToString();
|
||||
UUID ownerId = TestHelpers.ParseTail(0x2);
|
||||
UUID itemId = TestHelpers.ParseTail(0x10);
|
||||
UUID assetId = TestHelpers.ParseTail(0x20);
|
||||
UUID folderId = TestHelpers.ParseTail(0x30);
|
||||
int invType = (int)InventoryType.Animation;
|
||||
int assetType = (int)AssetType.Animation;
|
||||
string itemName = "item1";
|
||||
string itemName2 = "item2";
|
||||
|
||||
IInventoryService xis = CreateXInventoryService();
|
||||
|
||||
InventoryItemBase itemToStore
|
||||
= new InventoryItemBase(itemId, ownerId)
|
||||
{
|
||||
CreatorIdentification = creatorId.ToString(),
|
||||
AssetID = assetId,
|
||||
Name = itemName,
|
||||
Folder = folderId,
|
||||
InvType = invType,
|
||||
AssetType = assetType
|
||||
};
|
||||
|
||||
Assert.That(xis.AddItem(itemToStore), Is.True);
|
||||
|
||||
// Normal update
|
||||
itemToStore.Name = itemName2;
|
||||
|
||||
Assert.That(xis.UpdateItem(itemToStore), Is.True);
|
||||
|
||||
InventoryItemBase itemRetrieved = new InventoryItemBase(itemId);
|
||||
itemRetrieved = xis.GetItem(itemRetrieved);
|
||||
|
||||
Assert.That(itemRetrieved, Is.Not.Null);
|
||||
Assert.That(itemRetrieved.Name, Is.EqualTo(itemName2));
|
||||
|
||||
// Attempt to update properties that should never change
|
||||
string creatorId2 = TestHelpers.ParseTail(0x7).ToString();
|
||||
UUID ownerId2 = TestHelpers.ParseTail(0x8);
|
||||
UUID folderId2 = TestHelpers.ParseTail(0x70);
|
||||
int invType2 = (int)InventoryType.CallingCard;
|
||||
int assetType2 = (int)AssetType.CallingCard;
|
||||
string itemName3 = "item3";
|
||||
|
||||
itemToStore.CreatorIdentification = creatorId2.ToString();
|
||||
itemToStore.Owner = ownerId2;
|
||||
itemToStore.Folder = folderId2;
|
||||
itemToStore.InvType = invType2;
|
||||
itemToStore.AssetType = assetType2;
|
||||
itemToStore.Name = itemName3;
|
||||
|
||||
Assert.That(xis.UpdateItem(itemToStore), Is.True);
|
||||
|
||||
itemRetrieved = xis.GetItem(itemRetrieved);
|
||||
|
||||
Assert.That(itemRetrieved, Is.Not.Null);
|
||||
Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId));
|
||||
Assert.That(itemRetrieved.Owner, Is.EqualTo(ownerId));
|
||||
Assert.That(itemRetrieved.AssetID, Is.EqualTo(assetId));
|
||||
Assert.That(itemRetrieved.Folder, Is.EqualTo(folderId));
|
||||
Assert.That(itemRetrieved.InvType, Is.EqualTo(invType));
|
||||
Assert.That(itemRetrieved.AssetType, Is.EqualTo(assetType));
|
||||
Assert.That(itemRetrieved.Name, Is.EqualTo(itemName3));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://aurora-sim.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 Aurora-Sim 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.
|
||||
*/
|
||||
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
|
||||
libsqlite version: 3.7.5
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user