Creating branch for Physics development
commit
4b55de3e42
|
@ -0,0 +1,44 @@
|
||||||
|
|
||||||
|
The following people have contributed to OpenSim (Thankyou for your effort!)
|
||||||
|
Add your name in here if you have committed to OpenSim
|
||||||
|
|
||||||
|
OpenSim Developers
|
||||||
|
|
||||||
|
* MW
|
||||||
|
* Adam Frisby (DeepThink Pty Ltd)
|
||||||
|
* MingChen (DeepThink Pty Ltd)
|
||||||
|
* lbsa71
|
||||||
|
* sdague (International Business Machines Corp.)
|
||||||
|
* Andy-
|
||||||
|
* Gareth
|
||||||
|
* MorphW
|
||||||
|
* CW
|
||||||
|
* Babblefrog
|
||||||
|
* Tedd
|
||||||
|
|
||||||
|
Patches
|
||||||
|
|
||||||
|
* BigFootAg
|
||||||
|
* Danx0r
|
||||||
|
* Dalien
|
||||||
|
* Darok
|
||||||
|
|
||||||
|
Testers
|
||||||
|
|
||||||
|
* Ckrinke
|
||||||
|
|
||||||
|
|
||||||
|
This software uses components from the following developers:
|
||||||
|
* Sleepycat Software (Berkeley DB)
|
||||||
|
* DB4objects, Inc. (DB4o)
|
||||||
|
* SQLite (Public Domain)
|
||||||
|
* XmlRpcCS (http://xmlrpccs.sf.net/)
|
||||||
|
* MySQL, Inc. (MySQL Connector/NET)
|
||||||
|
* AGEIA Inc. (PhysX)
|
||||||
|
* Russel L. Smith (ODE)
|
||||||
|
* Prebuild ( http://sourceforge.net/projects/dnpb/ )
|
||||||
|
|
||||||
|
In addition, we would like to thank:
|
||||||
|
* The Mono Project
|
||||||
|
* The NANT Developers
|
||||||
|
* Microsoft (.NET, MSSQL-Adapters)
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,745 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Threading;
|
||||||
|
using libsecondlife;
|
||||||
|
using libsecondlife.Packets;
|
||||||
|
using OpenSim.Framework.Interfaces;
|
||||||
|
using OpenSim.Framework.Types;
|
||||||
|
using OpenSim.Framework.Utilities;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Communications.Caches
|
||||||
|
{
|
||||||
|
public delegate void DownloadComplete(AssetCache.TextureSender sender);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Manages local cache of assets and their sending to viewers.
|
||||||
|
/// </summary>
|
||||||
|
public class AssetCache : IAssetReceiver
|
||||||
|
{
|
||||||
|
public Dictionary<LLUUID, AssetInfo> Assets;
|
||||||
|
public Dictionary<LLUUID, TextureImage> Textures;
|
||||||
|
|
||||||
|
public List<AssetRequest> AssetRequests = new List<AssetRequest>(); //assets ready to be sent to viewers
|
||||||
|
public List<AssetRequest> TextureRequests = new List<AssetRequest>(); //textures ready to be sent
|
||||||
|
|
||||||
|
public Dictionary<LLUUID, AssetRequest> RequestedAssets = new Dictionary<LLUUID, AssetRequest>(); //Assets requested from the asset server
|
||||||
|
public Dictionary<LLUUID, AssetRequest> RequestedTextures = new Dictionary<LLUUID, AssetRequest>(); //Textures requested from the asset server
|
||||||
|
|
||||||
|
public Dictionary<LLUUID, TextureSender> SendingTextures = new Dictionary<LLUUID, TextureSender>();
|
||||||
|
private BlockingQueue<TextureSender> QueueTextures = new BlockingQueue<TextureSender>();
|
||||||
|
|
||||||
|
private Dictionary<LLUUID, List<LLUUID>> AvatarRecievedTextures = new Dictionary<LLUUID,List<LLUUID>>();
|
||||||
|
|
||||||
|
private IAssetServer _assetServer;
|
||||||
|
private Thread _assetCacheThread;
|
||||||
|
|
||||||
|
private Thread TextureSenderThread;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public AssetCache(IAssetServer assetServer)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Creating Asset cache");
|
||||||
|
_assetServer = assetServer;
|
||||||
|
_assetServer.SetReceiver(this);
|
||||||
|
Assets = new Dictionary<LLUUID, AssetInfo>();
|
||||||
|
Textures = new Dictionary<LLUUID, TextureImage>();
|
||||||
|
this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager));
|
||||||
|
this._assetCacheThread.IsBackground = true;
|
||||||
|
this._assetCacheThread.Start();
|
||||||
|
|
||||||
|
this.TextureSenderThread = new Thread(new ThreadStart(this.ProcessTextureSenders));
|
||||||
|
this.TextureSenderThread.IsBackground = true;
|
||||||
|
this.TextureSenderThread.Start();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Creating Asset cache");
|
||||||
|
_assetServer = this.LoadAssetDll(assetServerDLLName);
|
||||||
|
_assetServer.SetServerInfo(assetServerURL, assetServerKey);
|
||||||
|
_assetServer.SetReceiver(this);
|
||||||
|
Assets = new Dictionary<LLUUID, AssetInfo>();
|
||||||
|
Textures = new Dictionary<LLUUID, TextureImage>();
|
||||||
|
this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager));
|
||||||
|
this._assetCacheThread.IsBackground = true;
|
||||||
|
this._assetCacheThread.Start();
|
||||||
|
|
||||||
|
this.TextureSenderThread = new Thread(new ThreadStart(this.ProcessTextureSenders));
|
||||||
|
this.TextureSenderThread.IsBackground = true;
|
||||||
|
this.TextureSenderThread.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public void RunAssetManager()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.ProcessAssetQueue();
|
||||||
|
this.ProcessTextureQueue();
|
||||||
|
Thread.Sleep(500);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.Message + " : " + e.StackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public AssetBase GetAsset(LLUUID assetID)
|
||||||
|
{
|
||||||
|
AssetBase asset = null;
|
||||||
|
if (this.Textures.ContainsKey(assetID))
|
||||||
|
{
|
||||||
|
asset = this.Textures[assetID];
|
||||||
|
}
|
||||||
|
else if (this.Assets.ContainsKey(assetID))
|
||||||
|
{
|
||||||
|
asset = this.Assets[assetID];
|
||||||
|
}
|
||||||
|
return asset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssetBase GetAsset(LLUUID assetID, bool isTexture)
|
||||||
|
{
|
||||||
|
AssetBase asset = GetAsset(assetID);
|
||||||
|
if (asset == null)
|
||||||
|
{
|
||||||
|
this._assetServer.RequestAsset(assetID, isTexture);
|
||||||
|
}
|
||||||
|
return asset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddAsset(AssetBase asset)
|
||||||
|
{
|
||||||
|
// Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated());
|
||||||
|
if (asset.Type == 0)
|
||||||
|
{
|
||||||
|
//Console.WriteLine("which is a texture");
|
||||||
|
if (!this.Textures.ContainsKey(asset.FullID))
|
||||||
|
{ //texture
|
||||||
|
TextureImage textur = new TextureImage(asset);
|
||||||
|
this.Textures.Add(textur.FullID, textur);
|
||||||
|
this._assetServer.UploadNewAsset(asset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!this.Assets.ContainsKey(asset.FullID))
|
||||||
|
{
|
||||||
|
AssetInfo assetInf = new AssetInfo(asset);
|
||||||
|
this.Assets.Add(assetInf.FullID, assetInf);
|
||||||
|
this._assetServer.UploadNewAsset(asset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
private void ProcessTextureQueue()
|
||||||
|
{
|
||||||
|
if (this.TextureRequests.Count == 0)
|
||||||
|
{
|
||||||
|
//no requests waiting
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int num;
|
||||||
|
num = this.TextureRequests.Count;
|
||||||
|
|
||||||
|
AssetRequest req;
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
req = (AssetRequest)this.TextureRequests[i];
|
||||||
|
if (!this.SendingTextures.ContainsKey(req.ImageInfo.FullID))
|
||||||
|
{
|
||||||
|
//Console.WriteLine("new texture to send");
|
||||||
|
TextureSender sender = new TextureSender(req);
|
||||||
|
//sender.OnComplete += this.TextureSent;
|
||||||
|
lock (this.SendingTextures)
|
||||||
|
{
|
||||||
|
this.SendingTextures.Add(req.ImageInfo.FullID, sender);
|
||||||
|
}
|
||||||
|
this.QueueTextures.Enqueue(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
this.TextureRequests.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ProcessTextureSenders()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
TextureSender sender = this.QueueTextures.Dequeue();
|
||||||
|
bool finished = sender.SendTexture();
|
||||||
|
if (finished)
|
||||||
|
{
|
||||||
|
this.TextureSent(sender);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Console.WriteLine("readding texture");
|
||||||
|
this.QueueTextures.Enqueue(sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event handler, called by a TextureSender object to say that texture has been sent
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
public void TextureSent(TextureSender sender)
|
||||||
|
{
|
||||||
|
if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID))
|
||||||
|
{
|
||||||
|
lock (this.SendingTextures)
|
||||||
|
{
|
||||||
|
this.SendingTextures.Remove(sender.request.ImageInfo.FullID);
|
||||||
|
// this.AvatarRecievedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AssetReceived(AssetBase asset, bool IsTexture)
|
||||||
|
{
|
||||||
|
if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server
|
||||||
|
{
|
||||||
|
//check if it is a texture or not
|
||||||
|
//then add to the correct cache list
|
||||||
|
//then check for waiting requests for this asset/texture (in the Requested lists)
|
||||||
|
//and move those requests into the Requests list.
|
||||||
|
|
||||||
|
if (IsTexture)
|
||||||
|
{
|
||||||
|
// Console.WriteLine("asset recieved from asset server");
|
||||||
|
|
||||||
|
TextureImage image = new TextureImage(asset);
|
||||||
|
if (!this.Textures.ContainsKey(image.FullID))
|
||||||
|
{
|
||||||
|
this.Textures.Add(image.FullID, image);
|
||||||
|
if (this.RequestedTextures.ContainsKey(image.FullID))
|
||||||
|
{
|
||||||
|
AssetRequest req = this.RequestedTextures[image.FullID];
|
||||||
|
req.ImageInfo = image;
|
||||||
|
if (image.Data.LongLength > 600)
|
||||||
|
{
|
||||||
|
//over 600 bytes so split up file
|
||||||
|
req.NumPackets = 1 + (int)(image.Data.Length - 600) / 1000;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
req.NumPackets = 1;
|
||||||
|
}
|
||||||
|
this.RequestedTextures.Remove(image.FullID);
|
||||||
|
this.TextureRequests.Add(req);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AssetInfo assetInf = new AssetInfo(asset);
|
||||||
|
if (!this.Assets.ContainsKey(assetInf.FullID))
|
||||||
|
{
|
||||||
|
this.Assets.Add(assetInf.FullID, assetInf);
|
||||||
|
if (this.RequestedAssets.ContainsKey(assetInf.FullID))
|
||||||
|
{
|
||||||
|
AssetRequest req = this.RequestedAssets[assetInf.FullID];
|
||||||
|
req.AssetInf = assetInf;
|
||||||
|
if (assetInf.Data.LongLength > 600)
|
||||||
|
{
|
||||||
|
//over 600 bytes so split up file
|
||||||
|
req.NumPackets = 1 + (int)(assetInf.Data.Length - 600 + 999) / 1000;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
req.NumPackets = 1;
|
||||||
|
}
|
||||||
|
this.RequestedAssets.Remove(assetInf.FullID);
|
||||||
|
this.AssetRequests.Add(req);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AssetNotFound(AssetBase asset)
|
||||||
|
{
|
||||||
|
//the asset server had no knowledge of requested asset
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Assets
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <param name="transferRequest"></param>
|
||||||
|
public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest)
|
||||||
|
{
|
||||||
|
LLUUID requestID = null;
|
||||||
|
byte source = 2;
|
||||||
|
if (transferRequest.TransferInfo.SourceType == 2)
|
||||||
|
{
|
||||||
|
//direct asset request
|
||||||
|
requestID = new LLUUID(transferRequest.TransferInfo.Params, 0);
|
||||||
|
}
|
||||||
|
else if (transferRequest.TransferInfo.SourceType == 3)
|
||||||
|
{
|
||||||
|
//inventory asset request
|
||||||
|
requestID = new LLUUID(transferRequest.TransferInfo.Params, 80);
|
||||||
|
source = 3;
|
||||||
|
Console.WriteLine("asset request " + requestID);
|
||||||
|
}
|
||||||
|
//check to see if asset is in local cache, if not we need to request it from asset server.
|
||||||
|
//Console.WriteLine("asset request " + requestID);
|
||||||
|
if (!this.Assets.ContainsKey(requestID))
|
||||||
|
{
|
||||||
|
//not found asset
|
||||||
|
// so request from asset server
|
||||||
|
if (!this.RequestedAssets.ContainsKey(requestID))
|
||||||
|
{
|
||||||
|
AssetRequest request = new AssetRequest();
|
||||||
|
request.RequestUser = userInfo;
|
||||||
|
request.RequestAssetID = requestID;
|
||||||
|
request.TransferRequestID = transferRequest.TransferInfo.TransferID;
|
||||||
|
request.AssetRequestSource = source;
|
||||||
|
request.Params = transferRequest.TransferInfo.Params;
|
||||||
|
this.RequestedAssets.Add(requestID, request);
|
||||||
|
this._assetServer.RequestAsset(requestID, false);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//it is in our cache
|
||||||
|
AssetInfo asset = this.Assets[requestID];
|
||||||
|
|
||||||
|
//work out how many packets it should be sent in
|
||||||
|
// and add to the AssetRequests list
|
||||||
|
AssetRequest req = new AssetRequest();
|
||||||
|
req.RequestUser = userInfo;
|
||||||
|
req.RequestAssetID = requestID;
|
||||||
|
req.TransferRequestID = transferRequest.TransferInfo.TransferID;
|
||||||
|
req.AssetRequestSource = source;
|
||||||
|
req.Params = transferRequest.TransferInfo.Params;
|
||||||
|
req.AssetInf = asset;
|
||||||
|
|
||||||
|
if (asset.Data.LongLength > 600)
|
||||||
|
{
|
||||||
|
//over 600 bytes so split up file
|
||||||
|
req.NumPackets = 1 + (int)(asset.Data.Length - 600 + 999) / 1000;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
req.NumPackets = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.AssetRequests.Add(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
private void ProcessAssetQueue()
|
||||||
|
{
|
||||||
|
if (this.AssetRequests.Count == 0)
|
||||||
|
{
|
||||||
|
//no requests waiting
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int num;
|
||||||
|
|
||||||
|
if (this.AssetRequests.Count < 5)
|
||||||
|
{
|
||||||
|
//lower than 5 so do all of them
|
||||||
|
num = this.AssetRequests.Count;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
num = 5;
|
||||||
|
}
|
||||||
|
AssetRequest req;
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
req = (AssetRequest)this.AssetRequests[i];
|
||||||
|
//Console.WriteLine("sending asset " + req.RequestAssetID);
|
||||||
|
TransferInfoPacket Transfer = new TransferInfoPacket();
|
||||||
|
Transfer.TransferInfo.ChannelType = 2;
|
||||||
|
Transfer.TransferInfo.Status = 0;
|
||||||
|
Transfer.TransferInfo.TargetType = 0;
|
||||||
|
if (req.AssetRequestSource == 2)
|
||||||
|
{
|
||||||
|
Transfer.TransferInfo.Params = new byte[20];
|
||||||
|
Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
|
||||||
|
int assType = (int)req.AssetInf.Type;
|
||||||
|
Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4);
|
||||||
|
}
|
||||||
|
else if (req.AssetRequestSource == 3)
|
||||||
|
{
|
||||||
|
Transfer.TransferInfo.Params = req.Params;
|
||||||
|
// Transfer.TransferInfo.Params = new byte[100];
|
||||||
|
//Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
|
||||||
|
//Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16);
|
||||||
|
}
|
||||||
|
Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length;
|
||||||
|
Transfer.TransferInfo.TransferID = req.TransferRequestID;
|
||||||
|
req.RequestUser.OutPacket(Transfer);
|
||||||
|
|
||||||
|
if (req.NumPackets == 1)
|
||||||
|
{
|
||||||
|
TransferPacketPacket TransferPacket = new TransferPacketPacket();
|
||||||
|
TransferPacket.TransferData.Packet = 0;
|
||||||
|
TransferPacket.TransferData.ChannelType = 2;
|
||||||
|
TransferPacket.TransferData.TransferID = req.TransferRequestID;
|
||||||
|
TransferPacket.TransferData.Data = req.AssetInf.Data;
|
||||||
|
TransferPacket.TransferData.Status = 1;
|
||||||
|
req.RequestUser.OutPacket(TransferPacket);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//more than one packet so split file up , for now it can't be bigger than 2000 bytes
|
||||||
|
TransferPacketPacket TransferPacket = new TransferPacketPacket();
|
||||||
|
TransferPacket.TransferData.Packet = 0;
|
||||||
|
TransferPacket.TransferData.ChannelType = 2;
|
||||||
|
TransferPacket.TransferData.TransferID = req.TransferRequestID;
|
||||||
|
byte[] chunk = null;
|
||||||
|
if (req.AssetInf.Data.Length <= 1000)
|
||||||
|
{
|
||||||
|
chunk = new byte[req.AssetInf.Data.Length];
|
||||||
|
Array.Copy(req.AssetInf.Data, chunk, req.AssetInf.Data.Length);
|
||||||
|
TransferPacket.TransferData.Data = chunk;
|
||||||
|
TransferPacket.TransferData.Status = 1;
|
||||||
|
req.RequestUser.OutPacket(TransferPacket);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
chunk = new byte[1000];
|
||||||
|
Array.Copy(req.AssetInf.Data, chunk, 1000);
|
||||||
|
|
||||||
|
TransferPacket.TransferData.Data = chunk;
|
||||||
|
TransferPacket.TransferData.Status = 0;
|
||||||
|
req.RequestUser.OutPacket(TransferPacket);
|
||||||
|
|
||||||
|
TransferPacket = new TransferPacketPacket();
|
||||||
|
TransferPacket.TransferData.Packet = 1;
|
||||||
|
TransferPacket.TransferData.ChannelType = 2;
|
||||||
|
TransferPacket.TransferData.TransferID = req.TransferRequestID;
|
||||||
|
byte[] chunk1 = new byte[(req.AssetInf.Data.Length - 1000)];
|
||||||
|
Array.Copy(req.AssetInf.Data, 1000, chunk1, 0, chunk1.Length);
|
||||||
|
TransferPacket.TransferData.Data = chunk1;
|
||||||
|
TransferPacket.TransferData.Status = 1;
|
||||||
|
req.RequestUser.OutPacket(TransferPacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//remove requests that have been completed
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
this.AssetRequests.RemoveAt(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssetInfo CloneAsset(LLUUID newOwner, AssetInfo sourceAsset)
|
||||||
|
{
|
||||||
|
AssetInfo newAsset = new AssetInfo();
|
||||||
|
newAsset.Data = new byte[sourceAsset.Data.Length];
|
||||||
|
Array.Copy(sourceAsset.Data, newAsset.Data, sourceAsset.Data.Length);
|
||||||
|
newAsset.FullID = LLUUID.Random();
|
||||||
|
newAsset.Type = sourceAsset.Type;
|
||||||
|
newAsset.InvType = sourceAsset.InvType;
|
||||||
|
return (newAsset);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Textures
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <param name="imageID"></param>
|
||||||
|
public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID, uint packetNumber)
|
||||||
|
{
|
||||||
|
// Console.WriteLine("texture request for " + imageID.ToStringHyphenated());
|
||||||
|
//check to see if texture is in local cache, if not request from asset server
|
||||||
|
if(!this.AvatarRecievedTextures.ContainsKey(userInfo.AgentId))
|
||||||
|
{
|
||||||
|
this.AvatarRecievedTextures.Add(userInfo.AgentId, new List<LLUUID>());
|
||||||
|
}
|
||||||
|
/* if(this.AvatarRecievedTextures[userInfo.AgentId].Contains(imageID))
|
||||||
|
{
|
||||||
|
//Console.WriteLine(userInfo.AgentId +" is requesting a image( "+ imageID+" that has already been sent to them");
|
||||||
|
return;
|
||||||
|
}*/
|
||||||
|
if (!this.Textures.ContainsKey(imageID))
|
||||||
|
{
|
||||||
|
if (!this.RequestedTextures.ContainsKey(imageID))
|
||||||
|
{
|
||||||
|
//not is cache so request from asset server
|
||||||
|
AssetRequest request = new AssetRequest();
|
||||||
|
request.RequestUser = userInfo;
|
||||||
|
request.RequestAssetID = imageID;
|
||||||
|
request.IsTextureRequest = true;
|
||||||
|
this.RequestedTextures.Add(imageID, request);
|
||||||
|
this._assetServer.RequestAsset(imageID, true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Console.WriteLine("texture already in cache");
|
||||||
|
TextureImage imag = this.Textures[imageID];
|
||||||
|
AssetRequest req = new AssetRequest();
|
||||||
|
req.RequestUser = userInfo;
|
||||||
|
req.RequestAssetID = imageID;
|
||||||
|
req.IsTextureRequest = true;
|
||||||
|
req.ImageInfo = imag;
|
||||||
|
|
||||||
|
if (imag.Data.LongLength > 600)
|
||||||
|
{
|
||||||
|
//over 600 bytes so split up file
|
||||||
|
req.NumPackets = 1 + (int)(imag.Data.Length - 600 ) / 1000;
|
||||||
|
//Console.WriteLine("texture is " + imag.Data.Length + " which we will send in " +req.NumPackets +" packets");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
req.NumPackets = 1;
|
||||||
|
}
|
||||||
|
if (packetNumber != 0)
|
||||||
|
{
|
||||||
|
req.PacketCounter = (int)packetNumber;
|
||||||
|
}
|
||||||
|
this.TextureRequests.Add(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextureImage CloneImage(LLUUID newOwner, TextureImage source)
|
||||||
|
{
|
||||||
|
TextureImage newImage = new TextureImage();
|
||||||
|
newImage.Data = new byte[source.Data.Length];
|
||||||
|
Array.Copy(source.Data, newImage.Data, source.Data.Length);
|
||||||
|
//newImage.filename = source.filename;
|
||||||
|
newImage.FullID = LLUUID.Random();
|
||||||
|
newImage.Name = source.Name;
|
||||||
|
return (newImage);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private IAssetServer LoadAssetDll(string dllName)
|
||||||
|
{
|
||||||
|
Assembly pluginAssembly = Assembly.LoadFrom(dllName);
|
||||||
|
IAssetServer server = null;
|
||||||
|
|
||||||
|
foreach (Type pluginType in pluginAssembly.GetTypes())
|
||||||
|
{
|
||||||
|
if (pluginType.IsPublic)
|
||||||
|
{
|
||||||
|
if (!pluginType.IsAbstract)
|
||||||
|
{
|
||||||
|
Type typeInterface = pluginType.GetInterface("IAssetPlugin", true);
|
||||||
|
|
||||||
|
if (typeInterface != null)
|
||||||
|
{
|
||||||
|
IAssetPlugin plug = (IAssetPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
|
||||||
|
server = plug.GetAssetServer();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
typeInterface = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pluginAssembly = null;
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AssetRequest
|
||||||
|
{
|
||||||
|
public IClientAPI RequestUser;
|
||||||
|
public LLUUID RequestAssetID;
|
||||||
|
public AssetInfo AssetInf;
|
||||||
|
public TextureImage ImageInfo;
|
||||||
|
public LLUUID TransferRequestID;
|
||||||
|
public long DataPointer = 0;
|
||||||
|
public int NumPackets = 0;
|
||||||
|
public int PacketCounter = 0;
|
||||||
|
public bool IsTextureRequest;
|
||||||
|
public byte AssetRequestSource = 2;
|
||||||
|
public byte[] Params = null;
|
||||||
|
//public bool AssetInCache;
|
||||||
|
//public int TimeRequested;
|
||||||
|
|
||||||
|
public AssetRequest()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AssetInfo : AssetBase
|
||||||
|
{
|
||||||
|
public AssetInfo()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssetInfo(AssetBase aBase)
|
||||||
|
{
|
||||||
|
Data = aBase.Data;
|
||||||
|
FullID = aBase.FullID;
|
||||||
|
Type = aBase.Type;
|
||||||
|
InvType = aBase.InvType;
|
||||||
|
Name = aBase.Name;
|
||||||
|
Description = aBase.Description;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TextureImage : AssetBase
|
||||||
|
{
|
||||||
|
public TextureImage()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextureImage(AssetBase aBase)
|
||||||
|
{
|
||||||
|
Data = aBase.Data;
|
||||||
|
FullID = aBase.FullID;
|
||||||
|
Type = aBase.Type;
|
||||||
|
InvType = aBase.InvType;
|
||||||
|
Name = aBase.Name;
|
||||||
|
Description = aBase.Description;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TextureSender
|
||||||
|
{
|
||||||
|
public AssetRequest request;
|
||||||
|
private int counter = 0;
|
||||||
|
|
||||||
|
public TextureSender(AssetRequest req)
|
||||||
|
{
|
||||||
|
request = req;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SendTexture()
|
||||||
|
{
|
||||||
|
SendPacket();
|
||||||
|
counter++;
|
||||||
|
|
||||||
|
if ((request.PacketCounter > request.NumPackets) | (counter >120) |(request.NumPackets ==1))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SendPacket()
|
||||||
|
{
|
||||||
|
AssetRequest req = request;
|
||||||
|
// Console.WriteLine("sending " + req.ImageInfo.FullID);
|
||||||
|
if (req.PacketCounter == 0)
|
||||||
|
{
|
||||||
|
//first time for this request so send imagedata packet
|
||||||
|
if (req.NumPackets == 1)
|
||||||
|
{
|
||||||
|
//only one packet so send whole file
|
||||||
|
ImageDataPacket im = new ImageDataPacket();
|
||||||
|
im.ImageID.Packets = 1;
|
||||||
|
im.ImageID.ID = req.ImageInfo.FullID;
|
||||||
|
im.ImageID.Size = (uint)req.ImageInfo.Data.Length;
|
||||||
|
im.ImageData.Data = req.ImageInfo.Data;
|
||||||
|
im.ImageID.Codec = 2;
|
||||||
|
req.RequestUser.OutPacket(im);
|
||||||
|
req.PacketCounter++;
|
||||||
|
//req.ImageInfo.l= time;
|
||||||
|
//System.Console.WriteLine("sent texture: " + req.ImageInfo.FullID);
|
||||||
|
// Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//more than one packet so split file up
|
||||||
|
ImageDataPacket im = new ImageDataPacket();
|
||||||
|
im.ImageID.Packets = (ushort)(req.NumPackets);
|
||||||
|
im.ImageID.ID = req.ImageInfo.FullID;
|
||||||
|
im.ImageID.Size = (uint)req.ImageInfo.Data.Length;
|
||||||
|
im.ImageData.Data = new byte[600];
|
||||||
|
Array.Copy(req.ImageInfo.Data, 0, im.ImageData.Data, 0, 600);
|
||||||
|
im.ImageID.Codec = 2;
|
||||||
|
req.RequestUser.OutPacket(im);
|
||||||
|
|
||||||
|
req.PacketCounter++;
|
||||||
|
//req.ImageInfo.last_used = time;
|
||||||
|
//System.Console.WriteLine("sent first packet of texture:
|
||||||
|
// Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Console.WriteLine("sending packet" + req.PacketCounter + "for " + req.ImageInfo.FullID.ToStringHyphenated());
|
||||||
|
//send imagepacket
|
||||||
|
//more than one packet so split file up
|
||||||
|
ImagePacketPacket im = new ImagePacketPacket();
|
||||||
|
im.ImageID.Packet = (ushort)(req.PacketCounter);
|
||||||
|
im.ImageID.ID = req.ImageInfo.FullID;
|
||||||
|
int size = req.ImageInfo.Data.Length - 600 - (1000 * (req.PacketCounter - 1));
|
||||||
|
if (size > 1000) size = 1000;
|
||||||
|
im.ImageData.Data = new byte[size];
|
||||||
|
Array.Copy(req.ImageInfo.Data, 600 + (1000 * (req.PacketCounter - 1)), im.ImageData.Data, 0, size);
|
||||||
|
req.RequestUser.OutPacket(im);
|
||||||
|
req.PacketCounter++;
|
||||||
|
//req.ImageInfo.last_used = time;
|
||||||
|
//System.Console.WriteLine("sent a packet of texture: "+req.image_info.FullID);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveAssetToFile(string filename, byte[] data)
|
||||||
|
{
|
||||||
|
FileStream fs = File.Create(filename);
|
||||||
|
BinaryWriter bw = new BinaryWriter(fs);
|
||||||
|
bw.Write(data);
|
||||||
|
bw.Close();
|
||||||
|
fs.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,107 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 System.IO;
|
||||||
|
using libsecondlife;
|
||||||
|
using OpenSim.Framework.Interfaces;
|
||||||
|
using OpenSim.Framework.Types;
|
||||||
|
using OpenSim.Framework.Utilities;
|
||||||
|
using OpenSim.Framework.Data;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Communications.Caches
|
||||||
|
{
|
||||||
|
public class AssetTransactionManager
|
||||||
|
{
|
||||||
|
// Fields
|
||||||
|
public CommunicationsManager CommsManager;
|
||||||
|
public Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions = new Dictionary<LLUUID, AgentAssetTransactions>();
|
||||||
|
|
||||||
|
public AssetTransactionManager(CommunicationsManager commsManager)
|
||||||
|
{
|
||||||
|
CommsManager = commsManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
public AgentAssetTransactions AddUser(LLUUID userID)
|
||||||
|
{
|
||||||
|
if (!this.AgentTransactions.ContainsKey(userID))
|
||||||
|
{
|
||||||
|
AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this);
|
||||||
|
this.AgentTransactions.Add(userID, transactions);
|
||||||
|
return transactions;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AgentAssetTransactions GetUserTransActions(LLUUID userID)
|
||||||
|
{
|
||||||
|
if (this.AgentTransactions.ContainsKey(userID))
|
||||||
|
{
|
||||||
|
return this.AgentTransactions[userID];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandleInventoryFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask)
|
||||||
|
{
|
||||||
|
AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId);
|
||||||
|
if (transactions != null)
|
||||||
|
{
|
||||||
|
transactions.RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data)
|
||||||
|
{
|
||||||
|
AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId);
|
||||||
|
if (transactions != null)
|
||||||
|
{
|
||||||
|
AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
|
||||||
|
if (uploader != null)
|
||||||
|
{
|
||||||
|
uploader.Initialise(remoteClient, assetID, transaction, type, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
|
||||||
|
{
|
||||||
|
AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId);
|
||||||
|
if (transactions != null)
|
||||||
|
{
|
||||||
|
transactions.HandleXfer(xferID, packetID, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,382 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 System.IO;
|
||||||
|
using libsecondlife;
|
||||||
|
using libsecondlife.Packets;
|
||||||
|
using OpenSim.Framework.Interfaces;
|
||||||
|
using OpenSim.Framework.Types;
|
||||||
|
using OpenSim.Framework.Utilities;
|
||||||
|
using OpenSim.Framework.Data;
|
||||||
|
using OpenSim.Region.Capabilities;
|
||||||
|
using OpenSim.Framework.Servers;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Communications.Caches
|
||||||
|
{
|
||||||
|
public class AgentAssetTransactions
|
||||||
|
{
|
||||||
|
// Fields
|
||||||
|
public List<AssetCapsUploader> CapsUploaders = new List<AssetCapsUploader>();
|
||||||
|
public List<NoteCardCapsUpdate> NotecardUpdaters = new List<NoteCardCapsUpdate>();
|
||||||
|
public LLUUID UserID;
|
||||||
|
public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>();
|
||||||
|
public AssetTransactionManager Manager;
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
public AgentAssetTransactions(LLUUID agentID, AssetTransactionManager manager)
|
||||||
|
{
|
||||||
|
this.UserID = agentID;
|
||||||
|
Manager = manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssetCapsUploader RequestCapsUploader()
|
||||||
|
{
|
||||||
|
AssetCapsUploader uploader = new AssetCapsUploader();
|
||||||
|
this.CapsUploaders.Add(uploader);
|
||||||
|
return uploader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NoteCardCapsUpdate RequestNoteCardUpdater()
|
||||||
|
{
|
||||||
|
NoteCardCapsUpdate update = new NoteCardCapsUpdate();
|
||||||
|
this.NotecardUpdaters.Add(update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssetXferUploader RequestXferUploader(LLUUID transactionID)
|
||||||
|
{
|
||||||
|
if (!this.XferUploaders.ContainsKey(transactionID))
|
||||||
|
{
|
||||||
|
AssetXferUploader uploader = new AssetXferUploader(this);
|
||||||
|
|
||||||
|
this.XferUploaders.Add(transactionID, uploader);
|
||||||
|
return uploader;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandleXfer(ulong xferID, uint packetID, byte[] data)
|
||||||
|
{
|
||||||
|
foreach (AssetXferUploader uploader in this.XferUploaders.Values)
|
||||||
|
{
|
||||||
|
if (uploader.XferID == xferID)
|
||||||
|
{
|
||||||
|
uploader.HandleXferPacket(xferID, packetID, data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask)
|
||||||
|
{
|
||||||
|
if (this.XferUploaders.ContainsKey(transactionID))
|
||||||
|
{
|
||||||
|
this.XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nested Types
|
||||||
|
public class AssetCapsUploader
|
||||||
|
{
|
||||||
|
// Fields
|
||||||
|
private BaseHttpServer httpListener;
|
||||||
|
private LLUUID inventoryItemID;
|
||||||
|
private string m_assetDescription = "";
|
||||||
|
private string m_assetName = "";
|
||||||
|
private LLUUID m_folderID;
|
||||||
|
private LLUUID newAssetID;
|
||||||
|
private bool SaveImages = false;
|
||||||
|
private string uploaderPath = "";
|
||||||
|
|
||||||
|
// Events
|
||||||
|
public event UpLoadedAsset OnUpLoad;
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer)
|
||||||
|
{
|
||||||
|
this.m_assetName = assetName;
|
||||||
|
this.m_assetDescription = assetDescription;
|
||||||
|
this.m_folderID = folderID;
|
||||||
|
this.newAssetID = assetID;
|
||||||
|
this.inventoryItemID = inventoryItem;
|
||||||
|
this.uploaderPath = path;
|
||||||
|
this.httpListener = httpServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveImageToFile(string filename, byte[] data)
|
||||||
|
{
|
||||||
|
FileStream output = File.Create(filename);
|
||||||
|
BinaryWriter writer = new BinaryWriter(output);
|
||||||
|
writer.Write(data);
|
||||||
|
writer.Close();
|
||||||
|
output.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string uploaderCaps(byte[] data, string path, string param)
|
||||||
|
{
|
||||||
|
LLUUID inventoryItemID = this.inventoryItemID;
|
||||||
|
string text = "";
|
||||||
|
LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete();
|
||||||
|
complete.new_asset = this.newAssetID.ToStringHyphenated();
|
||||||
|
complete.new_inventory_item = inventoryItemID;
|
||||||
|
complete.state = "complete";
|
||||||
|
text = LLSDHelpers.SerialiseLLSDReply(complete);
|
||||||
|
this.httpListener.RemoveStreamHandler("POST", this.uploaderPath);
|
||||||
|
if (this.SaveImages)
|
||||||
|
{
|
||||||
|
this.SaveImageToFile(this.m_assetName + ".jp2", data);
|
||||||
|
}
|
||||||
|
if (this.OnUpLoad != null)
|
||||||
|
{
|
||||||
|
this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data, "" , "");
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AssetXferUploader
|
||||||
|
{
|
||||||
|
// Fields
|
||||||
|
public bool AddToInventory;
|
||||||
|
public AssetBase Asset;
|
||||||
|
public LLUUID InventFolder = LLUUID.Zero;
|
||||||
|
private IClientAPI ourClient;
|
||||||
|
public LLUUID TransactionID = LLUUID.Zero;
|
||||||
|
public bool UploadComplete;
|
||||||
|
public ulong XferID;
|
||||||
|
private string m_name = "";
|
||||||
|
private string m_description = "";
|
||||||
|
private sbyte type = 0;
|
||||||
|
private sbyte invType = 0;
|
||||||
|
private uint nextPerm = 0;
|
||||||
|
private bool m_finished = false;
|
||||||
|
private bool m_createItem = false;
|
||||||
|
private AgentAssetTransactions m_userTransactions;
|
||||||
|
|
||||||
|
public AssetXferUploader(AgentAssetTransactions transactions)
|
||||||
|
{
|
||||||
|
this.m_userTransactions = transactions;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
public void HandleXferPacket(ulong xferID, uint packetID, byte[] data)
|
||||||
|
{
|
||||||
|
if (this.XferID == xferID)
|
||||||
|
{
|
||||||
|
if (this.Asset.Data.Length > 1)
|
||||||
|
{
|
||||||
|
byte[] destinationArray = new byte[this.Asset.Data.Length + data.Length];
|
||||||
|
Array.Copy(this.Asset.Data, 0, destinationArray, 0, this.Asset.Data.Length);
|
||||||
|
Array.Copy(data, 0, destinationArray, this.Asset.Data.Length, data.Length);
|
||||||
|
this.Asset.Data = destinationArray;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
byte[] buffer2 = new byte[data.Length - 4];
|
||||||
|
Array.Copy(data, 4, buffer2, 0, data.Length - 4);
|
||||||
|
this.Asset.Data = buffer2;
|
||||||
|
}
|
||||||
|
ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket();
|
||||||
|
newPack.XferID.ID = xferID;
|
||||||
|
newPack.XferID.Packet = packetID;
|
||||||
|
this.ourClient.OutPacket(newPack);
|
||||||
|
if ((packetID & 0x80000000) != 0)
|
||||||
|
{
|
||||||
|
this.SendCompleteMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data)
|
||||||
|
{
|
||||||
|
this.ourClient = remoteClient;
|
||||||
|
this.Asset = new AssetBase();
|
||||||
|
this.Asset.FullID = assetID;
|
||||||
|
this.Asset.InvType = type;
|
||||||
|
this.Asset.Type = type;
|
||||||
|
this.Asset.Data = data;
|
||||||
|
this.Asset.Name = "blank";
|
||||||
|
this.Asset.Description = "empty";
|
||||||
|
this.TransactionID = transaction;
|
||||||
|
if (this.Asset.Data.Length > 2)
|
||||||
|
{
|
||||||
|
this.SendCompleteMessage();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.ReqestStartXfer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void ReqestStartXfer()
|
||||||
|
{
|
||||||
|
this.UploadComplete = false;
|
||||||
|
this.XferID = Util.GetNextXferID();
|
||||||
|
RequestXferPacket newPack = new RequestXferPacket();
|
||||||
|
newPack.XferID.ID = this.XferID;
|
||||||
|
newPack.XferID.VFileType = this.Asset.Type;
|
||||||
|
newPack.XferID.VFileID = this.Asset.FullID;
|
||||||
|
newPack.XferID.FilePath = 0;
|
||||||
|
newPack.XferID.Filename = new byte[0];
|
||||||
|
this.ourClient.OutPacket(newPack);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void SendCompleteMessage()
|
||||||
|
{
|
||||||
|
this.UploadComplete = true;
|
||||||
|
AssetUploadCompletePacket newPack = new AssetUploadCompletePacket();
|
||||||
|
newPack.AssetBlock.Type = this.Asset.Type;
|
||||||
|
newPack.AssetBlock.Success = true;
|
||||||
|
newPack.AssetBlock.UUID = this.Asset.FullID;
|
||||||
|
this.ourClient.OutPacket(newPack);
|
||||||
|
this.m_finished = true;
|
||||||
|
if (m_createItem)
|
||||||
|
{
|
||||||
|
DoCreateItem();
|
||||||
|
}
|
||||||
|
// Console.WriteLine("upload complete "+ this.TransactionID);
|
||||||
|
//SaveAssetToFile("testudpupload" + Util.RandomClass.Next(1, 1000) + ".dat", this.Asset.Data);
|
||||||
|
}
|
||||||
|
private void SaveAssetToFile(string filename, byte[] data)
|
||||||
|
{
|
||||||
|
FileStream fs = File.Create(filename);
|
||||||
|
BinaryWriter bw = new BinaryWriter(fs);
|
||||||
|
bw.Write(data);
|
||||||
|
bw.Close();
|
||||||
|
fs.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask)
|
||||||
|
{
|
||||||
|
if (this.TransactionID == transactionID)
|
||||||
|
{
|
||||||
|
this.InventFolder = folderID;
|
||||||
|
this.m_name = name;
|
||||||
|
this.m_description = description;
|
||||||
|
this.type = type;
|
||||||
|
this.invType = invType;
|
||||||
|
this.nextPerm = nextOwnerMask;
|
||||||
|
this.Asset.Name = name;
|
||||||
|
this.Asset.Description = description;
|
||||||
|
this.Asset.Type = type;
|
||||||
|
this.Asset.InvType = invType;
|
||||||
|
m_createItem = true;
|
||||||
|
if (m_finished)
|
||||||
|
{
|
||||||
|
DoCreateItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DoCreateItem()
|
||||||
|
{
|
||||||
|
this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset);
|
||||||
|
CachedUserInfo userInfo = m_userTransactions.Manager.CommsManager.UserProfiles.GetUserDetails(ourClient.AgentId);
|
||||||
|
if (userInfo != null)
|
||||||
|
{
|
||||||
|
InventoryItemBase item = new InventoryItemBase();
|
||||||
|
item.avatarID = this.ourClient.AgentId;
|
||||||
|
item.creatorsID = ourClient.AgentId;
|
||||||
|
item.inventoryID = LLUUID.Random();
|
||||||
|
item.assetID = Asset.FullID;
|
||||||
|
item.inventoryDescription = this.m_description;
|
||||||
|
item.inventoryName = m_name;
|
||||||
|
item.assetType = type;
|
||||||
|
item.invType = this.invType;
|
||||||
|
item.parentFolderID = this.InventFolder;
|
||||||
|
item.inventoryCurrentPermissions = 2147483647;
|
||||||
|
item.inventoryNextPermissions = this.nextPerm;
|
||||||
|
|
||||||
|
userInfo.AddItem(ourClient.AgentId, item);
|
||||||
|
ourClient.SendInventoryItemUpdate(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateInventoryItem(LLUUID itemID)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NoteCardCapsUpdate
|
||||||
|
{
|
||||||
|
// Fields
|
||||||
|
private BaseHttpServer httpListener;
|
||||||
|
private LLUUID inventoryItemID;
|
||||||
|
private string m_assetName = "";
|
||||||
|
private LLUUID newAssetID;
|
||||||
|
private bool SaveImages = false;
|
||||||
|
private string uploaderPath = "";
|
||||||
|
|
||||||
|
// Events
|
||||||
|
public event UpLoadedAsset OnUpLoad;
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
public void Initialise(LLUUID inventoryItem, string path, BaseHttpServer httpServer)
|
||||||
|
{
|
||||||
|
this.inventoryItemID = inventoryItem;
|
||||||
|
this.uploaderPath = path;
|
||||||
|
this.httpListener = httpServer;
|
||||||
|
this.newAssetID = LLUUID.Random();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveImageToFile(string filename, byte[] data)
|
||||||
|
{
|
||||||
|
FileStream output = File.Create(filename);
|
||||||
|
BinaryWriter writer = new BinaryWriter(output);
|
||||||
|
writer.Write(data);
|
||||||
|
writer.Close();
|
||||||
|
output.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string uploaderCaps(byte[] data, string path, string param)
|
||||||
|
{
|
||||||
|
LLUUID inventoryItemID = this.inventoryItemID;
|
||||||
|
string text = "";
|
||||||
|
LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete();
|
||||||
|
complete.new_asset = this.newAssetID.ToStringHyphenated();
|
||||||
|
complete.new_inventory_item = inventoryItemID;
|
||||||
|
complete.state = "complete";
|
||||||
|
text = LLSDHelpers.SerialiseLLSDReply(complete);
|
||||||
|
this.httpListener.RemoveStreamHandler("POST", this.uploaderPath);
|
||||||
|
if (this.SaveImages)
|
||||||
|
{
|
||||||
|
this.SaveImageToFile(this.m_assetName + "notecard.txt", data);
|
||||||
|
}
|
||||||
|
if (this.OnUpLoad != null)
|
||||||
|
{
|
||||||
|
this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data, "" , "" );
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,133 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 System.IO;
|
||||||
|
using libsecondlife;
|
||||||
|
using OpenSim.Framework.Interfaces;
|
||||||
|
using OpenSim.Framework.Types;
|
||||||
|
using OpenSim.Framework.Data;
|
||||||
|
using OpenSim.Framework.Utilities;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Communications.Caches
|
||||||
|
{
|
||||||
|
public class CachedUserInfo
|
||||||
|
{
|
||||||
|
private CommunicationsManager m_parentCommsManager;
|
||||||
|
// Fields
|
||||||
|
public InventoryFolder RootFolder = null;
|
||||||
|
public UserProfileData UserProfile = null;
|
||||||
|
|
||||||
|
public CachedUserInfo(CommunicationsManager commsManager)
|
||||||
|
{
|
||||||
|
m_parentCommsManager = commsManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
public void FolderReceive(LLUUID userID, InventoryFolder folderInfo)
|
||||||
|
{
|
||||||
|
if (userID == this.UserProfile.UUID)
|
||||||
|
{
|
||||||
|
if (this.RootFolder == null)
|
||||||
|
{
|
||||||
|
if (folderInfo.parentID == LLUUID.Zero)
|
||||||
|
{
|
||||||
|
this.RootFolder = folderInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (this.RootFolder.folderID == folderInfo.parentID)
|
||||||
|
{
|
||||||
|
this.RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InventoryFolder folder = this.RootFolder.HasSubFolder(folderInfo.parentID);
|
||||||
|
if (folder != null)
|
||||||
|
{
|
||||||
|
folder.SubFolders.Add(folderInfo.folderID, folderInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo)
|
||||||
|
{
|
||||||
|
if ((userID == this.UserProfile.UUID) && (this.RootFolder != null))
|
||||||
|
{
|
||||||
|
if (itemInfo.parentFolderID == this.RootFolder.folderID)
|
||||||
|
{
|
||||||
|
this.RootFolder.Items.Add(itemInfo.inventoryID, itemInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InventoryFolder folder = this.RootFolder.HasSubFolder(itemInfo.parentFolderID);
|
||||||
|
if (folder != null)
|
||||||
|
{
|
||||||
|
folder.Items.Add(itemInfo.inventoryID, itemInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddItem(LLUUID userID, InventoryItemBase itemInfo)
|
||||||
|
{
|
||||||
|
if ((userID == this.UserProfile.UUID) && (this.RootFolder != null))
|
||||||
|
{
|
||||||
|
this.ItemReceive(userID, itemInfo);
|
||||||
|
this.m_parentCommsManager.InventoryServer.AddNewInventoryItem(userID, itemInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateItem(LLUUID userID, InventoryItemBase itemInfo)
|
||||||
|
{
|
||||||
|
if ((userID == this.UserProfile.UUID) && (this.RootFolder != null))
|
||||||
|
{
|
||||||
|
this.m_parentCommsManager.InventoryServer.AddNewInventoryItem(userID, itemInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DeleteItem(LLUUID userID, InventoryItemBase item)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
if ((userID == this.UserProfile.UUID) && (this.RootFolder != null))
|
||||||
|
{
|
||||||
|
result = RootFolder.DeleteItem(item.inventoryID);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
this.m_parentCommsManager.InventoryServer.DeleteInventoryItem(userID, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,144 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 System.IO;
|
||||||
|
using libsecondlife;
|
||||||
|
using OpenSim.Framework.Interfaces;
|
||||||
|
using OpenSim.Framework.Data;
|
||||||
|
using OpenSim.Framework.Types;
|
||||||
|
using OpenSim.Framework.Utilities;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Communications.Caches
|
||||||
|
{
|
||||||
|
public class InventoryFolder : InventoryFolderBase
|
||||||
|
{
|
||||||
|
// Fields
|
||||||
|
public Dictionary<LLUUID, InventoryItemBase> Items = new Dictionary<LLUUID, InventoryItemBase>();
|
||||||
|
public Dictionary<LLUUID, InventoryFolder> SubFolders = new Dictionary<LLUUID, InventoryFolder>();
|
||||||
|
|
||||||
|
public InventoryFolder(InventoryFolderBase folderbase)
|
||||||
|
{
|
||||||
|
this.agentID = folderbase.agentID;
|
||||||
|
this.folderID = folderbase.folderID;
|
||||||
|
this.name = folderbase.name;
|
||||||
|
this.parentID = folderbase.parentID;
|
||||||
|
this.type = folderbase.type;
|
||||||
|
this.version = folderbase.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InventoryFolder()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
public InventoryFolder CreateNewSubFolder(LLUUID folderID, string folderName, ushort type)
|
||||||
|
{
|
||||||
|
InventoryFolder subFold = new InventoryFolder();
|
||||||
|
subFold.name = folderName;
|
||||||
|
subFold.folderID = folderID;
|
||||||
|
subFold.type = (short) type;
|
||||||
|
subFold.parentID = this.folderID;
|
||||||
|
subFold.agentID = this.agentID;
|
||||||
|
this.SubFolders.Add(subFold.folderID, subFold);
|
||||||
|
return subFold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InventoryItemBase HasItem(LLUUID itemID)
|
||||||
|
{
|
||||||
|
InventoryItemBase base2 = null;
|
||||||
|
if (this.Items.ContainsKey(itemID))
|
||||||
|
{
|
||||||
|
return this.Items[itemID];
|
||||||
|
}
|
||||||
|
foreach (InventoryFolder folder in this.SubFolders.Values)
|
||||||
|
{
|
||||||
|
base2 = folder.HasItem(itemID);
|
||||||
|
if (base2 != null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return base2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DeleteItem(LLUUID itemID)
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
if (this.Items.ContainsKey(itemID))
|
||||||
|
{
|
||||||
|
Items.Remove(itemID);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
foreach (InventoryFolder folder in this.SubFolders.Values)
|
||||||
|
{
|
||||||
|
found = folder.DeleteItem(itemID);
|
||||||
|
if (found == true)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public InventoryFolder HasSubFolder(LLUUID folderID)
|
||||||
|
{
|
||||||
|
InventoryFolder returnFolder = null;
|
||||||
|
if (this.SubFolders.ContainsKey(folderID))
|
||||||
|
{
|
||||||
|
returnFolder = this.SubFolders[folderID];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (InventoryFolder folder in this.SubFolders.Values)
|
||||||
|
{
|
||||||
|
returnFolder = folder.HasSubFolder(folderID);
|
||||||
|
if (returnFolder != null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<InventoryItemBase> RequestListOfItems()
|
||||||
|
{
|
||||||
|
List<InventoryItemBase> itemList = new List<InventoryItemBase>();
|
||||||
|
foreach (InventoryItemBase item in this.Items.Values)
|
||||||
|
{
|
||||||
|
itemList.Add(item);
|
||||||
|
}
|
||||||
|
return itemList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,213 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using libsecondlife;
|
||||||
|
using OpenSim.Framework.Utilities;
|
||||||
|
using OpenSim.Framework.Data;
|
||||||
|
using Nini.Config;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Communications.Caches
|
||||||
|
{
|
||||||
|
public class LibraryRootFolder : InventoryFolder
|
||||||
|
{
|
||||||
|
private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000");
|
||||||
|
private InventoryFolder m_textureFolder;
|
||||||
|
|
||||||
|
public LibraryRootFolder()
|
||||||
|
{
|
||||||
|
this.agentID = libOwner;
|
||||||
|
this.folderID = new LLUUID("00000112-000f-0000-0000-000100bba000");
|
||||||
|
this.name = "OpenSim Library";
|
||||||
|
this.parentID = LLUUID.Zero;
|
||||||
|
this.type = (short)-1;
|
||||||
|
this.version = (ushort)1;
|
||||||
|
|
||||||
|
InventoryFolder folderInfo = new InventoryFolder();
|
||||||
|
folderInfo.agentID = libOwner;
|
||||||
|
folderInfo.folderID = new LLUUID("00000112-000f-0000-0000-000100bba001");
|
||||||
|
folderInfo.name = "Texture Library";
|
||||||
|
folderInfo.parentID = this.folderID;
|
||||||
|
folderInfo.type = -1;
|
||||||
|
folderInfo.version = 1;
|
||||||
|
this.SubFolders.Add(folderInfo.folderID, folderInfo);
|
||||||
|
this.m_textureFolder = folderInfo;
|
||||||
|
|
||||||
|
this.CreateLibraryItems();
|
||||||
|
|
||||||
|
string filePath = Path.Combine(Util.configDir(), "OpenSimLibrary.xml");
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
XmlConfigSource source = new XmlConfigSource(filePath);
|
||||||
|
this.ReadItemsFromFile(source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateLibraryItems()
|
||||||
|
{
|
||||||
|
|
||||||
|
InventoryItemBase item = new InventoryItemBase();
|
||||||
|
item.avatarID = libOwner;
|
||||||
|
item.creatorsID = libOwner;
|
||||||
|
item.inventoryID = LLUUID.Random();
|
||||||
|
item.assetID = new LLUUID("00000000-0000-0000-9999-000000000002");
|
||||||
|
item.inventoryDescription = "Plywood texture";
|
||||||
|
item.inventoryName = "Plywood";
|
||||||
|
item.assetType = 0;
|
||||||
|
item.parentFolderID = m_textureFolder.folderID;
|
||||||
|
item.inventoryBasePermissions = 0x7FFFFFFF;
|
||||||
|
item.inventoryEveryOnePermissions = 0x7FFFFFFF;
|
||||||
|
item.inventoryCurrentPermissions = 0x7FFFFFFF;
|
||||||
|
item.inventoryNextPermissions = 0x7FFFFFFF;
|
||||||
|
this.m_textureFolder.Items.Add(item.inventoryID, item);
|
||||||
|
|
||||||
|
item = new InventoryItemBase();
|
||||||
|
item.avatarID = libOwner;
|
||||||
|
item.creatorsID = libOwner;
|
||||||
|
item.inventoryID = LLUUID.Random();
|
||||||
|
item.assetID = new LLUUID("00000000-0000-0000-9999-000000000003");
|
||||||
|
item.inventoryDescription = "Rocks texture";
|
||||||
|
item.inventoryName = "Rocks";
|
||||||
|
item.assetType = 0;
|
||||||
|
item.parentFolderID = m_textureFolder.folderID;
|
||||||
|
item.inventoryBasePermissions = 0x7FFFFFFF;
|
||||||
|
item.inventoryEveryOnePermissions = 0x7FFFFFFF;
|
||||||
|
item.inventoryCurrentPermissions = 0x7FFFFFFF;
|
||||||
|
item.inventoryNextPermissions = 0x7FFFFFFF;
|
||||||
|
this.m_textureFolder.Items.Add(item.inventoryID, item);
|
||||||
|
|
||||||
|
item = new InventoryItemBase();
|
||||||
|
item.avatarID = libOwner;
|
||||||
|
item.creatorsID = libOwner;
|
||||||
|
item.inventoryID = LLUUID.Random();
|
||||||
|
item.assetID = new LLUUID("00000000-0000-0000-9999-000000000001");
|
||||||
|
item.inventoryDescription = "Bricks texture";
|
||||||
|
item.inventoryName = "Bricks";
|
||||||
|
item.assetType = 0;
|
||||||
|
item.parentFolderID = m_textureFolder.folderID;
|
||||||
|
item.inventoryBasePermissions = 0x7FFFFFFF;
|
||||||
|
item.inventoryEveryOnePermissions = 0x7FFFFFFF;
|
||||||
|
item.inventoryCurrentPermissions = 0x7FFFFFFF;
|
||||||
|
item.inventoryNextPermissions = 0x7FFFFFFF;
|
||||||
|
this.m_textureFolder.Items.Add(item.inventoryID, item);
|
||||||
|
|
||||||
|
item = new InventoryItemBase();
|
||||||
|
item.avatarID = libOwner;
|
||||||
|
item.creatorsID = libOwner;
|
||||||
|
item.inventoryID = LLUUID.Random();
|
||||||
|
item.assetID = new LLUUID("00000000-0000-0000-9999-000000000004");
|
||||||
|
item.inventoryDescription = "Granite texture";
|
||||||
|
item.inventoryName = "Granite";
|
||||||
|
item.assetType = 0;
|
||||||
|
item.parentFolderID = m_textureFolder.folderID;
|
||||||
|
item.inventoryBasePermissions = 0x7FFFFFFF;
|
||||||
|
item.inventoryEveryOnePermissions = 0x7FFFFFFF;
|
||||||
|
item.inventoryCurrentPermissions = 0x7FFFFFFF;
|
||||||
|
item.inventoryNextPermissions = 0x7FFFFFFF;
|
||||||
|
this.m_textureFolder.Items.Add(item.inventoryID, item);
|
||||||
|
|
||||||
|
item = new InventoryItemBase();
|
||||||
|
item.avatarID = libOwner;
|
||||||
|
item.creatorsID = libOwner;
|
||||||
|
item.inventoryID = LLUUID.Random();
|
||||||
|
item.assetID = new LLUUID("00000000-0000-0000-9999-000000000005");
|
||||||
|
item.inventoryDescription = "Hardwood texture";
|
||||||
|
item.inventoryName = "Hardwood";
|
||||||
|
item.assetType = 0;
|
||||||
|
item.parentFolderID = m_textureFolder.folderID;
|
||||||
|
item.inventoryBasePermissions = 0x7FFFFFFF;
|
||||||
|
item.inventoryEveryOnePermissions = 0x7FFFFFFF;
|
||||||
|
item.inventoryCurrentPermissions = 0x7FFFFFFF;
|
||||||
|
item.inventoryNextPermissions = 0x7FFFFFFF;
|
||||||
|
this.m_textureFolder.Items.Add(item.inventoryID, item);
|
||||||
|
|
||||||
|
item = new InventoryItemBase();
|
||||||
|
item.avatarID = libOwner;
|
||||||
|
item.creatorsID = libOwner;
|
||||||
|
item.inventoryID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfaba9");
|
||||||
|
item.assetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
|
||||||
|
item.inventoryDescription = "Default Shape";
|
||||||
|
item.inventoryName = "Default Shape";
|
||||||
|
item.assetType = 13;
|
||||||
|
item.invType = 18;
|
||||||
|
item.parentFolderID = this.folderID;
|
||||||
|
item.inventoryCurrentPermissions = 0;
|
||||||
|
item.inventoryNextPermissions = 0;
|
||||||
|
this.Items.Add(item.inventoryID, item);
|
||||||
|
|
||||||
|
item = new InventoryItemBase();
|
||||||
|
item.avatarID = libOwner;
|
||||||
|
item.creatorsID = libOwner;
|
||||||
|
item.inventoryID = new LLUUID("77c41e39-38f9-f75a-024e-585989bfabc9");
|
||||||
|
item.assetID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb");
|
||||||
|
item.inventoryDescription = "Default Skin";
|
||||||
|
item.inventoryName = "Default Skin";
|
||||||
|
item.assetType = 13;
|
||||||
|
item.invType = 18;
|
||||||
|
item.parentFolderID = this.folderID;
|
||||||
|
item.inventoryCurrentPermissions = 0;
|
||||||
|
item.inventoryNextPermissions = 0;
|
||||||
|
this.Items.Add(item.inventoryID, item);
|
||||||
|
|
||||||
|
item = new InventoryItemBase();
|
||||||
|
item.avatarID = libOwner;
|
||||||
|
item.creatorsID = libOwner;
|
||||||
|
item.inventoryID = new LLUUID("77c41e39-38f9-f75a-0000-585989bf0000");
|
||||||
|
item.assetID = new LLUUID("00000000-38f9-1111-024e-222222111110");
|
||||||
|
item.inventoryDescription = "Default Shirt";
|
||||||
|
item.inventoryName = "Default Shirt";
|
||||||
|
item.assetType = 5;
|
||||||
|
item.invType = 18;
|
||||||
|
item.parentFolderID = this.folderID;
|
||||||
|
item.inventoryCurrentPermissions = 0;
|
||||||
|
item.inventoryNextPermissions = 0;
|
||||||
|
this.Items.Add(item.inventoryID, item);
|
||||||
|
|
||||||
|
item = new InventoryItemBase();
|
||||||
|
item.avatarID = libOwner;
|
||||||
|
item.creatorsID = libOwner;
|
||||||
|
item.inventoryID = new LLUUID("77c41e39-38f9-f75a-0000-5859892f1111");
|
||||||
|
item.assetID = new LLUUID("00000000-38f9-1111-024e-222222111120");
|
||||||
|
item.inventoryDescription = "Default Pants";
|
||||||
|
item.inventoryName = "Default Pants";
|
||||||
|
item.assetType = 5;
|
||||||
|
item.invType = 18;
|
||||||
|
item.parentFolderID = this.folderID;
|
||||||
|
item.inventoryCurrentPermissions = 0;
|
||||||
|
item.inventoryNextPermissions = 0;
|
||||||
|
this.Items.Add(item.inventoryID, item);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReadItemsFromFile(IConfigSource source)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < source.Configs.Count; i++)
|
||||||
|
{
|
||||||
|
InventoryItemBase item = new InventoryItemBase();
|
||||||
|
item.avatarID = libOwner;
|
||||||
|
item.creatorsID = libOwner;
|
||||||
|
item.inventoryID = new LLUUID(source.Configs[i].GetString("inventoryID", LLUUID.Random().ToStringHyphenated()));
|
||||||
|
item.assetID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()));
|
||||||
|
item.inventoryDescription = source.Configs[i].GetString("description", "");
|
||||||
|
item.inventoryName = source.Configs[i].GetString("name", "");
|
||||||
|
item.assetType = source.Configs[i].GetInt("assetType", 0);
|
||||||
|
item.invType = source.Configs[i].GetInt("inventoryType", 0);
|
||||||
|
item.inventoryCurrentPermissions = (uint)source.Configs[i].GetLong("currentPermissions", 0x7FFFFFFF);
|
||||||
|
item.inventoryNextPermissions = (uint)source.Configs[i].GetLong("nextPermissions", 0x7FFFFFFF);
|
||||||
|
item.inventoryEveryOnePermissions = (uint)source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF);
|
||||||
|
item.inventoryBasePermissions = (uint)source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF);
|
||||||
|
if (item.assetType == 0)
|
||||||
|
{
|
||||||
|
item.parentFolderID = this.m_textureFolder.folderID;
|
||||||
|
this.m_textureFolder.Items.Add(item.inventoryID, item);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item.parentFolderID = this.folderID;
|
||||||
|
this.Items.Add(item.inventoryID, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,234 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 System.IO;
|
||||||
|
using libsecondlife;
|
||||||
|
using OpenSim.Framework.Interfaces;
|
||||||
|
using OpenSim.Framework.Types;
|
||||||
|
using OpenSim.Framework.Utilities;
|
||||||
|
using OpenSim.Framework.Data;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Communications.Caches
|
||||||
|
{
|
||||||
|
public class UserProfileCache
|
||||||
|
{
|
||||||
|
// Fields
|
||||||
|
private CommunicationsManager m_parent;
|
||||||
|
public Dictionary<LLUUID, CachedUserInfo> UserProfiles = new Dictionary<LLUUID, CachedUserInfo>();
|
||||||
|
|
||||||
|
public LibraryRootFolder libraryRoot = new LibraryRootFolder();
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
public UserProfileCache(CommunicationsManager parent)
|
||||||
|
{
|
||||||
|
this.m_parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A new user has moved into a region in this instance
|
||||||
|
/// so get info from servers
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userID"></param>
|
||||||
|
public void AddNewUser(LLUUID userID)
|
||||||
|
{
|
||||||
|
if (!this.UserProfiles.ContainsKey(userID))
|
||||||
|
{
|
||||||
|
CachedUserInfo userInfo = new CachedUserInfo(this.m_parent);
|
||||||
|
userInfo.UserProfile = this.RequestUserProfileForUser(userID);
|
||||||
|
if (userInfo.UserProfile != null)
|
||||||
|
{
|
||||||
|
this.RequestInventoryForUser(userID, userInfo);
|
||||||
|
this.UserProfiles.Add(userID, userInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("CACHE", "User profile for user not found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A new user has moved into a region in this instance
|
||||||
|
/// so get info from servers
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="firstName"></param>
|
||||||
|
/// <param name="lastName"></param>
|
||||||
|
public void AddNewUser(string firstName, string lastName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public CachedUserInfo GetUserDetails(LLUUID userID)
|
||||||
|
{
|
||||||
|
if (this.UserProfiles.ContainsKey(userID))
|
||||||
|
{
|
||||||
|
return this.UserProfiles[userID];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID)
|
||||||
|
{
|
||||||
|
if (this.UserProfiles.ContainsKey(remoteClient.AgentId))
|
||||||
|
{
|
||||||
|
if (this.UserProfiles[remoteClient.AgentId].RootFolder != null)
|
||||||
|
{
|
||||||
|
CachedUserInfo info = this.UserProfiles[remoteClient.AgentId];
|
||||||
|
if (info.RootFolder.folderID == parentID)
|
||||||
|
{
|
||||||
|
InventoryFolder createdFolder = info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType);
|
||||||
|
if (createdFolder != null)
|
||||||
|
{
|
||||||
|
this.m_parent.InventoryServer.AddNewInventoryFolder(remoteClient.AgentId, createdFolder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InventoryFolder folder = info.RootFolder.HasSubFolder(parentID);
|
||||||
|
if (folder != null)
|
||||||
|
{
|
||||||
|
folder.CreateNewSubFolder(folderID, folderName, folderType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder)
|
||||||
|
{
|
||||||
|
InventoryFolder fold = null;
|
||||||
|
if (folderID == libraryRoot.folderID )
|
||||||
|
{
|
||||||
|
remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems());
|
||||||
|
}
|
||||||
|
else if (( fold = libraryRoot.HasSubFolder(folderID)) != null)
|
||||||
|
{
|
||||||
|
remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, folderID, fold.RequestListOfItems());
|
||||||
|
}
|
||||||
|
else if (this.UserProfiles.ContainsKey(remoteClient.AgentId))
|
||||||
|
{
|
||||||
|
if (this.UserProfiles[remoteClient.AgentId].RootFolder != null)
|
||||||
|
{
|
||||||
|
CachedUserInfo info = this.UserProfiles[remoteClient.AgentId];
|
||||||
|
if (info.RootFolder.folderID == folderID)
|
||||||
|
{
|
||||||
|
if (fetchItems)
|
||||||
|
{
|
||||||
|
remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, info.RootFolder.RequestListOfItems());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InventoryFolder folder = info.RootFolder.HasSubFolder(folderID);
|
||||||
|
if ((folder != null) && fetchItems)
|
||||||
|
{
|
||||||
|
remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID)
|
||||||
|
{
|
||||||
|
if (ownerID == libraryRoot.agentID)
|
||||||
|
{
|
||||||
|
//Console.WriteLine("request info for library item");
|
||||||
|
}
|
||||||
|
else if (this.UserProfiles.ContainsKey(remoteClient.AgentId))
|
||||||
|
{
|
||||||
|
if (this.UserProfiles[remoteClient.AgentId].RootFolder != null)
|
||||||
|
{
|
||||||
|
InventoryItemBase item = this.UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID);
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
remoteClient.SendInventoryItemDetails(ownerID, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Request Iventory Info from Inventory server
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userID"></param>
|
||||||
|
private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo)
|
||||||
|
{
|
||||||
|
this.m_parent.InventoryServer.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive);
|
||||||
|
|
||||||
|
//for now we manually create the root folder,
|
||||||
|
// but should be requesting all inventory from inventory server.
|
||||||
|
/* InventoryFolder folderInfo = new InventoryFolder();
|
||||||
|
folderInfo.agentID = userID;
|
||||||
|
folderInfo.folderID = userInfo.UserProfile.rootInventoryFolderID;
|
||||||
|
folderInfo.name = "My Inventory";
|
||||||
|
folderInfo.parentID = LLUUID.Zero;
|
||||||
|
folderInfo.type = 8;
|
||||||
|
folderInfo.version = 1;
|
||||||
|
userInfo.FolderReceive(userID, folderInfo);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Request the user profile from User server
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userID"></param>
|
||||||
|
private UserProfileData RequestUserProfileForUser(LLUUID userID)
|
||||||
|
{
|
||||||
|
return this.m_parent.UserServer.GetUserProfile(userID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update Inventory data to Inventory server
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userID"></param>
|
||||||
|
private void UpdateInventoryToServer(LLUUID userID)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Make sure UserProfile is updated on user server
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userID"></param>
|
||||||
|
private void UpdateUserProfileToServer(LLUUID userID)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A user has left this instance
|
||||||
|
/// so make sure servers have been updated
|
||||||
|
/// Then remove cached info
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userID"></param>
|
||||||
|
public void UserLogOut(LLUUID userID)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,502 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 System.IO;
|
||||||
|
using libsecondlife;
|
||||||
|
using OpenSim.Framework.Servers;
|
||||||
|
using OpenSim.Framework.Types;
|
||||||
|
using OpenSim.Framework.Utilities;
|
||||||
|
using OpenSim.Framework.Communications.Caches;
|
||||||
|
using OpenSim.Framework.Data;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Capabilities
|
||||||
|
{
|
||||||
|
public delegate void UpLoadedAsset(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data, string inventoryType, string assetType);
|
||||||
|
public delegate LLUUID UpdateItem(LLUUID itemID, byte[] data);
|
||||||
|
public delegate void NewInventoryItem(LLUUID userID, InventoryItemBase item);
|
||||||
|
public delegate LLUUID ItemUpdatedCallback(LLUUID userID, LLUUID itemID, byte[] data);
|
||||||
|
|
||||||
|
public class Caps
|
||||||
|
{
|
||||||
|
private string m_httpListenerHostName;
|
||||||
|
private int m_httpListenPort;
|
||||||
|
private string m_capsObjectPath = "00001-";
|
||||||
|
private string m_requestPath = "0000/";
|
||||||
|
private string m_mapLayerPath = "0001/";
|
||||||
|
private string m_newInventory = "0002/";
|
||||||
|
//private string m_requestTexture = "0003/";
|
||||||
|
private string m_notecardUpdatePath = "0004/";
|
||||||
|
//private string eventQueue = "0100/";
|
||||||
|
private BaseHttpServer httpListener;
|
||||||
|
private LLUUID agentID;
|
||||||
|
private AssetCache assetCache;
|
||||||
|
private int eventQueueCount = 1;
|
||||||
|
private Queue<string> CapsEventQueue = new Queue<string>();
|
||||||
|
public NewInventoryItem AddNewInventoryItem = null;
|
||||||
|
public ItemUpdatedCallback ItemUpdatedCall = null;
|
||||||
|
|
||||||
|
public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent)
|
||||||
|
{
|
||||||
|
assetCache = assetCach;
|
||||||
|
m_capsObjectPath = capsPath;
|
||||||
|
httpListener = httpServer;
|
||||||
|
m_httpListenerHostName = httpListen;
|
||||||
|
m_httpListenPort = httpPort;
|
||||||
|
agentID = agent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public void RegisterHandlers()
|
||||||
|
{
|
||||||
|
Console.WriteLine("registering CAPS handlers");
|
||||||
|
string capsBase = "/CAPS/" + m_capsObjectPath;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
httpListener.AddStreamHandler(new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST", capsBase + m_mapLayerPath, this.GetMapLayer));
|
||||||
|
httpListener.AddStreamHandler(new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST", capsBase + m_newInventory, this.NewAgentInventoryRequest));
|
||||||
|
|
||||||
|
AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest);
|
||||||
|
//AddLegacyCapsHandler(httpListener, m_requestTexture , RequestTexture);
|
||||||
|
AddLegacyCapsHandler(httpListener, m_notecardUpdatePath, NoteCardAgentInventory);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//[Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")]
|
||||||
|
//Commented out the obsolete as at this time the first caps request can not use the new Caps method
|
||||||
|
//as the sent type is a array and not a map and the deserialising doesn't deal properly with arrays.
|
||||||
|
private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod)
|
||||||
|
{
|
||||||
|
string capsBase = "/CAPS/" + m_capsObjectPath;
|
||||||
|
httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string CapsRequest(string request, string path, string param)
|
||||||
|
{
|
||||||
|
// Console.WriteLine("caps request " + request);
|
||||||
|
string result = LLSDHelpers.SerialiseLLSDReply(this.GetCapabilities());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
protected LLSDCapsDetails GetCapabilities()
|
||||||
|
{
|
||||||
|
LLSDCapsDetails caps = new LLSDCapsDetails();
|
||||||
|
string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath;
|
||||||
|
caps.MapLayer = capsBaseUrl + m_mapLayerPath;
|
||||||
|
caps.NewFileAgentInventory = capsBaseUrl + m_newInventory;
|
||||||
|
caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath;
|
||||||
|
caps.UpdateScriptAgentInventory = capsBaseUrl + m_notecardUpdatePath;
|
||||||
|
return caps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mapReq"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq)
|
||||||
|
{
|
||||||
|
LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
|
||||||
|
mapResponse.LayerData.Array.Add(this.GetLLSDMapLayerResponse());
|
||||||
|
return mapResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
protected LLSDMapLayer GetLLSDMapLayerResponse()
|
||||||
|
{
|
||||||
|
LLSDMapLayer mapLayer = new LLSDMapLayer();
|
||||||
|
mapLayer.Right = 5000;
|
||||||
|
mapLayer.Top = 5000;
|
||||||
|
mapLayer.ImageID = new LLUUID("00000000-0000-0000-9999-000000000006");
|
||||||
|
return mapLayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string RequestTexture(string request, string path, string param)
|
||||||
|
{
|
||||||
|
Console.WriteLine("texture request " + request);
|
||||||
|
// Needs implementing (added to remove compiler warning)
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
#region EventQueue (Currently not enabled)
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string ProcessEventQueue(string request, string path, string param)
|
||||||
|
{
|
||||||
|
string res = "";
|
||||||
|
|
||||||
|
if (this.CapsEventQueue.Count > 0)
|
||||||
|
{
|
||||||
|
lock (this.CapsEventQueue)
|
||||||
|
{
|
||||||
|
string item = CapsEventQueue.Dequeue();
|
||||||
|
res = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
res = this.CreateEmptyEventResponse();
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="caps"></param>
|
||||||
|
/// <param name="ipAddressPort"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string CreateEstablishAgentComms(string caps, string ipAddressPort)
|
||||||
|
{
|
||||||
|
LLSDCapEvent eventItem = new LLSDCapEvent();
|
||||||
|
eventItem.id = eventQueueCount;
|
||||||
|
//should be creating a EstablishAgentComms item, but there isn't a class for it yet
|
||||||
|
eventItem.events.Array.Add(new LLSDEmpty());
|
||||||
|
string res = LLSDHelpers.SerialiseLLSDReply(eventItem);
|
||||||
|
eventQueueCount++;
|
||||||
|
|
||||||
|
this.CapsEventQueue.Enqueue(res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string CreateEmptyEventResponse()
|
||||||
|
{
|
||||||
|
LLSDCapEvent eventItem = new LLSDCapEvent();
|
||||||
|
eventItem.id = eventQueueCount;
|
||||||
|
eventItem.events.Array.Add(new LLSDEmpty());
|
||||||
|
string res = LLSDHelpers.SerialiseLLSDReply(eventItem);
|
||||||
|
eventQueueCount++;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string NoteCardAgentInventory(string request, string path, string param)
|
||||||
|
{
|
||||||
|
Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request));
|
||||||
|
LLSDItemUpdate llsdRequest = new LLSDItemUpdate();
|
||||||
|
LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest);
|
||||||
|
|
||||||
|
string capsBase = "/CAPS/" + m_capsObjectPath;
|
||||||
|
LLUUID newInvItem = llsdRequest.item_id;
|
||||||
|
string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
|
||||||
|
|
||||||
|
ItemUpdater uploader = new ItemUpdater(newInvItem, capsBase + uploaderPath, this.httpListener);
|
||||||
|
uploader.OnUpLoad += this.ItemUpdated;
|
||||||
|
|
||||||
|
httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps));
|
||||||
|
string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath;
|
||||||
|
|
||||||
|
LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse();
|
||||||
|
uploadResponse.uploader = uploaderURL;
|
||||||
|
uploadResponse.state = "upload";
|
||||||
|
|
||||||
|
return LLSDHelpers.SerialiseLLSDReply(uploadResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="llsdRequest"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest)
|
||||||
|
{
|
||||||
|
//Console.WriteLine("asset upload request via CAPS" + llsdRequest.inventory_type +" , "+ llsdRequest.asset_type);
|
||||||
|
|
||||||
|
string assetName = llsdRequest.name;
|
||||||
|
string assetDes = llsdRequest.description;
|
||||||
|
string capsBase = "/CAPS/" + m_capsObjectPath;
|
||||||
|
LLUUID newAsset = LLUUID.Random();
|
||||||
|
LLUUID newInvItem = LLUUID.Random();
|
||||||
|
LLUUID parentFolder = llsdRequest.folder_id;
|
||||||
|
string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
|
||||||
|
|
||||||
|
AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, llsdRequest.asset_type, capsBase + uploaderPath, this.httpListener);
|
||||||
|
httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps));
|
||||||
|
string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath;
|
||||||
|
|
||||||
|
LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse();
|
||||||
|
uploadResponse.uploader = uploaderURL;
|
||||||
|
uploadResponse.state = "upload";
|
||||||
|
uploader.OnUpLoad += this.UploadCompleteHandler;
|
||||||
|
return uploadResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetID"></param>
|
||||||
|
/// <param name="inventoryItem"></param>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
public void UploadCompleteHandler(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data, string inventoryType, string assetType)
|
||||||
|
{
|
||||||
|
sbyte assType = 0;
|
||||||
|
sbyte inType = 0;
|
||||||
|
|
||||||
|
if (inventoryType == "sound")
|
||||||
|
{
|
||||||
|
inType = 1;
|
||||||
|
assType = 1;
|
||||||
|
}
|
||||||
|
else if (inventoryType == "animation")
|
||||||
|
{
|
||||||
|
inType = 19;
|
||||||
|
assType = 19;
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetBase asset;
|
||||||
|
asset = new AssetBase();
|
||||||
|
asset.FullID = assetID;
|
||||||
|
asset.Type = assType;
|
||||||
|
asset.InvType = inType;
|
||||||
|
asset.Name = assetName;
|
||||||
|
asset.Data = data;
|
||||||
|
this.assetCache.AddAsset(asset);
|
||||||
|
|
||||||
|
InventoryItemBase item = new InventoryItemBase();
|
||||||
|
item.avatarID = agentID;
|
||||||
|
item.creatorsID = agentID;
|
||||||
|
item.inventoryID = inventoryItem;
|
||||||
|
item.assetID = asset.FullID;
|
||||||
|
item.inventoryDescription = assetDescription;
|
||||||
|
item.inventoryName = assetName;
|
||||||
|
item.assetType = assType;
|
||||||
|
item.invType = inType;
|
||||||
|
item.parentFolderID = parentFolder;
|
||||||
|
item.inventoryCurrentPermissions = 2147483647;
|
||||||
|
item.inventoryNextPermissions = 2147483647;
|
||||||
|
|
||||||
|
if (AddNewInventoryItem != null)
|
||||||
|
{
|
||||||
|
AddNewInventoryItem(agentID, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public LLUUID ItemUpdated(LLUUID itemID, byte[] data)
|
||||||
|
{
|
||||||
|
if (ItemUpdatedCall != null)
|
||||||
|
{
|
||||||
|
return ItemUpdatedCall(this.agentID, itemID, data);
|
||||||
|
}
|
||||||
|
return LLUUID.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AssetUploader
|
||||||
|
{
|
||||||
|
public event UpLoadedAsset OnUpLoad;
|
||||||
|
|
||||||
|
private string uploaderPath = "";
|
||||||
|
private LLUUID newAssetID;
|
||||||
|
private LLUUID inventoryItemID;
|
||||||
|
private LLUUID parentFolder;
|
||||||
|
private BaseHttpServer httpListener;
|
||||||
|
private bool SaveAssets = false;
|
||||||
|
private string m_assetName = "";
|
||||||
|
private string m_assetDes = "";
|
||||||
|
|
||||||
|
private string m_invType = "";
|
||||||
|
private string m_assetType = "";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetID"></param>
|
||||||
|
/// <param name="inventoryItem"></param>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="httpServer"></param>
|
||||||
|
public AssetUploader(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolderID, string invType, string assetType, string path, BaseHttpServer httpServer)
|
||||||
|
{
|
||||||
|
m_assetName = assetName;
|
||||||
|
m_assetDes = description;
|
||||||
|
newAssetID = assetID;
|
||||||
|
inventoryItemID = inventoryItem;
|
||||||
|
uploaderPath = path;
|
||||||
|
httpListener = httpServer;
|
||||||
|
parentFolder = parentFolderID;
|
||||||
|
m_assetType = assetType;
|
||||||
|
m_invType = invType;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string uploaderCaps(byte[] data, string path, string param)
|
||||||
|
{
|
||||||
|
LLUUID inv = this.inventoryItemID;
|
||||||
|
string res = "";
|
||||||
|
LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
|
||||||
|
uploadComplete.new_asset = newAssetID.ToStringHyphenated();
|
||||||
|
uploadComplete.new_inventory_item = inv;
|
||||||
|
uploadComplete.state = "complete";
|
||||||
|
|
||||||
|
res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
|
||||||
|
|
||||||
|
httpListener.RemoveStreamHandler("POST", uploaderPath);
|
||||||
|
|
||||||
|
if(this.SaveAssets)
|
||||||
|
this.SaveAssetToFile(m_assetName + ".jp2", data);
|
||||||
|
|
||||||
|
if (OnUpLoad != null)
|
||||||
|
{
|
||||||
|
OnUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveAssetToFile(string filename, byte[] data)
|
||||||
|
{
|
||||||
|
FileStream fs = File.Create(filename);
|
||||||
|
BinaryWriter bw = new BinaryWriter(fs);
|
||||||
|
bw.Write(data);
|
||||||
|
bw.Close();
|
||||||
|
fs.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ItemUpdater
|
||||||
|
{
|
||||||
|
public event UpdateItem OnUpLoad;
|
||||||
|
|
||||||
|
private string uploaderPath = "";
|
||||||
|
private LLUUID inventoryItemID;
|
||||||
|
private BaseHttpServer httpListener;
|
||||||
|
private bool SaveAssets = false;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetID"></param>
|
||||||
|
/// <param name="inventoryItem"></param>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="httpServer"></param>
|
||||||
|
public ItemUpdater( LLUUID inventoryItem, string path, BaseHttpServer httpServer)
|
||||||
|
{
|
||||||
|
|
||||||
|
inventoryItemID = inventoryItem;
|
||||||
|
uploaderPath = path;
|
||||||
|
httpListener = httpServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string uploaderCaps(byte[] data, string path, string param)
|
||||||
|
{
|
||||||
|
LLUUID inv = this.inventoryItemID;
|
||||||
|
string res = "";
|
||||||
|
LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
|
||||||
|
LLUUID assetID = LLUUID.Zero;
|
||||||
|
|
||||||
|
if (OnUpLoad != null)
|
||||||
|
{
|
||||||
|
assetID = OnUpLoad(inv, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
uploadComplete.new_asset = assetID.ToStringHyphenated();
|
||||||
|
uploadComplete.new_inventory_item = inv;
|
||||||
|
uploadComplete.state = "complete";
|
||||||
|
|
||||||
|
res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
|
||||||
|
|
||||||
|
httpListener.RemoveStreamHandler("POST", uploaderPath);
|
||||||
|
|
||||||
|
if (this.SaveAssets)
|
||||||
|
this.SaveAssetToFile("updateditem"+Util.RandomClass.Next(1,1000) + ".dat", data);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveAssetToFile(string filename, byte[] data)
|
||||||
|
{
|
||||||
|
FileStream fs = File.Create(filename);
|
||||||
|
BinaryWriter bw = new BinaryWriter(fs);
|
||||||
|
bw.Write(data);
|
||||||
|
bw.Close();
|
||||||
|
fs.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Capabilities
|
||||||
|
{
|
||||||
|
[LLSDType("ARRAY")]
|
||||||
|
public class LLSDArray
|
||||||
|
{
|
||||||
|
public ArrayList Array = new ArrayList();
|
||||||
|
|
||||||
|
public LLSDArray()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Capabilities
|
||||||
|
{
|
||||||
|
[LLSDType("MAP")]
|
||||||
|
public class LLSDAssetUploadComplete
|
||||||
|
{
|
||||||
|
public string new_asset = "";
|
||||||
|
public LLUUID new_inventory_item = LLUUID.Zero;
|
||||||
|
public string state = "";
|
||||||
|
//public bool success = false;
|
||||||
|
|
||||||
|
public LLSDAssetUploadComplete()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Capabilities
|
||||||
|
{
|
||||||
|
[LLSDMap]
|
||||||
|
public class LLSDAssetUploadRequest
|
||||||
|
{
|
||||||
|
public string asset_type = "";
|
||||||
|
public string description = "";
|
||||||
|
public LLUUID folder_id = LLUUID.Zero;
|
||||||
|
public string inventory_type = "";
|
||||||
|
public string name = "";
|
||||||
|
|
||||||
|
public LLSDAssetUploadRequest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Capabilities
|
||||||
|
{
|
||||||
|
[LLSDMap]
|
||||||
|
public class LLSDAssetUploadResponse
|
||||||
|
{
|
||||||
|
public string uploader = "";
|
||||||
|
public string state = "";
|
||||||
|
|
||||||
|
public LLSDAssetUploadResponse()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
namespace OpenSim.Region.Capabilities
|
||||||
|
{
|
||||||
|
[LLSDType("MAP")]
|
||||||
|
public class LLSDCapEvent
|
||||||
|
{
|
||||||
|
public int id = 0;
|
||||||
|
public LLSDArray events = new LLSDArray();
|
||||||
|
|
||||||
|
public LLSDCapEvent()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
namespace OpenSim.Region.Capabilities
|
||||||
|
{
|
||||||
|
[LLSDType("MAP")]
|
||||||
|
public class LLSDCapsDetails
|
||||||
|
{
|
||||||
|
public string MapLayer = "";
|
||||||
|
public string NewFileAgentInventory = "";
|
||||||
|
//public string EventQueueGet = "";
|
||||||
|
// public string RequestTextureDownload = "";
|
||||||
|
// public string ChatSessionRequest = "";
|
||||||
|
public string UpdateNotecardAgentInventory = "";
|
||||||
|
public string UpdateScriptAgentInventory = "";
|
||||||
|
// public string ParcelVoiceInfoRequest = "";
|
||||||
|
|
||||||
|
public LLSDCapsDetails()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
namespace OpenSim.Region.Capabilities
|
||||||
|
{
|
||||||
|
[LLSDType("MAP")]
|
||||||
|
public class LLSDEmpty
|
||||||
|
{
|
||||||
|
public LLSDEmpty()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,164 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Xml;
|
||||||
|
using libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Capabilities
|
||||||
|
{
|
||||||
|
public class LLSDHelpers
|
||||||
|
{
|
||||||
|
public static string SerialiseLLSDReply(object obj)
|
||||||
|
{
|
||||||
|
StringWriter sw = new StringWriter();
|
||||||
|
XmlTextWriter writer = new XmlTextWriter(sw);
|
||||||
|
writer.Formatting = Formatting.None;
|
||||||
|
writer.WriteStartElement(String.Empty, "llsd", String.Empty);
|
||||||
|
SerializeLLSDType(writer, obj);
|
||||||
|
writer.WriteEndElement();
|
||||||
|
writer.Close();
|
||||||
|
return sw.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SerializeLLSDType(XmlTextWriter writer, object obj)
|
||||||
|
{
|
||||||
|
Type myType = obj.GetType();
|
||||||
|
LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false);
|
||||||
|
if (llsdattributes.Length > 0)
|
||||||
|
{
|
||||||
|
switch (llsdattributes[0].ObjectType)
|
||||||
|
{
|
||||||
|
case "MAP":
|
||||||
|
writer.WriteStartElement(String.Empty, "map", String.Empty);
|
||||||
|
FieldInfo[] fields = myType.GetFields();
|
||||||
|
for (int i = 0; i < fields.Length; i++)
|
||||||
|
{
|
||||||
|
object fieldValue = fields[i].GetValue(obj);
|
||||||
|
LLSDType[] fieldAttributes = (LLSDType[])fieldValue.GetType().GetCustomAttributes(typeof(LLSDType), false);
|
||||||
|
if (fieldAttributes.Length > 0)
|
||||||
|
{
|
||||||
|
writer.WriteStartElement(String.Empty, "key", String.Empty);
|
||||||
|
writer.WriteString(fields[i].Name);
|
||||||
|
writer.WriteEndElement();
|
||||||
|
SerializeLLSDType(writer, fieldValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writer.WriteStartElement(String.Empty, "key", String.Empty);
|
||||||
|
writer.WriteString(fields[i].Name);
|
||||||
|
writer.WriteEndElement();
|
||||||
|
LLSD.LLSDWriteOne(writer, fieldValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
writer.WriteEndElement();
|
||||||
|
break;
|
||||||
|
case "ARRAY":
|
||||||
|
// LLSDArray arrayObject = obj as LLSDArray;
|
||||||
|
// ArrayList a = arrayObject.Array;
|
||||||
|
ArrayList a = (ArrayList)obj.GetType().GetField("Array").GetValue(obj);
|
||||||
|
if (a != null)
|
||||||
|
{
|
||||||
|
writer.WriteStartElement(String.Empty, "array", String.Empty);
|
||||||
|
foreach (object item in a)
|
||||||
|
{
|
||||||
|
SerializeLLSDType(writer, item);
|
||||||
|
}
|
||||||
|
writer.WriteEndElement();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LLSD.LLSDWriteOne(writer, obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static object DeserialiseLLSDMap(Hashtable llsd, object obj)
|
||||||
|
{
|
||||||
|
Type myType = obj.GetType();
|
||||||
|
LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false);
|
||||||
|
if (llsdattributes.Length > 0)
|
||||||
|
{
|
||||||
|
switch (llsdattributes[0].ObjectType)
|
||||||
|
{
|
||||||
|
case "MAP":
|
||||||
|
IDictionaryEnumerator enumerator = llsd.GetEnumerator();
|
||||||
|
while (enumerator.MoveNext())
|
||||||
|
{
|
||||||
|
FieldInfo field = myType.GetField((string)enumerator.Key);
|
||||||
|
if (field != null)
|
||||||
|
{
|
||||||
|
if (enumerator.Value is Hashtable)
|
||||||
|
{
|
||||||
|
object fieldValue = field.GetValue(obj);
|
||||||
|
DeserialiseLLSDMap((Hashtable) enumerator.Value, fieldValue);
|
||||||
|
}
|
||||||
|
else if (enumerator.Value is ArrayList)
|
||||||
|
{
|
||||||
|
object fieldValue = field.GetValue(obj);
|
||||||
|
fieldValue.GetType().GetField("Array").SetValue(fieldValue, enumerator.Value);
|
||||||
|
//TODO
|
||||||
|
// the LLSD map/array types in the array need to be deserialised
|
||||||
|
// but first we need to know the right class to deserialise them into.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
field.SetValue(obj, enumerator.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Capabilities
|
||||||
|
{
|
||||||
|
[LLSDMap]
|
||||||
|
public class LLSDItemUpdate
|
||||||
|
{
|
||||||
|
public LLUUID item_id;
|
||||||
|
|
||||||
|
public LLSDItemUpdate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Capabilities
|
||||||
|
{
|
||||||
|
[LLSDType("MAP")]
|
||||||
|
public class LLSDMapLayer
|
||||||
|
{
|
||||||
|
public int Left = 0;
|
||||||
|
public int Right = 0;
|
||||||
|
public int Top = 0;
|
||||||
|
public int Bottom = 0;
|
||||||
|
public LLUUID ImageID = LLUUID.Zero;
|
||||||
|
|
||||||
|
public LLSDMapLayer()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
namespace OpenSim.Region.Capabilities
|
||||||
|
{
|
||||||
|
[LLSDType("MAP")]
|
||||||
|
public class LLSDMapLayerResponse
|
||||||
|
{
|
||||||
|
public LLSDMapRequest AgentData = new LLSDMapRequest();
|
||||||
|
public LLSDArray LayerData = new LLSDArray();
|
||||||
|
|
||||||
|
public LLSDMapLayerResponse()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
namespace OpenSim.Region.Capabilities
|
||||||
|
{
|
||||||
|
[LLSDType("MAP")]
|
||||||
|
public class LLSDMapRequest
|
||||||
|
{
|
||||||
|
public int Flags = 0;
|
||||||
|
|
||||||
|
public LLSDMapRequest()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Capabilities
|
||||||
|
{
|
||||||
|
public delegate TResponse LLSDMethod<TRequest, TResponse>(TRequest request);
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using OpenSim.Framework.Servers;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections;
|
||||||
|
using libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Capabilities
|
||||||
|
{
|
||||||
|
public class LLSDStreamhandler<TRequest, TResponse> : BaseStreamHandler
|
||||||
|
where TRequest : new()
|
||||||
|
{
|
||||||
|
private LLSDMethod<TRequest, TResponse> m_method;
|
||||||
|
|
||||||
|
public LLSDStreamhandler(string httpMethod, string path, LLSDMethod<TRequest, TResponse> method)
|
||||||
|
: base(httpMethod, path )
|
||||||
|
{
|
||||||
|
m_method = method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] Handle(string path, Stream request)
|
||||||
|
{
|
||||||
|
//Encoding encoding = Encoding.UTF8;
|
||||||
|
//StreamReader streamReader = new StreamReader(request, false);
|
||||||
|
|
||||||
|
//string requestBody = streamReader.ReadToEnd();
|
||||||
|
//streamReader.Close();
|
||||||
|
|
||||||
|
Hashtable hash = (Hashtable)LLSD.LLSDDeserialize( request );
|
||||||
|
TRequest llsdRequest = new TRequest();
|
||||||
|
LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest);
|
||||||
|
|
||||||
|
TResponse response = m_method(llsdRequest);
|
||||||
|
|
||||||
|
Encoding encoding = new UTF8Encoding(false);
|
||||||
|
|
||||||
|
return encoding.GetBytes( LLSDHelpers.SerialiseLLSDReply(response) );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
namespace OpenSim.Region.Capabilities
|
||||||
|
{
|
||||||
|
[LLSDType("MAP")]
|
||||||
|
public class LLSDTest
|
||||||
|
{
|
||||||
|
public int Test1 = 20;
|
||||||
|
public int Test2 = 10;
|
||||||
|
|
||||||
|
public LLSDTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Capabilities
|
||||||
|
{
|
||||||
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
|
public class LLSDType : Attribute
|
||||||
|
{
|
||||||
|
protected string myType;
|
||||||
|
|
||||||
|
public LLSDType(string type)
|
||||||
|
{
|
||||||
|
myType = type;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ObjectType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return myType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
|
public class LLSDMap : LLSDType
|
||||||
|
{
|
||||||
|
public LLSDMap() : base( "MAP" )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
|
||||||
|
using libsecondlife;
|
||||||
|
using libsecondlife.Packets;
|
||||||
|
using OpenSim.Framework.Data;
|
||||||
|
using OpenSim.Framework.Interfaces;
|
||||||
|
using OpenSim.Framework.Types;
|
||||||
|
using OpenSim.Framework.Servers;
|
||||||
|
using OpenSim.Framework.Communications.Caches;
|
||||||
|
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Communications
|
||||||
|
{
|
||||||
|
|
||||||
|
public class CommunicationsManager
|
||||||
|
{
|
||||||
|
public IUserServices UserServer;
|
||||||
|
public IGridServices GridServer;
|
||||||
|
public IInventoryServices InventoryServer;
|
||||||
|
public IInterRegionCommunications InterRegion;
|
||||||
|
public UserProfileCache UserProfiles;
|
||||||
|
public AssetTransactionManager TransactionsManager;
|
||||||
|
public AssetCache AssetCache;
|
||||||
|
|
||||||
|
public NetworkServersInfo ServersInfo;
|
||||||
|
public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache)
|
||||||
|
{
|
||||||
|
ServersInfo = serversInfo;
|
||||||
|
this.AssetCache = assetCache;
|
||||||
|
UserProfiles = new UserProfileCache(this);
|
||||||
|
TransactionsManager = new AssetTransactionManager(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Packet Handlers
|
||||||
|
public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client)
|
||||||
|
{
|
||||||
|
if (uuid == UserProfiles.libraryRoot.agentID)
|
||||||
|
{
|
||||||
|
remote_client.SendNameReply(uuid , "Mr" , "OpenSim");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UserProfileData profileData = this.UserServer.GetUserProfile(uuid);
|
||||||
|
if (profileData != null)
|
||||||
|
{
|
||||||
|
LLUUID profileId = profileData.UUID;
|
||||||
|
string firstname = profileData.username;
|
||||||
|
string lastname = profileData.surname;
|
||||||
|
|
||||||
|
remote_client.SendNameReply(profileId, firstname, lastname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 OpenSim.Framework.Types;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Communications
|
||||||
|
{
|
||||||
|
public interface IGridServices
|
||||||
|
{
|
||||||
|
RegionCommsListener RegisterRegion(RegionInfo regionInfos);
|
||||||
|
List<RegionInfo> RequestNeighbours(RegionInfo regionInfo);
|
||||||
|
RegionInfo RequestNeighbourInfo(ulong regionHandle);
|
||||||
|
List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
using OpenSim.Framework.Types;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Communications
|
||||||
|
{
|
||||||
|
public interface IInterRegionCommunications
|
||||||
|
{
|
||||||
|
bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData);
|
||||||
|
bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying);
|
||||||
|
bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentID);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using OpenSim.Framework.Data;
|
||||||
|
using libsecondlife;
|
||||||
|
using OpenSim.Framework.Communications.Caches;
|
||||||
|
using InventoryFolder = OpenSim.Framework.Communications.Caches.InventoryFolder;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Communications
|
||||||
|
{
|
||||||
|
public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolder folderInfo);
|
||||||
|
public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo);
|
||||||
|
|
||||||
|
public interface IInventoryServices
|
||||||
|
{
|
||||||
|
void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack);
|
||||||
|
void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder);
|
||||||
|
void AddNewInventoryItem(LLUUID userID, InventoryItemBase item);
|
||||||
|
void DeleteInventoryItem(LLUUID userID, InventoryItemBase item);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
using OpenSim.Framework.Data;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Communications
|
||||||
|
{
|
||||||
|
public interface IUserServices
|
||||||
|
{
|
||||||
|
UserProfileData GetUserProfile(string firstName, string lastName);
|
||||||
|
UserProfileData GetUserProfile(string name);
|
||||||
|
UserProfileData GetUserProfile(LLUUID avatarID);
|
||||||
|
void clearUserAgent(LLUUID avatarID);
|
||||||
|
|
||||||
|
UserProfileData SetupMasterUser(string firstName, string lastName);
|
||||||
|
UserProfileData SetupMasterUser(string firstName, string lastName, string password);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("OpenGrid.Framework.Communications")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("OpenGrid.Framework.Communications")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2007")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("13e7c396-78a9-4a5c-baf2-6f980ea75d95")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,89 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using OpenSim.Framework.Configuration.Interfaces;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Configuration.HTTP
|
||||||
|
{
|
||||||
|
public class HTTPConfiguration : IGenericConfig
|
||||||
|
{
|
||||||
|
RemoteConfigSettings remoteConfigSettings;
|
||||||
|
|
||||||
|
XmlConfiguration xmlConfig;
|
||||||
|
|
||||||
|
private string configFileName = "";
|
||||||
|
|
||||||
|
public HTTPConfiguration()
|
||||||
|
{
|
||||||
|
remoteConfigSettings = new RemoteConfigSettings("remoteconfig.xml");
|
||||||
|
xmlConfig = new XmlConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetFileName(string fileName)
|
||||||
|
{
|
||||||
|
configFileName = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
byte[] buf = new byte[8192];
|
||||||
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.remoteConfigSettings.baseConfigURL + this.configFileName);
|
||||||
|
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||||
|
|
||||||
|
Stream resStream = response.GetResponseStream();
|
||||||
|
|
||||||
|
string tempString = null;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
count = resStream.Read(buf, 0, buf.Length);
|
||||||
|
if (count != 0)
|
||||||
|
{
|
||||||
|
tempString = Encoding.ASCII.GetString(buf, 0, count);
|
||||||
|
sb.Append(tempString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (count > 0);
|
||||||
|
LoadDataFromString(sb.ToString());
|
||||||
|
}
|
||||||
|
catch (WebException)
|
||||||
|
{
|
||||||
|
Console.MainLog.Instance.Warn("Unable to connect to remote configuration file (" + remoteConfigSettings.baseConfigURL + configFileName + "). Creating local file instead.");
|
||||||
|
xmlConfig.SetFileName(configFileName);
|
||||||
|
xmlConfig.LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadDataFromString(string data)
|
||||||
|
{
|
||||||
|
xmlConfig.LoadDataFromString(data);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetAttribute(string attributeName)
|
||||||
|
{
|
||||||
|
return xmlConfig.GetAttribute(attributeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SetAttribute(string attributeName, string attributeValue)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Commit()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using OpenSim.Framework.Configuration;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Configuration.HTTP
|
||||||
|
{
|
||||||
|
public class RemoteConfigSettings
|
||||||
|
{
|
||||||
|
private ConfigurationMember configMember;
|
||||||
|
|
||||||
|
public string baseConfigURL = "";
|
||||||
|
public RemoteConfigSettings(string filename)
|
||||||
|
{
|
||||||
|
configMember = new ConfigurationMember(filename, "REMOTE CONFIG SETTINGS", loadConfigurationOptions, handleIncomingConfiguration);
|
||||||
|
configMember.forceConfigurationPluginLibrary("OpenSim.Framework.Configuration.XML.dll");
|
||||||
|
configMember.performConfigurationRetrieve();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadConfigurationOptions()
|
||||||
|
{
|
||||||
|
configMember.addConfigurationOption("base_config_url", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "URL Containing Configuration Files", "http://localhost/", false);
|
||||||
|
}
|
||||||
|
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
|
||||||
|
{
|
||||||
|
if (configuration_key == "base_config_url")
|
||||||
|
{
|
||||||
|
baseConfigURL = (string)configuration_result;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,139 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
|
using OpenSim.Framework.Interfaces;
|
||||||
|
using OpenSim.Framework.Configuration.Interfaces;
|
||||||
|
using OpenSim.Framework.Utilities;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Configuration
|
||||||
|
{
|
||||||
|
public class XmlConfiguration : IGenericConfig
|
||||||
|
{
|
||||||
|
private XmlDocument doc;
|
||||||
|
private XmlNode rootNode;
|
||||||
|
private XmlNode configNode;
|
||||||
|
private string fileName;
|
||||||
|
private bool createdFile = false;
|
||||||
|
|
||||||
|
public void SetFileName(string file)
|
||||||
|
{
|
||||||
|
fileName = file;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadDataToClass()
|
||||||
|
{
|
||||||
|
rootNode = doc.FirstChild;
|
||||||
|
if (rootNode.Name != "Root")
|
||||||
|
throw new Exception("Error: Invalid .xml File. Missing <Root>");
|
||||||
|
|
||||||
|
configNode = rootNode.FirstChild;
|
||||||
|
if (configNode.Name != "Config")
|
||||||
|
throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>");
|
||||||
|
}
|
||||||
|
public void LoadData()
|
||||||
|
{
|
||||||
|
doc = new XmlDocument();
|
||||||
|
if (File.Exists(fileName))
|
||||||
|
{
|
||||||
|
XmlTextReader reader = new XmlTextReader(fileName);
|
||||||
|
reader.WhitespaceHandling = WhitespaceHandling.None;
|
||||||
|
doc.Load(reader);
|
||||||
|
reader.Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
createdFile = true;
|
||||||
|
rootNode = doc.CreateNode(XmlNodeType.Element, "Root", "");
|
||||||
|
doc.AppendChild(rootNode);
|
||||||
|
configNode = doc.CreateNode(XmlNodeType.Element, "Config", "");
|
||||||
|
rootNode.AppendChild(configNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadDataToClass();
|
||||||
|
|
||||||
|
if (createdFile)
|
||||||
|
{
|
||||||
|
this.Commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadDataFromString(string data)
|
||||||
|
{
|
||||||
|
doc = new XmlDocument();
|
||||||
|
doc.LoadXml(data);
|
||||||
|
|
||||||
|
LoadDataToClass();
|
||||||
|
}
|
||||||
|
public string GetAttribute(string attributeName)
|
||||||
|
{
|
||||||
|
string result = null;
|
||||||
|
if (configNode.Attributes[attributeName] != null)
|
||||||
|
{
|
||||||
|
result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SetAttribute(string attributeName, string attributeValue)
|
||||||
|
{
|
||||||
|
if (configNode.Attributes[attributeName] != null)
|
||||||
|
{
|
||||||
|
((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XmlAttribute attri;
|
||||||
|
attri = doc.CreateAttribute(attributeName);
|
||||||
|
attri.Value = attributeValue;
|
||||||
|
configNode.Attributes.Append(attri);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Commit()
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(Util.configDir()))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(Util.configDir());
|
||||||
|
}
|
||||||
|
|
||||||
|
doc.Save(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
configNode = null;
|
||||||
|
rootNode = null;
|
||||||
|
doc = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
// Information about this assembly is defined by the following
|
||||||
|
// attributes.
|
||||||
|
//
|
||||||
|
// change them to the information which is associated with the assembly
|
||||||
|
// you compile.
|
||||||
|
|
||||||
|
[assembly: AssemblyTitle("ServerConsole")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("ServerConsole")]
|
||||||
|
[assembly: AssemblyCopyright("")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// This sets the default COM visibility of types in the assembly to invisible.
|
||||||
|
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The assembly version has following format :
|
||||||
|
//
|
||||||
|
// Major.Minor.Build.Revision
|
||||||
|
//
|
||||||
|
// You can specify all values by your own or you can build default build and revision
|
||||||
|
// numbers with the '*' character (the default):
|
||||||
|
|
||||||
|
[assembly: AssemblyVersion("1.0.*")]
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
namespace OpenSim.Framework.Console
|
||||||
|
{
|
||||||
|
public interface conscmd_callback
|
||||||
|
{
|
||||||
|
void RunCmd(string cmd, string[] cmdparams);
|
||||||
|
void Show(string ShowWhat);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,463 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Console
|
||||||
|
{
|
||||||
|
public enum LogPriority : int
|
||||||
|
{
|
||||||
|
CRITICAL,
|
||||||
|
HIGH,
|
||||||
|
MEDIUM,
|
||||||
|
NORMAL,
|
||||||
|
LOW,
|
||||||
|
VERBOSE,
|
||||||
|
EXTRAVERBOSE
|
||||||
|
}
|
||||||
|
|
||||||
|
public class LogBase
|
||||||
|
{
|
||||||
|
StreamWriter Log;
|
||||||
|
public conscmd_callback cmdparser;
|
||||||
|
public string componentname;
|
||||||
|
private bool m_silent;
|
||||||
|
|
||||||
|
public LogBase(string LogFile, string componentname, conscmd_callback cmdparser, bool silent)
|
||||||
|
{
|
||||||
|
this.componentname = componentname;
|
||||||
|
this.cmdparser = cmdparser;
|
||||||
|
this.m_silent = silent;
|
||||||
|
System.Console.WriteLine("Creating new local console");
|
||||||
|
|
||||||
|
if (String.IsNullOrEmpty(LogFile))
|
||||||
|
{
|
||||||
|
LogFile = componentname + ".log";
|
||||||
|
}
|
||||||
|
|
||||||
|
System.Console.WriteLine("Logs will be saved to current directory in " + LogFile);
|
||||||
|
|
||||||
|
Log = File.AppendText(LogFile);
|
||||||
|
Log.WriteLine("========================================================================");
|
||||||
|
Log.WriteLine(componentname + " Started at " + DateTime.Now.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
Log.WriteLine("Shutdown at " + DateTime.Now.ToString());
|
||||||
|
Log.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Obsolete("Log.WriteLine is obsolete, use Warn / Error / Verbose instead.")]
|
||||||
|
public void Write(string format, params object[] args)
|
||||||
|
{
|
||||||
|
// HOUSEKEEPING : Will remove once use is removed.
|
||||||
|
Notice(format, args);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Obsolete("Log.WriteLine is obsolete, use Warn / Error / Verbose instead.")]
|
||||||
|
public void WriteLine(LogPriority importance, string format, params object[] args)
|
||||||
|
{
|
||||||
|
// HOUSEKEEPING : Will remove once use is removed.
|
||||||
|
Log.WriteLine(format, args);
|
||||||
|
Log.Flush();
|
||||||
|
if (!m_silent)
|
||||||
|
{
|
||||||
|
System.Console.WriteLine(format, args);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// derive an ansi color from a string, ignoring the darker colors.
|
||||||
|
/// This is used to help automatically bin component tags with colors
|
||||||
|
/// in various print functions.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">arbitrary string for input</param>
|
||||||
|
/// <returns>an ansii color</returns>
|
||||||
|
private ConsoleColor DeriveColor(string input)
|
||||||
|
{
|
||||||
|
int colIdx = (input.ToUpper().GetHashCode() % 6) + 9;
|
||||||
|
return (ConsoleColor)colIdx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends a warning to the current log output
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="format">The message to send</param>
|
||||||
|
/// <param name="args">WriteLine-style message arguments</param>
|
||||||
|
public void Warn(string format, params object[] args)
|
||||||
|
{
|
||||||
|
WriteNewLine(ConsoleColor.Yellow, format, args);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends a warning to the current log output
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The module that sent this message</param>
|
||||||
|
/// <param name="format">The message to send</param>
|
||||||
|
/// <param name="args">WriteLine-style message arguments</param>
|
||||||
|
public void Warn(string sender, string format, params object[] args)
|
||||||
|
{
|
||||||
|
WritePrefixLine(DeriveColor(sender), sender);
|
||||||
|
WriteNewLine(ConsoleColor.Yellow, format, args);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends a notice to the current log output
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="format">The message to send</param>
|
||||||
|
/// <param name="args">WriteLine-style message arguments</param>
|
||||||
|
public void Notice(string format, params object[] args)
|
||||||
|
{
|
||||||
|
WriteNewLine(ConsoleColor.White, format, args);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends a notice to the current log output
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The module that sent this message</param>
|
||||||
|
/// <param name="format">The message to send</param>
|
||||||
|
/// <param name="args">WriteLine-style message arguments</param>
|
||||||
|
public void Notice(string sender, string format, params object[] args)
|
||||||
|
{
|
||||||
|
WritePrefixLine(DeriveColor(sender), sender);
|
||||||
|
WriteNewLine(ConsoleColor.White, format, args);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends an error to the current log output
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="format">The message to send</param>
|
||||||
|
/// <param name="args">WriteLine-style message arguments</param>
|
||||||
|
public void Error(string format, params object[] args)
|
||||||
|
{
|
||||||
|
WriteNewLine(ConsoleColor.Red, format, args);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends an error to the current log output
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The module that sent this message</param>
|
||||||
|
/// <param name="format">The message to send</param>
|
||||||
|
/// <param name="args">WriteLine-style message arguments</param>
|
||||||
|
public void Error(string sender, string format, params object[] args)
|
||||||
|
{
|
||||||
|
WritePrefixLine(DeriveColor(sender), sender);
|
||||||
|
Error( format, args);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends a informational message to the current log output
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="format">The message to send</param>
|
||||||
|
/// <param name="args">WriteLine-style message arguments</param>
|
||||||
|
public void Verbose(string format, params object[] args)
|
||||||
|
{
|
||||||
|
WriteNewLine(ConsoleColor.Gray, format, args);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends an informational message to the current log output
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The module that sent this message</param>
|
||||||
|
/// <param name="format">The message to send</param>
|
||||||
|
/// <param name="args">WriteLine-style message arguments</param>
|
||||||
|
public void Verbose(string sender, string format, params object[] args)
|
||||||
|
{
|
||||||
|
WritePrefixLine(DeriveColor(sender), sender);
|
||||||
|
WriteNewLine(ConsoleColor.Gray, format, args);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends a status message to the current log output
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="format">The message to send</param>
|
||||||
|
/// <param name="args">WriteLine-style message arguments</param>
|
||||||
|
public void Status(string format, params object[] args)
|
||||||
|
{
|
||||||
|
WriteNewLine(ConsoleColor.Blue, format, args);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends a status message to the current log output
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The module that sent this message</param>
|
||||||
|
/// <param name="format">The message to send</param>
|
||||||
|
/// <param name="args">WriteLine-style message arguments</param>
|
||||||
|
public void Status(string sender, string format, params object[] args)
|
||||||
|
{
|
||||||
|
WritePrefixLine(DeriveColor(sender), sender);
|
||||||
|
WriteNewLine(ConsoleColor.Blue, format, args);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void WriteNewLine(ConsoleColor color, string format, params object[] args)
|
||||||
|
{
|
||||||
|
Log.WriteLine(format, args);
|
||||||
|
Log.Flush();
|
||||||
|
if (!m_silent)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (color != ConsoleColor.White)
|
||||||
|
System.Console.ForegroundColor = color;
|
||||||
|
|
||||||
|
System.Console.WriteLine(format, args);
|
||||||
|
System.Console.ResetColor();
|
||||||
|
}
|
||||||
|
catch (ArgumentNullException)
|
||||||
|
{
|
||||||
|
// Some older systems dont support coloured text.
|
||||||
|
System.Console.WriteLine(format, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WritePrefixLine(ConsoleColor color, string sender)
|
||||||
|
{
|
||||||
|
sender = sender.ToUpper();
|
||||||
|
Log.WriteLine("[" + sender + "] ");
|
||||||
|
Log.Flush();
|
||||||
|
|
||||||
|
System.Console.Write("[");
|
||||||
|
|
||||||
|
if (!m_silent)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
System.Console.ForegroundColor = color;
|
||||||
|
System.Console.Write(sender);
|
||||||
|
System.Console.ResetColor();
|
||||||
|
}
|
||||||
|
catch (ArgumentNullException)
|
||||||
|
{
|
||||||
|
// Some older systems dont support coloured text.
|
||||||
|
System.Console.WriteLine(sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
System.Console.Write("] \t");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string ReadLine()
|
||||||
|
{
|
||||||
|
string TempStr = System.Console.ReadLine();
|
||||||
|
Log.WriteLine(TempStr);
|
||||||
|
return TempStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Read()
|
||||||
|
{
|
||||||
|
int TempInt = System.Console.Read();
|
||||||
|
Log.Write((char)TempInt);
|
||||||
|
return TempInt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPAddress CmdPromptIPAddress(string prompt, string defaultvalue)
|
||||||
|
{
|
||||||
|
IPAddress address;
|
||||||
|
string addressStr;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
addressStr = MainLog.Instance.CmdPrompt(prompt, defaultvalue);
|
||||||
|
if (IPAddress.TryParse(addressStr, out address))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MainLog.Instance.Error("Illegal address. Please re-enter.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CmdPromptIPPort(string prompt, string defaultvalue)
|
||||||
|
{
|
||||||
|
int port;
|
||||||
|
string portStr;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
portStr = MainLog.Instance.CmdPrompt(prompt, defaultvalue);
|
||||||
|
if (int.TryParse(portStr, out port))
|
||||||
|
{
|
||||||
|
if (port >= IPEndPoint.MinPort && port <= IPEndPoint.MaxPort)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MainLog.Instance.Error("Illegal address. Please re-enter.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Displays a prompt and waits for the user to enter a string, then returns that string
|
||||||
|
// Done with no echo and suitable for passwords
|
||||||
|
public string PasswdPrompt(string prompt)
|
||||||
|
{
|
||||||
|
// FIXME: Needs to be better abstracted
|
||||||
|
Log.WriteLine(prompt);
|
||||||
|
this.Notice(prompt);
|
||||||
|
ConsoleColor oldfg = System.Console.ForegroundColor;
|
||||||
|
System.Console.ForegroundColor = System.Console.BackgroundColor;
|
||||||
|
string temp = System.Console.ReadLine();
|
||||||
|
System.Console.ForegroundColor = oldfg;
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Displays a command prompt and waits for the user to enter a string, then returns that string
|
||||||
|
public string CmdPrompt(string prompt)
|
||||||
|
{
|
||||||
|
this.Notice(String.Format("{0}: ", prompt));
|
||||||
|
return this.ReadLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Displays a command prompt and returns a default value if the user simply presses enter
|
||||||
|
public string CmdPrompt(string prompt, string defaultresponse)
|
||||||
|
{
|
||||||
|
string temp = CmdPrompt(String.Format("{0} [{1}]", prompt, defaultresponse));
|
||||||
|
if (temp == "")
|
||||||
|
{
|
||||||
|
return defaultresponse;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Displays a command prompt and returns a default value, user may only enter 1 of 2 options
|
||||||
|
public string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB)
|
||||||
|
{
|
||||||
|
bool itisdone = false;
|
||||||
|
string temp = CmdPrompt(prompt, defaultresponse);
|
||||||
|
while (itisdone == false)
|
||||||
|
{
|
||||||
|
if ((temp == OptionA) || (temp == OptionB))
|
||||||
|
{
|
||||||
|
itisdone = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Notice("Valid options are " + OptionA + " or " + OptionB);
|
||||||
|
temp = CmdPrompt(prompt, defaultresponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Runs a command with a number of parameters
|
||||||
|
public Object RunCmd(string Cmd, string[] cmdparams)
|
||||||
|
{
|
||||||
|
cmdparser.RunCmd(Cmd, cmdparams);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shows data about something
|
||||||
|
public void ShowCommands(string ShowWhat)
|
||||||
|
{
|
||||||
|
cmdparser.Show(ShowWhat);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MainLogPrompt()
|
||||||
|
{
|
||||||
|
|
||||||
|
string tempstr = this.CmdPrompt(this.componentname + "# ");
|
||||||
|
MainLogRunCommand(tempstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MainLogRunCommand(string command)
|
||||||
|
{
|
||||||
|
string[] tempstrarray;
|
||||||
|
tempstrarray = command.Split(' ');
|
||||||
|
string cmd = tempstrarray[0];
|
||||||
|
Array.Reverse(tempstrarray);
|
||||||
|
Array.Resize<string>(ref tempstrarray, tempstrarray.Length - 1);
|
||||||
|
Array.Reverse(tempstrarray);
|
||||||
|
string[] cmdparams = (string[])tempstrarray;
|
||||||
|
RunCmd(cmd, cmdparams);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string LineInfo
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
string result = String.Empty;
|
||||||
|
|
||||||
|
string stacktrace = Environment.StackTrace;
|
||||||
|
List<string> lines = new List<string>(stacktrace.Split(new string[] { "at " }, StringSplitOptions.None));
|
||||||
|
|
||||||
|
if (lines.Count > 4)
|
||||||
|
{
|
||||||
|
lines.RemoveRange(0, 4);
|
||||||
|
|
||||||
|
string tmpLine = lines[0];
|
||||||
|
|
||||||
|
int inIndex = tmpLine.IndexOf(" in ");
|
||||||
|
|
||||||
|
if (inIndex > -1)
|
||||||
|
{
|
||||||
|
result = tmpLine.Substring(0, inIndex);
|
||||||
|
|
||||||
|
int lineIndex = tmpLine.IndexOf(":line ");
|
||||||
|
|
||||||
|
if (lineIndex > -1)
|
||||||
|
{
|
||||||
|
lineIndex += 6;
|
||||||
|
result += ", line " + tmpLine.Substring(lineIndex, (tmpLine.Length - lineIndex) - 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
namespace OpenSim.Framework.Console
|
||||||
|
{
|
||||||
|
public class MainLog {
|
||||||
|
|
||||||
|
private static LogBase instance;
|
||||||
|
|
||||||
|
public static LogBase Instance
|
||||||
|
{
|
||||||
|
get { return instance; }
|
||||||
|
set { instance = value; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,162 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data.DB4o
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A grid server storage mechanism employing the DB4o database system
|
||||||
|
/// </summary>
|
||||||
|
class DB4oGridData : IGridData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The database manager object
|
||||||
|
/// </summary>
|
||||||
|
DB4oGridManager manager;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the plugin is first loaded (as constructors are not called)
|
||||||
|
/// </summary>
|
||||||
|
public void Initialise() {
|
||||||
|
manager = new DB4oGridManager("gridserver.yap");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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>
|
||||||
|
public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a region located at the specified regionHandle (warning multiple regions may occupy the one spot, first found is returned)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="handle">The handle to search for</param>
|
||||||
|
/// <returns>A region profile</returns>
|
||||||
|
public SimProfileData GetProfileByHandle(ulong handle) {
|
||||||
|
lock (manager.simProfiles)
|
||||||
|
{
|
||||||
|
foreach (LLUUID UUID in manager.simProfiles.Keys)
|
||||||
|
{
|
||||||
|
if (manager.simProfiles[UUID].regionHandle == handle)
|
||||||
|
{
|
||||||
|
return manager.simProfiles[UUID];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Exception("Unable to find profile with handle (" + handle.ToString() + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a specific region
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uuid">The region ID code</param>
|
||||||
|
/// <returns>A region profile</returns>
|
||||||
|
public SimProfileData GetProfileByLLUUID(LLUUID uuid)
|
||||||
|
{
|
||||||
|
lock (manager.simProfiles)
|
||||||
|
{
|
||||||
|
if (manager.simProfiles.ContainsKey(uuid))
|
||||||
|
return manager.simProfiles[uuid];
|
||||||
|
}
|
||||||
|
throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + "). Total Registered Regions: " + manager.simProfiles.Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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>
|
||||||
|
public DataResponse AddProfile(SimProfileData profile)
|
||||||
|
{
|
||||||
|
lock (manager.simProfiles)
|
||||||
|
{
|
||||||
|
if (manager.AddRow(profile))
|
||||||
|
{
|
||||||
|
return DataResponse.RESPONSE_OK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return DataResponse.RESPONSE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Authenticates a new region using the shared secrets. NOT SECURE.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uuid">The UUID the region is authenticating with</param>
|
||||||
|
/// <param name="handle">The location the region is logging into (unused in Db4o)</param>
|
||||||
|
/// <param name="key">The shared secret</param>
|
||||||
|
/// <returns>Authenticated?</returns>
|
||||||
|
public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) {
|
||||||
|
if (manager.simProfiles[uuid].regionRecvKey == key)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shuts down the database
|
||||||
|
/// </summary>
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
manager = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the providers name
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The name of the storage system</returns>
|
||||||
|
public string getName()
|
||||||
|
{
|
||||||
|
return "DB4o Grid Provider";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the providers version
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The version of the storage system</returns>
|
||||||
|
public string getVersion()
|
||||||
|
{
|
||||||
|
return "0.1";
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReservationData GetReservationAtPoint(uint x, uint y)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,169 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 Db4objects.Db4o;
|
||||||
|
using libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data.DB4o
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A Database manager for Db4o
|
||||||
|
/// </summary>
|
||||||
|
class DB4oGridManager
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A list of the current regions connected (in-memory cache)
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<LLUUID, SimProfileData> simProfiles = new Dictionary<LLUUID, SimProfileData>();
|
||||||
|
/// <summary>
|
||||||
|
/// Database File Name
|
||||||
|
/// </summary>
|
||||||
|
string dbfl;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new grid storage manager
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="db4odb">Filename to the database file</param>
|
||||||
|
public DB4oGridManager(string db4odb)
|
||||||
|
{
|
||||||
|
dbfl = db4odb;
|
||||||
|
IObjectContainer database;
|
||||||
|
database = Db4oFactory.OpenFile(dbfl);
|
||||||
|
IObjectSet result = database.Get(typeof(SimProfileData));
|
||||||
|
// Loads the file into the in-memory cache
|
||||||
|
foreach(SimProfileData row in result) {
|
||||||
|
simProfiles.Add(row.UUID, row);
|
||||||
|
}
|
||||||
|
database.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a new profile to the database (Warning: Probably slow.)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="row">The profile to add</param>
|
||||||
|
/// <returns>Successful?</returns>
|
||||||
|
public bool AddRow(SimProfileData row)
|
||||||
|
{
|
||||||
|
if (simProfiles.ContainsKey(row.UUID))
|
||||||
|
{
|
||||||
|
simProfiles[row.UUID] = row;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
simProfiles.Add(row.UUID, row);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IObjectContainer database;
|
||||||
|
database = Db4oFactory.OpenFile(dbfl);
|
||||||
|
database.Set(row);
|
||||||
|
database.Close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A manager for the DB4o database (user profiles)
|
||||||
|
/// </summary>
|
||||||
|
class DB4oUserManager
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A list of the user profiles (in memory cache)
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<LLUUID, UserProfileData> userProfiles = new Dictionary<LLUUID, UserProfileData>();
|
||||||
|
/// <summary>
|
||||||
|
/// Database filename
|
||||||
|
/// </summary>
|
||||||
|
string dbfl;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialises a new DB manager
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="db4odb">The filename to the database</param>
|
||||||
|
public DB4oUserManager(string db4odb)
|
||||||
|
{
|
||||||
|
dbfl = db4odb;
|
||||||
|
IObjectContainer database;
|
||||||
|
database = Db4oFactory.OpenFile(dbfl);
|
||||||
|
// Load to cache
|
||||||
|
IObjectSet result = database.Get(typeof(UserProfileData));
|
||||||
|
foreach (UserProfileData row in result)
|
||||||
|
{
|
||||||
|
if (userProfiles.ContainsKey(row.UUID))
|
||||||
|
userProfiles[row.UUID] = row;
|
||||||
|
else
|
||||||
|
userProfiles.Add(row.UUID, row);
|
||||||
|
}
|
||||||
|
database.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds or updates a record to the user database. Do this when changes are needed
|
||||||
|
/// in the user profile that need to be persistant.
|
||||||
|
///
|
||||||
|
/// TODO: the logic here is not ACID, the local cache will be
|
||||||
|
/// updated even if the persistant data is not. This may lead
|
||||||
|
/// to unexpected results.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="record">The profile to update</param>
|
||||||
|
/// <returns>true on success, false on fail to persist to db</returns>
|
||||||
|
public bool UpdateRecord(UserProfileData record)
|
||||||
|
{
|
||||||
|
if (userProfiles.ContainsKey(record.UUID))
|
||||||
|
{
|
||||||
|
userProfiles[record.UUID] = record;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
userProfiles.Add(record.UUID, record);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IObjectContainer database;
|
||||||
|
database = Db4oFactory.OpenFile(dbfl);
|
||||||
|
database.Set(record);
|
||||||
|
database.Close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,221 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using libsecondlife;
|
||||||
|
using OpenSim.Framework.Utilities;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data.DB4o
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A User storage interface for the DB4o database system
|
||||||
|
/// </summary>
|
||||||
|
public class DB4oUserData : IUserData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The database manager
|
||||||
|
/// </summary>
|
||||||
|
DB4oUserManager manager;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Artificial constructor called upon plugin load
|
||||||
|
/// </summary>
|
||||||
|
public void Initialise()
|
||||||
|
{
|
||||||
|
manager = new DB4oUserManager(Path.Combine(Util.dataDir(),"userprofiles.yap"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads a specified user profile from a UUID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uuid">The users UUID</param>
|
||||||
|
/// <returns>A user profile</returns>
|
||||||
|
public UserProfileData getUserByUUID(LLUUID uuid)
|
||||||
|
{
|
||||||
|
if(manager.userProfiles.ContainsKey(uuid))
|
||||||
|
return manager.userProfiles[uuid];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a user by searching for its name
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The users account name</param>
|
||||||
|
/// <returns>A matching users profile</returns>
|
||||||
|
public UserProfileData getUserByName(string name)
|
||||||
|
{
|
||||||
|
return getUserByName(name.Split(' ')[0], name.Split(' ')[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a user by searching for its name
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fname">The first part of the users account name</param>
|
||||||
|
/// <param name="lname">The second part of the users account name</param>
|
||||||
|
/// <returns>A matching users profile</returns>
|
||||||
|
public UserProfileData getUserByName(string fname, string lname)
|
||||||
|
{
|
||||||
|
foreach (UserProfileData profile in manager.userProfiles.Values)
|
||||||
|
{
|
||||||
|
if (profile.username == fname && profile.surname == lname)
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a user by UUID direct
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uuid">The users account ID</param>
|
||||||
|
/// <returns>A matching users profile</returns>
|
||||||
|
public UserAgentData getAgentByUUID(LLUUID uuid)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return getUserByUUID(uuid).currentAgent;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a session by account name
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The account name</param>
|
||||||
|
/// <returns>The users session agent</returns>
|
||||||
|
public UserAgentData getAgentByName(string name)
|
||||||
|
{
|
||||||
|
return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a session by account name
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fname">The first part of the users account name</param>
|
||||||
|
/// <param name="lname">The second part of the users account name</param>
|
||||||
|
/// <returns>A user agent</returns>
|
||||||
|
public UserAgentData getAgentByName(string fname, string lname)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return getUserByName(fname,lname).currentAgent;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new user profile
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The profile to add to the database</param>
|
||||||
|
public void addNewUserProfile(UserProfileData user)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
manager.UpdateRecord(user);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new user profile
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The profile to add to the database</param>
|
||||||
|
/// <returns>True on success, false on error</returns>
|
||||||
|
public bool updateUserProfile(UserProfileData user)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return manager.UpdateRecord(user);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new user agent
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="agent">The agent to add to the database</param>
|
||||||
|
public void addNewUserAgent(UserAgentData agent)
|
||||||
|
{
|
||||||
|
// Do nothing. yet.
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Transfers money between two user accounts
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="from">Starting account</param>
|
||||||
|
/// <param name="to">End account</param>
|
||||||
|
/// <param name="amount">The amount to move</param>
|
||||||
|
/// <returns>Success?</returns>
|
||||||
|
public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Transfers inventory between two accounts
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Move to inventory server</remarks>
|
||||||
|
/// <param name="from">Senders account</param>
|
||||||
|
/// <param name="to">Recievers account</param>
|
||||||
|
/// <param name="item">Inventory item</param>
|
||||||
|
/// <returns>Success?</returns>
|
||||||
|
public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the name of the storage provider
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Storage provider name</returns>
|
||||||
|
public string getName()
|
||||||
|
{
|
||||||
|
return "DB4o Userdata";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the version of the storage provider
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Storage provider version</returns>
|
||||||
|
public string getVersion()
|
||||||
|
{
|
||||||
|
return "0.1";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("OpenSim.Framework.Data.DB4o")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("OpenSim.Framework.Data.DB4o")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2007")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("57991e15-79da-41b7-aa06-2e6b49165a63")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,194 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data.MSSQL
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A grid data interface for Microsoft SQL Server
|
||||||
|
/// </summary>
|
||||||
|
public class SqlGridData : IGridData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Database manager
|
||||||
|
/// </summary>
|
||||||
|
private MSSqlManager database;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialises the Grid Interface
|
||||||
|
/// </summary>
|
||||||
|
public void Initialise()
|
||||||
|
{
|
||||||
|
database = new MSSqlManager("localhost", "db", "user", "password", "false");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shuts down the grid interface
|
||||||
|
/// </summary>
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
database.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the storage system name
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string containing the storage system name</returns>
|
||||||
|
public string getName()
|
||||||
|
{
|
||||||
|
return "Sql OpenGridData";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the storage system version
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string containing the storage system version</returns>
|
||||||
|
public string getVersion()
|
||||||
|
{
|
||||||
|
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>
|
||||||
|
public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a sim profile from it's location
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="handle">Region location handle</param>
|
||||||
|
/// <returns>Sim profile</returns>
|
||||||
|
public SimProfileData 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();
|
||||||
|
|
||||||
|
SimProfileData row = database.getRow(reader);
|
||||||
|
reader.Close();
|
||||||
|
result.Dispose();
|
||||||
|
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a sim profile from it's UUID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uuid">The region UUID</param>
|
||||||
|
/// <returns>The sim profile</returns>
|
||||||
|
public SimProfileData GetProfileByLLUUID(LLUUID uuid)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
|
param["uuid"] = uuid.ToStringHyphenated();
|
||||||
|
|
||||||
|
IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = @uuid", param);
|
||||||
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
SimProfileData row = database.getRow(reader);
|
||||||
|
reader.Close();
|
||||||
|
result.Dispose();
|
||||||
|
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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>
|
||||||
|
public DataResponse AddProfile(SimProfileData profile)
|
||||||
|
{
|
||||||
|
if (database.insertRow(profile))
|
||||||
|
{
|
||||||
|
return DataResponse.RESPONSE_OK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return DataResponse.RESPONSE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DEPRECIATED. 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>
|
||||||
|
public bool AuthenticateSim(LLUUID 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.");
|
||||||
|
|
||||||
|
SimProfileData data = GetProfileByLLUUID(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(LLUUID uuid, ulong handle, string authhash, string challenge)
|
||||||
|
{
|
||||||
|
SHA512Managed HashProvider = new SHA512Managed();
|
||||||
|
ASCIIEncoding TextProvider = new ASCIIEncoding();
|
||||||
|
|
||||||
|
byte[] stream = TextProvider.GetBytes(uuid.ToStringHyphenated() + ":" + handle.ToString() + ":" + challenge);
|
||||||
|
byte[] hash = HashProvider.ComputeHash(stream);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public ReservationData GetReservationAtPoint(uint x, uint y)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,211 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data.MSSQL
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A management class for the MS SQL Storage Engine
|
||||||
|
/// </summary>
|
||||||
|
class MSSqlManager
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The database connection object
|
||||||
|
/// </summary>
|
||||||
|
IDbConnection dbcon;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialises and creates a new Sql connection and maintains it.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hostname">The Sql server being connected to</param>
|
||||||
|
/// <param name="database">The name of the Sql database being used</param>
|
||||||
|
/// <param name="username">The username logging into the database</param>
|
||||||
|
/// <param name="password">The password for the user logging in</param>
|
||||||
|
/// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param>
|
||||||
|
public MSSqlManager(string hostname, string database, string username, string password, string cpooling)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string connectionString = "Server=" + hostname + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";";
|
||||||
|
dbcon = new SqlConnection(connectionString);
|
||||||
|
|
||||||
|
dbcon.Open();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new Exception("Error initialising Sql 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 Sql DB Command</returns>
|
||||||
|
public IDbCommand Query(string sql, Dictionary<string, string> parameters)
|
||||||
|
{
|
||||||
|
SqlCommand dbcommand = (SqlCommand)dbcon.CreateCommand();
|
||||||
|
dbcommand.CommandText = sql;
|
||||||
|
foreach (KeyValuePair<string, string> param in parameters)
|
||||||
|
{
|
||||||
|
dbcommand.Parameters.AddWithValue(param.Key, param.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (IDbCommand)dbcommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Runs a database reader object and returns a region row
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reader">An active database reader</param>
|
||||||
|
/// <returns>A region row</returns>
|
||||||
|
public SimProfileData getRow(IDataReader reader)
|
||||||
|
{
|
||||||
|
SimProfileData regionprofile = new SimProfileData();
|
||||||
|
|
||||||
|
if (reader.Read())
|
||||||
|
{
|
||||||
|
// Region Main
|
||||||
|
regionprofile.regionHandle = (ulong)reader["regionHandle"];
|
||||||
|
regionprofile.regionName = (string)reader["regionName"];
|
||||||
|
regionprofile.UUID = new LLUUID((string)reader["uuid"]);
|
||||||
|
|
||||||
|
// Secrets
|
||||||
|
regionprofile.regionRecvKey = (string)reader["regionRecvKey"];
|
||||||
|
regionprofile.regionSecret = (string)reader["regionSecret"];
|
||||||
|
regionprofile.regionSendKey = (string)reader["regionSendKey"];
|
||||||
|
|
||||||
|
// Region Server
|
||||||
|
regionprofile.regionDataURI = (string)reader["regionDataURI"];
|
||||||
|
regionprofile.regionOnline = false; // Needs to be pinged before this can be set.
|
||||||
|
regionprofile.serverIP = (string)reader["serverIP"];
|
||||||
|
regionprofile.serverPort = (uint)reader["serverPort"];
|
||||||
|
regionprofile.serverURI = (string)reader["serverURI"];
|
||||||
|
|
||||||
|
// Location
|
||||||
|
regionprofile.regionLocX = (uint)((int)reader["locX"]);
|
||||||
|
regionprofile.regionLocY = (uint)((int)reader["locY"]);
|
||||||
|
regionprofile.regionLocZ = (uint)((int)reader["locZ"]);
|
||||||
|
|
||||||
|
// Neighbours - 0 = No Override
|
||||||
|
regionprofile.regionEastOverrideHandle = (ulong)reader["eastOverrideHandle"];
|
||||||
|
regionprofile.regionWestOverrideHandle = (ulong)reader["westOverrideHandle"];
|
||||||
|
regionprofile.regionSouthOverrideHandle = (ulong)reader["southOverrideHandle"];
|
||||||
|
regionprofile.regionNorthOverrideHandle = (ulong)reader["northOverrideHandle"];
|
||||||
|
|
||||||
|
// Assets
|
||||||
|
regionprofile.regionAssetURI = (string)reader["regionAssetURI"];
|
||||||
|
regionprofile.regionAssetRecvKey = (string)reader["regionAssetRecvKey"];
|
||||||
|
regionprofile.regionAssetSendKey = (string)reader["regionAssetSendKey"];
|
||||||
|
|
||||||
|
// Userserver
|
||||||
|
regionprofile.regionUserURI = (string)reader["regionUserURI"];
|
||||||
|
regionprofile.regionUserRecvKey = (string)reader["regionUserRecvKey"];
|
||||||
|
regionprofile.regionUserSendKey = (string)reader["regionUserSendKey"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("No rows to return");
|
||||||
|
}
|
||||||
|
return regionprofile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new region in the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="profile">The region profile to insert</param>
|
||||||
|
/// <returns>Successful?</returns>
|
||||||
|
public bool insertRow(SimProfileData 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("OpenSim.Framework.Data.MSSQL")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("OpenSim.Framework.Data.MSSQL")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2007")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("0e1c1ca4-2cf2-4315-b0e7-432c02feea8a")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,287 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data.MySQL
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A MySQL Interface for the Grid Server
|
||||||
|
/// </summary>
|
||||||
|
public class MySQLGridData : IGridData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// MySQL Database Manager
|
||||||
|
/// </summary>
|
||||||
|
private MySQLManager database;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialises the Grid Interface
|
||||||
|
/// </summary>
|
||||||
|
public void Initialise()
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shuts down the grid interface
|
||||||
|
/// </summary>
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
database.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the plugin name
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Plugin name</returns>
|
||||||
|
public string getName()
|
||||||
|
{
|
||||||
|
return "MySql OpenGridData";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the plugin version
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Plugin version</returns>
|
||||||
|
public string getVersion()
|
||||||
|
{
|
||||||
|
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></returns>
|
||||||
|
public SimProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (database)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
|
param["?xmin"] = xmin.ToString();
|
||||||
|
param["?ymin"] = ymin.ToString();
|
||||||
|
param["?xmax"] = xmax.ToString();
|
||||||
|
param["?ymax"] = ymax.ToString();
|
||||||
|
|
||||||
|
IDbCommand result = database.Query("SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", param);
|
||||||
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
SimProfileData row;
|
||||||
|
|
||||||
|
List<SimProfileData> rows = new List<SimProfileData>();
|
||||||
|
|
||||||
|
while ((row = database.readSimRow(reader)) != null)
|
||||||
|
{
|
||||||
|
rows.Add(row);
|
||||||
|
}
|
||||||
|
reader.Close();
|
||||||
|
result.Dispose();
|
||||||
|
|
||||||
|
return rows.ToArray();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
database.Reconnect();
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a sim profile from it's location
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="handle">Region location handle</param>
|
||||||
|
/// <returns>Sim profile</returns>
|
||||||
|
public SimProfileData GetProfileByHandle(ulong handle)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (database)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
|
param["?handle"] = handle.ToString();
|
||||||
|
|
||||||
|
IDbCommand result = database.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param);
|
||||||
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
SimProfileData row = database.readSimRow(reader);
|
||||||
|
reader.Close();
|
||||||
|
result.Dispose();
|
||||||
|
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
database.Reconnect();
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a sim profile from it's UUID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uuid">The region UUID</param>
|
||||||
|
/// <returns>The sim profile</returns>
|
||||||
|
public SimProfileData GetProfileByLLUUID(LLUUID uuid)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (database)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
|
param["?uuid"] = uuid.ToStringHyphenated();
|
||||||
|
|
||||||
|
IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = ?uuid", param);
|
||||||
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
SimProfileData row = database.readSimRow(reader);
|
||||||
|
reader.Close();
|
||||||
|
result.Dispose();
|
||||||
|
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
database.Reconnect();
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a new profile to the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="profile">The profile to add</param>
|
||||||
|
/// <returns>Successful?</returns>
|
||||||
|
public DataResponse AddProfile(SimProfileData profile)
|
||||||
|
{
|
||||||
|
lock (database)
|
||||||
|
{
|
||||||
|
if (database.insertRegion(profile))
|
||||||
|
{
|
||||||
|
return DataResponse.RESPONSE_OK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return DataResponse.RESPONSE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DEPRECIATED. 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>
|
||||||
|
public bool AuthenticateSim(LLUUID 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.");
|
||||||
|
|
||||||
|
SimProfileData data = GetProfileByLLUUID(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(LLUUID uuid, ulong handle, string authhash, string challenge)
|
||||||
|
{
|
||||||
|
SHA512Managed HashProvider = new SHA512Managed();
|
||||||
|
ASCIIEncoding TextProvider = new ASCIIEncoding();
|
||||||
|
|
||||||
|
byte[] stream = TextProvider.GetBytes(uuid.ToStringHyphenated() + ":" + handle.ToString() + ":" + challenge);
|
||||||
|
byte[] hash = HashProvider.ComputeHash(stream);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReservationData GetReservationAtPoint(uint x, uint y)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (database)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
|
param["?x"] = x.ToString();
|
||||||
|
param["?y"] = y.ToString();
|
||||||
|
IDbCommand result = database.Query("SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", param);
|
||||||
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
ReservationData row = database.readReservationRow(reader);
|
||||||
|
reader.Close();
|
||||||
|
result.Dispose();
|
||||||
|
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
database.Reconnect();
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,352 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data.MySQL
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A MySQL interface for the inventory server
|
||||||
|
/// </summary>
|
||||||
|
class MySQLInventoryData : IInventoryData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The database manager
|
||||||
|
/// </summary>
|
||||||
|
public MySQLManager database;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads and initialises this database plugin
|
||||||
|
/// </summary>
|
||||||
|
public void Initialise()
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The name of this DB provider
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Name of DB provider</returns>
|
||||||
|
public string getName()
|
||||||
|
{
|
||||||
|
return "MySQL Inventory Data Interface";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Closes this DB provider
|
||||||
|
/// </summary>
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the version of this DB provider
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string containing the DB provider</returns>
|
||||||
|
public string getVersion()
|
||||||
|
{
|
||||||
|
return "0.1";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a list of items in a specified folder
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folderID">The folder to search</param>
|
||||||
|
/// <returns>A list containing inventory items</returns>
|
||||||
|
public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (database)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
|
param["?uuid"] = folderID.ToStringHyphenated();
|
||||||
|
|
||||||
|
IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", param);
|
||||||
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
List<InventoryItemBase> items = database.readInventoryItems(reader);
|
||||||
|
|
||||||
|
reader.Close();
|
||||||
|
result.Dispose();
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
database.Reconnect();
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a list of the root folders within a users inventory
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The user whos inventory is to be searched</param>
|
||||||
|
/// <returns>A list of folder objects</returns>
|
||||||
|
public List<InventoryFolderBase> getUserRootFolders(LLUUID user)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (database)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
|
param["?uuid"] = user.ToStringHyphenated();
|
||||||
|
param["?zero"] = LLUUID.Zero.ToStringHyphenated();
|
||||||
|
|
||||||
|
IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", param);
|
||||||
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
List<InventoryFolderBase> items = database.readInventoryFolders(reader);
|
||||||
|
|
||||||
|
reader.Close();
|
||||||
|
result.Dispose();
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
database.Reconnect();
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the users inventory root folder.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public InventoryFolderBase getUserRootFolder(LLUUID user)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (database)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
|
param["?uuid"] = user.ToStringHyphenated();
|
||||||
|
param["?zero"] = LLUUID.Zero.ToStringHyphenated();
|
||||||
|
|
||||||
|
IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", param);
|
||||||
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
List<InventoryFolderBase> items = database.readInventoryFolders(reader);
|
||||||
|
InventoryFolderBase rootFolder = items[0]; //should only be one folder with parent set to zero (the root one).
|
||||||
|
reader.Close();
|
||||||
|
result.Dispose();
|
||||||
|
|
||||||
|
return rootFolder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
database.Reconnect();
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a list of folders in a users inventory contained within the specified folder
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parentID">The folder to search</param>
|
||||||
|
/// <returns>A list of inventory folders</returns>
|
||||||
|
public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (database)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
|
param["?uuid"] = parentID.ToStringHyphenated();
|
||||||
|
|
||||||
|
IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", param);
|
||||||
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
List<InventoryFolderBase> items = database.readInventoryFolders(reader);
|
||||||
|
|
||||||
|
reader.Close();
|
||||||
|
result.Dispose();
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
database.Reconnect();
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a specified inventory item
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item to return</param>
|
||||||
|
/// <returns>An inventory item</returns>
|
||||||
|
public InventoryItemBase getInventoryItem(LLUUID item)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (database)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
|
param["?uuid"] = item.ToStringHyphenated();
|
||||||
|
|
||||||
|
IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", param);
|
||||||
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
List<InventoryItemBase> items = database.readInventoryItems(reader);
|
||||||
|
|
||||||
|
reader.Close();
|
||||||
|
result.Dispose();
|
||||||
|
|
||||||
|
if (items.Count > 0)
|
||||||
|
{
|
||||||
|
return items[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
database.Reconnect();
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a specified inventory folder
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folder">The folder to return</param>
|
||||||
|
/// <returns>A folder class</returns>
|
||||||
|
public InventoryFolderBase getInventoryFolder(LLUUID folder)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (database)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
|
param["?uuid"] = folder.ToStringHyphenated();
|
||||||
|
|
||||||
|
IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", param);
|
||||||
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
List<InventoryFolderBase> items = database.readInventoryFolders(reader);
|
||||||
|
|
||||||
|
reader.Close();
|
||||||
|
result.Dispose();
|
||||||
|
|
||||||
|
if (items.Count > 0)
|
||||||
|
{
|
||||||
|
return items[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
database.Reconnect();
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a specified item to the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The inventory item</param>
|
||||||
|
public void addInventoryItem(InventoryItemBase item)
|
||||||
|
{
|
||||||
|
lock (database)
|
||||||
|
{
|
||||||
|
database.insertItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the specified inventory item
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">Inventory item to update</param>
|
||||||
|
public void updateInventoryItem(InventoryItemBase item)
|
||||||
|
{
|
||||||
|
addInventoryItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
public void deleteInventoryItem(InventoryItemBase item)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new inventory folder
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folder">Folder to create</param>
|
||||||
|
public void addInventoryFolder(InventoryFolderBase folder)
|
||||||
|
{
|
||||||
|
lock (database)
|
||||||
|
{
|
||||||
|
database.insertFolder(folder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates an inventory folder
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folder">Folder to update</param>
|
||||||
|
public void updateInventoryFolder(InventoryFolderBase folder)
|
||||||
|
{
|
||||||
|
addInventoryFolder(folder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,105 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data.MySQL
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An interface to the log database for MySQL
|
||||||
|
/// </summary>
|
||||||
|
class MySQLLogData : ILogData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The database manager
|
||||||
|
/// </summary>
|
||||||
|
public MySQLManager database;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Artificial constructor called when the plugin is loaded
|
||||||
|
/// </summary>
|
||||||
|
public void Initialise()
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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
|
||||||
|
{
|
||||||
|
database.Reconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the name of this DB provider
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string containing the DB provider name</returns>
|
||||||
|
public string getName()
|
||||||
|
{
|
||||||
|
return "MySQL Logdata Interface";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Closes the database provider
|
||||||
|
/// </summary>
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the version of this DB provider
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string containing the provider version</returns>
|
||||||
|
public string getVersion()
|
||||||
|
{
|
||||||
|
return "0.1";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,692 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data.MySQL
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A MySQL Database manager
|
||||||
|
/// </summary>
|
||||||
|
class MySQLManager
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The database connection object
|
||||||
|
/// </summary>
|
||||||
|
IDbConnection dbcon;
|
||||||
|
/// <summary>
|
||||||
|
/// Connection string for ADO.net
|
||||||
|
/// </summary>
|
||||||
|
string connectionString;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialises and creates a new MySQL connection and maintains it.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hostname">The MySQL server being connected to</param>
|
||||||
|
/// <param name="database">The name of the MySQL database being used</param>
|
||||||
|
/// <param name="username">The username logging into the database</param>
|
||||||
|
/// <param name="password">The password for the user logging in</param>
|
||||||
|
/// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param>
|
||||||
|
public MySQLManager(string hostname, string database, string username, string password, string cpooling, string port)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
connectionString = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";";
|
||||||
|
dbcon = new MySqlConnection(connectionString);
|
||||||
|
|
||||||
|
dbcon.Open();
|
||||||
|
|
||||||
|
Console.WriteLine("MySQL connection established");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new Exception("Error initialising MySql Database: " + e.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shuts down the database connection
|
||||||
|
/// </summary>
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
dbcon.Close();
|
||||||
|
dbcon = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reconnects to the database
|
||||||
|
/// </summary>
|
||||||
|
public void Reconnect()
|
||||||
|
{
|
||||||
|
lock (dbcon)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Close the DB connection
|
||||||
|
dbcon.Close();
|
||||||
|
// Try reopen it
|
||||||
|
dbcon = new MySqlConnection(connectionString);
|
||||||
|
dbcon.Open();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Unable to reconnect to database " + e.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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 MySQL DB Command</returns>
|
||||||
|
public IDbCommand Query(string sql, Dictionary<string, string> parameters)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand();
|
||||||
|
dbcommand.CommandText = sql;
|
||||||
|
foreach (KeyValuePair<string, string> param in parameters)
|
||||||
|
{
|
||||||
|
dbcommand.Parameters.Add(param.Key, param.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (IDbCommand)dbcommand;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
lock (dbcon)
|
||||||
|
{
|
||||||
|
// Close the DB connection
|
||||||
|
try
|
||||||
|
{
|
||||||
|
dbcon.Close();
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
// Try reopen it
|
||||||
|
try
|
||||||
|
{
|
||||||
|
dbcon = new MySqlConnection(connectionString);
|
||||||
|
dbcon.Open();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Unable to reconnect to database " + e.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run the query again
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand();
|
||||||
|
dbcommand.CommandText = sql;
|
||||||
|
foreach (KeyValuePair<string, string> param in parameters)
|
||||||
|
{
|
||||||
|
dbcommand.Parameters.Add(param.Key, param.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (IDbCommand)dbcommand;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// Return null if it fails.
|
||||||
|
Console.WriteLine("Failed during Query generation: " + e.ToString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads a region row from a database reader
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reader">An active database reader</param>
|
||||||
|
/// <returns>A region profile</returns>
|
||||||
|
public SimProfileData readSimRow(IDataReader reader)
|
||||||
|
{
|
||||||
|
SimProfileData retval = new SimProfileData();
|
||||||
|
|
||||||
|
if (reader.Read())
|
||||||
|
{
|
||||||
|
// Region Main
|
||||||
|
retval.regionHandle = Convert.ToUInt64(reader["regionHandle"].ToString());
|
||||||
|
retval.regionName = (string)reader["regionName"];
|
||||||
|
retval.UUID = new LLUUID((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"];
|
||||||
|
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 = (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"];
|
||||||
|
|
||||||
|
// World Map Addition
|
||||||
|
string tempRegionMap = reader["regionMapTexture"].ToString();
|
||||||
|
if (tempRegionMap != "")
|
||||||
|
{
|
||||||
|
retval.regionMapTextureID = new LLUUID(tempRegionMap);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retval.regionMapTextureID = new LLUUID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads a reservation row from a database reader
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reader">An active database reader</param>
|
||||||
|
/// <returns>A reservation data object</returns>
|
||||||
|
public ReservationData readReservationRow(IDataReader reader)
|
||||||
|
{
|
||||||
|
ReservationData retval = new ReservationData();
|
||||||
|
if (reader.Read())
|
||||||
|
{
|
||||||
|
retval.gridRecvKey = (string)reader["gridRecvKey"];
|
||||||
|
retval.gridSendKey = (string)reader["gridSendKey"];
|
||||||
|
retval.reservationCompany = (string)reader["resCompany"];
|
||||||
|
retval.reservationMaxX = Convert.ToInt32(reader["resXMax"].ToString());
|
||||||
|
retval.reservationMaxY = Convert.ToInt32(reader["resYMax"].ToString());
|
||||||
|
retval.reservationMinX = Convert.ToInt32(reader["resXMin"].ToString());
|
||||||
|
retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString());
|
||||||
|
retval.reservationName = (string)reader["resName"];
|
||||||
|
retval.status = Convert.ToInt32(reader["status"].ToString()) == 1;
|
||||||
|
retval.userUUID = new LLUUID((string)reader["userUUID"]);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Reads an agent row from a database reader
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reader">An active database reader</param>
|
||||||
|
/// <returns>A user session agent</returns>
|
||||||
|
public UserAgentData readAgentRow(IDataReader reader)
|
||||||
|
{
|
||||||
|
UserAgentData retval = new UserAgentData();
|
||||||
|
|
||||||
|
if (reader.Read())
|
||||||
|
{
|
||||||
|
// Agent IDs
|
||||||
|
retval.UUID = new LLUUID((string)reader["UUID"]);
|
||||||
|
retval.sessionID = new LLUUID((string)reader["sessionID"]);
|
||||||
|
retval.secureSessionID = new LLUUID((string)reader["secureSessionID"]);
|
||||||
|
|
||||||
|
// Agent Who?
|
||||||
|
retval.agentIP = (string)reader["agentIP"];
|
||||||
|
retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString());
|
||||||
|
retval.agentOnline = Convert.ToBoolean(reader["agentOnline"].ToString());
|
||||||
|
|
||||||
|
// Login/Logout times (UNIX Epoch)
|
||||||
|
retval.loginTime = Convert.ToInt32(reader["loginTime"].ToString());
|
||||||
|
retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString());
|
||||||
|
|
||||||
|
// Current position
|
||||||
|
retval.currentRegion = (string)reader["currentRegion"];
|
||||||
|
retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString());
|
||||||
|
LLVector3.TryParse((string)reader["currentPos"], out retval.currentPos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads a user profile from an active data reader
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reader">An active database reader</param>
|
||||||
|
/// <returns>A user profile</returns>
|
||||||
|
public UserProfileData readUserRow(IDataReader reader)
|
||||||
|
{
|
||||||
|
UserProfileData retval = new UserProfileData();
|
||||||
|
|
||||||
|
if (reader.Read())
|
||||||
|
{
|
||||||
|
retval.UUID = new LLUUID((string)reader["UUID"]);
|
||||||
|
retval.username = (string)reader["username"];
|
||||||
|
retval.surname = (string)reader["lastname"];
|
||||||
|
|
||||||
|
retval.passwordHash = (string)reader["passwordHash"];
|
||||||
|
retval.passwordSalt = (string)reader["passwordSalt"];
|
||||||
|
|
||||||
|
retval.homeRegion = Convert.ToUInt64(reader["homeRegion"].ToString());
|
||||||
|
retval.homeLocation = new LLVector3(
|
||||||
|
Convert.ToSingle(reader["homeLocationX"].ToString()),
|
||||||
|
Convert.ToSingle(reader["homeLocationY"].ToString()),
|
||||||
|
Convert.ToSingle(reader["homeLocationZ"].ToString()));
|
||||||
|
retval.homeLookAt = new LLVector3(
|
||||||
|
Convert.ToSingle(reader["homeLookAtX"].ToString()),
|
||||||
|
Convert.ToSingle(reader["homeLookAtY"].ToString()),
|
||||||
|
Convert.ToSingle(reader["homeLookAtZ"].ToString()));
|
||||||
|
|
||||||
|
retval.created = Convert.ToInt32(reader["created"].ToString());
|
||||||
|
retval.lastLogin = Convert.ToInt32(reader["lastLogin"].ToString());
|
||||||
|
|
||||||
|
retval.userInventoryURI = (string)reader["userInventoryURI"];
|
||||||
|
retval.userAssetURI = (string)reader["userAssetURI"];
|
||||||
|
|
||||||
|
retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString());
|
||||||
|
retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString());
|
||||||
|
|
||||||
|
retval.profileAboutText = (string)reader["profileAboutText"];
|
||||||
|
retval.profileFirstText = (string)reader["profileFirstText"];
|
||||||
|
|
||||||
|
retval.profileImage = new LLUUID((string)reader["profileImage"]);
|
||||||
|
retval.profileFirstImage = new LLUUID((string)reader["profileFirstImage"]);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads a list of inventory folders returned by a query.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reader">A MySQL Data Reader</param>
|
||||||
|
/// <returns>A List containing inventory folders</returns>
|
||||||
|
public List<InventoryFolderBase> readInventoryFolders(IDataReader reader)
|
||||||
|
{
|
||||||
|
List<InventoryFolderBase> rows = new List<InventoryFolderBase>();
|
||||||
|
|
||||||
|
while(reader.Read())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
InventoryFolderBase folder = new InventoryFolderBase();
|
||||||
|
|
||||||
|
folder.agentID = new LLUUID((string)reader["agentID"]);
|
||||||
|
folder.parentID = new LLUUID((string)reader["parentFolderID"]);
|
||||||
|
folder.folderID = new LLUUID((string)reader["folderID"]);
|
||||||
|
folder.name = (string)reader["folderName"];
|
||||||
|
|
||||||
|
rows.Add(folder);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads a collection of items from an SQL result
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reader">The SQL Result</param>
|
||||||
|
/// <returns>A List containing Inventory Items</returns>
|
||||||
|
public List<InventoryItemBase> readInventoryItems(IDataReader reader)
|
||||||
|
{
|
||||||
|
List<InventoryItemBase> rows = new List<InventoryItemBase>();
|
||||||
|
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
InventoryItemBase item = new InventoryItemBase();
|
||||||
|
|
||||||
|
item.assetID = new LLUUID((string)reader["assetID"]);
|
||||||
|
item.avatarID = new LLUUID((string)reader["avatarID"]);
|
||||||
|
item.inventoryCurrentPermissions = Convert.ToUInt32(reader["inventoryCurrentPermissions"].ToString());
|
||||||
|
item.inventoryDescription = (string)reader["inventoryDescription"];
|
||||||
|
item.inventoryID = new LLUUID((string)reader["inventoryID"]);
|
||||||
|
item.inventoryName = (string)reader["inventoryName"];
|
||||||
|
item.inventoryNextPermissions = Convert.ToUInt32(reader["inventoryNextPermissions"].ToString());
|
||||||
|
item.parentFolderID = new LLUUID((string)reader["parentFolderID"]);
|
||||||
|
item.assetType = Convert.ToInt32(reader["type"].ToString());
|
||||||
|
|
||||||
|
rows.Add(item);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inserts a new row into the log database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serverDaemon">The daemon which triggered this event</param>
|
||||||
|
/// <param name="target">Who were we operating on when this occured (region UUID, user 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">Extra message info</param>
|
||||||
|
/// <returns>Saved successfully?</returns>
|
||||||
|
public bool insertLogRow(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)";
|
||||||
|
|
||||||
|
Dictionary<string, string> parameters = new Dictionary<string, string>();
|
||||||
|
parameters["?server"] = serverDaemon;
|
||||||
|
parameters["?target"] = target;
|
||||||
|
parameters["?method"] = methodCall;
|
||||||
|
parameters["?arguments"] = arguments;
|
||||||
|
parameters["?priority"] = priority.ToString();
|
||||||
|
parameters["?message"] = logMessage;
|
||||||
|
|
||||||
|
bool returnval = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IDbCommand result = Query(sql, parameters);
|
||||||
|
|
||||||
|
if (result.ExecuteNonQuery() == 1)
|
||||||
|
returnval = true;
|
||||||
|
|
||||||
|
result.Dispose();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inserts a new item into the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item</param>
|
||||||
|
/// <returns>Success?</returns>
|
||||||
|
public bool insertItem(InventoryItemBase item)
|
||||||
|
{
|
||||||
|
string sql = "REPLACE INTO inventoryitems (inventoryID, assetID, type, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions) VALUES ";
|
||||||
|
sql += "(?inventoryID, ?assetID, ?type, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription, ?inventoryNextPermissions, ?inventoryCurrentPermissions)";
|
||||||
|
|
||||||
|
Dictionary<string, string> parameters = new Dictionary<string, string>();
|
||||||
|
parameters["?inventoryID"] = item.inventoryID.ToStringHyphenated();
|
||||||
|
parameters["?assetID"] = item.assetID.ToStringHyphenated();
|
||||||
|
parameters["?type"] = item.assetType.ToString();
|
||||||
|
parameters["?parentFolderID"] = item.parentFolderID.ToStringHyphenated();
|
||||||
|
parameters["?avatarID"] = item.avatarID.ToStringHyphenated();
|
||||||
|
parameters["?inventoryName"] = item.inventoryName;
|
||||||
|
parameters["?inventoryDescription"] = item.inventoryDescription;
|
||||||
|
parameters["?inventoryNextPermissions"] = item.inventoryNextPermissions.ToString();
|
||||||
|
parameters["?inventoryCurrentPermissions"] = item.inventoryCurrentPermissions.ToString();
|
||||||
|
|
||||||
|
bool returnval = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IDbCommand result = Query(sql, parameters);
|
||||||
|
|
||||||
|
if (result.ExecuteNonQuery() == 1)
|
||||||
|
returnval = true;
|
||||||
|
|
||||||
|
result.Dispose();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inserts a new folder into the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folder">The folder</param>
|
||||||
|
/// <returns>Success?</returns>
|
||||||
|
public bool insertFolder(InventoryFolderBase folder)
|
||||||
|
{
|
||||||
|
string sql = "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName) VALUES ";
|
||||||
|
sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName)";
|
||||||
|
|
||||||
|
Dictionary<string, string> parameters = new Dictionary<string, string>();
|
||||||
|
parameters["?folderID"] = folder.folderID.ToStringHyphenated();
|
||||||
|
parameters["?agentID"] = folder.agentID.ToStringHyphenated();
|
||||||
|
parameters["?parentFolderID"] = folder.parentID.ToStringHyphenated();
|
||||||
|
parameters["?folderName"] = folder.name;
|
||||||
|
|
||||||
|
bool returnval = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IDbCommand result = Query(sql, parameters);
|
||||||
|
|
||||||
|
if (result.ExecuteNonQuery() == 1)
|
||||||
|
returnval = true;
|
||||||
|
|
||||||
|
result.Dispose();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return returnval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new user and inserts it into the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uuid">User ID</param>
|
||||||
|
/// <param name="username">First part of the login</param>
|
||||||
|
/// <param name="lastname">Second part of the login</param>
|
||||||
|
/// <param name="passwordHash">A salted hash of the users password</param>
|
||||||
|
/// <param name="passwordSalt">The salt used for the password hash</param>
|
||||||
|
/// <param name="homeRegion">A regionHandle of the users home region</param>
|
||||||
|
/// <param name="homeLocX">Home region position vector</param>
|
||||||
|
/// <param name="homeLocY">Home region position vector</param>
|
||||||
|
/// <param name="homeLocZ">Home region position vector</param>
|
||||||
|
/// <param name="homeLookAtX">Home region 'look at' vector</param>
|
||||||
|
/// <param name="homeLookAtY">Home region 'look at' vector</param>
|
||||||
|
/// <param name="homeLookAtZ">Home region 'look at' vector</param>
|
||||||
|
/// <param name="created">Account created (unix timestamp)</param>
|
||||||
|
/// <param name="lastlogin">Last login (unix timestamp)</param>
|
||||||
|
/// <param name="inventoryURI">Users inventory URI</param>
|
||||||
|
/// <param name="assetURI">Users asset URI</param>
|
||||||
|
/// <param name="canDoMask">I can do mask</param>
|
||||||
|
/// <param name="wantDoMask">I want to do mask</param>
|
||||||
|
/// <param name="aboutText">Profile text</param>
|
||||||
|
/// <param name="firstText">Firstlife text</param>
|
||||||
|
/// <param name="profileImage">UUID for profile image</param>
|
||||||
|
/// <param name="firstImage">UUID for firstlife image</param>
|
||||||
|
/// <returns>Success?</returns>
|
||||||
|
public bool insertUserRow(libsecondlife.LLUUID uuid, string username, string lastname, string passwordHash, string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ,
|
||||||
|
float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, string aboutText, string firstText,
|
||||||
|
libsecondlife.LLUUID profileImage, libsecondlife.LLUUID firstImage)
|
||||||
|
{
|
||||||
|
string sql = "INSERT INTO users (`UUID`, `username`, `lastname`, `passwordHash`, `passwordSalt`, `homeRegion`, ";
|
||||||
|
sql += "`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, ";
|
||||||
|
sql += "`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, ";
|
||||||
|
sql += "`profileFirstText`, `profileImage`, `profileFirstImage`) VALUES ";
|
||||||
|
|
||||||
|
sql += "(?UUID, ?username, ?lastname, ?passwordHash, ?passwordSalt, ?homeRegion, ";
|
||||||
|
sql += "?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, ";
|
||||||
|
sql += "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, ";
|
||||||
|
sql += "?profileFirstText, ?profileImage, ?profileFirstImage)";
|
||||||
|
|
||||||
|
Dictionary<string, string> parameters = new Dictionary<string, string>();
|
||||||
|
parameters["?UUID"] = uuid.ToStringHyphenated();
|
||||||
|
parameters["?username"] = username.ToString();
|
||||||
|
parameters["?lastname"] = lastname.ToString();
|
||||||
|
parameters["?passwordHash"] = passwordHash.ToString();
|
||||||
|
parameters["?passwordSalt"] = passwordSalt.ToString();
|
||||||
|
parameters["?homeRegion"] = homeRegion.ToString();
|
||||||
|
parameters["?homeLocationX"] = homeLocX.ToString();
|
||||||
|
parameters["?homeLocationY"] = homeLocY.ToString();
|
||||||
|
parameters["?homeLocationZ"] = homeLocZ.ToString();
|
||||||
|
parameters["?homeLookAtX"] = homeLookAtX.ToString();
|
||||||
|
parameters["?homeLookAtY"] = homeLookAtY.ToString();
|
||||||
|
parameters["?homeLookAtZ"] = homeLookAtZ.ToString();
|
||||||
|
parameters["?created"] = created.ToString();
|
||||||
|
parameters["?lastLogin"] = lastlogin.ToString();
|
||||||
|
parameters["?userInventoryURI"] = "";
|
||||||
|
parameters["?userAssetURI"] = "";
|
||||||
|
parameters["?profileCanDoMask"] = "0";
|
||||||
|
parameters["?profileWantDoMask"] = "0";
|
||||||
|
parameters["?profileAboutText"] = "";
|
||||||
|
parameters["?profileFirstText"] = "";
|
||||||
|
parameters["?profileImage"] = libsecondlife.LLUUID.Zero.ToStringHyphenated();
|
||||||
|
parameters["?profileFirstImage"] = libsecondlife.LLUUID.Zero.ToStringHyphenated();
|
||||||
|
|
||||||
|
bool returnval = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IDbCommand result = Query(sql, parameters);
|
||||||
|
|
||||||
|
if (result.ExecuteNonQuery() == 1)
|
||||||
|
returnval = true;
|
||||||
|
|
||||||
|
result.Dispose();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inserts a new region into the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="profile">The region to insert</param>
|
||||||
|
/// <returns>Success?</returns>
|
||||||
|
public bool insertRegion(SimProfileData regiondata)
|
||||||
|
{
|
||||||
|
string sql = "REPLACE INTO regions (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, regionMapTexture, serverHttpPort, serverRemotingPort) 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, ?regionMapTexture, ?serverHttpPort, ?serverRemotingPort);";
|
||||||
|
|
||||||
|
Dictionary<string, string> parameters = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
parameters["?regionHandle"] = regiondata.regionHandle.ToString();
|
||||||
|
parameters["?regionName"] = regiondata.regionName.ToString();
|
||||||
|
parameters["?uuid"] = regiondata.UUID.ToStringHyphenated();
|
||||||
|
parameters["?regionRecvKey"] = regiondata.regionRecvKey.ToString();
|
||||||
|
parameters["?regionSecret"] = regiondata.regionSecret.ToString();
|
||||||
|
parameters["?regionSendKey"] = regiondata.regionSendKey.ToString();
|
||||||
|
parameters["?regionDataURI"] = regiondata.regionDataURI.ToString();
|
||||||
|
parameters["?serverIP"] = regiondata.serverIP.ToString();
|
||||||
|
parameters["?serverPort"] = regiondata.serverPort.ToString();
|
||||||
|
parameters["?serverURI"] = regiondata.serverURI.ToString();
|
||||||
|
parameters["?locX"] = regiondata.regionLocX.ToString();
|
||||||
|
parameters["?locY"] = regiondata.regionLocY.ToString();
|
||||||
|
parameters["?locZ"] = regiondata.regionLocZ.ToString();
|
||||||
|
parameters["?eastOverrideHandle"] = regiondata.regionEastOverrideHandle.ToString();
|
||||||
|
parameters["?westOverrideHandle"] = regiondata.regionWestOverrideHandle.ToString();
|
||||||
|
parameters["?northOverrideHandle"] = regiondata.regionNorthOverrideHandle.ToString();
|
||||||
|
parameters["?southOverrideHandle"] = regiondata.regionSouthOverrideHandle.ToString();
|
||||||
|
parameters["?regionAssetURI"] = regiondata.regionAssetURI.ToString();
|
||||||
|
parameters["?regionAssetRecvKey"] = regiondata.regionAssetRecvKey.ToString();
|
||||||
|
parameters["?regionAssetSendKey"] = regiondata.regionAssetSendKey.ToString();
|
||||||
|
parameters["?regionUserURI"] = regiondata.regionUserURI.ToString();
|
||||||
|
parameters["?regionUserRecvKey"] = regiondata.regionUserRecvKey.ToString();
|
||||||
|
parameters["?regionUserSendKey"] = regiondata.regionUserSendKey.ToString();
|
||||||
|
parameters["?regionMapTexture"] = regiondata.regionMapTextureID.ToStringHyphenated();
|
||||||
|
parameters["?serverHttpPort"] = regiondata.httpPort.ToString();
|
||||||
|
parameters["?serverRemotingPort"] = regiondata.remotingPort.ToString();
|
||||||
|
|
||||||
|
bool returnval = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
IDbCommand result = Query(sql, parameters);
|
||||||
|
|
||||||
|
//Console.WriteLine(result.CommandText);
|
||||||
|
int x;
|
||||||
|
if ((x = result.ExecuteNonQuery()) > 0)
|
||||||
|
{
|
||||||
|
returnval = true;
|
||||||
|
}
|
||||||
|
result.Dispose();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,278 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data.MySQL
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A database interface class to a user profile storage system
|
||||||
|
/// </summary>
|
||||||
|
class MySQLUserData : IUserData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Database manager for MySQL
|
||||||
|
/// </summary>
|
||||||
|
public MySQLManager database;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads and initialises the MySQL storage plugin
|
||||||
|
/// </summary>
|
||||||
|
public void Initialise()
|
||||||
|
{
|
||||||
|
// Load from an INI file connection details
|
||||||
|
// TODO: move this to XML?
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Searches the database for a specified user profile
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The account name of the user</param>
|
||||||
|
/// <returns>A user profile</returns>
|
||||||
|
public UserProfileData getUserByName(string name)
|
||||||
|
{
|
||||||
|
return getUserByName(name.Split(' ')[0], name.Split(' ')[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Searches the database for a specified user profile by name components
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The first part of the account name</param>
|
||||||
|
/// <param name="last">The second part of the account name</param>
|
||||||
|
/// <returns>A user profile</returns>
|
||||||
|
public UserProfileData getUserByName(string user, string last)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (database)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
|
param["?first"] = user;
|
||||||
|
param["?second"] = last;
|
||||||
|
|
||||||
|
IDbCommand result = database.Query("SELECT * FROM users WHERE username = ?first AND lastname = ?second", param);
|
||||||
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
UserProfileData row = database.readUserRow(reader);
|
||||||
|
|
||||||
|
reader.Close();
|
||||||
|
result.Dispose();
|
||||||
|
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
database.Reconnect();
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Searches the database for a specified user profile by UUID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uuid">The account ID</param>
|
||||||
|
/// <returns>The users profile</returns>
|
||||||
|
public UserProfileData getUserByUUID(LLUUID uuid)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (database)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
|
param["?uuid"] = uuid.ToStringHyphenated();
|
||||||
|
|
||||||
|
IDbCommand result = database.Query("SELECT * FROM users WHERE UUID = ?uuid", param);
|
||||||
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
UserProfileData row = database.readUserRow(reader);
|
||||||
|
|
||||||
|
reader.Close();
|
||||||
|
result.Dispose();
|
||||||
|
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
database.Reconnect();
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a user session searching by name
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The account name</param>
|
||||||
|
/// <returns>The users session</returns>
|
||||||
|
public 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 UserAgentData getAgentByName(string user, string last)
|
||||||
|
{
|
||||||
|
UserProfileData profile = getUserByName(user, last);
|
||||||
|
return getAgentByUUID(profile.UUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns an agent session by account UUID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uuid">The accounts UUID</param>
|
||||||
|
/// <returns>The users session</returns>
|
||||||
|
public UserAgentData getAgentByUUID(LLUUID uuid)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (database)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
|
param["?uuid"] = uuid.ToStringHyphenated();
|
||||||
|
|
||||||
|
IDbCommand result = database.Query("SELECT * FROM agents WHERE UUID = ?uuid", param);
|
||||||
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
UserAgentData row = database.readAgentRow(reader);
|
||||||
|
|
||||||
|
reader.Close();
|
||||||
|
result.Dispose();
|
||||||
|
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
database.Reconnect();
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new users profile
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The user profile to create</param>
|
||||||
|
public void addNewUserProfile(UserProfileData user)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (database)
|
||||||
|
{
|
||||||
|
database.insertUserRow(user.UUID, user.username, user.surname, user.passwordHash, user.passwordSalt, user.homeRegion, 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.profileCanDoMask, user.profileWantDoMask,
|
||||||
|
user.profileAboutText, user.profileFirstText, user.profileImage, user.profileFirstImage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
database.Reconnect();
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new agent
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="agent">The agent to create</param>
|
||||||
|
public void addNewUserAgent(UserAgentData agent)
|
||||||
|
{
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public bool updateUserProfile(UserProfileData user)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
// TODO: implement
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs a money transfer request between two accounts
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="from">The senders account ID</param>
|
||||||
|
/// <param name="to">The recievers account ID</param>
|
||||||
|
/// <param name="amount">The amount to transfer</param>
|
||||||
|
/// <returns>Success?</returns>
|
||||||
|
public bool moneyTransferRequest(LLUUID from, LLUUID 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 recievers account ID</param>
|
||||||
|
/// <param name="item">The item to transfer</param>
|
||||||
|
/// <returns>Success?</returns>
|
||||||
|
public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Database provider name
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Provider name</returns>
|
||||||
|
public string getName()
|
||||||
|
{
|
||||||
|
return "MySQL Userdata Interface";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Database provider version
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>provider version</returns>
|
||||||
|
public string getVersion()
|
||||||
|
{
|
||||||
|
return "0.1";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("OpenSim.Framework.Data.MySQL")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("OpenSim.Framework.Data.MySQL")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2007")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("e49826b2-dcef-41be-a5bd-596733fa3304")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,33 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("OpenSim.Framework.Data.SQLite")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("OpenSim.Framework.Data.SQLite")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2007")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("6113d5ce-4547-49f4-9236-0dcc503457b1")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,197 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data.SQLite
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A Grid Interface to the SQLite database
|
||||||
|
/// </summary>
|
||||||
|
public class SQLiteGridData : IGridData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A database manager
|
||||||
|
/// </summary>
|
||||||
|
private SQLiteManager database;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialises the Grid Interface
|
||||||
|
/// </summary>
|
||||||
|
public void Initialise()
|
||||||
|
{
|
||||||
|
database = new SQLiteManager("localhost", "db", "user", "password", "false");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shuts down the grid interface
|
||||||
|
/// </summary>
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
database.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the name of this grid interface
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string containing the grid interface</returns>
|
||||||
|
public string getName()
|
||||||
|
{
|
||||||
|
return "SQLite OpenGridData";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the version of this grid interface
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string containing the version</returns>
|
||||||
|
public string getVersion()
|
||||||
|
{
|
||||||
|
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>
|
||||||
|
public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a sim profile from it's location
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="handle">Region location handle</param>
|
||||||
|
/// <returns>Sim profile</returns>
|
||||||
|
public SimProfileData 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();
|
||||||
|
|
||||||
|
SimProfileData row = database.getRow(reader);
|
||||||
|
reader.Close();
|
||||||
|
result.Dispose();
|
||||||
|
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a sim profile from it's UUID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uuid">The region UUID</param>
|
||||||
|
/// <returns>The sim profile</returns>
|
||||||
|
public SimProfileData GetProfileByLLUUID(LLUUID uuid)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
|
param["uuid"] = uuid.ToStringHyphenated();
|
||||||
|
|
||||||
|
IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = @uuid", param);
|
||||||
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
SimProfileData row = database.getRow(reader);
|
||||||
|
reader.Close();
|
||||||
|
result.Dispose();
|
||||||
|
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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>
|
||||||
|
public DataResponse AddProfile(SimProfileData profile)
|
||||||
|
{
|
||||||
|
if (database.insertRow(profile))
|
||||||
|
{
|
||||||
|
return DataResponse.RESPONSE_OK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return DataResponse.RESPONSE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DEPRECIATED. 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>
|
||||||
|
public bool AuthenticateSim(LLUUID 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.");
|
||||||
|
|
||||||
|
SimProfileData data = GetProfileByLLUUID(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(LLUUID uuid, ulong handle, string authhash, string challenge)
|
||||||
|
{
|
||||||
|
SHA512Managed HashProvider = new SHA512Managed();
|
||||||
|
ASCIIEncoding TextProvider = new ASCIIEncoding();
|
||||||
|
|
||||||
|
byte[] stream = TextProvider.GetBytes(uuid.ToStringHyphenated() + ":" + handle.ToString() + ":" + challenge);
|
||||||
|
byte[] hash = HashProvider.ComputeHash(stream);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReservationData GetReservationAtPoint(uint x, uint y)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,485 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using OpenSim.Framework.Console;
|
||||||
|
using OpenSim.Framework.Types;
|
||||||
|
using OpenSim.Framework.Utilities;
|
||||||
|
using libsecondlife;
|
||||||
|
|
||||||
|
using System.Data;
|
||||||
|
using System.Data.SqlTypes;
|
||||||
|
|
||||||
|
using Mono.Data.SqliteClient;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data.SQLite
|
||||||
|
{
|
||||||
|
|
||||||
|
public class SQLiteInventoryStore : IInventoryData
|
||||||
|
{
|
||||||
|
private const string invItemsSelect = "select * from inventoryitems";
|
||||||
|
private const string invFoldersSelect = "select * from inventoryfolders";
|
||||||
|
|
||||||
|
private DataSet ds;
|
||||||
|
private SqliteDataAdapter invItemsDa;
|
||||||
|
private SqliteDataAdapter invFoldersDa;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialises the interface
|
||||||
|
/// </summary>
|
||||||
|
public void Initialise()
|
||||||
|
{
|
||||||
|
Initialise("inventoryStore.db", "inventoryDatabase");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Initialise(string dbfile, string dbname)
|
||||||
|
{
|
||||||
|
string connectionString = "URI=file:" + dbfile + ",version=3";
|
||||||
|
|
||||||
|
MainLog.Instance.Verbose("Inventory", "Sqlite - connecting: " + dbfile);
|
||||||
|
SqliteConnection conn = new SqliteConnection(connectionString);
|
||||||
|
|
||||||
|
SqliteCommand itemsSelectCmd = new SqliteCommand(invItemsSelect, conn);
|
||||||
|
invItemsDa = new SqliteDataAdapter(itemsSelectCmd);
|
||||||
|
// SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa);
|
||||||
|
|
||||||
|
SqliteCommand foldersSelectCmd = new SqliteCommand(invFoldersSelect, conn);
|
||||||
|
invFoldersDa = new SqliteDataAdapter(foldersSelectCmd);
|
||||||
|
|
||||||
|
ds = new DataSet();
|
||||||
|
|
||||||
|
invItemsDa.Fill(ds, "inventoryitems");
|
||||||
|
invFoldersDa.Fill(ds, "inventoryfolders");
|
||||||
|
ds.AcceptChanges();
|
||||||
|
|
||||||
|
DataTable itemsTable = ds.Tables["inventoryitems"];
|
||||||
|
itemsTable.PrimaryKey = new DataColumn[] { itemsTable.Columns["UUID"] };
|
||||||
|
setupItemsCommands(invItemsDa, conn);
|
||||||
|
|
||||||
|
// shapeDa.FillSchema(ds, SchemaType.Source, "ShapeSchema");
|
||||||
|
DataTable folderTable = ds.Tables["inventoryfolders"];
|
||||||
|
folderTable.PrimaryKey = new DataColumn[] { folderTable.Columns["UUID"] };
|
||||||
|
setupFoldersCommands(invFoldersDa, conn);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SqliteParameter createSqliteParameter(string name, DbType type)
|
||||||
|
{
|
||||||
|
SqliteParameter param = new SqliteParameter();
|
||||||
|
param.ParameterName = ":" + name;
|
||||||
|
param.DbType = type;
|
||||||
|
param.SourceColumn = name;
|
||||||
|
param.SourceVersion = DataRowVersion.Current;
|
||||||
|
return param;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, DbType> createInventoryItemsDataDefs()
|
||||||
|
{
|
||||||
|
Dictionary<string, DbType> data = new Dictionary<string, DbType>();
|
||||||
|
data.Add("UUID", DbType.String); //inventoryID
|
||||||
|
data.Add("assetID", DbType.String);
|
||||||
|
data.Add("assetType", DbType.Int32);
|
||||||
|
data.Add("invType", DbType.Int32);
|
||||||
|
data.Add("parentFolderID", DbType.String);
|
||||||
|
data.Add("avatarID", DbType.String);
|
||||||
|
data.Add("creatorsID", DbType.String);
|
||||||
|
|
||||||
|
data.Add("inventoryName", DbType.String);
|
||||||
|
data.Add("inventoryDescription", DbType.String);
|
||||||
|
// permissions
|
||||||
|
data.Add("inventoryNextPermissions", DbType.Int32);
|
||||||
|
data.Add("inventoryCurrentPermissions", DbType.Int32);
|
||||||
|
data.Add("inventoryBasePermissions", DbType.Int32);
|
||||||
|
data.Add("inventoryEveryOnePermissions", DbType.Int32);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, DbType> createShapeDataDefs()
|
||||||
|
{
|
||||||
|
Dictionary<string, DbType> data = new Dictionary<string, DbType>();
|
||||||
|
data.Add("UUID", DbType.String); //folderID
|
||||||
|
// shape is an enum
|
||||||
|
data.Add("name", DbType.String);
|
||||||
|
// vectors
|
||||||
|
data.Add("agentID", DbType.String);
|
||||||
|
data.Add("parentID", DbType.String);
|
||||||
|
data.Add("type", DbType.Int32);
|
||||||
|
data.Add("version", DbType.Int32);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SqliteCommand createInsertCommand(string table, Dictionary<string, DbType> defs)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* This is subtle enough to deserve some commentary.
|
||||||
|
* Instead of doing *lots* and *lots of hardcoded strings
|
||||||
|
* for database definitions we'll use the fact that
|
||||||
|
* realistically all insert statements look like "insert
|
||||||
|
* into A(b, c) values(:b, :c) on the parameterized query
|
||||||
|
* front. If we just have a list of b, c, etc... we can
|
||||||
|
* generate these strings instead of typing them out.
|
||||||
|
*/
|
||||||
|
string[] cols = new string[defs.Keys.Count];
|
||||||
|
defs.Keys.CopyTo(cols, 0);
|
||||||
|
|
||||||
|
string sql = "insert into " + table + "(";
|
||||||
|
sql += String.Join(", ", cols);
|
||||||
|
// important, the first ':' needs to be here, the rest get added in the join
|
||||||
|
sql += ") values (:";
|
||||||
|
sql += String.Join(", :", cols);
|
||||||
|
sql += ")";
|
||||||
|
SqliteCommand cmd = new SqliteCommand(sql);
|
||||||
|
|
||||||
|
// this provides the binding for all our parameters, so
|
||||||
|
// much less code than it used to be
|
||||||
|
foreach (KeyValuePair<string, DbType> kvp in defs)
|
||||||
|
{
|
||||||
|
cmd.Parameters.Add(createSqliteParameter(kvp.Key, kvp.Value));
|
||||||
|
}
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SqliteCommand createUpdateCommand(string table, string pk, Dictionary<string, DbType> defs)
|
||||||
|
{
|
||||||
|
string sql = "update " + table + " set ";
|
||||||
|
string subsql = "";
|
||||||
|
foreach (string key in defs.Keys)
|
||||||
|
{
|
||||||
|
if (subsql.Length > 0)
|
||||||
|
{ // a map function would rock so much here
|
||||||
|
subsql += ", ";
|
||||||
|
}
|
||||||
|
subsql += key + "= :" + key;
|
||||||
|
}
|
||||||
|
sql += subsql;
|
||||||
|
sql += " where " + pk;
|
||||||
|
SqliteCommand cmd = new SqliteCommand(sql);
|
||||||
|
|
||||||
|
// this provides the binding for all our parameters, so
|
||||||
|
// much less code than it used to be
|
||||||
|
foreach (KeyValuePair<string, DbType> kvp in defs)
|
||||||
|
{
|
||||||
|
cmd.Parameters.Add(createSqliteParameter(kvp.Key, kvp.Value));
|
||||||
|
}
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupItemsCommands(SqliteDataAdapter da, SqliteConnection conn)
|
||||||
|
{
|
||||||
|
Dictionary<string, DbType> invDataDefs = createInventoryItemsDataDefs();
|
||||||
|
|
||||||
|
da.InsertCommand = createInsertCommand("inventoryitems", invDataDefs);
|
||||||
|
da.InsertCommand.Connection = conn;
|
||||||
|
|
||||||
|
da.UpdateCommand = createUpdateCommand("inventoryitems", "UUID=:UUID", invDataDefs);
|
||||||
|
da.UpdateCommand.Connection = conn;
|
||||||
|
|
||||||
|
SqliteCommand delete = new SqliteCommand("delete from inventoryitems where UUID = :UUID");
|
||||||
|
delete.Parameters.Add(createSqliteParameter("UUID", DbType.String));
|
||||||
|
delete.Connection = conn;
|
||||||
|
da.DeleteCommand = delete;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupFoldersCommands(SqliteDataAdapter da, SqliteConnection conn)
|
||||||
|
{
|
||||||
|
Dictionary<string, DbType> shapeDataDefs = createShapeDataDefs();
|
||||||
|
|
||||||
|
da.InsertCommand = createInsertCommand("inventoryfolders", shapeDataDefs);
|
||||||
|
da.InsertCommand.Connection = conn;
|
||||||
|
|
||||||
|
da.UpdateCommand = createUpdateCommand("inventoryfolders", "UUID=:UUID", shapeDataDefs);
|
||||||
|
da.UpdateCommand.Connection = conn;
|
||||||
|
|
||||||
|
SqliteCommand delete = new SqliteCommand("delete from inventoryfolders where UUID = :UUID");
|
||||||
|
delete.Parameters.Add(createSqliteParameter("UUID", DbType.String));
|
||||||
|
delete.Connection = conn;
|
||||||
|
da.DeleteCommand = delete;
|
||||||
|
}
|
||||||
|
|
||||||
|
private InventoryFolderBase buildFolder(DataRow row)
|
||||||
|
{
|
||||||
|
InventoryFolderBase folder = new InventoryFolderBase();
|
||||||
|
folder.folderID = new LLUUID((string)row["UUID"]);
|
||||||
|
folder.name = (string)row["name"];
|
||||||
|
folder.agentID = new LLUUID((string)row["agentID"]);
|
||||||
|
folder.parentID = new LLUUID((string)row["parentID"]);
|
||||||
|
folder.type = Convert.ToInt16(row["type"]);
|
||||||
|
folder.version = Convert.ToUInt16(row["version"]);
|
||||||
|
return folder;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillFolderRow(DataRow row, InventoryFolderBase folder)
|
||||||
|
{
|
||||||
|
row["UUID"] = folder.folderID;
|
||||||
|
row["name"] = folder.name;
|
||||||
|
row["agentID"] = folder.agentID;
|
||||||
|
row["parentID"] = folder.parentID;
|
||||||
|
row["type"] = folder.type;
|
||||||
|
row["version"] = folder.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InventoryItemBase BuildItem(DataRow row)
|
||||||
|
{
|
||||||
|
InventoryItemBase item = new InventoryItemBase();
|
||||||
|
item.inventoryID = new LLUUID((string)row["UUID"]);
|
||||||
|
item.assetID = new LLUUID((string)row["assetID"]);
|
||||||
|
item.assetType = Convert.ToInt32(row["assetType"]);
|
||||||
|
item.invType = Convert.ToInt32(row["invType"]);
|
||||||
|
item.parentFolderID = new LLUUID((string)row["parentFolderID"]);
|
||||||
|
item.avatarID = new LLUUID((string)row["avatarID"]);
|
||||||
|
item.creatorsID = new LLUUID((string)row["creatorsID"]);
|
||||||
|
item.inventoryName =(string) row["inventoryName"];
|
||||||
|
item.inventoryDescription = (string) row["inventoryDescription"];
|
||||||
|
|
||||||
|
item.inventoryNextPermissions = Convert.ToUInt32(row["inventoryNextPermissions"]);
|
||||||
|
item.inventoryCurrentPermissions = Convert.ToUInt32(row["inventoryCurrentPermissions"]);
|
||||||
|
item.inventoryBasePermissions = Convert.ToUInt32(row["inventoryBasePermissions"]);
|
||||||
|
item.inventoryEveryOnePermissions = Convert.ToUInt32(row["inventoryEveryOnePermissions"]);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillItemRow(DataRow row, InventoryItemBase item)
|
||||||
|
{
|
||||||
|
row["UUID"] = item.inventoryID;
|
||||||
|
row["assetID"] = item.assetID;
|
||||||
|
row["assetType"] = item.assetType;
|
||||||
|
row["invType"] = item.invType;
|
||||||
|
row["parentFolderID"] = item.parentFolderID;
|
||||||
|
row["avatarID"] = item.avatarID;
|
||||||
|
row["creatorsID"] = item.creatorsID;
|
||||||
|
row["inventoryName"] = item.inventoryName;
|
||||||
|
row["inventoryDescription"] = item.inventoryDescription;
|
||||||
|
|
||||||
|
row["inventoryNextPermissions"] = item.inventoryNextPermissions;
|
||||||
|
row["inventoryCurrentPermissions"] = item.inventoryCurrentPermissions;
|
||||||
|
row["inventoryBasePermissions"] = item.inventoryBasePermissions;
|
||||||
|
row["inventoryEveryOnePermissions"] = item.inventoryEveryOnePermissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addFolder(InventoryFolderBase folder)
|
||||||
|
{
|
||||||
|
DataTable inventoryFolderTable = ds.Tables["inventoryfolders"];
|
||||||
|
|
||||||
|
DataRow inventoryRow = inventoryFolderTable.Rows.Find(folder.folderID);
|
||||||
|
if (inventoryRow == null)
|
||||||
|
{
|
||||||
|
inventoryRow = inventoryFolderTable.NewRow();
|
||||||
|
fillFolderRow(inventoryRow, folder);
|
||||||
|
inventoryFolderTable.Rows.Add(inventoryRow);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fillFolderRow(inventoryRow, folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.invFoldersDa.Update(ds, "inventoryfolders");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addItem(InventoryItemBase item)
|
||||||
|
{
|
||||||
|
DataTable inventoryItemTable = ds.Tables["inventoryitems"];
|
||||||
|
|
||||||
|
DataRow inventoryRow = inventoryItemTable.Rows.Find(item.inventoryID);
|
||||||
|
if (inventoryRow == null)
|
||||||
|
{
|
||||||
|
inventoryRow = inventoryItemTable.NewRow();
|
||||||
|
fillItemRow(inventoryRow, item);
|
||||||
|
inventoryItemTable.Rows.Add(inventoryRow);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fillItemRow(inventoryRow, item);
|
||||||
|
}
|
||||||
|
this.invItemsDa.Update(ds, "inventoryitems");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Shutdown()
|
||||||
|
{
|
||||||
|
// TODO: DataSet commit
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Closes the interface
|
||||||
|
/// </summary>
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The plugin being loaded
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string containing the plugin name</returns>
|
||||||
|
public string getName()
|
||||||
|
{
|
||||||
|
return "SQLite Inventory Data Interface";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The plugins version
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string containing the plugin version</returns>
|
||||||
|
public string getVersion()
|
||||||
|
{
|
||||||
|
return "0.1";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a list of inventory items contained within the specified folder
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folderID">The UUID of the target folder</param>
|
||||||
|
/// <returns>A List of InventoryItemBase items</returns>
|
||||||
|
public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID)
|
||||||
|
{
|
||||||
|
List<InventoryItemBase> retval = new List<InventoryItemBase>();
|
||||||
|
DataTable inventoryItemTable = ds.Tables["inventoryitems"];
|
||||||
|
string selectExp = "parentFolderID = '" + folderID.ToString() + "'";
|
||||||
|
DataRow[] rows = inventoryItemTable.Select(selectExp);
|
||||||
|
foreach (DataRow row in rows)
|
||||||
|
{
|
||||||
|
retval.Add(BuildItem(row));
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a list of the root folders within a users inventory
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The user whos inventory is to be searched</param>
|
||||||
|
/// <returns>A list of folder objects</returns>
|
||||||
|
public List<InventoryFolderBase> getUserRootFolders(LLUUID user)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the users inventory root folder.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The UUID of the user who is having inventory being returned</param>
|
||||||
|
/// <returns>Root inventory folder</returns>
|
||||||
|
public InventoryFolderBase getUserRootFolder(LLUUID user)
|
||||||
|
{
|
||||||
|
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
|
||||||
|
DataTable inventoryFolderTable = ds.Tables["inventoryfolders"];
|
||||||
|
string selectExp = "agentID = '" + user.ToString() + "' AND parentID = '" + LLUUID.Zero.ToString() + "'";
|
||||||
|
DataRow[] rows = inventoryFolderTable.Select(selectExp);
|
||||||
|
foreach (DataRow row in rows)
|
||||||
|
{
|
||||||
|
folders.Add(this.buildFolder(row));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (folders.Count == 1)
|
||||||
|
{
|
||||||
|
//we found the root
|
||||||
|
//System.Console.WriteLine("found root inventory folder");
|
||||||
|
return folders[0];
|
||||||
|
}
|
||||||
|
else if (folders.Count > 1)
|
||||||
|
{
|
||||||
|
//err shouldn't be more than one root
|
||||||
|
//System.Console.WriteLine("found more than one root inventory folder");
|
||||||
|
}
|
||||||
|
else if (folders.Count == 0)
|
||||||
|
{
|
||||||
|
// no root?
|
||||||
|
//System.Console.WriteLine("couldn't find root inventory folder");
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a list of inventory folders contained in the folder 'parentID'
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parentID">The folder to get subfolders for</param>
|
||||||
|
/// <returns>A list of inventory folders</returns>
|
||||||
|
public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID)
|
||||||
|
{
|
||||||
|
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
|
||||||
|
DataTable inventoryFolderTable = ds.Tables["inventoryfolders"];
|
||||||
|
string selectExp = "parentID = '" + parentID.ToString() + "'";
|
||||||
|
DataRow[] rows = inventoryFolderTable.Select(selectExp);
|
||||||
|
foreach (DataRow row in rows)
|
||||||
|
{
|
||||||
|
folders.Add(this.buildFolder(row));
|
||||||
|
}
|
||||||
|
// System.Console.WriteLine("found " + folders.Count + " inventory folders");
|
||||||
|
return folders;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns an inventory item by its UUID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The UUID of the item to be returned</param>
|
||||||
|
/// <returns>A class containing item information</returns>
|
||||||
|
public InventoryItemBase getInventoryItem(LLUUID item)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a specified inventory folder by its UUID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folder">The UUID of the folder to be returned</param>
|
||||||
|
/// <returns>A class containing folder information</returns>
|
||||||
|
public InventoryFolderBase getInventoryFolder(LLUUID folder)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new inventory item based on item
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item to be created</param>
|
||||||
|
public void addInventoryItem(InventoryItemBase item)
|
||||||
|
{
|
||||||
|
this.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates an inventory item with item (updates based on ID)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The updated item</param>
|
||||||
|
public void updateInventoryItem(InventoryItemBase item)
|
||||||
|
{
|
||||||
|
this.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
public void deleteInventoryItem(InventoryItemBase item)
|
||||||
|
{
|
||||||
|
DataTable inventoryItemTable = ds.Tables["inventoryitems"];
|
||||||
|
|
||||||
|
DataRow inventoryRow = inventoryItemTable.Rows.Find(item.inventoryID);
|
||||||
|
if (inventoryRow != null)
|
||||||
|
{
|
||||||
|
inventoryRow.Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.invItemsDa.Update(ds, "inventoryitems");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a new folder specified by folder
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folder">The inventory folder</param>
|
||||||
|
public void addInventoryFolder(InventoryFolderBase folder)
|
||||||
|
{
|
||||||
|
this.addFolder(folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates a folder based on its ID with folder
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folder">The inventory folder</param>
|
||||||
|
public void updateInventoryFolder(InventoryFolderBase folder)
|
||||||
|
{
|
||||||
|
this.addFolder(folder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,206 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data.SQLite
|
||||||
|
{
|
||||||
|
class SQLiteManager
|
||||||
|
{
|
||||||
|
IDbConnection dbcon;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialises and creates a new SQLite connection and maintains it.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hostname">The SQLite server being connected to</param>
|
||||||
|
/// <param name="database">The name of the SQLite database being used</param>
|
||||||
|
/// <param name="username">The username logging into the database</param>
|
||||||
|
/// <param name="password">The password for the user logging in</param>
|
||||||
|
/// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param>
|
||||||
|
public SQLiteManager(string hostname, string database, string username, string password, string cpooling)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string 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 SimProfileData getRow(IDataReader reader)
|
||||||
|
{
|
||||||
|
SimProfileData retval = new SimProfileData();
|
||||||
|
|
||||||
|
if (reader.Read())
|
||||||
|
{
|
||||||
|
// Region Main
|
||||||
|
retval.regionHandle = (ulong)reader["regionHandle"];
|
||||||
|
retval.regionName = (string)reader["regionName"];
|
||||||
|
retval.UUID = new LLUUID((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(SimProfileData 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data
|
||||||
|
{
|
||||||
|
public enum DataResponse
|
||||||
|
{
|
||||||
|
RESPONSE_OK,
|
||||||
|
RESPONSE_AUTHREQUIRED,
|
||||||
|
RESPONSE_INVALIDCREDENTIALS,
|
||||||
|
RESPONSE_ERROR
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A standard grid interface
|
||||||
|
/// </summary>
|
||||||
|
public interface IGridData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a sim profile from a regionHandle
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="regionHandle">A 64bit Region Handle</param>
|
||||||
|
/// <returns>A simprofile</returns>
|
||||||
|
SimProfileData GetProfileByHandle(ulong regionHandle);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a sim profile from a UUID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="UUID">A 128bit UUID</param>
|
||||||
|
/// <returns>A sim profile</returns>
|
||||||
|
SimProfileData GetProfileByLLUUID(LLUUID UUID);
|
||||||
|
|
||||||
|
/// <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>
|
||||||
|
SimProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Authenticates a sim by use of it's 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 recieving key sent by the sim</param>
|
||||||
|
/// <returns>Whether the sim has been authenticated</returns>
|
||||||
|
bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialises the interface
|
||||||
|
/// </summary>
|
||||||
|
void Initialise();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Closes the interface
|
||||||
|
/// </summary>
|
||||||
|
void Close();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The plugin being loaded
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string containing the plugin name</returns>
|
||||||
|
string getName();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The plugins version
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string containing the plugin version</returns>
|
||||||
|
string getVersion();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a new profile to the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="profile">The profile to add</param>
|
||||||
|
/// <returns>RESPONSE_OK if successful, error if not.</returns>
|
||||||
|
DataResponse AddProfile(SimProfileData profile);
|
||||||
|
|
||||||
|
ReservationData GetReservationAtPoint(uint x, uint y);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
namespace OpenSim.Framework.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 ILogData
|
||||||
|
{
|
||||||
|
void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,string logMessage);
|
||||||
|
/// <summary>
|
||||||
|
/// Initialises the interface
|
||||||
|
/// </summary>
|
||||||
|
void Initialise();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Closes the interface
|
||||||
|
/// </summary>
|
||||||
|
void Close();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The plugin being loaded
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string containing the plugin name</returns>
|
||||||
|
string getName();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The plugins version
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string containing the plugin version</returns>
|
||||||
|
string getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.IO;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
/*
|
||||||
|
Taken from public code listing at by Alex Pinsker
|
||||||
|
http://alexpinsker.blogspot.com/2005/12/reading-ini-file-from-c_113432097333021549.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Parse settings from ini-like files
|
||||||
|
/// </summary>
|
||||||
|
public class IniFile
|
||||||
|
{
|
||||||
|
static IniFile()
|
||||||
|
{
|
||||||
|
_iniKeyValuePatternRegex = new Regex(
|
||||||
|
@"((\s)*(?<Key>([^\=^\s^\n]+))[\s^\n]*
|
||||||
|
# key part (surrounding whitespace stripped)
|
||||||
|
\=
|
||||||
|
(\s)*(?<Value>([^\n^\s]+(\n){0,1})))
|
||||||
|
# value part (surrounding whitespace stripped)
|
||||||
|
",
|
||||||
|
RegexOptions.IgnorePatternWhitespace |
|
||||||
|
RegexOptions.Compiled |
|
||||||
|
RegexOptions.CultureInvariant);
|
||||||
|
}
|
||||||
|
static private Regex _iniKeyValuePatternRegex;
|
||||||
|
|
||||||
|
public IniFile(string iniFileName)
|
||||||
|
{
|
||||||
|
_iniFileName = iniFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ParseFileReadValue(string key)
|
||||||
|
{
|
||||||
|
using (StreamReader reader =
|
||||||
|
new StreamReader(_iniFileName))
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
string line = reader.ReadLine();
|
||||||
|
Match match =
|
||||||
|
_iniKeyValuePatternRegex.Match(line);
|
||||||
|
if (match.Success)
|
||||||
|
{
|
||||||
|
string currentKey =
|
||||||
|
match.Groups["Key"].Value as string;
|
||||||
|
if (currentKey != null &&
|
||||||
|
currentKey.Trim().CompareTo(key) == 0)
|
||||||
|
{
|
||||||
|
string value =
|
||||||
|
match.Groups["Value"].Value as string;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
while (reader.Peek() != -1);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string IniFileName
|
||||||
|
{
|
||||||
|
get { return _iniFileName; }
|
||||||
|
} private string _iniFileName;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,222 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Inventory Item - contains all the properties associated with an individual inventory piece.
|
||||||
|
/// </summary>
|
||||||
|
public class InventoryItemBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A UUID containing the ID for the inventory item itself
|
||||||
|
/// </summary>
|
||||||
|
public LLUUID inventoryID;
|
||||||
|
/// <summary>
|
||||||
|
/// The UUID of the associated asset on the asset server
|
||||||
|
/// </summary>
|
||||||
|
public LLUUID assetID;
|
||||||
|
/// <summary>
|
||||||
|
/// This is an enumerated value determining the type of asset (eg Notecard, Sound, Object, etc)
|
||||||
|
/// </summary>
|
||||||
|
public int assetType;
|
||||||
|
/// <summary>
|
||||||
|
/// The type of inventory item. (Can be slightly different to the asset type
|
||||||
|
/// </summary>
|
||||||
|
public int invType;
|
||||||
|
/// <summary>
|
||||||
|
/// The folder this item is contained in
|
||||||
|
/// </summary>
|
||||||
|
public LLUUID parentFolderID;
|
||||||
|
/// <summary>
|
||||||
|
/// The owner of this inventory item
|
||||||
|
/// </summary>
|
||||||
|
public LLUUID avatarID;
|
||||||
|
/// <summary>
|
||||||
|
/// The creator of this item
|
||||||
|
/// </summary>
|
||||||
|
public LLUUID creatorsID;
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the inventory item (must be less than 64 characters)
|
||||||
|
/// </summary>
|
||||||
|
public string inventoryName;
|
||||||
|
/// <summary>
|
||||||
|
/// The description of the inventory item (must be less than 64 characters)
|
||||||
|
/// </summary>
|
||||||
|
public string inventoryDescription;
|
||||||
|
/// <summary>
|
||||||
|
/// A mask containing the permissions for the next owner (cannot be enforced)
|
||||||
|
/// </summary>
|
||||||
|
public uint inventoryNextPermissions;
|
||||||
|
/// <summary>
|
||||||
|
/// A mask containing permissions for the current owner (cannot be enforced)
|
||||||
|
/// </summary>
|
||||||
|
public uint inventoryCurrentPermissions;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public uint inventoryBasePermissions;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public uint inventoryEveryOnePermissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A Class for folders which contain users inventory
|
||||||
|
/// </summary>
|
||||||
|
public class InventoryFolderBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the folder (64 characters or less)
|
||||||
|
/// </summary>
|
||||||
|
public string name;
|
||||||
|
/// <summary>
|
||||||
|
/// The agent who's inventory this is contained by
|
||||||
|
/// </summary>
|
||||||
|
public LLUUID agentID;
|
||||||
|
/// <summary>
|
||||||
|
/// The folder this folder is contained in
|
||||||
|
/// </summary>
|
||||||
|
public LLUUID parentID;
|
||||||
|
/// <summary>
|
||||||
|
/// The UUID for this folder
|
||||||
|
/// </summary>
|
||||||
|
public LLUUID folderID;
|
||||||
|
/// <summary>
|
||||||
|
/// Tyep of Items normally stored in this folder
|
||||||
|
/// </summary>
|
||||||
|
public short type;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public ushort version;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An interface for accessing inventory data from a storage server
|
||||||
|
/// </summary>
|
||||||
|
public interface IInventoryData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initialises the interface
|
||||||
|
/// </summary>
|
||||||
|
void Initialise();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Closes the interface
|
||||||
|
/// </summary>
|
||||||
|
void Close();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The plugin being loaded
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string containing the plugin name</returns>
|
||||||
|
string getName();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The plugins version
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string containing the plugin version</returns>
|
||||||
|
string getVersion();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a list of inventory items contained within the specified folder
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folderID">The UUID of the target folder</param>
|
||||||
|
/// <returns>A List of InventoryItemBase items</returns>
|
||||||
|
List<InventoryItemBase> getInventoryInFolder(LLUUID folderID);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a list of the root folders within a users inventory
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The user whos inventory is to be searched</param>
|
||||||
|
/// <returns>A list of folder objects</returns>
|
||||||
|
List<InventoryFolderBase> getUserRootFolders(LLUUID user);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the users inventory root folder.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The UUID of the user who is having inventory being returned</param>
|
||||||
|
/// <returns>Root inventory folder</returns>
|
||||||
|
InventoryFolderBase getUserRootFolder(LLUUID user);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a list of inventory folders contained in the folder 'parentID'
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parentID">The folder to get subfolders for</param>
|
||||||
|
/// <returns>A list of inventory folders</returns>
|
||||||
|
List<InventoryFolderBase> getInventoryFolders(LLUUID parentID);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns an inventory item by its UUID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The UUID of the item to be returned</param>
|
||||||
|
/// <returns>A class containing item information</returns>
|
||||||
|
InventoryItemBase getInventoryItem(LLUUID item);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a specified inventory folder by its UUID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folder">The UUID of the folder to be returned</param>
|
||||||
|
/// <returns>A class containing folder information</returns>
|
||||||
|
InventoryFolderBase getInventoryFolder(LLUUID folder);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new inventory item based on item
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item to be created</param>
|
||||||
|
void addInventoryItem(InventoryItemBase item);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates an inventory item with item (updates based on ID)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The updated item</param>
|
||||||
|
void updateInventoryItem(InventoryItemBase item);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
void deleteInventoryItem(InventoryItemBase item);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a new folder specified by folder
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folder">The inventory folder</param>
|
||||||
|
void addInventoryFolder(InventoryFolderBase folder);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates a folder based on its ID with folder
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folder">The inventory folder</param>
|
||||||
|
void updateInventoryFolder(InventoryFolderBase folder);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("OpenSim.Framework.Data")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("OpenSim.Framework.Data")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2007")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("3a711c34-b0c0-4264-b0fe-f366eabf9d7b")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data
|
||||||
|
{
|
||||||
|
public class ReservationData
|
||||||
|
{
|
||||||
|
public LLUUID userUUID = new LLUUID();
|
||||||
|
public int reservationMinX = 0;
|
||||||
|
public int reservationMinY = 0;
|
||||||
|
public int reservationMaxX = 65536;
|
||||||
|
public int reservationMaxY = 65536;
|
||||||
|
|
||||||
|
public string reservationName = "";
|
||||||
|
public string reservationCompany = "";
|
||||||
|
public bool status = true;
|
||||||
|
|
||||||
|
public string gridSendKey = "";
|
||||||
|
public string gridRecvKey = "";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,192 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
using Nwc.XmlRpc;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A class which contains information known to the grid server about a region
|
||||||
|
/// </summary>
|
||||||
|
public class SimProfileData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the region
|
||||||
|
/// </summary>
|
||||||
|
public string regionName = "";
|
||||||
|
|
||||||
|
/// <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 LLUUID 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 = "";
|
||||||
|
public string regionRecvKey = "";
|
||||||
|
public string regionSecret = "";
|
||||||
|
|
||||||
|
/// <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 = "";
|
||||||
|
public uint serverPort;
|
||||||
|
public string serverURI = "";
|
||||||
|
|
||||||
|
public uint httpPort;
|
||||||
|
public uint remotingPort;
|
||||||
|
public string httpServerURI = "";
|
||||||
|
|
||||||
|
/// <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 = "";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Region Asset Details
|
||||||
|
/// </summary>
|
||||||
|
public string regionAssetURI = "";
|
||||||
|
public string regionAssetSendKey = "";
|
||||||
|
public string regionAssetRecvKey = "";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Region Userserver Details
|
||||||
|
/// </summary>
|
||||||
|
public string regionUserURI = "";
|
||||||
|
public string regionUserSendKey = "";
|
||||||
|
public string regionUserRecvKey = "";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Region Map Texture Asset
|
||||||
|
/// </summary>
|
||||||
|
public LLUUID regionMapTextureID = new LLUUID("00000000-0000-0000-9999-000000000006");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get Sim profile data from grid server when in grid mode
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="region_uuid"></param>
|
||||||
|
/// <param name="gridserver_url"></param>
|
||||||
|
/// <param name="?"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public SimProfileData RequestSimProfileData(LLUUID region_uuid, string gridserver_url, string gridserver_sendkey, string gridserver_recvkey)
|
||||||
|
{
|
||||||
|
Hashtable requestData = new Hashtable();
|
||||||
|
requestData["region_uuid"] = region_uuid.UUID.ToString();
|
||||||
|
requestData["authkey"] = gridserver_sendkey;
|
||||||
|
ArrayList SendParams = new ArrayList();
|
||||||
|
SendParams.Add(requestData);
|
||||||
|
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
|
||||||
|
XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
|
||||||
|
|
||||||
|
Hashtable responseData = (Hashtable)GridResp.Value;
|
||||||
|
|
||||||
|
if (responseData.ContainsKey("error"))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
SimProfileData simData = new SimProfileData();
|
||||||
|
simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]);
|
||||||
|
simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]);
|
||||||
|
simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * 256), (simData.regionLocY * 256));
|
||||||
|
simData.serverIP = (string)responseData["sim_ip"];
|
||||||
|
simData.serverPort = Convert.ToUInt32((string)responseData["sim_port"]);
|
||||||
|
simData.httpPort = Convert.ToUInt32((string)responseData["http_port"]);
|
||||||
|
simData.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
|
||||||
|
simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/";
|
||||||
|
simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/";
|
||||||
|
simData.UUID = new LLUUID((string)responseData["region_UUID"]);
|
||||||
|
simData.regionName = (string)responseData["region_name"];
|
||||||
|
|
||||||
|
return simData;
|
||||||
|
}
|
||||||
|
public SimProfileData RequestSimProfileData(ulong region_handle, string gridserver_url, string gridserver_sendkey, string gridserver_recvkey)
|
||||||
|
{
|
||||||
|
Hashtable requestData = new Hashtable();
|
||||||
|
requestData["region_handle"] = region_handle.ToString();
|
||||||
|
requestData["authkey"] = gridserver_sendkey;
|
||||||
|
ArrayList SendParams = new ArrayList();
|
||||||
|
SendParams.Add(requestData);
|
||||||
|
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
|
||||||
|
XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
|
||||||
|
|
||||||
|
Hashtable responseData = (Hashtable)GridResp.Value;
|
||||||
|
|
||||||
|
if (responseData.ContainsKey("error"))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
SimProfileData simData = new SimProfileData();
|
||||||
|
simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]);
|
||||||
|
simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]);
|
||||||
|
simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * 256), (simData.regionLocY * 256));
|
||||||
|
simData.serverIP = (string)responseData["sim_ip"];
|
||||||
|
simData.serverPort = Convert.ToUInt32((string)responseData["sim_port"]);
|
||||||
|
simData.httpPort = Convert.ToUInt32((string)responseData["http_port"]);
|
||||||
|
simData.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
|
||||||
|
simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/";
|
||||||
|
simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/";
|
||||||
|
simData.UUID = new LLUUID((string)responseData["region_UUID"]);
|
||||||
|
simData.regionName = (string)responseData["region_name"];
|
||||||
|
|
||||||
|
return simData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,134 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An interface for connecting to user storage servers.
|
||||||
|
/// </summary>
|
||||||
|
public interface IUserData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a user profile from a database via their UUID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The accounts UUID</param>
|
||||||
|
/// <returns>The user data profile</returns>
|
||||||
|
UserProfileData getUserByUUID(LLUUID user);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a users profile by searching their username
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The users username</param>
|
||||||
|
/// <returns>The user data profile</returns>
|
||||||
|
UserProfileData getUserByName(string name);
|
||||||
|
|
||||||
|
/// <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</returns>
|
||||||
|
UserProfileData getUserByName(string fname, string lname);
|
||||||
|
|
||||||
|
/// <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</returns>
|
||||||
|
UserAgentData getAgentByUUID(LLUUID 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>
|
||||||
|
/// Adds a new User profile to the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">UserProfile to add</param>
|
||||||
|
void addNewUserProfile(UserProfileData user);
|
||||||
|
|
||||||
|
/// <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>
|
||||||
|
/// 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(LLUUID from, LLUUID 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(LLUUID from, LLUUID to, LLUUID inventory);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the plugin version
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Plugin version in MAJOR.MINOR.REVISION.BUILD format</returns>
|
||||||
|
string getVersion();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the plugin name
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Plugin name, eg MySQL User Provider</returns>
|
||||||
|
string getName();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialises the plugin (artificial constructor)
|
||||||
|
/// </summary>
|
||||||
|
void Initialise();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,182 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Data
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Information about a particular user known to the userserver
|
||||||
|
/// </summary>
|
||||||
|
public class UserProfileData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The ID value for this user
|
||||||
|
/// </summary>
|
||||||
|
public LLUUID UUID;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The first component of a users account name
|
||||||
|
/// </summary>
|
||||||
|
public string username;
|
||||||
|
/// <summary>
|
||||||
|
/// The second component of a users account name
|
||||||
|
/// </summary>
|
||||||
|
public string surname;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A salted hash containing the users password, in the format md5(md5(password) + ":" + salt)
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This is double MD5'd because the client sends an unsalted MD5 to the loginserver</remarks>
|
||||||
|
public string passwordHash;
|
||||||
|
/// <summary>
|
||||||
|
/// The salt used for the users hash, should be 32 bytes or longer
|
||||||
|
/// </summary>
|
||||||
|
public string passwordSalt;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The regionhandle of the users preffered home region. If multiple sims occupy the same spot, the grid may decide which region the user logs into
|
||||||
|
/// </summary>
|
||||||
|
public ulong homeRegion;
|
||||||
|
/// <summary>
|
||||||
|
/// The coordinates inside the region of the home location
|
||||||
|
/// </summary>
|
||||||
|
public LLVector3 homeLocation;
|
||||||
|
/// <summary>
|
||||||
|
/// Where the user will be looking when they rez.
|
||||||
|
/// </summary>
|
||||||
|
public LLVector3 homeLookAt;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A UNIX Timestamp (seconds since epoch) for the users creation
|
||||||
|
/// </summary>
|
||||||
|
public int created;
|
||||||
|
/// <summary>
|
||||||
|
/// A UNIX Timestamp for the users last login date / time
|
||||||
|
/// </summary>
|
||||||
|
public int lastLogin;
|
||||||
|
|
||||||
|
public LLUUID rootInventoryFolderID;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A URI to the users inventory server, used for foreigners and large grids
|
||||||
|
/// </summary>
|
||||||
|
public string userInventoryURI;
|
||||||
|
/// <summary>
|
||||||
|
/// A URI to the users asset server, used for foreigners and large grids.
|
||||||
|
/// </summary>
|
||||||
|
public string userAssetURI;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A uint mask containing the "I can do" fields of the users profile
|
||||||
|
/// </summary>
|
||||||
|
public uint profileCanDoMask;
|
||||||
|
/// <summary>
|
||||||
|
/// A uint mask containing the "I want to do" part of the users profile
|
||||||
|
/// </summary>
|
||||||
|
public uint profileWantDoMask; // Profile window "I want to" mask
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The about text listed in a users profile.
|
||||||
|
/// </summary>
|
||||||
|
public string profileAboutText;
|
||||||
|
/// <summary>
|
||||||
|
/// The first life about text listed in a users profile
|
||||||
|
/// </summary>
|
||||||
|
public string profileFirstText;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The profile image for an avatar stored on the asset server
|
||||||
|
/// </summary>
|
||||||
|
public LLUUID profileImage;
|
||||||
|
/// <summary>
|
||||||
|
/// The profile image for the users first life tab
|
||||||
|
/// </summary>
|
||||||
|
public LLUUID profileFirstImage;
|
||||||
|
/// <summary>
|
||||||
|
/// The users last registered agent (filled in on the user server)
|
||||||
|
/// </summary>
|
||||||
|
public UserAgentData currentAgent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Information about a users session
|
||||||
|
/// </summary>
|
||||||
|
public class UserAgentData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The UUID of the users avatar (not the agent!)
|
||||||
|
/// </summary>
|
||||||
|
public LLUUID UUID;
|
||||||
|
/// <summary>
|
||||||
|
/// The IP address of the user
|
||||||
|
/// </summary>
|
||||||
|
public string agentIP = String.Empty;
|
||||||
|
/// <summary>
|
||||||
|
/// The port of the user
|
||||||
|
/// </summary>
|
||||||
|
public uint agentPort;
|
||||||
|
/// <summary>
|
||||||
|
/// Is the user online?
|
||||||
|
/// </summary>
|
||||||
|
public bool agentOnline;
|
||||||
|
/// <summary>
|
||||||
|
/// The session ID for the user (also the agent ID)
|
||||||
|
/// </summary>
|
||||||
|
public LLUUID sessionID;
|
||||||
|
/// <summary>
|
||||||
|
/// The "secure" session ID for the user
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Not very secure. Dont rely on it for anything more than Linden Lab does.</remarks>
|
||||||
|
public LLUUID secureSessionID;
|
||||||
|
/// <summary>
|
||||||
|
/// The region the user logged into initially
|
||||||
|
/// </summary>
|
||||||
|
public LLUUID regionID;
|
||||||
|
/// <summary>
|
||||||
|
/// A unix timestamp from when the user logged in
|
||||||
|
/// </summary>
|
||||||
|
public int loginTime;
|
||||||
|
/// <summary>
|
||||||
|
/// When this agent expired and logged out, 0 if still online
|
||||||
|
/// </summary>
|
||||||
|
public int logoutTime;
|
||||||
|
/// <summary>
|
||||||
|
/// Current region the user is logged into
|
||||||
|
/// </summary>
|
||||||
|
public LLUUID currentRegion;
|
||||||
|
/// <summary>
|
||||||
|
/// Region handle of the current region the user is in
|
||||||
|
/// </summary>
|
||||||
|
public ulong currentHandle;
|
||||||
|
/// <summary>
|
||||||
|
/// The position of the user within the region
|
||||||
|
/// </summary>
|
||||||
|
public LLVector3 currentPos;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,130 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
using OpenSim.Framework.Interfaces;
|
||||||
|
using OpenSim.Framework.Types;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Types
|
||||||
|
{
|
||||||
|
public class AgentCircuitManager
|
||||||
|
{
|
||||||
|
public Dictionary<uint, AgentCircuitData> AgentCircuits = new Dictionary<uint, AgentCircuitData>();
|
||||||
|
|
||||||
|
public AgentCircuitManager()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode)
|
||||||
|
{
|
||||||
|
AgentCircuitData validcircuit = null;
|
||||||
|
if (this.AgentCircuits.ContainsKey(circuitcode))
|
||||||
|
{
|
||||||
|
validcircuit = this.AgentCircuits[circuitcode];
|
||||||
|
}
|
||||||
|
AuthenticateResponse user = new AuthenticateResponse();
|
||||||
|
if (validcircuit == null)
|
||||||
|
{
|
||||||
|
//don't have this circuit code in our list
|
||||||
|
user.Authorised = false;
|
||||||
|
return (user);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID))
|
||||||
|
{
|
||||||
|
user.Authorised = true;
|
||||||
|
user.LoginInfo = new Login();
|
||||||
|
user.LoginInfo.Agent = agentID;
|
||||||
|
user.LoginInfo.Session = sessionID;
|
||||||
|
user.LoginInfo.SecureSession = validcircuit.SecureSessionID;
|
||||||
|
user.LoginInfo.First = validcircuit.firstname;
|
||||||
|
user.LoginInfo.Last = validcircuit.lastname;
|
||||||
|
user.LoginInfo.InventoryFolder = validcircuit.InventoryFolder;
|
||||||
|
user.LoginInfo.BaseFolder = validcircuit.BaseFolder;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Invalid
|
||||||
|
user.Authorised = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void AddNewCircuit(uint circuitCode, AgentCircuitData agentData)
|
||||||
|
{
|
||||||
|
if (this.AgentCircuits.ContainsKey(circuitCode))
|
||||||
|
{
|
||||||
|
this.AgentCircuits[circuitCode] = agentData;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.AgentCircuits.Add(circuitCode, agentData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public LLVector3 GetPosition(uint circuitCode)
|
||||||
|
{
|
||||||
|
LLVector3 vec = new LLVector3();
|
||||||
|
if (this.AgentCircuits.ContainsKey(circuitCode))
|
||||||
|
{
|
||||||
|
vec = this.AgentCircuits[circuitCode].startpos;
|
||||||
|
}
|
||||||
|
return vec;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateAgentData(AgentCircuitData agentData)
|
||||||
|
{
|
||||||
|
if (this.AgentCircuits.ContainsKey((uint)agentData.circuitcode))
|
||||||
|
{
|
||||||
|
this.AgentCircuits[(uint)agentData.circuitcode].firstname = agentData.firstname;
|
||||||
|
this.AgentCircuits[(uint)agentData.circuitcode].lastname = agentData.lastname;
|
||||||
|
this.AgentCircuits[(uint)agentData.circuitcode].startpos = agentData.startpos;
|
||||||
|
// Console.WriteLine("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateAgentChildStatus(uint circuitcode, bool childstatus)
|
||||||
|
{
|
||||||
|
if (this.AgentCircuits.ContainsKey(circuitcode))
|
||||||
|
{
|
||||||
|
this.AgentCircuits[circuitcode].child = childstatus;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool GetAgentChildStatus(uint circuitcode)
|
||||||
|
{
|
||||||
|
if (this.AgentCircuits.ContainsKey(circuitcode))
|
||||||
|
{
|
||||||
|
return this.AgentCircuits[circuitcode].child;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,261 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
using libsecondlife.Packets;
|
||||||
|
using OpenSim.Framework.Types;
|
||||||
|
using OpenSim.Framework.Utilities;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Inventory
|
||||||
|
{
|
||||||
|
public class AgentInventory
|
||||||
|
{
|
||||||
|
//Holds the local copy of Inventory info for a agent
|
||||||
|
public Dictionary<LLUUID, InventoryFolder> InventoryFolders;
|
||||||
|
public Dictionary<LLUUID, InventoryItem> InventoryItems;
|
||||||
|
public InventoryFolder InventoryRoot;
|
||||||
|
public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server
|
||||||
|
public LLUUID AgentID;
|
||||||
|
public AvatarWearable[] Wearables;
|
||||||
|
|
||||||
|
public AgentInventory()
|
||||||
|
{
|
||||||
|
InventoryFolders = new Dictionary<LLUUID, InventoryFolder>();
|
||||||
|
InventoryItems = new Dictionary<LLUUID, InventoryItem>();
|
||||||
|
this.Initialise();
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void Initialise()
|
||||||
|
{
|
||||||
|
Wearables = new AvatarWearable[13];
|
||||||
|
for (int i = 0; i < 13; i++)
|
||||||
|
{
|
||||||
|
Wearables[i] = new AvatarWearable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateNewFolder(LLUUID folderID, ushort type)
|
||||||
|
{
|
||||||
|
InventoryFolder Folder = new InventoryFolder();
|
||||||
|
Folder.FolderID = folderID;
|
||||||
|
Folder.OwnerID = this.AgentID;
|
||||||
|
Folder.DefaultType = type;
|
||||||
|
this.InventoryFolders.Add(Folder.FolderID, Folder);
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateRootFolder(LLUUID newAgentID, bool createTextures)
|
||||||
|
{
|
||||||
|
this.AgentID = newAgentID;
|
||||||
|
InventoryRoot = new InventoryFolder();
|
||||||
|
InventoryRoot.FolderID = LLUUID.Random();
|
||||||
|
InventoryRoot.ParentID = new LLUUID();
|
||||||
|
InventoryRoot.Version = 1;
|
||||||
|
InventoryRoot.DefaultType = 8;
|
||||||
|
InventoryRoot.OwnerID = this.AgentID;
|
||||||
|
InventoryRoot.FolderName = "My Inventory";
|
||||||
|
InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot);
|
||||||
|
InventoryRoot.OwnerID = this.AgentID;
|
||||||
|
if (createTextures)
|
||||||
|
{
|
||||||
|
this.CreateNewFolder(LLUUID.Random(), 0, "Textures", InventoryRoot.FolderID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName)
|
||||||
|
{
|
||||||
|
InventoryFolder Folder = new InventoryFolder();
|
||||||
|
Folder.FolderID = folderID;
|
||||||
|
Folder.OwnerID = this.AgentID;
|
||||||
|
Folder.DefaultType = type;
|
||||||
|
Folder.FolderName = folderName;
|
||||||
|
this.InventoryFolders.Add(Folder.FolderID, Folder);
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parentID)
|
||||||
|
{
|
||||||
|
if (!this.InventoryFolders.ContainsKey(folderID))
|
||||||
|
{
|
||||||
|
System.Console.WriteLine("creating new folder called " + folderName + " in agents inventory");
|
||||||
|
InventoryFolder Folder = new InventoryFolder();
|
||||||
|
Folder.FolderID = folderID;
|
||||||
|
Folder.OwnerID = this.AgentID;
|
||||||
|
Folder.DefaultType = type;
|
||||||
|
Folder.FolderName = folderName;
|
||||||
|
Folder.ParentID = parentID;
|
||||||
|
this.InventoryFolders.Add(Folder.FolderID, Folder);
|
||||||
|
}
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasFolder(LLUUID folderID)
|
||||||
|
{
|
||||||
|
if (this.InventoryFolders.ContainsKey(folderID))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LLUUID GetFolderID(string folderName)
|
||||||
|
{
|
||||||
|
foreach (InventoryFolder inv in this.InventoryFolders.Values)
|
||||||
|
{
|
||||||
|
if (inv.FolderName == folderName)
|
||||||
|
{
|
||||||
|
return inv.FolderID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return LLUUID.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool UpdateItemAsset(LLUUID itemID, AssetBase asset)
|
||||||
|
{
|
||||||
|
if(this.InventoryItems.ContainsKey(itemID))
|
||||||
|
{
|
||||||
|
InventoryItem Item = this.InventoryItems[itemID];
|
||||||
|
Item.AssetID = asset.FullID;
|
||||||
|
System.Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated() + " so it now is set to asset " + asset.FullID.ToStringHyphenated());
|
||||||
|
//TODO need to update the rest of the info
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool UpdateItemDetails(LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet)
|
||||||
|
{
|
||||||
|
System.Console.WriteLine("updating inventory item details");
|
||||||
|
if (this.InventoryItems.ContainsKey(itemID))
|
||||||
|
{
|
||||||
|
System.Console.WriteLine("changing name to "+ Util.FieldToString(packet.Name));
|
||||||
|
InventoryItem Item = this.InventoryItems[itemID];
|
||||||
|
Item.Name = Util.FieldToString(packet.Name);
|
||||||
|
System.Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated());
|
||||||
|
//TODO need to update the rest of the info
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LLUUID AddToInventory(LLUUID folderID, AssetBase asset)
|
||||||
|
{
|
||||||
|
if (this.InventoryFolders.ContainsKey(folderID))
|
||||||
|
{
|
||||||
|
LLUUID NewItemID = LLUUID.Random();
|
||||||
|
|
||||||
|
InventoryItem Item = new InventoryItem();
|
||||||
|
Item.FolderID = folderID;
|
||||||
|
Item.OwnerID = AgentID;
|
||||||
|
Item.AssetID = asset.FullID;
|
||||||
|
Item.ItemID = NewItemID;
|
||||||
|
Item.Type = asset.Type;
|
||||||
|
Item.Name = asset.Name;
|
||||||
|
Item.Description = asset.Description;
|
||||||
|
Item.InvType = asset.InvType;
|
||||||
|
this.InventoryItems.Add(Item.ItemID, Item);
|
||||||
|
InventoryFolder Folder = InventoryFolders[Item.FolderID];
|
||||||
|
Folder.Items.Add(Item);
|
||||||
|
return (Item.ItemID);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DeleteFromInventory(LLUUID itemID)
|
||||||
|
{
|
||||||
|
bool res = false;
|
||||||
|
if (this.InventoryItems.ContainsKey(itemID))
|
||||||
|
{
|
||||||
|
InventoryItem item = this.InventoryItems[itemID];
|
||||||
|
this.InventoryItems.Remove(itemID);
|
||||||
|
foreach (InventoryFolder fold in InventoryFolders.Values)
|
||||||
|
{
|
||||||
|
if (fold.Items.Contains(item))
|
||||||
|
{
|
||||||
|
fold.Items.Remove(item);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class InventoryFolder
|
||||||
|
{
|
||||||
|
public List<InventoryItem> Items;
|
||||||
|
//public List<InventoryFolder> Subfolders;
|
||||||
|
public LLUUID FolderID;
|
||||||
|
public LLUUID OwnerID;
|
||||||
|
public LLUUID ParentID = LLUUID.Zero;
|
||||||
|
public string FolderName;
|
||||||
|
public ushort DefaultType;
|
||||||
|
public ushort Version;
|
||||||
|
|
||||||
|
public InventoryFolder()
|
||||||
|
{
|
||||||
|
Items = new List<InventoryItem>();
|
||||||
|
//Subfolders = new List<InventoryFolder>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class InventoryItem
|
||||||
|
{
|
||||||
|
public LLUUID FolderID;
|
||||||
|
public LLUUID OwnerID;
|
||||||
|
public LLUUID ItemID;
|
||||||
|
public LLUUID AssetID;
|
||||||
|
public LLUUID CreatorID;
|
||||||
|
public sbyte InvType;
|
||||||
|
public sbyte Type;
|
||||||
|
public string Name ="";
|
||||||
|
public string Description;
|
||||||
|
|
||||||
|
public InventoryItem()
|
||||||
|
{
|
||||||
|
this.CreatorID = LLUUID.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ExportString()
|
||||||
|
{
|
||||||
|
string typ = "notecard";
|
||||||
|
string result = "";
|
||||||
|
result += "\tinv_object\t0\n\t{\n";
|
||||||
|
result += "\t\tobj_id\t%s\n";
|
||||||
|
result += "\t\tparent_id\t"+ ItemID.ToString() +"\n";
|
||||||
|
result += "\t\ttype\t"+ typ +"\n";
|
||||||
|
result += "\t\tname\t" + Name+"|\n";
|
||||||
|
result += "\t}\n";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 System.Threading;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Utilities
|
||||||
|
{
|
||||||
|
public class BlockingQueue<T>
|
||||||
|
{
|
||||||
|
private Queue<T> _queue = new Queue<T>();
|
||||||
|
private object _queueSync = new object();
|
||||||
|
|
||||||
|
public void Enqueue(T value)
|
||||||
|
{
|
||||||
|
lock (_queueSync)
|
||||||
|
{
|
||||||
|
_queue.Enqueue(value);
|
||||||
|
Monitor.Pulse(_queueSync);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Dequeue()
|
||||||
|
{
|
||||||
|
lock (_queueSync)
|
||||||
|
{
|
||||||
|
if (_queue.Count < 1)
|
||||||
|
Monitor.Wait(_queueSync);
|
||||||
|
|
||||||
|
return _queue.Dequeue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using OpenSim.Framework.Interfaces;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework
|
||||||
|
{
|
||||||
|
public delegate void ForEachClientDelegate( IClientAPI client );
|
||||||
|
public class ClientManager
|
||||||
|
{
|
||||||
|
private Dictionary<uint, IClientAPI> m_clients;
|
||||||
|
|
||||||
|
public void ForEachClient(ForEachClientDelegate whatToDo)
|
||||||
|
{
|
||||||
|
foreach (IClientAPI client in m_clients.Values)
|
||||||
|
{
|
||||||
|
whatToDo(client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientManager()
|
||||||
|
{
|
||||||
|
m_clients = new Dictionary<uint, IClientAPI>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Remove(uint id)
|
||||||
|
{
|
||||||
|
m_clients.Remove(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(uint id, IClientAPI client )
|
||||||
|
{
|
||||||
|
m_clients.Add( id, client );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,387 @@
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
using libsecondlife;
|
||||||
|
|
||||||
|
using OpenSim.Framework.Console;
|
||||||
|
using OpenSim.Framework.Configuration.Interfaces;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Configuration
|
||||||
|
{
|
||||||
|
public class ConfigurationMember
|
||||||
|
{
|
||||||
|
public delegate bool ConfigurationOptionResult(string configuration_key, object configuration_result);
|
||||||
|
public delegate void ConfigurationOptionsLoad();
|
||||||
|
|
||||||
|
private List<ConfigurationOption> configurationOptions = new List<ConfigurationOption>();
|
||||||
|
private string configurationFilename = "";
|
||||||
|
private string configurationDescription = "";
|
||||||
|
|
||||||
|
private ConfigurationOptionsLoad loadFunction;
|
||||||
|
private ConfigurationOptionResult resultFunction;
|
||||||
|
|
||||||
|
private IGenericConfig configurationPlugin = null;
|
||||||
|
/// <summary>
|
||||||
|
/// This is the default configuration DLL loaded
|
||||||
|
/// </summary>
|
||||||
|
private string configurationPluginFilename = "OpenSim.Framework.Configuration.XML.dll";
|
||||||
|
public ConfigurationMember(string configuration_filename, string configuration_description, ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function)
|
||||||
|
{
|
||||||
|
this.configurationFilename = configuration_filename;
|
||||||
|
this.configurationDescription = configuration_description;
|
||||||
|
this.loadFunction = load_function;
|
||||||
|
this.resultFunction = result_function;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfigurationFilename(string filename)
|
||||||
|
{
|
||||||
|
configurationFilename = filename;
|
||||||
|
}
|
||||||
|
public void setConfigurationDescription(string desc)
|
||||||
|
{
|
||||||
|
configurationDescription = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfigurationResultFunction(ConfigurationOptionResult result)
|
||||||
|
{
|
||||||
|
resultFunction = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void forceConfigurationPluginLibrary(string dll_filename)
|
||||||
|
{
|
||||||
|
configurationPluginFilename = dll_filename;
|
||||||
|
}
|
||||||
|
public void addConfigurationOption(string configuration_key, ConfigurationOption.ConfigurationTypes configuration_type, string configuration_question, string configuration_default, bool use_default_no_prompt)
|
||||||
|
{
|
||||||
|
ConfigurationOption configOption = new ConfigurationOption();
|
||||||
|
configOption.configurationKey = configuration_key;
|
||||||
|
configOption.configurationQuestion = configuration_question;
|
||||||
|
configOption.configurationDefault = configuration_default;
|
||||||
|
configOption.configurationType = configuration_type;
|
||||||
|
configOption.configurationUseDefaultNoPrompt = use_default_no_prompt;
|
||||||
|
|
||||||
|
if ((configuration_key != "" && configuration_question != "") || (configuration_key != "" && use_default_no_prompt))
|
||||||
|
{
|
||||||
|
if (!configurationOptions.Contains(configOption))
|
||||||
|
{
|
||||||
|
configurationOptions.Add(configOption);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MainLog.Instance.Notice("Required fields for adding a configuration option is invalid. Will not add this option (" + configuration_key + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void performConfigurationRetrieve()
|
||||||
|
{
|
||||||
|
configurationPlugin = this.LoadConfigDll(configurationPluginFilename);
|
||||||
|
configurationOptions.Clear();
|
||||||
|
if(loadFunction == null)
|
||||||
|
{
|
||||||
|
MainLog.Instance.Error("Load Function for '" + this.configurationDescription + "' is null. Refusing to run configuration.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(resultFunction == null)
|
||||||
|
{
|
||||||
|
MainLog.Instance.Error("Result Function for '" + this.configurationDescription + "' is null. Refusing to run configuration.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MainLog.Instance.Verbose("Calling Configuration Load Function...");
|
||||||
|
this.loadFunction();
|
||||||
|
|
||||||
|
if(configurationOptions.Count <= 0)
|
||||||
|
{
|
||||||
|
MainLog.Instance.Error("No configuration options were specified for '" + this.configurationOptions + "'. Refusing to continue configuration.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool useFile = true;
|
||||||
|
if (configurationPlugin == null)
|
||||||
|
{
|
||||||
|
MainLog.Instance.Error("Configuration Plugin NOT LOADED!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configurationFilename.Trim() != "")
|
||||||
|
{
|
||||||
|
configurationPlugin.SetFileName(configurationFilename);
|
||||||
|
configurationPlugin.LoadData();
|
||||||
|
useFile = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MainLog.Instance.Notice("XML Configuration Filename is not valid; will not save to the file.");
|
||||||
|
useFile = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (ConfigurationOption configOption in configurationOptions)
|
||||||
|
{
|
||||||
|
bool convertSuccess = false;
|
||||||
|
object return_result = null;
|
||||||
|
string errorMessage = "";
|
||||||
|
bool ignoreNextFromConfig = false;
|
||||||
|
while (convertSuccess == false)
|
||||||
|
{
|
||||||
|
|
||||||
|
string console_result = "";
|
||||||
|
string attribute = null;
|
||||||
|
if (useFile)
|
||||||
|
{
|
||||||
|
if (!ignoreNextFromConfig)
|
||||||
|
{
|
||||||
|
attribute = configurationPlugin.GetAttribute(configOption.configurationKey);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ignoreNextFromConfig = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attribute == null)
|
||||||
|
{
|
||||||
|
if (configOption.configurationUseDefaultNoPrompt)
|
||||||
|
{
|
||||||
|
console_result = configOption.configurationDefault;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
if (configurationDescription.Trim() != "")
|
||||||
|
{
|
||||||
|
console_result = MainLog.Instance.CmdPrompt(configurationDescription + ": " + configOption.configurationQuestion, configOption.configurationDefault);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
console_result = MainLog.Instance.CmdPrompt(configOption.configurationQuestion, configOption.configurationDefault);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
console_result = attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (configOption.configurationType)
|
||||||
|
{
|
||||||
|
case ConfigurationOption.ConfigurationTypes.TYPE_STRING:
|
||||||
|
return_result = console_result;
|
||||||
|
convertSuccess = true;
|
||||||
|
break;
|
||||||
|
case ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY:
|
||||||
|
if (console_result.Length > 0)
|
||||||
|
{
|
||||||
|
return_result = console_result;
|
||||||
|
convertSuccess = true;
|
||||||
|
}
|
||||||
|
errorMessage = "a string that is not empty";
|
||||||
|
break;
|
||||||
|
case ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN:
|
||||||
|
bool boolResult;
|
||||||
|
if (Boolean.TryParse(console_result, out boolResult))
|
||||||
|
{
|
||||||
|
convertSuccess = true;
|
||||||
|
return_result = boolResult;
|
||||||
|
}
|
||||||
|
errorMessage = "'true' or 'false' (Boolean)";
|
||||||
|
break;
|
||||||
|
case ConfigurationOption.ConfigurationTypes.TYPE_BYTE:
|
||||||
|
byte byteResult;
|
||||||
|
if (Byte.TryParse(console_result, out byteResult))
|
||||||
|
{
|
||||||
|
convertSuccess = true;
|
||||||
|
return_result = byteResult;
|
||||||
|
}
|
||||||
|
errorMessage = "a byte (Byte)";
|
||||||
|
break;
|
||||||
|
case ConfigurationOption.ConfigurationTypes.TYPE_CHARACTER:
|
||||||
|
char charResult;
|
||||||
|
if (Char.TryParse(console_result, out charResult))
|
||||||
|
{
|
||||||
|
convertSuccess = true;
|
||||||
|
return_result = charResult;
|
||||||
|
}
|
||||||
|
errorMessage = "a character (Char)";
|
||||||
|
break;
|
||||||
|
case ConfigurationOption.ConfigurationTypes.TYPE_INT16:
|
||||||
|
short shortResult;
|
||||||
|
if (Int16.TryParse(console_result, out shortResult))
|
||||||
|
{
|
||||||
|
convertSuccess = true;
|
||||||
|
return_result = shortResult;
|
||||||
|
}
|
||||||
|
errorMessage = "a signed 32 bit integer (short)";
|
||||||
|
break;
|
||||||
|
case ConfigurationOption.ConfigurationTypes.TYPE_INT32:
|
||||||
|
int intResult;
|
||||||
|
if (Int32.TryParse(console_result, out intResult))
|
||||||
|
{
|
||||||
|
convertSuccess = true;
|
||||||
|
return_result = intResult;
|
||||||
|
|
||||||
|
}
|
||||||
|
errorMessage = "a signed 32 bit integer (int)";
|
||||||
|
break;
|
||||||
|
case ConfigurationOption.ConfigurationTypes.TYPE_INT64:
|
||||||
|
long longResult;
|
||||||
|
if (Int64.TryParse(console_result, out longResult))
|
||||||
|
{
|
||||||
|
convertSuccess = true;
|
||||||
|
return_result = longResult;
|
||||||
|
}
|
||||||
|
errorMessage = "a signed 32 bit integer (long)";
|
||||||
|
break;
|
||||||
|
case ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS:
|
||||||
|
IPAddress ipAddressResult;
|
||||||
|
if (IPAddress.TryParse(console_result, out ipAddressResult))
|
||||||
|
{
|
||||||
|
convertSuccess = true;
|
||||||
|
return_result = ipAddressResult;
|
||||||
|
}
|
||||||
|
errorMessage = "an IP Address (IPAddress)";
|
||||||
|
break;
|
||||||
|
case ConfigurationOption.ConfigurationTypes.TYPE_LLUUID:
|
||||||
|
LLUUID uuidResult;
|
||||||
|
if (LLUUID.TryParse(console_result, out uuidResult))
|
||||||
|
{
|
||||||
|
convertSuccess = true;
|
||||||
|
return_result = uuidResult;
|
||||||
|
}
|
||||||
|
errorMessage = "a UUID (LLUUID)";
|
||||||
|
break;
|
||||||
|
case ConfigurationOption.ConfigurationTypes.TYPE_LLVECTOR3:
|
||||||
|
LLVector3 vectorResult;
|
||||||
|
if (LLVector3.TryParse(console_result, out vectorResult))
|
||||||
|
{
|
||||||
|
convertSuccess = true;
|
||||||
|
return_result = vectorResult;
|
||||||
|
}
|
||||||
|
errorMessage = "a vector (LLVector3)";
|
||||||
|
break;
|
||||||
|
case ConfigurationOption.ConfigurationTypes.TYPE_UINT16:
|
||||||
|
ushort ushortResult;
|
||||||
|
if (UInt16.TryParse(console_result, out ushortResult))
|
||||||
|
{
|
||||||
|
convertSuccess = true;
|
||||||
|
return_result = ushortResult;
|
||||||
|
}
|
||||||
|
errorMessage = "an unsigned 16 bit integer (ushort)";
|
||||||
|
break;
|
||||||
|
case ConfigurationOption.ConfigurationTypes.TYPE_UINT32:
|
||||||
|
uint uintResult;
|
||||||
|
if (UInt32.TryParse(console_result, out uintResult))
|
||||||
|
{
|
||||||
|
convertSuccess = true;
|
||||||
|
return_result = uintResult;
|
||||||
|
|
||||||
|
}
|
||||||
|
errorMessage = "an unsigned 32 bit integer (uint)";
|
||||||
|
break;
|
||||||
|
case ConfigurationOption.ConfigurationTypes.TYPE_UINT64:
|
||||||
|
ulong ulongResult;
|
||||||
|
if (UInt64.TryParse(console_result, out ulongResult))
|
||||||
|
{
|
||||||
|
convertSuccess = true;
|
||||||
|
return_result = ulongResult;
|
||||||
|
}
|
||||||
|
errorMessage = "an unsigned 64 bit integer (ulong)";
|
||||||
|
break;
|
||||||
|
case ConfigurationOption.ConfigurationTypes.TYPE_FLOAT:
|
||||||
|
float floatResult;
|
||||||
|
if (float.TryParse(console_result, out floatResult))
|
||||||
|
{
|
||||||
|
convertSuccess = true;
|
||||||
|
return_result = floatResult;
|
||||||
|
}
|
||||||
|
errorMessage = "a single-precision floating point number (float)";
|
||||||
|
break;
|
||||||
|
case ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE:
|
||||||
|
double doubleResult;
|
||||||
|
if (Double.TryParse(console_result, out doubleResult))
|
||||||
|
{
|
||||||
|
convertSuccess = true;
|
||||||
|
return_result = doubleResult;
|
||||||
|
}
|
||||||
|
errorMessage = "an double-precision floating point number (double)";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (convertSuccess)
|
||||||
|
{
|
||||||
|
if (useFile)
|
||||||
|
{
|
||||||
|
configurationPlugin.SetAttribute(configOption.configurationKey, console_result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!this.resultFunction(configOption.configurationKey, return_result))
|
||||||
|
{
|
||||||
|
Console.MainLog.Instance.Notice("The handler for the last configuration option denied that input, please try again.");
|
||||||
|
convertSuccess = false;
|
||||||
|
ignoreNextFromConfig = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (configOption.configurationUseDefaultNoPrompt)
|
||||||
|
{
|
||||||
|
MainLog.Instance.Error("Default given for '" + configOption.configurationKey + "' is not valid; the configuration result must be " + errorMessage + ". Will skip this option...");
|
||||||
|
convertSuccess = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MainLog.Instance.Warn("configuration","Incorrect result given, the configuration option must be " + errorMessage + ". Prompting for same option...");
|
||||||
|
ignoreNextFromConfig = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(useFile)
|
||||||
|
{
|
||||||
|
configurationPlugin.Commit();
|
||||||
|
configurationPlugin.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IGenericConfig LoadConfigDll(string dllName)
|
||||||
|
{
|
||||||
|
Assembly pluginAssembly = Assembly.LoadFrom(dllName);
|
||||||
|
IGenericConfig plug = null;
|
||||||
|
|
||||||
|
foreach (Type pluginType in pluginAssembly.GetTypes())
|
||||||
|
{
|
||||||
|
if (pluginType.IsPublic)
|
||||||
|
{
|
||||||
|
if (!pluginType.IsAbstract)
|
||||||
|
{
|
||||||
|
Type typeInterface = pluginType.GetInterface("IGenericConfig", true);
|
||||||
|
|
||||||
|
if (typeInterface != null)
|
||||||
|
{
|
||||||
|
plug = (IGenericConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pluginAssembly = null;
|
||||||
|
return plug;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void forceSetConfigurationOption(string configuration_key, string configuration_value)
|
||||||
|
{
|
||||||
|
this.configurationPlugin.LoadData();
|
||||||
|
this.configurationPlugin.SetAttribute(configuration_key, configuration_value);
|
||||||
|
this.configurationPlugin.Commit();
|
||||||
|
this.configurationPlugin.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Configuration
|
||||||
|
{
|
||||||
|
public class ConfigurationOption
|
||||||
|
{
|
||||||
|
public enum ConfigurationTypes
|
||||||
|
{
|
||||||
|
TYPE_STRING,
|
||||||
|
TYPE_STRING_NOT_EMPTY,
|
||||||
|
TYPE_UINT16,
|
||||||
|
TYPE_UINT32,
|
||||||
|
TYPE_UINT64,
|
||||||
|
TYPE_INT16,
|
||||||
|
TYPE_INT32,
|
||||||
|
TYPE_INT64,
|
||||||
|
TYPE_IP_ADDRESS,
|
||||||
|
TYPE_CHARACTER,
|
||||||
|
TYPE_BOOLEAN,
|
||||||
|
TYPE_BYTE,
|
||||||
|
TYPE_LLUUID,
|
||||||
|
TYPE_LLVECTOR3,
|
||||||
|
TYPE_FLOAT,
|
||||||
|
TYPE_DOUBLE
|
||||||
|
};
|
||||||
|
|
||||||
|
public string configurationKey = "";
|
||||||
|
public string configurationQuestion = "";
|
||||||
|
public string configurationDefault = "";
|
||||||
|
|
||||||
|
public ConfigurationTypes configurationType = ConfigurationTypes.TYPE_STRING;
|
||||||
|
public bool configurationUseDefaultNoPrompt = false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Configuration
|
||||||
|
{
|
||||||
|
public class GridConfig
|
||||||
|
{
|
||||||
|
public string GridOwner = "";
|
||||||
|
public string DefaultAssetServer = "";
|
||||||
|
public string AssetSendKey = "";
|
||||||
|
public string AssetRecvKey = "";
|
||||||
|
|
||||||
|
public string DefaultUserServer = "";
|
||||||
|
public string UserSendKey = "";
|
||||||
|
public string UserRecvKey = "";
|
||||||
|
|
||||||
|
public string SimSendKey = "";
|
||||||
|
public string SimRecvKey = "";
|
||||||
|
|
||||||
|
public string DatabaseProvider = "";
|
||||||
|
|
||||||
|
private ConfigurationMember configMember;
|
||||||
|
public GridConfig(string description, string filename)
|
||||||
|
{
|
||||||
|
configMember = new ConfigurationMember(filename, description, this.loadConfigurationOptions, this.handleIncomingConfiguration);
|
||||||
|
configMember.performConfigurationRetrieve();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadConfigurationOptions()
|
||||||
|
{
|
||||||
|
configMember.addConfigurationOption("grid_owner", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "OGS Grid Owner", "OGS development team", false);
|
||||||
|
configMember.addConfigurationOption("default_asset_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Asset Server URI", "http://127.0.0.1:8003/", false);
|
||||||
|
configMember.addConfigurationOption("asset_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to asset server", "null", false);
|
||||||
|
configMember.addConfigurationOption("asset_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from asset server", "null", false);
|
||||||
|
|
||||||
|
configMember.addConfigurationOption("default_user_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default User Server URI", "http://127.0.0.1:8002/", false);
|
||||||
|
configMember.addConfigurationOption("user_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to user server", "null", false);
|
||||||
|
configMember.addConfigurationOption("user_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from user server", "null", false);
|
||||||
|
|
||||||
|
configMember.addConfigurationOption("sim_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to a simulator", "null", false);
|
||||||
|
configMember.addConfigurationOption("sim_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from a simulator", "null", false);
|
||||||
|
configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
|
||||||
|
{
|
||||||
|
switch (configuration_key)
|
||||||
|
{
|
||||||
|
case "grid_owner":
|
||||||
|
this.GridOwner = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
case "default_asset_server":
|
||||||
|
this.DefaultAssetServer = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
case "asset_send_key":
|
||||||
|
this.AssetSendKey = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
case "asset_recv_key":
|
||||||
|
this.AssetRecvKey = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
case "default_user_server":
|
||||||
|
this.DefaultUserServer = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
case "user_send_key":
|
||||||
|
this.UserSendKey = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
case "user_recv_key":
|
||||||
|
this.UserRecvKey = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
case "sim_send_key":
|
||||||
|
this.SimSendKey = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
case "sim_recv_key":
|
||||||
|
this.SimRecvKey = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
case "database_provider":
|
||||||
|
this.DatabaseProvider = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
namespace OpenSim.Framework.Configuration.Interfaces
|
||||||
|
{
|
||||||
|
public interface IGenericConfig
|
||||||
|
{
|
||||||
|
void SetFileName(string fileName);
|
||||||
|
void LoadData();
|
||||||
|
void LoadDataFromString(string data);
|
||||||
|
string GetAttribute(string attributeName);
|
||||||
|
bool SetAttribute(string attributeName, string attributeValue);
|
||||||
|
void Commit();
|
||||||
|
void Close();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Configuration
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// UserConfig -- For User Server Configuration
|
||||||
|
/// </summary>
|
||||||
|
public class UserConfig
|
||||||
|
{
|
||||||
|
public string DefaultStartupMsg = "";
|
||||||
|
public string GridServerURL = "";
|
||||||
|
public string GridSendKey = "";
|
||||||
|
public string GridRecvKey = "";
|
||||||
|
|
||||||
|
public string DatabaseProvider = "";
|
||||||
|
|
||||||
|
private ConfigurationMember configMember;
|
||||||
|
|
||||||
|
public UserConfig(string description, string filename)
|
||||||
|
{
|
||||||
|
configMember = new ConfigurationMember(filename, description, this.loadConfigurationOptions, this.handleIncomingConfiguration);
|
||||||
|
configMember.performConfigurationRetrieve();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadConfigurationOptions()
|
||||||
|
{
|
||||||
|
configMember.addConfigurationOption("default_startup_message", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Startup Message", "Welcome to OGS",false);
|
||||||
|
|
||||||
|
configMember.addConfigurationOption("default_grid_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Grid Server URI", "http://127.0.0.1:8001/", false);
|
||||||
|
configMember.addConfigurationOption("grid_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to grid server", "null", false);
|
||||||
|
configMember.addConfigurationOption("grid_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from grid server", "null", false);
|
||||||
|
configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
|
||||||
|
{
|
||||||
|
switch (configuration_key)
|
||||||
|
{
|
||||||
|
case "default_startup_message":
|
||||||
|
this.DefaultStartupMsg = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
case "default_grid_server":
|
||||||
|
this.GridServerURL = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
case "grid_send_key":
|
||||||
|
this.GridSendKey = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
case "grid_recv_key":
|
||||||
|
this.GridRecvKey = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
case "database_provider":
|
||||||
|
this.DatabaseProvider = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
using OpenSim.Framework.Interfaces;
|
||||||
|
using OpenSim.Framework.Types;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework
|
||||||
|
{
|
||||||
|
public delegate void ExpectUserDelegate(ulong regionHandle, AgentCircuitData agent);
|
||||||
|
public delegate void UpdateNeighbours(List<RegionInfo> neighbours);
|
||||||
|
public delegate void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying);
|
||||||
|
public delegate void AcknowledgeAgentCross(ulong regionHandle, LLUUID agentID);
|
||||||
|
|
||||||
|
public interface IRegionCommsListener
|
||||||
|
{
|
||||||
|
event ExpectUserDelegate OnExpectUser;
|
||||||
|
event GenericCall2 OnExpectChildAgent;
|
||||||
|
event AgentCrossing OnAvatarCrossingIntoRegion;
|
||||||
|
event AcknowledgeAgentCross OnAcknowledgeAgentCrossed;
|
||||||
|
event UpdateNeighbours OnNeighboursUpdate;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Types;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Interfaces
|
||||||
|
{
|
||||||
|
public class AuthenticateResponse
|
||||||
|
{
|
||||||
|
public bool Authorised;
|
||||||
|
public Login LoginInfo;
|
||||||
|
|
||||||
|
public AuthenticateResponse()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
using OpenSim.Framework.Types;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Interfaces
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Description of IAssetServer.
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
public interface IAssetServer
|
||||||
|
{
|
||||||
|
void SetReceiver(IAssetReceiver receiver);
|
||||||
|
void RequestAsset(LLUUID assetID, bool isTexture);
|
||||||
|
void UpdateAsset(AssetBase asset);
|
||||||
|
void UploadNewAsset(AssetBase asset);
|
||||||
|
void SetServerInfo(string ServerUrl, string ServerKey);
|
||||||
|
void Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// could change to delegate?
|
||||||
|
public interface IAssetReceiver
|
||||||
|
{
|
||||||
|
void AssetReceived(AssetBase asset, bool IsTexture);
|
||||||
|
void AssetNotFound(AssetBase asset);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IAssetPlugin
|
||||||
|
{
|
||||||
|
IAssetServer GetAssetServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct ARequest
|
||||||
|
{
|
||||||
|
public LLUUID AssetID;
|
||||||
|
public bool IsTexture;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,233 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 System.Net;
|
||||||
|
using libsecondlife;
|
||||||
|
using libsecondlife.Packets;
|
||||||
|
using OpenSim.Framework.Types;
|
||||||
|
using OpenSim.Framework.Data;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Interfaces
|
||||||
|
{
|
||||||
|
public delegate void ChatFromViewer(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID);
|
||||||
|
public delegate void ImprovedInstantMessage(LLUUID fromAgentID, LLUUID toAgentID, uint timestamp, string fromAgentName, string message); // Cut down from full list
|
||||||
|
public delegate void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos);
|
||||||
|
public delegate void ModifyTerrain(float height, float seconds, byte size, byte action, float north, float west, IClientAPI remoteClient);
|
||||||
|
public delegate void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam);
|
||||||
|
public delegate void StartAnim(LLUUID animID, int seq);
|
||||||
|
public delegate void LinkObjects(uint parent, List<uint> children);
|
||||||
|
public delegate void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY);
|
||||||
|
public delegate void TeleportLocationRequest(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags);
|
||||||
|
public delegate void DisconnectUser();
|
||||||
|
public delegate void RequestAvatarProperties(IClientAPI remoteClient, LLUUID avatarID);
|
||||||
|
|
||||||
|
public delegate void GenericCall(IClientAPI remoteClient);
|
||||||
|
public delegate void GenericCall2();
|
||||||
|
public delegate void GenericCall3(Packet packet); // really don't want to be passing packets in these events, so this is very temporary.
|
||||||
|
public delegate void GenericCall4(Packet packet, IClientAPI remoteClient);
|
||||||
|
public delegate void GenericCall5(IClientAPI remoteClient, bool status);
|
||||||
|
public delegate void GenericCall6(LLUUID uid);
|
||||||
|
public delegate void GenericCall7(uint localID, string message);
|
||||||
|
|
||||||
|
public delegate void UpdateShape(uint localID, ObjectShapePacket.ObjectDataBlock shapeBlock);
|
||||||
|
public delegate void ObjectExtraParams(uint localID, ushort type, bool inUse, byte[] data);
|
||||||
|
public delegate void ObjectSelect(uint localID, IClientAPI remoteClient);
|
||||||
|
public delegate void ObjectDeselect(uint localID, IClientAPI remoteClient);
|
||||||
|
public delegate void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient);
|
||||||
|
public delegate void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient);
|
||||||
|
public delegate void UpdateVector(uint localID, LLVector3 pos, IClientAPI remoteClient);
|
||||||
|
public delegate void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient);
|
||||||
|
public delegate void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient);
|
||||||
|
public delegate void UpdatePrimGroupRotation(uint localID,LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient);
|
||||||
|
public delegate void ObjectDuplicate(uint localID, LLVector3 offset, uint dupeFlags);
|
||||||
|
public delegate void StatusChange(bool status);
|
||||||
|
public delegate void NewAvatar(IClientAPI remoteClient, LLUUID agentID, bool status);
|
||||||
|
public delegate void UpdateAgent(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation);
|
||||||
|
public delegate void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 grapPos, IClientAPI remoteClient);
|
||||||
|
|
||||||
|
public delegate void ParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client);
|
||||||
|
public delegate void ParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client);
|
||||||
|
public delegate void ParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client);
|
||||||
|
public delegate void ParcelPropertiesUpdateRequest(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client);
|
||||||
|
public delegate void ParcelSelectObjects(int land_local_id, int request_type, IClientAPI remote_client);
|
||||||
|
public delegate void ParcelObjectOwnerRequest(int local_id, IClientAPI remote_client);
|
||||||
|
public delegate void EstateOwnerMessageRequest(EstateOwnerMessagePacket packet, IClientAPI remote_client);
|
||||||
|
|
||||||
|
public delegate void UUIDNameRequest(LLUUID id, IClientAPI remote_client);
|
||||||
|
|
||||||
|
public delegate void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape);
|
||||||
|
|
||||||
|
public delegate void CreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID);
|
||||||
|
public delegate void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask);
|
||||||
|
public delegate void FetchInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder);
|
||||||
|
public delegate void FetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID);
|
||||||
|
public delegate void RequestTaskInventory(IClientAPI remoteClient, uint localID);
|
||||||
|
|
||||||
|
public delegate void UDPAssetUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data);
|
||||||
|
public delegate void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data);
|
||||||
|
public delegate void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName);
|
||||||
|
|
||||||
|
public interface IClientAPI
|
||||||
|
{
|
||||||
|
event ImprovedInstantMessage OnInstantMessage;
|
||||||
|
event ChatFromViewer OnChatFromViewer;
|
||||||
|
event RezObject OnRezObject;
|
||||||
|
event ModifyTerrain OnModifyTerrain;
|
||||||
|
event SetAppearance OnSetAppearance;
|
||||||
|
event StartAnim OnStartAnim;
|
||||||
|
event LinkObjects OnLinkObjects;
|
||||||
|
event RequestMapBlocks OnRequestMapBlocks;
|
||||||
|
event TeleportLocationRequest OnTeleportLocationRequest;
|
||||||
|
event DisconnectUser OnDisconnectUser;
|
||||||
|
event RequestAvatarProperties OnRequestAvatarProperties;
|
||||||
|
|
||||||
|
event GenericCall4 OnDeRezObject;
|
||||||
|
event GenericCall OnRegionHandShakeReply;
|
||||||
|
event GenericCall OnRequestWearables;
|
||||||
|
event GenericCall2 OnCompleteMovementToRegion;
|
||||||
|
event UpdateAgent OnAgentUpdate;
|
||||||
|
event GenericCall OnRequestAvatarsData;
|
||||||
|
event AddNewPrim OnAddPrim;
|
||||||
|
event ObjectDuplicate OnObjectDuplicate;
|
||||||
|
event UpdateVector OnGrabObject;
|
||||||
|
event ObjectSelect OnDeGrabObject;
|
||||||
|
event MoveObject OnGrabUpdate;
|
||||||
|
|
||||||
|
event UpdateShape OnUpdatePrimShape;
|
||||||
|
event ObjectExtraParams OnUpdateExtraParams;
|
||||||
|
event ObjectSelect OnObjectSelect;
|
||||||
|
event ObjectDeselect OnObjectDeselect;
|
||||||
|
event GenericCall7 OnObjectDescription;
|
||||||
|
event GenericCall7 OnObjectName;
|
||||||
|
event UpdatePrimFlags OnUpdatePrimFlags;
|
||||||
|
event UpdatePrimTexture OnUpdatePrimTexture;
|
||||||
|
event UpdateVector OnUpdatePrimGroupPosition;
|
||||||
|
event UpdateVector OnUpdatePrimSinglePosition;
|
||||||
|
event UpdatePrimRotation OnUpdatePrimGroupRotation;
|
||||||
|
event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
|
||||||
|
event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
|
||||||
|
event UpdateVector OnUpdatePrimScale;
|
||||||
|
event StatusChange OnChildAgentStatus;
|
||||||
|
event GenericCall2 OnStopMovement;
|
||||||
|
event GenericCall6 OnRemoveAvatar;
|
||||||
|
|
||||||
|
event CreateNewInventoryItem OnCreateNewInventoryItem;
|
||||||
|
event CreateInventoryFolder OnCreateNewInventoryFolder;
|
||||||
|
event FetchInventoryDescendents OnFetchInventoryDescendents;
|
||||||
|
event FetchInventory OnFetchInventory;
|
||||||
|
event RequestTaskInventory OnRequestTaskInventory;
|
||||||
|
event UDPAssetUploadRequest OnAssetUploadRequest;
|
||||||
|
event XferReceive OnXferReceive;
|
||||||
|
event RequestXfer OnRequestXfer;
|
||||||
|
|
||||||
|
event UUIDNameRequest OnNameFromUUIDRequest;
|
||||||
|
|
||||||
|
event ParcelPropertiesRequest OnParcelPropertiesRequest;
|
||||||
|
event ParcelDivideRequest OnParcelDivideRequest;
|
||||||
|
event ParcelJoinRequest OnParcelJoinRequest;
|
||||||
|
event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
|
||||||
|
event ParcelSelectObjects OnParcelSelectObjects;
|
||||||
|
event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
|
||||||
|
event EstateOwnerMessageRequest OnEstateOwnerMessage;
|
||||||
|
|
||||||
|
LLVector3 StartPos
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
LLUUID AgentId
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
LLUUID SessionId
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
string FirstName
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
string LastName
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutPacket(Packet newPack);
|
||||||
|
void SendWearables(AvatarWearable[] wearables);
|
||||||
|
void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry);
|
||||||
|
void SendStartPingCheck(byte seq);
|
||||||
|
void SendKillObject(ulong regionHandle, uint localID);
|
||||||
|
void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId);
|
||||||
|
void SendRegionHandshake(RegionInfo regionInfo);
|
||||||
|
void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID);
|
||||||
|
void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID);
|
||||||
|
void SendInstantMessage(string message, LLUUID target, string fromName);
|
||||||
|
void SendLayerData(float[] map);
|
||||||
|
void SendLayerData(int px, int py, float[] map);
|
||||||
|
void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look);
|
||||||
|
void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint );
|
||||||
|
AgentCircuitData RequestClientInfo();
|
||||||
|
void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint newRegionExternalEndPoint, string capsURL );
|
||||||
|
void SendMapBlock(List<MapBlockData> mapBlocks);
|
||||||
|
void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags);
|
||||||
|
void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL);
|
||||||
|
void SendTeleportCancel();
|
||||||
|
void SendTeleportLocationStart();
|
||||||
|
void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance);
|
||||||
|
|
||||||
|
void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry);
|
||||||
|
void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity);
|
||||||
|
|
||||||
|
void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint);
|
||||||
|
void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID, byte[] particleSystem, LLQuaternion rotation);
|
||||||
|
void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation);
|
||||||
|
|
||||||
|
void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items);
|
||||||
|
void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item);
|
||||||
|
void SendInventoryItemUpdate(InventoryItemBase Item);
|
||||||
|
void SendRemoveInventoryItem(LLUUID itemID);
|
||||||
|
void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName);
|
||||||
|
void SendXferPacket(ulong xferID, uint packet, byte[] data);
|
||||||
|
|
||||||
|
void SendPreLoadSound(LLUUID objectID, LLUUID ownerID, LLUUID soundID);
|
||||||
|
void SendPlayAttachedSound(LLUUID soundID, LLUUID objectID, LLUUID ownerID, float gain, byte flags);
|
||||||
|
|
||||||
|
void SendNameReply(LLUUID profileId, string firstname, string lastname);
|
||||||
|
void SendAlertMessage(string message);
|
||||||
|
void SendAgentAlertMessage(string message, bool modal);
|
||||||
|
void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url);
|
||||||
|
bool AddMoney( int debit );
|
||||||
|
|
||||||
|
void SendViewerTime(int phase);
|
||||||
|
void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, LLUUID partnerID);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
using OpenSim.Framework.Types;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Interfaces
|
||||||
|
{
|
||||||
|
public interface IScene
|
||||||
|
{
|
||||||
|
void AddNewClient(IClientAPI client, bool child);
|
||||||
|
void RemoveClient(LLUUID agentID);
|
||||||
|
|
||||||
|
RegionInfo RegionInfo { get; }
|
||||||
|
object SyncRoot { get; }
|
||||||
|
uint NextLocalId { get; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,165 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net;
|
||||||
|
using OpenSim.Framework.Interfaces;
|
||||||
|
using OpenSim.Framework.Types;
|
||||||
|
using OpenSim.Framework.Data;
|
||||||
|
using libsecondlife;
|
||||||
|
using libsecondlife.Packets;
|
||||||
|
|
||||||
|
|
||||||
|
namespace OpenSim.Framework
|
||||||
|
{
|
||||||
|
public class NullClientAPI : IClientAPI
|
||||||
|
{
|
||||||
|
#pragma warning disable 67
|
||||||
|
public event ImprovedInstantMessage OnInstantMessage;
|
||||||
|
public event ChatFromViewer OnChatFromViewer;
|
||||||
|
public event RezObject OnRezObject;
|
||||||
|
public event ModifyTerrain OnModifyTerrain;
|
||||||
|
public event SetAppearance OnSetAppearance;
|
||||||
|
public event StartAnim OnStartAnim;
|
||||||
|
public event LinkObjects OnLinkObjects;
|
||||||
|
public event RequestMapBlocks OnRequestMapBlocks;
|
||||||
|
public event TeleportLocationRequest OnTeleportLocationRequest;
|
||||||
|
public event DisconnectUser OnDisconnectUser;
|
||||||
|
public event RequestAvatarProperties OnRequestAvatarProperties;
|
||||||
|
|
||||||
|
public event GenericCall4 OnDeRezObject;
|
||||||
|
public event GenericCall OnRegionHandShakeReply;
|
||||||
|
public event GenericCall OnRequestWearables;
|
||||||
|
public event GenericCall2 OnCompleteMovementToRegion;
|
||||||
|
public event UpdateAgent OnAgentUpdate;
|
||||||
|
public event GenericCall OnRequestAvatarsData;
|
||||||
|
public event AddNewPrim OnAddPrim;
|
||||||
|
public event ObjectDuplicate OnObjectDuplicate;
|
||||||
|
public event UpdateVector OnGrabObject;
|
||||||
|
public event ObjectSelect OnDeGrabObject;
|
||||||
|
public event MoveObject OnGrabUpdate;
|
||||||
|
|
||||||
|
public event UpdateShape OnUpdatePrimShape;
|
||||||
|
public event ObjectExtraParams OnUpdateExtraParams;
|
||||||
|
public event ObjectSelect OnObjectSelect;
|
||||||
|
public event GenericCall7 OnObjectDescription;
|
||||||
|
public event GenericCall7 OnObjectName;
|
||||||
|
public event UpdatePrimFlags OnUpdatePrimFlags;
|
||||||
|
public event UpdatePrimTexture OnUpdatePrimTexture;
|
||||||
|
public event UpdateVector OnUpdatePrimGroupPosition;
|
||||||
|
public event UpdateVector OnUpdatePrimSinglePosition;
|
||||||
|
public event UpdatePrimRotation OnUpdatePrimGroupRotation;
|
||||||
|
public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
|
||||||
|
public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
|
||||||
|
public event UpdateVector OnUpdatePrimScale;
|
||||||
|
public event StatusChange OnChildAgentStatus;
|
||||||
|
public event GenericCall2 OnStopMovement;
|
||||||
|
public event GenericCall6 OnRemoveAvatar;
|
||||||
|
|
||||||
|
public event CreateNewInventoryItem OnCreateNewInventoryItem;
|
||||||
|
public event CreateInventoryFolder OnCreateNewInventoryFolder;
|
||||||
|
public event FetchInventoryDescendents OnFetchInventoryDescendents;
|
||||||
|
public event FetchInventory OnFetchInventory;
|
||||||
|
public event RequestTaskInventory OnRequestTaskInventory;
|
||||||
|
public event UDPAssetUploadRequest OnAssetUploadRequest;
|
||||||
|
public event XferReceive OnXferReceive;
|
||||||
|
public event RequestXfer OnRequestXfer;
|
||||||
|
|
||||||
|
public event UUIDNameRequest OnNameFromUUIDRequest;
|
||||||
|
|
||||||
|
public event ParcelPropertiesRequest OnParcelPropertiesRequest;
|
||||||
|
public event ParcelDivideRequest OnParcelDivideRequest;
|
||||||
|
public event ParcelJoinRequest OnParcelJoinRequest;
|
||||||
|
public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
|
||||||
|
public event ParcelSelectObjects OnParcelSelectObjects;
|
||||||
|
public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
|
||||||
|
public event ObjectDeselect OnObjectDeselect;
|
||||||
|
|
||||||
|
|
||||||
|
public event EstateOwnerMessageRequest OnEstateOwnerMessage;
|
||||||
|
#pragma warning restore 67
|
||||||
|
|
||||||
|
private LLUUID m_uuid = LLUUID.Random();
|
||||||
|
public virtual LLVector3 StartPos
|
||||||
|
{
|
||||||
|
get { return new LLVector3(); }
|
||||||
|
set { }
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual LLUUID AgentId
|
||||||
|
{
|
||||||
|
get { return m_uuid; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public LLUUID SessionId
|
||||||
|
{
|
||||||
|
get { return LLUUID.Zero; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual string FirstName
|
||||||
|
{
|
||||||
|
get { return ""; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual string LastName
|
||||||
|
{
|
||||||
|
get { return ""; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public NullClientAPI()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OutPacket(Packet newPack){}
|
||||||
|
public virtual void SendWearables(AvatarWearable[] wearables){}
|
||||||
|
public virtual void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry) { }
|
||||||
|
public virtual void SendStartPingCheck(byte seq){}
|
||||||
|
public virtual void SendKillObject(ulong regionHandle, uint localID){}
|
||||||
|
public virtual void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId){}
|
||||||
|
public virtual void SendRegionHandshake(RegionInfo regionInfo){}
|
||||||
|
public virtual void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID){}
|
||||||
|
public virtual void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID){}
|
||||||
|
public virtual void SendInstantMessage(string message, LLUUID target, string fromName){}
|
||||||
|
public virtual void SendLayerData(float[] map){}
|
||||||
|
public virtual void SendLayerData(int px, int py, float[] map){}
|
||||||
|
public virtual void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look){}
|
||||||
|
public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint){}
|
||||||
|
public virtual AgentCircuitData RequestClientInfo() { return new AgentCircuitData(); }
|
||||||
|
public virtual void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint newRegionExternalEndPoint, string capsURL){}
|
||||||
|
public virtual void SendMapBlock(List<MapBlockData> mapBlocks){}
|
||||||
|
public virtual void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags){}
|
||||||
|
public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL){}
|
||||||
|
public virtual void SendTeleportCancel(){}
|
||||||
|
public virtual void SendTeleportLocationStart(){}
|
||||||
|
public virtual void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance){}
|
||||||
|
|
||||||
|
public virtual void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry){}
|
||||||
|
public virtual void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity){}
|
||||||
|
|
||||||
|
public virtual void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint){}
|
||||||
|
public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID, byte[] particleSystem, LLQuaternion rotation){}
|
||||||
|
public virtual void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation){}
|
||||||
|
|
||||||
|
public virtual void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items){}
|
||||||
|
public virtual void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item){}
|
||||||
|
public virtual void SendInventoryItemUpdate(InventoryItemBase Item) { }
|
||||||
|
public virtual void SendRemoveInventoryItem(LLUUID itemID) { }
|
||||||
|
public virtual void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName) { }
|
||||||
|
public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data) { }
|
||||||
|
|
||||||
|
public virtual void SendPreLoadSound(LLUUID objectID, LLUUID ownerID, LLUUID soundID) { }
|
||||||
|
public virtual void SendPlayAttachedSound(LLUUID soundID, LLUUID objectID, LLUUID ownerID, float gain, byte flags) { }
|
||||||
|
|
||||||
|
public virtual void SendNameReply(LLUUID profileId, string firstname, string lastname){}
|
||||||
|
public void SendAlertMessage(string message) { }
|
||||||
|
public void SendAgentAlertMessage(string message, bool modal) { }
|
||||||
|
public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url) { }
|
||||||
|
|
||||||
|
|
||||||
|
public bool AddMoney(int debit)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SendViewerTime(int phase) { }
|
||||||
|
public void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, LLUUID partnerID) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("OpenSim.FrameWork")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("OpenSim.FrameWork")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2007")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("a08e20c7-f191-4137-b1f0-9291408fa521")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,114 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
using OpenSim.Framework.Interfaces;
|
||||||
|
using OpenSim.Framework.Types;
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework
|
||||||
|
{
|
||||||
|
public class RegionCommsListener :IRegionCommsListener
|
||||||
|
{
|
||||||
|
public event ExpectUserDelegate OnExpectUser;
|
||||||
|
public event GenericCall2 OnExpectChildAgent;
|
||||||
|
public event AgentCrossing OnAvatarCrossingIntoRegion;
|
||||||
|
public event UpdateNeighbours OnNeighboursUpdate;
|
||||||
|
public event AcknowledgeAgentCross OnAcknowledgeAgentCrossed;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="agent"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual bool TriggerExpectUser(ulong regionHandle, AgentCircuitData agent)
|
||||||
|
{
|
||||||
|
if(OnExpectUser != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
OnExpectUser(regionHandle, agent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool TriggerExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying)
|
||||||
|
{
|
||||||
|
if (OnAvatarCrossingIntoRegion != null)
|
||||||
|
{
|
||||||
|
OnAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool TriggerAcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentID)
|
||||||
|
{
|
||||||
|
if (OnAcknowledgeAgentCrossed != null)
|
||||||
|
{
|
||||||
|
OnAcknowledgeAgentCrossed(regionHandle, agentID);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>TODO: Doesnt take any args??</remarks>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual bool TriggerExpectChildAgent()
|
||||||
|
{
|
||||||
|
if (OnExpectChildAgent != null)
|
||||||
|
{
|
||||||
|
OnExpectChildAgent();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Added to avoid a unused compiler warning on OnNeighboursUpdate, TODO: Check me</remarks>
|
||||||
|
/// <param name="neighbours"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual bool TriggerOnNeighboursUpdate(List<RegionInfo> neighbours)
|
||||||
|
{
|
||||||
|
if (OnNeighboursUpdate != null)
|
||||||
|
{
|
||||||
|
OnNeighboursUpdate(neighbours);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,135 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// NEEDS AUDIT.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Suggested implementation
|
||||||
|
/// <para>Store two digests for each foreign host. A local copy of the local hash using the local challenge (when issued), and a local copy of the remote hash using the remote challenge.</para>
|
||||||
|
/// <para>When sending data to the foreign host - run 'Sign' on the data and affix the returned byte[] to the message.</para>
|
||||||
|
/// <para>When recieving data from the foreign host - run 'Authenticate' against the data and the attached byte[].</para>
|
||||||
|
/// <para>Both hosts should be performing these operations for this to be effective.</para>
|
||||||
|
/// </remarks>
|
||||||
|
class RemoteDigest
|
||||||
|
{
|
||||||
|
private byte[] currentHash;
|
||||||
|
private byte[] secret;
|
||||||
|
|
||||||
|
private SHA512Managed SHA512;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialises a new RemoteDigest authentication mechanism
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Needs an audit by a cryptographic professional - was not "roll your own"'d by choice but rather a serious lack of decent authentication mechanisms in .NET remoting</remarks>
|
||||||
|
/// <param name="sharedSecret">The shared secret between systems (for inter-sim, this is provided in encrypted form during connection, for grid this is input manually in setup)</param>
|
||||||
|
/// <param name="salt">Binary salt - some common value - to be decided what</param>
|
||||||
|
/// <param name="challenge">The challenge key provided by the third party</param>
|
||||||
|
public RemoteDigest(string sharedSecret, byte[] salt, string challenge)
|
||||||
|
{
|
||||||
|
SHA512 = new SHA512Managed();
|
||||||
|
Rfc2898DeriveBytes RFC2898 = new Rfc2898DeriveBytes(sharedSecret,salt);
|
||||||
|
secret = RFC2898.GetBytes(512);
|
||||||
|
ASCIIEncoding ASCII = new ASCIIEncoding();
|
||||||
|
|
||||||
|
currentHash = SHA512.ComputeHash(AppendArrays(secret, ASCII.GetBytes(challenge)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Authenticates a piece of incoming data against the local digest. Upon successful authentication, digest string is incremented.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">The incoming data</param>
|
||||||
|
/// <param name="digest">The remote digest</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool Authenticate(byte[] data, byte[] digest)
|
||||||
|
{
|
||||||
|
byte[] newHash = SHA512.ComputeHash(AppendArrays(AppendArrays(currentHash, secret), data));
|
||||||
|
if (digest == newHash)
|
||||||
|
{
|
||||||
|
currentHash = newHash;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("Hash comparison failed. Key resync required.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Signs a new bit of data with the current hash. Returns a byte array which should be affixed to the message.
|
||||||
|
/// Signing a piece of data will automatically increment the hash - if you sign data and do not send it, the
|
||||||
|
/// hashes will get out of sync and throw an exception when validation is attempted.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">The outgoing data</param>
|
||||||
|
/// <returns>The local digest</returns>
|
||||||
|
public byte[] Sign(byte[] data)
|
||||||
|
{
|
||||||
|
currentHash = SHA512.ComputeHash(AppendArrays(AppendArrays(currentHash, secret), data));
|
||||||
|
return currentHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generates a new challenge string to be issued to a foreign host. Challenges are 1024-bit (effective strength of less than 512-bits) messages generated using the Crytographic Random Number Generator.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A 128-character hexadecimal string containing the challenge.</returns>
|
||||||
|
public static string GenerateChallenge()
|
||||||
|
{
|
||||||
|
RNGCryptoServiceProvider RNG = new RNGCryptoServiceProvider();
|
||||||
|
byte[] bytes = new byte[64];
|
||||||
|
RNG.GetBytes(bytes);
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder(bytes.Length * 2);
|
||||||
|
foreach (byte b in bytes)
|
||||||
|
{
|
||||||
|
sb.AppendFormat("{0:x2}", b);
|
||||||
|
}
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Helper function, merges two byte arrays
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Sourced from MSDN Forum</remarks>
|
||||||
|
/// <param name="a">A</param>
|
||||||
|
/// <param name="b">B</param>
|
||||||
|
/// <returns>C</returns>
|
||||||
|
private byte[] AppendArrays(byte[] a, byte[] b)
|
||||||
|
{
|
||||||
|
byte[] c = new byte[a.Length + b.Length];
|
||||||
|
Buffer.BlockCopy(a, 0, c, 0, a.Length);
|
||||||
|
Buffer.BlockCopy(b, 0, c, a.Length, b.Length);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Types
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class AgentCircuitData
|
||||||
|
{
|
||||||
|
public AgentCircuitData() { }
|
||||||
|
public LLUUID AgentID;
|
||||||
|
public LLUUID SessionID;
|
||||||
|
public LLUUID SecureSessionID;
|
||||||
|
public LLVector3 startpos;
|
||||||
|
public string firstname;
|
||||||
|
public string lastname;
|
||||||
|
public uint circuitcode;
|
||||||
|
public bool child;
|
||||||
|
public LLUUID InventoryFolder;
|
||||||
|
public LLUUID BaseFolder;
|
||||||
|
public string CapsPath = "";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Types
|
||||||
|
{
|
||||||
|
public class AvatarWearable
|
||||||
|
{
|
||||||
|
public LLUUID AssetID = new LLUUID("00000000-0000-0000-0000-000000000000");
|
||||||
|
public LLUUID ItemID = new LLUUID("00000000-0000-0000-0000-000000000000");
|
||||||
|
|
||||||
|
public AvatarWearable()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AvatarWearable[] DefaultWearables
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
AvatarWearable[] defaultWearables = new AvatarWearable[13]; //should be 13 of these
|
||||||
|
for (int i = 0; i < 13; i++)
|
||||||
|
{
|
||||||
|
defaultWearables[i] = new AvatarWearable();
|
||||||
|
}
|
||||||
|
defaultWearables[0].AssetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
|
||||||
|
defaultWearables[0].ItemID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfaba9");
|
||||||
|
|
||||||
|
defaultWearables[1].ItemID = new LLUUID("77c41e39-38f9-f75a-024e-585989bfabc9");
|
||||||
|
defaultWearables[1].AssetID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb");
|
||||||
|
|
||||||
|
defaultWearables[4].ItemID = new LLUUID("77c41e39-38f9-f75a-0000-585989bf0000");
|
||||||
|
defaultWearables[4].AssetID = new LLUUID("00000000-38f9-1111-024e-222222111110");
|
||||||
|
|
||||||
|
defaultWearables[5].ItemID = new LLUUID("77c41e39-38f9-f75a-0000-5859892f1111");
|
||||||
|
defaultWearables[5].AssetID = new LLUUID("00000000-38f9-1111-024e-222222111120");
|
||||||
|
return defaultWearables;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Types
|
||||||
|
{
|
||||||
|
public class AssetBase
|
||||||
|
{
|
||||||
|
public byte[] Data;
|
||||||
|
public LLUUID FullID;
|
||||||
|
public sbyte Type;
|
||||||
|
public sbyte InvType;
|
||||||
|
public string Name;
|
||||||
|
public string Description;
|
||||||
|
|
||||||
|
public AssetBase()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
|
||||||
|
using libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Types
|
||||||
|
{
|
||||||
|
public class AssetLandmark : AssetBase
|
||||||
|
{
|
||||||
|
public int Version;
|
||||||
|
public LLVector3 Position;
|
||||||
|
public LLUUID RegionID;
|
||||||
|
|
||||||
|
public AssetLandmark(AssetBase a)
|
||||||
|
{
|
||||||
|
this.Data = a.Data;
|
||||||
|
this.FullID = a.FullID;
|
||||||
|
this.Type = a.Type;
|
||||||
|
this.InvType = a.InvType;
|
||||||
|
this.Name = a.Name;
|
||||||
|
this.Description = a.Description;
|
||||||
|
InternData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InternData()
|
||||||
|
{
|
||||||
|
string temp = Encoding.UTF8.GetString(Data).Trim();
|
||||||
|
string[] parts = temp.Split('\n');
|
||||||
|
int.TryParse(parts[0].Substring(17, 1), out Version);
|
||||||
|
LLUUID.TryParse(parts[1].Substring(10, 36), out RegionID);
|
||||||
|
LLVector3.TryParse(parts[2].Substring(11, parts[2].Length - 11), out Position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Types
|
||||||
|
{
|
||||||
|
public class AssetStorage
|
||||||
|
{
|
||||||
|
|
||||||
|
public AssetStorage() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssetStorage(LLUUID assetUUID) {
|
||||||
|
UUID=assetUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] Data;
|
||||||
|
public sbyte Type;
|
||||||
|
public string Name;
|
||||||
|
public LLUUID UUID;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,732 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.IO;
|
||||||
|
using libsecondlife;
|
||||||
|
using OpenSim.Framework.Configuration;
|
||||||
|
using OpenSim.Framework.Utilities;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Types
|
||||||
|
{
|
||||||
|
public class EstateSettings
|
||||||
|
{
|
||||||
|
|
||||||
|
//Settings to this island
|
||||||
|
private float m_billableFactor;
|
||||||
|
public float billableFactor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_billableFactor;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_billableFactor = value;
|
||||||
|
configMember.forceSetConfigurationOption("billable_factor", m_billableFactor.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private uint m_estateID;
|
||||||
|
public uint estateID
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_estateID;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_estateID = value;
|
||||||
|
configMember.forceSetConfigurationOption("estate_id", m_estateID.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private uint m_parentEstateID;
|
||||||
|
public uint parentEstateID
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_parentEstateID;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_parentEstateID = value;
|
||||||
|
configMember.forceSetConfigurationOption("parent_estate_id", m_parentEstateID.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte m_maxAgents;
|
||||||
|
public byte maxAgents
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_maxAgents;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_maxAgents = value;
|
||||||
|
configMember.forceSetConfigurationOption("max_agents", m_maxAgents.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float m_objectBonusFactor;
|
||||||
|
public float objectBonusFactor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_objectBonusFactor;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_objectBonusFactor = value;
|
||||||
|
configMember.forceSetConfigurationOption("object_bonus_factor", m_objectBonusFactor.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int m_redirectGridX;
|
||||||
|
public int redirectGridX
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_redirectGridX;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_redirectGridX = value;
|
||||||
|
configMember.forceSetConfigurationOption("redirect_grid_x", m_redirectGridX.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int m_redirectGridY;
|
||||||
|
public int redirectGridY
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_redirectGridY;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_redirectGridY = value;
|
||||||
|
configMember.forceSetConfigurationOption("redirect_grid_y", m_redirectGridY.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Simulator.RegionFlags m_regionFlags;
|
||||||
|
public Simulator.RegionFlags regionFlags
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_regionFlags;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_regionFlags = value;
|
||||||
|
configMember.forceSetConfigurationOption("region_flags", m_regionFlags.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Simulator.SimAccess m_simAccess;
|
||||||
|
public Simulator.SimAccess simAccess
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_simAccess;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_simAccess = value;
|
||||||
|
configMember.forceSetConfigurationOption("sim_access", m_simAccess.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float m_sunHour;
|
||||||
|
public float sunHour
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_sunHour;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_sunHour = value;
|
||||||
|
configMember.forceSetConfigurationOption("sun_hour", m_sunHour.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float m_terrainRaiseLimit;
|
||||||
|
public float terrainRaiseLimit
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainRaiseLimit;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainRaiseLimit = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_raise_limit", m_terrainRaiseLimit.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float m_terrainLowerLimit;
|
||||||
|
public float terrainLowerLimit
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainLowerLimit;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainLowerLimit = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_lower_limit", m_terrainLowerLimit.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool m_useFixedSun;
|
||||||
|
public bool useFixedSun
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_useFixedSun;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_useFixedSun = value;
|
||||||
|
configMember.forceSetConfigurationOption("use_fixed_sun", m_useFixedSun.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private int m_pricePerMeter;
|
||||||
|
public int pricePerMeter
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_pricePerMeter;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_pricePerMeter = value;
|
||||||
|
configMember.forceSetConfigurationOption("price_per_meter", m_pricePerMeter.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ushort m_regionWaterHeight;
|
||||||
|
public ushort regionWaterHeight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_regionWaterHeight;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_regionWaterHeight = value;
|
||||||
|
configMember.forceSetConfigurationOption("region_water_height", m_regionWaterHeight.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private bool m_regionAllowTerraform;
|
||||||
|
public bool regionAllowTerraform
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_regionAllowTerraform;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_regionAllowTerraform = value;
|
||||||
|
configMember.forceSetConfigurationOption("region_allow_terraform", m_regionAllowTerraform.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Region Information
|
||||||
|
// Low resolution 'base' textures. No longer used.
|
||||||
|
private LLUUID m_terrainBase0;
|
||||||
|
public LLUUID terrainBase0
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainBase0;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainBase0 = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_base_0", m_terrainBase0.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private LLUUID m_terrainBase1;
|
||||||
|
public LLUUID terrainBase1
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainBase1;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainBase1 = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_base_1", m_terrainBase1.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private LLUUID m_terrainBase2;
|
||||||
|
public LLUUID terrainBase2
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainBase2;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainBase2 = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_base_2", m_terrainBase2.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private LLUUID m_terrainBase3;
|
||||||
|
public LLUUID terrainBase3
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainBase3;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainBase3 = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_base_3", m_terrainBase3.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Higher resolution terrain textures
|
||||||
|
private LLUUID m_terrainDetail0;
|
||||||
|
public LLUUID terrainDetail0
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainDetail0;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
|
||||||
|
m_terrainDetail0 = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_detail_0", m_terrainDetail0.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private LLUUID m_terrainDetail1;
|
||||||
|
public LLUUID terrainDetail1
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainDetail1;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainDetail1 = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_detail_1", m_terrainDetail1.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private LLUUID m_terrainDetail2;
|
||||||
|
public LLUUID terrainDetail2
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainDetail2;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainDetail2 = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_detail_2", m_terrainDetail2.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private LLUUID m_terrainDetail3;
|
||||||
|
public LLUUID terrainDetail3
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainDetail3;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainDetail3 = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_detail_3", m_terrainDetail3.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// First quad - each point is bilinearly interpolated at each meter of terrain
|
||||||
|
private float m_terrainStartHeight0;
|
||||||
|
public float terrainStartHeight0
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainStartHeight0;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainStartHeight0 = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_start_height_0", m_terrainStartHeight0.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private float m_terrainStartHeight1;
|
||||||
|
public float terrainStartHeight1
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainStartHeight1;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainStartHeight1 = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_start_height_1", m_terrainStartHeight1.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float m_terrainStartHeight2;
|
||||||
|
public float terrainStartHeight2
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainStartHeight2;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainStartHeight2 = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_start_height_2", m_terrainStartHeight2.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float m_terrainStartHeight3;
|
||||||
|
public float terrainStartHeight3
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainStartHeight3;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainStartHeight3 = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_start_height_3", m_terrainStartHeight3.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Second quad - also bilinearly interpolated.
|
||||||
|
// Terrain texturing is done that:
|
||||||
|
// 0..3 (0 = base0, 3 = base3) = (terrain[x,y] - start[x,y]) / range[x,y]
|
||||||
|
private float m_terrainHeightRange0;
|
||||||
|
public float terrainHeightRange0
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainHeightRange0;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainHeightRange0 = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_height_range_0", m_terrainHeightRange0.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float m_terrainHeightRange1;
|
||||||
|
public float terrainHeightRange1
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainHeightRange1;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainHeightRange1 = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_height_range_1", m_terrainHeightRange1.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float m_terrainHeightRange2;
|
||||||
|
public float terrainHeightRange2
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainHeightRange2;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainHeightRange2 = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_height_range_2", m_terrainHeightRange2.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float m_terrainHeightRange3;
|
||||||
|
public float terrainHeightRange3
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainHeightRange3;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainHeightRange3 = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_height_range_3", m_terrainHeightRange3.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Terrain Default (Must be in F32 Format!)
|
||||||
|
private string m_terrainFile;
|
||||||
|
public string terrainFile
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainFile;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainFile = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_file", m_terrainFile.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private double m_terrainMultiplier;
|
||||||
|
public double terrainMultiplier
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainMultiplier;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainMultiplier = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_multiplier", m_terrainMultiplier.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float m_waterHeight;
|
||||||
|
public float waterHeight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_waterHeight;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_waterHeight = value;
|
||||||
|
configMember.forceSetConfigurationOption("water_height", m_waterHeight.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private LLUUID m_terrainImageID;
|
||||||
|
public LLUUID terrainImageID
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_terrainImageID;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_terrainImageID = value;
|
||||||
|
configMember.forceSetConfigurationOption("terrain_image_id", m_terrainImageID.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private ConfigurationMember configMember;
|
||||||
|
public EstateSettings()
|
||||||
|
{
|
||||||
|
configMember = new ConfigurationMember(Path.Combine(Util.configDir(),"estate_settings.xml"), "ESTATE SETTINGS", this.loadConfigurationOptions, this.handleIncomingConfiguration);
|
||||||
|
configMember.performConfigurationRetrieve();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadConfigurationOptions()
|
||||||
|
{
|
||||||
|
configMember.addConfigurationOption("billable_factor", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "","0.0",true);
|
||||||
|
configMember.addConfigurationOption("estate_id", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "","0",true);
|
||||||
|
configMember.addConfigurationOption("parent_estate_id", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "", "0", true);
|
||||||
|
configMember.addConfigurationOption("max_agents", ConfigurationOption.ConfigurationTypes.TYPE_BYTE, "", "40", true);
|
||||||
|
|
||||||
|
configMember.addConfigurationOption("object_bonus_factor", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "1.0", true);
|
||||||
|
configMember.addConfigurationOption("redirect_grid_x", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "", "0", true);
|
||||||
|
configMember.addConfigurationOption("redirect_grid_y", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "", "0", true);
|
||||||
|
configMember.addConfigurationOption("region_flags", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "", "0", true);
|
||||||
|
configMember.addConfigurationOption("sim_access", ConfigurationOption.ConfigurationTypes.TYPE_BYTE, "", "21", true);
|
||||||
|
configMember.addConfigurationOption("sun_hour", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "0", true);
|
||||||
|
configMember.addConfigurationOption("terrain_raise_limit", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "0", true);
|
||||||
|
configMember.addConfigurationOption("terrain_lower_limit", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "0", true);
|
||||||
|
configMember.addConfigurationOption("use_fixed_sun", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, "", "false", true);
|
||||||
|
configMember.addConfigurationOption("price_per_meter", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "", "1", true);
|
||||||
|
configMember.addConfigurationOption("region_water_height", ConfigurationOption.ConfigurationTypes.TYPE_UINT16, "", "20", true);
|
||||||
|
configMember.addConfigurationOption("region_allow_terraform", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, "", "true", true);
|
||||||
|
|
||||||
|
configMember.addConfigurationOption("terrain_base_0", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", "b8d3965a-ad78-bf43-699b-bff8eca6c975", true);
|
||||||
|
configMember.addConfigurationOption("terrain_base_1", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", "abb783e6-3e93-26c0-248a-247666855da3", true);
|
||||||
|
configMember.addConfigurationOption("terrain_base_2", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", "179cdabd-398a-9b6b-1391-4dc333ba321f", true);
|
||||||
|
configMember.addConfigurationOption("terrain_base_3", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", "beb169c7-11ea-fff2-efe5-0f24dc881df2", true);
|
||||||
|
|
||||||
|
configMember.addConfigurationOption("terrain_detail_0", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", "00000000-0000-0000-0000-000000000000", true);
|
||||||
|
configMember.addConfigurationOption("terrain_detail_1", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", "00000000-0000-0000-0000-000000000000", true);
|
||||||
|
configMember.addConfigurationOption("terrain_detail_2", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", "00000000-0000-0000-0000-000000000000", true);
|
||||||
|
configMember.addConfigurationOption("terrain_detail_3", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", "00000000-0000-0000-0000-000000000000", true);
|
||||||
|
|
||||||
|
configMember.addConfigurationOption("terrain_start_height_0", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "10.0", true);
|
||||||
|
configMember.addConfigurationOption("terrain_start_height_1", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "10.0", true);
|
||||||
|
configMember.addConfigurationOption("terrain_start_height_2", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "10.0", true);
|
||||||
|
configMember.addConfigurationOption("terrain_start_height_3", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "10.0", true);
|
||||||
|
|
||||||
|
configMember.addConfigurationOption("terrain_height_range_0", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "60.0", true);
|
||||||
|
configMember.addConfigurationOption("terrain_height_range_1", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "60.0", true);
|
||||||
|
configMember.addConfigurationOption("terrain_height_range_2", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "60.0", true);
|
||||||
|
configMember.addConfigurationOption("terrain_height_range_3", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "60.0", true);
|
||||||
|
|
||||||
|
configMember.addConfigurationOption("terrain_file", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "", "default.r32", true);
|
||||||
|
configMember.addConfigurationOption("terrain_multiplier", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "60.0", true);
|
||||||
|
configMember.addConfigurationOption("water_height", ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE, "", "20.0", true);
|
||||||
|
configMember.addConfigurationOption("terrain_image_id", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", "00000000-0000-0000-0000-000000000000", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
|
||||||
|
{
|
||||||
|
switch (configuration_key)
|
||||||
|
{
|
||||||
|
case "billable_factor":
|
||||||
|
this.m_billableFactor = (float)configuration_result;
|
||||||
|
break;
|
||||||
|
case "estate_id":
|
||||||
|
this.m_estateID = (uint)configuration_result;
|
||||||
|
break;
|
||||||
|
case "parent_estate_id":
|
||||||
|
this.m_parentEstateID = (uint)configuration_result;
|
||||||
|
break;
|
||||||
|
case "max_agents":
|
||||||
|
this.m_maxAgents = (byte)configuration_result;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "object_bonus_factor":
|
||||||
|
this.m_objectBonusFactor = (float)configuration_result;
|
||||||
|
break;
|
||||||
|
case "redirect_grid_x":
|
||||||
|
this.m_redirectGridX = (int)configuration_result;
|
||||||
|
break;
|
||||||
|
case "redirect_grid_y":
|
||||||
|
this.m_redirectGridY = (int)configuration_result;
|
||||||
|
break;
|
||||||
|
case "region_flags":
|
||||||
|
this.m_regionFlags = (Simulator.RegionFlags)((uint)configuration_result);
|
||||||
|
break;
|
||||||
|
case "sim_access":
|
||||||
|
this.m_simAccess = (Simulator.SimAccess)((byte)configuration_result);
|
||||||
|
break;
|
||||||
|
case "sun_hour":
|
||||||
|
this.m_sunHour = (float)configuration_result;
|
||||||
|
break;
|
||||||
|
case "terrain_raise_limit":
|
||||||
|
this.m_terrainRaiseLimit = (float)configuration_result;
|
||||||
|
break;
|
||||||
|
case "terrain_lower_limit":
|
||||||
|
this.m_terrainLowerLimit = (float)configuration_result;
|
||||||
|
break;
|
||||||
|
case "use_fixed_sun":
|
||||||
|
this.m_useFixedSun = (bool)configuration_result;
|
||||||
|
break;
|
||||||
|
case "price_per_meter":
|
||||||
|
this.m_pricePerMeter = System.Convert.ToInt32(configuration_result);
|
||||||
|
break;
|
||||||
|
case "region_water_height":
|
||||||
|
this.m_regionWaterHeight = (ushort)configuration_result;
|
||||||
|
break;
|
||||||
|
case "region_allow_terraform":
|
||||||
|
this.m_regionAllowTerraform = (bool)configuration_result;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "terrain_base_0":
|
||||||
|
this.m_terrainBase0 = (LLUUID)configuration_result;
|
||||||
|
break;
|
||||||
|
case "terrain_base_1":
|
||||||
|
this.m_terrainBase1 = (LLUUID)configuration_result;
|
||||||
|
break;
|
||||||
|
case "terrain_base_2":
|
||||||
|
this.m_terrainBase2 = (LLUUID)configuration_result;
|
||||||
|
break;
|
||||||
|
case "terrain_base_3":
|
||||||
|
this.m_terrainBase3 = (LLUUID)configuration_result;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "terrain_detail_0":
|
||||||
|
this.m_terrainDetail0 = (LLUUID)configuration_result;
|
||||||
|
break;
|
||||||
|
case "terrain_detail_1":
|
||||||
|
this.m_terrainDetail1 = (LLUUID)configuration_result;
|
||||||
|
break;
|
||||||
|
case "terrain_detail_2":
|
||||||
|
this.m_terrainDetail2 = (LLUUID)configuration_result;
|
||||||
|
break;
|
||||||
|
case "terrain_detail_3":
|
||||||
|
this.m_terrainDetail3 = (LLUUID)configuration_result;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "terrain_start_height_0":
|
||||||
|
this.m_terrainStartHeight0 = (float)configuration_result;
|
||||||
|
break;
|
||||||
|
case "terrain_start_height_1":
|
||||||
|
this.m_terrainStartHeight1 = (float)configuration_result;
|
||||||
|
break;
|
||||||
|
case "terrain_start_height_2":
|
||||||
|
this.m_terrainStartHeight2 = (float)configuration_result;
|
||||||
|
break;
|
||||||
|
case "terrain_start_height_3":
|
||||||
|
this.m_terrainStartHeight3 = (float)configuration_result;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "terrain_height_range_0":
|
||||||
|
this.m_terrainHeightRange0 = (float)configuration_result;
|
||||||
|
break;
|
||||||
|
case "terrain_height_range_1":
|
||||||
|
this.m_terrainHeightRange1 = (float)configuration_result;
|
||||||
|
break;
|
||||||
|
case "terrain_height_range_2":
|
||||||
|
this.m_terrainHeightRange2 = (float)configuration_result;
|
||||||
|
break;
|
||||||
|
case "terrain_height_range_3":
|
||||||
|
this.m_terrainHeightRange3 = (float)configuration_result;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "terrain_file":
|
||||||
|
this.m_terrainFile = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
case "terrain_multiplier":
|
||||||
|
this.m_terrainMultiplier = System.Convert.ToDouble(configuration_result);
|
||||||
|
break;
|
||||||
|
case "water_height":
|
||||||
|
float.TryParse(((double)configuration_result).ToString(),out this.m_waterHeight);
|
||||||
|
break;
|
||||||
|
case "terrain_image_id":
|
||||||
|
this.m_terrainImageID = (LLUUID)configuration_result;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,120 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Types
|
||||||
|
{
|
||||||
|
|
||||||
|
public class LandData
|
||||||
|
{
|
||||||
|
public byte[] landBitmapByteArray = new byte[512];
|
||||||
|
public string landName = "Your Parcel";
|
||||||
|
public string landDesc = "";
|
||||||
|
public LLUUID ownerID = new LLUUID();
|
||||||
|
public bool isGroupOwned = false;
|
||||||
|
public LLVector3 AABBMin = new LLVector3();
|
||||||
|
public LLVector3 AABBMax = new LLVector3();
|
||||||
|
public int area = 0;
|
||||||
|
public uint auctionID = 0; //Unemplemented. If set to 0, not being auctioned
|
||||||
|
public LLUUID authBuyerID = new LLUUID(); //Unemplemented. Authorized Buyer's UUID
|
||||||
|
public Parcel.ParcelCategory category = new Parcel.ParcelCategory(); //Unemplemented. Parcel's chosen category
|
||||||
|
public int claimDate = 0; //Unemplemented
|
||||||
|
public int claimPrice = 0; //Unemplemented
|
||||||
|
public LLUUID groupID = new LLUUID(); //Unemplemented
|
||||||
|
public int groupPrims = 0;
|
||||||
|
public int otherPrims = 0;
|
||||||
|
public int ownerPrims = 0;
|
||||||
|
public int selectedPrims = 0;
|
||||||
|
public int simwidePrims = 0;
|
||||||
|
public int simwideArea = 0;
|
||||||
|
public int salePrice = 0; //Unemeplemented. Parcels price.
|
||||||
|
public Parcel.ParcelStatus landStatus = Parcel.ParcelStatus.Leased;
|
||||||
|
public uint landFlags = (uint)Parcel.ParcelFlags.AllowFly | (uint)Parcel.ParcelFlags.AllowLandmark | (uint)Parcel.ParcelFlags.AllowAllObjectEntry | (uint)Parcel.ParcelFlags.AllowDeedToGroup | (uint)Parcel.ParcelFlags.AllowTerraform | (uint)Parcel.ParcelFlags.CreateObjects | (uint)Parcel.ParcelFlags.AllowOtherScripts;
|
||||||
|
public byte landingType = 0;
|
||||||
|
public byte mediaAutoScale = 0;
|
||||||
|
public LLUUID mediaID = LLUUID.Zero;
|
||||||
|
public int localID = 0;
|
||||||
|
public LLUUID globalID = new LLUUID();
|
||||||
|
|
||||||
|
public string mediaURL = "";
|
||||||
|
public string musicURL = "";
|
||||||
|
public float passHours = 0;
|
||||||
|
public int passPrice = 0;
|
||||||
|
public LLUUID snapshotID = LLUUID.Zero;
|
||||||
|
public LLVector3 userLocation = new LLVector3();
|
||||||
|
public LLVector3 userLookAt = new LLVector3();
|
||||||
|
|
||||||
|
public LandData()
|
||||||
|
{
|
||||||
|
globalID = LLUUID.Random();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LandData Copy()
|
||||||
|
{
|
||||||
|
LandData landData = new LandData();
|
||||||
|
|
||||||
|
landData.AABBMax = this.AABBMax;
|
||||||
|
landData.AABBMin = this.AABBMin;
|
||||||
|
landData.area = this.area;
|
||||||
|
landData.auctionID = this.auctionID;
|
||||||
|
landData.authBuyerID = this.authBuyerID;
|
||||||
|
landData.category = this.category;
|
||||||
|
landData.claimDate = this.claimDate;
|
||||||
|
landData.claimPrice = this.claimPrice;
|
||||||
|
landData.globalID = this.globalID;
|
||||||
|
landData.groupID = this.groupID;
|
||||||
|
landData.groupPrims = this.groupPrims;
|
||||||
|
landData.otherPrims = this.otherPrims;
|
||||||
|
landData.ownerPrims = this.ownerPrims;
|
||||||
|
landData.selectedPrims = this.selectedPrims;
|
||||||
|
landData.isGroupOwned = this.isGroupOwned;
|
||||||
|
landData.localID = this.localID;
|
||||||
|
landData.landingType = this.landingType;
|
||||||
|
landData.mediaAutoScale = this.mediaAutoScale;
|
||||||
|
landData.mediaID = this.mediaID;
|
||||||
|
landData.mediaURL = this.mediaURL;
|
||||||
|
landData.musicURL = this.musicURL;
|
||||||
|
landData.ownerID = this.ownerID;
|
||||||
|
landData.landBitmapByteArray = (byte[])this.landBitmapByteArray.Clone();
|
||||||
|
landData.landDesc = this.landDesc;
|
||||||
|
landData.landFlags = this.landFlags;
|
||||||
|
landData.landName = this.landName;
|
||||||
|
landData.landStatus = this.landStatus;
|
||||||
|
landData.passHours = this.passHours;
|
||||||
|
landData.passPrice = this.passPrice;
|
||||||
|
landData.salePrice = this.salePrice;
|
||||||
|
landData.snapshotID = this.snapshotID;
|
||||||
|
landData.userLocation = this.userLocation;
|
||||||
|
landData.userLookAt = this.userLookAt;
|
||||||
|
|
||||||
|
return landData;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Types
|
||||||
|
{
|
||||||
|
public class Login
|
||||||
|
{
|
||||||
|
public string First = "Test";
|
||||||
|
public string Last = "User";
|
||||||
|
public LLUUID Agent;
|
||||||
|
public LLUUID Session;
|
||||||
|
public LLUUID SecureSession = LLUUID.Zero;
|
||||||
|
public LLUUID InventoryFolder;
|
||||||
|
public LLUUID BaseFolder;
|
||||||
|
public uint CircuitCode;
|
||||||
|
public string CapsPath ="";
|
||||||
|
|
||||||
|
public Login()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
using System;
|
||||||
|
using libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Types
|
||||||
|
{
|
||||||
|
public class MapBlockData
|
||||||
|
{
|
||||||
|
public uint Flags;
|
||||||
|
public ushort X;
|
||||||
|
public ushort Y;
|
||||||
|
public byte Agents;
|
||||||
|
public byte Access;
|
||||||
|
public byte WaterHeight;
|
||||||
|
public LLUUID MapImageId;
|
||||||
|
public String Name;
|
||||||
|
public uint RegionFlags;
|
||||||
|
|
||||||
|
public MapBlockData()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
namespace OpenSim.Framework.Types
|
||||||
|
{
|
||||||
|
public class NeighbourInfo
|
||||||
|
{
|
||||||
|
public NeighbourInfo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ulong regionhandle;
|
||||||
|
public uint RegionLocX;
|
||||||
|
public uint RegionLocY;
|
||||||
|
public string sim_ip;
|
||||||
|
public uint sim_port;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,92 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 OpenSim.Framework.Console;
|
||||||
|
using OpenSim.Framework.Interfaces;
|
||||||
|
using OpenSim.Framework.Configuration;
|
||||||
|
|
||||||
|
using Nini.Config;
|
||||||
|
namespace OpenSim.Framework.Types
|
||||||
|
{
|
||||||
|
public class NetworkServersInfo
|
||||||
|
{
|
||||||
|
public string AssetURL = "http://127.0.0.1:8003/";
|
||||||
|
public string AssetSendKey = "";
|
||||||
|
|
||||||
|
public string GridURL = "";
|
||||||
|
public string GridSendKey = "";
|
||||||
|
public string GridRecvKey = "";
|
||||||
|
public string UserURL = "";
|
||||||
|
public string UserSendKey = "";
|
||||||
|
public string UserRecvKey = "";
|
||||||
|
public bool isSandbox;
|
||||||
|
|
||||||
|
public int HttpListenerPort = 9000;
|
||||||
|
public int RemotingListenerPort = 8895;
|
||||||
|
|
||||||
|
|
||||||
|
public NetworkServersInfo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public NetworkServersInfo(uint defaultHomeLocX, uint defaultHomeLocY)
|
||||||
|
{
|
||||||
|
m_defaultHomeLocX = defaultHomeLocX;
|
||||||
|
m_defaultHomeLocY = defaultHomeLocY;
|
||||||
|
}
|
||||||
|
|
||||||
|
private uint? m_defaultHomeLocX;
|
||||||
|
public uint DefaultHomeLocX
|
||||||
|
{
|
||||||
|
get { return m_defaultHomeLocX.Value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private uint? m_defaultHomeLocY;
|
||||||
|
public uint DefaultHomeLocY
|
||||||
|
{
|
||||||
|
get { return m_defaultHomeLocY.Value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadFromConfiguration(IConfigSource config)
|
||||||
|
{
|
||||||
|
m_defaultHomeLocX = (uint)config.Configs["StandAlone"].GetInt("default_location_x", 1000);
|
||||||
|
m_defaultHomeLocY = (uint)config.Configs["StandAlone"].GetInt("default_location_y", 1000);
|
||||||
|
|
||||||
|
HttpListenerPort = config.Configs["Network"].GetInt("http_listener_port", 9000);
|
||||||
|
RemotingListenerPort = config.Configs["Network"].GetInt("remoting_listener_port", 8895);
|
||||||
|
GridURL = config.Configs["Network"].GetString("grid_server_url", "http://127.0.0.1:8001");
|
||||||
|
GridSendKey = config.Configs["Network"].GetString("grid_send_key", "null");
|
||||||
|
GridRecvKey = config.Configs["Network"].GetString("grid_recv_key", "null");
|
||||||
|
UserURL = config.Configs["Network"].GetString("user_server_url", "http://127.0.0.1:8002");
|
||||||
|
UserSendKey = config.Configs["Network"].GetString("user_send_key", "null");
|
||||||
|
UserRecvKey = config.Configs["Network"].GetString("user_recv_key", "null");
|
||||||
|
AssetURL = config.Configs["Network"].GetString("asset_server_url", "http://127.0.0.1:8003");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,228 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Types
|
||||||
|
{
|
||||||
|
public class PrimData
|
||||||
|
{
|
||||||
|
private const uint FULL_MASK_PERMISSIONS = 2147483647;
|
||||||
|
|
||||||
|
public LLUUID OwnerID;
|
||||||
|
public byte PCode;
|
||||||
|
public ushort PathBegin;
|
||||||
|
public ushort PathEnd;
|
||||||
|
public byte PathScaleX;
|
||||||
|
public byte PathScaleY;
|
||||||
|
public byte PathShearX;
|
||||||
|
public byte PathShearY;
|
||||||
|
public sbyte PathSkew;
|
||||||
|
public ushort ProfileBegin;
|
||||||
|
public ushort ProfileEnd;
|
||||||
|
public LLVector3 Scale;
|
||||||
|
public byte PathCurve;
|
||||||
|
public byte ProfileCurve;
|
||||||
|
public uint ParentID = 0;
|
||||||
|
public ushort ProfileHollow;
|
||||||
|
public sbyte PathRadiusOffset;
|
||||||
|
public byte PathRevolutions;
|
||||||
|
public sbyte PathTaperX;
|
||||||
|
public sbyte PathTaperY;
|
||||||
|
public sbyte PathTwist;
|
||||||
|
public sbyte PathTwistBegin;
|
||||||
|
public byte[] TextureEntry; // a LL textureEntry in byte[] format
|
||||||
|
|
||||||
|
public Int32 CreationDate;
|
||||||
|
public uint OwnerMask = FULL_MASK_PERMISSIONS;
|
||||||
|
public uint NextOwnerMask = FULL_MASK_PERMISSIONS;
|
||||||
|
public uint GroupMask = FULL_MASK_PERMISSIONS;
|
||||||
|
public uint EveryoneMask = FULL_MASK_PERMISSIONS;
|
||||||
|
public uint BaseMask = FULL_MASK_PERMISSIONS;
|
||||||
|
|
||||||
|
//following only used during prim storage
|
||||||
|
public LLVector3 Position;
|
||||||
|
public LLQuaternion Rotation = new LLQuaternion(0, 1, 0, 0);
|
||||||
|
public uint LocalID;
|
||||||
|
public LLUUID FullID;
|
||||||
|
|
||||||
|
public PrimData()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrimData(byte[] data)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
this.OwnerID = new LLUUID(data, i); i += 16;
|
||||||
|
this.PCode = data[i++];
|
||||||
|
this.PathBegin = (ushort)(data[i++] + (data[i++] << 8));
|
||||||
|
this.PathEnd = (ushort)(data[i++] + (data[i++] << 8));
|
||||||
|
this.PathScaleX = data[i++];
|
||||||
|
this.PathScaleY = data[i++];
|
||||||
|
this.PathShearX = data[i++];
|
||||||
|
this.PathShearY = data[i++];
|
||||||
|
this.PathSkew = (sbyte)data[i++];
|
||||||
|
this.ProfileBegin = (ushort)(data[i++] + (data[i++] << 8));
|
||||||
|
this.ProfileEnd = (ushort)(data[i++] + (data[i++] << 8));
|
||||||
|
this.Scale = new LLVector3(data, i); i += 12;
|
||||||
|
this.PathCurve = data[i++];
|
||||||
|
this.ProfileCurve = data[i++];
|
||||||
|
this.ParentID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
|
||||||
|
this.ProfileHollow = (ushort)(data[i++] + (data[i++] << 8));
|
||||||
|
this.PathRadiusOffset = (sbyte)data[i++];
|
||||||
|
this.PathRevolutions = data[i++];
|
||||||
|
this.PathTaperX = (sbyte)data[i++];
|
||||||
|
this.PathTaperY = (sbyte)data[i++];
|
||||||
|
this.PathTwist = (sbyte)data[i++];
|
||||||
|
this.PathTwistBegin = (sbyte)data[i++];
|
||||||
|
ushort length = (ushort)(data[i++] + (data[i++] << 8));
|
||||||
|
this.TextureEntry = new byte[length];
|
||||||
|
Array.Copy(data, i, TextureEntry, 0, length); i += length;
|
||||||
|
this.CreationDate = (Int32)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
|
||||||
|
this.OwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
|
||||||
|
this.NextOwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
|
||||||
|
this.GroupMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
|
||||||
|
this.EveryoneMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
|
||||||
|
this.BaseMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
|
||||||
|
this.Position = new LLVector3(data, i); i += 12;
|
||||||
|
this.Rotation = new LLQuaternion(data, i, true); i += 12;
|
||||||
|
this.LocalID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
|
||||||
|
this.FullID = new LLUUID(data, i); i += 16;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] ToBytes()
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
byte[] bytes = new byte[126 + TextureEntry.Length];
|
||||||
|
Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16;
|
||||||
|
bytes[i++] = this.PCode;
|
||||||
|
bytes[i++] = (byte)(this.PathBegin % 256);
|
||||||
|
bytes[i++] = (byte)((this.PathBegin >> 8) % 256);
|
||||||
|
bytes[i++] = (byte)(this.PathEnd % 256);
|
||||||
|
bytes[i++] = (byte)((this.PathEnd >> 8) % 256);
|
||||||
|
bytes[i++] = this.PathScaleX;
|
||||||
|
bytes[i++] = this.PathScaleY;
|
||||||
|
bytes[i++] = this.PathShearX;
|
||||||
|
bytes[i++] = this.PathShearY;
|
||||||
|
bytes[i++] = (byte)this.PathSkew;
|
||||||
|
bytes[i++] = (byte)(this.ProfileBegin % 256);
|
||||||
|
bytes[i++] = (byte)((this.ProfileBegin >> 8) % 256);
|
||||||
|
bytes[i++] = (byte)(this.ProfileEnd % 256);
|
||||||
|
bytes[i++] = (byte)((this.ProfileEnd >> 8) % 256);
|
||||||
|
Array.Copy(Scale.GetBytes(), 0, bytes, i, 12); i += 12;
|
||||||
|
bytes[i++] = this.PathCurve;
|
||||||
|
bytes[i++] = this.ProfileCurve;
|
||||||
|
bytes[i++] = (byte)(ParentID % 256);
|
||||||
|
bytes[i++] = (byte)((ParentID >> 8) % 256);
|
||||||
|
bytes[i++] = (byte)((ParentID >> 16) % 256);
|
||||||
|
bytes[i++] = (byte)((ParentID >> 24) % 256);
|
||||||
|
bytes[i++] = (byte)(this.ProfileHollow % 256);
|
||||||
|
bytes[i++] = (byte)((this.ProfileHollow >> 8) % 256);
|
||||||
|
bytes[i++] = ((byte)this.PathRadiusOffset);
|
||||||
|
bytes[i++] = this.PathRevolutions;
|
||||||
|
bytes[i++] = ((byte)this.PathTaperX);
|
||||||
|
bytes[i++] = ((byte)this.PathTaperY);
|
||||||
|
bytes[i++] = ((byte)this.PathTwist);
|
||||||
|
bytes[i++] = ((byte)this.PathTwistBegin);
|
||||||
|
bytes[i++] = (byte)(TextureEntry.Length % 256);
|
||||||
|
bytes[i++] = (byte)((TextureEntry.Length >> 8) % 256);
|
||||||
|
Array.Copy(TextureEntry, 0, bytes, i, TextureEntry.Length); i += TextureEntry.Length;
|
||||||
|
bytes[i++] = (byte)(this.CreationDate % 256);
|
||||||
|
bytes[i++] = (byte)((this.CreationDate >> 8) % 256);
|
||||||
|
bytes[i++] = (byte)((this.CreationDate >> 16) % 256);
|
||||||
|
bytes[i++] = (byte)((this.CreationDate >> 24) % 256);
|
||||||
|
bytes[i++] = (byte)(this.OwnerMask % 256);
|
||||||
|
bytes[i++] = (byte)((this.OwnerMask >> 8) % 256);
|
||||||
|
bytes[i++] = (byte)((this.OwnerMask >> 16) % 256);
|
||||||
|
bytes[i++] = (byte)((this.OwnerMask >> 24) % 256);
|
||||||
|
bytes[i++] = (byte)(this.NextOwnerMask % 256);
|
||||||
|
bytes[i++] = (byte)((this.NextOwnerMask >> 8) % 256);
|
||||||
|
bytes[i++] = (byte)((this.NextOwnerMask >> 16) % 256);
|
||||||
|
bytes[i++] = (byte)((this.NextOwnerMask >> 24) % 256);
|
||||||
|
bytes[i++] = (byte)(this.GroupMask % 256);
|
||||||
|
bytes[i++] = (byte)((this.GroupMask >> 8) % 256);
|
||||||
|
bytes[i++] = (byte)((this.GroupMask >> 16) % 256);
|
||||||
|
bytes[i++] = (byte)((this.GroupMask >> 24) % 256);
|
||||||
|
bytes[i++] = (byte)(this.EveryoneMask % 256);
|
||||||
|
bytes[i++] = (byte)((this.EveryoneMask >> 8) % 256);
|
||||||
|
bytes[i++] = (byte)((this.EveryoneMask >> 16) % 256);
|
||||||
|
bytes[i++] = (byte)((this.EveryoneMask >> 24) % 256);
|
||||||
|
bytes[i++] = (byte)(this.BaseMask % 256);
|
||||||
|
bytes[i++] = (byte)((this.BaseMask >> 8) % 256);
|
||||||
|
bytes[i++] = (byte)((this.BaseMask >> 16) % 256);
|
||||||
|
bytes[i++] = (byte)((this.BaseMask >> 24) % 256);
|
||||||
|
Array.Copy(this.Position.GetBytes(), 0, bytes, i, 12); i += 12;
|
||||||
|
if (this.Rotation == new LLQuaternion(0, 0, 0, 0))
|
||||||
|
{
|
||||||
|
this.Rotation = new LLQuaternion(0, 1, 0, 0);
|
||||||
|
}
|
||||||
|
Array.Copy(this.Rotation.GetBytes(), 0, bytes, i, 12); i += 12;
|
||||||
|
bytes[i++] = (byte)(this.LocalID % 256);
|
||||||
|
bytes[i++] = (byte)((this.LocalID >> 8) % 256);
|
||||||
|
bytes[i++] = (byte)((this.LocalID >> 16) % 256);
|
||||||
|
bytes[i++] = (byte)((this.LocalID >> 24) % 256);
|
||||||
|
Array.Copy(FullID.GetBytes(), 0, bytes, i, 16); i += 16;
|
||||||
|
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
//public static PrimData DefaultCube()
|
||||||
|
//{
|
||||||
|
// PrimData primData = new PrimData();
|
||||||
|
// primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
|
||||||
|
// primData.FullID = LLUUID.Random();
|
||||||
|
// primData.Scale = new LLVector3(0.5f, 0.5f, 0.5f);
|
||||||
|
// primData.Rotation = new LLQuaternion(0, 0, 0, 1);
|
||||||
|
// primData.PCode = 9;
|
||||||
|
// primData.ParentID = 0;
|
||||||
|
// primData.PathBegin = 0;
|
||||||
|
// primData.PathEnd = 0;
|
||||||
|
// primData.PathScaleX = 0;
|
||||||
|
// primData.PathScaleY = 0;
|
||||||
|
// primData.PathShearX = 0;
|
||||||
|
// primData.PathShearY = 0;
|
||||||
|
// primData.PathSkew = 0;
|
||||||
|
// primData.ProfileBegin = 0;
|
||||||
|
// primData.ProfileEnd = 0;
|
||||||
|
// primData.PathCurve = 16;
|
||||||
|
// primData.ProfileCurve = 1;
|
||||||
|
// primData.ProfileHollow = 0;
|
||||||
|
// primData.PathRadiusOffset = 0;
|
||||||
|
// primData.PathRevolutions = 0;
|
||||||
|
// primData.PathTaperX = 0;
|
||||||
|
// primData.PathTaperY = 0;
|
||||||
|
// primData.PathTwist = 0;
|
||||||
|
// primData.PathTwistBegin = 0;
|
||||||
|
|
||||||
|
// return primData;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,194 @@
|
||||||
|
using libsecondlife;
|
||||||
|
using libsecondlife.Packets;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Types
|
||||||
|
{
|
||||||
|
public enum ProfileShape : byte
|
||||||
|
{
|
||||||
|
Circle = 0,
|
||||||
|
Square = 1,
|
||||||
|
IsometricTriangle = 2,
|
||||||
|
EquilateralTriangle = 3,
|
||||||
|
RightTriangle = 4,
|
||||||
|
HalfCircle = 5
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum HollowShape : byte
|
||||||
|
{
|
||||||
|
Same = 0,
|
||||||
|
Circle = 16,
|
||||||
|
Square = 32,
|
||||||
|
Triangle = 48
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum PCodeEnum : byte
|
||||||
|
{
|
||||||
|
Primitive = 9,
|
||||||
|
Avatar = 47
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Extrusion : byte
|
||||||
|
{
|
||||||
|
Straight = 16,
|
||||||
|
Curve1 = 32,
|
||||||
|
Curve2 = 48,
|
||||||
|
Flexible = 128
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PrimitiveBaseShape
|
||||||
|
{
|
||||||
|
private static byte[] m_defaultTextureEntry;
|
||||||
|
|
||||||
|
public byte PCode;
|
||||||
|
public ushort PathBegin;
|
||||||
|
public ushort PathEnd;
|
||||||
|
public byte PathScaleX;
|
||||||
|
public byte PathScaleY;
|
||||||
|
public byte PathShearX;
|
||||||
|
public byte PathShearY;
|
||||||
|
public sbyte PathSkew;
|
||||||
|
public ushort ProfileBegin;
|
||||||
|
public ushort ProfileEnd;
|
||||||
|
public LLVector3 Scale;
|
||||||
|
public byte PathCurve;
|
||||||
|
public byte ProfileCurve;
|
||||||
|
public ushort ProfileHollow;
|
||||||
|
public sbyte PathRadiusOffset;
|
||||||
|
public byte PathRevolutions;
|
||||||
|
public sbyte PathTaperX;
|
||||||
|
public sbyte PathTaperY;
|
||||||
|
public sbyte PathTwist;
|
||||||
|
public sbyte PathTwistBegin;
|
||||||
|
public byte[] TextureEntry; // a LL textureEntry in byte[] format
|
||||||
|
public byte[] ExtraParams;
|
||||||
|
|
||||||
|
public ProfileShape ProfileShape
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (ProfileShape)(ProfileCurve & 0xf);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
byte oldValueMasked = (byte)(ProfileCurve & 0xf0);
|
||||||
|
ProfileCurve = (byte)(oldValueMasked | (byte)value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public HollowShape HollowShape
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (HollowShape)(ProfileHollow & 0xf0);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
byte oldValueMasked = (byte)(ProfileHollow & 0xf0);
|
||||||
|
ProfileHollow = (byte)(oldValueMasked | (byte)value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public LLVector3 PrimScale
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.Scale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static PrimitiveBaseShape()
|
||||||
|
{
|
||||||
|
m_defaultTextureEntry = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-9999-000000000005")).ToBytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrimitiveBaseShape()
|
||||||
|
{
|
||||||
|
PCode = (byte)PCodeEnum.Primitive;
|
||||||
|
ExtraParams = new byte[1];
|
||||||
|
TextureEntry = m_defaultTextureEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
//void returns need to change of course
|
||||||
|
public virtual void GetMesh()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrimitiveBaseShape Copy()
|
||||||
|
{
|
||||||
|
return (PrimitiveBaseShape)this.MemberwiseClone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GenericShape : PrimitiveBaseShape
|
||||||
|
{
|
||||||
|
public GenericShape()
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BoxShape : PrimitiveBaseShape
|
||||||
|
{
|
||||||
|
public BoxShape()
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
PathCurve = (byte)Extrusion.Straight;
|
||||||
|
ProfileShape = ProfileShape.Square;
|
||||||
|
PathScaleX = 100;
|
||||||
|
PathScaleY = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BoxShape(float side)
|
||||||
|
: this()
|
||||||
|
{
|
||||||
|
SetSide(side);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetSide(float side)
|
||||||
|
{
|
||||||
|
Scale = new LLVector3(side, side, side);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BoxShape Default
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
BoxShape boxShape = new BoxShape();
|
||||||
|
|
||||||
|
boxShape.SetSide(0.5f);
|
||||||
|
|
||||||
|
return boxShape;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class CylinderShape : PrimitiveBaseShape
|
||||||
|
{
|
||||||
|
public CylinderShape()
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
PathCurve = (byte)Extrusion.Straight;
|
||||||
|
ProfileShape = ProfileShape.Circle;
|
||||||
|
PathScaleX = 100;
|
||||||
|
PathScaleY = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CylinderShape(float radius, float heigth)
|
||||||
|
: this()
|
||||||
|
{
|
||||||
|
SetRadius(radius);
|
||||||
|
SetHeigth(heigth);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetHeigth(float heigth)
|
||||||
|
{
|
||||||
|
Scale.Z = heigth;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetRadius(float radius)
|
||||||
|
{
|
||||||
|
Scale.X = Scale.Y = radius * 2f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,121 @@
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Types
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A class for manipulating RegionHandle coordinates
|
||||||
|
/// </summary>
|
||||||
|
class RegionHandle
|
||||||
|
{
|
||||||
|
private UInt64 handle;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialises a new grid-aware RegionHandle
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ip">IP Address of the Grid Server for this region</param>
|
||||||
|
/// <param name="x">Grid X Coordinate</param>
|
||||||
|
/// <param name="y">Grid Y Coordinate</param>
|
||||||
|
public RegionHandle(string ip, short x, short y)
|
||||||
|
{
|
||||||
|
IPAddress addr = IPAddress.Parse(ip);
|
||||||
|
|
||||||
|
if (addr.AddressFamily != System.Net.Sockets.AddressFamily.InterNetwork)
|
||||||
|
throw new Exception("Bad RegionHandle Parameter - must be an IPv4 address");
|
||||||
|
|
||||||
|
uint baseHandle = BitConverter.ToUInt32(addr.GetAddressBytes(), 0);
|
||||||
|
|
||||||
|
// Split the IP address in half
|
||||||
|
short a = (short)((baseHandle << 16) & 0xFFFF);
|
||||||
|
short b = (short)((baseHandle << 0) & 0xFFFF);
|
||||||
|
|
||||||
|
// Raise the bounds a little
|
||||||
|
uint nx = (uint)x;
|
||||||
|
uint ny = (uint)y;
|
||||||
|
|
||||||
|
// Multiply grid coords to get region coords
|
||||||
|
nx *= 256;
|
||||||
|
ny *= 256;
|
||||||
|
|
||||||
|
// Stuff the IP address in too
|
||||||
|
nx = (uint)a << 16;
|
||||||
|
ny = (uint)b << 16;
|
||||||
|
|
||||||
|
handle = ((UInt64)nx << 32) | (uint)ny;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialises a new RegionHandle that is not inter-grid aware
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x">Grid X Coordinate</param>
|
||||||
|
/// <param name="y">Grid Y Coordinate</param>
|
||||||
|
public RegionHandle(uint x, uint y)
|
||||||
|
{
|
||||||
|
handle = ((x * 256) << 32) | (y * 256);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialises a new RegionHandle from an existing value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Region">A U64 RegionHandle</param>
|
||||||
|
public RegionHandle(UInt64 Region)
|
||||||
|
{
|
||||||
|
handle = Region;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the Grid Masked RegionHandle - For use in Teleport packets and other packets where sending the grid IP address may be handy.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Do not use for SimulatorEnable packets. The client will choke.</remarks>
|
||||||
|
/// <returns>Region Handle including IP Address encoding</returns>
|
||||||
|
public UInt64 getTeleportHandle()
|
||||||
|
{
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a RegionHandle which may be used for SimulatorEnable packets. Removes the IP address encoding and returns the lower bounds.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A U64 RegionHandle for use in SimulatorEnable packets.</returns>
|
||||||
|
public UInt64 getNeighbourHandle()
|
||||||
|
{
|
||||||
|
UInt64 mask = 0x0000FFFF0000FFFF;
|
||||||
|
|
||||||
|
return handle | mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the IP Address of the GridServer from a Grid-Encoded RegionHandle
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Grid Server IP Address</returns>
|
||||||
|
public IPAddress getGridIP()
|
||||||
|
{
|
||||||
|
uint a = (uint)((handle >> 16) & 0xFFFF);
|
||||||
|
uint b = (uint)((handle >> 48) & 0xFFFF);
|
||||||
|
|
||||||
|
return new IPAddress((long)(a << 16) | (long)b);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the X Coordinate from a Grid-Encoded RegionHandle
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>X Coordinate</returns>
|
||||||
|
public uint getGridX()
|
||||||
|
{
|
||||||
|
uint x = (uint)((handle >> 32) & 0xFFFF);
|
||||||
|
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the Y Coordinate from a Grid-Encoded RegionHandle
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Y Coordinate</returns>
|
||||||
|
public uint getGridY()
|
||||||
|
{
|
||||||
|
uint y = (uint)((handle >> 0) & 0xFFFF);
|
||||||
|
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,280 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Globalization;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using Nini.Config;
|
||||||
|
using libsecondlife;
|
||||||
|
using OpenSim.Framework.Console;
|
||||||
|
using OpenSim.Framework.Interfaces;
|
||||||
|
using OpenSim.Framework.Utilities;
|
||||||
|
|
||||||
|
using OpenSim.Framework.Configuration;
|
||||||
|
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Types
|
||||||
|
{
|
||||||
|
public class RegionInfo
|
||||||
|
{
|
||||||
|
public LLUUID SimUUID = new LLUUID();
|
||||||
|
public string RegionName = "";
|
||||||
|
|
||||||
|
private IPEndPoint m_internalEndPoint;
|
||||||
|
public IPEndPoint InternalEndPoint
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_internalEndPoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPEndPoint ExternalEndPoint
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
// Old one defaults to IPv6
|
||||||
|
//return new IPEndPoint( Dns.GetHostAddresses( m_externalHostName )[0], m_internalEndPoint.Port );
|
||||||
|
|
||||||
|
// New method favors IPv4
|
||||||
|
IPAddress ia = null;
|
||||||
|
foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName))
|
||||||
|
{
|
||||||
|
if (ia == null)
|
||||||
|
ia = Adr;
|
||||||
|
|
||||||
|
if (Adr.AddressFamily == AddressFamily.InterNetwork)
|
||||||
|
{
|
||||||
|
ia = Adr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return new IPEndPoint(ia, m_internalEndPoint.Port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string m_externalHostName;
|
||||||
|
public string ExternalHostName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_externalHostName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private uint? m_regionLocX;
|
||||||
|
public uint RegionLocX
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_regionLocX.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private uint? m_regionLocY;
|
||||||
|
public uint RegionLocY
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_regionLocY.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ulong? m_regionHandle;
|
||||||
|
public ulong RegionHandle
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (!m_regionHandle.HasValue)
|
||||||
|
{
|
||||||
|
m_regionHandle = Util.UIntsToLong((RegionLocX * 256), (RegionLocY * 256));
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_regionHandle.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private uint m_remotingPort;
|
||||||
|
public uint RemotingPort
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_remotingPort;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_remotingPort = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string RemotingAddress;
|
||||||
|
|
||||||
|
public string DataStore = "";
|
||||||
|
public bool isSandbox = false;
|
||||||
|
|
||||||
|
public LLUUID MasterAvatarAssignedUUID = new LLUUID();
|
||||||
|
public string MasterAvatarFirstName = "";
|
||||||
|
public string MasterAvatarLastName = "";
|
||||||
|
public string MasterAvatarSandboxPassword = "";
|
||||||
|
|
||||||
|
public EstateSettings estateSettings;
|
||||||
|
|
||||||
|
public ConfigurationMember configMember;
|
||||||
|
public RegionInfo(string description, string filename)
|
||||||
|
{
|
||||||
|
estateSettings = new EstateSettings();
|
||||||
|
configMember = new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration);
|
||||||
|
configMember.performConfigurationRetrieve();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri)
|
||||||
|
{
|
||||||
|
|
||||||
|
estateSettings = new EstateSettings();
|
||||||
|
m_regionLocX = regionLocX;
|
||||||
|
m_regionLocY = regionLocY;
|
||||||
|
|
||||||
|
m_internalEndPoint = internalEndPoint;
|
||||||
|
m_externalHostName = externalUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadFromNiniSource(IConfigSource source)
|
||||||
|
{
|
||||||
|
this.LoadFromNiniSource(source, "RegionInfo");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadFromNiniSource(IConfigSource source, string sectionName)
|
||||||
|
{
|
||||||
|
string errorMessage = "";
|
||||||
|
this.SimUUID = new LLUUID(source.Configs[sectionName].GetString("sim_UUID", LLUUID.Random().ToStringHyphenated()));
|
||||||
|
this.RegionName = source.Configs[sectionName].GetString("sim_name", "OpenSim Test");
|
||||||
|
this.m_regionLocX = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_x", "1000"));
|
||||||
|
this.m_regionLocY = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_y", "1000"));
|
||||||
|
this.DataStore = source.Configs[sectionName].GetString("datastore", "OpenSim.db");
|
||||||
|
|
||||||
|
string ipAddress = source.Configs[sectionName].GetString("internal_ip_address", "0.0.0.0");
|
||||||
|
IPAddress ipAddressResult;
|
||||||
|
if (IPAddress.TryParse(ipAddress, out ipAddressResult))
|
||||||
|
{
|
||||||
|
this.m_internalEndPoint = new IPEndPoint(ipAddressResult, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorMessage = "needs an IP Address (IPAddress)";
|
||||||
|
}
|
||||||
|
this.m_internalEndPoint.Port = source.Configs[sectionName].GetInt("internal_ip_port",(int) 9000);
|
||||||
|
|
||||||
|
string externalHost = source.Configs[sectionName].GetString("external_host_name", "127.0.0.1");
|
||||||
|
if (externalHost != "SYSTEMIP")
|
||||||
|
{
|
||||||
|
this.m_externalHostName = externalHost;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.m_externalHostName = Util.GetLocalHost().ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.MasterAvatarFirstName = source.Configs[sectionName].GetString("master_avatar_first", "Test");
|
||||||
|
this.MasterAvatarLastName = source.Configs[sectionName].GetString("master_avatar_last", "User");
|
||||||
|
this.MasterAvatarSandboxPassword = source.Configs[sectionName].GetString("master_avatar_pass", "test");
|
||||||
|
|
||||||
|
if (errorMessage != "")
|
||||||
|
{
|
||||||
|
// a error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadConfigurationOptions()
|
||||||
|
{
|
||||||
|
configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "UUID of Simulator (Default is recommended, random UUID)", LLUUID.Random().ToString(), true);
|
||||||
|
configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Simulator Name", "OpenSim Test", false);
|
||||||
|
configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Grid Location (X Axis)", "1000", false);
|
||||||
|
configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Grid Location (Y Axis)", "1000", false);
|
||||||
|
configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "localworld.yap", false);
|
||||||
|
configMember.addConfigurationOption("internal_ip_address", ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, "Internal IP Address for incoming UDP client connections", "0.0.0.0", false);
|
||||||
|
configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Internal IP Port for incoming UDP client connections", "9000", false);
|
||||||
|
configMember.addConfigurationOption("external_host_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "External Host Name", "127.0.0.1", false);
|
||||||
|
configMember.addConfigurationOption("master_avatar_first", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "First Name of Master Avatar", "Test", false);
|
||||||
|
configMember.addConfigurationOption("master_avatar_last", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Last Name of Master Avatar", "User", false);
|
||||||
|
configMember.addConfigurationOption("master_avatar_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "(Sandbox Mode Only)Password for Master Avatar account", "test", false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
|
||||||
|
{
|
||||||
|
switch (configuration_key)
|
||||||
|
{
|
||||||
|
case "sim_UUID":
|
||||||
|
this.SimUUID = (LLUUID)configuration_result;
|
||||||
|
break;
|
||||||
|
case "sim_name":
|
||||||
|
this.RegionName = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
case "sim_location_x":
|
||||||
|
this.m_regionLocX = (uint)configuration_result;
|
||||||
|
break;
|
||||||
|
case "sim_location_y":
|
||||||
|
this.m_regionLocY = (uint)configuration_result;
|
||||||
|
break;
|
||||||
|
case "datastore":
|
||||||
|
this.DataStore = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
case "internal_ip_address":
|
||||||
|
IPAddress address = (IPAddress)configuration_result;
|
||||||
|
this.m_internalEndPoint = new IPEndPoint(address, 0);
|
||||||
|
break;
|
||||||
|
case "internal_ip_port":
|
||||||
|
this.m_internalEndPoint.Port = (int)configuration_result;
|
||||||
|
break;
|
||||||
|
case "external_host_name":
|
||||||
|
if ((string)configuration_result != "SYSTEMIP")
|
||||||
|
{
|
||||||
|
this.m_externalHostName = (string)configuration_result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.m_externalHostName = Util.GetLocalHost().ToString();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "master_avatar_first":
|
||||||
|
this.MasterAvatarFirstName = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
case "master_avatar_last":
|
||||||
|
this.MasterAvatarLastName = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
case "master_avatar_pass":
|
||||||
|
this.MasterAvatarSandboxPassword = (string)configuration_result;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
using System;
|
||||||
|
using libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Types
|
||||||
|
{
|
||||||
|
class UUID
|
||||||
|
{
|
||||||
|
public LLUUID llUUID;
|
||||||
|
|
||||||
|
public UUID(string uuid)
|
||||||
|
{
|
||||||
|
llUUID = new LLUUID(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID(byte[] uuid)
|
||||||
|
{
|
||||||
|
llUUID = new LLUUID(uuid, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID(byte[] uuid, int offset)
|
||||||
|
{
|
||||||
|
llUUID = new LLUUID(uuid, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID()
|
||||||
|
{
|
||||||
|
llUUID = LLUUID.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID(ulong uuid)
|
||||||
|
{
|
||||||
|
llUUID = new LLUUID(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID(UInt32 first, UInt32 second, UInt32 third, UInt32 fourth)
|
||||||
|
{
|
||||||
|
byte[] uuid = new byte[16];
|
||||||
|
|
||||||
|
byte[] n = BitConverter.GetBytes(first);
|
||||||
|
n.CopyTo(uuid, 0);
|
||||||
|
n = BitConverter.GetBytes(second);
|
||||||
|
n.CopyTo(uuid, 4);
|
||||||
|
n = BitConverter.GetBytes(third);
|
||||||
|
n.CopyTo(uuid, 8);
|
||||||
|
n = BitConverter.GetBytes(fourth);
|
||||||
|
n.CopyTo(uuid, 12);
|
||||||
|
|
||||||
|
llUUID = new LLUUID(uuid,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return llUUID.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ToStringHyphenated()
|
||||||
|
{
|
||||||
|
return llUUID.ToStringHyphenated();
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] GetBytes()
|
||||||
|
{
|
||||||
|
return llUUID.GetBytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public UInt32[] GetInts()
|
||||||
|
{
|
||||||
|
UInt32[] ints = new UInt32[4];
|
||||||
|
ints[0] = BitConverter.ToUInt32(llUUID.Data, 0);
|
||||||
|
ints[1] = BitConverter.ToUInt32(llUUID.Data, 4);
|
||||||
|
ints[2] = BitConverter.ToUInt32(llUUID.Data, 8);
|
||||||
|
ints[3] = BitConverter.ToUInt32(llUUID.Data, 12);
|
||||||
|
|
||||||
|
return ints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LLUUID GetLLUUID()
|
||||||
|
{
|
||||||
|
return llUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint CRC()
|
||||||
|
{
|
||||||
|
return llUUID.CRC();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return llUUID.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Combine(UUID other)
|
||||||
|
{
|
||||||
|
llUUID.Combine(other.GetLLUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Combine(LLUUID other)
|
||||||
|
{
|
||||||
|
llUUID.Combine(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(Object other)
|
||||||
|
{
|
||||||
|
return llUUID.Equals(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(UUID a, UUID b)
|
||||||
|
{
|
||||||
|
return a.llUUID.Equals(b.GetLLUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(UUID a, UUID b)
|
||||||
|
{
|
||||||
|
return !a.llUUID.Equals(b.GetLLUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(UUID a, LLUUID b)
|
||||||
|
{
|
||||||
|
return a.Equals(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(UUID a, LLUUID b)
|
||||||
|
{
|
||||||
|
return !a.Equals(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 System.Security.Cryptography;
|
||||||
|
using libsecondlife;
|
||||||
|
using OpenSim.Framework.Inventory;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.User
|
||||||
|
{
|
||||||
|
public class UserProfile
|
||||||
|
{
|
||||||
|
|
||||||
|
public string firstname;
|
||||||
|
public string lastname;
|
||||||
|
public ulong homeregionhandle;
|
||||||
|
public LLVector3 homepos;
|
||||||
|
public LLVector3 homelookat;
|
||||||
|
|
||||||
|
public bool IsGridGod = false;
|
||||||
|
public bool IsLocal = true; // will be used in future for visitors from foreign grids
|
||||||
|
public string AssetURL;
|
||||||
|
public string MD5passwd;
|
||||||
|
|
||||||
|
public LLUUID CurrentSessionID;
|
||||||
|
public LLUUID CurrentSecureSessionID;
|
||||||
|
public LLUUID UUID;
|
||||||
|
public Dictionary<LLUUID, uint> Circuits = new Dictionary<LLUUID, uint>(); // tracks circuit codes
|
||||||
|
|
||||||
|
public AgentInventory Inventory;
|
||||||
|
|
||||||
|
public UserProfile()
|
||||||
|
{
|
||||||
|
Circuits = new Dictionary<LLUUID, uint>();
|
||||||
|
Inventory = new AgentInventory();
|
||||||
|
homeregionhandle = Helpers.UIntsToLong((1000 * 256), (1000 * 256));
|
||||||
|
homepos = new LLVector3();
|
||||||
|
homelookat = new LLVector3();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InitSessionData()
|
||||||
|
{
|
||||||
|
RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
|
||||||
|
|
||||||
|
byte[] randDataS = new byte[16];
|
||||||
|
byte[] randDataSS = new byte[16];
|
||||||
|
|
||||||
|
rand.GetBytes(randDataS);
|
||||||
|
rand.GetBytes(randDataSS);
|
||||||
|
|
||||||
|
CurrentSecureSessionID = new LLUUID(randDataSS,0);
|
||||||
|
CurrentSessionID = new LLUUID(randDataS,0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddSimCircuit(uint circuitCode, LLUUID regionUUID)
|
||||||
|
{
|
||||||
|
if (this.Circuits.ContainsKey(regionUUID) == false)
|
||||||
|
this.Circuits.Add(regionUUID, circuitCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue