Merge branch 'master' into careminster

avinationmerge
Melanie 2009-12-12 04:14:47 +00:00
commit 1382dc976c
17 changed files with 93 additions and 1341 deletions

View File

@ -1,87 +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;
namespace OpenSim.Framework
{
/// <summary>
/// AssetConfig -- For Asset Server Configuration
/// </summary>
public class AssetConfig:ConfigBase
{
public string DatabaseConnect = String.Empty;
public string DatabaseProvider = String.Empty;
public uint HttpPort = ConfigSettings.DefaultAssetServerHttpPort;
public string AssetSetsLocation = string.Empty;
public AssetConfig(string description, string filename)
{
m_configMember =
new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, true);
m_configMember.performConfigurationRetrieve();
}
public void loadConfigurationOptions()
{
m_configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"DLL for database provider", "OpenSim.Data.MySQL.dll", false);
m_configMember.addConfigurationOption("database_connect", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Database connection string", "", false);
m_configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
"Http Listener port", ConfigSettings.DefaultAssetServerHttpPort.ToString(), false);
m_configMember.addConfigurationOption("assetset_location", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Location of 'AssetSets.xml'",
string.Format(".{0}assets{0}AssetSets.xml", Path.DirectorySeparatorChar), false);
}
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
{
switch (configuration_key)
{
case "database_provider":
DatabaseProvider = (string) configuration_result;
break;
case "database_connect":
DatabaseConnect = (string) configuration_result;
break;
case "assetset_location":
AssetSetsLocation = (string) configuration_result;
break;
case "http_port":
HttpPort = (uint) configuration_result;
break;
}
return true;
}
}
}

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 OpenMetaverse;
namespace OpenSim.Framework
{
public struct AssetRequest
{
public UUID AssetID;
public bool IsTexture;
}
}

View File

@ -1,48 +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 OpenMetaverse;
namespace OpenSim.Framework
{
public class AssetStorage
{
public byte[] Data;
public string Name;
public sbyte Type;
public UUID UUID;
public AssetStorage()
{
}
public AssetStorage(UUID assetUUID)
{
UUID = assetUUID;
}
}
}

View File

