Merge branch 'presence-refactor' of ssh://opensimulator.org/var/git/opensim into presence-refactor
commit
71c6559a91
|
@ -128,6 +128,7 @@ what it is today.
|
||||||
* YZh
|
* YZh
|
||||||
* Zackary Geers aka Kunnis Basiat
|
* Zackary Geers aka Kunnis Basiat
|
||||||
* Zha Ewry
|
* Zha Ewry
|
||||||
|
* ziah
|
||||||
|
|
||||||
|
|
||||||
= LSL Devs =
|
= LSL Devs =
|
||||||
|
|
|
@ -1,155 +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 OpenSim.Framework;
|
|
||||||
|
|
||||||
namespace OpenSim.Data
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A static class containing methods for obtaining handles to database
|
|
||||||
/// storage objects.
|
|
||||||
/// </summary>
|
|
||||||
public static class DataPluginFactory
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Based on <typeparam name="T" />, returns the appropriate
|
|
||||||
/// PluginInitialiserBase instance in <paramref name="init" /> and
|
|
||||||
/// extension point path in <paramref name="path" />.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="connect">
|
|
||||||
/// The DB connection string used when creating a new
|
|
||||||
/// PluginInitialiserBase, returned in <paramref name="init" />.
|
|
||||||
/// </param>
|
|
||||||
/// <param name="init">
|
|
||||||
/// A reference to a PluginInitialiserBase object in which the proper
|
|
||||||
/// initialiser will be returned.
|
|
||||||
/// </param>
|
|
||||||
/// <param name="path">
|
|
||||||
/// A string in which the proper extension point path will be returned.
|
|
||||||
/// </param>
|
|
||||||
/// <typeparam name="T">
|
|
||||||
/// The type of data plugin requested.
|
|
||||||
/// </typeparam>
|
|
||||||
/// <exception cref="NotImplementedException">
|
|
||||||
/// Thrown if <typeparamref name="T" /> is not one of the expected data
|
|
||||||
/// interfaces.
|
|
||||||
/// </exception>
|
|
||||||
private static void PluginLoaderParamFactory<T>(string connect, out PluginInitialiserBase init, out string path) where T : IPlugin
|
|
||||||
{
|
|
||||||
Type type = typeof(T);
|
|
||||||
|
|
||||||
if (type == typeof(IInventoryDataPlugin))
|
|
||||||
{
|
|
||||||
init = new InventoryDataInitialiser(connect);
|
|
||||||
path = "/OpenSim/InventoryData";
|
|
||||||
}
|
|
||||||
else if (type == typeof(IUserDataPlugin))
|
|
||||||
{
|
|
||||||
init = new UserDataInitialiser(connect);
|
|
||||||
path = "/OpenSim/UserData";
|
|
||||||
}
|
|
||||||
else if (type == typeof(IGridDataPlugin))
|
|
||||||
{
|
|
||||||
init = new GridDataInitialiser(connect);
|
|
||||||
path = "/OpenSim/GridData";
|
|
||||||
}
|
|
||||||
else if (type == typeof(ILogDataPlugin))
|
|
||||||
{
|
|
||||||
init = new LogDataInitialiser(connect);
|
|
||||||
path = "/OpenSim/LogData";
|
|
||||||
}
|
|
||||||
else if (type == typeof(IAssetDataPlugin))
|
|
||||||
{
|
|
||||||
init = new AssetDataInitialiser(connect);
|
|
||||||
path = "/OpenSim/AssetData";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// We don't support this data plugin.
|
|
||||||
throw new NotImplementedException(String.Format("The type '{0}' is not a valid data plugin.", type));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a list of new <typeparamref name="T" /> data plugins.
|
|
||||||
/// Plugins will be requested in the order they were added.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="provider">
|
|
||||||
/// The filename of the inventory server plugin DLL.
|
|
||||||
/// </param>
|
|
||||||
/// <param name="connect">
|
|
||||||
/// The connection string for the storage backend.
|
|
||||||
/// </param>
|
|
||||||
/// <typeparam name="T">
|
|
||||||
/// The type of data plugin requested.
|
|
||||||
/// </typeparam>
|
|
||||||
/// <returns>
|
|
||||||
/// A list of all loaded plugins matching <typeparamref name="T" />.
|
|
||||||
/// </returns>
|
|
||||||
public static List<T> LoadDataPlugins<T>(string provider, string connect) where T : IPlugin
|
|
||||||
{
|
|
||||||
PluginInitialiserBase pluginInitialiser;
|
|
||||||
string extensionPointPath;
|
|
||||||
|
|
||||||
PluginLoaderParamFactory<T>(connect, out pluginInitialiser, out extensionPointPath);
|
|
||||||
|
|
||||||
using (PluginLoader<T> loader = new PluginLoader<T>(pluginInitialiser))
|
|
||||||
{
|
|
||||||
// loader will try to load all providers (MySQL, MSSQL, etc)
|
|
||||||
// unless it is constrainted to the correct "Provider" entry in the addin.xml
|
|
||||||
loader.Add(extensionPointPath, new PluginProviderFilter(provider));
|
|
||||||
loader.Load();
|
|
||||||
|
|
||||||
return loader.Plugins;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a new <typeparamref name="T" /> data plugin instance if
|
|
||||||
/// only one was loaded, otherwise returns null (<c>default(T)</c>).
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="provider">
|
|
||||||
/// The filename of the inventory server plugin DLL.
|
|
||||||
/// </param>
|
|
||||||
/// <param name="connect">
|
|
||||||
/// The connection string for the storage backend.
|
|
||||||
/// </param>
|
|
||||||
/// <typeparam name="T">
|
|
||||||
/// The type of data plugin requested.
|
|
||||||
/// </typeparam>
|
|
||||||
/// <returns>
|
|
||||||
/// A list of all loaded plugins matching <typeparamref name="T" />.
|
|
||||||
/// </returns>
|
|
||||||
public static T LoadDataPlugin<T>(string provider, string connect) where T : IPlugin
|
|
||||||
{
|
|
||||||
List<T> plugins = LoadDataPlugins<T>(provider, connect);
|
|
||||||
return (plugins.Count == 1) ? plugins[0] : default(T);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +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.Generic;
|
|
||||||
using OpenMetaverse;
|
|
||||||
|
|
||||||
namespace OpenSim.Data
|
|
||||||
{
|
|
||||||
public abstract class GridDataBase : IGridDataPlugin
|
|
||||||
{
|
|
||||||
public abstract RegionProfileData GetProfileByHandle(ulong regionHandle);
|
|
||||||
public abstract RegionProfileData GetProfileByUUID(UUID UUID);
|
|
||||||
public abstract RegionProfileData GetProfileByString(string regionName);
|
|
||||||
public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
|
|
||||||
public abstract List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum);
|
|
||||||
public abstract bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey);
|
|
||||||
public abstract DataResponse StoreProfile(RegionProfileData profile);
|
|
||||||
public abstract ReservationData GetReservationAtPoint(uint x, uint y);
|
|
||||||
public abstract DataResponse DeleteProfile(string uuid);
|
|
||||||
|
|
||||||
public abstract void Initialise();
|
|
||||||
public abstract void Initialise(string connect);
|
|
||||||
public abstract void Dispose();
|
|
||||||
|
|
||||||
public abstract string Name { get; }
|
|
||||||
public abstract string Version { get; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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.Collections.Generic;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
|
|
||||||
namespace OpenSim.Data
|
|
||||||
{
|
|
||||||
public enum DataResponse
|
|
||||||
{
|
|
||||||
RESPONSE_OK,
|
|
||||||
RESPONSE_AUTHREQUIRED,
|
|
||||||
RESPONSE_INVALIDCREDENTIALS,
|
|
||||||
RESPONSE_ERROR
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A standard grid interface
|
|
||||||
/// </summary>
|
|
||||||
public interface IGridDataPlugin : IPlugin
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Initialises the interface
|
|
||||||
/// </summary>
|
|
||||||
void Initialise(string connect);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a sim profile from a regionHandle
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="regionHandle">A 64bit Region Handle</param>
|
|
||||||
/// <returns>A simprofile</returns>
|
|
||||||
RegionProfileData GetProfileByHandle(ulong regionHandle);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a sim profile from a UUID
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="UUID">A 128bit UUID</param>
|
|
||||||
/// <returns>A sim profile</returns>
|
|
||||||
RegionProfileData GetProfileByUUID(UUID UUID);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a sim profile from a string match
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="regionName">A string for a partial region name match</param>
|
|
||||||
/// <returns>A sim profile</returns>
|
|
||||||
RegionProfileData GetProfileByString(string regionName);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns all profiles within the specified range
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="Xmin">Minimum sim coordinate (X)</param>
|
|
||||||
/// <param name="Ymin">Minimum sim coordinate (Y)</param>
|
|
||||||
/// <param name="Xmax">Maximum sim coordinate (X)</param>
|
|
||||||
/// <param name="Ymin">Maximum sim coordinate (Y)</param>
|
|
||||||
/// <returns>An array containing all the sim profiles in the specified range</returns>
|
|
||||||
RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns up to maxNum profiles of regions that have a name starting with namePrefix
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name to match against</param>
|
|
||||||
/// <param name="maxNum">Maximum number of profiles to return</param>
|
|
||||||
/// <returns>A list of sim profiles</returns>
|
|
||||||
List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Authenticates a sim by use of its recv key.
|
|
||||||
/// WARNING: Insecure
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="UUID">The UUID sent by the sim</param>
|
|
||||||
/// <param name="regionHandle">The regionhandle sent by the sim</param>
|
|
||||||
/// <param name="simrecvkey">The receiving key sent by the sim</param>
|
|
||||||
/// <returns>Whether the sim has been authenticated</returns>
|
|
||||||
bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds or updates a profile in the database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="profile">The profile to add</param>
|
|
||||||
/// <returns>RESPONSE_OK if successful, error if not.</returns>
|
|
||||||
DataResponse StoreProfile(RegionProfileData profile);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove a profile from the database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="UUID">ID of profile to remove</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
DataResponse DeleteProfile(string UUID);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Function not used????
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="x"></param>
|
|
||||||
/// <param name="y"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
ReservationData GetReservationAtPoint(uint x, uint y);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class GridDataInitialiser : PluginInitialiserBase
|
|
||||||
{
|
|
||||||
private string connect;
|
|
||||||
public GridDataInitialiser (string s) { connect = s; }
|
|
||||||
public override void Initialise (IPlugin plugin)
|
|
||||||
{
|
|
||||||
IGridDataPlugin p = plugin as IGridDataPlugin;
|
|
||||||
p.Initialise (connect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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 OpenSim.Framework;
|
|
||||||
|
|
||||||
namespace OpenSim.Data
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The severity of an individual log message
|
|
||||||
/// </summary>
|
|
||||||
public enum LogSeverity : int
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Critical: systems failure
|
|
||||||
/// </summary>
|
|
||||||
CRITICAL = 1,
|
|
||||||
/// <summary>
|
|
||||||
/// Major: warning prior to systems failure
|
|
||||||
/// </summary>
|
|
||||||
MAJOR = 2,
|
|
||||||
/// <summary>
|
|
||||||
/// Medium: an individual non-critical task failed
|
|
||||||
/// </summary>
|
|
||||||
MEDIUM = 3,
|
|
||||||
/// <summary>
|
|
||||||
/// Low: Informational warning
|
|
||||||
/// </summary>
|
|
||||||
LOW = 4,
|
|
||||||
/// <summary>
|
|
||||||
/// Info: Information
|
|
||||||
/// </summary>
|
|
||||||
INFO = 5,
|
|
||||||
/// <summary>
|
|
||||||
/// Verbose: Debug Information
|
|
||||||
/// </summary>
|
|
||||||
VERBOSE = 6
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// An interface to a LogData storage system
|
|
||||||
/// </summary>
|
|
||||||
public interface ILogDataPlugin : IPlugin
|
|
||||||
{
|
|
||||||
void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,
|
|
||||||
string logMessage);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initialises the interface
|
|
||||||
/// </summary>
|
|
||||||
void Initialise(string connect);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class LogDataInitialiser : PluginInitialiserBase
|
|
||||||
{
|
|
||||||
private string connect;
|
|
||||||
public LogDataInitialiser (string s) { connect = s; }
|
|
||||||
public override void Initialise (IPlugin plugin)
|
|
||||||
{
|
|
||||||
ILogDataPlugin p = plugin as ILogDataPlugin;
|
|
||||||
p.Initialise (connect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,100 +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;
|
|
||||||
using OpenMetaverse;
|
|
||||||
|
|
||||||
namespace OpenSim.Data
|
|
||||||
{
|
|
||||||
public interface IRegionProfileService
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a region by argument
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uuid">A UUID key of the region to return</param>
|
|
||||||
/// <returns>A SimProfileData for the region</returns>
|
|
||||||
RegionProfileData GetRegion(UUID uuid);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a region by argument
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uuid">A regionHandle of the region to return</param>
|
|
||||||
/// <returns>A SimProfileData for the region</returns>
|
|
||||||
RegionProfileData GetRegion(ulong handle);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a region by argument
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="regionName">A partial regionName of the region to return</param>
|
|
||||||
/// <returns>A SimProfileData for the region</returns>
|
|
||||||
RegionProfileData GetRegion(string regionName);
|
|
||||||
|
|
||||||
List<RegionProfileData> GetRegions(uint xmin, uint ymin, uint xmax, uint ymax);
|
|
||||||
List<RegionProfileData> GetRegions(string name, int maxNum);
|
|
||||||
DataResponse AddUpdateRegion(RegionProfileData sim, RegionProfileData existingSim);
|
|
||||||
DataResponse DeleteRegion(string uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IRegionProfileRouter
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Request sim profile information from a grid server, by Region UUID
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="regionId">The region UUID to look for</param>
|
|
||||||
/// <param name="gridserverUrl"></param>
|
|
||||||
/// <param name="gridserverSendkey"></param>
|
|
||||||
/// <param name="gridserverRecvkey"></param>
|
|
||||||
/// <returns>The sim profile. Null if there was a request failure</returns>
|
|
||||||
/// <remarks>This method should be statics</remarks>
|
|
||||||
RegionProfileData RequestSimProfileData(UUID regionId, Uri gridserverUrl,
|
|
||||||
string gridserverSendkey, string gridserverRecvkey);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Request sim profile information from a grid server, by Region Handle
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="regionHandle">the region handle to look for</param>
|
|
||||||
/// <param name="gridserverUrl"></param>
|
|
||||||
/// <param name="gridserverSendkey"></param>
|
|
||||||
/// <param name="gridserverRecvkey"></param>
|
|
||||||
/// <returns>The sim profile. Null if there was a request failure</returns>
|
|
||||||
RegionProfileData RequestSimProfileData(ulong regionHandle, Uri gridserverUrl,
|
|
||||||
string gridserverSendkey, string gridserverRecvkey);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Request sim profile information from a grid server, by Region Name
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="regionName">the region name to look for</param>
|
|
||||||
/// <param name="gridserverUrl"></param>
|
|
||||||
/// <param name="gridserverSendkey"></param>
|
|
||||||
/// <param name="gridserverRecvkey"></param>
|
|
||||||
/// <returns>The sim profile. Null if there was a request failure</returns>
|
|
||||||
RegionProfileData RequestSimProfileData(string regionName, Uri gridserverUrl,
|
|
||||||
string gridserverSendkey, string gridserverRecvkey);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,209 +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 OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
|
|
||||||
namespace OpenSim.Data
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// An interface for connecting to user storage servers.
|
|
||||||
/// </summary>
|
|
||||||
public interface IUserDataPlugin : IPlugin
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a user profile from a database via their UUID
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="user">The user's UUID</param>
|
|
||||||
/// <returns>The user data profile. Returns null if no user is found</returns>
|
|
||||||
UserProfileData GetUserByUUID(UUID user);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a users profile by searching their username parts
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fname">Account firstname</param>
|
|
||||||
/// <param name="lname">Account lastname</param>
|
|
||||||
/// <returns>The user data profile. Null if no user is found</returns>
|
|
||||||
UserProfileData GetUserByName(string fname, string lname);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get a user from a given uri.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uri"></param>
|
|
||||||
/// <returns>The user data profile. Null if no user is found.</returns>
|
|
||||||
UserProfileData GetUserByUri(Uri uri);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a list of UUIDs firstnames and lastnames that match string query entered into the avatar picker.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="queryID">ID associated with the user's query. This must match what the client sent</param>
|
|
||||||
/// <param name="query">The filtered contents of the search box when the user hit search.</param>
|
|
||||||
/// <returns>A list of user details. If there are no results than either an empty list or null</returns>
|
|
||||||
List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the current agent for a user searching by it's UUID
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="user">The users UUID</param>
|
|
||||||
/// <returns>The current agent session. Null if no session was found</returns>
|
|
||||||
UserAgentData GetAgentByUUID(UUID user);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the current session agent for a user searching by username
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The users account name</param>
|
|
||||||
/// <returns>The current agent session</returns>
|
|
||||||
UserAgentData GetAgentByName(string name);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the current session agent for a user searching by username parts
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fname">The users first account name</param>
|
|
||||||
/// <param name="lname">The users account surname</param>
|
|
||||||
/// <returns>The current agent session</returns>
|
|
||||||
UserAgentData GetAgentByName(string fname, string lname);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Stores new web-login key for user during web page login
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="webLoginKey"></param>
|
|
||||||
void StoreWebLoginKey(UUID agentID, UUID webLoginKey);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a new User profile to the database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="user">UserProfile to add</param>
|
|
||||||
void AddNewUserProfile(UserProfileData user);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a temporary user profile. A temporary userprofile is one that should exist only for the lifetime of
|
|
||||||
/// the process.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="userProfile"></param>
|
|
||||||
void AddTemporaryUserProfile(UserProfileData userProfile);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates an existing user profile
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="user">UserProfile to update</param>
|
|
||||||
bool UpdateUserProfile(UserProfileData user);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a new agent to the database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="agent">The agent to add</param>
|
|
||||||
void AddNewUserAgent(UserAgentData agent);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a new friend to the database for XUser
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="friendlistowner">The agent that who's friends list is being added to</param>
|
|
||||||
/// <param name="friend">The agent that being added to the friends list of the friends list owner</param>
|
|
||||||
/// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param>
|
|
||||||
void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Delete friend on friendlistowner's friendlist.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="friendlistowner">The agent that who's friends list is being updated</param>
|
|
||||||
/// <param name="friend">The Ex-friend agent</param>
|
|
||||||
void RemoveUserFriend(UUID friendlistowner, UUID friend);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Update permissions for friend on friendlistowner's friendlist.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="friendlistowner">The agent that who's friends list is being updated</param>
|
|
||||||
/// <param name="friend">The agent that is getting or loosing permissions</param>
|
|
||||||
/// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param>
|
|
||||||
void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param>
|
|
||||||
/// <returns>The user's friends. If there are no results than either an empty list or null</returns>
|
|
||||||
List<FriendListItem> GetUserFriendList(UUID friendlistowner);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a list of <see cref="FriendRegionInfo/>s for the specified UUIDs.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uuids">
|
|
||||||
/// A <see cref="List"/> of <see cref="UUID/>s to fetch info for
|
|
||||||
/// </param>
|
|
||||||
/// <returns>
|
|
||||||
/// A <see cref="Dictionary"/>, mapping the <see cref="UUID"/>s to <see cref="FriendRegionInfo"/>s.
|
|
||||||
/// </returns>
|
|
||||||
Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Attempts to move currency units between accounts (NOT RELIABLE / TRUSTWORTHY. DONT TRY RUN YOUR OWN CURRENCY EXCHANGE WITH REAL VALUES)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="from">The account to transfer from</param>
|
|
||||||
/// <param name="to">The account to transfer to</param>
|
|
||||||
/// <param name="amount">The amount to transfer</param>
|
|
||||||
/// <returns>Successful?</returns>
|
|
||||||
bool MoneyTransferRequest(UUID from, UUID to, uint amount);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Attempts to move inventory between accounts, if inventory is copyable it will be copied into the target account.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="from">User to transfer from</param>
|
|
||||||
/// <param name="to">User to transfer to</param>
|
|
||||||
/// <param name="inventory">Specified inventory item</param>
|
|
||||||
/// <returns>Successful?</returns>
|
|
||||||
bool InventoryTransferRequest(UUID from, UUID to, UUID inventory);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initialises the plugin (artificial constructor)
|
|
||||||
/// </summary>
|
|
||||||
void Initialise(string connect);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the user appearance
|
|
||||||
/// </summer>
|
|
||||||
AvatarAppearance GetUserAppearance(UUID user);
|
|
||||||
|
|
||||||
void UpdateUserAppearance(UUID user, AvatarAppearance appearance);
|
|
||||||
|
|
||||||
void ResetAttachments(UUID userID);
|
|
||||||
|
|
||||||
void LogoutUsers(UUID regionID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class UserDataInitialiser : PluginInitialiserBase
|
|
||||||
{
|
|
||||||
private string connect;
|
|
||||||
public UserDataInitialiser (string s) { connect = s; }
|
|
||||||
public override void Initialise (IPlugin plugin)
|
|
||||||
{
|
|
||||||
IUserDataPlugin p = plugin as IUserDataPlugin;
|
|
||||||
p.Initialise (connect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,587 +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.Data;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using System.Reflection;
|
|
||||||
using log4net;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MSSQL
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A grid data interface for MSSQL Server
|
|
||||||
/// </summary>
|
|
||||||
public class MSSQLGridData : GridDataBase
|
|
||||||
{
|
|
||||||
private const string _migrationStore = "GridStore";
|
|
||||||
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Database manager
|
|
||||||
/// </summary>
|
|
||||||
private MSSQLManager database;
|
|
||||||
|
|
||||||
private string m_regionsTableName = "regions";
|
|
||||||
|
|
||||||
#region IPlugin Members
|
|
||||||
|
|
||||||
// [Obsolete("Cannot be default-initialized!")]
|
|
||||||
override public void Initialise()
|
|
||||||
{
|
|
||||||
m_log.Info("[GRID DB]: " + Name + " cannot be default-initialized!");
|
|
||||||
throw new PluginNotInitialisedException(Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initialises the Grid Interface
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="connectionString">connect string</param>
|
|
||||||
/// <remarks>use mssql_connection.ini</remarks>
|
|
||||||
override public void Initialise(string connectionString)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(connectionString))
|
|
||||||
{
|
|
||||||
database = new MSSQLManager(connectionString);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO: make the connect string actually do something
|
|
||||||
IniFile iniFile = new IniFile("mssql_connection.ini");
|
|
||||||
|
|
||||||
string settingDataSource = iniFile.ParseFileReadValue("data_source");
|
|
||||||
string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog");
|
|
||||||
string settingPersistSecurityInfo = iniFile.ParseFileReadValue("persist_security_info");
|
|
||||||
string settingUserId = iniFile.ParseFileReadValue("user_id");
|
|
||||||
string settingPassword = iniFile.ParseFileReadValue("password");
|
|
||||||
|
|
||||||
m_regionsTableName = iniFile.ParseFileReadValue("regionstablename");
|
|
||||||
if (m_regionsTableName == null)
|
|
||||||
{
|
|
||||||
m_regionsTableName = "regions";
|
|
||||||
}
|
|
||||||
|
|
||||||
database =
|
|
||||||
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
|
|
||||||
settingPassword);
|
|
||||||
}
|
|
||||||
|
|
||||||
//New migrations check of store
|
|
||||||
database.CheckMigration(_migrationStore);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Shuts down the grid interface
|
|
||||||
/// </summary>
|
|
||||||
override public void Dispose()
|
|
||||||
{
|
|
||||||
database = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The name of this DB provider.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string containing the storage system name</returns>
|
|
||||||
override public string Name
|
|
||||||
{
|
|
||||||
get { return "MSSQL OpenGridData"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Database provider version.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string containing the storage system version</returns>
|
|
||||||
override public string Version
|
|
||||||
{
|
|
||||||
get { return "0.1"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Public override GridDataBase methods
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a list of regions within the specified ranges
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="xmin">minimum X coordinate</param>
|
|
||||||
/// <param name="ymin">minimum Y coordinate</param>
|
|
||||||
/// <param name="xmax">maximum X coordinate</param>
|
|
||||||
/// <param name="ymax">maximum Y coordinate</param>
|
|
||||||
/// <returns>null</returns>
|
|
||||||
/// <remarks>always return null</remarks>
|
|
||||||
override public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax)
|
|
||||||
{
|
|
||||||
using (AutoClosingSqlCommand command = database.Query("SELECT * FROM regions WHERE locX >= @xmin AND locX <= @xmax AND locY >= @ymin AND locY <= @ymax"))
|
|
||||||
{
|
|
||||||
command.Parameters.Add(database.CreateParameter("xmin", xmin));
|
|
||||||
command.Parameters.Add(database.CreateParameter("ymin", ymin));
|
|
||||||
command.Parameters.Add(database.CreateParameter("xmax", xmax));
|
|
||||||
command.Parameters.Add(database.CreateParameter("ymax", ymax));
|
|
||||||
|
|
||||||
List<RegionProfileData> rows = new List<RegionProfileData>();
|
|
||||||
|
|
||||||
using (SqlDataReader reader = command.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
rows.Add(ReadSimRow(reader));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rows.Count > 0)
|
|
||||||
{
|
|
||||||
return rows.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_log.Info("[GRID DB] : Found no regions within range.");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns up to maxNum profiles of regions that have a name starting with namePrefix
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="namePrefix">The name to match against</param>
|
|
||||||
/// <param name="maxNum">Maximum number of profiles to return</param>
|
|
||||||
/// <returns>A list of sim profiles</returns>
|
|
||||||
override public List<RegionProfileData> GetRegionsByName (string namePrefix, uint maxNum)
|
|
||||||
{
|
|
||||||
using (AutoClosingSqlCommand command = database.Query("SELECT * FROM regions WHERE regionName LIKE @name"))
|
|
||||||
{
|
|
||||||
command.Parameters.Add(database.CreateParameter("name", namePrefix + "%"));
|
|
||||||
|
|
||||||
List<RegionProfileData> rows = new List<RegionProfileData>();
|
|
||||||
|
|
||||||
using (SqlDataReader reader = command.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (rows.Count < maxNum && reader.Read())
|
|
||||||
{
|
|
||||||
rows.Add(ReadSimRow(reader));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return rows;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a sim profile from its location
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="handle">Region location handle</param>
|
|
||||||
/// <returns>Sim profile</returns>
|
|
||||||
override public RegionProfileData GetProfileByHandle(ulong handle)
|
|
||||||
{
|
|
||||||
using (AutoClosingSqlCommand command = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE regionHandle = @handle"))
|
|
||||||
{
|
|
||||||
command.Parameters.Add(database.CreateParameter("handle", handle));
|
|
||||||
|
|
||||||
using (SqlDataReader reader = command.ExecuteReader())
|
|
||||||
{
|
|
||||||
if (reader.Read())
|
|
||||||
{
|
|
||||||
return ReadSimRow(reader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_log.InfoFormat("[GRID DB] : No region found with handle : {0}", handle);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a sim profile from its UUID
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uuid">The region UUID</param>
|
|
||||||
/// <returns>The sim profile</returns>
|
|
||||||
override public RegionProfileData GetProfileByUUID(UUID uuid)
|
|
||||||
{
|
|
||||||
using (AutoClosingSqlCommand command = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE uuid = @uuid"))
|
|
||||||
{
|
|
||||||
command.Parameters.Add(database.CreateParameter("uuid", uuid));
|
|
||||||
|
|
||||||
using (SqlDataReader reader = command.ExecuteReader())
|
|
||||||
{
|
|
||||||
if (reader.Read())
|
|
||||||
{
|
|
||||||
return ReadSimRow(reader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_log.InfoFormat("[GRID DB] : No region found with UUID : {0}", uuid);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a sim profile from it's Region name string
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="regionName">The region name search query</param>
|
|
||||||
/// <returns>The sim profile</returns>
|
|
||||||
override public RegionProfileData GetProfileByString(string regionName)
|
|
||||||
{
|
|
||||||
if (regionName.Length > 2)
|
|
||||||
{
|
|
||||||
using (AutoClosingSqlCommand command = database.Query("SELECT top 1 * FROM " + m_regionsTableName + " WHERE regionName like @regionName order by regionName"))
|
|
||||||
{
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionName", regionName + "%"));
|
|
||||||
|
|
||||||
using (SqlDataReader reader = command.ExecuteReader())
|
|
||||||
{
|
|
||||||
if (reader.Read())
|
|
||||||
{
|
|
||||||
return ReadSimRow(reader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_log.InfoFormat("[GRID DB] : No region found with regionName : {0}", regionName);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a new specified region to the database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="profile">The profile to add</param>
|
|
||||||
/// <returns>A dataresponse enum indicating success</returns>
|
|
||||||
override public DataResponse StoreProfile(RegionProfileData profile)
|
|
||||||
{
|
|
||||||
if (GetProfileByUUID(profile.UUID) == null)
|
|
||||||
{
|
|
||||||
if (InsertRegionRow(profile))
|
|
||||||
{
|
|
||||||
return DataResponse.RESPONSE_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (UpdateRegionRow(profile))
|
|
||||||
{
|
|
||||||
return DataResponse.RESPONSE_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return DataResponse.RESPONSE_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Deletes a sim profile from the database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uuid">the sim UUID</param>
|
|
||||||
/// <returns>Successful?</returns>
|
|
||||||
//public DataResponse DeleteProfile(RegionProfileData profile)
|
|
||||||
override public DataResponse DeleteProfile(string uuid)
|
|
||||||
{
|
|
||||||
using (AutoClosingSqlCommand command = database.Query("DELETE FROM regions WHERE uuid = @uuid;"))
|
|
||||||
{
|
|
||||||
command.Parameters.Add(database.CreateParameter("uuid", uuid));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
command.ExecuteNonQuery();
|
|
||||||
return DataResponse.RESPONSE_OK;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[GRID DB] : Error deleting region info, error is : {0}", e.Message);
|
|
||||||
return DataResponse.RESPONSE_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods that are not used or deprecated (still needed because of base class)
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// DEPRECATED. Attempts to authenticate a region by comparing a shared secret.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uuid">The UUID of the challenger</param>
|
|
||||||
/// <param name="handle">The attempted regionHandle of the challenger</param>
|
|
||||||
/// <param name="authkey">The secret</param>
|
|
||||||
/// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
|
|
||||||
override public bool AuthenticateSim(UUID uuid, ulong handle, string authkey)
|
|
||||||
{
|
|
||||||
bool throwHissyFit = false; // Should be true by 1.0
|
|
||||||
|
|
||||||
if (throwHissyFit)
|
|
||||||
throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
|
|
||||||
|
|
||||||
RegionProfileData data = GetProfileByUUID(uuid);
|
|
||||||
|
|
||||||
return (handle == data.regionHandle && authkey == data.regionSecret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>This requires a security audit.</remarks>
|
|
||||||
/// <param name="uuid"></param>
|
|
||||||
/// <param name="handle"></param>
|
|
||||||
/// <param name="authhash"></param>
|
|
||||||
/// <param name="challenge"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool AuthenticateSim(UUID uuid, ulong handle, string authhash, string challenge)
|
|
||||||
{
|
|
||||||
// SHA512Managed HashProvider = new SHA512Managed();
|
|
||||||
// Encoding TextProvider = new UTF8Encoding();
|
|
||||||
|
|
||||||
// byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge);
|
|
||||||
// byte[] hash = HashProvider.ComputeHash(stream);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// NOT IMPLEMENTED
|
|
||||||
/// WHEN IS THIS GONNA BE IMPLEMENTED.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="x"></param>
|
|
||||||
/// <param name="y"></param>
|
|
||||||
/// <returns>null</returns>
|
|
||||||
override public ReservationData GetReservationAtPoint(uint x, uint y)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region private methods
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Reads a region row from a database reader
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="reader">An active database reader</param>
|
|
||||||
/// <returns>A region profile</returns>
|
|
||||||
private static RegionProfileData ReadSimRow(IDataRecord reader)
|
|
||||||
{
|
|
||||||
RegionProfileData retval = new RegionProfileData();
|
|
||||||
|
|
||||||
// Region Main gotta-have-or-we-return-null parts
|
|
||||||
UInt64 tmp64;
|
|
||||||
if (!UInt64.TryParse(reader["regionHandle"].ToString(), out tmp64))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
retval.regionHandle = tmp64;
|
|
||||||
|
|
||||||
// UUID tmp_uuid;
|
|
||||||
// if (!UUID.TryParse((string)reader["uuid"], out tmp_uuid))
|
|
||||||
// {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
retval.UUID = new UUID((Guid)reader["uuid"]); // tmp_uuid;
|
|
||||||
|
|
||||||
// non-critical parts
|
|
||||||
retval.regionName = reader["regionName"].ToString();
|
|
||||||
retval.originUUID = new UUID((Guid)reader["originUUID"]);
|
|
||||||
|
|
||||||
// Secrets
|
|
||||||
retval.regionRecvKey = reader["regionRecvKey"].ToString();
|
|
||||||
retval.regionSecret = reader["regionSecret"].ToString();
|
|
||||||
retval.regionSendKey = reader["regionSendKey"].ToString();
|
|
||||||
|
|
||||||
// Region Server
|
|
||||||
retval.regionDataURI = reader["regionDataURI"].ToString();
|
|
||||||
retval.regionOnline = false; // Needs to be pinged before this can be set.
|
|
||||||
retval.serverIP = reader["serverIP"].ToString();
|
|
||||||
retval.serverPort = Convert.ToUInt32(reader["serverPort"]);
|
|
||||||
retval.serverURI = reader["serverURI"].ToString();
|
|
||||||
retval.httpPort = Convert.ToUInt32(reader["serverHttpPort"].ToString());
|
|
||||||
retval.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"].ToString());
|
|
||||||
|
|
||||||
// Location
|
|
||||||
retval.regionLocX = Convert.ToUInt32(reader["locX"].ToString());
|
|
||||||
retval.regionLocY = Convert.ToUInt32(reader["locY"].ToString());
|
|
||||||
retval.regionLocZ = Convert.ToUInt32(reader["locZ"].ToString());
|
|
||||||
|
|
||||||
// Neighbours - 0 = No Override
|
|
||||||
retval.regionEastOverrideHandle = Convert.ToUInt64(reader["eastOverrideHandle"].ToString());
|
|
||||||
retval.regionWestOverrideHandle = Convert.ToUInt64(reader["westOverrideHandle"].ToString());
|
|
||||||
retval.regionSouthOverrideHandle = Convert.ToUInt64(reader["southOverrideHandle"].ToString());
|
|
||||||
retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString());
|
|
||||||
|
|
||||||
// Assets
|
|
||||||
retval.regionAssetURI = reader["regionAssetURI"].ToString();
|
|
||||||
retval.regionAssetRecvKey = reader["regionAssetRecvKey"].ToString();
|
|
||||||
retval.regionAssetSendKey = reader["regionAssetSendKey"].ToString();
|
|
||||||
|
|
||||||
// Userserver
|
|
||||||
retval.regionUserURI = reader["regionUserURI"].ToString();
|
|
||||||
retval.regionUserRecvKey = reader["regionUserRecvKey"].ToString();
|
|
||||||
retval.regionUserSendKey = reader["regionUserSendKey"].ToString();
|
|
||||||
|
|
||||||
// World Map Addition
|
|
||||||
retval.regionMapTextureID = new UUID((Guid)reader["regionMapTexture"]);
|
|
||||||
retval.owner_uuid = new UUID((Guid)reader["owner_uuid"]);
|
|
||||||
retval.maturity = Convert.ToUInt32(reader["access"]);
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Update the specified region in the database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="profile">The profile to update</param>
|
|
||||||
/// <returns>success ?</returns>
|
|
||||||
private bool UpdateRegionRow(RegionProfileData profile)
|
|
||||||
{
|
|
||||||
bool returnval = false;
|
|
||||||
|
|
||||||
//Insert new region
|
|
||||||
string sql =
|
|
||||||
"UPDATE " + m_regionsTableName + @" SET
|
|
||||||
[regionHandle]=@regionHandle, [regionName]=@regionName,
|
|
||||||
[regionRecvKey]=@regionRecvKey, [regionSecret]=@regionSecret, [regionSendKey]=@regionSendKey,
|
|
||||||
[regionDataURI]=@regionDataURI, [serverIP]=@serverIP, [serverPort]=@serverPort, [serverURI]=@serverURI,
|
|
||||||
[locX]=@locX, [locY]=@locY, [locZ]=@locZ, [eastOverrideHandle]=@eastOverrideHandle,
|
|
||||||
[westOverrideHandle]=@westOverrideHandle, [southOverrideHandle]=@southOverrideHandle,
|
|
||||||
[northOverrideHandle]=@northOverrideHandle, [regionAssetURI]=@regionAssetURI,
|
|
||||||
[regionAssetRecvKey]=@regionAssetRecvKey, [regionAssetSendKey]=@regionAssetSendKey,
|
|
||||||
[regionUserURI]=@regionUserURI, [regionUserRecvKey]=@regionUserRecvKey, [regionUserSendKey]=@regionUserSendKey,
|
|
||||||
[regionMapTexture]=@regionMapTexture, [serverHttpPort]=@serverHttpPort,
|
|
||||||
[serverRemotingPort]=@serverRemotingPort, [owner_uuid]=@owner_uuid , [originUUID]=@originUUID
|
|
||||||
where [uuid]=@uuid";
|
|
||||||
|
|
||||||
using (AutoClosingSqlCommand command = database.Query(sql))
|
|
||||||
{
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionHandle", profile.regionHandle));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionName", profile.regionName));
|
|
||||||
command.Parameters.Add(database.CreateParameter("uuid", profile.UUID));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionRecvKey", profile.regionRecvKey));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionSecret", profile.regionSecret));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionSendKey", profile.regionSendKey));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionDataURI", profile.regionDataURI));
|
|
||||||
command.Parameters.Add(database.CreateParameter("serverIP", profile.serverIP));
|
|
||||||
command.Parameters.Add(database.CreateParameter("serverPort", profile.serverPort));
|
|
||||||
command.Parameters.Add(database.CreateParameter("serverURI", profile.serverURI));
|
|
||||||
command.Parameters.Add(database.CreateParameter("locX", profile.regionLocX));
|
|
||||||
command.Parameters.Add(database.CreateParameter("locY", profile.regionLocY));
|
|
||||||
command.Parameters.Add(database.CreateParameter("locZ", profile.regionLocZ));
|
|
||||||
command.Parameters.Add(database.CreateParameter("eastOverrideHandle", profile.regionEastOverrideHandle));
|
|
||||||
command.Parameters.Add(database.CreateParameter("westOverrideHandle", profile.regionWestOverrideHandle));
|
|
||||||
command.Parameters.Add(database.CreateParameter("northOverrideHandle", profile.regionNorthOverrideHandle));
|
|
||||||
command.Parameters.Add(database.CreateParameter("southOverrideHandle", profile.regionSouthOverrideHandle));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionAssetURI", profile.regionAssetURI));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionAssetRecvKey", profile.regionAssetRecvKey));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionAssetSendKey", profile.regionAssetSendKey));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionUserURI", profile.regionUserURI));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionUserRecvKey", profile.regionUserRecvKey));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionUserSendKey", profile.regionUserSendKey));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionMapTexture", profile.regionMapTextureID));
|
|
||||||
command.Parameters.Add(database.CreateParameter("serverHttpPort", profile.httpPort));
|
|
||||||
command.Parameters.Add(database.CreateParameter("serverRemotingPort", profile.remotingPort));
|
|
||||||
command.Parameters.Add(database.CreateParameter("owner_uuid", profile.owner_uuid));
|
|
||||||
command.Parameters.Add(database.CreateParameter("originUUID", profile.originUUID));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
command.ExecuteNonQuery();
|
|
||||||
returnval = true;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error("[GRID DB] : Error updating region, error: " + e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a new region in the database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="profile">The region profile to insert</param>
|
|
||||||
/// <returns>Successful?</returns>
|
|
||||||
private bool InsertRegionRow(RegionProfileData profile)
|
|
||||||
{
|
|
||||||
bool returnval = false;
|
|
||||||
|
|
||||||
//Insert new region
|
|
||||||
string sql =
|
|
||||||
"INSERT INTO " + m_regionsTableName + @" ([regionHandle], [regionName], [uuid], [regionRecvKey], [regionSecret], [regionSendKey], [regionDataURI],
|
|
||||||
[serverIP], [serverPort], [serverURI], [locX], [locY], [locZ], [eastOverrideHandle], [westOverrideHandle],
|
|
||||||
[southOverrideHandle], [northOverrideHandle], [regionAssetURI], [regionAssetRecvKey], [regionAssetSendKey],
|
|
||||||
[regionUserURI], [regionUserRecvKey], [regionUserSendKey], [regionMapTexture], [serverHttpPort],
|
|
||||||
[serverRemotingPort], [owner_uuid], [originUUID], [access])
|
|
||||||
VALUES (@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI,
|
|
||||||
@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle,
|
|
||||||
@southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, @regionAssetSendKey,
|
|
||||||
@regionUserURI, @regionUserRecvKey, @regionUserSendKey, @regionMapTexture, @serverHttpPort, @serverRemotingPort, @owner_uuid, @originUUID, @access);";
|
|
||||||
|
|
||||||
using (AutoClosingSqlCommand command = database.Query(sql))
|
|
||||||
{
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionHandle", profile.regionHandle));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionName", profile.regionName));
|
|
||||||
command.Parameters.Add(database.CreateParameter("uuid", profile.UUID));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionRecvKey", profile.regionRecvKey));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionSecret", profile.regionSecret));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionSendKey", profile.regionSendKey));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionDataURI", profile.regionDataURI));
|
|
||||||
command.Parameters.Add(database.CreateParameter("serverIP", profile.serverIP));
|
|
||||||
command.Parameters.Add(database.CreateParameter("serverPort", profile.serverPort));
|
|
||||||
command.Parameters.Add(database.CreateParameter("serverURI", profile.serverURI));
|
|
||||||
command.Parameters.Add(database.CreateParameter("locX", profile.regionLocX));
|
|
||||||
command.Parameters.Add(database.CreateParameter("locY", profile.regionLocY));
|
|
||||||
command.Parameters.Add(database.CreateParameter("locZ", profile.regionLocZ));
|
|
||||||
command.Parameters.Add(database.CreateParameter("eastOverrideHandle", profile.regionEastOverrideHandle));
|
|
||||||
command.Parameters.Add(database.CreateParameter("westOverrideHandle", profile.regionWestOverrideHandle));
|
|
||||||
command.Parameters.Add(database.CreateParameter("northOverrideHandle", profile.regionNorthOverrideHandle));
|
|
||||||
command.Parameters.Add(database.CreateParameter("southOverrideHandle", profile.regionSouthOverrideHandle));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionAssetURI", profile.regionAssetURI));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionAssetRecvKey", profile.regionAssetRecvKey));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionAssetSendKey", profile.regionAssetSendKey));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionUserURI", profile.regionUserURI));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionUserRecvKey", profile.regionUserRecvKey));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionUserSendKey", profile.regionUserSendKey));
|
|
||||||
command.Parameters.Add(database.CreateParameter("regionMapTexture", profile.regionMapTextureID));
|
|
||||||
command.Parameters.Add(database.CreateParameter("serverHttpPort", profile.httpPort));
|
|
||||||
command.Parameters.Add(database.CreateParameter("serverRemotingPort", profile.remotingPort));
|
|
||||||
command.Parameters.Add(database.CreateParameter("owner_uuid", profile.owner_uuid));
|
|
||||||
command.Parameters.Add(database.CreateParameter("originUUID", profile.originUUID));
|
|
||||||
command.Parameters.Add(database.CreateParameter("access", profile.maturity));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
command.ExecuteNonQuery();
|
|
||||||
returnval = true;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error("[GRID DB] : Error inserting region, error: " + e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnval;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,146 +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 log4net;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MSSQL
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// An interface to the log database for MSSQL
|
|
||||||
/// </summary>
|
|
||||||
internal class MSSQLLogData : ILogDataPlugin
|
|
||||||
{
|
|
||||||
private const string _migrationStore = "LogStore";
|
|
||||||
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The database manager
|
|
||||||
/// </summary>
|
|
||||||
public MSSQLManager database;
|
|
||||||
|
|
||||||
[Obsolete("Cannot be default-initialized!")]
|
|
||||||
public void Initialise()
|
|
||||||
{
|
|
||||||
m_log.Info("[LOG DB]: " + Name + " cannot be default-initialized!");
|
|
||||||
throw new PluginNotInitialisedException (Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Artificial constructor called when the plugin is loaded
|
|
||||||
/// </summary>
|
|
||||||
public void Initialise(string connect)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(connect))
|
|
||||||
{
|
|
||||||
database = new MSSQLManager(connect);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO: do something with the connect string
|
|
||||||
IniFile gridDataMSSqlFile = new IniFile("mssql_connection.ini");
|
|
||||||
string settingDataSource = gridDataMSSqlFile.ParseFileReadValue("data_source");
|
|
||||||
string settingInitialCatalog = gridDataMSSqlFile.ParseFileReadValue("initial_catalog");
|
|
||||||
string settingPersistSecurityInfo = gridDataMSSqlFile.ParseFileReadValue("persist_security_info");
|
|
||||||
string settingUserId = gridDataMSSqlFile.ParseFileReadValue("user_id");
|
|
||||||
string settingPassword = gridDataMSSqlFile.ParseFileReadValue("password");
|
|
||||||
|
|
||||||
database =
|
|
||||||
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
|
|
||||||
settingPassword);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Updating mechanisme
|
|
||||||
database.CheckMigration(_migrationStore);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Saves a log item to the database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="serverDaemon">The daemon triggering the event</param>
|
|
||||||
/// <param name="target">The target of the action (region / agent UUID, etc)</param>
|
|
||||||
/// <param name="methodCall">The method call where the problem occured</param>
|
|
||||||
/// <param name="arguments">The arguments passed to the method</param>
|
|
||||||
/// <param name="priority">How critical is this?</param>
|
|
||||||
/// <param name="logMessage">The message to log</param>
|
|
||||||
public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,
|
|
||||||
string logMessage)
|
|
||||||
{
|
|
||||||
string sql = "INSERT INTO logs ([target], [server], [method], [arguments], [priority], [message]) VALUES ";
|
|
||||||
sql += "(@target, @server, @method, @arguments, @priority, @message);";
|
|
||||||
|
|
||||||
using (AutoClosingSqlCommand command = database.Query(sql))
|
|
||||||
{
|
|
||||||
command.Parameters.Add(database.CreateParameter("server", serverDaemon));
|
|
||||||
command.Parameters.Add(database.CreateParameter("target",target));
|
|
||||||
command.Parameters.Add(database.CreateParameter("method", methodCall));
|
|
||||||
command.Parameters.Add(database.CreateParameter("arguments", arguments));
|
|
||||||
command.Parameters.Add(database.CreateParameter("priority", priority.ToString()));
|
|
||||||
command.Parameters.Add(database.CreateParameter("message", logMessage));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
command.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
//Are we not in a loop here
|
|
||||||
m_log.Error("[LOG DB] Error logging : " + e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the name of this DB provider
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string containing the DB provider name</returns>
|
|
||||||
public string Name
|
|
||||||
{
|
|
||||||
get { return "MSSQL Logdata Interface"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Closes the database provider
|
|
||||||
/// </summary>
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
database = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the version of this DB provider
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string containing the provider version</returns>
|
|
||||||
public string Version
|
|
||||||
{
|
|
||||||
get { return "0.1"; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,422 +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.Data;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Threading;
|
|
||||||
using log4net;
|
|
||||||
using MySql.Data.MySqlClient;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MySQL
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A MySQL Interface for the Grid Server
|
|
||||||
/// </summary>
|
|
||||||
public class MySQLGridData : GridDataBase
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
private MySQLManager m_database;
|
|
||||||
private object m_dbLock = new object();
|
|
||||||
private string m_connectionString;
|
|
||||||
|
|
||||||
override public void Initialise()
|
|
||||||
{
|
|
||||||
m_log.Info("[MySQLGridData]: " + Name + " cannot be default-initialized!");
|
|
||||||
throw new PluginNotInitialisedException (Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// <para>Initialises Grid interface</para>
|
|
||||||
/// <para>
|
|
||||||
/// <list type="bullet">
|
|
||||||
/// <item>Loads and initialises the MySQL storage plugin</item>
|
|
||||||
/// <item>Warns and uses the obsolete mysql_connection.ini if connect string is empty.</item>
|
|
||||||
/// <item>Check for migration</item>
|
|
||||||
/// </list>
|
|
||||||
/// </para>
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="connect">connect string.</param>
|
|
||||||
override public void Initialise(string connect)
|
|
||||||
{
|
|
||||||
m_connectionString = connect;
|
|
||||||
m_database = new MySQLManager(connect);
|
|
||||||
|
|
||||||
// This actually does the roll forward assembly stuff
|
|
||||||
Assembly assem = GetType().Assembly;
|
|
||||||
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
Migration m = new Migration(dbcon, assem, "GridStore");
|
|
||||||
m.Update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Shuts down the grid interface
|
|
||||||
/// </summary>
|
|
||||||
override public void Dispose()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the plugin name
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Plugin name</returns>
|
|
||||||
override public string Name
|
|
||||||
{
|
|
||||||
get { return "MySql OpenGridData"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the plugin version
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Plugin version</returns>
|
|
||||||
override public string Version
|
|
||||||
{
|
|
||||||
get { return "0.1"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns all the specified region profiles within coordates -- coordinates are inclusive
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="xmin">Minimum X coordinate</param>
|
|
||||||
/// <param name="ymin">Minimum Y coordinate</param>
|
|
||||||
/// <param name="xmax">Maximum X coordinate</param>
|
|
||||||
/// <param name="ymax">Maximum Y coordinate</param>
|
|
||||||
/// <returns>Array of sim profiles</returns>
|
|
||||||
override public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
|
||||||
param["?xmin"] = xmin.ToString();
|
|
||||||
param["?ymin"] = ymin.ToString();
|
|
||||||
param["?xmax"] = xmax.ToString();
|
|
||||||
param["?ymax"] = ymax.ToString();
|
|
||||||
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
|
|
||||||
using (IDbCommand result = m_database.Query(dbcon,
|
|
||||||
"SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax",
|
|
||||||
param))
|
|
||||||
{
|
|
||||||
using (IDataReader reader = result.ExecuteReader())
|
|
||||||
{
|
|
||||||
RegionProfileData row;
|
|
||||||
|
|
||||||
List<RegionProfileData> rows = new List<RegionProfileData>();
|
|
||||||
|
|
||||||
while ((row = m_database.readSimRow(reader)) != null)
|
|
||||||
rows.Add(row);
|
|
||||||
|
|
||||||
return rows.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns up to maxNum profiles of regions that have a name starting with namePrefix
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name to match against</param>
|
|
||||||
/// <param name="maxNum">Maximum number of profiles to return</param>
|
|
||||||
/// <returns>A list of sim profiles</returns>
|
|
||||||
override public List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
|
||||||
param["?name"] = namePrefix + "%";
|
|
||||||
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
|
|
||||||
using (IDbCommand result = m_database.Query(dbcon,
|
|
||||||
"SELECT * FROM regions WHERE regionName LIKE ?name",
|
|
||||||
param))
|
|
||||||
{
|
|
||||||
using (IDataReader reader = result.ExecuteReader())
|
|
||||||
{
|
|
||||||
RegionProfileData row;
|
|
||||||
|
|
||||||
List<RegionProfileData> rows = new List<RegionProfileData>();
|
|
||||||
|
|
||||||
while (rows.Count < maxNum && (row = m_database.readSimRow(reader)) != null)
|
|
||||||
rows.Add(row);
|
|
||||||
|
|
||||||
return rows;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a sim profile from it's location
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="handle">Region location handle</param>
|
|
||||||
/// <returns>Sim profile</returns>
|
|
||||||
override public RegionProfileData GetProfileByHandle(ulong handle)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
|
||||||
param["?handle"] = handle.ToString();
|
|
||||||
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
|
|
||||||
using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM regions WHERE regionHandle = ?handle", param))
|
|
||||||
{
|
|
||||||
using (IDataReader reader = result.ExecuteReader())
|
|
||||||
{
|
|
||||||
RegionProfileData row = m_database.readSimRow(reader);
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a sim profile from it's UUID
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uuid">The region UUID</param>
|
|
||||||
/// <returns>The sim profile</returns>
|
|
||||||
override public RegionProfileData GetProfileByUUID(UUID uuid)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
|
||||||
param["?uuid"] = uuid.ToString();
|
|
||||||
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
|
|
||||||
using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM regions WHERE uuid = ?uuid", param))
|
|
||||||
{
|
|
||||||
using (IDataReader reader = result.ExecuteReader())
|
|
||||||
{
|
|
||||||
RegionProfileData row = m_database.readSimRow(reader);
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a sim profile from it's Region name string
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>The sim profile</returns>
|
|
||||||
override public RegionProfileData GetProfileByString(string regionName)
|
|
||||||
{
|
|
||||||
if (regionName.Length > 2)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
|
||||||
// Add % because this is a like query.
|
|
||||||
param["?regionName"] = regionName + "%";
|
|
||||||
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
|
|
||||||
// Order by statement will return shorter matches first. Only returns one record or no record.
|
|
||||||
using (IDbCommand result = m_database.Query(dbcon,
|
|
||||||
"SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1",
|
|
||||||
param))
|
|
||||||
{
|
|
||||||
using (IDataReader reader = result.ExecuteReader())
|
|
||||||
{
|
|
||||||
RegionProfileData row = m_database.readSimRow(reader);
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a new profile to the database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="profile">The profile to add</param>
|
|
||||||
/// <returns>Successful?</returns>
|
|
||||||
override public DataResponse StoreProfile(RegionProfileData profile)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (m_database.insertRegion(profile))
|
|
||||||
return DataResponse.RESPONSE_OK;
|
|
||||||
else
|
|
||||||
return DataResponse.RESPONSE_ERROR;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return DataResponse.RESPONSE_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Deletes a sim profile from the database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uuid">the sim UUID</param>
|
|
||||||
/// <returns>Successful?</returns>
|
|
||||||
//public DataResponse DeleteProfile(RegionProfileData profile)
|
|
||||||
override public DataResponse DeleteProfile(string uuid)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (m_database.deleteRegion(uuid))
|
|
||||||
return DataResponse.RESPONSE_OK;
|
|
||||||
else
|
|
||||||
return DataResponse.RESPONSE_ERROR;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return DataResponse.RESPONSE_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// DEPRECATED. Attempts to authenticate a region by comparing a shared secret.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uuid">The UUID of the challenger</param>
|
|
||||||
/// <param name="handle">The attempted regionHandle of the challenger</param>
|
|
||||||
/// <param name="authkey">The secret</param>
|
|
||||||
/// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
|
|
||||||
override public bool AuthenticateSim(UUID uuid, ulong handle, string authkey)
|
|
||||||
{
|
|
||||||
bool throwHissyFit = false; // Should be true by 1.0
|
|
||||||
|
|
||||||
if (throwHissyFit)
|
|
||||||
throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
|
|
||||||
|
|
||||||
RegionProfileData data = GetProfileByUUID(uuid);
|
|
||||||
|
|
||||||
return (handle == data.regionHandle && authkey == data.regionSecret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>This requires a security audit.</remarks>
|
|
||||||
/// <param name="uuid"></param>
|
|
||||||
/// <param name="handle"></param>
|
|
||||||
/// <param name="authhash"></param>
|
|
||||||
/// <param name="challenge"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool AuthenticateSim(UUID uuid, ulong handle, string authhash, string challenge)
|
|
||||||
{
|
|
||||||
// SHA512Managed HashProvider = new SHA512Managed();
|
|
||||||
// Encoding TextProvider = new UTF8Encoding();
|
|
||||||
|
|
||||||
// byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge);
|
|
||||||
// byte[] hash = HashProvider.ComputeHash(stream);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a location reservation
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="x">x coordinate</param>
|
|
||||||
/// <param name="y">y coordinate</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
override public ReservationData GetReservationAtPoint(uint x, uint y)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
|
||||||
param["?x"] = x.ToString();
|
|
||||||
param["?y"] = y.ToString();
|
|
||||||
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
|
|
||||||
using (IDbCommand result = m_database.Query(dbcon,
|
|
||||||
"SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y",
|
|
||||||
param))
|
|
||||||
{
|
|
||||||
using (IDataReader reader = result.ExecuteReader())
|
|
||||||
{
|
|
||||||
ReservationData row = m_database.readReservationRow(reader);
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,166 +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 OpenSim.Framework;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MySQL
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// An interface to the log database for MySQL
|
|
||||||
/// </summary>
|
|
||||||
internal class MySQLLogData : ILogDataPlugin
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The database manager
|
|
||||||
/// </summary>
|
|
||||||
public MySQLManager database;
|
|
||||||
|
|
||||||
public void Initialise()
|
|
||||||
{
|
|
||||||
m_log.Info("[MySQLLogData]: " + Name + " cannot be default-initialized!");
|
|
||||||
throw new PluginNotInitialisedException (Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Artificial constructor called when the plugin is loaded
|
|
||||||
/// Uses the obsolete mysql_connection.ini if connect string is empty.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="connect">connect string</param>
|
|
||||||
public void Initialise(string connect)
|
|
||||||
{
|
|
||||||
if (connect != String.Empty)
|
|
||||||
{
|
|
||||||
database = new MySQLManager(connect);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.xml and we'll use that instead");
|
|
||||||
|
|
||||||
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
|
|
||||||
string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
|
|
||||||
string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
|
|
||||||
string settingUsername = GridDataMySqlFile.ParseFileReadValue("username");
|
|
||||||
string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
|
|
||||||
string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
|
|
||||||
string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
|
|
||||||
|
|
||||||
database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword,
|
|
||||||
settingPooling, settingPort);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This actually does the roll forward assembly stuff
|
|
||||||
Assembly assem = GetType().Assembly;
|
|
||||||
|
|
||||||
using (MySql.Data.MySqlClient.MySqlConnection dbcon = new MySql.Data.MySqlClient.MySqlConnection(connect))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
|
|
||||||
Migration m = new Migration(dbcon, assem, "LogStore");
|
|
||||||
|
|
||||||
// TODO: After rev 6000, remove this. People should have
|
|
||||||
// been rolled onto the new migration code by then.
|
|
||||||
TestTables(m);
|
|
||||||
|
|
||||||
m.Update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary></summary>
|
|
||||||
/// <param name="m"></param>
|
|
||||||
private void TestTables(Migration m)
|
|
||||||
{
|
|
||||||
// under migrations, bail
|
|
||||||
if (m.Version > 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Dictionary<string, string> tableList = new Dictionary<string, string>();
|
|
||||||
tableList["logs"] = null;
|
|
||||||
database.GetTableVersion(tableList);
|
|
||||||
|
|
||||||
// migrations will handle it
|
|
||||||
if (tableList["logs"] == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// we have the table, so pretend like we did the first migration in the past
|
|
||||||
if (m.Version == 0)
|
|
||||||
m.Version = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Saves a log item to the database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="serverDaemon">The daemon triggering the event</param>
|
|
||||||
/// <param name="target">The target of the action (region / agent UUID, etc)</param>
|
|
||||||
/// <param name="methodCall">The method call where the problem occured</param>
|
|
||||||
/// <param name="arguments">The arguments passed to the method</param>
|
|
||||||
/// <param name="priority">How critical is this?</param>
|
|
||||||
/// <param name="logMessage">The message to log</param>
|
|
||||||
public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,
|
|
||||||
string logMessage)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
database.insertLogRow(serverDaemon, target, methodCall, arguments, priority, logMessage);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the name of this DB provider
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string containing the DB provider name</returns>
|
|
||||||
public string Name
|
|
||||||
{
|
|
||||||
get { return "MySQL Logdata Interface";}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Closes the database provider
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>do nothing</remarks>
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
// Do nothing.
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the version of this DB provider
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string containing the provider version</returns>
|
|
||||||
public string Version
|
|
||||||
{
|
|
||||||
get { return "0.1"; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,52 +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.Threading;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MySQL
|
|
||||||
{
|
|
||||||
public class MySQLSuperManager
|
|
||||||
{
|
|
||||||
public bool Locked;
|
|
||||||
private readonly Mutex m_lock = new Mutex(false);
|
|
||||||
public MySQLManager Manager;
|
|
||||||
public string Running;
|
|
||||||
|
|
||||||
public void GetLock()
|
|
||||||
{
|
|
||||||
Locked = true;
|
|
||||||
m_lock.WaitOne();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Release()
|
|
||||||
{
|
|
||||||
m_lock.ReleaseMutex();
|
|
||||||
Locked = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,766 +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.Data;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Threading;
|
|
||||||
using log4net;
|
|
||||||
using MySql.Data.MySqlClient;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MySQL
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A database interface class to a user profile storage system
|
|
||||||
/// </summary>
|
|
||||||
public class MySQLUserData : UserDataBase
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
private MySQLManager m_database;
|
|
||||||
private string m_connectionString;
|
|
||||||
private object m_dbLock = new object();
|
|
||||||
|
|
||||||
public int m_maxConnections = 10;
|
|
||||||
public int m_lastConnect;
|
|
||||||
|
|
||||||
private string m_agentsTableName = "agents";
|
|
||||||
private string m_usersTableName = "users";
|
|
||||||
private string m_userFriendsTableName = "userfriends";
|
|
||||||
private string m_appearanceTableName = "avatarappearance";
|
|
||||||
private string m_attachmentsTableName = "avatarattachments";
|
|
||||||
|
|
||||||
public override void Initialise()
|
|
||||||
{
|
|
||||||
m_log.Info("[MySQLUserData]: " + Name + " cannot be default-initialized!");
|
|
||||||
throw new PluginNotInitialisedException(Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initialise User Interface
|
|
||||||
/// Loads and initialises the MySQL storage plugin
|
|
||||||
/// Warns and uses the obsolete mysql_connection.ini if connect string is empty.
|
|
||||||
/// Checks for migration
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="connect">connect string.</param>
|
|
||||||
public override void Initialise(string connect)
|
|
||||||
{
|
|
||||||
m_connectionString = connect;
|
|
||||||
m_database = new MySQLManager(connect);
|
|
||||||
|
|
||||||
// This actually does the roll forward assembly stuff
|
|
||||||
Assembly assem = GetType().Assembly;
|
|
||||||
|
|
||||||
using (MySql.Data.MySqlClient.MySqlConnection dbcon = new MySql.Data.MySqlClient.MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
Migration m = new Migration(dbcon, assem, "UserStore");
|
|
||||||
m.Update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Dispose()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// see IUserDataPlugin
|
|
||||||
public override UserProfileData GetUserByName(string user, string last)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
|
||||||
param["?first"] = user;
|
|
||||||
param["?second"] = last;
|
|
||||||
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
|
|
||||||
using (IDbCommand result = m_database.Query(dbcon,
|
|
||||||
"SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param))
|
|
||||||
{
|
|
||||||
using (IDataReader reader = result.ExecuteReader())
|
|
||||||
{
|
|
||||||
UserProfileData row = m_database.readUserRow(reader);
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region User Friends List Data
|
|
||||||
|
|
||||||
public override void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
|
|
||||||
{
|
|
||||||
int dtvalue = Util.UnixTimeSinceEpoch();
|
|
||||||
|
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
|
||||||
param["?ownerID"] = friendlistowner.ToString();
|
|
||||||
param["?friendID"] = friend.ToString();
|
|
||||||
param["?friendPerms"] = perms.ToString();
|
|
||||||
param["?datetimestamp"] = dtvalue.ToString();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
|
|
||||||
using (IDbCommand adder = m_database.Query(dbcon,
|
|
||||||
"INSERT INTO `" + m_userFriendsTableName + "` " +
|
|
||||||
"(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
|
|
||||||
"VALUES " +
|
|
||||||
"(?ownerID,?friendID,?friendPerms,?datetimestamp)",
|
|
||||||
param))
|
|
||||||
{
|
|
||||||
adder.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
|
|
||||||
using (IDbCommand adder = m_database.Query(dbcon,
|
|
||||||
"INSERT INTO `" + m_userFriendsTableName + "` " +
|
|
||||||
"(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
|
|
||||||
"VALUES " +
|
|
||||||
"(?friendID,?ownerID,?friendPerms,?datetimestamp)",
|
|
||||||
param))
|
|
||||||
{
|
|
||||||
adder.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void RemoveUserFriend(UUID friendlistowner, UUID friend)
|
|
||||||
{
|
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
|
||||||
param["?ownerID"] = friendlistowner.ToString();
|
|
||||||
param["?friendID"] = friend.ToString();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
|
|
||||||
using (IDbCommand updater = m_database.Query(dbcon,
|
|
||||||
"delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID",
|
|
||||||
param))
|
|
||||||
{
|
|
||||||
updater.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
|
|
||||||
using (IDbCommand updater = m_database.Query(dbcon,
|
|
||||||
"delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID",
|
|
||||||
param))
|
|
||||||
{
|
|
||||||
updater.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
|
|
||||||
{
|
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
|
||||||
param["?ownerID"] = friendlistowner.ToString();
|
|
||||||
param["?friendID"] = friend.ToString();
|
|
||||||
param["?friendPerms"] = perms.ToString();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
|
|
||||||
using (IDbCommand updater = m_database.Query(dbcon,
|
|
||||||
"update " + m_userFriendsTableName +
|
|
||||||
" SET friendPerms = ?friendPerms " +
|
|
||||||
"where ownerID = ?ownerID and friendID = ?friendID",
|
|
||||||
param))
|
|
||||||
{
|
|
||||||
updater.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override List<FriendListItem> GetUserFriendList(UUID friendlistowner)
|
|
||||||
{
|
|
||||||
List<FriendListItem> Lfli = new List<FriendListItem>();
|
|
||||||
|
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
|
||||||
param["?ownerID"] = friendlistowner.ToString();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
|
|
||||||
//Left Join userfriends to itself
|
|
||||||
using (IDbCommand result = m_database.Query(dbcon,
|
|
||||||
"select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " +
|
|
||||||
m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" +
|
|
||||||
" where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID",
|
|
||||||
param))
|
|
||||||
{
|
|
||||||
using (IDataReader reader = result.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
FriendListItem fli = new FriendListItem();
|
|
||||||
fli.FriendListOwner = new UUID((string)reader["ownerID"]);
|
|
||||||
fli.Friend = new UUID((string)reader["friendID"]);
|
|
||||||
fli.FriendPerms = (uint)Convert.ToInt32(reader["friendPerms"]);
|
|
||||||
|
|
||||||
// This is not a real column in the database table, it's a joined column from the opposite record
|
|
||||||
fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]);
|
|
||||||
|
|
||||||
Lfli.Add(fli);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
return Lfli;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Lfli;
|
|
||||||
}
|
|
||||||
|
|
||||||
override public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids)
|
|
||||||
{
|
|
||||||
Dictionary<UUID, FriendRegionInfo> infos = new Dictionary<UUID,FriendRegionInfo>();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
|
|
||||||
foreach (UUID uuid in uuids)
|
|
||||||
{
|
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
|
||||||
param["?uuid"] = uuid.ToString();
|
|
||||||
|
|
||||||
using (IDbCommand result = m_database.Query(dbcon, "select agentOnline,currentHandle from " + m_agentsTableName +
|
|
||||||
" where UUID = ?uuid", param))
|
|
||||||
{
|
|
||||||
using (IDataReader reader = result.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
FriendRegionInfo fri = new FriendRegionInfo();
|
|
||||||
fri.isOnline = (sbyte)reader["agentOnline"] != 0;
|
|
||||||
fri.regionHandle = (ulong)reader["currentHandle"];
|
|
||||||
|
|
||||||
infos[uuid] = fri;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e);
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return infos;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public override List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query)
|
|
||||||
{
|
|
||||||
List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
|
|
||||||
|
|
||||||
Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]");
|
|
||||||
|
|
||||||
string[] querysplit;
|
|
||||||
querysplit = query.Split(' ');
|
|
||||||
if (querysplit.Length > 1 && querysplit[1].Trim() != String.Empty)
|
|
||||||
{
|
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
|
||||||
param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%";
|
|
||||||
param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], String.Empty) + "%";
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
|
|
||||||
using (IDbCommand result = m_database.Query(dbcon,
|
|
||||||
"SELECT UUID,username,lastname FROM " + m_usersTableName +
|
|
||||||
" WHERE username like ?first AND lastname like ?second LIMIT 100",
|
|
||||||
param))
|
|
||||||
{
|
|
||||||
using (IDataReader reader = result.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
AvatarPickerAvatar user = new AvatarPickerAvatar();
|
|
||||||
user.AvatarID = new UUID((string)reader["UUID"]);
|
|
||||||
user.firstName = (string)reader["username"];
|
|
||||||
user.lastName = (string)reader["lastname"];
|
|
||||||
returnlist.Add(user);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
return returnlist;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
|
||||||
param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%";
|
|
||||||
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
|
|
||||||
using (IDbCommand result = m_database.Query(dbcon,
|
|
||||||
"SELECT UUID,username,lastname FROM " + m_usersTableName +
|
|
||||||
" WHERE username like ?first OR lastname like ?first LIMIT 100",
|
|
||||||
param))
|
|
||||||
{
|
|
||||||
using (IDataReader reader = result.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
AvatarPickerAvatar user = new AvatarPickerAvatar();
|
|
||||||
user.AvatarID = new UUID((string)reader["UUID"]);
|
|
||||||
user.firstName = (string)reader["username"];
|
|
||||||
user.lastName = (string)reader["lastname"];
|
|
||||||
returnlist.Add(user);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
return returnlist;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return returnlist;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// See IUserDataPlugin
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uuid">User UUID</param>
|
|
||||||
/// <returns>User profile data</returns>
|
|
||||||
public override UserProfileData GetUserByUUID(UUID uuid)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
|
||||||
param["?uuid"] = uuid.ToString();
|
|
||||||
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
|
|
||||||
using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param))
|
|
||||||
{
|
|
||||||
using (IDataReader reader = result.ExecuteReader())
|
|
||||||
{
|
|
||||||
UserProfileData row = m_database.readUserRow(reader);
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a user session searching by name
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The account name : "Username Lastname"</param>
|
|
||||||
/// <returns>The users session</returns>
|
|
||||||
public override UserAgentData GetAgentByName(string name)
|
|
||||||
{
|
|
||||||
return GetAgentByName(name.Split(' ')[0], name.Split(' ')[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a user session by account name
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="user">First part of the users account name</param>
|
|
||||||
/// <param name="last">Second part of the users account name</param>
|
|
||||||
/// <returns>The users session</returns>
|
|
||||||
public override UserAgentData GetAgentByName(string user, string last)
|
|
||||||
{
|
|
||||||
UserProfileData profile = GetUserByName(user, last);
|
|
||||||
return GetAgentByUUID(profile.ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="AgentID"></param>
|
|
||||||
/// <param name="WebLoginKey"></param>
|
|
||||||
/// <remarks>is it still used ?</remarks>
|
|
||||||
public override void StoreWebLoginKey(UUID AgentID, UUID WebLoginKey)
|
|
||||||
{
|
|
||||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
|
||||||
param["?UUID"] = AgentID.ToString();
|
|
||||||
param["?webLoginKey"] = WebLoginKey.ToString();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
m_database.ExecuteParameterizedSql(
|
|
||||||
"update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " +
|
|
||||||
"where UUID = ?UUID",
|
|
||||||
param);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns an agent session by account UUID
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uuid">The accounts UUID</param>
|
|
||||||
/// <returns>The users session</returns>
|
|
||||||
public override UserAgentData GetAgentByUUID(UUID uuid)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
|
||||||
param["?uuid"] = uuid.ToString();
|
|
||||||
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
|
|
||||||
using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", param))
|
|
||||||
{
|
|
||||||
using (IDataReader reader = result.ExecuteReader())
|
|
||||||
{
|
|
||||||
UserAgentData row = m_database.readAgentRow(reader);
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a new users profile
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="user">The user profile to create</param>
|
|
||||||
public override void AddNewUserProfile(UserProfileData user)
|
|
||||||
{
|
|
||||||
UUID zero = UUID.Zero;
|
|
||||||
if (user.ID == zero)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
m_database.insertUserRow(
|
|
||||||
user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt,
|
|
||||||
user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y,
|
|
||||||
user.HomeLocation.Z,
|
|
||||||
user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created,
|
|
||||||
user.LastLogin, user.UserInventoryURI, user.UserAssetURI,
|
|
||||||
user.CanDoMask, user.WantDoMask,
|
|
||||||
user.AboutText, user.FirstLifeAboutText, user.Image,
|
|
||||||
user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a new agent
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="agent">The agent to create</param>
|
|
||||||
public override void AddNewUserAgent(UserAgentData agent)
|
|
||||||
{
|
|
||||||
UUID zero = UUID.Zero;
|
|
||||||
if (agent.ProfileID == zero || agent.SessionID == zero)
|
|
||||||
return;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
m_database.insertAgentRow(agent);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates a user profile stored in the DB
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="user">The profile data to use to update the DB</param>
|
|
||||||
public override bool UpdateUserProfile(UserProfileData user)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
m_database.updateUserRow(
|
|
||||||
user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt,
|
|
||||||
user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y,
|
|
||||||
user.HomeLocation.Z, user.HomeLookAt.X,
|
|
||||||
user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin,
|
|
||||||
user.UserInventoryURI,
|
|
||||||
user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText,
|
|
||||||
user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey,
|
|
||||||
user.UserFlags, user.GodLevel, user.CustomType, user.Partner);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Performs a money transfer request between two accounts
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="from">The senders account ID</param>
|
|
||||||
/// <param name="to">The receivers account ID</param>
|
|
||||||
/// <param name="amount">The amount to transfer</param>
|
|
||||||
/// <returns>Success?</returns>
|
|
||||||
public override bool MoneyTransferRequest(UUID from, UUID to, uint amount)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Performs an inventory transfer request between two accounts
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>TODO: Move to inventory server</remarks>
|
|
||||||
/// <param name="from">The senders account ID</param>
|
|
||||||
/// <param name="to">The receivers account ID</param>
|
|
||||||
/// <param name="item">The item to transfer</param>
|
|
||||||
/// <returns>Success?</returns>
|
|
||||||
public override bool InventoryTransferRequest(UUID from, UUID to, UUID item)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override AvatarAppearance GetUserAppearance(UUID user)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
|
||||||
param["?owner"] = user.ToString();
|
|
||||||
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
|
|
||||||
using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param))
|
|
||||||
{
|
|
||||||
using (IDataReader reader = result.ExecuteReader())
|
|
||||||
{
|
|
||||||
AvatarAppearance appearance = m_database.readAppearanceRow(reader);
|
|
||||||
|
|
||||||
if (appearance == null)
|
|
||||||
{
|
|
||||||
m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
appearance.SetAttachments(GetUserAttachments(user));
|
|
||||||
return appearance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates an avatar appearence
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="user">The user UUID</param>
|
|
||||||
/// <param name="appearance">The avatar appearance</param>
|
|
||||||
// override
|
|
||||||
public override void UpdateUserAppearance(UUID user, AvatarAppearance appearance)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
appearance.Owner = user;
|
|
||||||
m_database.insertAppearanceRow(appearance);
|
|
||||||
|
|
||||||
UpdateUserAttachments(user, appearance.GetAttachments());
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Database provider name
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Provider name</returns>
|
|
||||||
public override string Name
|
|
||||||
{
|
|
||||||
get { return "MySQL Userdata Interface"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Database provider version
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>provider version</returns>
|
|
||||||
public override string Version
|
|
||||||
{
|
|
||||||
get { return "0.1"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public Hashtable GetUserAttachments(UUID agentID)
|
|
||||||
{
|
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
|
||||||
param["?uuid"] = agentID.ToString();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
|
|
||||||
using (IDbCommand result = m_database.Query(dbcon,
|
|
||||||
"SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param))
|
|
||||||
{
|
|
||||||
using (IDataReader reader = result.ExecuteReader())
|
|
||||||
{
|
|
||||||
Hashtable ret = m_database.readAttachments(reader);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateUserAttachments(UUID agentID, Hashtable data)
|
|
||||||
{
|
|
||||||
m_database.writeAttachments(agentID, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void ResetAttachments(UUID userID)
|
|
||||||
{
|
|
||||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
|
||||||
param["?uuid"] = userID.ToString();
|
|
||||||
|
|
||||||
m_database.ExecuteParameterizedSql(
|
|
||||||
"UPDATE " + m_attachmentsTableName +
|
|
||||||
" SET asset = '00000000-0000-0000-0000-000000000000' WHERE UUID = ?uuid",
|
|
||||||
param);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void LogoutUsers(UUID regionID)
|
|
||||||
{
|
|
||||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
|
||||||
param["?regionID"] = regionID.ToString();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
m_database.ExecuteParameterizedSql(
|
|
||||||
"update " + m_agentsTableName + " SET agentOnline = 0 " +
|
|
||||||
"where currentRegion = ?regionID",
|
|
||||||
param);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.Message, e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -31,6 +31,7 @@ using OpenSim.Data.Tests;
|
||||||
using log4net;
|
using log4net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using OpenSim.Tests.Common;
|
using OpenSim.Tests.Common;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
|
||||||
namespace OpenSim.Data.MySQL.Tests
|
namespace OpenSim.Data.MySQL.Tests
|
||||||
{
|
{
|
||||||
|
@ -39,7 +40,7 @@ namespace OpenSim.Data.MySQL.Tests
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
public string file;
|
public string file;
|
||||||
public MySQLManager database;
|
private string m_connectionString;
|
||||||
public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;";
|
public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;";
|
||||||
|
|
||||||
[TestFixtureSetUp]
|
[TestFixtureSetUp]
|
||||||
|
@ -52,7 +53,6 @@ namespace OpenSim.Data.MySQL.Tests
|
||||||
// tests.
|
// tests.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
database = new MySQLManager(connect);
|
|
||||||
db = new MySQLAssetData();
|
db = new MySQLAssetData();
|
||||||
db.Initialise(connect);
|
db.Initialise(connect);
|
||||||
}
|
}
|
||||||
|
@ -70,10 +70,22 @@ namespace OpenSim.Data.MySQL.Tests
|
||||||
{
|
{
|
||||||
db.Dispose();
|
db.Dispose();
|
||||||
}
|
}
|
||||||
if (database != null)
|
ExecuteSql("drop table migrations");
|
||||||
|
ExecuteSql("drop table assets");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a MySqlCommand
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql">sql string to execute</param>
|
||||||
|
private void ExecuteSql(string sql)
|
||||||
{
|
{
|
||||||
database.ExecuteSql("drop table migrations");
|
using (MySqlConnection dbcon = new MySqlConnection(connect))
|
||||||
database.ExecuteSql("drop table assets");
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
|
||||||
|
MySqlCommand cmd = new MySqlCommand(sql, dbcon);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@ using OpenSim.Data.Tests;
|
||||||
using log4net;
|
using log4net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using OpenSim.Tests.Common;
|
using OpenSim.Tests.Common;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MySQL.Tests
|
namespace OpenSim.Data.MySQL.Tests
|
||||||
{
|
{
|
||||||
|
@ -39,7 +41,6 @@ namespace OpenSim.Data.MySQL.Tests
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
public string file;
|
public string file;
|
||||||
public MySQLManager database;
|
|
||||||
public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;";
|
public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;";
|
||||||
|
|
||||||
[TestFixtureSetUp]
|
[TestFixtureSetUp]
|
||||||
|
@ -52,9 +53,8 @@ namespace OpenSim.Data.MySQL.Tests
|
||||||
// tests.
|
// tests.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
database = new MySQLManager(connect);
|
|
||||||
// clear db incase to ensure we are in a clean state
|
// clear db incase to ensure we are in a clean state
|
||||||
ClearDB(database);
|
ClearDB();
|
||||||
|
|
||||||
regionDb = new MySQLDataStore();
|
regionDb = new MySQLDataStore();
|
||||||
regionDb.Initialise(connect);
|
regionDb.Initialise(connect);
|
||||||
|
@ -75,29 +75,41 @@ namespace OpenSim.Data.MySQL.Tests
|
||||||
{
|
{
|
||||||
regionDb.Dispose();
|
regionDb.Dispose();
|
||||||
}
|
}
|
||||||
ClearDB(database);
|
ClearDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClearDB(MySQLManager manager)
|
private void ClearDB()
|
||||||
{
|
{
|
||||||
// if a new table is added, it has to be dropped here
|
// if a new table is added, it has to be dropped here
|
||||||
if (manager != null)
|
ExecuteSql("drop table if exists migrations");
|
||||||
|
ExecuteSql("drop table if exists prims");
|
||||||
|
ExecuteSql("drop table if exists primshapes");
|
||||||
|
ExecuteSql("drop table if exists primitems");
|
||||||
|
ExecuteSql("drop table if exists terrain");
|
||||||
|
ExecuteSql("drop table if exists land");
|
||||||
|
ExecuteSql("drop table if exists landaccesslist");
|
||||||
|
ExecuteSql("drop table if exists regionban");
|
||||||
|
ExecuteSql("drop table if exists regionsettings");
|
||||||
|
ExecuteSql("drop table if exists estate_managers");
|
||||||
|
ExecuteSql("drop table if exists estate_groups");
|
||||||
|
ExecuteSql("drop table if exists estate_users");
|
||||||
|
ExecuteSql("drop table if exists estateban");
|
||||||
|
ExecuteSql("drop table if exists estate_settings");
|
||||||
|
ExecuteSql("drop table if exists estate_map");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a MySqlCommand
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql">sql string to execute</param>
|
||||||
|
private void ExecuteSql(string sql)
|
||||||
{
|
{
|
||||||
manager.ExecuteSql("drop table if exists migrations");
|
using (MySqlConnection dbcon = new MySqlConnection(connect))
|
||||||
manager.ExecuteSql("drop table if exists prims");
|
{
|
||||||
manager.ExecuteSql("drop table if exists primshapes");
|
dbcon.Open();
|
||||||
manager.ExecuteSql("drop table if exists primitems");
|
|
||||||
manager.ExecuteSql("drop table if exists terrain");
|
MySqlCommand cmd = new MySqlCommand(sql, dbcon);
|
||||||
manager.ExecuteSql("drop table if exists land");
|
cmd.ExecuteNonQuery();
|
||||||
manager.ExecuteSql("drop table if exists landaccesslist");
|
|
||||||
manager.ExecuteSql("drop table if exists regionban");
|
|
||||||
manager.ExecuteSql("drop table if exists regionsettings");
|
|
||||||
manager.ExecuteSql("drop table if exists estate_managers");
|
|
||||||
manager.ExecuteSql("drop table if exists estate_groups");
|
|
||||||
manager.ExecuteSql("drop table if exists estate_users");
|
|
||||||
manager.ExecuteSql("drop table if exists estateban");
|
|
||||||
manager.ExecuteSql("drop table if exists estate_settings");
|
|
||||||
manager.ExecuteSql("drop table if exists estate_map");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,94 +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 NUnit.Framework;
|
|
||||||
using OpenSim.Data.Tests;
|
|
||||||
using log4net;
|
|
||||||
using System.Reflection;
|
|
||||||
using OpenSim.Tests.Common;
|
|
||||||
using MySql.Data.MySqlClient;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MySQL.Tests
|
|
||||||
{
|
|
||||||
[TestFixture, DatabaseTest]
|
|
||||||
public class MySQLGridTest : BasicGridTest
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
public string file;
|
|
||||||
public MySQLManager database;
|
|
||||||
public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;";
|
|
||||||
|
|
||||||
[TestFixtureSetUp]
|
|
||||||
public void Init()
|
|
||||||
{
|
|
||||||
SuperInit();
|
|
||||||
// If we manage to connect to the database with the user
|
|
||||||
// and password above it is our test database, and run
|
|
||||||
// these tests. If anything goes wrong, ignore these
|
|
||||||
// tests.
|
|
||||||
try
|
|
||||||
{
|
|
||||||
database = new MySQLManager(connect);
|
|
||||||
db = new MySQLGridData();
|
|
||||||
db.Initialise(connect);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error("Exception {0}", e);
|
|
||||||
Assert.Ignore();
|
|
||||||
}
|
|
||||||
|
|
||||||
// This actually does the roll forward assembly stuff
|
|
||||||
Assembly assem = GetType().Assembly;
|
|
||||||
|
|
||||||
using (MySqlConnection dbcon = new MySqlConnection(connect))
|
|
||||||
{
|
|
||||||
dbcon.Open();
|
|
||||||
Migration m = new Migration(dbcon, assem, "AssetStore");
|
|
||||||
m.Update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestFixtureTearDown]
|
|
||||||
public void Cleanup()
|
|
||||||
{
|
|
||||||
m_log.Warn("Cleaning up.");
|
|
||||||
if (db != null)
|
|
||||||
{
|
|
||||||
db.Dispose();
|
|
||||||
}
|
|
||||||
// if a new table is added, it has to be dropped here
|
|
||||||
if (database != null)
|
|
||||||
{
|
|
||||||
database.ExecuteSql("drop table migrations");
|
|
||||||
database.ExecuteSql("drop table regions");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -31,6 +31,8 @@ using OpenSim.Data.Tests;
|
||||||
using log4net;
|
using log4net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using OpenSim.Tests.Common;
|
using OpenSim.Tests.Common;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MySQL.Tests
|
namespace OpenSim.Data.MySQL.Tests
|
||||||
{
|
{
|
||||||
|
@ -39,7 +41,6 @@ namespace OpenSim.Data.MySQL.Tests
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
public string file;
|
public string file;
|
||||||
public MySQLManager database;
|
|
||||||
public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;";
|
public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;";
|
||||||
|
|
||||||
[TestFixtureSetUp]
|
[TestFixtureSetUp]
|
||||||
|
@ -52,7 +53,6 @@ namespace OpenSim.Data.MySQL.Tests
|
||||||
// tests.
|
// tests.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
database = new MySQLManager(connect);
|
|
||||||
DropTables();
|
DropTables();
|
||||||
db = new MySQLInventoryData();
|
db = new MySQLInventoryData();
|
||||||
db.Initialise(connect);
|
db.Initialise(connect);
|
||||||
|
@ -71,17 +71,29 @@ namespace OpenSim.Data.MySQL.Tests
|
||||||
{
|
{
|
||||||
db.Dispose();
|
db.Dispose();
|
||||||
}
|
}
|
||||||
if (database != null)
|
|
||||||
{
|
|
||||||
DropTables();
|
DropTables();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void DropTables()
|
private void DropTables()
|
||||||
{
|
{
|
||||||
database.ExecuteSql("drop table IF EXISTS inventoryitems");
|
ExecuteSql("drop table IF EXISTS inventoryitems");
|
||||||
database.ExecuteSql("drop table IF EXISTS inventoryfolders");
|
ExecuteSql("drop table IF EXISTS inventoryfolders");
|
||||||
database.ExecuteSql("drop table IF EXISTS migrations");
|
ExecuteSql("drop table IF EXISTS migrations");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a MySqlCommand
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql">sql string to execute</param>
|
||||||
|
private void ExecuteSql(string sql)
|
||||||
|
{
|
||||||
|
using (MySqlConnection dbcon = new MySqlConnection(connect))
|
||||||
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
|
||||||
|
MySqlCommand cmd = new MySqlCommand(sql, dbcon);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ using OpenSim.Data.Tests;
|
||||||
using log4net;
|
using log4net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using OpenSim.Tests.Common;
|
using OpenSim.Tests.Common;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
|
||||||
namespace OpenSim.Data.MySQL.Tests
|
namespace OpenSim.Data.MySQL.Tests
|
||||||
{
|
{
|
||||||
|
@ -39,7 +40,6 @@ namespace OpenSim.Data.MySQL.Tests
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
public string file;
|
public string file;
|
||||||
public MySQLManager database;
|
|
||||||
public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;";
|
public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;";
|
||||||
|
|
||||||
[TestFixtureSetUp]
|
[TestFixtureSetUp]
|
||||||
|
@ -52,9 +52,8 @@ namespace OpenSim.Data.MySQL.Tests
|
||||||
// tests.
|
// tests.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
database = new MySQLManager(connect);
|
|
||||||
// this is important in case a previous run ended badly
|
// this is important in case a previous run ended badly
|
||||||
ClearDB(database);
|
ClearDB();
|
||||||
|
|
||||||
db = new MySQLDataStore();
|
db = new MySQLDataStore();
|
||||||
db.Initialise(connect);
|
db.Initialise(connect);
|
||||||
|
@ -73,28 +72,40 @@ namespace OpenSim.Data.MySQL.Tests
|
||||||
{
|
{
|
||||||
db.Dispose();
|
db.Dispose();
|
||||||
}
|
}
|
||||||
ClearDB(database);
|
ClearDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClearDB(MySQLManager manager)
|
private void ClearDB()
|
||||||
{
|
{
|
||||||
if (manager != null)
|
ExecuteSql("drop table if exists migrations");
|
||||||
|
ExecuteSql("drop table if exists prims");
|
||||||
|
ExecuteSql("drop table if exists primshapes");
|
||||||
|
ExecuteSql("drop table if exists primitems");
|
||||||
|
ExecuteSql("drop table if exists terrain");
|
||||||
|
ExecuteSql("drop table if exists land");
|
||||||
|
ExecuteSql("drop table if exists landaccesslist");
|
||||||
|
ExecuteSql("drop table if exists regionban");
|
||||||
|
ExecuteSql("drop table if exists regionsettings");
|
||||||
|
ExecuteSql("drop table if exists estate_managers");
|
||||||
|
ExecuteSql("drop table if exists estate_groups");
|
||||||
|
ExecuteSql("drop table if exists estate_users");
|
||||||
|
ExecuteSql("drop table if exists estateban");
|
||||||
|
ExecuteSql("drop table if exists estate_settings");
|
||||||
|
ExecuteSql("drop table if exists estate_map");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a MySqlCommand
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql">sql string to execute</param>
|
||||||
|
private void ExecuteSql(string sql)
|
||||||
{
|
{
|
||||||
manager.ExecuteSql("drop table if exists migrations");
|
using (MySqlConnection dbcon = new MySqlConnection(connect))
|
||||||
manager.ExecuteSql("drop table if exists prims");
|
{
|
||||||
manager.ExecuteSql("drop table if exists primshapes");
|
dbcon.Open();
|
||||||
manager.ExecuteSql("drop table if exists primitems");
|
|
||||||
manager.ExecuteSql("drop table if exists terrain");
|
MySqlCommand cmd = new MySqlCommand(sql, dbcon);
|
||||||
manager.ExecuteSql("drop table if exists land");
|
cmd.ExecuteNonQuery();
|
||||||
manager.ExecuteSql("drop table if exists landaccesslist");
|
|
||||||
manager.ExecuteSql("drop table if exists regionban");
|
|
||||||
manager.ExecuteSql("drop table if exists regionsettings");
|
|
||||||
manager.ExecuteSql("drop table if exists estate_managers");
|
|
||||||
manager.ExecuteSql("drop table if exists estate_groups");
|
|
||||||
manager.ExecuteSql("drop table if exists estate_users");
|
|
||||||
manager.ExecuteSql("drop table if exists estateban");
|
|
||||||
manager.ExecuteSql("drop table if exists estate_settings");
|
|
||||||
manager.ExecuteSql("drop table if exists estate_map");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ namespace OpenSim.Data.Null
|
||||||
public NullPresenceData(string connectionString, string realm)
|
public NullPresenceData(string connectionString, string realm)
|
||||||
{
|
{
|
||||||
if (Instance == null)
|
if (Instance == null)
|
||||||
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
|
||||||
//Console.WriteLine("[XXX] NullRegionData constructor");
|
//Console.WriteLine("[XXX] NullRegionData constructor");
|
||||||
|
@ -51,9 +52,10 @@ namespace OpenSim.Data.Null
|
||||||
p.SessionID = UUID.Zero;
|
p.SessionID = UUID.Zero;
|
||||||
p.UserID = UUID.Zero.ToString();
|
p.UserID = UUID.Zero.ToString();
|
||||||
p.Data = new Dictionary<string, string>();
|
p.Data = new Dictionary<string, string>();
|
||||||
p.Data["Online"] = "true";
|
p.Data["Online"] = true.ToString();
|
||||||
m_presenceData.Add(UUID.Zero, p);
|
m_presenceData.Add(UUID.Zero, p);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool Store(PresenceData data)
|
public bool Store(PresenceData data)
|
||||||
{
|
{
|
||||||
|
@ -70,7 +72,9 @@ namespace OpenSim.Data.Null
|
||||||
return Instance.Get(sessionID);
|
return Instance.Get(sessionID);
|
||||||
|
|
||||||
if (m_presenceData.ContainsKey(sessionID))
|
if (m_presenceData.ContainsKey(sessionID))
|
||||||
|
{
|
||||||
return m_presenceData[sessionID];
|
return m_presenceData[sessionID];
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,337 +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 Nwc.XmlRpc;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
|
|
||||||
namespace OpenSim.Data
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A class which contains information known to the grid server about a region
|
|
||||||
/// </summary>
|
|
||||||
[Serializable]
|
|
||||||
public class RegionProfileData
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The name of the region
|
|
||||||
/// </summary>
|
|
||||||
public string regionName = String.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A 64-bit number combining map position into a (mostly) unique ID
|
|
||||||
/// </summary>
|
|
||||||
public ulong regionHandle;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// OGS/OpenSim Specific ID for a region
|
|
||||||
/// </summary>
|
|
||||||
public UUID UUID;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Coordinates of the region
|
|
||||||
/// </summary>
|
|
||||||
public uint regionLocX;
|
|
||||||
public uint regionLocY;
|
|
||||||
public uint regionLocZ; // Reserved (round-robin, layers, etc)
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Authentication secrets
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>Not very secure, needs improvement.</remarks>
|
|
||||||
public string regionSendKey = String.Empty;
|
|
||||||
public string regionRecvKey = String.Empty;
|
|
||||||
public string regionSecret = String.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether the region is online
|
|
||||||
/// </summary>
|
|
||||||
public bool regionOnline;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Information about the server that the region is currently hosted on
|
|
||||||
/// </summary>
|
|
||||||
public string serverIP = String.Empty;
|
|
||||||
public uint serverPort;
|
|
||||||
public string serverURI = String.Empty;
|
|
||||||
|
|
||||||
public uint httpPort;
|
|
||||||
public uint remotingPort;
|
|
||||||
public string httpServerURI = String.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Set of optional overrides. Can be used to create non-eulicidean spaces.
|
|
||||||
/// </summary>
|
|
||||||
public ulong regionNorthOverrideHandle;
|
|
||||||
public ulong regionSouthOverrideHandle;
|
|
||||||
public ulong regionEastOverrideHandle;
|
|
||||||
public ulong regionWestOverrideHandle;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Optional: URI Location of the region database
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>Used for floating sim pools where the region data is not nessecarily coupled to a specific server</remarks>
|
|
||||||
public string regionDataURI = String.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Region Asset Details
|
|
||||||
/// </summary>
|
|
||||||
public string regionAssetURI = String.Empty;
|
|
||||||
|
|
||||||
public string regionAssetSendKey = String.Empty;
|
|
||||||
public string regionAssetRecvKey = String.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Region Userserver Details
|
|
||||||
/// </summary>
|
|
||||||
public string regionUserURI = String.Empty;
|
|
||||||
|
|
||||||
public string regionUserSendKey = String.Empty;
|
|
||||||
public string regionUserRecvKey = String.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Region Map Texture Asset
|
|
||||||
/// </summary>
|
|
||||||
public UUID regionMapTextureID = new UUID("00000000-0000-1111-9999-000000000006");
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// this particular mod to the file provides support within the spec for RegionProfileData for the
|
|
||||||
/// owner_uuid for the region
|
|
||||||
/// </summary>
|
|
||||||
public UUID owner_uuid = UUID.Zero;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// OGS/OpenSim Specific original ID for a region after move/split
|
|
||||||
/// </summary>
|
|
||||||
public UUID originUUID;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The Maturity rating of the region
|
|
||||||
/// </summary>
|
|
||||||
public uint maturity;
|
|
||||||
|
|
||||||
//Data Wrappers
|
|
||||||
public string RegionName
|
|
||||||
{
|
|
||||||
get { return regionName; }
|
|
||||||
set { regionName = value; }
|
|
||||||
}
|
|
||||||
public ulong RegionHandle
|
|
||||||
{
|
|
||||||
get { return regionHandle; }
|
|
||||||
set { regionHandle = value; }
|
|
||||||
}
|
|
||||||
public UUID Uuid
|
|
||||||
{
|
|
||||||
get { return UUID; }
|
|
||||||
set { UUID = value; }
|
|
||||||
}
|
|
||||||
public uint RegionLocX
|
|
||||||
{
|
|
||||||
get { return regionLocX; }
|
|
||||||
set { regionLocX = value; }
|
|
||||||
}
|
|
||||||
public uint RegionLocY
|
|
||||||
{
|
|
||||||
get { return regionLocY; }
|
|
||||||
set { regionLocY = value; }
|
|
||||||
}
|
|
||||||
public uint RegionLocZ
|
|
||||||
{
|
|
||||||
get { return regionLocZ; }
|
|
||||||
set { regionLocZ = value; }
|
|
||||||
}
|
|
||||||
public string RegionSendKey
|
|
||||||
{
|
|
||||||
get { return regionSendKey; }
|
|
||||||
set { regionSendKey = value; }
|
|
||||||
}
|
|
||||||
public string RegionRecvKey
|
|
||||||
{
|
|
||||||
get { return regionRecvKey; }
|
|
||||||
set { regionRecvKey = value; }
|
|
||||||
}
|
|
||||||
public string RegionSecret
|
|
||||||
{
|
|
||||||
get { return regionSecret; }
|
|
||||||
set { regionSecret = value; }
|
|
||||||
}
|
|
||||||
public bool RegionOnline
|
|
||||||
{
|
|
||||||
get { return regionOnline; }
|
|
||||||
set { regionOnline = value; }
|
|
||||||
}
|
|
||||||
public string ServerIP
|
|
||||||
{
|
|
||||||
get { return serverIP; }
|
|
||||||
set { serverIP = value; }
|
|
||||||
}
|
|
||||||
public uint ServerPort
|
|
||||||
{
|
|
||||||
get { return serverPort; }
|
|
||||||
set { serverPort = value; }
|
|
||||||
}
|
|
||||||
public string ServerURI
|
|
||||||
{
|
|
||||||
get { return serverURI; }
|
|
||||||
set { serverURI = value; }
|
|
||||||
}
|
|
||||||
public uint ServerHttpPort
|
|
||||||
{
|
|
||||||
get { return httpPort; }
|
|
||||||
set { httpPort = value; }
|
|
||||||
}
|
|
||||||
public uint ServerRemotingPort
|
|
||||||
{
|
|
||||||
get { return remotingPort; }
|
|
||||||
set { remotingPort = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public ulong NorthOverrideHandle
|
|
||||||
{
|
|
||||||
get { return regionNorthOverrideHandle; }
|
|
||||||
set { regionNorthOverrideHandle = value; }
|
|
||||||
}
|
|
||||||
public ulong SouthOverrideHandle
|
|
||||||
{
|
|
||||||
get { return regionSouthOverrideHandle; }
|
|
||||||
set { regionSouthOverrideHandle = value; }
|
|
||||||
}
|
|
||||||
public ulong EastOverrideHandle
|
|
||||||
{
|
|
||||||
get { return regionEastOverrideHandle; }
|
|
||||||
set { regionEastOverrideHandle = value; }
|
|
||||||
}
|
|
||||||
public ulong WestOverrideHandle
|
|
||||||
{
|
|
||||||
get { return regionWestOverrideHandle; }
|
|
||||||
set { regionWestOverrideHandle = value; }
|
|
||||||
}
|
|
||||||
public string RegionDataURI
|
|
||||||
{
|
|
||||||
get { return regionDataURI; }
|
|
||||||
set { regionDataURI = value; }
|
|
||||||
}
|
|
||||||
public string RegionAssetURI
|
|
||||||
{
|
|
||||||
get { return regionAssetURI; }
|
|
||||||
set { regionAssetURI = value; }
|
|
||||||
}
|
|
||||||
public string RegionAssetSendKey
|
|
||||||
{
|
|
||||||
get { return regionAssetSendKey; }
|
|
||||||
set { regionAssetSendKey = value; }
|
|
||||||
}
|
|
||||||
public string RegionAssetRecvKey
|
|
||||||
{
|
|
||||||
get { return regionAssetRecvKey; }
|
|
||||||
set { regionAssetRecvKey = value; }
|
|
||||||
}
|
|
||||||
public string RegionUserURI
|
|
||||||
{
|
|
||||||
get { return regionUserURI; }
|
|
||||||
set { regionUserURI = value; }
|
|
||||||
}
|
|
||||||
public string RegionUserSendKey
|
|
||||||
{
|
|
||||||
get { return regionUserSendKey; }
|
|
||||||
set { regionUserSendKey = value; }
|
|
||||||
}
|
|
||||||
public string RegionUserRecvKey
|
|
||||||
{
|
|
||||||
get { return regionUserRecvKey; }
|
|
||||||
set { regionUserRecvKey = value; }
|
|
||||||
}
|
|
||||||
public UUID RegionMapTextureID
|
|
||||||
{
|
|
||||||
get { return regionMapTextureID; }
|
|
||||||
set { regionMapTextureID = value; }
|
|
||||||
}
|
|
||||||
public UUID Owner_uuid
|
|
||||||
{
|
|
||||||
get { return owner_uuid; }
|
|
||||||
set { owner_uuid = value; }
|
|
||||||
}
|
|
||||||
public UUID OriginUUID
|
|
||||||
{
|
|
||||||
get { return originUUID; }
|
|
||||||
set { originUUID = value; }
|
|
||||||
}
|
|
||||||
public uint Maturity
|
|
||||||
{
|
|
||||||
get { return maturity; }
|
|
||||||
set { maturity = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte AccessLevel
|
|
||||||
{
|
|
||||||
get { return Util.ConvertMaturityToAccessLevel(maturity); }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public RegionInfo ToRegionInfo()
|
|
||||||
{
|
|
||||||
return RegionInfo.Create(UUID, regionName, regionLocX, regionLocY, serverIP, httpPort, serverPort, remotingPort, serverURI);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RegionProfileData FromRegionInfo(RegionInfo regionInfo)
|
|
||||||
{
|
|
||||||
if (regionInfo == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Create(regionInfo.RegionID, regionInfo.RegionName, regionInfo.RegionLocX,
|
|
||||||
regionInfo.RegionLocY, regionInfo.ExternalHostName,
|
|
||||||
(uint) regionInfo.ExternalEndPoint.Port, regionInfo.HttpPort, regionInfo.RemotingPort,
|
|
||||||
regionInfo.ServerURI, regionInfo.AccessLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RegionProfileData Create(UUID regionID, string regionName, uint locX, uint locY, string externalHostName, uint regionPort, uint httpPort, uint remotingPort, string serverUri, byte access)
|
|
||||||
{
|
|
||||||
RegionProfileData regionProfile;
|
|
||||||
regionProfile = new RegionProfileData();
|
|
||||||
regionProfile.regionLocX = locX;
|
|
||||||
regionProfile.regionLocY = locY;
|
|
||||||
regionProfile.regionHandle =
|
|
||||||
Utils.UIntsToLong((regionProfile.regionLocX * Constants.RegionSize),
|
|
||||||
(regionProfile.regionLocY*Constants.RegionSize));
|
|
||||||
regionProfile.serverIP = externalHostName;
|
|
||||||
regionProfile.serverPort = regionPort;
|
|
||||||
regionProfile.httpPort = httpPort;
|
|
||||||
regionProfile.remotingPort = remotingPort;
|
|
||||||
regionProfile.serverURI = serverUri;
|
|
||||||
regionProfile.httpServerURI = "http://" + externalHostName + ":" + httpPort + "/";
|
|
||||||
regionProfile.UUID = regionID;
|
|
||||||
regionProfile.regionName = regionName;
|
|
||||||
regionProfile.maturity = access;
|
|
||||||
return regionProfile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,119 +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.Text;
|
|
||||||
using Nwc.XmlRpc;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
|
|
||||||
namespace OpenSim.Data
|
|
||||||
{
|
|
||||||
public class RegionProfileServiceProxy : IRegionProfileRouter
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Request sim data based on arbitrary key/value
|
|
||||||
/// </summary>
|
|
||||||
private RegionProfileData RequestSimData(Uri gridserverUrl, string gridserverSendkey, string keyField, string keyValue)
|
|
||||||
{
|
|
||||||
Hashtable requestData = new Hashtable();
|
|
||||||
requestData[keyField] = keyValue;
|
|
||||||
requestData["authkey"] = gridserverSendkey;
|
|
||||||
ArrayList SendParams = new ArrayList();
|
|
||||||
SendParams.Add(requestData);
|
|
||||||
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
|
|
||||||
XmlRpcResponse GridResp = GridReq.Send(gridserverUrl.ToString(), 3000);
|
|
||||||
|
|
||||||
Hashtable responseData = (Hashtable) GridResp.Value;
|
|
||||||
|
|
||||||
RegionProfileData simData = null;
|
|
||||||
|
|
||||||
if (!responseData.ContainsKey("error"))
|
|
||||||
{
|
|
||||||
uint locX = Convert.ToUInt32((string)responseData["region_locx"]);
|
|
||||||
uint locY = Convert.ToUInt32((string)responseData["region_locy"]);
|
|
||||||
string externalHostName = (string)responseData["sim_ip"];
|
|
||||||
uint simPort = Convert.ToUInt32((string)responseData["sim_port"]);
|
|
||||||
uint httpPort = Convert.ToUInt32((string)responseData["http_port"]);
|
|
||||||
uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
|
|
||||||
string serverUri = (string)responseData["server_uri"];
|
|
||||||
UUID regionID = new UUID((string)responseData["region_UUID"]);
|
|
||||||
string regionName = (string)responseData["region_name"];
|
|
||||||
byte access = Convert.ToByte((string)responseData["access"]);
|
|
||||||
|
|
||||||
simData = RegionProfileData.Create(regionID, regionName, locX, locY, externalHostName, simPort, httpPort, remotingPort, serverUri, access);
|
|
||||||
}
|
|
||||||
|
|
||||||
return simData;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Request sim profile information from a grid server, by Region UUID
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="regionId">The region UUID to look for</param>
|
|
||||||
/// <param name="gridserverUrl"></param>
|
|
||||||
/// <param name="gridserverSendkey"></param>
|
|
||||||
/// <param name="gridserverRecvkey"></param>
|
|
||||||
/// <returns>The sim profile. Null if there was a request failure</returns>
|
|
||||||
/// <remarks>This method should be statics</remarks>
|
|
||||||
public RegionProfileData RequestSimProfileData(UUID regionId, Uri gridserverUrl,
|
|
||||||
string gridserverSendkey, string gridserverRecvkey)
|
|
||||||
{
|
|
||||||
return RequestSimData(gridserverUrl, gridserverSendkey, "region_UUID", regionId.Guid.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Request sim profile information from a grid server, by Region Handle
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="regionHandle">the region handle to look for</param>
|
|
||||||
/// <param name="gridserverUrl"></param>
|
|
||||||
/// <param name="gridserverSendkey"></param>
|
|
||||||
/// <param name="gridserverRecvkey"></param>
|
|
||||||
/// <returns>The sim profile. Null if there was a request failure</returns>
|
|
||||||
public RegionProfileData RequestSimProfileData(ulong regionHandle, Uri gridserverUrl,
|
|
||||||
string gridserverSendkey, string gridserverRecvkey)
|
|
||||||
{
|
|
||||||
return RequestSimData(gridserverUrl, gridserverSendkey, "region_handle", regionHandle.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Request sim profile information from a grid server, by Region Name
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="regionName">the region name to look for</param>
|
|
||||||
/// <param name="gridserverUrl"></param>
|
|
||||||
/// <param name="gridserverSendkey"></param>
|
|
||||||
/// <param name="gridserverRecvkey"></param>
|
|
||||||
/// <returns>The sim profile. Null if there was a request failure</returns>
|
|
||||||
public RegionProfileData RequestSimProfileData(string regionName, Uri gridserverUrl,
|
|
||||||
string gridserverSendkey, string gridserverRecvkey)
|
|
||||||
{
|
|
||||||
return RequestSimData(gridserverUrl, gridserverSendkey, "region_name_search", regionName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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 System;
|
|
||||||
using OpenMetaverse;
|
|
||||||
|
|
||||||
namespace OpenSim.Data
|
|
||||||
{
|
|
||||||
public class ReservationData
|
|
||||||
{
|
|
||||||
public UUID userUUID = UUID.Zero;
|
|
||||||
public int reservationMinX = 0;
|
|
||||||
public int reservationMinY = 0;
|
|
||||||
public int reservationMaxX = 65536;
|
|
||||||
public int reservationMaxY = 65536;
|
|
||||||
|
|
||||||
public string reservationName = String.Empty;
|
|
||||||
public string reservationCompany = String.Empty;
|
|
||||||
public bool status = true;
|
|
||||||
|
|
||||||
public string gridSendKey = String.Empty;
|
|
||||||
public string gridRecvKey = String.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
CREATE TABLE auth (
|
||||||
|
UUID char(36) NOT NULL,
|
||||||
|
passwordHash char(32) NOT NULL default '',
|
||||||
|
passwordSalt char(32) NOT NULL default '',
|
||||||
|
webLoginKey varchar(255) NOT NULL default '',
|
||||||
|
accountType VARCHAR(32) NOT NULL DEFAULT 'UserAccount',
|
||||||
|
PRIMARY KEY (`UUID`)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE tokens (
|
||||||
|
UUID char(36) NOT NULL,
|
||||||
|
token varchar(255) NOT NULL,
|
||||||
|
validity datetime NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
COMMIT;
|
|
@ -0,0 +1,9 @@
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
CREATE TABLE Avatars (
|
||||||
|
PrincipalID CHAR(36) NOT NULL,
|
||||||
|
Name VARCHAR(32) NOT NULL,
|
||||||
|
Value VARCHAR(255) NOT NULL DEFAULT '',
|
||||||
|
PRIMARY KEY(PrincipalID, Name));
|
||||||
|
|
||||||
|
COMMIT;
|
|
@ -0,0 +1,17 @@
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
-- useraccounts table
|
||||||
|
CREATE TABLE UserAccounts (
|
||||||
|
PrincipalID CHAR(36) NOT NULL,
|
||||||
|
ScopeID CHAR(36) NOT NULL,
|
||||||
|
FirstName VARCHAR(64) NOT NULL,
|
||||||
|
LastName VARCHAR(64) NOT NULL,
|
||||||
|
Email VARCHAR(64),
|
||||||
|
ServiceURLs TEXT,
|
||||||
|
Created INT(11),
|
||||||
|
UserLevel integer NOT NULL DEFAULT 0,
|
||||||
|
UserFlags integer NOT NULL DEFAULT 0,
|
||||||
|
UserTitle varchar(64) NOT NULL DEFAULT ''
|
||||||
|
);
|
||||||
|
|
||||||
|
COMMIT;
|
|
@ -0,0 +1,5 @@
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
INSERT INTO auth (UUID, passwordHash, passwordSalt, webLoginKey) SELECT `UUID` AS UUID, `passwordHash` AS passwordHash, `passwordSalt` AS passwordSalt, `webLoginKey` AS webLoginKey FROM users;
|
||||||
|
|
||||||
|
COMMIT;
|
|
@ -0,0 +1,5 @@
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
INSERT INTO UserAccounts (PrincipalID, ScopeID, FirstName, LastName, Email, ServiceURLs, Created) SELECT `UUID` AS PrincipalID, '00000000-0000-0000-0000-000000000000' AS ScopeID, username AS FirstName, surname AS LastName, '' as Email, '' AS ServiceURLs, created as Created FROM users;
|
||||||
|
|
||||||
|
COMMIT;
|
|
@ -0,0 +1,262 @@
|
||||||
|
/*
|
||||||
|
* 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.Data;
|
||||||
|
using OpenMetaverse;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using Mono.Data.SqliteClient;
|
||||||
|
|
||||||
|
namespace OpenSim.Data.SQLite
|
||||||
|
{
|
||||||
|
public class SQLiteAuthenticationData : SQLiteFramework, IAuthenticationData
|
||||||
|
{
|
||||||
|
private string m_Realm;
|
||||||
|
private List<string> m_ColumnNames;
|
||||||
|
private int m_LastExpire;
|
||||||
|
private string m_connectionString;
|
||||||
|
|
||||||
|
protected static SqliteConnection m_Connection;
|
||||||
|
private static bool m_initialized = false;
|
||||||
|
|
||||||
|
public SQLiteAuthenticationData(string connectionString, string realm)
|
||||||
|
: base(connectionString)
|
||||||
|
{
|
||||||
|
m_Realm = realm;
|
||||||
|
m_connectionString = connectionString;
|
||||||
|
|
||||||
|
if (!m_initialized)
|
||||||
|
{
|
||||||
|
m_Connection = new SqliteConnection(connectionString);
|
||||||
|
m_Connection.Open();
|
||||||
|
|
||||||
|
using (SqliteConnection dbcon = (SqliteConnection)((ICloneable)m_Connection).Clone())
|
||||||
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
Migration m = new Migration(dbcon, GetType().Assembly, "AuthStore");
|
||||||
|
m.Update();
|
||||||
|
dbcon.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_initialized = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthenticationData Get(UUID principalID)
|
||||||
|
{
|
||||||
|
AuthenticationData ret = new AuthenticationData();
|
||||||
|
ret.Data = new Dictionary<string, object>();
|
||||||
|
|
||||||
|
SqliteCommand cmd = new SqliteCommand("select * from `" + m_Realm + "` where UUID = :PrincipalID");
|
||||||
|
cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString()));
|
||||||
|
|
||||||
|
IDataReader result = ExecuteReader(cmd, m_Connection);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (result.Read())
|
||||||
|
{
|
||||||
|
ret.PrincipalID = principalID;
|
||||||
|
|
||||||
|
if (m_ColumnNames == null)
|
||||||
|
{
|
||||||
|
m_ColumnNames = new List<string>();
|
||||||
|
|
||||||
|
DataTable schemaTable = result.GetSchemaTable();
|
||||||
|
foreach (DataRow row in schemaTable.Rows)
|
||||||
|
m_ColumnNames.Add(row["ColumnName"].ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string s in m_ColumnNames)
|
||||||
|
{
|
||||||
|
if (s == "UUID")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ret.Data[s] = result[s].ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseCommand(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Store(AuthenticationData data)
|
||||||
|
{
|
||||||
|
if (data.Data.ContainsKey("UUID"))
|
||||||
|
data.Data.Remove("UUID");
|
||||||
|
|
||||||
|
string[] fields = new List<string>(data.Data.Keys).ToArray();
|
||||||
|
string[] values = new string[data.Data.Count];
|
||||||
|
int i = 0;
|
||||||
|
foreach (object o in data.Data.Values)
|
||||||
|
values[i++] = o.ToString();
|
||||||
|
|
||||||
|
SqliteCommand cmd = new SqliteCommand();
|
||||||
|
|
||||||
|
if (Get(data.PrincipalID) != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
string update = "update `" + m_Realm + "` set ";
|
||||||
|
bool first = true;
|
||||||
|
foreach (string field in fields)
|
||||||
|
{
|
||||||
|
if (!first)
|
||||||
|
update += ", ";
|
||||||
|
update += "`" + field + "` = :" + field;
|
||||||
|
cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field]));
|
||||||
|
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
update += " where UUID = :UUID";
|
||||||
|
cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString()));
|
||||||
|
|
||||||
|
cmd.CommandText = update;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (ExecuteNonQuery(cmd, m_Connection) < 1)
|
||||||
|
{
|
||||||
|
CloseCommand(cmd);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
CloseCommand(cmd);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string insert = "insert into `" + m_Realm + "` (`UUID`, `" +
|
||||||
|
String.Join("`, `", fields) +
|
||||||
|
"`) values (:UUID, :" + String.Join(", :", fields) + ")";
|
||||||
|
|
||||||
|
cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString()));
|
||||||
|
foreach (string field in fields)
|
||||||
|
cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field]));
|
||||||
|
|
||||||
|
cmd.CommandText = insert;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (ExecuteNonQuery(cmd, m_Connection) < 1)
|
||||||
|
{
|
||||||
|
CloseCommand(cmd);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
CloseCommand(cmd);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseCommand(cmd);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SetDataItem(UUID principalID, string item, string value)
|
||||||
|
{
|
||||||
|
SqliteCommand cmd = new SqliteCommand("update `" + m_Realm +
|
||||||
|
"` set `" + item + "` = " + value + " where UUID = '" + principalID.ToString() + "'");
|
||||||
|
|
||||||
|
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SetToken(UUID principalID, string token, int lifetime)
|
||||||
|
{
|
||||||
|
if (System.Environment.TickCount - m_LastExpire > 30000)
|
||||||
|
DoExpire();
|
||||||
|
|
||||||
|
SqliteCommand cmd = new SqliteCommand("insert into tokens (UUID, token, validity) values ('" + principalID.ToString() +
|
||||||
|
"', '" + token + "', datetime('now', 'localtime', '+" + lifetime.ToString() + " minutes'))");
|
||||||
|
|
||||||
|
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||||
|
{
|
||||||
|
cmd.Dispose();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Dispose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CheckToken(UUID principalID, string token, int lifetime)
|
||||||
|
{
|
||||||
|
if (System.Environment.TickCount - m_LastExpire > 30000)
|
||||||
|
DoExpire();
|
||||||
|
|
||||||
|
SqliteCommand cmd = new SqliteCommand("update tokens set validity = datetime('now, 'localtime', '+" + lifetime.ToString() +
|
||||||
|
" minutes') where UUID = '" + principalID.ToString() + "' and token = '" + token + "' and validity > datetime('now', 'localtime')");
|
||||||
|
|
||||||
|
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||||
|
{
|
||||||
|
cmd.Dispose();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Dispose();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DoExpire()
|
||||||
|
{
|
||||||
|
SqliteCommand cmd = new SqliteCommand("delete from tokens where validity < datetime('now', 'localtime')");
|
||||||
|
ExecuteNonQuery(cmd, m_Connection);
|
||||||
|
|
||||||
|
cmd.Dispose();
|
||||||
|
|
||||||
|
m_LastExpire = System.Environment.TickCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,40 +25,50 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.IO;
|
using System;
|
||||||
using NUnit.Framework;
|
using System.Collections.Generic;
|
||||||
using OpenSim.Data.Tests;
|
using System.Data;
|
||||||
using OpenSim.Tests.Common;
|
using System.Reflection;
|
||||||
|
using System.Threading;
|
||||||
|
using log4net;
|
||||||
|
using OpenMetaverse;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using Mono.Data.SqliteClient;
|
||||||
|
|
||||||
namespace OpenSim.Data.SQLite.Tests
|
namespace OpenSim.Data.SQLite
|
||||||
{
|
{
|
||||||
[TestFixture, DatabaseTest]
|
/// <summary>
|
||||||
public class SQLiteUserTest : BasicUserTest
|
/// A MySQL Interface for the Grid Server
|
||||||
|
/// </summary>
|
||||||
|
public class SQLiteAvatarData : SQLiteGenericTableHandler<AvatarBaseData>,
|
||||||
|
IAvatarData
|
||||||
{
|
{
|
||||||
public string file;
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
public string connect;
|
|
||||||
|
|
||||||
[TestFixtureSetUp]
|
public SQLiteAvatarData(string connectionString, string realm) :
|
||||||
public void Init()
|
base(connectionString, realm, "Avatar")
|
||||||
{
|
{
|
||||||
// SQLite doesn't work on power or z linux
|
|
||||||
if (Directory.Exists("/proc/ppc64") || Directory.Exists("/proc/dasd"))
|
|
||||||
{
|
|
||||||
Assert.Ignore();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SuperInit();
|
public bool Delete(UUID principalID, string name)
|
||||||
file = Path.GetTempFileName() + ".db";
|
|
||||||
connect = "URI=file:" + file + ",version=3";
|
|
||||||
db = new SQLiteUserData();
|
|
||||||
db.Initialise(connect);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestFixtureTearDown]
|
|
||||||
public void Cleanup()
|
|
||||||
{
|
{
|
||||||
db.Dispose();
|
SqliteCommand cmd = new SqliteCommand();
|
||||||
File.Delete(file);
|
|
||||||
|
cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = :PrincipalID and `Name` = :Name", m_Realm);
|
||||||
|
cmd.Parameters.Add(":PrincipalID", principalID.ToString());
|
||||||
|
cmd.Parameters.Add(":Name", name);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseCommand(cmd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -40,12 +40,10 @@ namespace OpenSim.Data.SQLite
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SQLiteFramework
|
public class SQLiteFramework
|
||||||
{
|
{
|
||||||
protected SqliteConnection m_Connection;
|
protected Object m_lockObject = new Object();
|
||||||
|
|
||||||
protected SQLiteFramework(string connectionString)
|
protected SQLiteFramework(string connectionString)
|
||||||
{
|
{
|
||||||
m_Connection = new SqliteConnection(connectionString);
|
|
||||||
m_Connection.Open();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
|
@ -53,27 +51,37 @@ namespace OpenSim.Data.SQLite
|
||||||
// All non queries are funneled through one connection
|
// All non queries are funneled through one connection
|
||||||
// to increase performance a little
|
// to increase performance a little
|
||||||
//
|
//
|
||||||
protected int ExecuteNonQuery(SqliteCommand cmd)
|
protected int ExecuteNonQuery(SqliteCommand cmd, SqliteConnection connection)
|
||||||
{
|
{
|
||||||
lock (m_Connection)
|
lock (connection)
|
||||||
{
|
{
|
||||||
cmd.Connection = m_Connection;
|
SqliteConnection newConnection =
|
||||||
|
(SqliteConnection)((ICloneable)connection).Clone();
|
||||||
|
newConnection.Open();
|
||||||
|
|
||||||
|
cmd.Connection = newConnection;
|
||||||
|
//Console.WriteLine("XXX " + cmd.CommandText);
|
||||||
|
|
||||||
return cmd.ExecuteNonQuery();
|
return cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IDataReader ExecuteReader(SqliteCommand cmd)
|
protected IDataReader ExecuteReader(SqliteCommand cmd, SqliteConnection connection)
|
||||||
|
{
|
||||||
|
lock (connection)
|
||||||
{
|
{
|
||||||
SqliteConnection newConnection =
|
SqliteConnection newConnection =
|
||||||
(SqliteConnection)((ICloneable)m_Connection).Clone();
|
(SqliteConnection)((ICloneable)connection).Clone();
|
||||||
newConnection.Open();
|
newConnection.Open();
|
||||||
|
|
||||||
cmd.Connection = newConnection;
|
cmd.Connection = newConnection;
|
||||||
|
//Console.WriteLine("XXX " + cmd.CommandText);
|
||||||
|
|
||||||
return cmd.ExecuteReader();
|
return cmd.ExecuteReader();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void CloseReaderCommand(SqliteCommand cmd)
|
protected void CloseCommand(SqliteCommand cmd)
|
||||||
{
|
{
|
||||||
cmd.Connection.Close();
|
cmd.Connection.Close();
|
||||||
cmd.Connection.Dispose();
|
cmd.Connection.Dispose();
|
||||||
|
|
|
@ -48,16 +48,33 @@ namespace OpenSim.Data.SQLite
|
||||||
protected string m_Realm;
|
protected string m_Realm;
|
||||||
protected FieldInfo m_DataField = null;
|
protected FieldInfo m_DataField = null;
|
||||||
|
|
||||||
|
protected static SqliteConnection m_Connection;
|
||||||
|
private static bool m_initialized;
|
||||||
|
|
||||||
public SQLiteGenericTableHandler(string connectionString,
|
public SQLiteGenericTableHandler(string connectionString,
|
||||||
string realm, string storeName) : base(connectionString)
|
string realm, string storeName) : base(connectionString)
|
||||||
{
|
{
|
||||||
m_Realm = realm;
|
m_Realm = realm;
|
||||||
|
|
||||||
|
if (!m_initialized)
|
||||||
|
{
|
||||||
|
m_Connection = new SqliteConnection(connectionString);
|
||||||
|
m_Connection.Open();
|
||||||
|
|
||||||
if (storeName != String.Empty)
|
if (storeName != String.Empty)
|
||||||
{
|
{
|
||||||
Assembly assem = GetType().Assembly;
|
Assembly assem = GetType().Assembly;
|
||||||
|
SqliteConnection newConnection =
|
||||||
|
(SqliteConnection)((ICloneable)m_Connection).Clone();
|
||||||
|
newConnection.Open();
|
||||||
|
|
||||||
Migration m = new Migration(m_Connection, assem, storeName);
|
Migration m = new Migration(newConnection, assem, storeName);
|
||||||
m.Update();
|
m.Update();
|
||||||
|
newConnection.Close();
|
||||||
|
newConnection.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Type t = typeof(T);
|
Type t = typeof(T);
|
||||||
|
@ -125,7 +142,7 @@ namespace OpenSim.Data.SQLite
|
||||||
|
|
||||||
protected T[] DoQuery(SqliteCommand cmd)
|
protected T[] DoQuery(SqliteCommand cmd)
|
||||||
{
|
{
|
||||||
IDataReader reader = ExecuteReader(cmd);
|
IDataReader reader = ExecuteReader(cmd, m_Connection);
|
||||||
if (reader == null)
|
if (reader == null)
|
||||||
return new T[0];
|
return new T[0];
|
||||||
|
|
||||||
|
@ -180,7 +197,7 @@ namespace OpenSim.Data.SQLite
|
||||||
result.Add(row);
|
result.Add(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseReaderCommand(cmd);
|
CloseCommand(cmd);
|
||||||
|
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
|
@ -229,7 +246,7 @@ namespace OpenSim.Data.SQLite
|
||||||
|
|
||||||
cmd.CommandText = query;
|
cmd.CommandText = query;
|
||||||
|
|
||||||
if (ExecuteNonQuery(cmd) > 0)
|
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -242,7 +259,7 @@ namespace OpenSim.Data.SQLite
|
||||||
cmd.CommandText = String.Format("delete from {0} where `{1}` = :{1}", m_Realm, field);
|
cmd.CommandText = String.Format("delete from {0} where `{1}` = :{1}", m_Realm, field);
|
||||||
cmd.Parameters.Add(new SqliteParameter(field, val));
|
cmd.Parameters.Add(new SqliteParameter(field, val));
|
||||||
|
|
||||||
if (ExecuteNonQuery(cmd) > 0)
|
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,286 +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.Data;
|
|
||||||
using System.Reflection;
|
|
||||||
using log4net;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.SQLite
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A Grid Interface to the SQLite database
|
|
||||||
/// </summary>
|
|
||||||
public class SQLiteGridData : GridDataBase
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// SQLite database manager
|
|
||||||
/// </summary>
|
|
||||||
private SQLiteManager database;
|
|
||||||
|
|
||||||
override public void Initialise()
|
|
||||||
{
|
|
||||||
m_log.Info("[SQLite]: " + Name + " cannot be default-initialized!");
|
|
||||||
throw new PluginNotInitialisedException (Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// <list type="bullet">
|
|
||||||
/// <item>Initialises Inventory interface</item>
|
|
||||||
/// <item>Loads and initialises a new SQLite connection and maintains it.</item>
|
|
||||||
/// <item>use default URI if connect string is empty.</item>
|
|
||||||
/// </list>
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dbconnect">connect string</param>
|
|
||||||
override public void Initialise(string connect)
|
|
||||||
{
|
|
||||||
database = new SQLiteManager(connect);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Shuts down the grid interface
|
|
||||||
/// </summary>
|
|
||||||
override public void Dispose()
|
|
||||||
{
|
|
||||||
database.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the name of this grid interface
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string containing the grid interface</returns>
|
|
||||||
override public string Name
|
|
||||||
{
|
|
||||||
get { return "SQLite OpenGridData"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the version of this grid interface
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string containing the version</returns>
|
|
||||||
override public string Version
|
|
||||||
{
|
|
||||||
get { return "0.1"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a list of regions within the specified ranges
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="a">minimum X coordinate</param>
|
|
||||||
/// <param name="b">minimum Y coordinate</param>
|
|
||||||
/// <param name="c">maximum X coordinate</param>
|
|
||||||
/// <param name="d">maximum Y coordinate</param>
|
|
||||||
/// <returns>An array of region profiles</returns>
|
|
||||||
/// <remarks>NOT IMPLEMENTED ? always return null</remarks>
|
|
||||||
override public RegionProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns up to maxNum profiles of regions that have a name starting with namePrefix
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name to match against</param>
|
|
||||||
/// <param name="maxNum">Maximum number of profiles to return</param>
|
|
||||||
/// <returns>A list of sim profiles</returns>
|
|
||||||
override public List<RegionProfileData> GetRegionsByName (string namePrefix, uint maxNum)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a sim profile from it's handle
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="handle">Region location handle</param>
|
|
||||||
/// <returns>Sim profile</returns>
|
|
||||||
override public RegionProfileData GetProfileByHandle(ulong handle)
|
|
||||||
{
|
|
||||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
|
||||||
param["handle"] = handle.ToString();
|
|
||||||
|
|
||||||
IDbCommand result = database.Query("SELECT * FROM regions WHERE handle = @handle", param);
|
|
||||||
IDataReader reader = result.ExecuteReader();
|
|
||||||
|
|
||||||
RegionProfileData row = database.getRow(reader);
|
|
||||||
reader.Close();
|
|
||||||
result.Dispose();
|
|
||||||
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a sim profile from it's Region name string
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="regionName">The region name search query</param>
|
|
||||||
/// <returns>The sim profile</returns>
|
|
||||||
override public RegionProfileData GetProfileByString(string regionName)
|
|
||||||
{
|
|
||||||
if (regionName.Length > 2)
|
|
||||||
{
|
|
||||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
|
||||||
// Add % because this is a like query.
|
|
||||||
param["?regionName"] = regionName + "%";
|
|
||||||
// Only returns one record or no record.
|
|
||||||
IDbCommand result = database.Query("SELECT * FROM regions WHERE regionName like ?regionName LIMIT 1", param);
|
|
||||||
IDataReader reader = result.ExecuteReader();
|
|
||||||
|
|
||||||
RegionProfileData row = database.getRow(reader);
|
|
||||||
reader.Close();
|
|
||||||
result.Dispose();
|
|
||||||
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//m_log.Error("[DATABASE]: Searched for a Region Name shorter then 3 characters");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a sim profile from it's UUID
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uuid">The region UUID</param>
|
|
||||||
/// <returns>The sim profile</returns>
|
|
||||||
override public RegionProfileData GetProfileByUUID(UUID uuid)
|
|
||||||
{
|
|
||||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
|
||||||
param["uuid"] = uuid.ToString();
|
|
||||||
|
|
||||||
IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = @uuid", param);
|
|
||||||
IDataReader reader = result.ExecuteReader();
|
|
||||||
|
|
||||||
RegionProfileData row = database.getRow(reader);
|
|
||||||
reader.Close();
|
|
||||||
result.Dispose();
|
|
||||||
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a list of avatar and UUIDs that match the query
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>do nothing yet</remarks>
|
|
||||||
public List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query)
|
|
||||||
{
|
|
||||||
//Do nothing yet
|
|
||||||
List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
|
|
||||||
return returnlist;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a new specified region to the database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="profile">The profile to add</param>
|
|
||||||
/// <returns>A dataresponse enum indicating success</returns>
|
|
||||||
override public DataResponse StoreProfile(RegionProfileData profile)
|
|
||||||
{
|
|
||||||
if (database.insertRow(profile))
|
|
||||||
{
|
|
||||||
return DataResponse.RESPONSE_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return DataResponse.RESPONSE_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Deletes a sim profile from the database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uuid">the sim UUID</param>
|
|
||||||
/// <returns>Successful?</returns>
|
|
||||||
override public DataResponse DeleteProfile(string uuid)
|
|
||||||
{
|
|
||||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
|
||||||
param["uuid"] = uuid;
|
|
||||||
|
|
||||||
IDbCommand result = database.Query("DELETE FROM regions WHERE uuid = @uuid", param);
|
|
||||||
if (result.ExecuteNonQuery() > 0)
|
|
||||||
{
|
|
||||||
return DataResponse.RESPONSE_OK;
|
|
||||||
}
|
|
||||||
return DataResponse.RESPONSE_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// DEPRECATED. Attempts to authenticate a region by comparing a shared secret.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uuid">The UUID of the challenger</param>
|
|
||||||
/// <param name="handle">The attempted regionHandle of the challenger</param>
|
|
||||||
/// <param name="authkey">The secret</param>
|
|
||||||
/// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
|
|
||||||
override public bool AuthenticateSim(UUID uuid, ulong handle, string authkey)
|
|
||||||
{
|
|
||||||
bool throwHissyFit = false; // Should be true by 1.0
|
|
||||||
|
|
||||||
if (throwHissyFit)
|
|
||||||
throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
|
|
||||||
|
|
||||||
RegionProfileData data = GetProfileByUUID(uuid);
|
|
||||||
|
|
||||||
return (handle == data.regionHandle && authkey == data.regionSecret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>This requires a security audit.</remarks>
|
|
||||||
/// <param name="uuid"></param>
|
|
||||||
/// <param name="handle"></param>
|
|
||||||
/// <param name="authhash"></param>
|
|
||||||
/// <param name="challenge"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool AuthenticateSim(UUID uuid, ulong handle, string authhash, string challenge)
|
|
||||||
{
|
|
||||||
// SHA512Managed HashProvider = new SHA512Managed();
|
|
||||||
// Encoding TextProvider = new UTF8Encoding();
|
|
||||||
|
|
||||||
// byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge);
|
|
||||||
// byte[] hash = HashProvider.ComputeHash(stream);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// NOT IMPLEMENTED
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="x">x coordinate</param>
|
|
||||||
/// <param name="y">y coordinate</param>
|
|
||||||
/// <returns>always return null</returns>
|
|
||||||
override public ReservationData GetReservationAtPoint(uint x, uint y)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,225 +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.Data;
|
|
||||||
using System.Data.SQLite;
|
|
||||||
using System.Reflection;
|
|
||||||
using log4net;
|
|
||||||
using OpenMetaverse;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.SQLite
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// SQLite Manager
|
|
||||||
/// </summary>
|
|
||||||
internal class SQLiteManager : SQLiteUtil
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
private IDbConnection dbcon;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// <list type="bullet">
|
|
||||||
/// <item>Initialises and creates a new SQLite connection and maintains it.</item>
|
|
||||||
/// <item>use default URI if connect string is empty.</item>
|
|
||||||
/// </list>
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="connect">connect string</param>
|
|
||||||
public SQLiteManager(string connect)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string connectionString = String.Empty;
|
|
||||||
if (connect != String.Empty)
|
|
||||||
{
|
|
||||||
connectionString = connect;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_log.Warn("[SQLITE] grid db not specified, using default");
|
|
||||||
connectionString = "URI=file:GridServerSqlite.db;";
|
|
||||||
}
|
|
||||||
|
|
||||||
dbcon = new SQLiteConnection(connectionString);
|
|
||||||
|
|
||||||
dbcon.Open();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new Exception("Error initialising SQLite Database: " + e.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Shuts down the database connection
|
|
||||||
/// </summary>
|
|
||||||
public void Close()
|
|
||||||
{
|
|
||||||
dbcon.Close();
|
|
||||||
dbcon = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Runs a query with protection against SQL Injection by using parameterised input.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param>
|
|
||||||
/// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param>
|
|
||||||
/// <returns>A SQLite DB Command</returns>
|
|
||||||
public IDbCommand Query(string sql, Dictionary<string, string> parameters)
|
|
||||||
{
|
|
||||||
SQLiteCommand dbcommand = (SQLiteCommand) dbcon.CreateCommand();
|
|
||||||
dbcommand.CommandText = sql;
|
|
||||||
foreach (KeyValuePair<string, string> param in parameters)
|
|
||||||
{
|
|
||||||
SQLiteParameter paramx = new SQLiteParameter(param.Key, param.Value);
|
|
||||||
dbcommand.Parameters.Add(paramx);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (IDbCommand) dbcommand;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Reads a region row from a database reader
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="reader">An active database reader</param>
|
|
||||||
/// <returns>A region profile</returns>
|
|
||||||
public RegionProfileData getRow(IDataReader reader)
|
|
||||||
{
|
|
||||||
RegionProfileData retval = new RegionProfileData();
|
|
||||||
|
|
||||||
if (reader.Read())
|
|
||||||
{
|
|
||||||
// Region Main
|
|
||||||
retval.regionHandle = (ulong) reader["regionHandle"];
|
|
||||||
retval.regionName = (string) reader["regionName"];
|
|
||||||
retval.UUID = new UUID((string) reader["uuid"]);
|
|
||||||
|
|
||||||
// Secrets
|
|
||||||
retval.regionRecvKey = (string) reader["regionRecvKey"];
|
|
||||||
retval.regionSecret = (string) reader["regionSecret"];
|
|
||||||
retval.regionSendKey = (string) reader["regionSendKey"];
|
|
||||||
|
|
||||||
// Region Server
|
|
||||||
retval.regionDataURI = (string) reader["regionDataURI"];
|
|
||||||
retval.regionOnline = false; // Needs to be pinged before this can be set.
|
|
||||||
retval.serverIP = (string) reader["serverIP"];
|
|
||||||
retval.serverPort = (uint) reader["serverPort"];
|
|
||||||
retval.serverURI = (string) reader["serverURI"];
|
|
||||||
|
|
||||||
// Location
|
|
||||||
retval.regionLocX = (uint) ((int) reader["locX"]);
|
|
||||||
retval.regionLocY = (uint) ((int) reader["locY"]);
|
|
||||||
retval.regionLocZ = (uint) ((int) reader["locZ"]);
|
|
||||||
|
|
||||||
// Neighbours - 0 = No Override
|
|
||||||
retval.regionEastOverrideHandle = (ulong) reader["eastOverrideHandle"];
|
|
||||||
retval.regionWestOverrideHandle = (ulong) reader["westOverrideHandle"];
|
|
||||||
retval.regionSouthOverrideHandle = (ulong) reader["southOverrideHandle"];
|
|
||||||
retval.regionNorthOverrideHandle = (ulong) reader["northOverrideHandle"];
|
|
||||||
|
|
||||||
// Assets
|
|
||||||
retval.regionAssetURI = (string) reader["regionAssetURI"];
|
|
||||||
retval.regionAssetRecvKey = (string) reader["regionAssetRecvKey"];
|
|
||||||
retval.regionAssetSendKey = (string) reader["regionAssetSendKey"];
|
|
||||||
|
|
||||||
// Userserver
|
|
||||||
retval.regionUserURI = (string) reader["regionUserURI"];
|
|
||||||
retval.regionUserRecvKey = (string) reader["regionUserRecvKey"];
|
|
||||||
retval.regionUserSendKey = (string) reader["regionUserSendKey"];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception("No rows to return");
|
|
||||||
}
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Inserts a new region into the database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="profile">The region to insert</param>
|
|
||||||
/// <returns>Success?</returns>
|
|
||||||
public bool insertRow(RegionProfileData profile)
|
|
||||||
{
|
|
||||||
string sql =
|
|
||||||
"REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
|
|
||||||
sql +=
|
|
||||||
"serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
|
|
||||||
sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey) VALUES ";
|
|
||||||
|
|
||||||
sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, ";
|
|
||||||
sql +=
|
|
||||||
"@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, ";
|
|
||||||
sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);";
|
|
||||||
|
|
||||||
Dictionary<string, string> parameters = new Dictionary<string, string>();
|
|
||||||
|
|
||||||
parameters["regionHandle"] = profile.regionHandle.ToString();
|
|
||||||
parameters["regionName"] = profile.regionName;
|
|
||||||
parameters["uuid"] = profile.UUID.ToString();
|
|
||||||
parameters["regionRecvKey"] = profile.regionRecvKey;
|
|
||||||
parameters["regionSendKey"] = profile.regionSendKey;
|
|
||||||
parameters["regionDataURI"] = profile.regionDataURI;
|
|
||||||
parameters["serverIP"] = profile.serverIP;
|
|
||||||
parameters["serverPort"] = profile.serverPort.ToString();
|
|
||||||
parameters["serverURI"] = profile.serverURI;
|
|
||||||
parameters["locX"] = profile.regionLocX.ToString();
|
|
||||||
parameters["locY"] = profile.regionLocY.ToString();
|
|
||||||
parameters["locZ"] = profile.regionLocZ.ToString();
|
|
||||||
parameters["eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString();
|
|
||||||
parameters["westOverrideHandle"] = profile.regionWestOverrideHandle.ToString();
|
|
||||||
parameters["northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString();
|
|
||||||
parameters["southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString();
|
|
||||||
parameters["regionAssetURI"] = profile.regionAssetURI;
|
|
||||||
parameters["regionAssetRecvKey"] = profile.regionAssetRecvKey;
|
|
||||||
parameters["regionAssetSendKey"] = profile.regionAssetSendKey;
|
|
||||||
parameters["regionUserURI"] = profile.regionUserURI;
|
|
||||||
parameters["regionUserRecvKey"] = profile.regionUserRecvKey;
|
|
||||||
parameters["regionUserSendKey"] = profile.regionUserSendKey;
|
|
||||||
|
|
||||||
bool returnval = false;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
IDbCommand result = Query(sql, parameters);
|
|
||||||
|
|
||||||
if (result.ExecuteNonQuery() == 1)
|
|
||||||
returnval = true;
|
|
||||||
|
|
||||||
result.Dispose();
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnval;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -26,60 +26,56 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using NUnit.Framework;
|
using System.Collections;
|
||||||
using OpenSim.Data.Tests;
|
using System.Collections.Generic;
|
||||||
using log4net;
|
using System.Data;
|
||||||
using System.Reflection;
|
using OpenMetaverse;
|
||||||
using OpenSim.Tests.Common;
|
using OpenSim.Framework;
|
||||||
|
using Mono.Data.SqliteClient;
|
||||||
|
|
||||||
namespace OpenSim.Data.MySQL.Tests
|
namespace OpenSim.Data.SQLite
|
||||||
{
|
{
|
||||||
[TestFixture, DatabaseTest]
|
public class SQLiteUserAccountData : SQLiteGenericTableHandler<UserAccountData>, IUserAccountData
|
||||||
public class MySQLUserTest : BasicUserTest
|
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
public SQLiteUserAccountData(string connectionString, string realm)
|
||||||
public string file;
|
: base(connectionString, realm, "UserAccount")
|
||||||
public MySQLManager database;
|
|
||||||
public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;";
|
|
||||||
|
|
||||||
[TestFixtureSetUp]
|
|
||||||
public void Init()
|
|
||||||
{
|
{
|
||||||
SuperInit();
|
|
||||||
// If we manage to connect to the database with the user
|
|
||||||
// and password above it is our test database, and run
|
|
||||||
// these tests. If anything goes wrong, ignore these
|
|
||||||
// tests.
|
|
||||||
try
|
|
||||||
{
|
|
||||||
database = new MySQLManager(connect);
|
|
||||||
db = new MySQLUserData();
|
|
||||||
db.Initialise(connect);
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
|
public UserAccountData[] GetUsers(UUID scopeID, string query)
|
||||||
{
|
{
|
||||||
m_log.Error("Exception {0}", e);
|
string[] words = query.Split(new char[] {' '});
|
||||||
Assert.Ignore();
|
|
||||||
|
for (int i = 0 ; i < words.Length ; i++)
|
||||||
|
{
|
||||||
|
if (words[i].Length < 3)
|
||||||
|
{
|
||||||
|
if (i != words.Length - 1)
|
||||||
|
Array.Copy(words, i + 1, words, i, words.Length - i - 1);
|
||||||
|
Array.Resize(ref words, words.Length - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestFixtureTearDown]
|
if (words.Length == 0)
|
||||||
public void Cleanup()
|
return new UserAccountData[0];
|
||||||
|
|
||||||
|
if (words.Length > 2)
|
||||||
|
return new UserAccountData[0];
|
||||||
|
|
||||||
|
SqliteCommand cmd = new SqliteCommand();
|
||||||
|
|
||||||
|
if (words.Length == 1)
|
||||||
{
|
{
|
||||||
if (db != null)
|
cmd.CommandText = String.Format("select * from {0} where ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')",
|
||||||
|
m_Realm, scopeID.ToString(), words[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
db.Dispose();
|
cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')",
|
||||||
}
|
m_Realm, scopeID.ToString(), words[0], words[1]);
|
||||||
// if a new table is added, it has to be dropped here
|
|
||||||
if (database != null)
|
|
||||||
{
|
|
||||||
database.ExecuteSql("drop table migrations");
|
|
||||||
database.ExecuteSql("drop table users");
|
|
||||||
database.ExecuteSql("drop table userfriends");
|
|
||||||
database.ExecuteSql("drop table agents");
|
|
||||||
database.ExecuteSql("drop table avatarappearance");
|
|
||||||
database.ExecuteSql("drop table avatarattachments");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return DoQuery(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -115,7 +115,7 @@ namespace OpenSim.Data.SQLite
|
||||||
cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParent));
|
cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParent));
|
||||||
cmd.Parameters.Add(new SqliteParameter(":InventoryID", id));
|
cmd.Parameters.Add(new SqliteParameter(":InventoryID", id));
|
||||||
|
|
||||||
return ExecuteNonQuery(cmd) == 0 ? false : true;
|
return ExecuteNonQuery(cmd, m_Connection) == 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public XInventoryItem[] GetActiveGestures(UUID principalID)
|
public XInventoryItem[] GetActiveGestures(UUID principalID)
|
||||||
|
@ -137,7 +137,7 @@ namespace OpenSim.Data.SQLite
|
||||||
cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString()));
|
cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString()));
|
||||||
cmd.Parameters.Add(new SqliteParameter(":AssetID", assetID.ToString()));
|
cmd.Parameters.Add(new SqliteParameter(":AssetID", assetID.ToString()));
|
||||||
|
|
||||||
IDataReader reader = ExecuteReader(cmd);
|
IDataReader reader = ExecuteReader(cmd, m_Connection);
|
||||||
|
|
||||||
int perms = 0;
|
int perms = 0;
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ namespace OpenSim.Data.SQLite
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.Close();
|
reader.Close();
|
||||||
CloseReaderCommand(cmd);
|
CloseCommand(cmd);
|
||||||
|
|
||||||
return perms;
|
return perms;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,17 +73,23 @@ namespace OpenSim.Data.Tests
|
||||||
a2.Data = asset1;
|
a2.Data = asset1;
|
||||||
a3.Data = asset1;
|
a3.Data = asset1;
|
||||||
|
|
||||||
|
a1.Metadata.ContentType = "application/octet-stream";
|
||||||
|
a2.Metadata.ContentType = "application/octet-stream";
|
||||||
|
a3.Metadata.ContentType = "application/octet-stream";
|
||||||
|
|
||||||
PropertyScrambler<AssetBase> scrambler = new PropertyScrambler<AssetBase>()
|
PropertyScrambler<AssetBase> scrambler = new PropertyScrambler<AssetBase>()
|
||||||
.DontScramble(x => x.Data)
|
.DontScramble(x => x.Data)
|
||||||
.DontScramble(x => x.ID)
|
.DontScramble(x => x.ID)
|
||||||
.DontScramble(x => x.FullID)
|
.DontScramble(x => x.FullID)
|
||||||
.DontScramble(x => x.Metadata.ID)
|
.DontScramble(x => x.Metadata.ID)
|
||||||
|
.DontScramble(x => x.Metadata.ContentType)
|
||||||
.DontScramble(x => x.Metadata.FullID);
|
.DontScramble(x => x.Metadata.FullID);
|
||||||
|
|
||||||
scrambler.Scramble(a1);
|
scrambler.Scramble(a1);
|
||||||
scrambler.Scramble(a2);
|
scrambler.Scramble(a2);
|
||||||
scrambler.Scramble(a3);
|
scrambler.Scramble(a3);
|
||||||
|
|
||||||
|
|
||||||
db.StoreAsset(a1);
|
db.StoreAsset(a1);
|
||||||
db.StoreAsset(a2);
|
db.StoreAsset(a2);
|
||||||
db.StoreAsset(a3);
|
db.StoreAsset(a3);
|
||||||
|
|
|
@ -1,173 +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;
|
|
||||||
using NUnit.Framework;
|
|
||||||
using NUnit.Framework.SyntaxHelpers;
|
|
||||||
using OpenMetaverse;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.Tests
|
|
||||||
{
|
|
||||||
public class BasicGridTest
|
|
||||||
{
|
|
||||||
public IGridDataPlugin db;
|
|
||||||
public UUID region1, region2, region3;
|
|
||||||
public UUID zero = UUID.Zero;
|
|
||||||
public static Random random = new Random();
|
|
||||||
|
|
||||||
[TearDown]
|
|
||||||
public void removeAllRegions()
|
|
||||||
{
|
|
||||||
// Clean up all the regions.
|
|
||||||
List<RegionProfileData> regions = db.GetRegionsByName("", 100);
|
|
||||||
if (regions != null)
|
|
||||||
{
|
|
||||||
foreach (RegionProfileData region in regions)
|
|
||||||
{
|
|
||||||
db.DeleteProfile(region.Uuid.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SuperInit()
|
|
||||||
{
|
|
||||||
OpenSim.Tests.Common.TestLogging.LogToConsole();
|
|
||||||
region1 = UUID.Random();
|
|
||||||
region2 = UUID.Random();
|
|
||||||
region3 = UUID.Random();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected RegionProfileData createRegion(UUID regionUUID, string regionName)
|
|
||||||
{
|
|
||||||
RegionProfileData reg = new RegionProfileData();
|
|
||||||
new PropertyScrambler<RegionProfileData>().Scramble(reg);
|
|
||||||
reg.Uuid = regionUUID;
|
|
||||||
reg.RegionName = regionName;
|
|
||||||
|
|
||||||
db.StoreProfile(reg);
|
|
||||||
|
|
||||||
return reg;
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T001_LoadEmpty()
|
|
||||||
{
|
|
||||||
Assert.That(db.GetProfileByUUID(region1),Is.Null);
|
|
||||||
Assert.That(db.GetProfileByUUID(region2),Is.Null);
|
|
||||||
Assert.That(db.GetProfileByUUID(region3),Is.Null);
|
|
||||||
Assert.That(db.GetProfileByUUID(zero),Is.Null);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T011_AddRetrieveCompleteTest()
|
|
||||||
{
|
|
||||||
RegionProfileData newreg = createRegion(region2, "|<Goth@m Ci1y>|");
|
|
||||||
RegionProfileData retreg = db.GetProfileByUUID(region2);
|
|
||||||
|
|
||||||
Assert.That(retreg, Constraints.PropertyCompareConstraint(newreg).IgnoreProperty(x => x.RegionOnline));
|
|
||||||
|
|
||||||
retreg = db.GetProfileByHandle(newreg.RegionHandle);
|
|
||||||
Assert.That(retreg.Uuid, Is.EqualTo(region2), "Assert.That(retreg.Uuid, Is.EqualTo(region2))");
|
|
||||||
|
|
||||||
retreg = db.GetProfileByString(newreg.RegionName);
|
|
||||||
Assert.That(retreg.Uuid, Is.EqualTo(region2), "Assert.That(retreg.Uuid, Is.EqualTo(region2))");
|
|
||||||
|
|
||||||
RegionProfileData[] retregs = db.GetProfilesInRange(newreg.RegionLocX,newreg.RegionLocY,newreg.RegionLocX,newreg.RegionLocY);
|
|
||||||
Assert.That(retregs[0].Uuid, Is.EqualTo(region2), "Assert.That(retregs[0].Uuid, Is.EqualTo(region2))");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T012_DeleteProfile()
|
|
||||||
{
|
|
||||||
createRegion(region1, "doesn't matter");
|
|
||||||
|
|
||||||
db.DeleteProfile(region1.ToString());
|
|
||||||
RegionProfileData retreg = db.GetProfileByUUID(region1);
|
|
||||||
Assert.That(retreg,Is.Null);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T013_UpdateProfile()
|
|
||||||
{
|
|
||||||
createRegion(region2, "|<Goth@m Ci1y>|");
|
|
||||||
|
|
||||||
RegionProfileData retreg = db.GetProfileByUUID(region2);
|
|
||||||
retreg.regionName = "Gotham City";
|
|
||||||
|
|
||||||
db.StoreProfile(retreg);
|
|
||||||
|
|
||||||
retreg = db.GetProfileByUUID(region2);
|
|
||||||
Assert.That(retreg.RegionName, Is.EqualTo("Gotham City"), "Assert.That(retreg.RegionName, Is.EqualTo(\"Gotham City\"))");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T014_RegionList()
|
|
||||||
{
|
|
||||||
createRegion(region2, "Gotham City");
|
|
||||||
|
|
||||||
RegionProfileData retreg = db.GetProfileByUUID(region2);
|
|
||||||
retreg.RegionName = "Gotham Town";
|
|
||||||
retreg.Uuid = region1;
|
|
||||||
|
|
||||||
db.StoreProfile(retreg);
|
|
||||||
|
|
||||||
retreg = db.GetProfileByUUID(region2);
|
|
||||||
retreg.RegionName = "Gothan Town";
|
|
||||||
retreg.Uuid = region3;
|
|
||||||
|
|
||||||
db.StoreProfile(retreg);
|
|
||||||
|
|
||||||
List<RegionProfileData> listreg = db.GetRegionsByName("Gotham",10);
|
|
||||||
|
|
||||||
Assert.That(listreg.Count,Is.EqualTo(2), "Assert.That(listreg.Count,Is.EqualTo(2))");
|
|
||||||
Assert.That(listreg[0].Uuid,Is.Not.EqualTo(listreg[1].Uuid), "Assert.That(listreg[0].Uuid,Is.Not.EqualTo(listreg[1].Uuid))");
|
|
||||||
Assert.That(listreg[0].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2), "Assert.That(listreg[0].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2))");
|
|
||||||
Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2), "Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2))");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T999_StillNull()
|
|
||||||
{
|
|
||||||
Assert.That(db.GetProfileByUUID(zero), Is.Null);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static string RandomName()
|
|
||||||
{
|
|
||||||
StringBuilder name = new StringBuilder();
|
|
||||||
int size = random.Next(5,12);
|
|
||||||
char ch ;
|
|
||||||
for (int i=0; i<size; i++)
|
|
||||||
{
|
|
||||||
ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
|
|
||||||
name.Append(ch);
|
|
||||||
}
|
|
||||||
return name.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -524,7 +524,7 @@ namespace OpenSim.Data.Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
//[Test]
|
||||||
public void T016_RandomSogWithSceneParts()
|
public void T016_RandomSogWithSceneParts()
|
||||||
{
|
{
|
||||||
PropertyScrambler<SceneObjectPart> scrambler =
|
PropertyScrambler<SceneObjectPart> scrambler =
|
||||||
|
|
|
@ -1,703 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TODO: Money Transfer, Inventory Transfer and UpdateUserRegion once they exist
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using log4net.Config;
|
|
||||||
using NUnit.Framework;
|
|
||||||
using NUnit.Framework.SyntaxHelpers;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using log4net;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.Tests
|
|
||||||
{
|
|
||||||
public class BasicUserTest
|
|
||||||
{
|
|
||||||
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
public IUserDataPlugin db;
|
|
||||||
public UUID user1;
|
|
||||||
public UUID user2;
|
|
||||||
public UUID user3;
|
|
||||||
public UUID user4;
|
|
||||||
public UUID user5;
|
|
||||||
public UUID webkey;
|
|
||||||
public UUID zero = UUID.Zero;
|
|
||||||
public static Random random;
|
|
||||||
|
|
||||||
public UUID agent1;
|
|
||||||
public UUID agent2;
|
|
||||||
public UUID agent3;
|
|
||||||
public UUID agent4;
|
|
||||||
|
|
||||||
public UUID region1;
|
|
||||||
|
|
||||||
public string fname0;
|
|
||||||
public string lname0;
|
|
||||||
public string fname1;
|
|
||||||
public string lname1;
|
|
||||||
public string fname2;
|
|
||||||
public string lname2;
|
|
||||||
public string fname3;
|
|
||||||
public string lname3;
|
|
||||||
|
|
||||||
public void SuperInit()
|
|
||||||
{
|
|
||||||
OpenSim.Tests.Common.TestLogging.LogToConsole();
|
|
||||||
random = new Random();
|
|
||||||
user1 = UUID.Random();
|
|
||||||
user2 = UUID.Random();
|
|
||||||
user3 = UUID.Random();
|
|
||||||
user4 = UUID.Random();
|
|
||||||
user5 = UUID.Random();
|
|
||||||
agent1 = UUID.Random();
|
|
||||||
agent2 = UUID.Random();
|
|
||||||
agent3 = UUID.Random();
|
|
||||||
agent4 = UUID.Random();
|
|
||||||
webkey = UUID.Random();
|
|
||||||
region1 = UUID.Random();
|
|
||||||
fname0 = RandomName();
|
|
||||||
lname0 = RandomName();
|
|
||||||
fname1 = RandomName();
|
|
||||||
lname1 = RandomName();
|
|
||||||
fname2 = RandomName();
|
|
||||||
lname2 = RandomName();
|
|
||||||
fname3 = RandomName();
|
|
||||||
lname3 = RandomName();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T001_LoadEmpty()
|
|
||||||
{
|
|
||||||
Assert.That(db.GetUserByUUID(zero), Is.Null);
|
|
||||||
Assert.That(db.GetUserByUUID(user1), Is.Null);
|
|
||||||
Assert.That(db.GetUserByUUID(user2), Is.Null);
|
|
||||||
Assert.That(db.GetUserByUUID(user3), Is.Null);
|
|
||||||
Assert.That(db.GetUserByUUID(UUID.Random()), Is.Null);
|
|
||||||
|
|
||||||
Assert.That(db.GetAgentByUUID(zero), Is.Null);
|
|
||||||
Assert.That(db.GetAgentByUUID(agent1), Is.Null);
|
|
||||||
Assert.That(db.GetAgentByUUID(agent2), Is.Null);
|
|
||||||
Assert.That(db.GetAgentByUUID(agent3), Is.Null);
|
|
||||||
Assert.That(db.GetAgentByUUID(UUID.Random()), Is.Null);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T010_CreateUser()
|
|
||||||
{
|
|
||||||
UserProfileData u1 = NewUser(user1,fname1,lname1);
|
|
||||||
UserProfileData u2 = NewUser(user2,fname2,lname2);
|
|
||||||
UserProfileData u3 = NewUser(user3,fname3,lname3);
|
|
||||||
// this is used to check whether null works here
|
|
||||||
u3.Email = null;
|
|
||||||
|
|
||||||
db.AddNewUserProfile(u1);
|
|
||||||
db.AddNewUserProfile(u2);
|
|
||||||
db.AddNewUserProfile(u3);
|
|
||||||
UserProfileData u1a = db.GetUserByUUID(user1);
|
|
||||||
UserProfileData u2a = db.GetUserByUUID(user2);
|
|
||||||
UserProfileData u3a = db.GetUserByUUID(user3);
|
|
||||||
Assert.That(user1,Is.EqualTo(u1a.ID), "Assert.That(user1,Is.EqualTo(u1a.ID))");
|
|
||||||
Assert.That(user2,Is.EqualTo(u2a.ID), "Assert.That(user2,Is.EqualTo(u2a.ID))");
|
|
||||||
Assert.That(user3,Is.EqualTo(u3a.ID), "Assert.That(user3,Is.EqualTo(u3a.ID))");
|
|
||||||
|
|
||||||
// and one email test
|
|
||||||
Assert.That(u3.Email, Is.Null);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T011_FetchUserByName()
|
|
||||||
{
|
|
||||||
UserProfileData u1 = db.GetUserByName(fname1,lname1);
|
|
||||||
UserProfileData u2 = db.GetUserByName(fname2,lname2);
|
|
||||||
UserProfileData u3 = db.GetUserByName(fname3,lname3);
|
|
||||||
Assert.That(user1,Is.EqualTo(u1.ID), "Assert.That(user1,Is.EqualTo(u1.ID))");
|
|
||||||
Assert.That(user2,Is.EqualTo(u2.ID), "Assert.That(user2,Is.EqualTo(u2.ID))");
|
|
||||||
Assert.That(user3,Is.EqualTo(u3.ID), "Assert.That(user3,Is.EqualTo(u3.ID))");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T012_UpdateUserProfile()
|
|
||||||
{
|
|
||||||
UserProfileData u1 = db.GetUserByUUID(user1);
|
|
||||||
Assert.That(fname1,Is.EqualTo(u1.FirstName), "Assert.That(fname1,Is.EqualTo(u1.FirstName))");
|
|
||||||
u1.FirstName = "Ugly";
|
|
||||||
|
|
||||||
db.UpdateUserProfile(u1);
|
|
||||||
Assert.That("Ugly",Is.EqualTo(u1.FirstName), "Assert.That(\"Ugly\",Is.EqualTo(u1.FirstName))");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T013_StoreUserWebKey()
|
|
||||||
{
|
|
||||||
UserProfileData u1 = db.GetUserByUUID(user1);
|
|
||||||
Assert.That(u1.WebLoginKey,Is.EqualTo(zero), "Assert.That(u1.WebLoginKey,Is.EqualTo(zero))");
|
|
||||||
db.StoreWebLoginKey(user1, webkey);
|
|
||||||
u1 = db.GetUserByUUID(user1);
|
|
||||||
Assert.That(u1.WebLoginKey,Is.EqualTo(webkey), "Assert.That(u1.WebLoginKey,Is.EqualTo(webkey))");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T014_ExpectedNullReferenceReturns()
|
|
||||||
{
|
|
||||||
UserProfileData u0 = NewUser(zero,fname0,lname0);
|
|
||||||
UserProfileData u4 = NewUser(user4,fname2,lname2);
|
|
||||||
db.AddNewUserProfile(u0); //UserID 0 should fail to save.
|
|
||||||
db.AddNewUserProfile(u4); //The first name and last name are already in use (from T010), so this should fail too
|
|
||||||
Assert.That(db.GetUserByUUID(zero),Is.Null);
|
|
||||||
Assert.That(db.GetUserByUUID(user4),Is.Null);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T015_UserPersistency()
|
|
||||||
{
|
|
||||||
UserProfileData u = new UserProfileData();
|
|
||||||
UUID id = user5;
|
|
||||||
string fname = RandomName();
|
|
||||||
string lname = RandomName();
|
|
||||||
string email = RandomName();
|
|
||||||
string passhash = RandomName();
|
|
||||||
string passsalt = RandomName();
|
|
||||||
UUID homeregion = UUID.Random();
|
|
||||||
UUID webloginkey = UUID.Random();
|
|
||||||
uint homeregx = (uint) random.Next();
|
|
||||||
uint homeregy = (uint) random.Next();
|
|
||||||
Vector3 homeloc
|
|
||||||
= new Vector3(
|
|
||||||
(float)Math.Round(random.NextDouble(), 5),
|
|
||||||
(float)Math.Round(random.NextDouble(), 5),
|
|
||||||
(float)Math.Round(random.NextDouble(), 5));
|
|
||||||
Vector3 homelookat
|
|
||||||
= new Vector3(
|
|
||||||
(float)Math.Round(random.NextDouble(), 5),
|
|
||||||
(float)Math.Round(random.NextDouble(), 5),
|
|
||||||
(float)Math.Round(random.NextDouble(), 5));
|
|
||||||
int created = random.Next();
|
|
||||||
int lastlogin = random.Next();
|
|
||||||
string userinvuri = RandomName();
|
|
||||||
string userasseturi = RandomName();
|
|
||||||
uint candomask = (uint) random.Next();
|
|
||||||
uint wantdomask = (uint) random.Next();
|
|
||||||
string abouttext = RandomName();
|
|
||||||
string flabouttext = RandomName();
|
|
||||||
UUID image = UUID.Random();
|
|
||||||
UUID firstimage = UUID.Random();
|
|
||||||
UserAgentData agent = NewAgent(id,UUID.Random());
|
|
||||||
int userflags = random.Next();
|
|
||||||
int godlevel = random.Next();
|
|
||||||
string customtype = RandomName();
|
|
||||||
UUID partner = UUID.Random();
|
|
||||||
|
|
||||||
//HomeRegionX and HomeRegionY must only use 24 bits
|
|
||||||
homeregx = ((homeregx << 8) >> 8);
|
|
||||||
homeregy = ((homeregy << 8) >> 8);
|
|
||||||
|
|
||||||
u.ID = id;
|
|
||||||
u.WebLoginKey = webloginkey;
|
|
||||||
u.HomeRegionID = homeregion;
|
|
||||||
u.FirstName = fname;
|
|
||||||
u.SurName = lname;
|
|
||||||
u.Email = email;
|
|
||||||
u.PasswordHash = passhash;
|
|
||||||
u.PasswordSalt = passsalt;
|
|
||||||
u.HomeRegionX = homeregx;
|
|
||||||
u.HomeRegionY = homeregy;
|
|
||||||
ulong homereg = u.HomeRegion;
|
|
||||||
u.HomeLocation = homeloc;
|
|
||||||
u.HomeLookAt = homelookat;
|
|
||||||
u.Created = created;
|
|
||||||
u.LastLogin = lastlogin;
|
|
||||||
u.UserInventoryURI = userinvuri;
|
|
||||||
u.UserAssetURI = userasseturi;
|
|
||||||
u.CanDoMask = candomask;
|
|
||||||
u.WantDoMask = wantdomask;
|
|
||||||
u.AboutText = abouttext;
|
|
||||||
u.FirstLifeAboutText = flabouttext;
|
|
||||||
u.Image = image;
|
|
||||||
u.FirstLifeImage = firstimage;
|
|
||||||
u.CurrentAgent = agent;
|
|
||||||
u.UserFlags = userflags;
|
|
||||||
u.GodLevel = godlevel;
|
|
||||||
u.CustomType = customtype;
|
|
||||||
u.Partner = partner;
|
|
||||||
|
|
||||||
db.AddNewUserProfile(u);
|
|
||||||
UserProfileData u1a = db.GetUserByUUID(id);
|
|
||||||
Assert.That(u1a,Is.Not.Null);
|
|
||||||
Assert.That(id,Is.EqualTo(u1a.ID), "Assert.That(id,Is.EqualTo(u1a.ID))");
|
|
||||||
Assert.That(homeregion,Is.EqualTo(u1a.HomeRegionID), "Assert.That(homeregion,Is.EqualTo(u1a.HomeRegionID))");
|
|
||||||
Assert.That(webloginkey,Is.EqualTo(u1a.WebLoginKey), "Assert.That(webloginkey,Is.EqualTo(u1a.WebLoginKey))");
|
|
||||||
Assert.That(fname,Is.EqualTo(u1a.FirstName), "Assert.That(fname,Is.EqualTo(u1a.FirstName))");
|
|
||||||
Assert.That(lname,Is.EqualTo(u1a.SurName), "Assert.That(lname,Is.EqualTo(u1a.SurName))");
|
|
||||||
Assert.That(email,Is.EqualTo(u1a.Email), "Assert.That(email,Is.EqualTo(u1a.Email))");
|
|
||||||
Assert.That(passhash,Is.EqualTo(u1a.PasswordHash), "Assert.That(passhash,Is.EqualTo(u1a.PasswordHash))");
|
|
||||||
Assert.That(passsalt,Is.EqualTo(u1a.PasswordSalt), "Assert.That(passsalt,Is.EqualTo(u1a.PasswordSalt))");
|
|
||||||
Assert.That(homeregx,Is.EqualTo(u1a.HomeRegionX), "Assert.That(homeregx,Is.EqualTo(u1a.HomeRegionX))");
|
|
||||||
Assert.That(homeregy,Is.EqualTo(u1a.HomeRegionY), "Assert.That(homeregy,Is.EqualTo(u1a.HomeRegionY))");
|
|
||||||
Assert.That(homereg,Is.EqualTo(u1a.HomeRegion), "Assert.That(homereg,Is.EqualTo(u1a.HomeRegion))");
|
|
||||||
Assert.That(homeloc,Is.EqualTo(u1a.HomeLocation), "Assert.That(homeloc,Is.EqualTo(u1a.HomeLocation))");
|
|
||||||
Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt), "Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt))");
|
|
||||||
Assert.That(created,Is.EqualTo(u1a.Created), "Assert.That(created,Is.EqualTo(u1a.Created))");
|
|
||||||
Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin), "Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin))");
|
|
||||||
Assert.That(userinvuri,Is.EqualTo(u1a.UserInventoryURI), "Assert.That(userinvuri,Is.EqualTo(u1a.UserInventoryURI))");
|
|
||||||
Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI), "Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI))");
|
|
||||||
Assert.That(candomask,Is.EqualTo(u1a.CanDoMask), "Assert.That(candomask,Is.EqualTo(u1a.CanDoMask))");
|
|
||||||
Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask), "Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask))");
|
|
||||||
Assert.That(abouttext,Is.EqualTo(u1a.AboutText), "Assert.That(abouttext,Is.EqualTo(u1a.AboutText))");
|
|
||||||
Assert.That(flabouttext,Is.EqualTo(u1a.FirstLifeAboutText), "Assert.That(flabouttext,Is.EqualTo(u1a.FirstLifeAboutText))");
|
|
||||||
Assert.That(image,Is.EqualTo(u1a.Image), "Assert.That(image,Is.EqualTo(u1a.Image))");
|
|
||||||
Assert.That(firstimage,Is.EqualTo(u1a.FirstLifeImage), "Assert.That(firstimage,Is.EqualTo(u1a.FirstLifeImage))");
|
|
||||||
Assert.That(u1a.CurrentAgent,Is.Null);
|
|
||||||
Assert.That(userflags,Is.EqualTo(u1a.UserFlags), "Assert.That(userflags,Is.EqualTo(u1a.UserFlags))");
|
|
||||||
Assert.That(godlevel,Is.EqualTo(u1a.GodLevel), "Assert.That(godlevel,Is.EqualTo(u1a.GodLevel))");
|
|
||||||
Assert.That(customtype,Is.EqualTo(u1a.CustomType), "Assert.That(customtype,Is.EqualTo(u1a.CustomType))");
|
|
||||||
Assert.That(partner,Is.EqualTo(u1a.Partner), "Assert.That(partner,Is.EqualTo(u1a.Partner))");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T016_UserUpdatePersistency()
|
|
||||||
{
|
|
||||||
UUID id = user5;
|
|
||||||
UserProfileData u = db.GetUserByUUID(id);
|
|
||||||
string fname = RandomName();
|
|
||||||
string lname = RandomName();
|
|
||||||
string email = RandomName();
|
|
||||||
string passhash = RandomName();
|
|
||||||
string passsalt = RandomName();
|
|
||||||
UUID homeregionid = UUID.Random();
|
|
||||||
UUID webloginkey = UUID.Random();
|
|
||||||
uint homeregx = (uint) random.Next();
|
|
||||||
uint homeregy = (uint) random.Next();
|
|
||||||
Vector3 homeloc = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5));
|
|
||||||
Vector3 homelookat = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5));
|
|
||||||
int created = random.Next();
|
|
||||||
int lastlogin = random.Next();
|
|
||||||
string userinvuri = RandomName();
|
|
||||||
string userasseturi = RandomName();
|
|
||||||
uint candomask = (uint) random.Next();
|
|
||||||
uint wantdomask = (uint) random.Next();
|
|
||||||
string abouttext = RandomName();
|
|
||||||
string flabouttext = RandomName();
|
|
||||||
UUID image = UUID.Random();
|
|
||||||
UUID firstimage = UUID.Random();
|
|
||||||
UserAgentData agent = NewAgent(id,UUID.Random());
|
|
||||||
int userflags = random.Next();
|
|
||||||
int godlevel = random.Next();
|
|
||||||
string customtype = RandomName();
|
|
||||||
UUID partner = UUID.Random();
|
|
||||||
|
|
||||||
//HomeRegionX and HomeRegionY must only use 24 bits
|
|
||||||
homeregx = ((homeregx << 8) >> 8);
|
|
||||||
homeregy = ((homeregy << 8) >> 8);
|
|
||||||
|
|
||||||
u.WebLoginKey = webloginkey;
|
|
||||||
u.HomeRegionID = homeregionid;
|
|
||||||
u.FirstName = fname;
|
|
||||||
u.SurName = lname;
|
|
||||||
u.Email = email;
|
|
||||||
u.PasswordHash = passhash;
|
|
||||||
u.PasswordSalt = passsalt;
|
|
||||||
u.HomeRegionX = homeregx;
|
|
||||||
u.HomeRegionY = homeregy;
|
|
||||||
ulong homereg = u.HomeRegion;
|
|
||||||
u.HomeLocation = homeloc;
|
|
||||||
u.HomeLookAt = homelookat;
|
|
||||||
u.Created = created;
|
|
||||||
u.LastLogin = lastlogin;
|
|
||||||
u.UserInventoryURI = userinvuri;
|
|
||||||
u.UserAssetURI = userasseturi;
|
|
||||||
u.CanDoMask = candomask;
|
|
||||||
u.WantDoMask = wantdomask;
|
|
||||||
u.AboutText = abouttext;
|
|
||||||
u.FirstLifeAboutText = flabouttext;
|
|
||||||
u.Image = image;
|
|
||||||
u.FirstLifeImage = firstimage;
|
|
||||||
u.CurrentAgent = agent;
|
|
||||||
u.UserFlags = userflags;
|
|
||||||
u.GodLevel = godlevel;
|
|
||||||
u.CustomType = customtype;
|
|
||||||
u.Partner = partner;
|
|
||||||
|
|
||||||
db.UpdateUserProfile(u);
|
|
||||||
UserProfileData u1a = db.GetUserByUUID(id);
|
|
||||||
Assert.That(u1a,Is.Not.Null);
|
|
||||||
Assert.That(id,Is.EqualTo(u1a.ID), "Assert.That(id,Is.EqualTo(u1a.ID))");
|
|
||||||
Assert.That(homeregionid,Is.EqualTo(u1a.HomeRegionID), "Assert.That(homeregionid,Is.EqualTo(u1a.HomeRegionID))");
|
|
||||||
Assert.That(webloginkey,Is.EqualTo(u1a.WebLoginKey), "Assert.That(webloginkey,Is.EqualTo(u1a.WebLoginKey))");
|
|
||||||
Assert.That(fname,Is.EqualTo(u1a.FirstName), "Assert.That(fname,Is.EqualTo(u1a.FirstName))");
|
|
||||||
Assert.That(lname,Is.EqualTo(u1a.SurName), "Assert.That(lname,Is.EqualTo(u1a.SurName))");
|
|
||||||
Assert.That(email,Is.EqualTo(u1a.Email), "Assert.That(email,Is.EqualTo(u1a.Email))");
|
|
||||||
Assert.That(passhash,Is.EqualTo(u1a.PasswordHash), "Assert.That(passhash,Is.EqualTo(u1a.PasswordHash))");
|
|
||||||
Assert.That(passsalt,Is.EqualTo(u1a.PasswordSalt), "Assert.That(passsalt,Is.EqualTo(u1a.PasswordSalt))");
|
|
||||||
Assert.That(homereg,Is.EqualTo(u1a.HomeRegion), "Assert.That(homereg,Is.EqualTo(u1a.HomeRegion))");
|
|
||||||
Assert.That(homeregx,Is.EqualTo(u1a.HomeRegionX), "Assert.That(homeregx,Is.EqualTo(u1a.HomeRegionX))");
|
|
||||||
Assert.That(homeregy,Is.EqualTo(u1a.HomeRegionY), "Assert.That(homeregy,Is.EqualTo(u1a.HomeRegionY))");
|
|
||||||
Assert.That(homereg,Is.EqualTo(u1a.HomeRegion), "Assert.That(homereg,Is.EqualTo(u1a.HomeRegion))");
|
|
||||||
Assert.That(homeloc,Is.EqualTo(u1a.HomeLocation), "Assert.That(homeloc,Is.EqualTo(u1a.HomeLocation))");
|
|
||||||
Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt), "Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt))");
|
|
||||||
Assert.That(created,Is.EqualTo(u1a.Created), "Assert.That(created,Is.EqualTo(u1a.Created))");
|
|
||||||
Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin), "Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin))");
|
|
||||||
Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI), "Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI))");
|
|
||||||
Assert.That(candomask,Is.EqualTo(u1a.CanDoMask), "Assert.That(candomask,Is.EqualTo(u1a.CanDoMask))");
|
|
||||||
Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask), "Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask))");
|
|
||||||
Assert.That(abouttext,Is.EqualTo(u1a.AboutText), "Assert.That(abouttext,Is.EqualTo(u1a.AboutText))");
|
|
||||||
Assert.That(flabouttext,Is.EqualTo(u1a.FirstLifeAboutText), "Assert.That(flabouttext,Is.EqualTo(u1a.FirstLifeAboutText))");
|
|
||||||
Assert.That(image,Is.EqualTo(u1a.Image), "Assert.That(image,Is.EqualTo(u1a.Image))");
|
|
||||||
Assert.That(firstimage,Is.EqualTo(u1a.FirstLifeImage), "Assert.That(firstimage,Is.EqualTo(u1a.FirstLifeImage))");
|
|
||||||
Assert.That(u1a.CurrentAgent,Is.Null);
|
|
||||||
Assert.That(userflags,Is.EqualTo(u1a.UserFlags), "Assert.That(userflags,Is.EqualTo(u1a.UserFlags))");
|
|
||||||
Assert.That(godlevel,Is.EqualTo(u1a.GodLevel), "Assert.That(godlevel,Is.EqualTo(u1a.GodLevel))");
|
|
||||||
Assert.That(customtype,Is.EqualTo(u1a.CustomType), "Assert.That(customtype,Is.EqualTo(u1a.CustomType))");
|
|
||||||
Assert.That(partner,Is.EqualTo(u1a.Partner), "Assert.That(partner,Is.EqualTo(u1a.Partner))");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T017_UserUpdateRandomPersistency()
|
|
||||||
{
|
|
||||||
UUID id = user5;
|
|
||||||
UserProfileData u = db.GetUserByUUID(id);
|
|
||||||
new PropertyScrambler<UserProfileData>().DontScramble(x=>x.ID).Scramble(u);
|
|
||||||
|
|
||||||
db.UpdateUserProfile(u);
|
|
||||||
UserProfileData u1a = db.GetUserByUUID(id);
|
|
||||||
Assert.That(u1a, Constraints.PropertyCompareConstraint(u)
|
|
||||||
.IgnoreProperty(x=>x.HomeRegionX)
|
|
||||||
.IgnoreProperty(x=>x.HomeRegionY)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T020_CreateAgent()
|
|
||||||
{
|
|
||||||
UserAgentData a1 = NewAgent(user1,agent1);
|
|
||||||
UserAgentData a2 = NewAgent(user2,agent2);
|
|
||||||
UserAgentData a3 = NewAgent(user3,agent3);
|
|
||||||
db.AddNewUserAgent(a1);
|
|
||||||
db.AddNewUserAgent(a2);
|
|
||||||
db.AddNewUserAgent(a3);
|
|
||||||
UserAgentData a1a = db.GetAgentByUUID(user1);
|
|
||||||
UserAgentData a2a = db.GetAgentByUUID(user2);
|
|
||||||
UserAgentData a3a = db.GetAgentByUUID(user3);
|
|
||||||
Assert.That(agent1,Is.EqualTo(a1a.SessionID), "Assert.That(agent1,Is.EqualTo(a1a.SessionID))");
|
|
||||||
Assert.That(user1,Is.EqualTo(a1a.ProfileID), "Assert.That(user1,Is.EqualTo(a1a.ProfileID))");
|
|
||||||
Assert.That(agent2,Is.EqualTo(a2a.SessionID), "Assert.That(agent2,Is.EqualTo(a2a.SessionID))");
|
|
||||||
Assert.That(user2,Is.EqualTo(a2a.ProfileID), "Assert.That(user2,Is.EqualTo(a2a.ProfileID))");
|
|
||||||
Assert.That(agent3,Is.EqualTo(a3a.SessionID), "Assert.That(agent3,Is.EqualTo(a3a.SessionID))");
|
|
||||||
Assert.That(user3,Is.EqualTo(a3a.ProfileID), "Assert.That(user3,Is.EqualTo(a3a.ProfileID))");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T021_FetchAgentByName()
|
|
||||||
{
|
|
||||||
String name3 = fname3 + " " + lname3;
|
|
||||||
UserAgentData a2 = db.GetAgentByName(fname2,lname2);
|
|
||||||
UserAgentData a3 = db.GetAgentByName(name3);
|
|
||||||
Assert.That(user2,Is.EqualTo(a2.ProfileID), "Assert.That(user2,Is.EqualTo(a2.ProfileID))");
|
|
||||||
Assert.That(user3,Is.EqualTo(a3.ProfileID), "Assert.That(user3,Is.EqualTo(a3.ProfileID))");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T022_ExceptionalCases()
|
|
||||||
{
|
|
||||||
UserAgentData a0 = NewAgent(user4,zero);
|
|
||||||
UserAgentData a4 = NewAgent(zero,agent4);
|
|
||||||
db.AddNewUserAgent(a0);
|
|
||||||
db.AddNewUserAgent(a4);
|
|
||||||
|
|
||||||
Assert.That(db.GetAgentByUUID(user4),Is.Null);
|
|
||||||
Assert.That(db.GetAgentByUUID(zero),Is.Null);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T023_AgentPersistency()
|
|
||||||
{
|
|
||||||
UUID user = user4;
|
|
||||||
UUID agent = agent4;
|
|
||||||
UUID secureagent = UUID.Random();
|
|
||||||
string agentip = RandomName();
|
|
||||||
uint agentport = (uint)random.Next();
|
|
||||||
bool agentonline = (random.NextDouble() > 0.5);
|
|
||||||
int logintime = random.Next();
|
|
||||||
int logouttime = random.Next();
|
|
||||||
UUID regionid = UUID.Random();
|
|
||||||
ulong regionhandle = (ulong) random.Next();
|
|
||||||
Vector3 currentpos = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5));
|
|
||||||
Vector3 currentlookat = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5));
|
|
||||||
UUID orgregionid = UUID.Random();
|
|
||||||
|
|
||||||
UserAgentData a = new UserAgentData();
|
|
||||||
a.ProfileID = user;
|
|
||||||
a.SessionID = agent;
|
|
||||||
a.SecureSessionID = secureagent;
|
|
||||||
a.AgentIP = agentip;
|
|
||||||
a.AgentPort = agentport;
|
|
||||||
a.AgentOnline = agentonline;
|
|
||||||
a.LoginTime = logintime;
|
|
||||||
a.LogoutTime = logouttime;
|
|
||||||
a.Region = regionid;
|
|
||||||
a.Handle = regionhandle;
|
|
||||||
a.Position = currentpos;
|
|
||||||
a.LookAt = currentlookat;
|
|
||||||
a.InitialRegion = orgregionid;
|
|
||||||
|
|
||||||
db.AddNewUserAgent(a);
|
|
||||||
|
|
||||||
UserAgentData a1 = db.GetAgentByUUID(user4);
|
|
||||||
Assert.That(user,Is.EqualTo(a1.ProfileID), "Assert.That(user,Is.EqualTo(a1.ProfileID))");
|
|
||||||
Assert.That(agent,Is.EqualTo(a1.SessionID), "Assert.That(agent,Is.EqualTo(a1.SessionID))");
|
|
||||||
Assert.That(secureagent,Is.EqualTo(a1.SecureSessionID), "Assert.That(secureagent,Is.EqualTo(a1.SecureSessionID))");
|
|
||||||
Assert.That(agentip,Is.EqualTo(a1.AgentIP), "Assert.That(agentip,Is.EqualTo(a1.AgentIP))");
|
|
||||||
Assert.That(agentport,Is.EqualTo(a1.AgentPort), "Assert.That(agentport,Is.EqualTo(a1.AgentPort))");
|
|
||||||
Assert.That(agentonline,Is.EqualTo(a1.AgentOnline), "Assert.That(agentonline,Is.EqualTo(a1.AgentOnline))");
|
|
||||||
Assert.That(logintime,Is.EqualTo(a1.LoginTime), "Assert.That(logintime,Is.EqualTo(a1.LoginTime))");
|
|
||||||
Assert.That(logouttime,Is.EqualTo(a1.LogoutTime), "Assert.That(logouttime,Is.EqualTo(a1.LogoutTime))");
|
|
||||||
Assert.That(regionid,Is.EqualTo(a1.Region), "Assert.That(regionid,Is.EqualTo(a1.Region))");
|
|
||||||
Assert.That(regionhandle,Is.EqualTo(a1.Handle), "Assert.That(regionhandle,Is.EqualTo(a1.Handle))");
|
|
||||||
Assert.That(currentpos,Is.EqualTo(a1.Position), "Assert.That(currentpos,Is.EqualTo(a1.Position))");
|
|
||||||
Assert.That(currentlookat,Is.EqualTo(a1.LookAt), "Assert.That(currentlookat,Is.EqualTo(a1.LookAt))");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T030_CreateFriendList()
|
|
||||||
{
|
|
||||||
Dictionary<UUID, uint> perms = new Dictionary<UUID,uint>();
|
|
||||||
Dictionary<UUID, int> friends = new Dictionary<UUID,int>();
|
|
||||||
uint temp;
|
|
||||||
int tempu1, tempu2;
|
|
||||||
db.AddNewUserFriend(user1,user2, 1);
|
|
||||||
db.AddNewUserFriend(user1,user3, 2);
|
|
||||||
db.AddNewUserFriend(user1,user2, 4);
|
|
||||||
List<FriendListItem> fl1 = db.GetUserFriendList(user1);
|
|
||||||
Assert.That(fl1.Count,Is.EqualTo(2), "Assert.That(fl1.Count,Is.EqualTo(2))");
|
|
||||||
perms.Add(user2,1);
|
|
||||||
perms.Add(user3,2);
|
|
||||||
for (int i = 0; i < fl1.Count; i++)
|
|
||||||
{
|
|
||||||
Assert.That(user1,Is.EqualTo(fl1[i].FriendListOwner), "Assert.That(user1,Is.EqualTo(fl1[i].FriendListOwner))");
|
|
||||||
friends.Add(fl1[i].Friend,1);
|
|
||||||
temp = perms[fl1[i].Friend];
|
|
||||||
Assert.That(temp,Is.EqualTo(fl1[i].FriendPerms), "Assert.That(temp,Is.EqualTo(fl1[i].FriendPerms))");
|
|
||||||
}
|
|
||||||
tempu1 = friends[user2];
|
|
||||||
tempu2 = friends[user3];
|
|
||||||
Assert.That(1,Is.EqualTo(tempu1) & Is.EqualTo(tempu2), "Assert.That(1,Is.EqualTo(tempu1) & Is.EqualTo(tempu2))");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T031_RemoveUserFriend()
|
|
||||||
// user1 has 2 friends, user2 and user3.
|
|
||||||
{
|
|
||||||
List<FriendListItem> fl1 = db.GetUserFriendList(user1);
|
|
||||||
List<FriendListItem> fl2 = db.GetUserFriendList(user2);
|
|
||||||
|
|
||||||
Assert.That(fl1.Count,Is.EqualTo(2), "Assert.That(fl1.Count,Is.EqualTo(2))");
|
|
||||||
Assert.That(fl1[0].Friend,Is.EqualTo(user2) | Is.EqualTo(user3), "Assert.That(fl1[0].Friend,Is.EqualTo(user2) | Is.EqualTo(user3))");
|
|
||||||
Assert.That(fl2[0].Friend,Is.EqualTo(user1), "Assert.That(fl2[0].Friend,Is.EqualTo(user1))");
|
|
||||||
db.RemoveUserFriend(user2, user1);
|
|
||||||
|
|
||||||
fl1 = db.GetUserFriendList(user1);
|
|
||||||
fl2 = db.GetUserFriendList(user2);
|
|
||||||
Assert.That(fl1.Count,Is.EqualTo(1), "Assert.That(fl1.Count,Is.EqualTo(1))");
|
|
||||||
Assert.That(fl1[0].Friend, Is.EqualTo(user3), "Assert.That(fl1[0].Friend, Is.EqualTo(user3))");
|
|
||||||
Assert.That(fl2, Is.Empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T032_UpdateFriendPerms()
|
|
||||||
// user1 has 1 friend, user3, who has permission 2 in T030.
|
|
||||||
{
|
|
||||||
List<FriendListItem> fl1 = db.GetUserFriendList(user1);
|
|
||||||
Assert.That(fl1[0].FriendPerms,Is.EqualTo(2), "Assert.That(fl1[0].FriendPerms,Is.EqualTo(2))");
|
|
||||||
db.UpdateUserFriendPerms(user1, user3, 4);
|
|
||||||
|
|
||||||
fl1 = db.GetUserFriendList(user1);
|
|
||||||
Assert.That(fl1[0].FriendPerms,Is.EqualTo(4), "Assert.That(fl1[0].FriendPerms,Is.EqualTo(4))");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T040_UserAppearance()
|
|
||||||
{
|
|
||||||
AvatarAppearance appear = new AvatarAppearance();
|
|
||||||
appear.Owner = user1;
|
|
||||||
db.UpdateUserAppearance(user1, appear);
|
|
||||||
AvatarAppearance user1app = db.GetUserAppearance(user1);
|
|
||||||
Assert.That(user1,Is.EqualTo(user1app.Owner), "Assert.That(user1,Is.EqualTo(user1app.Owner))");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T041_UserAppearancePersistency()
|
|
||||||
{
|
|
||||||
AvatarAppearance appear = new AvatarAppearance();
|
|
||||||
UUID owner = UUID.Random();
|
|
||||||
int serial = random.Next();
|
|
||||||
byte[] visualp = new byte[218];
|
|
||||||
random.NextBytes(visualp);
|
|
||||||
UUID bodyitem = UUID.Random();
|
|
||||||
UUID bodyasset = UUID.Random();
|
|
||||||
UUID skinitem = UUID.Random();
|
|
||||||
UUID skinasset = UUID.Random();
|
|
||||||
UUID hairitem = UUID.Random();
|
|
||||||
UUID hairasset = UUID.Random();
|
|
||||||
UUID eyesitem = UUID.Random();
|
|
||||||
UUID eyesasset = UUID.Random();
|
|
||||||
UUID shirtitem = UUID.Random();
|
|
||||||
UUID shirtasset = UUID.Random();
|
|
||||||
UUID pantsitem = UUID.Random();
|
|
||||||
UUID pantsasset = UUID.Random();
|
|
||||||
UUID shoesitem = UUID.Random();
|
|
||||||
UUID shoesasset = UUID.Random();
|
|
||||||
UUID socksitem = UUID.Random();
|
|
||||||
UUID socksasset = UUID.Random();
|
|
||||||
UUID jacketitem = UUID.Random();
|
|
||||||
UUID jacketasset = UUID.Random();
|
|
||||||
UUID glovesitem = UUID.Random();
|
|
||||||
UUID glovesasset = UUID.Random();
|
|
||||||
UUID ushirtitem = UUID.Random();
|
|
||||||
UUID ushirtasset = UUID.Random();
|
|
||||||
UUID upantsitem = UUID.Random();
|
|
||||||
UUID upantsasset = UUID.Random();
|
|
||||||
UUID skirtitem = UUID.Random();
|
|
||||||
UUID skirtasset = UUID.Random();
|
|
||||||
Primitive.TextureEntry texture = AvatarAppearance.GetDefaultTexture();
|
|
||||||
float avatarheight = (float) (Math.Round(random.NextDouble(),5));
|
|
||||||
|
|
||||||
appear.Owner = owner;
|
|
||||||
appear.Serial = serial;
|
|
||||||
appear.VisualParams = visualp;
|
|
||||||
appear.BodyItem = bodyitem;
|
|
||||||
appear.BodyAsset = bodyasset;
|
|
||||||
appear.SkinItem = skinitem;
|
|
||||||
appear.SkinAsset = skinasset;
|
|
||||||
appear.HairItem = hairitem;
|
|
||||||
appear.HairAsset = hairasset;
|
|
||||||
appear.EyesItem = eyesitem;
|
|
||||||
appear.EyesAsset = eyesasset;
|
|
||||||
appear.ShirtItem = shirtitem;
|
|
||||||
appear.ShirtAsset = shirtasset;
|
|
||||||
appear.PantsItem = pantsitem;
|
|
||||||
appear.PantsAsset = pantsasset;
|
|
||||||
appear.ShoesItem = shoesitem;
|
|
||||||
appear.ShoesAsset = shoesasset;
|
|
||||||
appear.SocksItem = socksitem;
|
|
||||||
appear.SocksAsset = socksasset;
|
|
||||||
appear.JacketItem = jacketitem;
|
|
||||||
appear.JacketAsset = jacketasset;
|
|
||||||
appear.GlovesItem = glovesitem;
|
|
||||||
appear.GlovesAsset = glovesasset;
|
|
||||||
appear.UnderShirtItem = ushirtitem;
|
|
||||||
appear.UnderShirtAsset = ushirtasset;
|
|
||||||
appear.UnderPantsItem = upantsitem;
|
|
||||||
appear.UnderPantsAsset = upantsasset;
|
|
||||||
appear.SkirtItem = skirtitem;
|
|
||||||
appear.SkirtAsset = skirtasset;
|
|
||||||
appear.Texture = texture;
|
|
||||||
appear.AvatarHeight = avatarheight;
|
|
||||||
|
|
||||||
db.UpdateUserAppearance(owner, appear);
|
|
||||||
AvatarAppearance app = db.GetUserAppearance(owner);
|
|
||||||
|
|
||||||
Assert.That(owner,Is.EqualTo(app.Owner), "Assert.That(owner,Is.EqualTo(app.Owner))");
|
|
||||||
Assert.That(serial,Is.EqualTo(app.Serial), "Assert.That(serial,Is.EqualTo(app.Serial))");
|
|
||||||
Assert.That(visualp,Is.EqualTo(app.VisualParams), "Assert.That(visualp,Is.EqualTo(app.VisualParams))");
|
|
||||||
Assert.That(bodyitem,Is.EqualTo(app.BodyItem), "Assert.That(bodyitem,Is.EqualTo(app.BodyItem))");
|
|
||||||
Assert.That(bodyasset,Is.EqualTo(app.BodyAsset), "Assert.That(bodyasset,Is.EqualTo(app.BodyAsset))");
|
|
||||||
Assert.That(skinitem,Is.EqualTo(app.SkinItem), "Assert.That(skinitem,Is.EqualTo(app.SkinItem))");
|
|
||||||
Assert.That(skinasset,Is.EqualTo(app.SkinAsset), "Assert.That(skinasset,Is.EqualTo(app.SkinAsset))");
|
|
||||||
Assert.That(hairitem,Is.EqualTo(app.HairItem), "Assert.That(hairitem,Is.EqualTo(app.HairItem))");
|
|
||||||
Assert.That(hairasset,Is.EqualTo(app.HairAsset), "Assert.That(hairasset,Is.EqualTo(app.HairAsset))");
|
|
||||||
Assert.That(eyesitem,Is.EqualTo(app.EyesItem), "Assert.That(eyesitem,Is.EqualTo(app.EyesItem))");
|
|
||||||
Assert.That(eyesasset,Is.EqualTo(app.EyesAsset), "Assert.That(eyesasset,Is.EqualTo(app.EyesAsset))");
|
|
||||||
Assert.That(shirtitem,Is.EqualTo(app.ShirtItem), "Assert.That(shirtitem,Is.EqualTo(app.ShirtItem))");
|
|
||||||
Assert.That(shirtasset,Is.EqualTo(app.ShirtAsset), "Assert.That(shirtasset,Is.EqualTo(app.ShirtAsset))");
|
|
||||||
Assert.That(pantsitem,Is.EqualTo(app.PantsItem), "Assert.That(pantsitem,Is.EqualTo(app.PantsItem))");
|
|
||||||
Assert.That(pantsasset,Is.EqualTo(app.PantsAsset), "Assert.That(pantsasset,Is.EqualTo(app.PantsAsset))");
|
|
||||||
Assert.That(shoesitem,Is.EqualTo(app.ShoesItem), "Assert.That(shoesitem,Is.EqualTo(app.ShoesItem))");
|
|
||||||
Assert.That(shoesasset,Is.EqualTo(app.ShoesAsset), "Assert.That(shoesasset,Is.EqualTo(app.ShoesAsset))");
|
|
||||||
Assert.That(socksitem,Is.EqualTo(app.SocksItem), "Assert.That(socksitem,Is.EqualTo(app.SocksItem))");
|
|
||||||
Assert.That(socksasset,Is.EqualTo(app.SocksAsset), "Assert.That(socksasset,Is.EqualTo(app.SocksAsset))");
|
|
||||||
Assert.That(jacketitem,Is.EqualTo(app.JacketItem), "Assert.That(jacketitem,Is.EqualTo(app.JacketItem))");
|
|
||||||
Assert.That(jacketasset,Is.EqualTo(app.JacketAsset), "Assert.That(jacketasset,Is.EqualTo(app.JacketAsset))");
|
|
||||||
Assert.That(glovesitem,Is.EqualTo(app.GlovesItem), "Assert.That(glovesitem,Is.EqualTo(app.GlovesItem))");
|
|
||||||
Assert.That(glovesasset,Is.EqualTo(app.GlovesAsset), "Assert.That(glovesasset,Is.EqualTo(app.GlovesAsset))");
|
|
||||||
Assert.That(ushirtitem,Is.EqualTo(app.UnderShirtItem), "Assert.That(ushirtitem,Is.EqualTo(app.UnderShirtItem))");
|
|
||||||
Assert.That(ushirtasset,Is.EqualTo(app.UnderShirtAsset), "Assert.That(ushirtasset,Is.EqualTo(app.UnderShirtAsset))");
|
|
||||||
Assert.That(upantsitem,Is.EqualTo(app.UnderPantsItem), "Assert.That(upantsitem,Is.EqualTo(app.UnderPantsItem))");
|
|
||||||
Assert.That(upantsasset,Is.EqualTo(app.UnderPantsAsset), "Assert.That(upantsasset,Is.EqualTo(app.UnderPantsAsset))");
|
|
||||||
Assert.That(skirtitem,Is.EqualTo(app.SkirtItem), "Assert.That(skirtitem,Is.EqualTo(app.SkirtItem))");
|
|
||||||
Assert.That(skirtasset,Is.EqualTo(app.SkirtAsset), "Assert.That(skirtasset,Is.EqualTo(app.SkirtAsset))");
|
|
||||||
Assert.That(texture.ToString(),Is.EqualTo(app.Texture.ToString()), "Assert.That(texture.ToString(),Is.EqualTo(app.Texture.ToString()))");
|
|
||||||
Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight), "Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight))");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T999_StillNull()
|
|
||||||
{
|
|
||||||
Assert.That(db.GetUserByUUID(zero), Is.Null);
|
|
||||||
Assert.That(db.GetAgentByUUID(zero), Is.Null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserProfileData NewUser(UUID id,string fname,string lname)
|
|
||||||
{
|
|
||||||
UserProfileData u = new UserProfileData();
|
|
||||||
u.ID = id;
|
|
||||||
u.FirstName = fname;
|
|
||||||
u.SurName = lname;
|
|
||||||
u.PasswordHash = "NOTAHASH";
|
|
||||||
u.PasswordSalt = "NOTSALT";
|
|
||||||
// MUST specify at least these 5 parameters or an exception is raised
|
|
||||||
|
|
||||||
return u;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserAgentData NewAgent(UUID user_profile, UUID agent)
|
|
||||||
{
|
|
||||||
UserAgentData a = new UserAgentData();
|
|
||||||
a.ProfileID = user_profile;
|
|
||||||
a.SessionID = agent;
|
|
||||||
a.SecureSessionID = UUID.Random();
|
|
||||||
a.AgentIP = RandomName();
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string RandomName()
|
|
||||||
{
|
|
||||||
StringBuilder name = new StringBuilder();
|
|
||||||
int size = random.Next(5,12);
|
|
||||||
char ch ;
|
|
||||||
for (int i=0; i<size; i++)
|
|
||||||
{
|
|
||||||
ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
|
|
||||||
name.Append(ch);
|
|
||||||
}
|
|
||||||
return name.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;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
|
|
||||||
namespace OpenSim.Data
|
|
||||||
{
|
|
||||||
public abstract class UserDataBase : IUserDataPlugin
|
|
||||||
{
|
|
||||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
// private Dictionary<UUID, AvatarAppearance> aplist = new Dictionary<UUID, AvatarAppearance>();
|
|
||||||
|
|
||||||
public abstract UserProfileData GetUserByUUID(UUID user);
|
|
||||||
public abstract UserProfileData GetUserByName(string fname, string lname);
|
|
||||||
public abstract UserAgentData GetAgentByUUID(UUID user);
|
|
||||||
public abstract UserAgentData GetAgentByName(string name);
|
|
||||||
public abstract UserAgentData GetAgentByName(string fname, string lname);
|
|
||||||
public UserProfileData GetUserByUri(Uri uri) { return null; }
|
|
||||||
public abstract void StoreWebLoginKey(UUID agentID, UUID webLoginKey);
|
|
||||||
public abstract void AddNewUserProfile(UserProfileData user);
|
|
||||||
|
|
||||||
public virtual void AddTemporaryUserProfile(UserProfileData userProfile)
|
|
||||||
{
|
|
||||||
// Deliberately blank - database plugins shouldn't store temporary profiles.
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract bool UpdateUserProfile(UserProfileData user);
|
|
||||||
public abstract void AddNewUserAgent(UserAgentData agent);
|
|
||||||
public abstract void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms);
|
|
||||||
public abstract void RemoveUserFriend(UUID friendlistowner, UUID friend);
|
|
||||||
public abstract void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms);
|
|
||||||
public abstract List<FriendListItem> GetUserFriendList(UUID friendlistowner);
|
|
||||||
public abstract Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids);
|
|
||||||
public abstract bool MoneyTransferRequest(UUID from, UUID to, uint amount);
|
|
||||||
public abstract bool InventoryTransferRequest(UUID from, UUID to, UUID inventory);
|
|
||||||
public abstract List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query);
|
|
||||||
public abstract AvatarAppearance GetUserAppearance(UUID user);
|
|
||||||
public abstract void UpdateUserAppearance(UUID user, AvatarAppearance appearance);
|
|
||||||
// public virtual AvatarAppearance GetUserAppearance(UUID user) {
|
|
||||||
// AvatarAppearance aa = null;
|
|
||||||
// try {
|
|
||||||
// aa = aplist[user];
|
|
||||||
// m_log.Info("[APPEARANCE] Found appearance for " + user.ToString() + aa.ToString());
|
|
||||||
// } catch (System.Collections.Generic.KeyNotFoundException e) {
|
|
||||||
// m_log.Info("[APPEARANCE] No appearance found for " + user.ToString());
|
|
||||||
// }
|
|
||||||
// return aa;
|
|
||||||
// }
|
|
||||||
// public virtual void UpdateUserAppearance(UUID user, AvatarAppearance appearance) {
|
|
||||||
// aplist[user] = appearance;
|
|
||||||
// m_log.Info("[APPEARANCE] Setting appearance for " + user.ToString() + appearance.ToString());
|
|
||||||
// }
|
|
||||||
public abstract void ResetAttachments(UUID userID);
|
|
||||||
|
|
||||||
public abstract void LogoutUsers(UUID regionID);
|
|
||||||
|
|
||||||
public abstract string Version {get;}
|
|
||||||
public abstract string Name {get;}
|
|
||||||
public abstract void Initialise(string connect);
|
|
||||||
public abstract void Initialise();
|
|
||||||
public abstract void Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,104 +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 OpenMetaverse;
|
|
||||||
using OpenSim.Data;
|
|
||||||
|
|
||||||
namespace OpenSim.Framework.Communications
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Plugin for managing temporary user profiles.
|
|
||||||
/// </summary>
|
|
||||||
public class TemporaryUserProfilePlugin : IUserDataPlugin
|
|
||||||
{
|
|
||||||
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
protected Dictionary<UUID, UserProfileData> m_profiles = new Dictionary<UUID, UserProfileData>();
|
|
||||||
|
|
||||||
public string Name { get { return "TemporaryUserProfilePlugin"; } }
|
|
||||||
public string Version { get { return "0.1"; } }
|
|
||||||
public void Initialise() {}
|
|
||||||
public void Initialise(string connect) {}
|
|
||||||
public void Dispose() {}
|
|
||||||
|
|
||||||
public UserProfileData GetUserByUUID(UUID user)
|
|
||||||
{
|
|
||||||
//m_log.DebugFormat("[TEMP USER PROFILE]: Received request for {0}", user);
|
|
||||||
|
|
||||||
lock (m_profiles)
|
|
||||||
{
|
|
||||||
if (m_profiles.ContainsKey(user))
|
|
||||||
return m_profiles[user];
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserProfileData GetUserByName(string fname, string lname)
|
|
||||||
{
|
|
||||||
// We deliberately don't look up a temporary profile by name so that we don't obscure non-temporary
|
|
||||||
// profiles.
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void AddTemporaryUserProfile(UserProfileData userProfile)
|
|
||||||
{
|
|
||||||
//m_log.DebugFormat("[TEMP USER PROFILE]: Adding {0} {1}", userProfile.Name, userProfile.ID);
|
|
||||||
|
|
||||||
lock (m_profiles)
|
|
||||||
{
|
|
||||||
m_profiles[userProfile.ID] = userProfile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserProfileData GetUserByUri(Uri uri) { return null; }
|
|
||||||
public List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query) { return null; }
|
|
||||||
public UserAgentData GetAgentByUUID(UUID user) { return null; }
|
|
||||||
public UserAgentData GetAgentByName(string name) { return null; }
|
|
||||||
public UserAgentData GetAgentByName(string fname, string lname) { return null; }
|
|
||||||
public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) {}
|
|
||||||
public void AddNewUserProfile(UserProfileData user) {}
|
|
||||||
public bool UpdateUserProfile(UserProfileData user) { return false; }
|
|
||||||
public void AddNewUserAgent(UserAgentData agent) {}
|
|
||||||
public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) {}
|
|
||||||
public void RemoveUserFriend(UUID friendlistowner, UUID friend) {}
|
|
||||||
public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) {}
|
|
||||||
public List<FriendListItem> GetUserFriendList(UUID friendlistowner) { return null; }
|
|
||||||
public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids) { return null; }
|
|
||||||
public bool MoneyTransferRequest(UUID from, UUID to, uint amount) { return false; }
|
|
||||||
public bool InventoryTransferRequest(UUID from, UUID to, UUID inventory) { return false; }
|
|
||||||
public AvatarAppearance GetUserAppearance(UUID user) { return null; }
|
|
||||||
public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) {}
|
|
||||||
public void ResetAttachments(UUID userID) {}
|
|
||||||
public void LogoutUsers(UUID regionID) {}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -483,7 +483,6 @@ namespace OpenSim.Framework
|
||||||
else
|
else
|
||||||
m_externalHostName = externalName;
|
m_externalHostName = externalName;
|
||||||
|
|
||||||
|
|
||||||
m_regionType = config.GetString("RegionType", String.Empty);
|
m_regionType = config.GetString("RegionType", String.Empty);
|
||||||
|
|
||||||
// Prim stuff
|
// Prim stuff
|
||||||
|
|
|
@ -589,11 +589,17 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
public static IPAddress GetLocalHost()
|
public static IPAddress GetLocalHost()
|
||||||
{
|
{
|
||||||
string dnsAddress = "localhost";
|
IPAddress[] iplist = GetLocalHosts();
|
||||||
|
|
||||||
IPAddress[] hosts = Dns.GetHostEntry(dnsAddress).AddressList;
|
if (iplist.Length == 0) // No accessible external interfaces
|
||||||
|
{
|
||||||
|
IPAddress[] loopback = Dns.GetHostAddresses("localhost");
|
||||||
|
IPAddress localhost = loopback[0];
|
||||||
|
|
||||||
foreach (IPAddress host in hosts)
|
return localhost;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (IPAddress host in iplist)
|
||||||
{
|
{
|
||||||
if (!IPAddress.IsLoopback(host) && host.AddressFamily == AddressFamily.InterNetwork)
|
if (!IPAddress.IsLoopback(host) && host.AddressFamily == AddressFamily.InterNetwork)
|
||||||
{
|
{
|
||||||
|
@ -601,15 +607,15 @@ namespace OpenSim.Framework
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hosts.Length > 0)
|
if (iplist.Length > 0)
|
||||||
{
|
{
|
||||||
foreach (IPAddress host in hosts)
|
foreach (IPAddress host in iplist)
|
||||||
{
|
{
|
||||||
if (host.AddressFamily == AddressFamily.InterNetwork)
|
if (host.AddressFamily == AddressFamily.InterNetwork)
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
// Well all else failed...
|
// Well all else failed...
|
||||||
return hosts[0];
|
return iplist[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -194,6 +194,8 @@ namespace OpenSim
|
||||||
|
|
||||||
PrintFileToConsole("startuplogo.txt");
|
PrintFileToConsole("startuplogo.txt");
|
||||||
|
|
||||||
|
m_log.InfoFormat("[NETWORK]: Using {0} as SYSTEMIP", Util.GetLocalHost().ToString());
|
||||||
|
|
||||||
// For now, start at the 'root' level by default
|
// For now, start at the 'root' level by default
|
||||||
if (m_sceneManager.Scenes.Count == 1) // If there is only one region, select it
|
if (m_sceneManager.Scenes.Count == 1) // If there is only one region, select it
|
||||||
ChangeSelectedRegion("region",
|
ChangeSelectedRegion("region",
|
||||||
|
@ -624,7 +626,6 @@ namespace OpenSim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Load, Unload, and list Region modules in use
|
/// Load, Unload, and list Region modules in use
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -924,7 +925,6 @@ namespace OpenSim
|
||||||
scene.RegionInfo.RegionLocX,
|
scene.RegionInfo.RegionLocX,
|
||||||
scene.RegionInfo.RegionLocY,
|
scene.RegionInfo.RegionLocY,
|
||||||
scene.RegionInfo.InternalEndPoint.Port));
|
scene.RegionInfo.InternalEndPoint.Port));
|
||||||
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -69,7 +69,7 @@ namespace Flotsam.RegionModules.AssetCache
|
||||||
|
|
||||||
private readonly List<char> m_InvalidChars = new List<char>();
|
private readonly List<char> m_InvalidChars = new List<char>();
|
||||||
|
|
||||||
private int m_LogLevel = 1;
|
private int m_LogLevel = 0;
|
||||||
private ulong m_HitRateDisplay = 1; // How often to display hit statistics, given in requests
|
private ulong m_HitRateDisplay = 1; // How often to display hit statistics, given in requests
|
||||||
|
|
||||||
private static ulong m_Requests;
|
private static ulong m_Requests;
|
||||||
|
@ -156,7 +156,7 @@ namespace Flotsam.RegionModules.AssetCache
|
||||||
m_WaitOnInprogressTimeout = assetConfig.GetInt("WaitOnInprogressTimeout", 3000);
|
m_WaitOnInprogressTimeout = assetConfig.GetInt("WaitOnInprogressTimeout", 3000);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_LogLevel = assetConfig.GetInt("LogLevel", 1);
|
m_LogLevel = assetConfig.GetInt("LogLevel", 0);
|
||||||
m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1000);
|
m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1000);
|
||||||
|
|
||||||
m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration));
|
m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration));
|
||||||
|
|
|
@ -159,7 +159,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule
|
||||||
avatar.Invulnerable = true;
|
avatar.Invulnerable = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,8 +130,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
if (userInfo != null)
|
if (userInfo != null)
|
||||||
{
|
{
|
||||||
if (CheckPresence(userInfo.PrincipalID))
|
if (CheckPresence(userInfo.PrincipalID))
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute();
|
new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute();
|
||||||
|
}
|
||||||
|
catch (EntryPointNotFoundException e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
|
||||||
|
+ "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
|
||||||
|
m_log.Error(e);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -155,8 +168,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
if (userInfo != null)
|
if (userInfo != null)
|
||||||
{
|
{
|
||||||
if (CheckPresence(userInfo.PrincipalID))
|
if (CheckPresence(userInfo.PrincipalID))
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute();
|
new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute();
|
||||||
|
}
|
||||||
|
catch (EntryPointNotFoundException e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
|
||||||
|
+ "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
|
||||||
|
m_log.Error(e);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -181,8 +207,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
{
|
{
|
||||||
if (CheckPresence(userInfo.PrincipalID))
|
if (CheckPresence(userInfo.PrincipalID))
|
||||||
{
|
{
|
||||||
InventoryArchiveReadRequest request =
|
InventoryArchiveReadRequest request;
|
||||||
new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream);
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream);
|
||||||
|
}
|
||||||
|
catch (EntryPointNotFoundException e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
|
||||||
|
+ "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
|
||||||
|
m_log.Error(e);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
UpdateClientWithLoadedNodes(userInfo, request.Execute());
|
UpdateClientWithLoadedNodes(userInfo, request.Execute());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -209,8 +249,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
{
|
{
|
||||||
if (CheckPresence(userInfo.PrincipalID))
|
if (CheckPresence(userInfo.PrincipalID))
|
||||||
{
|
{
|
||||||
InventoryArchiveReadRequest request =
|
InventoryArchiveReadRequest request;
|
||||||
new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath);
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath);
|
||||||
|
}
|
||||||
|
catch (EntryPointNotFoundException e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
|
||||||
|
+ "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
|
||||||
|
m_log.Error(e);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
UpdateClientWithLoadedNodes(userInfo, request.Execute());
|
UpdateClientWithLoadedNodes(userInfo, request.Execute());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
|
||||||
config.AddConfig("GridService");
|
config.AddConfig("GridService");
|
||||||
config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector");
|
config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector");
|
||||||
config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
|
config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
|
||||||
config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData");
|
config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
|
||||||
|
|
||||||
m_LocalConnector = new LocalGridServicesConnector(config);
|
m_LocalConnector = new LocalGridServicesConnector(config);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
|
||||||
r2.HttpPort = 9002;
|
r2.HttpPort = 9002;
|
||||||
r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
|
r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
|
||||||
s = new Scene(new RegionInfo());
|
s = new Scene(new RegionInfo());
|
||||||
s.RegionInfo.RegionID = r1.RegionID;
|
s.RegionInfo.RegionID = r2.RegionID;
|
||||||
m_LocalConnector.AddRegion(s);
|
m_LocalConnector.AddRegion(s);
|
||||||
|
|
||||||
GridRegion r3 = new GridRegion();
|
GridRegion r3 = new GridRegion();
|
||||||
|
@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
|
||||||
r3.HttpPort = 9003;
|
r3.HttpPort = 9003;
|
||||||
r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
|
r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
|
||||||
s = new Scene(new RegionInfo());
|
s = new Scene(new RegionInfo());
|
||||||
s.RegionInfo.RegionID = r1.RegionID;
|
s.RegionInfo.RegionID = r3.RegionID;
|
||||||
m_LocalConnector.AddRegion(s);
|
m_LocalConnector.AddRegion(s);
|
||||||
|
|
||||||
m_LocalConnector.RegisterRegion(UUID.Zero, r1);
|
m_LocalConnector.RegisterRegion(UUID.Zero, r1);
|
||||||
|
|
|
@ -314,7 +314,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
||||||
item = m_InventoryService.GetItem(item);
|
item = m_InventoryService.GetItem(item);
|
||||||
|
|
||||||
if (null == item)
|
if (null == item)
|
||||||
m_log.ErrorFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find item with id {0}");
|
m_log.ErrorFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find item with id {0}", item.ID);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests
|
||||||
config.AddConfig("PresenceService");
|
config.AddConfig("PresenceService");
|
||||||
config.Configs["Modules"].Set("PresenceServices", "LocalPresenceServicesConnector");
|
config.Configs["Modules"].Set("PresenceServices", "LocalPresenceServicesConnector");
|
||||||
config.Configs["PresenceService"].Set("LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService");
|
config.Configs["PresenceService"].Set("LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService");
|
||||||
config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullPresenceData");
|
config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
|
||||||
|
|
||||||
m_LocalConnector = new LocalPresenceServicesConnector(config);
|
m_LocalConnector = new LocalPresenceServicesConnector(config);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||||
public ArchiveReadRequest(Scene scene, string loadPath, bool merge, Guid requestId)
|
public ArchiveReadRequest(Scene scene, string loadPath, bool merge, Guid requestId)
|
||||||
{
|
{
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress);
|
m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress);
|
||||||
|
}
|
||||||
|
catch (EntryPointNotFoundException e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
|
||||||
|
+ "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
|
||||||
|
m_log.Error(e);
|
||||||
|
}
|
||||||
|
|
||||||
m_errorMessage = String.Empty;
|
m_errorMessage = String.Empty;
|
||||||
m_merge = merge;
|
m_merge = merge;
|
||||||
m_requestId = requestId;
|
m_requestId = requestId;
|
||||||
|
|
|
@ -65,7 +65,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||||
public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId)
|
public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId)
|
||||||
{
|
{
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress);
|
m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress);
|
||||||
|
}
|
||||||
|
catch (EntryPointNotFoundException e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
|
||||||
|
+ "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
|
||||||
|
m_log.Error(e);
|
||||||
|
}
|
||||||
|
|
||||||
m_requestId = requestId;
|
m_requestId = requestId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
|
||||||
SerialiserModule serialiserModule = new SerialiserModule();
|
SerialiserModule serialiserModule = new SerialiserModule();
|
||||||
TerrainModule terrainModule = new TerrainModule();
|
TerrainModule terrainModule = new TerrainModule();
|
||||||
|
|
||||||
m_scene = SceneSetupHelpers.SetupScene("scene1");
|
m_scene = SceneSetupHelpers.SetupScene("useraccounts");
|
||||||
SceneSetupHelpers.SetupSceneModules(m_scene, m_archiverModule, serialiserModule, terrainModule);
|
SceneSetupHelpers.SetupSceneModules(m_scene, m_archiverModule, serialiserModule, terrainModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -262,7 +262,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// Returns a new unallocated local ID
|
/// Returns a new unallocated local ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A brand new local ID</returns>
|
/// <returns>A brand new local ID</returns>
|
||||||
protected internal uint AllocateLocalId()
|
public uint AllocateLocalId()
|
||||||
{
|
{
|
||||||
uint myID;
|
uint myID;
|
||||||
|
|
||||||
|
|
|
@ -1505,6 +1505,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// <param name="part"></param>
|
/// <param name="part"></param>
|
||||||
internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags)
|
internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags)
|
||||||
{
|
{
|
||||||
|
// m_log.DebugFormat(
|
||||||
|
// "[SOG]: Sendinging part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId);
|
||||||
|
|
||||||
if (m_rootPart.UUID == part.UUID)
|
if (m_rootPart.UUID == part.UUID)
|
||||||
{
|
{
|
||||||
if (IsAttachment)
|
if (IsAttachment)
|
||||||
|
@ -2297,7 +2300,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
AttachToBackup();
|
AttachToBackup();
|
||||||
|
|
||||||
|
|
||||||
// Here's the deal, this is ABSOLUTELY CRITICAL so the physics scene gets the update about the
|
// Here's the deal, this is ABSOLUTELY CRITICAL so the physics scene gets the update about the
|
||||||
// position of linkset prims. IF YOU CHANGE THIS, YOU MUST TEST colliding with just linked and
|
// position of linkset prims. IF YOU CHANGE THIS, YOU MUST TEST colliding with just linked and
|
||||||
// unmoved prims!
|
// unmoved prims!
|
||||||
|
@ -2312,9 +2314,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// an independent SceneObjectGroup.
|
/// an independent SceneObjectGroup.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="partID"></param>
|
/// <param name="partID"></param>
|
||||||
public void DelinkFromGroup(uint partID)
|
/// <returns>The object group of the newly delinked prim. Null if part could not be found</returns>
|
||||||
|
public SceneObjectGroup DelinkFromGroup(uint partID)
|
||||||
{
|
{
|
||||||
DelinkFromGroup(partID, true);
|
return DelinkFromGroup(partID, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -2323,29 +2326,40 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="partID"></param>
|
/// <param name="partID"></param>
|
||||||
/// <param name="sendEvents"></param>
|
/// <param name="sendEvents"></param>
|
||||||
public void DelinkFromGroup(uint partID, bool sendEvents)
|
/// <returns>The object group of the newly delinked prim. Null if part could not be found</returns>
|
||||||
|
public SceneObjectGroup DelinkFromGroup(uint partID, bool sendEvents)
|
||||||
{
|
{
|
||||||
SceneObjectPart linkPart = GetChildPart(partID);
|
SceneObjectPart linkPart = GetChildPart(partID);
|
||||||
|
|
||||||
if (linkPart != null)
|
if (linkPart != null)
|
||||||
{
|
{
|
||||||
DelinkFromGroup(linkPart, sendEvents);
|
return DelinkFromGroup(linkPart, sendEvents);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.InfoFormat("[SCENE OBJECT GROUP]: " +
|
m_log.WarnFormat("[SCENE OBJECT GROUP]: " +
|
||||||
"DelinkFromGroup(): Child prim {0} not found in object {1}, {2}",
|
"DelinkFromGroup(): Child prim {0} not found in object {1}, {2}",
|
||||||
partID, LocalId, UUID);
|
partID, LocalId, UUID);
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DelinkFromGroup(SceneObjectPart linkPart, bool sendEvents)
|
/// <summary>
|
||||||
|
/// Delink the given prim from this group. The delinked prim is established as
|
||||||
|
/// an independent SceneObjectGroup.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="partID"></param>
|
||||||
|
/// <param name="sendEvents"></param>
|
||||||
|
/// <returns>The object group of the newly delinked prim.</returns>
|
||||||
|
public SceneObjectGroup DelinkFromGroup(SceneObjectPart linkPart, bool sendEvents)
|
||||||
{
|
{
|
||||||
linkPart.ClearUndoState();
|
|
||||||
// m_log.DebugFormat(
|
// m_log.DebugFormat(
|
||||||
// "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}",
|
// "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}",
|
||||||
// linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID);
|
// linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID);
|
||||||
|
|
||||||
|
linkPart.ClearUndoState();
|
||||||
|
|
||||||
Quaternion worldRot = linkPart.GetWorldRotation();
|
Quaternion worldRot = linkPart.GetWorldRotation();
|
||||||
|
|
||||||
// Remove the part from this object
|
// Remove the part from this object
|
||||||
|
@ -2397,6 +2411,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
//HasGroupChanged = true;
|
//HasGroupChanged = true;
|
||||||
//ScheduleGroupForFullUpdate();
|
//ScheduleGroupForFullUpdate();
|
||||||
|
|
||||||
|
return objectGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -2435,7 +2451,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
part.LinkNum = linkNum;
|
part.LinkNum = linkNum;
|
||||||
|
|
||||||
|
|
||||||
part.OffsetPosition = part.GroupPosition - AbsolutePosition;
|
part.OffsetPosition = part.GroupPosition - AbsolutePosition;
|
||||||
|
|
||||||
Quaternion rootRotation = m_rootPart.RotationOffset;
|
Quaternion rootRotation = m_rootPart.RotationOffset;
|
||||||
|
|
|
@ -1241,14 +1241,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_pos.X < 0)
|
|
||||||
m_pos.X = 128;
|
|
||||||
if (m_pos.Y < 0)
|
|
||||||
m_pos.Y = 128;
|
|
||||||
if (m_pos.X > Scene.WestBorders[0].BorderLine.X)
|
|
||||||
m_pos.X = 128;
|
|
||||||
if (m_pos.Y > Scene.NorthBorders[0].BorderLine.Y)
|
|
||||||
m_pos.Y = 128;
|
|
||||||
m_LastFinitePos = m_pos;
|
m_LastFinitePos = m_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2817,12 +2809,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
if (neighbor <= 0)
|
if (neighbor <= 0)
|
||||||
{
|
{
|
||||||
if (!needsTransit)
|
if (!needsTransit)
|
||||||
|
{
|
||||||
|
if (m_requestedSitTargetUUID == UUID.Zero)
|
||||||
{
|
{
|
||||||
Vector3 pos = AbsolutePosition;
|
Vector3 pos = AbsolutePosition;
|
||||||
if (AbsolutePosition.X < 0)
|
if (AbsolutePosition.X < 0)
|
||||||
pos.X += Velocity.Y;
|
pos.X += Velocity.X;
|
||||||
else if (AbsolutePosition.X > Constants.RegionSize)
|
else if (AbsolutePosition.X > Constants.RegionSize)
|
||||||
pos.X -= Velocity.Y;
|
pos.X -= Velocity.X;
|
||||||
if (AbsolutePosition.Y < 0)
|
if (AbsolutePosition.Y < 0)
|
||||||
pos.Y += Velocity.Y;
|
pos.Y += Velocity.Y;
|
||||||
else if (AbsolutePosition.Y > Constants.RegionSize)
|
else if (AbsolutePosition.Y > Constants.RegionSize)
|
||||||
|
@ -2830,6 +2824,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
AbsolutePosition = pos;
|
AbsolutePosition = pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (neighbor > 0)
|
else if (neighbor > 0)
|
||||||
CrossToNewRegion();
|
CrossToNewRegion();
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,6 @@ using OpenSim.Region.Framework.Scenes;
|
||||||
using Caps = OpenSim.Framework.Capabilities.Caps;
|
using Caps = OpenSim.Framework.Capabilities.Caps;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
|
||||||
namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
|
namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
|
||||||
{
|
{
|
||||||
public class FreeSwitchVoiceModule : IRegionModule, IVoiceModule
|
public class FreeSwitchVoiceModule : IRegionModule, IVoiceModule
|
||||||
|
@ -203,10 +202,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
|
||||||
FreeSwitchSLVoiceBuddyHTTPHandler);
|
FreeSwitchSLVoiceBuddyHTTPHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_log.InfoFormat("[FreeSwitchVoice] using FreeSwitch server {0}", m_freeSwitchRealm);
|
m_log.InfoFormat("[FreeSwitchVoice] using FreeSwitch server {0}", m_freeSwitchRealm);
|
||||||
|
|
||||||
m_FreeSwitchDirectory = new FreeSwitchDirectory();
|
m_FreeSwitchDirectory = new FreeSwitchDirectory();
|
||||||
|
@ -234,8 +229,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
|
||||||
OnRegisterCaps(scene, agentID, caps);
|
OnRegisterCaps(scene, agentID, caps);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ServicePointManager.ServerCertificateValidationCallback += CustomCertificateValidation;
|
ServicePointManager.ServerCertificateValidationCallback += CustomCertificateValidation;
|
||||||
|
@ -254,7 +247,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
|
||||||
m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions.");
|
m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,8 +447,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
|
||||||
throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available",
|
throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available",
|
||||||
scene.RegionInfo.RegionName, avatarName));
|
scene.RegionInfo.RegionName, avatarName));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// get channel_uri: check first whether estate
|
// get channel_uri: check first whether estate
|
||||||
// settings allow voice, then whether parcel allows
|
// settings allow voice, then whether parcel allows
|
||||||
// voice, if all do retrieve or obtain the parcel
|
// voice, if all do retrieve or obtain the parcel
|
||||||
|
@ -508,7 +498,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Callback for a client request for ChatSessionRequest
|
/// Callback for a client request for ChatSessionRequest
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -551,7 +540,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
|
||||||
int fwdresponsecode = 200;
|
int fwdresponsecode = 200;
|
||||||
string fwdresponsecontenttype = "text/xml";
|
string fwdresponsecontenttype = "text/xml";
|
||||||
|
|
||||||
|
|
||||||
HttpWebRequest forwardreq = (HttpWebRequest)WebRequest.Create(forwardaddress);
|
HttpWebRequest forwardreq = (HttpWebRequest)WebRequest.Create(forwardaddress);
|
||||||
forwardreq.Method = method;
|
forwardreq.Method = method;
|
||||||
forwardreq.ContentType = contenttype;
|
forwardreq.ContentType = contenttype;
|
||||||
|
@ -712,7 +700,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
|
||||||
pos++;
|
pos++;
|
||||||
if (s == userid)
|
if (s == userid)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -786,8 +773,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
|
||||||
// split string
|
// split string
|
||||||
string [] nvps = body.Split(new Char [] {'&'});
|
string [] nvps = body.Split(new Char [] {'&'});
|
||||||
|
|
||||||
foreach (string s in nvps) {
|
foreach (string s in nvps)
|
||||||
|
{
|
||||||
if (s.Trim() != "")
|
if (s.Trim() != "")
|
||||||
{
|
{
|
||||||
string [] nvp = s.Split(new Char [] {'='});
|
string [] nvp = s.Split(new Char [] {'='});
|
||||||
|
@ -800,7 +787,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
|
||||||
|
|
||||||
private string ChannelUri(Scene scene, LandData land)
|
private string ChannelUri(Scene scene, LandData land)
|
||||||
{
|
{
|
||||||
|
|
||||||
string channelUri = null;
|
string channelUri = null;
|
||||||
|
|
||||||
string landUUID;
|
string landUUID;
|
||||||
|
@ -852,11 +838,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
|
||||||
|
|
||||||
private static bool CustomCertificateValidation(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error)
|
private static bool CustomCertificateValidation(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error)
|
||||||
{
|
{
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public class MonoCert : ICertificatePolicy
|
public class MonoCert : ICertificatePolicy
|
||||||
{
|
{
|
||||||
#region ICertificatePolicy Members
|
#region ICertificatePolicy Members
|
||||||
|
|
|
@ -34,6 +34,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
||||||
{
|
{
|
||||||
public interface IAvatar : IEntity
|
public interface IAvatar : IEntity
|
||||||
{
|
{
|
||||||
|
|
||||||
|
bool IsChildAgent { get; }
|
||||||
|
|
||||||
//// <value>
|
//// <value>
|
||||||
/// Array of worn attachments, empty but not null, if no attachments are worn
|
/// Array of worn attachments, empty but not null, if no attachments are worn
|
||||||
/// </value>
|
/// </value>
|
||||||
|
|
|
@ -70,6 +70,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
||||||
set { GetSP().TeleportWithMomentum(value); }
|
set { GetSP().TeleportWithMomentum(value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsChildAgent
|
||||||
|
{
|
||||||
|
get { return GetSP().IsChildAgent; }
|
||||||
|
}
|
||||||
|
|
||||||
#region IAvatar implementation
|
#region IAvatar implementation
|
||||||
public IAvatarAttachment[] Attachments
|
public IAvatarAttachment[] Attachments
|
||||||
{
|
{
|
||||||
|
|
|
@ -106,12 +106,17 @@ namespace OpenSim.Services.AuthenticationService
|
||||||
string passwordSalt = Util.Md5Hash(UUID.Random().ToString());
|
string passwordSalt = Util.Md5Hash(UUID.Random().ToString());
|
||||||
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + passwordSalt);
|
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + passwordSalt);
|
||||||
|
|
||||||
AuthenticationData auth = new AuthenticationData();
|
AuthenticationData auth = m_Database.Get(principalID);
|
||||||
|
if (auth == null)
|
||||||
|
{
|
||||||
|
auth = new AuthenticationData();
|
||||||
auth.PrincipalID = principalID;
|
auth.PrincipalID = principalID;
|
||||||
auth.Data = new System.Collections.Generic.Dictionary<string, object>();
|
auth.Data = new System.Collections.Generic.Dictionary<string, object>();
|
||||||
|
auth.Data["accountType"] = "UserAccount";
|
||||||
|
auth.Data["webLoginKey"] = UUID.Zero.ToString();
|
||||||
|
}
|
||||||
auth.Data["passwordHash"] = md5PasswdHash;
|
auth.Data["passwordHash"] = md5PasswdHash;
|
||||||
auth.Data["passwordSalt"] = passwordSalt;
|
auth.Data["passwordSalt"] = passwordSalt;
|
||||||
auth.Data["webLoginKey"] = UUID.Zero.ToString();
|
|
||||||
if (!m_Database.Store(auth))
|
if (!m_Database.Store(auth))
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[AUTHENTICATION DB]: Failed to store authentication data");
|
m_log.DebugFormat("[AUTHENTICATION DB]: Failed to store authentication data");
|
||||||
|
|
|
@ -84,8 +84,9 @@ namespace OpenSim.Services.Base
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("XXX Exception " + e.StackTrace);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,8 @@ namespace OpenSim.Services.GridService
|
||||||
{
|
{
|
||||||
m_RootInstance = this;
|
m_RootInstance = this;
|
||||||
|
|
||||||
|
if (MainConsole.Instance != null)
|
||||||
|
{
|
||||||
MainConsole.Instance.Commands.AddCommand("grid", true,
|
MainConsole.Instance.Commands.AddCommand("grid", true,
|
||||||
"show region",
|
"show region",
|
||||||
"show region <Region name>",
|
"show region <Region name>",
|
||||||
|
@ -95,7 +97,7 @@ namespace OpenSim.Services.GridService
|
||||||
"Set database flags for region",
|
"Set database flags for region",
|
||||||
String.Empty,
|
String.Empty,
|
||||||
HandleSetFlags);
|
HandleSetFlags);
|
||||||
|
}
|
||||||
m_HypergridLinker = new HypergridLinker(m_config, this, m_Database);
|
m_HypergridLinker = new HypergridLinker(m_config, this, m_Database);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,8 @@ namespace OpenSim.Services.GridService
|
||||||
m_log.DebugFormat("[HYPERGRID LINKER]: Loaded all services...");
|
m_log.DebugFormat("[HYPERGRID LINKER]: Loaded all services...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (MainConsole.Instance != null)
|
||||||
|
{
|
||||||
MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region",
|
MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region",
|
||||||
"link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
|
"link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
|
||||||
"Link a hypergrid region", RunCommand);
|
"Link a hypergrid region", RunCommand);
|
||||||
|
@ -126,6 +127,7 @@ namespace OpenSim.Services.GridService
|
||||||
MainConsole.Instance.Commands.AddCommand("hypergrid", false, "show hyperlinks", "show hyperlinks <cr>",
|
MainConsole.Instance.Commands.AddCommand("hypergrid", false, "show hyperlinks", "show hyperlinks <cr>",
|
||||||
"List the HG regions", HandleShow);
|
"List the HG regions", HandleShow);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#region Link Region
|
#region Link Region
|
||||||
|
|
|
@ -77,6 +77,8 @@ namespace OpenSim.Services.UserAccountService
|
||||||
if (invServiceDll != string.Empty)
|
if (invServiceDll != string.Empty)
|
||||||
m_InventoryService = LoadPlugin<IInventoryService>(invServiceDll, new Object[] { config });
|
m_InventoryService = LoadPlugin<IInventoryService>(invServiceDll, new Object[] { config });
|
||||||
|
|
||||||
|
if (MainConsole.Instance != null)
|
||||||
|
{
|
||||||
MainConsole.Instance.Commands.AddCommand("UserService", false,
|
MainConsole.Instance.Commands.AddCommand("UserService", false,
|
||||||
"create user",
|
"create user",
|
||||||
"create user [<first> [<last> [<pass> [<email>]]]]",
|
"create user [<first> [<last> [<pass> [<email>]]]]",
|
||||||
|
@ -84,6 +86,7 @@ namespace OpenSim.Services.UserAccountService
|
||||||
MainConsole.Instance.Commands.AddCommand("UserService", false, "reset user password",
|
MainConsole.Instance.Commands.AddCommand("UserService", false, "reset user password",
|
||||||
"reset user password [<first> [<last> [<password>]]]",
|
"reset user password [<first> [<last> [<password>]]]",
|
||||||
"Reset a user password", HandleResetUserPassword);
|
"Reset a user password", HandleResetUserPassword);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,216 +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 OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using OpenSim.Data;
|
|
||||||
|
|
||||||
namespace OpenSim.Tests.Common.Mock
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// In memory user data provider. Might be quite useful as a proper user data plugin, though getting mono addins
|
|
||||||
/// to load any plugins when running unit tests has proven impossible so far. Currently no locking since unit
|
|
||||||
/// tests are single threaded.
|
|
||||||
/// </summary>
|
|
||||||
public class TestUserDataPlugin : IUserDataPlugin
|
|
||||||
{
|
|
||||||
public string Version { get { return "0"; } }
|
|
||||||
public string Name { get { return "TestUserDataPlugin"; } }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// User profiles keyed by name
|
|
||||||
/// </summary>
|
|
||||||
private Dictionary<string, UserProfileData> m_userProfilesByName = new Dictionary<string, UserProfileData>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// User profiles keyed by uuid
|
|
||||||
/// </summary>
|
|
||||||
private Dictionary<UUID, UserProfileData> m_userProfilesByUuid = new Dictionary<UUID, UserProfileData>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// User profiles and their agents
|
|
||||||
/// </summary>
|
|
||||||
private Dictionary<UUID, UserAgentData> m_agentByProfileUuid = new Dictionary<UUID, UserAgentData>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Friends list by uuid
|
|
||||||
/// </summary>
|
|
||||||
private Dictionary<UUID, List<FriendListItem>> m_friendsListByUuid = new Dictionary<UUID, List<FriendListItem>>();
|
|
||||||
|
|
||||||
public void Initialise() {}
|
|
||||||
public void Dispose() {}
|
|
||||||
|
|
||||||
public void AddTemporaryUserProfile(UserProfileData userProfile)
|
|
||||||
{
|
|
||||||
// Not interested
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddNewUserProfile(UserProfileData user)
|
|
||||||
{
|
|
||||||
UpdateUserProfile(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserProfileData GetUserByUUID(UUID user)
|
|
||||||
{
|
|
||||||
UserProfileData userProfile = null;
|
|
||||||
m_userProfilesByUuid.TryGetValue(user, out userProfile);
|
|
||||||
|
|
||||||
return userProfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserProfileData GetUserByName(string fname, string lname)
|
|
||||||
{
|
|
||||||
UserProfileData userProfile = null;
|
|
||||||
m_userProfilesByName.TryGetValue(fname + " " + lname, out userProfile);
|
|
||||||
|
|
||||||
return userProfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserProfileData GetUserByUri(Uri uri) { return null; }
|
|
||||||
|
|
||||||
public bool UpdateUserProfile(UserProfileData user)
|
|
||||||
{
|
|
||||||
m_userProfilesByUuid[user.ID] = user;
|
|
||||||
m_userProfilesByName[user.FirstName + " " + user.SurName] = user;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query) { return null; }
|
|
||||||
|
|
||||||
public UserAgentData GetAgentByUUID(UUID user)
|
|
||||||
{
|
|
||||||
UserAgentData userAgent = null;
|
|
||||||
m_agentByProfileUuid.TryGetValue(user, out userAgent);
|
|
||||||
|
|
||||||
return userAgent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserAgentData GetAgentByName(string name)
|
|
||||||
{
|
|
||||||
UserProfileData userProfile = null;
|
|
||||||
m_userProfilesByName.TryGetValue(name, out userProfile);
|
|
||||||
UserAgentData userAgent = null;
|
|
||||||
m_agentByProfileUuid.TryGetValue(userProfile.ID, out userAgent);
|
|
||||||
|
|
||||||
return userAgent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserAgentData GetAgentByName(string fname, string lname)
|
|
||||||
{
|
|
||||||
UserProfileData userProfile = GetUserByName(fname,lname);
|
|
||||||
UserAgentData userAgent = null;
|
|
||||||
m_agentByProfileUuid.TryGetValue(userProfile.ID, out userAgent);
|
|
||||||
|
|
||||||
return userAgent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) {}
|
|
||||||
|
|
||||||
public void AddNewUserAgent(UserAgentData agent)
|
|
||||||
{
|
|
||||||
m_agentByProfileUuid[agent.ProfileID] = agent;
|
|
||||||
}
|
|
||||||
public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
|
|
||||||
{
|
|
||||||
FriendListItem newfriend = new FriendListItem();
|
|
||||||
newfriend.FriendPerms = perms;
|
|
||||||
newfriend.Friend = friend;
|
|
||||||
newfriend.FriendListOwner = friendlistowner;
|
|
||||||
|
|
||||||
if (!m_friendsListByUuid.ContainsKey(friendlistowner))
|
|
||||||
{
|
|
||||||
List<FriendListItem> friendslist = new List<FriendListItem>();
|
|
||||||
m_friendsListByUuid[friendlistowner] = friendslist;
|
|
||||||
|
|
||||||
}
|
|
||||||
m_friendsListByUuid[friendlistowner].Add(newfriend);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveUserFriend(UUID friendlistowner, UUID friend)
|
|
||||||
{
|
|
||||||
if (m_friendsListByUuid.ContainsKey(friendlistowner))
|
|
||||||
{
|
|
||||||
List<FriendListItem> friendslist = m_friendsListByUuid[friendlistowner];
|
|
||||||
foreach (FriendListItem frienditem in friendslist)
|
|
||||||
{
|
|
||||||
if (frienditem.Friend == friend)
|
|
||||||
{
|
|
||||||
friendslist.Remove(frienditem);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
|
|
||||||
{
|
|
||||||
if (m_friendsListByUuid.ContainsKey(friendlistowner))
|
|
||||||
{
|
|
||||||
List<FriendListItem> friendslist = m_friendsListByUuid[friendlistowner];
|
|
||||||
foreach (FriendListItem frienditem in friendslist)
|
|
||||||
{
|
|
||||||
if (frienditem.Friend == friend)
|
|
||||||
{
|
|
||||||
frienditem.FriendPerms = perms;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<FriendListItem> GetUserFriendList(UUID friendlistowner)
|
|
||||||
{
|
|
||||||
if (m_friendsListByUuid.ContainsKey(friendlistowner))
|
|
||||||
{
|
|
||||||
return m_friendsListByUuid[friendlistowner];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return new List<FriendListItem>();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids) { return null; }
|
|
||||||
|
|
||||||
public bool MoneyTransferRequest(UUID from, UUID to, uint amount) { return false; }
|
|
||||||
|
|
||||||
public bool InventoryTransferRequest(UUID from, UUID to, UUID inventory) { return false; }
|
|
||||||
|
|
||||||
public void Initialise(string connect) { return; }
|
|
||||||
|
|
||||||
public AvatarAppearance GetUserAppearance(UUID user) { return null; }
|
|
||||||
|
|
||||||
public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) {}
|
|
||||||
|
|
||||||
public void ResetAttachments(UUID userID) {}
|
|
||||||
|
|
||||||
public void LogoutUsers(UUID regionID) {}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -45,6 +45,7 @@ using OpenSim.Region.CoreModules.Avatar.Gods;
|
||||||
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset;
|
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset;
|
||||||
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory;
|
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory;
|
||||||
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
|
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
|
||||||
|
using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts;
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
using OpenSim.Tests.Common.Mock;
|
using OpenSim.Tests.Common.Mock;
|
||||||
|
|
||||||
|
@ -60,6 +61,7 @@ namespace OpenSim.Tests.Common.Setup
|
||||||
private static ISharedRegionModule m_assetService = null;
|
private static ISharedRegionModule m_assetService = null;
|
||||||
private static ISharedRegionModule m_inventoryService = null;
|
private static ISharedRegionModule m_inventoryService = null;
|
||||||
private static ISharedRegionModule m_gridService = null;
|
private static ISharedRegionModule m_gridService = null;
|
||||||
|
private static ISharedRegionModule m_userAccountService = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set up a test scene
|
/// Set up a test scene
|
||||||
|
@ -183,6 +185,8 @@ namespace OpenSim.Tests.Common.Setup
|
||||||
StartInventoryService(testScene, false);
|
StartInventoryService(testScene, false);
|
||||||
if (realServices.Contains("grid"))
|
if (realServices.Contains("grid"))
|
||||||
StartGridService(testScene, true);
|
StartGridService(testScene, true);
|
||||||
|
if (realServices.Contains("useraccounts"))
|
||||||
|
StartUserAccountService(testScene, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
// If not, make sure the shared module gets references to this new scene
|
// If not, make sure the shared module gets references to this new scene
|
||||||
|
@ -269,6 +273,28 @@ namespace OpenSim.Tests.Common.Setup
|
||||||
//testScene.AddRegionModule(m_gridService.Name, m_gridService);
|
//testScene.AddRegionModule(m_gridService.Name, m_gridService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void StartUserAccountService(Scene testScene, bool real)
|
||||||
|
{
|
||||||
|
IConfigSource config = new IniConfigSource();
|
||||||
|
config.AddConfig("Modules");
|
||||||
|
config.AddConfig("UserAccountService");
|
||||||
|
config.Configs["Modules"].Set("UserAccountServices", "LocalUserAccountServicesConnector");
|
||||||
|
config.Configs["UserAccountService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
|
||||||
|
if (real)
|
||||||
|
config.Configs["UserAccountService"].Set("LocalServiceModule", "OpenSim.Services.UserAccountService.dll:UserAccountService");
|
||||||
|
if (m_userAccountService == null)
|
||||||
|
{
|
||||||
|
ISharedRegionModule userAccountService = new LocalUserAccountServicesConnector();
|
||||||
|
userAccountService.Initialise(config);
|
||||||
|
m_userAccountService = userAccountService;
|
||||||
|
}
|
||||||
|
//else
|
||||||
|
// config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestGridService");
|
||||||
|
m_userAccountService.AddRegion(testScene);
|
||||||
|
m_userAccountService.RegionLoaded(testScene);
|
||||||
|
//testScene.AddRegionModule(m_gridService.Name, m_gridService);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Setup modules for a scene using their default settings.
|
/// Setup modules for a scene using their default settings.
|
||||||
|
|
|
@ -122,17 +122,3 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
|
||||||
LibraryService = "OpenSim.Services.InventoryService.dll:LibraryService"
|
LibraryService = "OpenSim.Services.InventoryService.dll:LibraryService"
|
||||||
|
|
||||||
WelcomeMessage = "Welcome, Avatar!"
|
WelcomeMessage = "Welcome, Avatar!"
|
||||||
|
|
||||||
; * This is the new style grid service.
|
|
||||||
; * "Realm" is the table that is used for user lookup.
|
|
||||||
; * It defaults to "regions", which uses the legacy tables
|
|
||||||
; *
|
|
||||||
[GridService]
|
|
||||||
LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
|
|
||||||
StorageProvider = "OpenSim.Data.MySQL.dll:MySqlRegionData"
|
|
||||||
ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=grid;"
|
|
||||||
Realm = "regions"
|
|
||||||
|
|
||||||
; If true, duplicate region names are allowed on the grid. If false, no duplicate names are allowed
|
|
||||||
; Default is false
|
|
||||||
; AllowDuplicateNames = "True"
|
|
||||||
|
|
|
@ -4,9 +4,6 @@
|
||||||
;; which you can copy and change.
|
;; which you can copy and change.
|
||||||
;;
|
;;
|
||||||
|
|
||||||
[Includes]
|
|
||||||
Include-Common = "config-include/StandaloneCommon.ini"
|
|
||||||
|
|
||||||
[Modules]
|
[Modules]
|
||||||
AssetServices = "LocalAssetServicesConnector"
|
AssetServices = "LocalAssetServicesConnector"
|
||||||
InventoryServices = "LocalInventoryServicesConnector"
|
InventoryServices = "LocalInventoryServicesConnector"
|
||||||
|
@ -35,14 +32,14 @@
|
||||||
|
|
||||||
[AvatarService]
|
[AvatarService]
|
||||||
LocalServiceModule = "OpenSim.Services.AvatarService.dll:AvatarService"
|
LocalServiceModule = "OpenSim.Services.AvatarService.dll:AvatarService"
|
||||||
StorageProvider = "OpenSim.Data.Null.dll"
|
ConnectionString = "URI=file:avatars.db,version=3"
|
||||||
|
|
||||||
[AuthorizationService]
|
[AuthorizationService]
|
||||||
LocalServiceModule = "OpenSim.Services.AuthorizationService.dll:AuthorizationService"
|
LocalServiceModule = "OpenSim.Services.AuthorizationService.dll:AuthorizationService"
|
||||||
|
|
||||||
[AuthenticationService]
|
[AuthenticationService]
|
||||||
LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"
|
LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"
|
||||||
StorageProvider = "OpenSim.Data.Null.dll"
|
ConnectionString = "URI=file:auth.db,version=3"
|
||||||
|
|
||||||
[GridService]
|
[GridService]
|
||||||
LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
|
LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
|
||||||
|
@ -55,7 +52,7 @@
|
||||||
|
|
||||||
[UserAccountService]
|
[UserAccountService]
|
||||||
LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService"
|
LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService"
|
||||||
StorageProvider = "OpenSim.Data.Null.dll"
|
ConnectionString = "URI=file:userprofiles.db,version=3"
|
||||||
;; These are for creating new accounts
|
;; These are for creating new accounts
|
||||||
AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"
|
AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"
|
||||||
PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
|
PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
|
||||||
|
@ -72,3 +69,8 @@
|
||||||
AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService"
|
AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService"
|
||||||
|
|
||||||
WelcomeMessage = "Welcome, Avatar!"
|
WelcomeMessage = "Welcome, Avatar!"
|
||||||
|
|
||||||
|
|
||||||
|
;; This should always be the very last thing on this file
|
||||||
|
[Includes]
|
||||||
|
Include-Common = "config-include/StandaloneCommon.ini"
|
||||||
|
|
|
@ -4,9 +4,6 @@
|
||||||
;; which you can copy and change.
|
;; which you can copy and change.
|
||||||
;;
|
;;
|
||||||
|
|
||||||
[Includes]
|
|
||||||
Include-Common = "config-include/StandaloneCommon.ini"
|
|
||||||
|
|
||||||
[Modules]
|
[Modules]
|
||||||
AssetServices = "HGAssetBroker"
|
AssetServices = "HGAssetBroker"
|
||||||
InventoryServices = "HGInventoryBroker"
|
InventoryServices = "HGInventoryBroker"
|
||||||
|
@ -45,7 +42,7 @@
|
||||||
|
|
||||||
[AvatarService]
|
[AvatarService]
|
||||||
LocalServiceModule = "OpenSim.Services.AvatarService.dll:AvatarService"
|
LocalServiceModule = "OpenSim.Services.AvatarService.dll:AvatarService"
|
||||||
StorageProvider = "OpenSim.Data.Null.dll"
|
ConnectionString = "URI=file:avatars.db,version=3"
|
||||||
|
|
||||||
[LibraryService]
|
[LibraryService]
|
||||||
LocalServiceModule = "OpenSim.Services.InventoryService.dll:LibraryService"
|
LocalServiceModule = "OpenSim.Services.InventoryService.dll:LibraryService"
|
||||||
|
@ -57,7 +54,7 @@
|
||||||
|
|
||||||
[AuthenticationService]
|
[AuthenticationService]
|
||||||
LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"
|
LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"
|
||||||
StorageProvider = "OpenSim.Data.Null.dll"
|
ConnectionString = "URI=file:auth.db,version=3"
|
||||||
|
|
||||||
[GridService]
|
[GridService]
|
||||||
; LocalGridServicesConnector needs this
|
; LocalGridServicesConnector needs this
|
||||||
|
@ -73,7 +70,7 @@
|
||||||
|
|
||||||
[UserAccountService]
|
[UserAccountService]
|
||||||
LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService"
|
LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService"
|
||||||
StorageProvider = "OpenSim.Data.Null.dll"
|
ConnectionString = "URI=file:userprofiles.db,version=3"
|
||||||
;; These are for creating new accounts by the service
|
;; These are for creating new accounts by the service
|
||||||
AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"
|
AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"
|
||||||
PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
|
PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
|
||||||
|
@ -112,3 +109,8 @@
|
||||||
[HGInventoryService]
|
[HGInventoryService]
|
||||||
; For the InventoryServiceInConnector
|
; For the InventoryServiceInConnector
|
||||||
LocalServiceModule = "OpenSim.Services.InventoryService.dll:HGInventoryService"
|
LocalServiceModule = "OpenSim.Services.InventoryService.dll:HGInventoryService"
|
||||||
|
|
||||||
|
|
||||||
|
;; This should always be the very last thing on this file
|
||||||
|
[Includes]
|
||||||
|
Include-Common = "config-include/StandaloneCommon.ini"
|
||||||
|
|
Loading…
Reference in New Issue