@ -139,9 +139,16 @@ namespace OpenSim.Framework.Communications.Cache
else
{
UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(fname, lname);
if (userProfile != null)
{
if ((userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") && m_commsManager.NetworkServersInfo != null)
userProfile.UserAssetURI = m_commsManager.NetworkServersInfo.AssetURL;
if ((userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") && m_commsManager.NetworkServersInfo != null)
userProfile.UserInventoryURI = m_commsManager.NetworkServersInfo.InventoryURL;
return AddToCaches(userProfile);
}
else
return null;
}
@ -169,7 +176,14 @@ namespace OpenSim.Framework.Communications.Cache
{
UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID);
if (userProfile != null)
{
if ((userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") && m_commsManager.NetworkServersInfo != null)
userProfile.UserAssetURI = m_commsManager.NetworkServersInfo.AssetURL;
if ((userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") && m_commsManager.NetworkServersInfo != null)
userProfile.UserInventoryURI = m_commsManager.NetworkServersInfo.InventoryURL;
return AddToCaches(userProfile);
}
else
return null;
}

View File

@ -136,7 +136,7 @@ namespace OpenSim.Framework.Communications.Clients
}
Hashtable responseData = (Hashtable)UserResp.Value;
if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE")
if (responseData != null && responseData.ContainsKey("auth_session") && responseData["auth_session"] != null && responseData["auth_session"].ToString() == "TRUE")
{
//System.Console.WriteLine("[Authorization]: userserver reported authorized session for user " + userID);
return true;

View File

@ -1,114 +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 OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenSim.Framework
{
public delegate void AssetRequestCallback(UUID assetId, AssetBase asset);
/// <summary>
/// Interface to the local asset cache. This is the mechanism through which assets can be added and requested.
/// </summary>
public interface IAssetCache : IPlugin
{
/// <value>
/// The 'server' from which assets can be requested and to which assets are persisted.
/// </value>
void Initialise(ConfigSettings cs);
/// <summary>
/// Report statistical data to the log.
/// </summary>
void ShowState();
/// <summary>
/// Clear the asset cache.
/// </summary>
void Clear();
/// <summary>
/// Get an asset only if it's already in the cache.
/// </summary>
/// <param name="assetId"></param>
/// <param name="asset"></param>
/// <returns>true if the asset was in the cache, false if it was not</returns>
bool TryGetCachedAsset(UUID assetID, out AssetBase asset);
/// <summary>
/// Asynchronously retrieve an asset.
/// </summary>
/// <param name="assetId"></param>
/// <param name="callback">
/// <param name="isTexture"></param>
/// A callback invoked when the asset has either been found or not found.
/// If the asset was found this is called with the asset UUID and the asset data
/// If the asset was not found this is still called with the asset UUID but with a null asset data reference</param>
void GetAsset(UUID assetID, AssetRequestCallback callback, bool isTexture);
/// <summary>
/// Synchronously retreive an asset. If the asset isn't in the cache, a request will be made to the persistent store to
/// load it into the cache.
/// </summary>
///
/// XXX We'll keep polling the cache until we get the asset or we exceed
/// the allowed number of polls. This isn't a very good way of doing things since a single thread
/// is processing inbound packets, so if the asset server is slow, we could block this for up to
/// the timeout period. Whereever possible we want to use the asynchronous callback GetAsset()
///
/// <param name="assetID"></param>
/// <param name="isTexture"></param>
/// <returns>null if the asset could not be retrieved</returns>
AssetBase GetAsset(UUID assetID, bool isTexture);
/// <summary>
/// Add an asset to both the persistent store and the cache.
/// </summary>
/// <param name="asset"></param>
void AddAsset(AssetBase asset);
/// <summary>
/// Expire an asset from the cache
/// </summary>
/// Allows you to clear a specific asset by uuid out
/// of the asset cache. This is needed because the osdynamic
/// texture code grows the asset cache without bounds. The
/// real solution here is a much better cache archicture, but
/// this is a stop gap measure until we have such a thing.
void ExpireAsset(UUID assetID);
/// <summary>
/// Handle an asset request from the client. The result will be sent back asynchronously.
/// </summary>
/// <param name="userInfo"></param>
/// <param name="transferRequest"></param>
void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest);
}
}

View File

@ -1,113 +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>
/// Defines and handles inventory grid server configuration
/// </summary>
public class InventoryConfig:ConfigBase
{
public string DatabaseConnect = String.Empty;
public string DatabaseProvider = String.Empty;
public string DefaultStartupMsg = String.Empty;
public uint HttpPort = ConfigSettings.DefaultInventoryServerHttpPort;
public string InventoryServerURL = String.Empty;
public string UserServerURL = String.Empty;
public string AssetServerURL = String.Empty;
public bool SessionLookUp = true;
public bool RegionAccessToAgentsInventory = true;
public InventoryConfig(string description, string filename)
{
m_configMember =
new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, true);
m_configMember.performConfigurationRetrieve();
}
public void loadConfigurationOptions()
{
m_configMember.addConfigurationOption("default_inventory_server",
ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
"Default Inventory Server URI (this server's external name)",
"http://127.0.0.1:8004", false);
m_configMember.addConfigurationOption("default_user_server",
ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
"Default User Server URI",
"http://127.0.0.1:8002", false);
m_configMember.addConfigurationOption("default_asset_server",
ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
"Default Asset Server URI",
"http://127.0.0.1:8003", false);
m_configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"DLL for database provider", "OpenSim.Data.MySQL.dll", false);
m_configMember.addConfigurationOption("database_connect", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Database Connect String", "", false);
m_configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
"Http Listener port", ConfigSettings.DefaultInventoryServerHttpPort.ToString(), false);
m_configMember.addConfigurationOption("session_lookup", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN,
"Enable session lookup security", "False", false);
m_configMember.addConfigurationOption("region_access", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN,
"Allow direct region access to users inventories? (Keep True if you don't know what this is about)", "True", false);
}
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
{
switch (configuration_key)
{
case "default_inventory_server":
InventoryServerURL = (string)configuration_result;
break;
case "default_user_server":
UserServerURL = (string) configuration_result;
break;
case "default_asset_server":
AssetServerURL = (string)configuration_result;
break;
case "database_provider":
DatabaseProvider = (string) configuration_result;
break;
case "database_connect":
DatabaseConnect = (string) configuration_result;
break;
case "http_port":
HttpPort = (uint) configuration_result;
break;
case "session_lookup":
SessionLookUp = (bool)configuration_result;
break;
case "region_access":
RegionAccessToAgentsInventory = (bool)configuration_result;
break;
}
return true;
}
}
}

View File

@ -1,42 +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.Framework
{
public class NeighbourInfo
{
public ulong regionhandle;
public uint RegionLocX;
public uint RegionLocY;
public string sim_ip;
public uint sim_port;
public NeighbourInfo()
{
}
}
}

View File

@ -1,211 +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.Threading;
namespace OpenSim.Framework
{
/// <summary>
/// Provides helper methods for parallelizing loops
/// </summary>
public static class Parallel
{
public static readonly int ProcessorCount = System.Environment.ProcessorCount;
/// <summary>
/// Executes a for loop in which iterations may run in parallel
/// </summary>
/// <param name="fromInclusive">The loop will be started at this index</param>
/// <param name="toExclusive">The loop will be terminated before this index is reached</param>
/// <param name="body">Method body to run for each iteration of the loop</param>
public static void For(int fromInclusive, int toExclusive, Action<int> body)
{
For(ProcessorCount, fromInclusive, toExclusive, body);
}
/// <summary>
/// Executes a for loop in which iterations may run in parallel
/// </summary>
/// <param name="threadCount">The number of concurrent execution threads to run</param>
/// <param name="fromInclusive">The loop will be started at this index</param>
/// <param name="toExclusive">The loop will be terminated before this index is reached</param>
/// <param name="body">Method body to run for each iteration of the loop</param>
public static void For(int threadCount, int fromInclusive, int toExclusive, Action<int> body)
{
int counter = threadCount;
AutoResetEvent threadFinishEvent = new AutoResetEvent(false);
Exception exception = null;
--fromInclusive;
for (int i = 0; i < threadCount; i++)
{
Util.FireAndForget(
delegate(object o)
{
// int threadIndex = (int)o;
while (exception == null)
{
int currentIndex = Interlocked.Increment(ref fromInclusive);
if (currentIndex >= toExclusive)
break;
try { body(currentIndex); }
catch (Exception ex) { exception = ex; break; }
}
if (Interlocked.Decrement(ref counter) == 0)
threadFinishEvent.Set();
}, i
);
}
threadFinishEvent.WaitOne();
threadFinishEvent.Close();
if (exception != null)
throw new Exception(exception.Message, exception);
}
/// <summary>
/// Executes a foreach loop in which iterations may run in parallel
/// </summary>
/// <typeparam name="T">Object type that the collection wraps</typeparam>
/// <param name="enumerable">An enumerable collection to iterate over</param>
/// <param name="body">Method body to run for each object in the collection</param>
public static void ForEach<T>(IEnumerable<T> enumerable, Action<T> body)
{
ForEach<T>(ProcessorCount, enumerable, body);
}
/// <summary>
/// Executes a foreach loop in which iterations may run in parallel
/// </summary>
/// <typeparam name="T">Object type that the collection wraps</typeparam>
/// <param name="threadCount">The number of concurrent execution threads to run</param>
/// <param name="enumerable">An enumerable collection to iterate over</param>
/// <param name="body">Method body to run for each object in the collection</param>
public static void ForEach<T>(int threadCount, IEnumerable<T> enumerable, Action<T> body)
{
int counter = threadCount;
AutoResetEvent threadFinishEvent = new AutoResetEvent(false);
IEnumerator<T> enumerator = enumerable.GetEnumerator();
object syncRoot = new object();
Exception exception = null;
for (int i = 0; i < threadCount; i++)
{
Util.FireAndForget(
delegate(object o)
{
// int threadIndex = (int)o;
while (exception == null)
{
T entry;
lock (syncRoot)
{
if (!enumerator.MoveNext())
break;
entry = (T)enumerator.Current; // Explicit typecast for Mono's sake
}
try { body(entry); }
catch (Exception ex) { exception = ex; break; }
}
if (Interlocked.Decrement(ref counter) == 0)
threadFinishEvent.Set();
}, i
);
}
threadFinishEvent.WaitOne();
threadFinishEvent.Close();
if (exception != null)
throw new Exception(exception.Message, exception);
}
/// <summary>
/// Executes a series of tasks in parallel
/// </summary>
/// <param name="actions">A series of method bodies to execute</param>
public static void Invoke(params Action[] actions)
{
Invoke(ProcessorCount, actions);
}
/// <summary>
/// Executes a series of tasks in parallel
/// </summary>
/// <param name="threadCount">The number of concurrent execution threads to run</param>
/// <param name="actions">A series of method bodies to execute</param>
public static void Invoke(int threadCount, params Action[] actions)
{
int counter = threadCount;
AutoResetEvent threadFinishEvent = new AutoResetEvent(false);
int index = -1;
Exception exception = null;
for (int i = 0; i < threadCount; i++)
{
Util.FireAndForget(
delegate(object o)
{
// int threadIndex = (int)o;
while (exception == null)
{
int currentIndex = Interlocked.Increment(ref index);
if (currentIndex >= actions.Length)
break;
try { actions[currentIndex](); }
catch (Exception ex) { exception = ex; break; }
}
if (Interlocked.Decrement(ref counter) == 0)
threadFinishEvent.Set();
}, i
);
}
threadFinishEvent.WaitOne();
threadFinishEvent.Close();
if (exception != null)
throw new Exception(exception.Message, exception);
}
}
}

View File

@ -1,68 +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.Net;
namespace OpenSim.Framework
{
public sealed class ProxyCodec
{
public static void EncodeProxyMessage(byte[] bytes, ref int numBytes, EndPoint trueEP)
{
if (numBytes > 4090) // max UPD size = 4096
{
throw new Exception("ERROR: No space to encode the proxy EP");
}
ushort port = (ushort) ((IPEndPoint) trueEP).Port;
bytes[numBytes++] = (byte) (port % 256);
bytes[numBytes++] = (byte) (port / 256);
foreach (byte b in ((IPEndPoint) trueEP).Address.GetAddressBytes())
{
bytes[numBytes++] = b;
}
}
public static IPEndPoint DecodeProxyMessage(byte[] bytes, ref int numBytes)
{
// IPv4 Only
byte[] addr = new byte[4];
addr[3] = bytes[--numBytes];
addr[2] = bytes[--numBytes];
addr[1] = bytes[--numBytes];
addr[0] = bytes[--numBytes];
ushort port = (ushort) (bytes[--numBytes] * 256);
port += (ushort) bytes[--numBytes];
return new IPEndPoint(new IPAddress(addr), (int) port);
}
}
}

View File

@ -1,68 +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
{
[Serializable]
public class RegionUpData
{
private string m_ipaddr = "";
private int m_port = 0;
private uint m_X = 0;
private uint m_Y = 0;
public RegionUpData(uint X, uint Y, string ipaddr, int port)
{
m_X = X;
m_Y = Y;
m_ipaddr = ipaddr;
m_port = port;
}
public uint X
{
get { return m_X; }
}
public uint Y
{
get { return m_Y; }
}
public string IPADDR
{
get { return m_ipaddr; }
}
public int PORT
{
get { return m_port; }
}
}
}

View File

@ -1,134 +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.Security.Cryptography;
using System.Text;
namespace OpenSim.Framework
{
/// <summary>
/// NEEDS AUDIT.
/// </summary>
/// <remarks>
/// Suggested implementation
/// <para>Store two digests for each foreign host. A local copy of the local hash using the local challenge (when issued), and a local copy of the remote hash using the remote challenge.</para>
/// <para>When sending data to the foreign host - run 'Sign' on the data and affix the returned byte[] to the message.</para>
/// <para>When receiving data from the foreign host - run 'Authenticate' against the data and the attached byte[].</para>
/// <para>Both hosts should be performing these operations for this to be effective.</para>
/// </remarks>
internal class RemoteDigest
{
private byte[] currentHash;
private byte[] secret;
private SHA512Managed SHA512;
/// <summary>
/// Initialises a new RemoteDigest authentication mechanism
/// </summary>
/// <remarks>Needs an audit by a cryptographic professional - was not "roll your own"'d by choice but rather a serious lack of decent authentication mechanisms in .NET remoting</remarks>
/// <param name="sharedSecret">The shared secret between systems (for inter-sim, this is provided in encrypted form during connection, for grid this is input manually in setup)</param>
/// <param name="salt">Binary salt - some common value - to be decided what</param>
/// <param name="challenge">The challenge key provided by the third party</param>
public RemoteDigest(string sharedSecret, byte[] salt, string challenge)
{
SHA512 = new SHA512Managed();
Rfc2898DeriveBytes RFC2898 = new Rfc2898DeriveBytes(sharedSecret, salt);
secret = RFC2898.GetBytes(512);
ASCIIEncoding ASCII = new ASCIIEncoding();
currentHash = SHA512.ComputeHash(AppendArrays(secret, ASCII.GetBytes(challenge)));
}
/// <summary>
/// Authenticates a piece of incoming data against the local digest. Upon successful authentication, digest string is incremented.
/// </summary>
/// <param name="data">The incoming data</param>
/// <param name="digest">The remote digest</param>
/// <returns></returns>
public bool Authenticate(byte[] data, byte[] digest)
{
byte[] newHash = SHA512.ComputeHash(AppendArrays(AppendArrays(currentHash, secret), data));
if (digest == newHash)
{
currentHash = newHash;
return true;
}
else
{
throw new Exception("Hash comparison failed. Key resync required.");
}
}
/// <summary>
/// Signs a new bit of data with the current hash. Returns a byte array which should be affixed to the message.
/// Signing a piece of data will automatically increment the hash - if you sign data and do not send it, the
/// hashes will get out of sync and throw an exception when validation is attempted.
/// </summary>
/// <param name="data">The outgoing data</param>
/// <returns>The local digest</returns>
public byte[] Sign(byte[] data)
{
currentHash = SHA512.ComputeHash(AppendArrays(AppendArrays(currentHash, secret), data));
return currentHash;
}
/// <summary>
/// Generates a new challenge string to be issued to a foreign host. Challenges are 1024-bit (effective strength of less than 512-bits) messages generated using the Crytographic Random Number Generator.
/// </summary>
/// <returns>A 128-character hexadecimal string containing the challenge.</returns>
public static string GenerateChallenge()
{
RNGCryptoServiceProvider RNG = new RNGCryptoServiceProvider();
byte[] bytes = new byte[64];
RNG.GetBytes(bytes);
StringBuilder sb = new StringBuilder(bytes.Length * 2);
foreach (byte b in bytes)
{
sb.AppendFormat("{0:x2}", b);
}
return sb.ToString();
}
/// <summary>
/// Helper function, merges two byte arrays
/// </summary>
/// <remarks>Sourced from MSDN Forum</remarks>
/// <param name="a">A</param>
/// <param name="b">B</param>
/// <returns>C</returns>
private static byte[] AppendArrays(byte[] a, byte[] b)
{
byte[] c = new byte[a.Length + b.Length];
Buffer.BlockCopy(a, 0, c, 0, a.Length);
Buffer.BlockCopy(b, 0, c, a.Length, b.Length);
return c;
}
}
}

View File

@ -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.Collections;
using System.Xml.Serialization;
namespace OpenSim.Framework
{
/*
* .Net has some issues, serializing a dictionary, so we cannot reuse the InventoryFolder
* class defined in Communications.Framework.Communications.Caches. So we serialize/deserialize
* into this simpler class, and then use that.
*/
[XmlRoot(ElementName = "inventory", IsNullable = true)]
public class SerializableInventory
{
[XmlElement(ElementName = "folder", IsNullable = true)] public SerializableFolder root;
#region Nested type: SerializableFolder
[XmlRoot(ElementName = "folder", IsNullable = true)]
public class SerializableFolder : InventoryFolderBase
{
[XmlArray(ElementName = "items", IsNullable = true)] [XmlArrayItem(ElementName = "item", IsNullable = true, Type = typeof (InventoryItemBase))] public ArrayList
Items;
[XmlArray(ElementName = "folders", IsNullable = true)] [XmlArrayItem(ElementName = "folder", IsNullable = true, Type = typeof (SerializableFolder))] public
ArrayList SubFolders;
}
#endregion
}
}

View File

@ -1,355 +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.Globalization;
using System.IO;
using System.Text.RegularExpressions;
using OpenMetaverse;
namespace OpenSim.Framework
{
public class WearableItem
{
public string WearableName = "";
public WearableType WearType = WearableType.Invalid;
public string ItemInfo = "Created Wearable";
public SortedList<int, VisualSetting> VisualSettings = new SortedList<int, VisualSetting>();
// public LLObject.TextureEntry TextureEntry = null;
//public byte[] TextureEntry = null;
public List<string> TextureStrings = new List<string>();
//permissions
public uint BaseMask = 0;
public uint OwnerMask = 0;
public uint GroupMask = 0;
public uint EveryoneMask = 0;
public uint NextOwnerMask = 0;
public UUID CreatorID = UUID.Zero;
public UUID OwnerID = UUID.Zero;
public UUID LastOwnerID = UUID.Zero;
public UUID GroupID = UUID.Zero;
//sale
public string SaleType = "not";
public int SalePrice = 10;
private string BuildString = "";
public WearableItem(string wearableName, WearableType type)
{
WearableName = wearableName;
WearType = type;
}
public WearableItem(string wearableName)
{
WearableName = wearableName;
WearType = ConvertNameToType(WearableName);
}
public WearableItem(WearableType type)
{
WearType = type;
WearableName = Enum.GetName(typeof(WearableType), type).ToLower();
}
public WearableItem()
{
}
public void AddVisualSetting(VisualSetting setting)
{
if (!VisualSettings.ContainsKey(setting.VisualParam.ParamID))
{
VisualSettings.Add(setting.VisualParam.ParamID, setting);
}
}
public bool TryGetSetting(string paramName, out VisualSetting paramSetting)
{
foreach (VisualSetting setting in VisualSettings.Values)
{
if (setting.VisualParam.Name == paramName)
{
paramSetting = setting;
return true;
}
}
paramSetting = null;
return false;
}
public bool SetParamValue(string paramName, float value)
{
VisualSetting paramSetting;
if (TryGetSetting(paramName, out paramSetting))
{
if ((value >= paramSetting.VisualParam.MinValue) && (value <= paramSetting.VisualParam.MaxValue))
{
paramSetting.Value = value;
return true;
}
}
return false;
}
public void RandomiseValues()
{
foreach (VisualSetting setting in VisualSettings.Values)
{
//int randNum = Util.RandomClass.Next(0, 1000);
float range = setting.VisualParam.MaxValue - setting.VisualParam.MinValue;
// float val = ((float) randNum) / ((float)(1000.0f / range));
float val = (float)Util.RandomClass.NextDouble() * range * 0.2f;
setting.Value = setting.VisualParam.MinValue + (range / 2) + val;
}
}
public WearableType ConvertNameToType(string name)
{
return (WearableType)Enum.Parse(typeof(WearableType), name, true);
}
public string ToAssetFormat()
{
BuildString = "LLWearable version 22\n";
BuildString += "New Item \n";
BuildString += ItemInfo + "\n";
AddSectionStart("permissions");
AddTabbedNameValueLine("base_mask", BaseMask.ToString("00000000"));
AddTabbedNameValueLine("owner_mask", OwnerMask.ToString("00000000"));
AddTabbedNameValueLine("group_mask", GroupMask.ToString("00000000"));
AddTabbedNameValueLine("everyone_mask", EveryoneMask.ToString("00000000"));
AddTabbedNameValueLine("next_owner_mask", NextOwnerMask.ToString("00000000"));
AddTabbedNameValueLine("creator_id", CreatorID.ToString());
AddTabbedNameValueLine("owner_id", OwnerID.ToString());
AddTabbedNameValueLine("last_owner_id", LastOwnerID.ToString());
AddTabbedNameValueLine("group_id", GroupID.ToString());
AddSectionEnd();
AddSectionStart("sale_info");
AddTabbedNameValueLine("sale_type", SaleType.ToString());
AddTabbedNameValueLine("sale_price", SalePrice.ToString());
AddSectionEnd();
AddNameValueLine("type", ((byte)WearType).ToString());
AddNameValueLine("parameters", VisualSettings.Count.ToString());
foreach (KeyValuePair<int, VisualSetting> kp in VisualSettings)
{
AddNameValueLine(kp.Key.ToString(), kp.Value.Value.ToString(CultureInfo.InvariantCulture));
}
if (TextureStrings.Count == 0)
{
AddNameValueLine("textures", "0"); //todo output texture entry
}
else
{
AddNameValueLine("textures", TextureStrings.Count.ToString());
for (int i = 0; i < TextureStrings.Count; i++)
{
BuildString += TextureStrings[i] + "\n";
}
BuildString += "\n";
}
return BuildString;
}
public void SaveToFile(string fileName)
{
File.WriteAllText(fileName, this.ToAssetFormat());
}
public void AddSectionStart(string sectionName)
{
BuildString += "\t" + sectionName + " 0\n";
BuildString += "\t{\n";
}
public void AddSectionEnd()
{
BuildString += "\t}\n";
}
private void AddTabbedNameValueLine(string name, string value)
{
BuildString += "\t\t";
BuildString += name + "\t";
BuildString += value + "\n";
}
private void AddNameValueLine(string name, string value)
{
// BuildString += "\t\t";
BuildString += name + " ";
BuildString += value + "\n";
}
#region Static Methods
public static List<VisualParam> FindParamsForWearable(string wearableName)
{
List<VisualParam> wearableParams = new List<VisualParam>();
foreach (VisualParam param in VisualParams.Params.Values)
{
if (param.Wearable == wearableName)
{
wearableParams.Add(param);
}
}
return wearableParams;
}
public static WearableItem Create(string wearableTypeName)
{
WearableItem wearableItem = new WearableItem(wearableTypeName);
List<VisualParam> typeParams = FindParamsForWearable(wearableTypeName);
foreach (VisualParam param in typeParams)
{
wearableItem.AddVisualSetting(new VisualSetting(param));
}
return wearableItem;
}
public static WearableItem CreateFromAsset(string assetData)
{
UUID creatorID = UUID.Zero;
UUID ownerID = UUID.Zero;
UUID lastOwnerID = UUID.Zero;
UUID groupID = UUID.Zero;
char[] newlineDelimiter = { '\n' };
string[] lines = assetData.Split(newlineDelimiter);
WearableItem wearableObject = null;
Regex r = new Regex("[\t ]+");
bool reachedParams = false;
bool reachedTextures = false;
foreach (string line in lines)
{
string trimLine = line.Trim();
// m_log.Debug("line : " + trimLine);
string[] splitLine = r.Split(trimLine);
if (splitLine.Length > 1)
{
switch (splitLine[0])
{
case "textures":
reachedParams = false;
reachedTextures = true;
break;
case "type":
string wearableTypeName = Enum.GetName(typeof(WearableType), (WearableType)Convert.ToInt32(splitLine[1]));
wearableObject = Create(wearableTypeName.ToLower());
break;
case "parameters":
reachedParams = true;
break;
case "creator_id":
creatorID = new UUID(splitLine[1]);
break;
case "owner_id":
ownerID = new UUID(splitLine[1]);
break;
case "last_owner_id":
lastOwnerID = new UUID(splitLine[1]);
break;
case "group_id":
groupID = new UUID(splitLine[1]);
break;
default:
if ((wearableObject != null) && (reachedParams))
{
int id = Convert.ToInt32(splitLine[0]);
if (wearableObject.VisualSettings.ContainsKey(id))
{
wearableObject.VisualSettings[id].Value = Convert.ToSingle(splitLine[1], CultureInfo.InvariantCulture);
}
}
else if ((wearableObject != null) && (reachedTextures))
{
wearableObject.TextureStrings.Add(line);
}
break;
}
}
}
if (wearableObject != null)
{
wearableObject.CreatorID = creatorID;
wearableObject.OwnerID = ownerID;
wearableObject.LastOwnerID = lastOwnerID;
wearableObject.GroupID = groupID;
}
return wearableObject;
}
#endregion
#region Nested Class
public class VisualSetting
{
public VisualParam VisualParam;
public float Value = 0;
public VisualSetting(VisualParam param, float value)
{
VisualParam = param;
Value = value;
}
public VisualSetting(VisualParam param)
{
VisualParam = param;
Value = param.DefaultValue;
}
}
#endregion
}
}

View File

@ -655,9 +655,12 @@ namespace OpenSim.Region.Communications.OGS1
userData.Email = (string)data["email"];
userData.ID = new UUID((string)data["uuid"]);
userData.Created = Convert.ToInt32(data["profile_created"]);
userData.UserInventoryURI = (string)data["server_inventory"];
userData.UserAssetURI = (string)data["server_asset"];
userData.FirstLifeAboutText = (string)data["profile_firstlife_about"];
if (data.Contains("server_inventory") && data["server_inventory"] != null)
userData.UserInventoryURI = (string)data["server_inventory"];
if (data.Contains("server_asset") && data["server_asset"] != null)
userData.UserAssetURI = (string)data["server_asset"];
if (data.Contains("profile_firstlife_about") && data["profile_firstlife_about"] != null)
userData.FirstLifeAboutText = (string)data["profile_firstlife_about"];
userData.FirstLifeImage = new UUID((string)data["profile_firstlife_image"]);
userData.CanDoMask = Convert.ToUInt32((string)data["profile_can_do"]);
userData.WantDoMask = Convert.ToUInt32(data["profile_want_do"]);

View File

@ -155,7 +155,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene);
// Yikes!! Remove this as soon as user services get refactored
LocalAssetServerURI = scene.CommsManager.NetworkServersInfo.UserURL;
LocalAssetServerURI = scene.CommsManager.NetworkServersInfo.AssetURL;
LocalInventoryServerURI = scene.CommsManager.NetworkServersInfo.InventoryURL;
LocalUserServerURI = scene.CommsManager.NetworkServersInfo.UserURL;
HGNetworkServersInfo.Init(LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI);

View File

@ -45,6 +45,10 @@ namespace OpenSim.Region.DataSnapshot.Providers
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private bool m_stale = true;
private static UUID m_DefaultImage = new UUID("89556747-24cb-43ed-920b-47caed15465f");
private static UUID m_BlankImage = new UUID("5748decc-f629-461c-9a36-a35a221fe21f");
public void Initialize(Scene scene, DataSnapshotManager parent)
{
m_scene = scene;
@ -142,6 +146,19 @@ namespace OpenSim.Region.DataSnapshot.Providers
node.InnerText = land.LandData.GlobalID.ToString();
xmlobject.AppendChild(node);
node = nodeFactory.CreateNode(XmlNodeType.Element, "location", "");
Vector3 loc = obj.AbsolutePosition;
node.InnerText = loc.X.ToString() + "/" + loc.Y.ToString() + "/" + loc.Z.ToString();
xmlobject.AppendChild(node);
string bestImage = GuessImage(obj);
if (bestImage != string.Empty)
{
node = nodeFactory.CreateNode(XmlNodeType.Element, "image", "");
node.InnerText = bestImage;
xmlobject.AppendChild(node);
}
parent.AppendChild(xmlobject);
}
}
@ -173,5 +190,58 @@ namespace OpenSim.Region.DataSnapshot.Providers
}
public event ProviderStale OnStale;
/// <summary>
/// Guesses the best image, based on a simple heuristic. It guesses only for boxes.
/// We're optimizing for boxes, because those are the most common objects
/// marked "Show in search" -- boxes with content inside.For other shapes,
/// it's really hard to tell which texture should be grabbed.
/// </summary>
/// <param name="sog"></param>
/// <returns></returns>
private string GuessImage(SceneObjectGroup sog)
{
string bestguess = string.Empty;
Dictionary<UUID, int> counts = new Dictionary<UUID, int>();
if (sog.RootPart.Shape != null && sog.RootPart.Shape.ProfileShape == ProfileShape.Square &&
sog.RootPart.Shape.Textures != null && sog.RootPart.Shape.Textures.FaceTextures != null)
{
if (sog.RootPart.Shape.Textures.DefaultTexture.TextureID != UUID.Zero &&
sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_DefaultImage &&
sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_BlankImage &&
sog.RootPart.Shape.Textures.DefaultTexture.RGBA.A < 50)
{
counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] = 8;
}
foreach (Primitive.TextureEntryFace tentry in sog.RootPart.Shape.Textures.FaceTextures)
{
if (tentry != null)
{
if (tentry.TextureID != UUID.Zero && tentry.TextureID != m_DefaultImage && tentry.TextureID != m_BlankImage && tentry.RGBA.A < 50)
{
int c = 0;
counts.TryGetValue(tentry.TextureID, out c);
counts[tentry.TextureID] = c + 1;
// decrease the default texture count
if (counts.ContainsKey(sog.RootPart.Shape.Textures.DefaultTexture.TextureID))
counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] = counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] - 1;
}
}
}
// Let's pick the most unique texture
int min = 9999;
foreach (KeyValuePair<UUID, int> kv in counts)
{
if (kv.Value < min && kv.Value >= 1)
{
bestguess = kv.Key.ToString();
min = kv.Value;
}
}
}
return bestguess;
}
}
}