* Optimized usings

* Shortened type references
* Removed redundant 'this' qualifier
afrisby
lbsa71 2007-10-30 09:05:31 +00:00
parent c32d1f0562
commit 67e12b95ea
353 changed files with 15459 additions and 10338 deletions

View File

@ -37,17 +37,17 @@ namespace OpenSim.Framework.Communications
public CAPSService(BaseHttpServer httpServer)
{
m_server = httpServer;
this.AddCapsSeedHandler("/CapsSeed/", CapsRequest);
AddCapsSeedHandler("/CapsSeed/", CapsRequest);
}
private void AddCapsSeedHandler(string path, RestMethod restMethod)
{
m_server.AddStreamHandler(new RestStreamHandler("POST", path, restMethod));
m_server.AddStreamHandler(new RestStreamHandler("POST", path, restMethod));
}
public string CapsRequest(string request, string path, string param)
{
System.Console.WriteLine("new caps request " + request +" from path "+ path);
System.Console.WriteLine("new caps request " + request + " from path " + path);
return "";
}
}

View File

@ -29,12 +29,9 @@
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;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Communications.Cache
@ -51,18 +48,22 @@ namespace OpenSim.Framework.Communications.Cache
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> 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, 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 Dictionary<LLUUID, Dictionary<LLUUID, int>> TimesTextureSent = new Dictionary<LLUUID, Dictionary<LLUUID, int>>();
private Dictionary<LLUUID, Dictionary<LLUUID, int>> TimesTextureSent =
new Dictionary<LLUUID, Dictionary<LLUUID, int>>();
public Dictionary<LLUUID, AssetRequestsList> RequestLists = new Dictionary<LLUUID, AssetRequestsList>();
@ -76,19 +77,18 @@ namespace OpenSim.Framework.Communications.Cache
/// </summary>
public AssetCache(IAssetServer assetServer)
{
OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSTORAGE","Creating Asset cache");
MainLog.Instance.Verbose("ASSETSTORAGE", "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();
_assetCacheThread = new Thread(new ThreadStart(RunAssetManager));
_assetCacheThread.IsBackground = true;
_assetCacheThread.Start();
TextureSenderThread = new Thread(new ThreadStart(ProcessTextureSenders));
TextureSenderThread.IsBackground = true;
TextureSenderThread.Start();
}
/// <summary>
@ -100,8 +100,8 @@ namespace OpenSim.Framework.Communications.Cache
{
try
{
this.ProcessAssetQueue();
this.ProcessTextureQueue();
ProcessAssetQueue();
ProcessTextureQueue();
Thread.Sleep(500);
}
catch (Exception e)
@ -115,13 +115,13 @@ namespace OpenSim.Framework.Communications.Cache
public AssetBase GetAsset(LLUUID assetID)
{
AssetBase asset = null;
if (this.Textures.ContainsKey(assetID))
if (Textures.ContainsKey(assetID))
{
asset = this.Textures[assetID];
asset = Textures[assetID];
}
else if (this.Assets.ContainsKey(assetID))
else if (Assets.ContainsKey(assetID))
{
asset = this.Assets[assetID];
asset = Assets[assetID];
}
return asset;
}
@ -129,13 +129,13 @@ namespace OpenSim.Framework.Communications.Cache
public void GetAsset(LLUUID assetID, AssetRequestCallback callback)
{
AssetBase asset = null;
if (this.Textures.ContainsKey(assetID))
if (Textures.ContainsKey(assetID))
{
asset = this.Textures[assetID];
asset = Textures[assetID];
}
else if (this.Assets.ContainsKey(assetID))
else if (Assets.ContainsKey(assetID))
{
asset = this.Assets[assetID];
asset = Assets[assetID];
}
if (asset != null)
@ -145,7 +145,7 @@ namespace OpenSim.Framework.Communications.Cache
else
{
NewAssetRequest req = new NewAssetRequest(assetID, callback);
if (this.RequestLists.ContainsKey(assetID))
if (RequestLists.ContainsKey(assetID))
{
lock (RequestLists)
{
@ -161,7 +161,7 @@ namespace OpenSim.Framework.Communications.Cache
RequestLists.Add(assetID, reqList);
}
}
this._assetServer.FetchAsset(assetID, false);
_assetServer.FetchAsset(assetID, false);
}
}
@ -171,22 +171,23 @@ namespace OpenSim.Framework.Communications.Cache
AssetBase asset = GetAsset(assetID);
if (asset == null)
{
this._assetServer.FetchAsset(assetID, isTexture);
_assetServer.FetchAsset(assetID, isTexture);
}
return asset;
}
public void AddAsset(AssetBase asset)
{
//System.Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated());
//System.Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated());
if (asset.Type == 0)
{
//Console.WriteLine("which is a texture");
if (!Textures.ContainsKey(asset.FullID))
{ //texture
{
//texture
TextureImage textur = new TextureImage(asset);
Textures.Add(textur.FullID, textur);
if(!asset.Temporary)
if (!asset.Temporary)
_assetServer.StoreAndCommitAsset(asset);
}
else
@ -219,49 +220,47 @@ namespace OpenSim.Framework.Communications.Cache
/// </summary>
private void ProcessTextureQueue()
{
if (this.TextureRequests.Count == 0)
if (TextureRequests.Count == 0)
{
//no requests waiting
return;
}
int num;
num = this.TextureRequests.Count;
num = TextureRequests.Count;
AssetRequest req;
for (int i = 0; i < num; i++)
{
req = (AssetRequest)this.TextureRequests[i];
if (!this.SendingTextures.ContainsKey(req.ImageInfo.FullID))
req = (AssetRequest) TextureRequests[i];
if (!SendingTextures.ContainsKey(req.ImageInfo.FullID))
{
//Console.WriteLine("new texture to send");
TextureSender sender = new TextureSender(req);
//sender.OnComplete += this.TextureSent;
this.SendingTextures.Add(req.ImageInfo.FullID, sender);
this.QueueTextures.Enqueue(sender);
SendingTextures.Add(req.ImageInfo.FullID, sender);
QueueTextures.Enqueue(sender);
}
}
this.TextureRequests.Clear();
TextureRequests.Clear();
}
public void ProcessTextureSenders()
{
while (true)
{
TextureSender sender = this.QueueTextures.Dequeue();
TextureSender sender = QueueTextures.Dequeue();
bool finished = sender.SendTexture();
if (finished)
{
this.TextureSent(sender);
TextureSent(sender);
}
else
{
// Console.WriteLine("readding texture");
this.QueueTextures.Enqueue(sender);
QueueTextures.Enqueue(sender);
}
}
}
@ -271,16 +270,16 @@ namespace OpenSim.Framework.Communications.Cache
/// <param name="sender"></param>
public void TextureSent(TextureSender sender)
{
if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID))
if (SendingTextures.ContainsKey(sender.request.ImageInfo.FullID))
{
this.SendingTextures.Remove(sender.request.ImageInfo.FullID);
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
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
@ -292,48 +291,48 @@ namespace OpenSim.Framework.Communications.Cache
//Console.WriteLine("asset recieved from asset server");
TextureImage image = new TextureImage(asset);
if (!this.Textures.ContainsKey(image.FullID))
if (!Textures.ContainsKey(image.FullID))
{
this.Textures.Add(image.FullID, image);
if (this.RequestedTextures.ContainsKey(image.FullID))
Textures.Add(image.FullID, image);
if (RequestedTextures.ContainsKey(image.FullID))
{
AssetRequest req = this.RequestedTextures[image.FullID];
AssetRequest req = 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;
req.NumPackets = 1 + (int) (image.Data.Length - 600)/1000;
}
else
{
req.NumPackets = 1;
}
this.RequestedTextures.Remove(image.FullID);
this.TextureRequests.Add(req);
RequestedTextures.Remove(image.FullID);
TextureRequests.Add(req);
}
}
}
else
{
AssetInfo assetInf = new AssetInfo(asset);
if (!this.Assets.ContainsKey(assetInf.FullID))
if (!Assets.ContainsKey(assetInf.FullID))
{
this.Assets.Add(assetInf.FullID, assetInf);
if (this.RequestedAssets.ContainsKey(assetInf.FullID))
Assets.Add(assetInf.FullID, assetInf);
if (RequestedAssets.ContainsKey(assetInf.FullID))
{
AssetRequest req = this.RequestedAssets[assetInf.FullID];
AssetRequest req = 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;
req.NumPackets = 1 + (int) (assetInf.Data.Length - 600 + 999)/1000;
}
else
{
req.NumPackets = 1;
}
this.RequestedAssets.Remove(assetInf.FullID);
this.AssetRequests.Add(req);
RequestedAssets.Remove(assetInf.FullID);
AssetRequests.Add(req);
}
}
}
@ -345,7 +344,7 @@ namespace OpenSim.Framework.Communications.Cache
{
req.Callback(asset.FullID, asset);
}
lock (RequestLists)
{
RequestLists.Remove(asset.FullID);
@ -373,6 +372,7 @@ namespace OpenSim.Framework.Communications.Cache
}
#region Assets
/// <summary>
///
/// </summary>
@ -396,11 +396,11 @@ namespace OpenSim.Framework.Communications.Cache
}
//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))
if (!Assets.ContainsKey(requestID))
{
//not found asset
// so request from asset server
if (!this.RequestedAssets.ContainsKey(requestID))
if (!RequestedAssets.ContainsKey(requestID))
{
AssetRequest request = new AssetRequest();
request.RequestUser = userInfo;
@ -408,13 +408,13 @@ namespace OpenSim.Framework.Communications.Cache
request.TransferRequestID = transferRequest.TransferInfo.TransferID;
request.AssetRequestSource = source;
request.Params = transferRequest.TransferInfo.Params;
this.RequestedAssets.Add(requestID, request);
this._assetServer.FetchAsset(requestID, false);
RequestedAssets.Add(requestID, request);
_assetServer.FetchAsset(requestID, false);
}
return;
}
//it is in our cache
AssetInfo asset = this.Assets[requestID];
AssetInfo asset = Assets[requestID];
//work out how many packets it should be sent in
// and add to the AssetRequests list
@ -429,14 +429,14 @@ namespace OpenSim.Framework.Communications.Cache
if (asset.Data.LongLength > 600)
{
//over 600 bytes so split up file
req.NumPackets = 1 + (int)(asset.Data.Length - 600 + 999) / 1000;
req.NumPackets = 1 + (int) (asset.Data.Length - 600 + 999)/1000;
}
else
{
req.NumPackets = 1;
}
this.AssetRequests.Add(req);
AssetRequests.Add(req);
}
/// <summary>
@ -444,17 +444,17 @@ namespace OpenSim.Framework.Communications.Cache
/// </summary>
private void ProcessAssetQueue()
{
if (this.AssetRequests.Count == 0)
if (AssetRequests.Count == 0)
{
//no requests waiting
return;
}
int num;
if (this.AssetRequests.Count < 5)
if (AssetRequests.Count < 5)
{
//lower than 5 so do all of them
num = this.AssetRequests.Count;
num = AssetRequests.Count;
}
else
{
@ -463,7 +463,7 @@ namespace OpenSim.Framework.Communications.Cache
AssetRequest req;
for (int i = 0; i < num; i++)
{
req = (AssetRequest)this.AssetRequests[i];
req = (AssetRequest) AssetRequests[i];
//Console.WriteLine("sending asset " + req.RequestAssetID);
TransferInfoPacket Transfer = new TransferInfoPacket();
Transfer.TransferInfo.ChannelType = 2;
@ -473,7 +473,7 @@ namespace OpenSim.Framework.Communications.Cache
{
Transfer.TransferInfo.Params = new byte[20];
Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
int assType = (int)req.AssetInf.Type;
int assType = (int) req.AssetInf.Type;
Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4);
}
else if (req.AssetRequestSource == 3)
@ -483,7 +483,7 @@ namespace OpenSim.Framework.Communications.Cache
//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.Size = (int) req.AssetInf.Data.Length;
Transfer.TransferInfo.TransferID = req.TransferRequestID;
req.RequestUser.OutPacket(Transfer);
@ -533,19 +533,19 @@ namespace OpenSim.Framework.Communications.Cache
req.RequestUser.OutPacket(TransferPacket);
}
}
}
//remove requests that have been completed
for (int i = 0; i < num; i++)
{
this.AssetRequests.RemoveAt(0);
AssetRequests.RemoveAt(0);
}
}
#endregion
#region Textures
/// <summary>
///
/// </summary>
@ -553,21 +553,21 @@ namespace OpenSim.Framework.Communications.Cache
/// <param name="imageID"></param>
public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID, uint packetNumber, int discard)
{
// System.Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber);
// System.Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber);
//check to see if texture is in local cache, if not request from asset server
if (!this.AvatarRecievedTextures.ContainsKey(userInfo.AgentId))
if (!AvatarRecievedTextures.ContainsKey(userInfo.AgentId))
{
this.AvatarRecievedTextures.Add(userInfo.AgentId, new List<LLUUID>());
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 (!Textures.ContainsKey(imageID))
{
if (!this.RequestedTextures.ContainsKey(imageID))
if (!RequestedTextures.ContainsKey(imageID))
{
//not is cache so request from asset server
AssetRequest request = new AssetRequest();
@ -575,14 +575,14 @@ namespace OpenSim.Framework.Communications.Cache
request.RequestAssetID = imageID;
request.IsTextureRequest = true;
request.DiscardLevel = discard;
this.RequestedTextures.Add(imageID, request);
this._assetServer.FetchAsset(imageID, true);
RequestedTextures.Add(imageID, request);
_assetServer.FetchAsset(imageID, true);
}
return;
}
// System.Console.WriteLine("texture already in cache");
TextureImage imag = this.Textures[imageID];
// System.Console.WriteLine("texture already in cache");
TextureImage imag = Textures[imageID];
AssetRequest req = new AssetRequest();
req.RequestUser = userInfo;
req.RequestAssetID = imageID;
@ -594,7 +594,7 @@ namespace OpenSim.Framework.Communications.Cache
{
//Console.WriteLine("{0}", imag.Data.LongLength);
//over 600 bytes so split up file
req.NumPackets = 2 + (int)(imag.Data.Length - 601) / 1000;
req.NumPackets = 2 + (int) (imag.Data.Length - 601)/1000;
//Console.WriteLine("texture is " + imag.Data.Length + " which we will send in " +req.NumPackets +" packets");
}
else
@ -603,12 +603,11 @@ namespace OpenSim.Framework.Communications.Cache
}
if (packetNumber != 0)
{
req.PacketCounter = (int)packetNumber;
req.PacketCounter = (int) packetNumber;
}
this.TextureRequests.Add(req);
TextureRequests.Add(req);
}
#endregion
public class AssetRequest
@ -630,7 +629,6 @@ namespace OpenSim.Framework.Communications.Cache
public AssetRequest()
{
}
}
@ -638,7 +636,6 @@ namespace OpenSim.Framework.Communications.Cache
{
public AssetInfo()
{
}
public AssetInfo(AssetBase aBase)
@ -656,7 +653,6 @@ namespace OpenSim.Framework.Communications.Cache
{
public TextureImage()
{
}
public TextureImage(AssetBase aBase)
@ -678,7 +674,6 @@ namespace OpenSim.Framework.Communications.Cache
public TextureSender(AssetRequest req)
{
request = req;
}
public bool SendTexture()
@ -686,7 +681,8 @@ namespace OpenSim.Framework.Communications.Cache
SendPacket();
counter++;
if ((request.PacketCounter >= request.NumPackets) | counter > 100 | (request.NumPackets == 1) | (request.DiscardLevel == -1))
if ((request.PacketCounter >= request.NumPackets) | counter > 100 | (request.NumPackets == 1) |
(request.DiscardLevel == -1))
{
return true;
}
@ -707,7 +703,7 @@ namespace OpenSim.Framework.Communications.Cache
im.Header.Reliable = false;
im.ImageID.Packets = 1;
im.ImageID.ID = req.ImageInfo.FullID;
im.ImageID.Size = (uint)req.ImageInfo.Data.Length;
im.ImageID.Size = (uint) req.ImageInfo.Data.Length;
im.ImageData.Data = req.ImageInfo.Data;
im.ImageID.Codec = 2;
req.RequestUser.OutPacket(im);
@ -721,9 +717,9 @@ namespace OpenSim.Framework.Communications.Cache
//more than one packet so split file up
ImageDataPacket im = new ImageDataPacket();
im.Header.Reliable = false;
im.ImageID.Packets = (ushort)(req.NumPackets);
im.ImageID.Packets = (ushort) (req.NumPackets);
im.ImageID.ID = req.ImageInfo.FullID;
im.ImageID.Size = (uint)req.ImageInfo.Data.Length;
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;
@ -742,19 +738,18 @@ namespace OpenSim.Framework.Communications.Cache
//more than one packet so split file up
ImagePacketPacket im = new ImagePacketPacket();
im.Header.Reliable = false;
im.ImageID.Packet = (ushort)(req.PacketCounter);
im.ImageID.Packet = (ushort) (req.PacketCounter);
im.ImageID.ID = req.ImageInfo.FullID;
int size = req.ImageInfo.Data.Length - 600 - (1000 * (req.PacketCounter - 1));
int size = req.ImageInfo.Data.Length - 600 - (1000*(req.PacketCounter - 1));
if (size > 1000) size = 1000;
//Console.WriteLine("length= {0} counter= {1} size= {2}",req.ImageInfo.Data.Length, req.PacketCounter, size);
im.ImageData.Data = new byte[size];
Array.Copy(req.ImageInfo.Data, 600 + (1000 * (req.PacketCounter - 1)), im.ImageData.Data, 0, 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.ImageInfo.FullID);
}
}
private void SaveAssetToFile(string filename, byte[] data)
@ -789,7 +784,5 @@ namespace OpenSim.Framework.Communications.Cache
AssetID = assetID;
Callback = callback;
}
}
}
}

View File

@ -25,18 +25,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using Db4objects.Db4o;
using Db4objects.Db4o.Query;
using libsecondlife;
using Nini.Config;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework;
namespace OpenSim.Framework.Communications.Cache
{
@ -50,7 +43,7 @@ namespace OpenSim.Framework.Communications.Cache
yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap"));
db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap"));
MainLog.Instance.Verbose("ASSETS","Db4 Asset database creation");
MainLog.Instance.Verbose("ASSETS", "Db4 Asset database creation");
if (!yapfile)
{
@ -68,29 +61,29 @@ namespace OpenSim.Framework.Communications.Cache
db.Commit();
}
override public void Close()
public override void Close()
{
base.Close();
if (db != null)
{
MainLog.Instance.Verbose("ASSETSERVER","Closing local asset server database");
MainLog.Instance.Verbose("ASSETSERVER", "Closing local asset server database");
db.Close();
}
}
override protected void RunRequests()
protected override void RunRequests()
{
while (true)
{
byte[] idata = null;
bool found = false;
AssetStorage foundAsset = null;
ARequest req = this._assetRequests.Dequeue();
ARequest req = _assetRequests.Dequeue();
IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID));
if (result.Count > 0)
{
foundAsset = (AssetStorage)result.Next();
foundAsset = (AssetStorage) result.Next();
found = true;
}
@ -110,12 +103,10 @@ namespace OpenSim.Framework.Communications.Cache
//asset.FullID = ;
_receiver.AssetNotFound(req.AssetID);
}
}
}
override protected void StoreAsset(AssetBase asset)
protected override void StoreAsset(AssetBase asset)
{
AssetStorage store = new AssetStorage();
store.Data = asset.Data;
@ -148,6 +139,7 @@ namespace OpenSim.Framework.Communications.Cache
{
_findID = find;
}
public bool Match(AssetStorage asset)
{
return (asset.UUID == _findID);

View File

@ -5,8 +5,6 @@ using System.Threading;
using libsecondlife;
using Nini.Config;
using OpenSim.Framework.Console;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework;
namespace OpenSim.Framework.Communications.Cache
{
@ -36,13 +34,12 @@ namespace OpenSim.Framework.Communications.Cache
public AssetServerBase()
{
MainLog.Instance.Verbose("ASSETSERVER", "Starting asset storage system");
_assetRequests = new BlockingQueue<ARequest>();
OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSERVER","Starting asset storage system");
this._assetRequests = new BlockingQueue<ARequest>();
this._localAssetServerThread = new Thread(RunRequests);
this._localAssetServerThread.IsBackground = true;
this._localAssetServerThread.Start();
_localAssetServerThread = new Thread(RunRequests);
_localAssetServerThread.IsBackground = true;
_localAssetServerThread.Start();
}
public void LoadAsset(AssetBase info, bool image, string filename)
@ -57,7 +54,7 @@ namespace OpenSim.Framework.Communications.Cache
FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
byte[] idata = new byte[numBytes];
BinaryReader br = new BinaryReader(fStream);
idata = br.ReadBytes((int)numBytes);
idata = br.ReadBytes((int) numBytes);
br.Close();
fStream.Close();
info.Data = idata;
@ -66,7 +63,7 @@ namespace OpenSim.Framework.Communications.Cache
public void SetReceiver(IAssetReceiver receiver)
{
this._receiver = receiver;
_receiver = receiver;
}
public void FetchAsset(LLUUID assetID, bool isTexture)
@ -74,7 +71,7 @@ namespace OpenSim.Framework.Communications.Cache
ARequest req = new ARequest();
req.AssetID = assetID;
req.IsTexture = isTexture;
this._assetRequests.Enqueue(req);
_assetRequests.Enqueue(req);
}
public void UpdateAsset(AssetBase asset)
@ -102,7 +99,6 @@ namespace OpenSim.Framework.Communications.Cache
public void SetServerInfo(string ServerUrl, string ServerKey)
{
}
public virtual List<AssetBase> GetDefaultAssets()
@ -175,8 +171,8 @@ namespace OpenSim.Framework.Communications.Cache
// System.Console.WriteLine("loading asset into database");
string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated());
string name = source.Configs[i].GetString("name", "");
sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0);
sbyte invType = (sbyte)source.Configs[i].GetInt("inventoryType", 0);
sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0);
sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0);
string fileName = source.Configs[i].GetString("fileName", "");
AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false);
@ -189,4 +185,4 @@ namespace OpenSim.Framework.Communications.Cache
assets.ForEach(action);
}
}
}
}

View File

@ -25,15 +25,8 @@
* 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;
using OpenSim.Framework.Data;
namespace OpenSim.Framework.Communications.Cache
{
@ -41,7 +34,10 @@ namespace OpenSim.Framework.Communications.Cache
{
// Fields
public CommunicationsManager CommsManager;
public Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions = new Dictionary<LLUUID, AgentAssetTransactions>();
public Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions =
new Dictionary<LLUUID, AgentAssetTransactions>();
private bool m_dumpAssetsToFile;
public AssetTransactionManager(CommunicationsManager commsManager, bool dumpAssetsToFile)
@ -53,10 +49,10 @@ namespace OpenSim.Framework.Communications.Cache
// Methods
public AgentAssetTransactions AddUser(LLUUID userID)
{
if (!this.AgentTransactions.ContainsKey(userID))
if (!AgentTransactions.ContainsKey(userID))
{
AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile);
this.AgentTransactions.Add(userID, transactions);
AgentTransactions.Add(userID, transactions);
return transactions;
}
return null;
@ -64,27 +60,30 @@ namespace OpenSim.Framework.Communications.Cache
public AgentAssetTransactions GetUserTransActions(LLUUID userID)
{
if (this.AgentTransactions.ContainsKey(userID))
if (AgentTransactions.ContainsKey(userID))
{
return this.AgentTransactions[userID];
return 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)
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);
AgentAssetTransactions transactions = GetUserTransActions(remoteClient.AgentId);
if (transactions != null)
{
transactions.RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask);
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, bool storeLocal)
public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type,
byte[] data, bool storeLocal)
{
// Console.WriteLine("asset upload of " + assetID);
AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId);
AgentAssetTransactions transactions = GetUserTransActions(remoteClient.AgentId);
if (transactions != null)
{
AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
@ -97,7 +96,7 @@ namespace OpenSim.Framework.Communications.Cache
public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
{
AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId);
AgentAssetTransactions transactions = GetUserTransActions(remoteClient.AgentId);
if (transactions != null)
{
transactions.HandleXfer(xferID, packetID, data);

View File

@ -26,17 +26,12 @@
*
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework;
using OpenSim.Region.Capabilities;
using OpenSim.Framework.Servers;
using OpenSim.Region.Capabilities;
namespace OpenSim.Framework.Communications.Cache
{
@ -53,7 +48,7 @@ namespace OpenSim.Framework.Communications.Cache
// Methods
public AgentAssetTransactions(LLUUID agentID, AssetTransactionManager manager, bool dumpAssetsToFile)
{
this.UserID = agentID;
UserID = agentID;
Manager = manager;
m_dumpAssetsToFile = dumpAssetsToFile;
}
@ -61,24 +56,24 @@ namespace OpenSim.Framework.Communications.Cache
public AssetCapsUploader RequestCapsUploader()
{
AssetCapsUploader uploader = new AssetCapsUploader();
this.CapsUploaders.Add(uploader);
CapsUploaders.Add(uploader);
return uploader;
}
public NoteCardCapsUpdate RequestNoteCardUpdater()
{
NoteCardCapsUpdate update = new NoteCardCapsUpdate();
this.NotecardUpdaters.Add(update);
NotecardUpdaters.Add(update);
return update;
}
public AssetXferUploader RequestXferUploader(LLUUID transactionID)
{
if (!this.XferUploaders.ContainsKey(transactionID))
if (!XferUploaders.ContainsKey(transactionID))
{
AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile);
this.XferUploaders.Add(transactionID, uploader);
XferUploaders.Add(transactionID, uploader);
return uploader;
}
return null;
@ -86,7 +81,7 @@ namespace OpenSim.Framework.Communications.Cache
public void HandleXfer(ulong xferID, uint packetID, byte[] data)
{
foreach (AssetXferUploader uploader in this.XferUploaders.Values)
foreach (AssetXferUploader uploader in XferUploaders.Values)
{
if (uploader.XferID == xferID)
{
@ -96,17 +91,21 @@ namespace OpenSim.Framework.Communications.Cache
}
}
public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask)
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))
if (XferUploaders.ContainsKey(transactionID))
{
this.XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask);
XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID,
callbackID, description, name, invType, type,
wearableType, nextOwnerMask);
}
}
public AssetBase GetTransactionAsset(LLUUID transactionID)
{
if (this.XferUploaders.ContainsKey(transactionID))
if (XferUploaders.ContainsKey(transactionID))
{
return XferUploaders[transactionID].GetAssetData();
}
@ -130,15 +129,16 @@ namespace OpenSim.Framework.Communications.Cache
public event UpLoadedAsset OnUpLoad;
// Methods
public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer, bool dumpImageToFile)
public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem,
LLUUID folderID, string path, BaseHttpServer httpServer, bool dumpImageToFile)
{
this.m_assetName = assetName;
this.m_assetDescription = assetDescription;
this.m_folderID = folderID;
this.newAssetID = assetID;
this.inventoryItemID = inventoryItem;
this.uploaderPath = path;
this.httpListener = httpServer;
m_assetName = assetName;
m_assetDescription = assetDescription;
m_folderID = folderID;
newAssetID = assetID;
inventoryItemID = inventoryItem;
uploaderPath = path;
httpListener = httpServer;
m_dumpImageToFile = dumpImageToFile;
}
@ -156,18 +156,18 @@ namespace OpenSim.Framework.Communications.Cache
LLUUID inventoryItemID = this.inventoryItemID;
string text = "";
LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete();
complete.new_asset = this.newAssetID.ToStringHyphenated();
complete.new_asset = newAssetID.ToStringHyphenated();
complete.new_inventory_item = inventoryItemID;
complete.state = "complete";
text = LLSDHelpers.SerialiseLLSDReply(complete);
this.httpListener.RemoveStreamHandler("POST", this.uploaderPath);
if (this.m_dumpImageToFile)
httpListener.RemoveStreamHandler("POST", uploaderPath);
if (m_dumpImageToFile)
{
this.SaveImageToFile(this.m_assetName + ".jp2", data);
SaveImageToFile(m_assetName + ".jp2", data);
}
if (this.OnUpLoad != null)
if (OnUpLoad != null)
{
this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data, "" , "");
OnUpLoad(m_assetName, "description", newAssetID, inventoryItemID, LLUUID.Zero, data, "", "");
}
return text;
}
@ -196,90 +196,91 @@ namespace OpenSim.Framework.Communications.Cache
public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile)
{
this.m_userTransactions = transactions;
m_userTransactions = transactions;
m_dumpAssetToFile = dumpAssetToFile;
}
// Methods
public void HandleXferPacket(ulong xferID, uint packetID, byte[] data)
{
if (this.XferID == xferID)
if (XferID == xferID)
{
if (this.Asset.Data.Length > 1)
if (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;
byte[] destinationArray = new byte[Asset.Data.Length + data.Length];
Array.Copy(Asset.Data, 0, destinationArray, 0, Asset.Data.Length);
Array.Copy(data, 0, destinationArray, Asset.Data.Length, data.Length);
Asset.Data = destinationArray;
}
else
{
byte[] buffer2 = new byte[data.Length - 4];
Array.Copy(data, 4, buffer2, 0, data.Length - 4);
this.Asset.Data = buffer2;
Asset.Data = buffer2;
}
ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket();
newPack.XferID.ID = xferID;
newPack.XferID.Packet = packetID;
this.ourClient.OutPacket(newPack);
ourClient.OutPacket(newPack);
if ((packetID & 0x80000000) != 0)
{
this.SendCompleteMessage();
SendCompleteMessage();
}
}
}
public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, bool storeLocal)
public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data,
bool storeLocal)
{
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;
this.m_storeLocal = storeLocal;
if (this.Asset.Data.Length > 2)
ourClient = remoteClient;
Asset = new AssetBase();
Asset.FullID = assetID;
Asset.InvType = type;
Asset.Type = type;
Asset.Data = data;
Asset.Name = "blank";
Asset.Description = "empty";
TransactionID = transaction;
m_storeLocal = storeLocal;
if (Asset.Data.Length > 2)
{
this.SendCompleteMessage();
SendCompleteMessage();
}
else
{
this.ReqestStartXfer();
ReqestStartXfer();
}
}
protected void ReqestStartXfer()
{
this.UploadComplete = false;
this.XferID = Util.GetNextXferID();
UploadComplete = false;
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.ID = XferID;
newPack.XferID.VFileType = Asset.Type;
newPack.XferID.VFileID = Asset.FullID;
newPack.XferID.FilePath = 0;
newPack.XferID.Filename = new byte[0];
this.ourClient.OutPacket(newPack);
ourClient.OutPacket(newPack);
}
protected void SendCompleteMessage()
{
this.UploadComplete = true;
UploadComplete = true;
AssetUploadCompletePacket newPack = new AssetUploadCompletePacket();
newPack.AssetBlock.Type = this.Asset.Type;
newPack.AssetBlock.Type = Asset.Type;
newPack.AssetBlock.Success = true;
newPack.AssetBlock.UUID = this.Asset.FullID;
this.ourClient.OutPacket(newPack);
this.m_finished = true;
newPack.AssetBlock.UUID = Asset.FullID;
ourClient.OutPacket(newPack);
m_finished = true;
if (m_createItem)
{
DoCreateItem();
}
else if (m_storeLocal)
{
this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset);
m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(Asset);
}
// Console.WriteLine("upload complete "+ this.TransactionID);
@ -287,8 +288,10 @@ namespace OpenSim.Framework.Communications.Cache
if (m_dumpAssetToFile)
{
DateTime now = DateTime.Now;
string filename = String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, Asset.Name, Asset.Type );
SaveAssetToFile(filename, this.Asset.Data);
string filename =
String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}", now.Year, now.Month, now.Day,
now.Hour, now.Minute, now.Second, Asset.Name, Asset.Type);
SaveAssetToFile(filename, Asset.Data);
}
}
@ -301,20 +304,22 @@ namespace OpenSim.Framework.Communications.Cache
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)
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)
if (TransactionID == transactionID)
{
this.InventFolder = folderID;
this.m_name = name;
this.m_description = description;
InventFolder = folderID;
m_name = name;
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;
nextPerm = nextOwnerMask;
Asset.Name = name;
Asset.Description = description;
Asset.Type = type;
Asset.InvType = invType;
m_createItem = true;
if (m_finished)
{
@ -326,22 +331,23 @@ namespace OpenSim.Framework.Communications.Cache
private void DoCreateItem()
{
//really need to fix this call, if lbsa71 saw this he would die.
this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset);
CachedUserInfo userInfo = m_userTransactions.Manager.CommsManager.UserProfileCache.GetUserDetails(ourClient.AgentId);
m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(Asset);
CachedUserInfo userInfo =
m_userTransactions.Manager.CommsManager.UserProfileCache.GetUserDetails(ourClient.AgentId);
if (userInfo != null)
{
InventoryItemBase item = new InventoryItemBase();
item.avatarID = this.ourClient.AgentId;
item.avatarID = ourClient.AgentId;
item.creatorsID = ourClient.AgentId;
item.inventoryID = LLUUID.Random();
item.assetID = Asset.FullID;
item.inventoryDescription = this.m_description;
item.inventoryDescription = m_description;
item.inventoryName = m_name;
item.assetType = type;
item.invType = this.invType;
item.parentFolderID = this.InventFolder;
item.invType = invType;
item.parentFolderID = InventFolder;
item.inventoryCurrentPermissions = 2147483647;
item.inventoryNextPermissions = this.nextPerm;
item.inventoryNextPermissions = nextPerm;
userInfo.AddItem(ourClient.AgentId, item);
ourClient.SendInventoryItemUpdate(item);
@ -350,14 +356,13 @@ namespace OpenSim.Framework.Communications.Cache
public void UpdateInventoryItem(LLUUID itemID)
{
}
public AssetBase GetAssetData()
{
if (m_finished)
{
return this.Asset;
return Asset;
}
return null;
}
@ -379,10 +384,10 @@ namespace OpenSim.Framework.Communications.Cache
// Methods
public void Initialise(LLUUID inventoryItem, string path, BaseHttpServer httpServer)
{
this.inventoryItemID = inventoryItem;
this.uploaderPath = path;
this.httpListener = httpServer;
this.newAssetID = LLUUID.Random();
inventoryItemID = inventoryItem;
uploaderPath = path;
httpListener = httpServer;
newAssetID = LLUUID.Random();
}
private void SaveImageToFile(string filename, byte[] data)
@ -399,18 +404,18 @@ namespace OpenSim.Framework.Communications.Cache
LLUUID inventoryItemID = this.inventoryItemID;
string text = "";
LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete();
complete.new_asset = this.newAssetID.ToStringHyphenated();
complete.new_asset = newAssetID.ToStringHyphenated();
complete.new_inventory_item = inventoryItemID;
complete.state = "complete";
text = LLSDHelpers.SerialiseLLSDReply(complete);
this.httpListener.RemoveStreamHandler("POST", this.uploaderPath);
if (this.SaveImages)
httpListener.RemoveStreamHandler("POST", uploaderPath);
if (SaveImages)
{
this.SaveImageToFile(this.m_assetName + "notecard.txt", data);
SaveImageToFile(m_assetName + "notecard.txt", data);
}
if (this.OnUpLoad != null)
if (OnUpLoad != null)
{
this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data, "" , "" );
OnUpLoad(m_assetName, "description", newAssetID, inventoryItemID, LLUUID.Zero, data, "", "");
}
return text;
}

View File

@ -26,7 +26,6 @@
*
*/
using libsecondlife;
using OpenSim.Framework;
namespace OpenSim.Framework.Communications.Cache
{
@ -45,22 +44,22 @@ namespace OpenSim.Framework.Communications.Cache
// Methods
public void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo)
{
if (userID == this.UserProfile.UUID)
if (userID == UserProfile.UUID)
{
if (this.RootFolder == null)
if (RootFolder == null)
{
if (folderInfo.parentID == LLUUID.Zero)
{
this.RootFolder = folderInfo;
RootFolder = folderInfo;
}
}
else if (this.RootFolder.folderID == folderInfo.parentID)
else if (RootFolder.folderID == folderInfo.parentID)
{
this.RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo);
RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo);
}
else
{
InventoryFolderImpl folder = this.RootFolder.HasSubFolder(folderInfo.parentID);
InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.parentID);
if (folder != null)
{
folder.SubFolders.Add(folderInfo.folderID, folderInfo);
@ -71,18 +70,18 @@ namespace OpenSim.Framework.Communications.Cache
public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo)
{
if ((userID == this.UserProfile.UUID) && (this.RootFolder != null))
if ((userID == UserProfile.UUID) && (RootFolder != null))
{
if (itemInfo.parentFolderID == this.RootFolder.folderID)
if (itemInfo.parentFolderID == RootFolder.folderID)
{
this.RootFolder.Items.Add(itemInfo.inventoryID, itemInfo);
RootFolder.Items.Add(itemInfo.inventoryID, itemInfo);
}
else
{
InventoryFolderImpl folder = this.RootFolder.HasSubFolder(itemInfo.parentFolderID);
InventoryFolderImpl folder = RootFolder.HasSubFolder(itemInfo.parentFolderID);
if (folder != null)
{
folder.Items.Add(itemInfo.inventoryID, itemInfo);
folder.Items.Add(itemInfo.inventoryID, itemInfo);
}
}
}
@ -90,30 +89,30 @@ namespace OpenSim.Framework.Communications.Cache
public void AddItem(LLUUID userID, InventoryItemBase itemInfo)
{
if ((userID == this.UserProfile.UUID) && (this.RootFolder != null))
if ((userID == UserProfile.UUID) && (RootFolder != null))
{
this.ItemReceive(userID, itemInfo);
this.m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo);
ItemReceive(userID, itemInfo);
m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo);
}
}
public void UpdateItem(LLUUID userID, InventoryItemBase itemInfo)
{
if ((userID == this.UserProfile.UUID) && (this.RootFolder != null))
if ((userID == UserProfile.UUID) && (RootFolder != null))
{
this.m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo);
m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo);
}
}
public bool DeleteItem(LLUUID userID, InventoryItemBase item)
{
bool result = false;
if ((userID == this.UserProfile.UUID) && (this.RootFolder != null))
if ((userID == UserProfile.UUID) && (RootFolder != null))
{
result = RootFolder.DeleteItem(item.inventoryID);
if (result)
{
this.m_parentCommsManager.InventoryService.DeleteInventoryItem(userID, item);
m_parentCommsManager.InventoryService.DeleteInventoryItem(userID, item);
}
}
return result;

View File

@ -25,19 +25,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Reflection;
using System.Xml.Serialization;
using libsecondlife;
using Nini.Config;
using OpenSim.Framework.Console;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
namespace OpenSim.Framework.Communications.Cache
{
@ -63,7 +57,6 @@ namespace OpenSim.Framework.Communications.Cache
Stream s = null;
try
{
MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", assetID.ToString());
RestClient rc = new RestClient(_assetServerUrl);
@ -77,8 +70,8 @@ namespace OpenSim.Framework.Communications.Cache
if (s.Length > 0)
{
XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
AssetBase asset = (AssetBase)xs.Deserialize(s);
XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
AssetBase asset = (AssetBase) xs.Deserialize(s);
_receiver.AssetReceived(asset, isTexture);
}
@ -106,7 +99,7 @@ namespace OpenSim.Framework.Communications.Cache
{
MemoryStream s = new MemoryStream();
XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
xs.Serialize(s, asset);
RestClient rc = new RestClient(_assetServerUrl);
rc.AddResourcePath("assets");
@ -129,7 +122,7 @@ namespace OpenSim.Framework.Communications.Cache
throw new Exception("The method or operation is not implemented.");
}
public System.Collections.Generic.List<AssetBase> GetDefaultAssets()
public List<AssetBase> GetDefaultAssets()
{
throw new Exception("The method or operation is not implemented.");
}
@ -156,4 +149,4 @@ namespace OpenSim.Framework.Communications.Cache
#endregion
}
}
}

View File

@ -25,14 +25,8 @@
* 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;
namespace OpenSim.Framework.Communications.Cache
{
@ -44,17 +38,16 @@ namespace OpenSim.Framework.Communications.Cache
public InventoryFolderImpl(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;
agentID = folderbase.agentID;
folderID = folderbase.folderID;
name = folderbase.name;
parentID = folderbase.parentID;
type = folderbase.type;
version = folderbase.version;
}
public InventoryFolderImpl()
{
}
// Methods
@ -65,19 +58,19 @@ namespace OpenSim.Framework.Communications.Cache
subFold.folderID = folderID;
subFold.type = (short) type;
subFold.parentID = this.folderID;
subFold.agentID = this.agentID;
this.SubFolders.Add(subFold.folderID, subFold);
subFold.agentID = agentID;
SubFolders.Add(subFold.folderID, subFold);
return subFold;
}
public InventoryItemBase HasItem(LLUUID itemID)
{
InventoryItemBase base2 = null;
if (this.Items.ContainsKey(itemID))
if (Items.ContainsKey(itemID))
{
return this.Items[itemID];
return Items[itemID];
}
foreach (InventoryFolderImpl folder in this.SubFolders.Values)
foreach (InventoryFolderImpl folder in SubFolders.Values)
{
base2 = folder.HasItem(itemID);
if (base2 != null)
@ -91,12 +84,12 @@ namespace OpenSim.Framework.Communications.Cache
public bool DeleteItem(LLUUID itemID)
{
bool found = false;
if (this.Items.ContainsKey(itemID))
if (Items.ContainsKey(itemID))
{
Items.Remove(itemID);
return true;
}
foreach (InventoryFolderImpl folder in this.SubFolders.Values)
foreach (InventoryFolderImpl folder in SubFolders.Values)
{
found = folder.DeleteItem(itemID);
if (found == true)
@ -111,13 +104,13 @@ namespace OpenSim.Framework.Communications.Cache
public InventoryFolderImpl HasSubFolder(LLUUID folderID)
{
InventoryFolderImpl returnFolder = null;
if (this.SubFolders.ContainsKey(folderID))
if (SubFolders.ContainsKey(folderID))
{
returnFolder = this.SubFolders[folderID];
returnFolder = SubFolders[folderID];
}
else
{
foreach (InventoryFolderImpl folder in this.SubFolders.Values)
foreach (InventoryFolderImpl folder in SubFolders.Values)
{
returnFolder = folder.HasSubFolder(folderID);
if (returnFolder != null)
@ -132,7 +125,7 @@ namespace OpenSim.Framework.Communications.Cache
public List<InventoryItemBase> RequestListOfItems()
{
List<InventoryItemBase> itemList = new List<InventoryItemBase>();
foreach (InventoryItemBase item in this.Items.Values)
foreach (InventoryItemBase item in Items.Values)
{
itemList.Add(item);
}

View File

@ -26,12 +26,8 @@
*
*/
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using OpenSim.Framework;
using Nini.Config;
namespace OpenSim.Framework.Communications.Cache
@ -40,43 +36,42 @@ namespace OpenSim.Framework.Communications.Cache
/// Basically a hack to give us a Inventory library while we don't have a inventory server
/// once the server is fully implemented then should read the data from that
/// </summary>
public class LibraryRootFolder : Cache.InventoryFolderImpl
public class LibraryRootFolder : InventoryFolderImpl
{
private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000");
private Cache.InventoryFolderImpl m_textureFolder;
private InventoryFolderImpl 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;
agentID = libOwner;
folderID = new LLUUID("00000112-000f-0000-0000-000100bba000");
name = "OpenSim Library";
parentID = LLUUID.Zero;
type = (short) -1;
version = (ushort) 1;
Cache.InventoryFolderImpl folderInfo = new InventoryFolderImpl();
InventoryFolderImpl folderInfo = new InventoryFolderImpl();
folderInfo.agentID = libOwner;
folderInfo.folderID = new LLUUID("00000112-000f-0000-0000-000100bba001");
folderInfo.name = "Texture Library";
folderInfo.parentID = this.folderID;
folderInfo.parentID = folderID;
folderInfo.type = -1;
folderInfo.version = 1;
this.SubFolders.Add(folderInfo.folderID, folderInfo);
this.m_textureFolder = folderInfo;
SubFolders.Add(folderInfo.folderID, folderInfo);
m_textureFolder = folderInfo;
this.CreateLibraryItems();
CreateLibraryItems();
string filePath = Path.Combine(Util.configDir(), "OpenSimLibrary.xml");
if (File.Exists(filePath))
{
XmlConfigSource source = new XmlConfigSource(filePath);
this.ReadItemsFromFile(source);
ReadItemsFromFile(source);
}
}
private void CreateLibraryItems()
{
InventoryItemBase item = new InventoryItemBase();
item.avatarID = libOwner;
item.creatorsID = libOwner;
@ -90,7 +85,7 @@ namespace OpenSim.Framework.Communications.Cache
item.inventoryEveryOnePermissions = 0x7FFFFFFF;
item.inventoryCurrentPermissions = 0x7FFFFFFF;
item.inventoryNextPermissions = 0x7FFFFFFF;
this.m_textureFolder.Items.Add(item.inventoryID, item);
m_textureFolder.Items.Add(item.inventoryID, item);
item = new InventoryItemBase();
item.avatarID = libOwner;
@ -105,7 +100,7 @@ namespace OpenSim.Framework.Communications.Cache
item.inventoryEveryOnePermissions = 0x7FFFFFFF;
item.inventoryCurrentPermissions = 0x7FFFFFFF;
item.inventoryNextPermissions = 0x7FFFFFFF;
this.m_textureFolder.Items.Add(item.inventoryID, item);
m_textureFolder.Items.Add(item.inventoryID, item);
item = new InventoryItemBase();
item.avatarID = libOwner;
@ -120,7 +115,7 @@ namespace OpenSim.Framework.Communications.Cache
item.inventoryEveryOnePermissions = 0x7FFFFFFF;
item.inventoryCurrentPermissions = 0x7FFFFFFF;
item.inventoryNextPermissions = 0x7FFFFFFF;
this.m_textureFolder.Items.Add(item.inventoryID, item);
m_textureFolder.Items.Add(item.inventoryID, item);
item = new InventoryItemBase();
item.avatarID = libOwner;
@ -135,7 +130,7 @@ namespace OpenSim.Framework.Communications.Cache
item.inventoryEveryOnePermissions = 0x7FFFFFFF;
item.inventoryCurrentPermissions = 0x7FFFFFFF;
item.inventoryNextPermissions = 0x7FFFFFFF;
this.m_textureFolder.Items.Add(item.inventoryID, item);
m_textureFolder.Items.Add(item.inventoryID, item);
item = new InventoryItemBase();
item.avatarID = libOwner;
@ -150,7 +145,7 @@ namespace OpenSim.Framework.Communications.Cache
item.inventoryEveryOnePermissions = 0x7FFFFFFF;
item.inventoryCurrentPermissions = 0x7FFFFFFF;
item.inventoryNextPermissions = 0x7FFFFFFF;
this.m_textureFolder.Items.Add(item.inventoryID, item);
m_textureFolder.Items.Add(item.inventoryID, item);
item = new InventoryItemBase();
item.avatarID = libOwner;
@ -161,10 +156,10 @@ namespace OpenSim.Framework.Communications.Cache
item.inventoryName = "Default Shape";
item.assetType = 13;
item.invType = 18;
item.parentFolderID = this.folderID;
item.parentFolderID = folderID;
item.inventoryCurrentPermissions = 0;
item.inventoryNextPermissions = 0;
this.Items.Add(item.inventoryID, item);
Items.Add(item.inventoryID, item);
item = new InventoryItemBase();
item.avatarID = libOwner;
@ -175,10 +170,10 @@ namespace OpenSim.Framework.Communications.Cache
item.inventoryName = "Default Skin";
item.assetType = 13;
item.invType = 18;
item.parentFolderID = this.folderID;
item.parentFolderID = folderID;
item.inventoryCurrentPermissions = 0;
item.inventoryNextPermissions = 0;
this.Items.Add(item.inventoryID, item);
Items.Add(item.inventoryID, item);
item = new InventoryItemBase();
item.avatarID = libOwner;
@ -189,10 +184,10 @@ namespace OpenSim.Framework.Communications.Cache
item.inventoryName = "Default Shirt";
item.assetType = 5;
item.invType = 18;
item.parentFolderID = this.folderID;
item.parentFolderID = folderID;
item.inventoryCurrentPermissions = 0;
item.inventoryNextPermissions = 0;
this.Items.Add(item.inventoryID, item);
Items.Add(item.inventoryID, item);
item = new InventoryItemBase();
item.avatarID = libOwner;
@ -203,11 +198,10 @@ namespace OpenSim.Framework.Communications.Cache
item.inventoryName = "Default Pants";
item.assetType = 5;
item.invType = 18;
item.parentFolderID = this.folderID;
item.parentFolderID = folderID;
item.inventoryCurrentPermissions = 0;
item.inventoryNextPermissions = 0;
this.Items.Add(item.inventoryID, item);
Items.Add(item.inventoryID, item);
}
private void ReadItemsFromFile(IConfigSource source)
@ -217,28 +211,28 @@ namespace OpenSim.Framework.Communications.Cache
InventoryItemBase item = new InventoryItemBase();
item.avatarID = libOwner;
item.creatorsID = libOwner;
item.inventoryID = new LLUUID(source.Configs[i].GetString("inventoryID", LLUUID.Random().ToStringHyphenated()));
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);
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);
item.parentFolderID = m_textureFolder.folderID;
m_textureFolder.Items.Add(item.inventoryID, item);
}
else
{
item.parentFolderID = this.folderID;
this.Items.Add(item.inventoryID, item);
item.parentFolderID = folderID;
Items.Add(item.inventoryID, item);
}
}
}
}
}

View File

@ -26,14 +26,8 @@
*
*/
using System;
using System.IO;
using System.Threading;
using System.Reflection;
using libsecondlife;
using Nini.Config;
using OpenSim.Framework.Console;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework;
namespace OpenSim.Framework.Communications.Cache
{
@ -62,11 +56,14 @@ namespace OpenSim.Framework.Communications.Cache
if (typeInterface != null)
{
IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
IAssetProvider plug =
(IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
m_assetProviderPlugin = plug;
m_assetProviderPlugin.Initialise();
MainLog.Instance.Verbose("AssetStorage","Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version);
MainLog.Instance.Verbose("AssetStorage",
"Added " + m_assetProviderPlugin.Name + " " +
m_assetProviderPlugin.Version);
}
typeInterface = null;
@ -84,13 +81,13 @@ namespace OpenSim.Framework.Communications.Cache
m_assetProviderPlugin.CommitAssets();
}
override protected void RunRequests()
protected override void RunRequests()
{
while (true)
{
ARequest req = this._assetRequests.Dequeue();
ARequest req = _assetRequests.Dequeue();
//MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID);
//MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID);
AssetBase asset = null;
lock (syncLock)
@ -105,9 +102,7 @@ namespace OpenSim.Framework.Communications.Cache
{
_receiver.AssetNotFound(req.AssetID);
}
}
}
protected override void StoreAsset(AssetBase asset)

View File

@ -25,16 +25,8 @@
* 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.Communications.Cache;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework;
namespace OpenSim.Framework.Communications.Cache
{
@ -49,7 +41,7 @@ namespace OpenSim.Framework.Communications.Cache
// Methods
public UserProfileCache(CommunicationsManager parent)
{
this.m_parent = parent;
m_parent = parent;
}
/// <summary>
@ -62,14 +54,14 @@ namespace OpenSim.Framework.Communications.Cache
// Potential fix - Multithreading issue.
lock (UserProfiles)
{
if (!this.UserProfiles.ContainsKey(userID))
if (!UserProfiles.ContainsKey(userID))
{
CachedUserInfo userInfo = new CachedUserInfo(this.m_parent);
userInfo.UserProfile = this.RequestUserProfileForUser(userID);
CachedUserInfo userInfo = new CachedUserInfo(m_parent);
userInfo.UserProfile = RequestUserProfileForUser(userID);
if (userInfo.UserProfile != null)
{
this.RequestInventoryForUser(userID, userInfo);
this.UserProfiles.Add(userID, userInfo);
RequestInventoryForUser(userID, userInfo);
UserProfiles.Add(userID, userInfo);
}
else
{
@ -91,26 +83,28 @@ namespace OpenSim.Framework.Communications.Cache
public CachedUserInfo GetUserDetails(LLUUID userID)
{
if (this.UserProfiles.ContainsKey(userID))
if (UserProfiles.ContainsKey(userID))
{
return this.UserProfiles[userID];
return UserProfiles[userID];
}
return null;
}
public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID)
public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType,
string folderName, LLUUID parentID)
{
if (this.UserProfiles.ContainsKey(remoteClient.AgentId))
if (UserProfiles.ContainsKey(remoteClient.AgentId))
{
if (this.UserProfiles[remoteClient.AgentId].RootFolder != null)
if (UserProfiles[remoteClient.AgentId].RootFolder != null)
{
CachedUserInfo info = this.UserProfiles[remoteClient.AgentId];
CachedUserInfo info = UserProfiles[remoteClient.AgentId];
if (info.RootFolder.folderID == parentID)
{
InventoryFolderImpl createdFolder = info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType);
InventoryFolderImpl createdFolder =
info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType);
if (createdFolder != null)
{
this.m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdFolder);
m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdFolder);
}
}
else
@ -125,27 +119,30 @@ namespace OpenSim.Framework.Communications.Cache
}
}
public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder)
public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID,
bool fetchFolders, bool fetchItems, int sortOrder)
{
InventoryFolderImpl fold = null;
if (folderID == libraryRoot.folderID )
InventoryFolderImpl fold = null;
if (folderID == libraryRoot.folderID)
{
remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems());
remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID,
libraryRoot.RequestListOfItems());
}
else if (( fold = libraryRoot.HasSubFolder(folderID)) != null)
else if ((fold = libraryRoot.HasSubFolder(folderID)) != null)
{
remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, folderID, fold.RequestListOfItems());
}
else if (this.UserProfiles.ContainsKey(remoteClient.AgentId))
else if (UserProfiles.ContainsKey(remoteClient.AgentId))
{
if (this.UserProfiles[remoteClient.AgentId].RootFolder != null)
if (UserProfiles[remoteClient.AgentId].RootFolder != null)
{
CachedUserInfo info = this.UserProfiles[remoteClient.AgentId];
CachedUserInfo info = UserProfiles[remoteClient.AgentId];
if (info.RootFolder.folderID == folderID)
{
if (fetchItems)
{
remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, info.RootFolder.RequestListOfItems());
remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID,
info.RootFolder.RequestListOfItems());
}
}
else
@ -153,7 +150,8 @@ namespace OpenSim.Framework.Communications.Cache
InventoryFolderImpl folder = info.RootFolder.HasSubFolder(folderID);
if ((folder != null) && fetchItems)
{
remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems());
remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID,
folder.RequestListOfItems());
}
}
}
@ -166,11 +164,11 @@ namespace OpenSim.Framework.Communications.Cache
{
//Console.WriteLine("request info for library item");
}
else if (this.UserProfiles.ContainsKey(remoteClient.AgentId))
else if (UserProfiles.ContainsKey(remoteClient.AgentId))
{
if (this.UserProfiles[remoteClient.AgentId].RootFolder != null)
if (UserProfiles[remoteClient.AgentId].RootFolder != null)
{
InventoryItemBase item = this.UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID);
InventoryItemBase item = UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID);
if (item != null)
{
remoteClient.SendInventoryItemDetails(ownerID, item);
@ -185,7 +183,7 @@ namespace OpenSim.Framework.Communications.Cache
/// <param name="userID"></param>
private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo)
{
this.m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive);
m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive);
}
/// <summary>
@ -194,7 +192,7 @@ namespace OpenSim.Framework.Communications.Cache
/// <param name="userID"></param>
private UserProfileData RequestUserProfileForUser(LLUUID userID)
{
return this.m_parent.UserService.GetUserProfile(userID);
return m_parent.UserService.GetUserProfile(userID);
}
/// <summary>

View File

@ -28,18 +28,23 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using libsecondlife;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Servers;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
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 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
@ -62,7 +67,8 @@ namespace OpenSim.Region.Capabilities
public ItemUpdatedCallback ItemUpdatedCall = null;
private bool m_dumpAssetsToFile;
public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent, bool dumpAssetsToFile)
public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath,
LLUUID agent, bool dumpAssetsToFile)
{
assetCache = assetCach;
m_capsObjectPath = capsPath;
@ -78,12 +84,17 @@ namespace OpenSim.Region.Capabilities
/// </summary>
public void RegisterHandlers()
{
OpenSim.Framework.Console.MainLog.Instance.Verbose("CAPS","Registering CAPS handlers");
MainLog.Instance.Verbose("CAPS", "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));
httpListener.AddStreamHandler(
new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST", capsBase + m_mapLayerPath,
GetMapLayer));
httpListener.AddStreamHandler(
new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST",
capsBase + m_newInventory,
NewAgentInventoryRequest));
AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest);
//AddLegacyCapsHandler(httpListener, m_requestTexture , RequestTexture);
@ -103,7 +114,7 @@ namespace OpenSim.Region.Capabilities
string capsBase = "/CAPS/" + m_capsObjectPath;
httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod));
}
/// <summary>
///
/// </summary>
@ -113,8 +124,8 @@ namespace OpenSim.Region.Capabilities
/// <returns></returns>
public string CapsRequest(string request, string path, string param)
{
// Console.WriteLine("caps request " + request);
string result = LLSDHelpers.SerialiseLLSDReply(this.GetCapabilities());
// Console.WriteLine("caps request " + request);
string result = LLSDHelpers.SerialiseLLSDReply(GetCapabilities());
return result;
}
@ -125,9 +136,10 @@ namespace OpenSim.Region.Capabilities
protected LLSDCapsDetails GetCapabilities()
{
LLSDCapsDetails caps = new LLSDCapsDetails();
string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath;
string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" +
m_capsObjectPath;
caps.MapLayer = capsBaseUrl + m_mapLayerPath;
// caps.RequestTextureDownload = capsBaseUrl + m_requestTexture;
// caps.RequestTextureDownload = capsBaseUrl + m_requestTexture;
caps.NewFileAgentInventory = capsBaseUrl + m_newInventory;
caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath;
caps.UpdateScriptAgentInventory = capsBaseUrl + m_notecardUpdatePath;
@ -142,7 +154,7 @@ namespace OpenSim.Region.Capabilities
public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq)
{
LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
mapResponse.LayerData.Array.Add(this.GetLLSDMapLayerResponse());
mapResponse.LayerData.Array.Add(GetLLSDMapLayerResponse());
return mapResponse;
}
@ -174,6 +186,7 @@ namespace OpenSim.Region.Capabilities
}
#region EventQueue (Currently not enabled)
/// <summary>
///
/// </summary>
@ -184,10 +197,10 @@ namespace OpenSim.Region.Capabilities
public string ProcessEventQueue(string request, string path, string param)
{
string res = "";
if (this.CapsEventQueue.Count > 0)
if (CapsEventQueue.Count > 0)
{
lock (this.CapsEventQueue)
lock (CapsEventQueue)
{
string item = CapsEventQueue.Dequeue();
res = item;
@ -195,7 +208,7 @@ namespace OpenSim.Region.Capabilities
}
else
{
res = this.CreateEmptyEventResponse();
res = CreateEmptyEventResponse();
}
return res;
}
@ -214,8 +227,8 @@ namespace OpenSim.Region.Capabilities
eventItem.events.Array.Add(new LLSDEmpty());
string res = LLSDHelpers.SerialiseLLSDReply(eventItem);
eventQueueCount++;
this.CapsEventQueue.Enqueue(res);
CapsEventQueue.Enqueue(res);
return res;
}
@ -232,6 +245,7 @@ namespace OpenSim.Region.Capabilities
eventQueueCount++;
return res;
}
#endregion
/// <summary>
@ -243,24 +257,27 @@ namespace OpenSim.Region.Capabilities
/// <returns></returns>
public string NoteCardAgentInventory(string request, string path, string param)
{
Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request));
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, m_dumpAssetsToFile );
uploader.OnUpLoad += this.ItemUpdated;
ItemUpdater uploader =
new ItemUpdater(newInvItem, capsBase + uploaderPath, httpListener, m_dumpAssetsToFile);
uploader.OnUpLoad += ItemUpdated;
httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps));
string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath;
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);
}
@ -272,7 +289,7 @@ namespace OpenSim.Region.Capabilities
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;
@ -281,14 +298,18 @@ namespace OpenSim.Region.Capabilities
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, m_dumpAssetsToFile);
httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps));
string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath;
AssetUploader uploader =
new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type,
llsdRequest.asset_type, capsBase + uploaderPath, httpListener, m_dumpAssetsToFile);
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;
uploader.OnUpLoad += UploadCompleteHandler;
return uploadResponse;
}
@ -298,7 +319,9 @@ namespace OpenSim.Region.Capabilities
/// <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)
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;
@ -319,14 +342,14 @@ namespace OpenSim.Region.Capabilities
asset.FullID = assetID;
asset.Type = assType;
asset.InvType = inType;
asset.Name = assetName;
asset.Name = assetName;
asset.Data = data;
this.assetCache.AddAsset(asset);
assetCache.AddAsset(asset);
InventoryItemBase item = new InventoryItemBase();
item.avatarID = agentID;
item.creatorsID = agentID;
item.inventoryID = inventoryItem;
item.inventoryID = inventoryItem;
item.assetID = asset.FullID;
item.inventoryDescription = assetDescription;
item.inventoryName = assetName;
@ -340,14 +363,13 @@ namespace OpenSim.Region.Capabilities
{
AddNewInventoryItem(agentID, item);
}
}
public LLUUID ItemUpdated(LLUUID itemID, byte[] data)
{
if (ItemUpdatedCall != null)
{
return ItemUpdatedCall(this.agentID, itemID, data);
return ItemUpdatedCall(agentID, itemID, data);
}
return LLUUID.Zero;
}
@ -359,7 +381,7 @@ namespace OpenSim.Region.Capabilities
private string uploaderPath = "";
private LLUUID newAssetID;
private LLUUID inventoryItemID;
private LLUUID parentFolder;
private LLUUID parentFolder;
private BaseHttpServer httpListener;
private bool m_dumpAssetsToFile;
private string m_assetName = "";
@ -368,7 +390,9 @@ namespace OpenSim.Region.Capabilities
private string m_invType = "";
private string m_assetType = "";
public AssetUploader(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolderID, string invType, string assetType, string path, BaseHttpServer httpServer, bool dumpAssetsToFile)
public AssetUploader(string assetName, string description, LLUUID assetID, LLUUID inventoryItem,
LLUUID parentFolderID, string invType, string assetType, string path,
BaseHttpServer httpServer, bool dumpAssetsToFile)
{
m_assetName = assetName;
m_assetDes = description;
@ -391,7 +415,7 @@ namespace OpenSim.Region.Capabilities
/// <returns></returns>
public string uploaderCaps(byte[] data, string path, string param)
{
LLUUID inv = this.inventoryItemID;
LLUUID inv = inventoryItemID;
string res = "";
LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
uploadComplete.new_asset = newAssetID.ToStringHyphenated();
@ -399,29 +423,29 @@ namespace OpenSim.Region.Capabilities
uploadComplete.state = "complete";
res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
httpListener.RemoveStreamHandler("POST", uploaderPath);
if (this.m_dumpAssetsToFile)
if (m_dumpAssetsToFile)
{
this.SaveAssetToFile(m_assetName + ".jp2", data);
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();
FileStream fs = File.Create(filename);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(data);
bw.Close();
fs.Close();
}
}
@ -434,7 +458,7 @@ namespace OpenSim.Region.Capabilities
private BaseHttpServer httpListener;
private bool m_dumpAssetToFile;
public ItemUpdater( LLUUID inventoryItem, string path, BaseHttpServer httpServer, bool dumpAssetToFile)
public ItemUpdater(LLUUID inventoryItem, string path, BaseHttpServer httpServer, bool dumpAssetToFile)
{
m_dumpAssetToFile = dumpAssetToFile;
@ -452,7 +476,7 @@ namespace OpenSim.Region.Capabilities
/// <returns></returns>
public string uploaderCaps(byte[] data, string path, string param)
{
LLUUID inv = this.inventoryItemID;
LLUUID inv = inventoryItemID;
string res = "";
LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
LLUUID assetID = LLUUID.Zero;
@ -461,7 +485,7 @@ namespace OpenSim.Region.Capabilities
{
assetID = OnUpLoad(inv, data);
}
uploadComplete.new_asset = assetID.ToStringHyphenated();
uploadComplete.new_inventory_item = inv;
uploadComplete.state = "complete";
@ -470,9 +494,9 @@ namespace OpenSim.Region.Capabilities
httpListener.RemoveStreamHandler("POST", uploaderPath);
if (this.m_dumpAssetToFile)
if (m_dumpAssetToFile)
{
this.SaveAssetToFile("updateditem" + Util.RandomClass.Next(1, 1000) + ".dat", data);
SaveAssetToFile("updateditem" + Util.RandomClass.Next(1, 1000) + ".dat", data);
}
return res;
@ -488,6 +512,4 @@ namespace OpenSim.Region.Capabilities
}
}
}
}
}

View File

@ -36,7 +36,6 @@ namespace OpenSim.Region.Capabilities
public LLSDArray()
{
}
}
}
}

View File

@ -39,7 +39,6 @@ namespace OpenSim.Region.Capabilities
public LLSDAssetUploadComplete()
{
}
}
}
}

View File

@ -26,9 +26,6 @@
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
namespace OpenSim.Region.Capabilities
@ -46,4 +43,4 @@ namespace OpenSim.Region.Capabilities
{
}
}
}
}

View File

@ -26,10 +26,6 @@
*
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Region.Capabilities
{
[LLSDMap]
@ -40,7 +36,6 @@ namespace OpenSim.Region.Capabilities
public LLSDAssetUploadResponse()
{
}
}
}
}

View File

@ -35,7 +35,6 @@ namespace OpenSim.Region.Capabilities
public LLSDCapEvent()
{
}
}
}
}

View File

@ -34,18 +34,14 @@ namespace OpenSim.Region.Capabilities
public string MapLayer = "";
public string NewFileAgentInventory = "";
//public string EventQueueGet = "";
// public string RequestTextureDownload = "";
// public string ChatSessionRequest = "";
// public string RequestTextureDownload = "";
// public string ChatSessionRequest = "";
public string UpdateNotecardAgentInventory = "";
public string UpdateScriptAgentInventory = "";
// public string ParcelVoiceInfoRequest = "";
// public string ParcelVoiceInfoRequest = "";
public LLSDCapsDetails()
{
}
}
}
}

View File

@ -32,7 +32,6 @@ namespace OpenSim.Region.Capabilities
{
public LLSDEmpty()
{
}
}
}
}

View File

@ -51,7 +51,7 @@ namespace OpenSim.Region.Capabilities
public static void SerializeLLSDType(XmlTextWriter writer, object obj)
{
Type myType = obj.GetType();
LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false);
LLSDType[] llsdattributes = (LLSDType[]) myType.GetCustomAttributes(typeof (LLSDType), false);
if (llsdattributes.Length > 0)
{
switch (llsdattributes[0].ObjectType)
@ -62,7 +62,8 @@ namespace OpenSim.Region.Capabilities
for (int i = 0; i < fields.Length; i++)
{
object fieldValue = fields[i].GetValue(obj);
LLSDType[] fieldAttributes = (LLSDType[])fieldValue.GetType().GetCustomAttributes(typeof(LLSDType), false);
LLSDType[] fieldAttributes =
(LLSDType[]) fieldValue.GetType().GetCustomAttributes(typeof (LLSDType), false);
if (fieldAttributes.Length > 0)
{
writer.WriteStartElement(String.Empty, "key", String.Empty);
@ -83,7 +84,7 @@ namespace OpenSim.Region.Capabilities
case "ARRAY":
// LLSDArray arrayObject = obj as LLSDArray;
// ArrayList a = arrayObject.Array;
ArrayList a = (ArrayList)obj.GetType().GetField("Array").GetValue(obj);
ArrayList a = (ArrayList) obj.GetType().GetField("Array").GetValue(obj);
if (a != null)
{
writer.WriteStartElement(String.Empty, "array", String.Empty);
@ -105,7 +106,7 @@ namespace OpenSim.Region.Capabilities
public static object DeserialiseLLSDMap(Hashtable llsd, object obj)
{
Type myType = obj.GetType();
LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false);
LLSDType[] llsdattributes = (LLSDType[]) myType.GetCustomAttributes(typeof (LLSDType), false);
if (llsdattributes.Length > 0)
{
switch (llsdattributes[0].ObjectType)
@ -114,7 +115,7 @@ namespace OpenSim.Region.Capabilities
IDictionaryEnumerator enumerator = llsd.GetEnumerator();
while (enumerator.MoveNext())
{
FieldInfo field = myType.GetField((string)enumerator.Key);
FieldInfo field = myType.GetField((string) enumerator.Key);
if (field != null)
{
if (enumerator.Value is Hashtable)
@ -142,23 +143,4 @@ namespace OpenSim.Region.Capabilities
return obj;
}
}
}
}

View File

@ -26,9 +26,6 @@
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
namespace OpenSim.Region.Capabilities
@ -42,4 +39,4 @@ namespace OpenSim.Region.Capabilities
{
}
}
}
}

View File

@ -40,7 +40,6 @@ namespace OpenSim.Region.Capabilities
public LLSDMapLayer()
{
}
}
}
}

View File

@ -35,7 +35,6 @@ namespace OpenSim.Region.Capabilities
public LLSDMapLayerResponse()
{
}
}
}
}

View File

@ -35,7 +35,6 @@ namespace OpenSim.Region.Capabilities
public LLSDMapRequest()
{
}
}
}
}

View File

@ -26,11 +26,7 @@
*
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Region.Capabilities
{
public delegate TResponse LLSDMethod<TRequest, TResponse>(TRequest request);
}
}

View File

@ -26,13 +26,11 @@
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework.Servers;
using System.IO;
using System.Collections;
using System.IO;
using System.Text;
using libsecondlife;
using OpenSim.Framework.Servers;
namespace OpenSim.Region.Capabilities
{
@ -42,11 +40,11 @@ namespace OpenSim.Region.Capabilities
private LLSDMethod<TRequest, TResponse> m_method;
public LLSDStreamhandler(string httpMethod, string path, LLSDMethod<TRequest, TResponse> method)
: base(httpMethod, path )
: base(httpMethod, path)
{
m_method = method;
}
public override byte[] Handle(string path, Stream request)
{
//Encoding encoding = Encoding.UTF8;
@ -55,16 +53,15 @@ namespace OpenSim.Region.Capabilities
//string requestBody = streamReader.ReadToEnd();
//streamReader.Close();
Hashtable hash = (Hashtable)LLSD.LLSDDeserialize( request );
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) );
return encoding.GetBytes(LLSDHelpers.SerialiseLLSDReply(response));
}
}
}
}

View File

@ -35,7 +35,6 @@ namespace OpenSim.Region.Capabilities
public LLSDTest()
{
}
}
}
}

View File

@ -37,23 +37,19 @@ namespace OpenSim.Region.Capabilities
public LLSDType(string type)
{
myType = type;
}
public string ObjectType
{
get
{
return myType;
}
get { return myType; }
}
}
[AttributeUsage(AttributeTargets.Class)]
public class LLSDMap : LLSDType
{
public LLSDMap() : base( "MAP" )
public LLSDMap() : base("MAP")
{
}
}
}
}

View File

@ -28,69 +28,77 @@
using System;
using libsecondlife;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Servers;
using OpenSim.Framework;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Communications
{
public class CommunicationsManager
{
protected IUserService m_userService;
public IUserService UserService
{
get { return m_userService; }
}
protected IGridServices m_gridService;
public IGridServices GridService
{
get { return m_gridService; }
}
protected IInventoryServices m_inventoryService;
public IInventoryServices InventoryService
{
get { return m_inventoryService; }
}
protected IInterRegionCommunications m_interRegion;
public IInterRegionCommunications InterRegion
{
get { return m_interRegion; }
}
protected UserProfileCache m_userProfileCache;
public UserProfileCache UserProfileCache
{
get { return m_userProfileCache; }
}
protected AssetTransactionManager m_transactionsManager;
public AssetTransactionManager TransactionsManager
{
get { return m_transactionsManager; }
}
protected AssetCache m_assetCache;
public AssetCache AssetCache
{
get { return m_assetCache; }
}
protected NetworkServersInfo m_networkServersInfo;
public NetworkServersInfo NetworkServersInfo
{
get { return m_networkServersInfo; }
}
public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, bool dumpAssetsToFile)
public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache,
bool dumpAssetsToFile)
{
m_networkServersInfo = serversInfo;
m_assetCache = assetCache;
m_userProfileCache = new UserProfileCache(this);
m_transactionsManager = new AssetTransactionManager(this, dumpAssetsToFile );
m_transactionsManager = new AssetTransactionManager(this, dumpAssetsToFile);
}
public void doCreate(string[] cmmdParams)
@ -106,7 +114,6 @@ namespace OpenSim.Framework.Communications
if (cmmdParams.Length < 2)
{
firstName = MainLog.Instance.CmdPrompt("First name", "Default");
lastName = MainLog.Instance.CmdPrompt("Last name", "User");
password = MainLog.Instance.PasswdPrompt("Password");
@ -120,7 +127,6 @@ namespace OpenSim.Framework.Communications
password = cmmdParams[3];
regX = Convert.ToUInt32(cmmdParams[4]);
regY = Convert.ToUInt32(cmmdParams[5]);
}
AddUser(firstName, lastName, password, regX, regY);
@ -140,7 +146,7 @@ namespace OpenSim.Framework.Communications
}
else
{
this.m_inventoryService.CreateNewUserInventory(userProf.UUID);
m_inventoryService.CreateNewUserInventory(userProf.UUID);
System.Console.WriteLine("Created new inventory set for " + firstName + " " + lastName);
return userProf.UUID;
}

View File

@ -27,10 +27,6 @@
*/
using System.Collections.Generic;
using System.Net;
using libsecondlife;
using OpenSim.Framework;
namespace OpenSim.Framework.Communications
{
@ -41,4 +37,4 @@ namespace OpenSim.Framework.Communications
RegionInfo RequestNeighbourInfo(ulong regionHandle);
List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY);
}
}
}

View File

@ -26,7 +26,6 @@
*
*/
using libsecondlife;
using OpenSim.Framework;
namespace OpenSim.Framework.Communications
{
@ -36,4 +35,4 @@ namespace OpenSim.Framework.Communications
bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying);
bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId);
}
}
}

View File

@ -26,16 +26,14 @@
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework;
namespace OpenSim.Framework.Communications
{
public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolderImpl folderInfo);
public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo);
public interface IInventoryServices
@ -53,4 +51,4 @@ namespace OpenSim.Framework.Communications
/// <returns></returns>
List<InventoryFolderBase> RequestFirstLevelFolders(LLUUID userID);
}
}
}

View File

@ -30,10 +30,8 @@ using System;
using System.Collections.Generic;
using System.Reflection;
using libsecondlife;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console;
using OpenSim.Framework;
namespace OpenSim.Framework.Communications
{
@ -67,10 +65,10 @@ namespace OpenSim.Framework.Communications
if (typeInterface != null)
{
IInventoryData plug =
(IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
(IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
plug.Initialise();
this.m_plugins.Add(plug.getName(), plug);
MainLog.Instance.Verbose("INVENTORY","Added IInventoryData Interface");
m_plugins.Add(plug.getName(), plug);
MainLog.Instance.Verbose("INVENTORY", "Added IInventoryData Interface");
}
}
}
@ -168,7 +166,7 @@ namespace OpenSim.Framework.Communications
{
foreach (InventoryFolderBase folder in inventory.Folders.Values)
{
this.AddFolder(folder);
AddFolder(folder);
}
}
@ -176,7 +174,7 @@ namespace OpenSim.Framework.Communications
{
UsersInventory inven = new UsersInventory();
inven.CreateNewInventorySet(user);
this.AddNewInventorySet(inven);
AddNewInventorySet(inven);
}
public class UsersInventory
@ -186,7 +184,6 @@ namespace OpenSim.Framework.Communications
public UsersInventory()
{
}
public virtual void CreateNewInventorySet(LLUUID user)
@ -231,9 +228,11 @@ namespace OpenSim.Framework.Communications
}
}
public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack);
public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack,
InventoryItemInfo itemCallBack);
public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder);
public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item);
public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item);
}
}
}

View File

@ -34,12 +34,10 @@ using OpenSim.Framework.Console;
namespace OpenSim.Framework.UserManagement
{
/// <summary>
/// A temp class to handle login response.
/// Should make use of UserProfileManager where possible.
/// </summary>
public class LoginResponse
{
private Hashtable loginFlagsHash;
@ -103,211 +101,222 @@ namespace OpenSim.Framework.UserManagement
public LoginResponse()
{
this.loginFlags = new ArrayList();
this.globalTextures = new ArrayList();
this.eventCategories = new ArrayList();
this.uiConfig = new ArrayList();
this.classifiedCategories = new ArrayList();
loginFlags = new ArrayList();
globalTextures = new ArrayList();
eventCategories = new ArrayList();
uiConfig = new ArrayList();
classifiedCategories = new ArrayList();
this.loginError = new Hashtable();
this.uiConfigHash = new Hashtable();
loginError = new Hashtable();
uiConfigHash = new Hashtable();
this.defaultXmlRpcResponse = new XmlRpcResponse();
this.userProfile = new UserInfo();
this.inventoryRoot = new ArrayList();
this.initialOutfit = new ArrayList();
this.agentInventory = new ArrayList();
this.inventoryLibrary = new ArrayList();
this.inventoryLibraryOwner = new ArrayList();
defaultXmlRpcResponse = new XmlRpcResponse();
userProfile = new UserInfo();
inventoryRoot = new ArrayList();
initialOutfit = new ArrayList();
agentInventory = new ArrayList();
inventoryLibrary = new ArrayList();
inventoryLibraryOwner = new ArrayList();
this.xmlRpcResponse = new XmlRpcResponse();
this.defaultXmlRpcResponse = new XmlRpcResponse();
xmlRpcResponse = new XmlRpcResponse();
defaultXmlRpcResponse = new XmlRpcResponse();
this.SetDefaultValues();
SetDefaultValues();
} // LoginServer
public void SetDefaultValues()
{
this.DST = "N";
this.StipendSinceLogin = "N";
this.Gendered = "Y";
this.EverLoggedIn = "Y";
this.login = "false";
this.firstname = "Test";
this.lastname = "User";
this.agentAccess = "M";
this.startLocation = "last";
this.allowFirstLife = "Y";
DST = "N";
StipendSinceLogin = "N";
Gendered = "Y";
EverLoggedIn = "Y";
login = "false";
firstname = "Test";
lastname = "User";
agentAccess = "M";
startLocation = "last";
allowFirstLife = "Y";
this.SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271";
this.CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
this.MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271";
CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
this.ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock.";
this.ErrorReason = "key";
this.welcomeMessage = "Welcome to OpenSim!";
this.seedCapability = "";
this.home = "{'region_handle':[r" + (1000 * 256).ToString() + ",r" + (1000 * 256).ToString() + "], 'position':[r" + this.userProfile.homepos.X.ToString() + ",r" + this.userProfile.homepos.Y.ToString() + ",r" + this.userProfile.homepos.Z.ToString() + "], 'look_at':[r" + this.userProfile.homelookat.X.ToString() + ",r" + this.userProfile.homelookat.Y.ToString() + ",r" + this.userProfile.homelookat.Z.ToString() + "]}";
this.lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]";
this.RegionX = (uint)255232;
this.RegionY = (uint)254976;
ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock.";
ErrorReason = "key";
welcomeMessage = "Welcome to OpenSim!";
seedCapability = "";
home = "{'region_handle':[r" + (1000*256).ToString() + ",r" + (1000*256).ToString() + "], 'position':[r" +
userProfile.homepos.X.ToString() + ",r" + userProfile.homepos.Y.ToString() + ",r" +
userProfile.homepos.Z.ToString() + "], 'look_at':[r" + userProfile.homelookat.X.ToString() + ",r" +
userProfile.homelookat.Y.ToString() + ",r" + userProfile.homelookat.Z.ToString() + "]}";
lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]";
RegionX = (uint) 255232;
RegionY = (uint) 254976;
// Classifieds;
this.AddClassifiedCategory((Int32)1, "Shopping");
this.AddClassifiedCategory((Int32)2, "Land Rental");
this.AddClassifiedCategory((Int32)3, "Property Rental");
this.AddClassifiedCategory((Int32)4, "Special Attraction");
this.AddClassifiedCategory((Int32)5, "New Products");
this.AddClassifiedCategory((Int32)6, "Employment");
this.AddClassifiedCategory((Int32)7, "Wanted");
this.AddClassifiedCategory((Int32)8, "Service");
this.AddClassifiedCategory((Int32)9, "Personal");
// Classifieds;
AddClassifiedCategory((Int32) 1, "Shopping");
AddClassifiedCategory((Int32) 2, "Land Rental");
AddClassifiedCategory((Int32) 3, "Property Rental");
AddClassifiedCategory((Int32) 4, "Special Attraction");
AddClassifiedCategory((Int32) 5, "New Products");
AddClassifiedCategory((Int32) 6, "Employment");
AddClassifiedCategory((Int32) 7, "Wanted");
AddClassifiedCategory((Int32) 8, "Service");
AddClassifiedCategory((Int32) 9, "Personal");
this.SessionID = LLUUID.Random();
this.SecureSessionID = LLUUID.Random();
this.AgentID = LLUUID.Random();
Hashtable InitialOutfitHash = new Hashtable();
InitialOutfitHash["folder_name"] = "Nightclub Female";
InitialOutfitHash["gender"] = "female";
this.initialOutfit.Add(InitialOutfitHash);
SessionID = LLUUID.Random();
SecureSessionID = LLUUID.Random();
AgentID = LLUUID.Random();
Hashtable InitialOutfitHash = new Hashtable();
InitialOutfitHash["folder_name"] = "Nightclub Female";
InitialOutfitHash["gender"] = "female";
initialOutfit.Add(InitialOutfitHash);
} // SetDefaultValues
#region Login Failure Methods
public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login)
{
// Overwrite any default values;
this.xmlRpcResponse = new XmlRpcResponse();
xmlRpcResponse = new XmlRpcResponse();
// Ensure Login Failed message/reason;
this.ErrorMessage = message;
this.ErrorReason = reason;
ErrorMessage = message;
ErrorReason = reason;
this.loginError["reason"] = this.ErrorReason;
this.loginError["message"] = this.ErrorMessage;
this.loginError["login"] = login;
this.xmlRpcResponse.Value = this.loginError;
return (this.xmlRpcResponse);
loginError["reason"] = ErrorReason;
loginError["message"] = ErrorMessage;
loginError["login"] = login;
xmlRpcResponse.Value = loginError;
return (xmlRpcResponse);
} // GenerateResponse
public XmlRpcResponse CreateFailedResponse()
{
return (this.CreateLoginFailedResponse());
return (CreateLoginFailedResponse());
} // CreateErrorConnectingToGridResponse()
public XmlRpcResponse CreateLoginFailedResponse()
{
return (this.GenerateFailureResponse("key", "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", "false"));
return
(GenerateFailureResponse("key",
"Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.",
"false"));
} // LoginFailedResponse
public XmlRpcResponse CreateAlreadyLoggedInResponse()
{
return (this.GenerateFailureResponse("presence", "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner", "false"));
return
(GenerateFailureResponse("presence",
"You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner",
"false"));
} // CreateAlreadyLoggedInResponse()
public XmlRpcResponse CreateDeadRegionResponse()
{
return (this.GenerateFailureResponse("key", "The region you are attempting to log into is not responding. Please select another region and try again.", "false"));
return
(GenerateFailureResponse("key",
"The region you are attempting to log into is not responding. Please select another region and try again.",
"false"));
}
public XmlRpcResponse CreateGridErrorResponse()
public XmlRpcResponse CreateGridErrorResponse()
{
return (this.GenerateFailureResponse("key", "Error connecting to grid. Could not percieve credentials from login XML.", "false"));
return
(GenerateFailureResponse("key",
"Error connecting to grid. Could not percieve credentials from login XML.",
"false"));
}
#endregion
public XmlRpcResponse ToXmlRpcResponse()
{
try
{
Hashtable responseData = new Hashtable();
this.loginFlagsHash = new Hashtable();
this.loginFlagsHash["daylight_savings"] = this.DST;
this.loginFlagsHash["stipend_since_login"] = this.StipendSinceLogin;
this.loginFlagsHash["gendered"] = this.Gendered;
this.loginFlagsHash["ever_logged_in"] = this.EverLoggedIn;
this.loginFlags.Add(this.loginFlagsHash);
loginFlagsHash = new Hashtable();
loginFlagsHash["daylight_savings"] = DST;
loginFlagsHash["stipend_since_login"] = StipendSinceLogin;
loginFlagsHash["gendered"] = Gendered;
loginFlagsHash["ever_logged_in"] = EverLoggedIn;
loginFlags.Add(loginFlagsHash);
responseData["first_name"] = this.Firstname;
responseData["last_name"] = this.Lastname;
responseData["agent_access"] = this.agentAccess;
responseData["first_name"] = Firstname;
responseData["last_name"] = Lastname;
responseData["agent_access"] = agentAccess;
this.globalTexturesHash = new Hashtable();
this.globalTexturesHash["sun_texture_id"] = this.SunTexture;
this.globalTexturesHash["cloud_texture_id"] = this.CloudTexture;
this.globalTexturesHash["moon_texture_id"] = this.MoonTexture;
this.globalTextures.Add(this.globalTexturesHash);
// this.eventCategories.Add(this.eventCategoriesHash);
globalTexturesHash = new Hashtable();
globalTexturesHash["sun_texture_id"] = SunTexture;
globalTexturesHash["cloud_texture_id"] = CloudTexture;
globalTexturesHash["moon_texture_id"] = MoonTexture;
globalTextures.Add(globalTexturesHash);
// this.eventCategories.Add(this.eventCategoriesHash);
this.AddToUIConfig("allow_first_life", this.allowFirstLife);
this.uiConfig.Add(this.uiConfigHash);
AddToUIConfig("allow_first_life", allowFirstLife);
uiConfig.Add(uiConfigHash);
responseData["sim_port"] =(Int32) this.SimPort;
responseData["sim_ip"] = this.SimAddress;
responseData["agent_id"] = this.AgentID.ToStringHyphenated();
responseData["session_id"] = this.SessionID.ToStringHyphenated();
responseData["secure_session_id"] = this.SecureSessionID.ToStringHyphenated();
responseData["circuit_code"] = this.CircuitCode;
responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
responseData["login-flags"] = this.loginFlags;
responseData["global-textures"] = this.globalTextures;
responseData["seed_capability"] = this.seedCapability;
responseData["sim_port"] = (Int32) SimPort;
responseData["sim_ip"] = SimAddress;
responseData["event_categories"] = this.eventCategories;
responseData["agent_id"] = AgentID.ToStringHyphenated();
responseData["session_id"] = SessionID.ToStringHyphenated();
responseData["secure_session_id"] = SecureSessionID.ToStringHyphenated();
responseData["circuit_code"] = CircuitCode;
responseData["seconds_since_epoch"] = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
responseData["login-flags"] = loginFlags;
responseData["global-textures"] = globalTextures;
responseData["seed_capability"] = seedCapability;
responseData["event_categories"] = eventCategories;
responseData["event_notifications"] = new ArrayList(); // todo
responseData["classified_categories"] = this.classifiedCategories;
responseData["ui-config"] = this.uiConfig;
responseData["classified_categories"] = classifiedCategories;
responseData["ui-config"] = uiConfig;
responseData["inventory-skeleton"] = this.agentInventory;
responseData["inventory-skel-lib"] = this.inventoryLibrary;
responseData["inventory-root"] = this.inventoryRoot;
responseData["inventory-skeleton"] = agentInventory;
responseData["inventory-skel-lib"] = inventoryLibrary;
responseData["inventory-root"] = inventoryRoot;
responseData["gestures"] = new ArrayList(); // todo
responseData["inventory-lib-owner"] = this.inventoryLibraryOwner;
responseData["initial-outfit"] = this.initialOutfit;
responseData["start_location"] = this.startLocation;
responseData["seed_capability"] = this.seedCapability;
responseData["home"] = this.home;
responseData["look_at"] = this.lookAt;
responseData["message"] = this.welcomeMessage;
responseData["region_x"] = (Int32)this.RegionX * 256;
responseData["region_y"] = (Int32)this.RegionY * 256;
responseData["inventory-lib-owner"] = inventoryLibraryOwner;
responseData["initial-outfit"] = initialOutfit;
responseData["start_location"] = startLocation;
responseData["seed_capability"] = seedCapability;
responseData["home"] = home;
responseData["look_at"] = lookAt;
responseData["message"] = welcomeMessage;
responseData["region_x"] = (Int32) RegionX*256;
responseData["region_y"] = (Int32) RegionY*256;
//responseData["inventory-lib-root"] = new ArrayList(); // todo
//responseData["buddy-list"] = new ArrayList(); // todo
responseData["login"] = "true";
this.xmlRpcResponse.Value = responseData;
xmlRpcResponse.Value = responseData;
return (this.xmlRpcResponse);
return (xmlRpcResponse);
}
catch (Exception e)
{
MainLog.Instance.Warn(
"CLIENT",
"LoginResponse: Error creating XML-RPC Response: " + e.Message
);
return (this.GenerateFailureResponse("Internal Error", "Error generating Login Response", "false"));
);
return (GenerateFailureResponse("Internal Error", "Error generating Login Response", "false"));
}
} // ToXmlRpcResponse
public void SetEventCategories(string category, string value)
{
// this.eventCategoriesHash[category] = value;
// this.eventCategoriesHash[category] = value;
//TODO
} // SetEventCategories
public void AddToUIConfig(string itemName, string item)
{
this.uiConfigHash[itemName] = item;
uiConfigHash[itemName] = item;
} // SetUIConfig
public void AddClassifiedCategory(Int32 ID, string categoryName)
@ -315,372 +324,193 @@ namespace OpenSim.Framework.UserManagement
Hashtable hash = new Hashtable();
hash["category_name"] = categoryName;
hash["category_id"] = ID;
this.classifiedCategories.Add(hash);
classifiedCategories.Add(hash);
// this.classifiedCategoriesHash.Clear();
} // SetClassifiedCategory
#region Properties
public string Login
{
get
{
return this.login;
}
set
{
this.login = value;
}
get { return login; }
set { login = value; }
} // Login
public string DST
{
get
{
return this.dst;
}
set
{
this.dst = value;
}
get { return dst; }
set { dst = value; }
} // DST
public string StipendSinceLogin
{
get
{
return this.stipendSinceLogin;
}
set
{
this.stipendSinceLogin = value;
}
get { return stipendSinceLogin; }
set { stipendSinceLogin = value; }
} // StipendSinceLogin
public string Gendered
{
get
{
return this.gendered;
}
set
{
this.gendered = value;
}
get { return gendered; }
set { gendered = value; }
} // Gendered
public string EverLoggedIn
{
get
{
return this.everLoggedIn;
}
set
{
this.everLoggedIn = value;
}
get { return everLoggedIn; }
set { everLoggedIn = value; }
} // EverLoggedIn
public int SimPort
{
get
{
return this.simPort;
}
set
{
this.simPort = value;
}
get { return simPort; }
set { simPort = value; }
} // SimPort
public string SimAddress
{
get
{
return this.simAddress;
}
set
{
this.simAddress = value;
}
get { return simAddress; }
set { simAddress = value; }
} // SimAddress
public LLUUID AgentID
{
get
{
return this.agentID;
}
set
{
this.agentID = value;
}
get { return agentID; }
set { agentID = value; }
} // AgentID
public LLUUID SessionID
{
get
{
return this.sessionID;
}
set
{
this.sessionID = value;
}
get { return sessionID; }
set { sessionID = value; }
} // SessionID
public LLUUID SecureSessionID
{
get
{
return this.secureSessionID;
}
set
{
this.secureSessionID = value;
}
get { return secureSessionID; }
set { secureSessionID = value; }
} // SecureSessionID
public Int32 CircuitCode
{
get
{
return this.circuitCode;
}
set
{
this.circuitCode = value;
}
get { return circuitCode; }
set { circuitCode = value; }
} // CircuitCode
public uint RegionX
{
get
{
return this.regionX;
}
set
{
this.regionX = value;
}
get { return regionX; }
set { regionX = value; }
} // RegionX
public uint RegionY
{
get
{
return this.regionY;
}
set
{
this.regionY = value;
}
get { return regionY; }
set { regionY = value; }
} // RegionY
public string SunTexture
{
get
{
return this.sunTexture;
}
set
{
this.sunTexture = value;
}
get { return sunTexture; }
set { sunTexture = value; }
} // SunTexture
public string CloudTexture
{
get
{
return this.cloudTexture;
}
set
{
this.cloudTexture = value;
}
get { return cloudTexture; }
set { cloudTexture = value; }
} // CloudTexture
public string MoonTexture
{
get
{
return this.moonTexture;
}
set
{
this.moonTexture = value;
}
get { return moonTexture; }
set { moonTexture = value; }
} // MoonTexture
public string Firstname
{
get
{
return this.firstname;
}
set
{
this.firstname = value;
}
get { return firstname; }
set { firstname = value; }
} // Firstname
public string Lastname
{
get
{
return this.lastname;
}
set
{
this.lastname = value;
}
get { return lastname; }
set { lastname = value; }
} // Lastname
public string AgentAccess
{
get
{
return this.agentAccess;
}
set
{
this.agentAccess = value;
}
get { return agentAccess; }
set { agentAccess = value; }
}
public string StartLocation
{
get
{
return this.startLocation;
}
set
{
this.startLocation = value;
}
get { return startLocation; }
set { startLocation = value; }
} // StartLocation
public string LookAt
{
get
{
return this.lookAt;
}
set
{
this.lookAt = value;
}
get { return lookAt; }
set { lookAt = value; }
}
public string SeedCapability
{
get
{
return this.seedCapability;
}
set
{
this.seedCapability = value;
}
get { return seedCapability; }
set { seedCapability = value; }
} // SeedCapability
public string ErrorReason
{
get
{
return this.errorReason;
}
set
{
this.errorReason = value;
}
get { return errorReason; }
set { errorReason = value; }
} // ErrorReason
public string ErrorMessage
{
get
{
return this.errorMessage;
}
set
{
this.errorMessage = value;
}
get { return errorMessage; }
set { errorMessage = value; }
} // ErrorMessage
public ArrayList InventoryRoot
{
get
{
return this.inventoryRoot;
}
set
{
this.inventoryRoot = value;
}
get { return inventoryRoot; }
set { inventoryRoot = value; }
}
public ArrayList InventorySkeleton
{
get
{
return this.agentInventory;
}
set
{
this.agentInventory = value;
}
get { return agentInventory; }
set { agentInventory = value; }
}
public ArrayList InventoryLibrary
{
get
{
return this.inventoryLibrary;
}
set
{
this.inventoryLibrary = value;
}
get { return inventoryLibrary; }
set { inventoryLibrary = value; }
}
public ArrayList InventoryLibraryOwner
{
get
{
return this.inventoryLibraryOwner;
}
set
{
this.inventoryLibraryOwner = value;
}
get { return inventoryLibraryOwner; }
set { inventoryLibraryOwner = value; }
}
public string Home
{
get
{
return this.home;
}
set
{
this.home = value;
}
get { return home; }
set { home = value; }
}
public string Message
{
get
{
return this.welcomeMessage;
}
set
{
this.welcomeMessage = value;
}
get { return welcomeMessage; }
set { welcomeMessage = value; }
}
#endregion
#endregion
public class UserInfo
{
@ -691,6 +521,4 @@ namespace OpenSim.Framework.UserManagement
public LLVector3 homelookat;
}
}
}
}

View File

@ -28,16 +28,10 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Security.Cryptography;
using libsecondlife;
using Nwc.XmlRpc;
using OpenSim.Framework.Console;
using OpenSim.Framework;
using InventoryFolder = OpenSim.Framework.InventoryFolder;
namespace OpenSim.Framework.UserManagement
{
public class LoginService
@ -61,12 +55,12 @@ namespace OpenSim.Framework.UserManagement
/// <returns>The response to send</returns>
public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
{
MainLog.Instance.Verbose("LOGIN","Attempting login now...");
MainLog.Instance.Verbose("LOGIN", "Attempting login now...");
XmlRpcResponse response = new XmlRpcResponse();
Hashtable requestData = (Hashtable)request.Params[0];
Hashtable requestData = (Hashtable) request.Params[0];
bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd"));
bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") &&
requestData.Contains("passwd"));
bool GoodLogin = false;
UserProfileData userProfile;
@ -74,9 +68,9 @@ namespace OpenSim.Framework.UserManagement
if (GoodXML)
{
string firstname = (string)requestData["first"];
string lastname = (string)requestData["last"];
string passwd = (string)requestData["passwd"];
string firstname = (string) requestData["first"];
string lastname = (string) requestData["last"];
string passwd = (string) requestData["passwd"];
userProfile = GetTheUser(firstname, lastname);
if (userProfile == null)
@ -110,7 +104,7 @@ namespace OpenSim.Framework.UserManagement
LLUUID agentID = userProfile.UUID;
// Inventory Library Section
InventoryData inventData = this.CreateInventoryData(agentID);
InventoryData inventData = CreateInventoryData(agentID);
ArrayList AgentInventoryArray = inventData.InventoryArray;
Hashtable InventoryRootHash = new Hashtable();
@ -120,7 +114,7 @@ namespace OpenSim.Framework.UserManagement
userProfile.rootInventoryFolderID = inventData.RootFolderID;
// Circuit Code
uint circode = (uint)(Util.RandomClass.Next());
uint circode = (uint) (Util.RandomClass.Next());
logResponse.Lastname = userProfile.surname;
logResponse.Firstname = userProfile.username;
@ -129,20 +123,20 @@ namespace OpenSim.Framework.UserManagement
logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated();
logResponse.InventoryRoot = InventoryRoot;
logResponse.InventorySkeleton = AgentInventoryArray;
logResponse.InventoryLibrary = this.GetInventoryLibrary();
logResponse.InventoryLibraryOwner = this.GetLibraryOwner();
logResponse.CircuitCode = (Int32)circode;
logResponse.InventoryLibrary = GetInventoryLibrary();
logResponse.InventoryLibraryOwner = GetLibraryOwner();
logResponse.CircuitCode = (Int32) circode;
//logResponse.RegionX = 0; //overwritten
//logResponse.RegionY = 0; //overwritten
logResponse.Home = "!!null temporary value {home}!!"; // Overwritten
logResponse.Home = "!!null temporary value {home}!!"; // Overwritten
//logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n";
//logResponse.SimAddress = "127.0.0.1"; //overwritten
//logResponse.SimPort = 0; //overwritten
logResponse.Message = this.GetMessage();
logResponse.Message = GetMessage();
try
{
this.CustomiseResponse(logResponse, userProfile);
CustomiseResponse(logResponse, userProfile);
}
catch (Exception e)
{
@ -152,7 +146,6 @@ namespace OpenSim.Framework.UserManagement
}
CommitAgent(ref userProfile);
return logResponse.ToXmlRpcResponse();
}
catch (Exception E)
@ -162,7 +155,6 @@ namespace OpenSim.Framework.UserManagement
//}
}
return response;
}
/// <summary>
@ -174,7 +166,7 @@ namespace OpenSim.Framework.UserManagement
{
}
/// <summary>
/// <summary>
/// Saves a target agent to the database
/// </summary>
/// <param name="profile">The users profile</param>
@ -194,8 +186,7 @@ namespace OpenSim.Framework.UserManagement
/// <returns>Authenticated?</returns>
public virtual bool AuthenticateUser(UserProfileData profile, string password)
{
MainLog.Instance.Verbose("LOGIN","Authenticating " + profile.username + " " + profile.surname);
MainLog.Instance.Verbose("LOGIN", "Authenticating " + profile.username + " " + profile.surname);
password = password.Remove(0, 3); //remove $1$
@ -211,7 +202,7 @@ namespace OpenSim.Framework.UserManagement
/// <param name="request"></param>
public void CreateAgent(UserProfileData profile, XmlRpcRequest request)
{
this.m_userManager.CreateAgent(profile, request);
m_userManager.CreateAgent(profile, request);
}
/// <summary>
@ -222,7 +213,7 @@ namespace OpenSim.Framework.UserManagement
/// <returns></returns>
public virtual UserProfileData GetTheUser(string firstname, string lastname)
{
return this.m_userManager.GetUserProfile(firstname, lastname);
return m_userManager.GetUserProfile(firstname, lastname);
}
/// <summary>
@ -286,8 +277,8 @@ namespace OpenSim.Framework.UserManagement
TempHash = new Hashtable();
TempHash["name"] = InvFolder.FolderName;
TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
TempHash["version"] = (Int32)InvFolder.Version;
TempHash["type_default"] = (Int32)InvFolder.DefaultType;
TempHash["version"] = (Int32) InvFolder.Version;
TempHash["type_default"] = (Int32) InvFolder.DefaultType;
TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
AgentInventoryArray.Add(TempHash);
}
@ -307,4 +298,4 @@ namespace OpenSim.Framework.UserManagement
}
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
@ -27,25 +27,29 @@
*/
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("")]
[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)]
[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")]
[assembly : Guid("13e7c396-78a9-4a5c-baf2-6f980ea75d95")]
// Version information for an assembly consists of the following four values:
//
@ -56,5 +60,6 @@ using System.Runtime.InteropServices;
//
// 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")]
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]

View File

@ -1,13 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace OpenSim.Framework.Communications
{
internal class SimpleAsyncResult : IAsyncResult
{
private readonly AsyncCallback m_callback;
/// <summary>
@ -36,7 +33,6 @@ namespace OpenSim.Framework.Communications
m_completedSynchronously = 1;
}
#region IAsyncResult Members
public object AsyncState
@ -45,7 +41,6 @@ namespace OpenSim.Framework.Communications
}
public WaitHandle AsyncWaitHandle
{
get
@ -82,19 +77,18 @@ namespace OpenSim.Framework.Communications
get { return Thread.VolatileRead(ref m_completed) == 1; }
}
#endregion
#region class Methods
internal void SetAsCompleted(bool completedSynchronously)
{
m_completed = 1;
if(completedSynchronously)
if (completedSynchronously)
m_completedSynchronously = 1;
else
m_completedSynchronously = 0;
SignalCompletion();
}
@ -112,9 +106,9 @@ namespace OpenSim.Framework.Communications
private void SignalCompletion()
{
if(m_waitHandle != null) m_waitHandle.Set();
if (m_waitHandle != null) m_waitHandle.Set();
if(m_callback != null) m_callback(this);
if (m_callback != null) m_callback(this);
}
public void EndInvoke()
@ -125,14 +119,14 @@ namespace OpenSim.Framework.Communications
// If the operation isn't done, wait for it
AsyncWaitHandle.WaitOne();
AsyncWaitHandle.Close();
m_waitHandle = null; // Allow early GC
m_waitHandle = null; // Allow early GC
}
// Operation is done: if an exception occured, throw it
if (m_exception != null) throw m_exception;
}
}
#endregion
#endregion
}
internal class AsyncResult<T> : SimpleAsyncResult
@ -140,10 +134,12 @@ namespace OpenSim.Framework.Communications
private T m_result = default(T);
public AsyncResult(AsyncCallback asyncCallback, Object state) :
base(asyncCallback, state) { }
base(asyncCallback, state)
{
}
public void SetAsCompleted(T result, bool completedSynchronously)
public void SetAsCompleted(T result, bool completedSynchronously)
{
// Save the asynchronous operation's result
m_result = result;
@ -153,11 +149,10 @@ namespace OpenSim.Framework.Communications
base.SetAsCompleted(completedSynchronously);
}
new public T EndInvoke()
public new T EndInvoke()
{
base.EndInvoke();
return m_result;
base.EndInvoke();
return m_result;
}
}
}
}

View File

@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Web;
using System.Text;
using System.Collections.Generic;
using System.Threading;
using OpenSim.Framework.Console;
using System.Web;
namespace OpenSim.Framework.Communications
{
@ -29,9 +27,10 @@ namespace OpenSim.Framework.Communications
/// </remarks>
public class RestClient
{
private string realuri;
string realuri;
#region member variables
/// <summary>
/// The base Uri of the web-service e.g. http://www.google.com
/// </summary>
@ -60,7 +59,7 @@ namespace OpenSim.Framework.Communications
/// <summary>
/// MemoryStream representing the resultiong resource
/// </summary>
Stream _resource;
private Stream _resource;
/// <summary>
/// WebRequest object, held as a member variable
@ -80,12 +79,12 @@ namespace OpenSim.Framework.Communications
/// <summary>
/// Default time out period
/// </summary>
const int DefaultTimeout = 10 * 1000; // 10 seconds timeout
private const int DefaultTimeout = 10*1000; // 10 seconds timeout
/// <summary>
/// Default Buffer size of a block requested from the web-server
/// </summary>
const int BufferSize = 4096; // Read blocks of 4 KB.
private const int BufferSize = 4096; // Read blocks of 4 KB.
/// <summary>
@ -97,6 +96,7 @@ namespace OpenSim.Framework.Communications
#endregion member variables
#region constructors
/// <summary>
/// Instantiate a new RestClient
/// </summary>
@ -111,7 +111,8 @@ namespace OpenSim.Framework.Communications
_lock = new object();
}
object _lock;
private object _lock;
#endregion constructors
/// <summary>
@ -120,8 +121,8 @@ namespace OpenSim.Framework.Communications
/// <param name="element">path entry</param>
public void AddResourcePath(string element)
{
if(isSlashed(element))
_pathElements.Add(element.Substring(0, element.Length-1));
if (isSlashed(element))
_pathElements.Add(element.Substring(0, element.Length - 1));
else
_pathElements.Add(element);
}
@ -178,7 +179,7 @@ namespace OpenSim.Framework.Communications
/// Build a Uri based on the intial Url, path elements and parameters
/// </summary>
/// <returns>fully constructed Uri</returns>
Uri buildUri()
private Uri buildUri()
{
StringBuilder sb = new StringBuilder();
sb.Append(_url);
@ -196,7 +197,8 @@ namespace OpenSim.Framework.Communications
{
sb.Append("?");
firstElement = false;
} else
}
else
sb.Append("&");
sb.Append(kv.Key);
@ -209,7 +211,9 @@ namespace OpenSim.Framework.Communications
realuri = sb.ToString();
return new Uri(sb.ToString());
}
#region Async communications with server
/// <summary>
/// Async method, invoked when a block of data has been received from the service
/// </summary>
@ -218,13 +222,14 @@ namespace OpenSim.Framework.Communications
{
try
{
Stream s = (Stream)ar.AsyncState;
Stream s = (Stream) ar.AsyncState;
int read = s.EndRead(ar);
if (read > 0)
{
_resource.Write(_readbuf, 0, read);
IAsyncResult asynchronousResult = s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s);
IAsyncResult asynchronousResult =
s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s);
// TODO! Implement timeout, without killing the server
//ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true);
@ -251,12 +256,13 @@ namespace OpenSim.Framework.Communications
try
{
// grab response
WebRequest wr = (WebRequest)ar.AsyncState;
_response = (HttpWebResponse)wr.EndGetResponse(ar);
WebRequest wr = (WebRequest) ar.AsyncState;
_response = (HttpWebResponse) wr.EndGetResponse(ar);
// get response stream, and setup async reading
Stream s = _response.GetResponseStream();
IAsyncResult asynchronousResult = s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s);
IAsyncResult asynchronousResult =
s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s);
// TODO! Implement timeout, without killing the server
// wait until completed, or we timed out
@ -281,6 +287,7 @@ namespace OpenSim.Framework.Communications
}
}
}
#endregion Async communications with server
/// <summary>
@ -290,17 +297,17 @@ namespace OpenSim.Framework.Communications
{
lock (_lock)
{
_request = (HttpWebRequest)WebRequest.Create(buildUri());
_request = (HttpWebRequest) WebRequest.Create(buildUri());
_request.KeepAlive = false;
_request.ContentType = "application/xml";
_request.Timeout = 200000;
_asyncException = null;
// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request);
_response = (HttpWebResponse)_request.GetResponse();
_response = (HttpWebResponse) _request.GetResponse();
Stream src = _response.GetResponseStream();
int length = src.Read(_readbuf, 0, BufferSize);
while(length > 0)
while (length > 0)
{
_resource.Write(_readbuf, 0, length);
length = src.Read(_readbuf, 0, BufferSize);
@ -329,7 +336,7 @@ namespace OpenSim.Framework.Communications
public Stream Request(Stream src)
{
_request = (HttpWebRequest)WebRequest.Create(buildUri());
_request = (HttpWebRequest) WebRequest.Create(buildUri());
_request.KeepAlive = false;
_request.ContentType = "application/xml";
_request.Timeout = 900000;
@ -340,13 +347,13 @@ namespace OpenSim.Framework.Communications
src.Seek(0, SeekOrigin.Begin);
Stream dst = _request.GetRequestStream();
byte[] buf = new byte[1024];
int length = src.Read(buf,0, 1024);
int length = src.Read(buf, 0, 1024);
while (length > 0)
{
dst.Write(buf, 0, length);
length = src.Read(buf, 0, 1024);
}
_response = (HttpWebResponse)_request.GetResponse();
_response = (HttpWebResponse) _request.GetResponse();
// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request);
@ -357,8 +364,8 @@ namespace OpenSim.Framework.Communications
return null;
}
#region Async Invocation
public IAsyncResult BeginRequest(AsyncCallback callback, object state)
{
/// <summary>
@ -371,7 +378,7 @@ namespace OpenSim.Framework.Communications
public Stream EndRequest(IAsyncResult asyncResult)
{
AsyncResult<Stream> ar = (AsyncResult<Stream>)asyncResult;
AsyncResult<Stream> ar = (AsyncResult<Stream>) asyncResult;
// Wait for operation to complete, then return result or
// throw exception
@ -381,7 +388,7 @@ namespace OpenSim.Framework.Communications
private void RequestHelper(Object asyncResult)
{
// We know that it's really an AsyncResult<DateTime> object
AsyncResult<Stream> ar = (AsyncResult<Stream>)asyncResult;
AsyncResult<Stream> ar = (AsyncResult<Stream>) asyncResult;
try
{
// Perform the operation; if sucessful set the result
@ -394,6 +401,7 @@ namespace OpenSim.Framework.Communications
ar.HandleException(e, false);
}
}
#endregion Async Invocation
}
}
}

View File

@ -33,18 +33,15 @@ using System.Reflection;
using System.Security.Cryptography;
using libsecondlife;
using Nwc.XmlRpc;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.Data;
using OpenSim.Framework.Interfaces;
namespace OpenSim.Framework.UserManagement
{
public abstract class UserManagerBase : IUserService
{
public UserConfig _config;
Dictionary<string, IUserData> _plugins = new Dictionary<string, IUserData>();
private Dictionary<string, IUserData> _plugins = new Dictionary<string, IUserData>();
/// <summary>
/// Adds a new user server plugin - user servers will be requested in the order they were loaded.
@ -78,11 +75,12 @@ namespace OpenSim.Framework.UserManagement
public void AddPlugin(IUserData plug)
{
plug.Initialise();
this._plugins.Add(plug.getName(), plug);
MainLog.Instance.Verbose( "Userstorage: Added IUserData Interface");
_plugins.Add(plug.getName(), plug);
MainLog.Instance.Verbose("Userstorage: Added IUserData Interface");
}
#region Get UserProfile
/// <summary>
/// Loads a user profile from a database by UUID
/// </summary>
@ -100,7 +98,7 @@ namespace OpenSim.Framework.UserManagement
}
catch (Exception e)
{
MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
}
}
@ -126,7 +124,7 @@ namespace OpenSim.Framework.UserManagement
catch (Exception e)
{
System.Console.WriteLine("EEK!");
MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
}
}
@ -145,7 +143,7 @@ namespace OpenSim.Framework.UserManagement
{
try
{
UserProfileData profile = plugin.Value.GetUserByName(fname,lname);
UserProfileData profile = plugin.Value.GetUserByName(fname, lname);
profile.currentAgent = getUserAgent(profile.UUID);
@ -153,7 +151,7 @@ namespace OpenSim.Framework.UserManagement
}
catch (Exception e)
{
MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
}
}
@ -170,20 +168,24 @@ namespace OpenSim.Framework.UserManagement
{
foreach (KeyValuePair<string, IUserData> plugin in _plugins)
{
try {
try
{
plugin.Value.UpdateUserProfile(data);
return true;
} catch (Exception e) {
MainLog.Instance.Verbose( "Unable to set user via " + plugin.Key + "(" + e.ToString() + ")");
}
catch (Exception e)
{
MainLog.Instance.Verbose("Unable to set user via " + plugin.Key + "(" + e.ToString() + ")");
}
}
return false;
}
#endregion
#region Get UserAgent
/// <summary>
/// Loads a user agent by uuid (not called directly)
/// </summary>
@ -199,7 +201,7 @@ namespace OpenSim.Framework.UserManagement
}
catch (Exception e)
{
MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
}
}
@ -221,7 +223,7 @@ namespace OpenSim.Framework.UserManagement
}
catch (Exception e)
{
MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
}
}
@ -249,11 +251,11 @@ namespace OpenSim.Framework.UserManagement
{
try
{
return plugin.Value.GetAgentByName(fname,lname);
return plugin.Value.GetAgentByName(fname, lname);
}
catch (Exception e)
{
MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
}
}
@ -263,6 +265,7 @@ namespace OpenSim.Framework.UserManagement
#endregion
#region CreateAgent
/// <summary>
/// Creates and initialises a new user agent - make sure to use CommitAgent when done to submit to the DB
/// </summary>
@ -270,7 +273,7 @@ namespace OpenSim.Framework.UserManagement
/// <param name="request">The users loginrequest</param>
public void CreateAgent(UserProfileData profile, XmlRpcRequest request)
{
Hashtable requestData = (Hashtable)request.Params[0];
Hashtable requestData = (Hashtable) request.Params[0];
UserAgentData agent = new UserAgentData();
@ -297,7 +300,7 @@ namespace OpenSim.Framework.UserManagement
// If user specified additional start, use that
if (requestData.ContainsKey("start"))
{
string startLoc = ((string)requestData["start"]).Trim();
string startLoc = ((string) requestData["start"]).Trim();
if (!(startLoc == "last" || startLoc == "home"))
{
// Format: uri:Ahern&162&213&34
@ -312,7 +315,6 @@ namespace OpenSim.Framework.UserManagement
}
catch (Exception)
{
}
}
}
@ -323,7 +325,7 @@ namespace OpenSim.Framework.UserManagement
// Current location
agent.regionID = new LLUUID(); // Fill in later
agent.currentRegion = new LLUUID(); // Fill in later
agent.currentRegion = new LLUUID(); // Fill in later
profile.currentAgent = agent;
}
@ -364,7 +366,6 @@ namespace OpenSim.Framework.UserManagement
try
{
plugin.Value.AddNewUserProfile(user);
}
catch (Exception e)
{
@ -376,4 +377,4 @@ namespace OpenSim.Framework.UserManagement
public abstract UserProfileData SetupMasterUser(string firstName, string lastName);
public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password);
}
}
}

View File

@ -26,21 +26,18 @@
*
*/
using System;
using System.Collections.Generic;
using System.Net;
using System.IO;
using System.Net;
using System.Text;
using OpenSim.Framework;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Configuration.HTTP
{
public class HTTPConfiguration : IGenericConfig
{
RemoteConfigSettings remoteConfigSettings;
private RemoteConfigSettings remoteConfigSettings;
XmlConfiguration xmlConfig;
private XmlConfiguration xmlConfig;
private string configFileName = "";
@ -62,8 +59,9 @@ namespace OpenSim.Framework.Configuration.HTTP
StringBuilder sb = new StringBuilder();
byte[] buf = new byte[8192];
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.remoteConfigSettings.baseConfigURL + this.configFileName);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
HttpWebRequest request =
(HttpWebRequest) WebRequest.Create(remoteConfigSettings.baseConfigURL + configFileName);
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
Stream resStream = response.GetResponseStream();
@ -78,13 +76,14 @@ namespace OpenSim.Framework.Configuration.HTTP
tempString = Encoding.ASCII.GetString(buf, 0, count);
sb.Append(tempString);
}
}
while (count > 0);
} 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.");
MainLog.Instance.Warn("Unable to connect to remote configuration file (" +
remoteConfigSettings.baseConfigURL + configFileName +
"). Creating local file instead.");
xmlConfig.SetFileName(configFileName);
xmlConfig.LoadData();
}
@ -93,7 +92,6 @@ namespace OpenSim.Framework.Configuration.HTTP
public void LoadDataFromString(string data)
{
xmlConfig.LoadDataFromString(data);
}
public string GetAttribute(string attributeName)
@ -114,4 +112,4 @@ namespace OpenSim.Framework.Configuration.HTTP
{
}
}
}
}

View File

@ -26,12 +26,6 @@
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework;
namespace OpenSim.Framework.Configuration.HTTP
{
public class RemoteConfigSettings
@ -39,24 +33,30 @@ namespace OpenSim.Framework.Configuration.HTTP
private ConfigurationMember configMember;
public string baseConfigURL = "";
public RemoteConfigSettings(string filename)
{
configMember = new ConfigurationMember(filename, "REMOTE CONFIG SETTINGS", loadConfigurationOptions, handleIncomingConfiguration);
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);
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;
baseConfigURL = (string) configuration_result;
}
return true;
}
}
}
}

View File

@ -25,12 +25,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.IO;
using System.Xml;
using OpenSim.Framework;
namespace OpenSim.Framework.Configuration
{
public class XmlConfiguration : IGenericConfig
@ -56,6 +55,7 @@ namespace OpenSim.Framework.Configuration
if (configNode.Name != "Config")
throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>");
}
public void LoadData()
{
lock (this)
@ -81,7 +81,7 @@ namespace OpenSim.Framework.Configuration
if (createdFile)
{
this.Commit();
Commit();
}
}
}
@ -93,12 +93,13 @@ namespace OpenSim.Framework.Configuration
LoadDataToClass();
}
public string GetAttribute(string attributeName)
{
string result = null;
if (configNode.Attributes[attributeName] != null)
{
result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value;
result = ((XmlAttribute) configNode.Attributes.GetNamedItem(attributeName)).Value;
}
return result;
}
@ -107,7 +108,7 @@ namespace OpenSim.Framework.Configuration
{
if (configNode.Attributes[attributeName] != null)
{
((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue;
((XmlAttribute) configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue;
}
else
{
@ -124,7 +125,7 @@ namespace OpenSim.Framework.Configuration
if (!Directory.Exists(Util.configDir()))
{
Directory.CreateDirectory(Util.configDir());
}
}
doc.Save(fileName);
}
@ -134,6 +135,5 @@ namespace OpenSim.Framework.Configuration
rootNode = null;
doc = null;
}
}
}
}

View File

@ -27,24 +27,26 @@
*/
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("")]
[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)]
[assembly : ComVisible(false)]
// The assembly version has following format :
//
@ -53,4 +55,4 @@ using System.Runtime.InteropServices;
// 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.*")]
[assembly : AssemblyVersion("1.0.*")]

View File

@ -26,10 +26,10 @@
*
*/
namespace OpenSim.Framework.Console
{
{
public interface conscmd_callback
{
void RunCmd(string cmd, string[] cmdparams);
void Show(string ShowWhat);
}
}
}

View File

@ -26,10 +26,10 @@
*
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Diagnostics;
using System.Collections.Generic;
namespace OpenSim.Framework.Console
{
@ -48,7 +48,7 @@ namespace OpenSim.Framework.Console
{
private object m_syncRoot = new object();
StreamWriter Log;
private StreamWriter Log;
public conscmd_callback cmdparser;
public string componentname;
private bool m_verbose;
@ -57,7 +57,7 @@ namespace OpenSim.Framework.Console
{
this.componentname = componentname;
this.cmdparser = cmdparser;
this.m_verbose = verbose;
m_verbose = verbose;
System.Console.WriteLine("Creating new local console");
if (String.IsNullOrEmpty(LogFile))
@ -87,8 +87,8 @@ namespace OpenSim.Framework.Console
/// <returns>an ansii color</returns>
private ConsoleColor DeriveColor(string input)
{
int colIdx = (input.ToUpper().GetHashCode() % 6) + 9;
return (ConsoleColor)colIdx;
int colIdx = (input.ToUpper().GetHashCode()%6) + 9;
return (ConsoleColor) colIdx;
}
/// <summary>
@ -236,7 +236,7 @@ namespace OpenSim.Framework.Console
{
lock (m_syncRoot)
{
string now = System.DateTime.Now.ToString("[MM-dd hh:mm:ss] ");
string now = DateTime.Now.ToString("[MM-dd hh:mm:ss] ");
Log.Write(now);
Log.WriteLine(format, args);
Log.Flush();
@ -306,7 +306,7 @@ namespace OpenSim.Framework.Console
public int Read()
{
int TempInt = System.Console.Read();
Log.Write((char)TempInt);
Log.Write((char) TempInt);
return TempInt;
}
@ -359,7 +359,7 @@ namespace OpenSim.Framework.Console
{
// FIXME: Needs to be better abstracted
Log.WriteLine(prompt);
this.Notice(prompt);
Notice(prompt);
ConsoleColor oldfg = System.Console.ForegroundColor;
System.Console.ForegroundColor = System.Console.BackgroundColor;
string temp = System.Console.ReadLine();
@ -370,8 +370,8 @@ namespace OpenSim.Framework.Console
// 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();
Notice(String.Format("{0}: ", prompt));
return ReadLine();
}
// Displays a command prompt and returns a default value if the user simply presses enter
@ -423,8 +423,7 @@ namespace OpenSim.Framework.Console
public void MainLogPrompt()
{
string tempstr = this.CmdPrompt(this.componentname + "# ");
string tempstr = CmdPrompt(componentname + "# ");
MainLogRunCommand(tempstr);
}
@ -436,7 +435,7 @@ namespace OpenSim.Framework.Console
Array.Reverse(tempstrarray);
Array.Resize<string>(ref tempstrarray, tempstrarray.Length - 1);
Array.Reverse(tempstrarray);
string[] cmdparams = (string[])tempstrarray;
string[] cmdparams = (string[]) tempstrarray;
try
{
RunCmd(cmd, cmdparams);
@ -454,7 +453,7 @@ namespace OpenSim.Framework.Console
string result = String.Empty;
string stacktrace = Environment.StackTrace;
List<string> lines = new List<string>(stacktrace.Split(new string[] { "at " }, StringSplitOptions.None));
List<string> lines = new List<string>(stacktrace.Split(new string[] {"at "}, StringSplitOptions.None));
if (lines.Count > 4)
{
@ -481,4 +480,4 @@ namespace OpenSim.Framework.Console
}
}
}
}
}

View File

@ -27,15 +27,14 @@
*/
namespace OpenSim.Framework.Console
{
public class MainLog {
public class MainLog
{
private static LogBase instance;
public static LogBase Instance
public static LogBase Instance
{
get { return instance; }
set { instance = value; }
}
}
}
}

View File

@ -34,18 +34,19 @@ namespace OpenSim.Framework.Data.DB4o
/// <summary>
/// A grid server storage mechanism employing the DB4o database system
/// </summary>
class DB4oGridData : IGridData
internal class DB4oGridData : IGridData
{
/// <summary>
/// The database manager object
/// </summary>
DB4oGridManager manager;
private DB4oGridManager manager;
/// <summary>
/// Called when the plugin is first loaded (as constructors are not called)
/// </summary>
public void Initialise() {
manager = new DB4oGridManager("gridserver.yap");
public void Initialise()
{
manager = new DB4oGridManager("gridserver.yap");
}
/// <summary>
@ -93,7 +94,8 @@ namespace OpenSim.Framework.Data.DB4o
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);
throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() +
"). Total Registered Regions: " + manager.simProfiles.Count);
}
/// <summary>
@ -123,7 +125,8 @@ namespace OpenSim.Framework.Data.DB4o
/// <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) {
public bool AuthenticateSim(LLUUID uuid, ulong handle, string key)
{
if (manager.simProfiles[uuid].regionRecvKey == key)
return true;
return false;
@ -160,4 +163,4 @@ namespace OpenSim.Framework.Data.DB4o
return null;
}
}
}
}

View File

@ -29,23 +29,23 @@ using System;
using System.Collections.Generic;
using Db4objects.Db4o;
using libsecondlife;
using OpenSim.Framework;
namespace OpenSim.Framework.Data.DB4o
{
/// <summary>
/// A Database manager for Db4o
/// </summary>
class DB4oGridManager
internal class DB4oGridManager
{
/// <summary>
/// A list of the current regions connected (in-memory cache)
/// </summary>
public Dictionary<LLUUID, RegionProfileData> simProfiles = new Dictionary<LLUUID, RegionProfileData>();
/// <summary>
/// Database File Name
/// </summary>
string dbfl;
private string dbfl;
/// <summary>
/// Creates a new grid storage manager
@ -56,7 +56,7 @@ namespace OpenSim.Framework.Data.DB4o
dbfl = db4odb;
IObjectContainer database;
database = Db4oFactory.OpenFile(dbfl);
IObjectSet result = database.Get(typeof(RegionProfileData));
IObjectSet result = database.Get(typeof (RegionProfileData));
// Loads the file into the in-memory cache
foreach (RegionProfileData row in result)
{
@ -94,23 +94,22 @@ namespace OpenSim.Framework.Data.DB4o
return false;
}
}
}
/// <summary>
/// A manager for the DB4o database (user profiles)
/// </summary>
class DB4oUserManager
internal 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;
private string dbfl;
/// <summary>
/// Initialises a new DB manager
@ -122,7 +121,7 @@ namespace OpenSim.Framework.Data.DB4o
IObjectContainer database;
database = Db4oFactory.OpenFile(dbfl);
// Load to cache
IObjectSet result = database.Get(typeof(UserProfileData));
IObjectSet result = database.Get(typeof (UserProfileData));
foreach (UserProfileData row in result)
{
if (userProfiles.ContainsKey(row.UUID))
@ -144,7 +143,7 @@ namespace OpenSim.Framework.Data.DB4o
/// <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;
@ -168,4 +167,4 @@ namespace OpenSim.Framework.Data.DB4o
}
}
}
}
}

View File

@ -28,8 +28,6 @@
using System;
using System.IO;
using libsecondlife;
using OpenSim.Framework;
using OpenSim.Framework;
namespace OpenSim.Framework.Data.DB4o
{
@ -41,14 +39,14 @@ namespace OpenSim.Framework.Data.DB4o
/// <summary>
/// The database manager
/// </summary>
DB4oUserManager manager;
private DB4oUserManager manager;
/// <summary>
/// Artificial constructor called upon plugin load
/// </summary>
public void Initialise()
{
manager = new DB4oUserManager(Path.Combine(Util.dataDir(),"userprofiles.yap"));
manager = new DB4oUserManager(Path.Combine(Util.dataDir(), "userprofiles.yap"));
}
/// <summary>
@ -58,7 +56,7 @@ namespace OpenSim.Framework.Data.DB4o
/// <returns>A user profile</returns>
public UserProfileData GetUserByUUID(LLUUID uuid)
{
if(manager.userProfiles.ContainsKey(uuid))
if (manager.userProfiles.ContainsKey(uuid))
return manager.userProfiles[uuid];
return null;
}
@ -95,7 +93,7 @@ namespace OpenSim.Framework.Data.DB4o
/// <param name="uuid">The users account ID</param>
/// <returns>A matching users profile</returns>
public UserAgentData GetAgentByUUID(LLUUID uuid)
{
{
try
{
return GetUserByUUID(uuid).currentAgent;
@ -126,7 +124,7 @@ namespace OpenSim.Framework.Data.DB4o
{
try
{
return GetUserByName(fname,lname).currentAgent;
return GetUserByName(fname, lname).currentAgent;
}
catch (Exception)
{
@ -149,7 +147,7 @@ namespace OpenSim.Framework.Data.DB4o
Console.WriteLine(e.ToString());
}
}
/// <summary>
/// Creates a new user profile
/// </summary>
@ -157,15 +155,17 @@ namespace OpenSim.Framework.Data.DB4o
/// <returns>True on success, false on error</returns>
public bool UpdateUserProfile(UserProfileData user)
{
try {
try
{
return manager.UpdateRecord(user);
} catch (Exception e) {
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return false;
}
}
/// <summary>
/// Creates a new user agent
@ -219,4 +219,4 @@ namespace OpenSim.Framework.Data.DB4o
return "0.1";
}
}
}
}

View File

@ -1,24 +1,28 @@
using System.Reflection;
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("")]
[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)]
[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")]
[assembly : Guid("57991e15-79da-41b7-aa06-2e6b49165a63")]
// Version information for an assembly consists of the following four values:
//
@ -29,5 +33,6 @@ using System.Runtime.InteropServices;
//
// 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")]
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]

View File

@ -185,10 +185,10 @@ namespace OpenSim.Framework.Data.MSSQL
byte[] hash = HashProvider.ComputeHash(stream);
return false;
}
public ReservationData GetReservationAtPoint(uint x, uint y)
{
return null;
}
}
}
}

View File

@ -36,12 +36,12 @@ namespace OpenSim.Framework.Data.MSSQL
/// <summary>
/// A management class for the MS SQL Storage Engine
/// </summary>
class MSSqlManager
internal class MSSqlManager
{
/// <summary>
/// The database connection object
/// </summary>
IDbConnection dbcon;
private IDbConnection dbcon;
/// <summary>
/// Initialises and creates a new Sql connection and maintains it.
@ -55,7 +55,8 @@ namespace OpenSim.Framework.Data.MSSQL
{
try
{
string connectionString = "Server=" + hostname + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";";
string connectionString = "Server=" + hostname + ";Database=" + database + ";User ID=" + username +
";Password=" + password + ";Pooling=" + cpooling + ";";
dbcon = new SqlConnection(connectionString);
dbcon.Open();
@ -83,14 +84,14 @@ namespace OpenSim.Framework.Data.MSSQL
/// <returns>A Sql DB Command</returns>
public IDbCommand Query(string sql, Dictionary<string, string> parameters)
{
SqlCommand dbcommand = (SqlCommand)dbcon.CreateCommand();
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;
return (IDbCommand) dbcommand;
}
/// <summary>
@ -105,42 +106,42 @@ namespace OpenSim.Framework.Data.MSSQL
if (reader.Read())
{
// Region Main
regionprofile.regionHandle = (ulong)reader["regionHandle"];
regionprofile.regionName = (string)reader["regionName"];
regionprofile.UUID = new LLUUID((string)reader["uuid"]);
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"];
regionprofile.regionRecvKey = (string) reader["regionRecvKey"];
regionprofile.regionSecret = (string) reader["regionSecret"];
regionprofile.regionSendKey = (string) reader["regionSendKey"];
// Region Server
regionprofile.regionDataURI = (string)reader["regionDataURI"];
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"];
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"]);
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"];
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"];
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"];
regionprofile.regionUserURI = (string) reader["regionUserURI"];
regionprofile.regionUserRecvKey = (string) reader["regionUserRecvKey"];
regionprofile.regionUserSendKey = (string) reader["regionUserSendKey"];
}
else
{
@ -156,12 +157,15 @@ namespace OpenSim.Framework.Data.MSSQL
/// <returns>Successful?</returns>
public bool insertRow(RegionProfileData profile)
{
string sql = "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
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 +=
"@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>();
@ -208,4 +212,4 @@ namespace OpenSim.Framework.Data.MSSQL
return returnval;
}
}
}
}

View File

@ -1,24 +1,28 @@
using System.Reflection;
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("")]
[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)]
[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")]
[assembly : Guid("0e1c1ca4-2cf2-4315-b0e7-432c02feea8a")]
// Version information for an assembly consists of the following four values:
//
@ -29,5 +33,6 @@ using System.Runtime.InteropServices;
//
// 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")]
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]

View File

@ -28,18 +28,17 @@
using System;
using System.Collections.Generic;
using MySql.Data.MySqlClient;
using System.Data;
using libsecondlife;
using MySql.Data.MySqlClient;
using OpenSim.Framework.Console;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework;
namespace OpenSim.Framework.Data.MySQL
{
class MySQLAssetData : IAssetProvider
internal class MySQLAssetData : IAssetProvider
{
MySQLManager _dbConnection;
private MySQLManager _dbConnection;
#region IAssetProvider Members
private void UpgradeAssetsTable(string oldVersion)
@ -58,14 +57,12 @@ namespace OpenSim.Framework.Data.MySQL
/// </summary>
private void TestTables()
{
Dictionary<string, string> tableList = new Dictionary<string, string>();
tableList["assets"] = null;
_dbConnection.GetTableVersion(tableList);
UpgradeAssetsTable(tableList["assets"]);
}
public AssetBase FetchAsset(LLUUID assetID)
@ -73,21 +70,24 @@ namespace OpenSim.Framework.Data.MySQL
AssetBase asset = null;
lock (_dbConnection)
{
MySqlCommand cmd = new MySqlCommand("SELECT name, description, assetType, invType, local, temporary, data FROM assets WHERE id=?id", _dbConnection.Connection);
MySqlCommand cmd =
new MySqlCommand(
"SELECT name, description, assetType, invType, local, temporary, data FROM assets WHERE id=?id",
_dbConnection.Connection);
MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16);
p.Value = assetID.GetBytes();
using (MySqlDataReader dbReader = cmd.ExecuteReader(System.Data.CommandBehavior.SingleRow))
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
{
if (dbReader.Read())
{
asset = new AssetBase();
asset.Data = (byte[])dbReader["data"];
asset.Description = (string)dbReader["description"];
asset.Data = (byte[]) dbReader["data"];
asset.Description = (string) dbReader["description"];
asset.FullID = assetID;
asset.InvType = (sbyte)dbReader["invType"];
asset.Local = ((sbyte)dbReader["local"]) != 0 ? true : false;
asset.Name = (string)dbReader["name"];
asset.Type = (sbyte)dbReader["assetType"];
asset.InvType = (sbyte) dbReader["invType"];
asset.Local = ((sbyte) dbReader["local"]) != 0 ? true : false;
asset.Name = (string) dbReader["name"];
asset.Type = (sbyte) dbReader["assetType"];
}
}
}
@ -96,8 +96,11 @@ namespace OpenSim.Framework.Data.MySQL
public void CreateAsset(AssetBase asset)
{
MySqlCommand cmd = new MySqlCommand("REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" +
"VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)", _dbConnection.Connection);
MySqlCommand cmd =
new MySqlCommand(
"REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" +
"VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)",
_dbConnection.Connection);
MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16);
p.Value = asset.FullID.GetBytes();
cmd.Parameters.AddWithValue("?name", asset.Name);
@ -148,7 +151,7 @@ namespace OpenSim.Framework.Data.MySQL
public string Version
{
get { return _dbConnection.getVersion(); }
get { return _dbConnection.getVersion(); }
}
public string Name
@ -158,4 +161,4 @@ namespace OpenSim.Framework.Data.MySQL
#endregion
}
}
}

View File

@ -25,13 +25,13 @@
* 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;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.MySQL
@ -59,7 +59,9 @@ namespace OpenSim.Framework.Data.MySQL
string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
database =
new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
settingPort);
}
/// <summary>
@ -108,7 +110,10 @@ namespace OpenSim.Framework.Data.MySQL
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);
IDbCommand result =
database.Query(
"SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax",
param);
IDataReader reader = result.ExecuteReader();
RegionProfileData row;
@ -123,7 +128,6 @@ namespace OpenSim.Framework.Data.MySQL
result.Dispose();
return rows.ToArray();
}
}
catch (Exception e)
@ -266,7 +270,10 @@ namespace OpenSim.Framework.Data.MySQL
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);
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);
@ -284,6 +291,4 @@ namespace OpenSim.Framework.Data.MySQL
}
}
}
}
}

View File

@ -26,13 +26,10 @@
*
*/
using System;
using System.IO;
using System.Data;
using System.Collections.Generic;
using libsecondlife;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using MySql.Data.MySqlClient;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.MySQL
{
@ -59,7 +56,9 @@ namespace OpenSim.Framework.Data.MySQL
string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
database =
new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
settingPort);
TestTables(database.Connection);
}
@ -99,7 +98,6 @@ namespace OpenSim.Framework.Data.MySQL
private void TestTables(MySqlConnection conn)
{
Dictionary<string, string> tableList = new Dictionary<string, string>();
tableList["inventoryfolders"] = null;
@ -110,6 +108,7 @@ namespace OpenSim.Framework.Data.MySQL
UpgradeFoldersTable(tableList["inventoryfolders"]);
UpgradeItemsTable(tableList["inventoryitems"]);
}
#endregion
/// <summary>
@ -151,11 +150,13 @@ namespace OpenSim.Framework.Data.MySQL
{
List<InventoryItemBase> items = new List<InventoryItemBase>();
MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", database.Connection);
MySqlCommand result =
new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid",
database.Connection);
result.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated());
MySqlDataReader reader = result.ExecuteReader();
while(reader.Read())
while (reader.Read())
items.Add(readInventoryItem(reader));
reader.Close();
@ -183,13 +184,16 @@ namespace OpenSim.Framework.Data.MySQL
{
lock (database)
{
MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", database.Connection);
MySqlCommand result =
new MySqlCommand(
"SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid",
database.Connection);
result.Parameters.AddWithValue("?uuid", user.ToStringHyphenated());
result.Parameters.AddWithValue("?zero", LLUUID.Zero.ToStringHyphenated());
MySqlDataReader reader = result.ExecuteReader();
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
while(reader.Read())
while (reader.Read())
items.Add(readInventoryFolder(reader));
@ -218,17 +222,21 @@ namespace OpenSim.Framework.Data.MySQL
{
lock (database)
{
MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", database.Connection);
MySqlCommand result =
new MySqlCommand(
"SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid",
database.Connection);
result.Parameters.AddWithValue("?uuid", user.ToStringHyphenated());
result.Parameters.AddWithValue("?zero", LLUUID.Zero.ToStringHyphenated());
MySqlDataReader reader = result.ExecuteReader();
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
while(reader.Read())
while (reader.Read())
items.Add(readInventoryFolder(reader));
InventoryFolderBase rootFolder = items[0]; //should only be one folder with parent set to zero (the root one).
InventoryFolderBase rootFolder = items[0];
//should only be one folder with parent set to zero (the root one).
reader.Close();
result.Dispose();
@ -254,13 +262,15 @@ namespace OpenSim.Framework.Data.MySQL
{
lock (database)
{
MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", database.Connection);
MySqlCommand result =
new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid",
database.Connection);
result.Parameters.AddWithValue("?uuid", parentID.ToStringHyphenated());
MySqlDataReader reader = result.ExecuteReader();
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
while(reader.Read())
while (reader.Read())
items.Add(readInventoryFolder(reader));
reader.Close();
@ -288,19 +298,19 @@ namespace OpenSim.Framework.Data.MySQL
{
InventoryItemBase item = new InventoryItemBase();
item.inventoryID = new LLUUID((string)reader["inventoryID"]);
item.assetID = new LLUUID((string)reader["assetID"]);
item.assetType = (int)reader["assetType"];
item.parentFolderID = new LLUUID((string)reader["parentFolderID"]);
item.avatarID = new LLUUID((string)reader["avatarID"]);
item.inventoryName = (string)reader["inventoryName"];
item.inventoryDescription = (string)reader["inventoryDescription"];
item.inventoryNextPermissions = (uint)reader["inventoryNextPermissions"];
item.inventoryCurrentPermissions = (uint)reader["inventoryCurrentPermissions"];
item.invType = (int)reader["invType"];
item.creatorsID = new LLUUID((string)reader["creatorID"]);
item.inventoryBasePermissions = (uint)reader["inventoryBasePermissions"];
item.inventoryEveryOnePermissions = (uint)reader["inventoryEveryOnePermissions"];
item.inventoryID = new LLUUID((string) reader["inventoryID"]);
item.assetID = new LLUUID((string) reader["assetID"]);
item.assetType = (int) reader["assetType"];
item.parentFolderID = new LLUUID((string) reader["parentFolderID"]);
item.avatarID = new LLUUID((string) reader["avatarID"]);
item.inventoryName = (string) reader["inventoryName"];
item.inventoryDescription = (string) reader["inventoryDescription"];
item.inventoryNextPermissions = (uint) reader["inventoryNextPermissions"];
item.inventoryCurrentPermissions = (uint) reader["inventoryCurrentPermissions"];
item.invType = (int) reader["invType"];
item.creatorsID = new LLUUID((string) reader["creatorID"]);
item.inventoryBasePermissions = (uint) reader["inventoryBasePermissions"];
item.inventoryEveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"];
return item;
}
catch (MySqlException e)
@ -324,12 +334,13 @@ namespace OpenSim.Framework.Data.MySQL
{
Dictionary<string, string> param = new Dictionary<string, string>();
MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection);
MySqlCommand result =
new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection);
result.Parameters.AddWithValue("?uuid", itemID.ToStringHyphenated());
MySqlDataReader reader = result.ExecuteReader();
InventoryItemBase item = null;
if(reader.Read())
if (reader.Read())
item = readInventoryItem(reader);
reader.Close();
@ -356,12 +367,12 @@ namespace OpenSim.Framework.Data.MySQL
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"];
folder.type = (short)reader["type"];
folder.version = (ushort)((int)reader["version"]);
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"];
folder.type = (short) reader["type"];
folder.version = (ushort) ((int) reader["version"]);
return folder;
}
catch (Exception e)
@ -384,7 +395,8 @@ namespace OpenSim.Framework.Data.MySQL
{
lock (database)
{
MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection);
MySqlCommand result =
new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection);
result.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated());
MySqlDataReader reader = result.ExecuteReader();
@ -410,8 +422,10 @@ namespace OpenSim.Framework.Data.MySQL
/// <param name="item">The inventory item</param>
public void addInventoryItem(InventoryItemBase item)
{
string sql = "REPLACE INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType, creatorID, inventoryBasePermissions, inventoryEveryOnePermissions) VALUES ";
sql += "(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription, ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID, ?inventoryBasePermissions, ?inventoryEveryOnePermissions)";
string sql =
"REPLACE INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType, creatorID, inventoryBasePermissions, inventoryEveryOnePermissions) VALUES ";
sql +=
"(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription, ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID, ?inventoryBasePermissions, ?inventoryEveryOnePermissions)";
try
{
@ -424,7 +438,8 @@ namespace OpenSim.Framework.Data.MySQL
result.Parameters.AddWithValue("?inventoryName", item.inventoryName);
result.Parameters.AddWithValue("?inventoryDescription", item.inventoryDescription);
result.Parameters.AddWithValue("?inventoryNextPermissions", item.inventoryNextPermissions.ToString());
result.Parameters.AddWithValue("?inventoryCurrentPermissions", item.inventoryCurrentPermissions.ToString());
result.Parameters.AddWithValue("?inventoryCurrentPermissions",
item.inventoryCurrentPermissions.ToString());
result.Parameters.AddWithValue("?invType", item.invType);
result.Parameters.AddWithValue("?creatorID", item.creatorsID.ToStringHyphenated());
result.Parameters.AddWithValue("?inventoryBasePermissions", item.inventoryBasePermissions);
@ -455,7 +470,8 @@ namespace OpenSim.Framework.Data.MySQL
{
try
{
MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", database.Connection);
MySqlCommand cmd =
new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", database.Connection);
cmd.Parameters.AddWithValue("?uuid", itemID.ToStringHyphenated());
cmd.ExecuteNonQuery();
}
@ -472,7 +488,8 @@ namespace OpenSim.Framework.Data.MySQL
/// <param name="folder">Folder to create</param>
public void addInventoryFolder(InventoryFolderBase folder)
{
string sql = "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version) VALUES ";
string sql =
"REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version) VALUES ";
sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName, ?type, ?version)";
MySqlCommand cmd = new MySqlCommand(sql, database.Connection);
@ -480,9 +497,9 @@ namespace OpenSim.Framework.Data.MySQL
cmd.Parameters.AddWithValue("?agentID", folder.agentID.ToStringHyphenated());
cmd.Parameters.AddWithValue("?parentFolderID", folder.parentID.ToStringHyphenated());
cmd.Parameters.AddWithValue("?folderName", folder.name);
cmd.Parameters.AddWithValue("?type", (short)folder.type);
cmd.Parameters.AddWithValue("?type", (short) folder.type);
cmd.Parameters.AddWithValue("?version", folder.version);
try
{
cmd.ExecuteNonQuery();
@ -515,7 +532,7 @@ namespace OpenSim.Framework.Data.MySQL
foreach (InventoryFolderBase f in subfolderList)
folders.Add(f);
}
/// <summary>
/// Returns all child folders in the hierarchy from the parent folder and down
/// </summary>
@ -536,7 +553,8 @@ namespace OpenSim.Framework.Data.MySQL
{
try
{
MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection);
MySqlCommand cmd =
new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection);
cmd.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated());
cmd.ExecuteNonQuery();
}
@ -551,7 +569,8 @@ namespace OpenSim.Framework.Data.MySQL
{
try
{
MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection);
MySqlCommand cmd =
new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection);
cmd.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated());
cmd.ExecuteNonQuery();
}
@ -586,4 +605,4 @@ namespace OpenSim.Framework.Data.MySQL
}
}
}
}
}

View File

@ -25,14 +25,12 @@
* 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
internal class MySQLLogData : ILogData
{
/// <summary>
/// The database manager
@ -52,7 +50,9 @@ namespace OpenSim.Framework.Data.MySQL
string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
database =
new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
settingPort);
}
/// <summary>
@ -64,7 +64,8 @@ namespace OpenSim.Framework.Data.MySQL
/// <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)
public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,
string logMessage)
{
try
{
@ -102,4 +103,4 @@ namespace OpenSim.Framework.Data.MySQL
return "0.1";
}
}
}
}

View File

@ -25,16 +25,14 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.IO;
using System.Data;
using System.Reflection;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Reflection;
using libsecondlife;
using MySql.Data.MySqlClient;
using OpenSim.Framework;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.MySQL
@ -42,16 +40,17 @@ namespace OpenSim.Framework.Data.MySQL
/// <summary>
/// A MySQL Database manager
/// </summary>
class MySQLManager
internal class MySQLManager
{
/// <summary>
/// The database connection object
/// </summary>
MySqlConnection dbcon;
private MySqlConnection dbcon;
/// <summary>
/// Connection string for ADO.net
/// </summary>
string connectionString;
private string connectionString;
/// <summary>
/// Initialises and creates a new MySQL connection and maintains it.
@ -61,11 +60,13 @@ namespace OpenSim.Framework.Data.MySQL
/// <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)
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 + ";";
connectionString = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" +
username + ";Password=" + password + ";Pooling=" + cpooling + ";";
dbcon = new MySqlConnection(connectionString);
dbcon.Open();
@ -123,15 +124,17 @@ namespace OpenSim.Framework.Data.MySQL
/// <returns>A string containing the DB provider</returns>
public string getVersion()
{
System.Reflection.Module module = this.GetType().Module;
Module module = GetType().Module;
string dllName = module.Assembly.ManifestModule.Name;
Version dllVersion = module.Assembly.GetName().Version;
return string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, dllVersion.Revision);
return
string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
dllVersion.Revision);
}
/// <summary>
/// Extract a named string resource from the embedded resources
/// </summary>
@ -139,7 +142,7 @@ namespace OpenSim.Framework.Data.MySQL
/// <returns>string contained within the embedded resource</returns>
private string getResourceString(string name)
{
Assembly assem = this.GetType().Assembly;
Assembly assem = GetType().Assembly;
string[] names = assem.GetManifestResourceNames();
foreach (string s in names)
@ -173,7 +176,10 @@ namespace OpenSim.Framework.Data.MySQL
{
lock (dbcon)
{
MySqlCommand tablesCmd = new MySqlCommand("SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", dbcon);
MySqlCommand tablesCmd =
new MySqlCommand(
"SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname",
dbcon);
tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database);
using (MySqlDataReader tables = tablesCmd.ExecuteReader())
{
@ -181,9 +187,9 @@ namespace OpenSim.Framework.Data.MySQL
{
try
{
string tableName = (string)tables["TABLE_NAME"];
string comment = (string)tables["TABLE_COMMENT"];
if(tableList.ContainsKey(tableName))
string tableName = (string) tables["TABLE_NAME"];
string comment = (string) tables["TABLE_COMMENT"];
if (tableList.ContainsKey(tableName))
tableList[tableName] = comment;
}
catch (Exception e)
@ -198,7 +204,7 @@ namespace OpenSim.Framework.Data.MySQL
// at some time this code should be cleaned up
/// <summary>
/// Runs a query with protection against SQL Injection by using parameterised input.
/// </summary>
@ -209,14 +215,14 @@ namespace OpenSim.Framework.Data.MySQL
{
try
{
MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand();
MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand();
dbcommand.CommandText = sql;
foreach (KeyValuePair<string, string> param in parameters)
{
dbcommand.Parameters.AddWithValue(param.Key, param.Value);
}
return (IDbCommand)dbcommand;
return (IDbCommand) dbcommand;
}
catch
{
@ -227,7 +233,9 @@ namespace OpenSim.Framework.Data.MySQL
{
dbcon.Close();
}
catch { }
catch
{
}
// Try reopen it
try
@ -243,14 +251,14 @@ namespace OpenSim.Framework.Data.MySQL
// Run the query again
try
{
MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand();
MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand();
dbcommand.CommandText = sql;
foreach (KeyValuePair<string, string> param in parameters)
{
dbcommand.Parameters.AddWithValue(param.Key, param.Value);
}
return (IDbCommand)dbcommand;
return (IDbCommand) dbcommand;
}
catch (Exception e)
{
@ -275,20 +283,20 @@ namespace OpenSim.Framework.Data.MySQL
{
// Region Main
retval.regionHandle = Convert.ToUInt64(reader["regionHandle"].ToString());
retval.regionName = (string)reader["regionName"];
retval.UUID = new LLUUID((string)reader["uuid"]);
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"];
retval.regionRecvKey = (string) reader["regionRecvKey"];
retval.regionSecret = (string) reader["regionSecret"];
retval.regionSendKey = (string) reader["regionSendKey"];
// Region Server
retval.regionDataURI = (string)reader["regionDataURI"];
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.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());
@ -304,14 +312,14 @@ namespace OpenSim.Framework.Data.MySQL
retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString());
// Assets
retval.regionAssetURI = (string)reader["regionAssetURI"];
retval.regionAssetRecvKey = (string)reader["regionAssetRecvKey"];
retval.regionAssetSendKey = (string)reader["regionAssetSendKey"];
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"];
retval.regionUserURI = (string) reader["regionUserURI"];
retval.regionUserRecvKey = (string) reader["regionUserRecvKey"];
retval.regionUserSendKey = (string) reader["regionUserSendKey"];
// World Map Addition
string tempRegionMap = reader["regionMapTexture"].ToString();
@ -341,17 +349,16 @@ namespace OpenSim.Framework.Data.MySQL
ReservationData retval = new ReservationData();
if (reader.Read())
{
retval.gridRecvKey = (string)reader["gridRecvKey"];
retval.gridSendKey = (string)reader["gridSendKey"];
retval.reservationCompany = (string)reader["resCompany"];
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.reservationName = (string) reader["resName"];
retval.status = Convert.ToInt32(reader["status"].ToString()) == 1;
retval.userUUID = new LLUUID((string)reader["userUUID"]);
retval.userUUID = new LLUUID((string) reader["userUUID"]);
}
else
{
@ -359,6 +366,7 @@ namespace OpenSim.Framework.Data.MySQL
}
return retval;
}
/// <summary>
/// Reads an agent row from a database reader
/// </summary>
@ -371,12 +379,12 @@ namespace OpenSim.Framework.Data.MySQL
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"]);
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.agentIP = (string) reader["agentIP"];
retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString());
retval.agentOnline = Convert.ToBoolean(reader["agentOnline"].ToString());
@ -385,9 +393,9 @@ namespace OpenSim.Framework.Data.MySQL
retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString());
// Current position
retval.currentRegion = (string)reader["currentRegion"];
retval.currentRegion = (string) reader["currentRegion"];
retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString());
LLVector3.TryParse((string)reader["currentPos"], out retval.currentPos);
LLVector3.TryParse((string) reader["currentPos"], out retval.currentPos);
}
else
{
@ -407,12 +415,12 @@ namespace OpenSim.Framework.Data.MySQL
if (reader.Read())
{
retval.UUID = new LLUUID((string)reader["UUID"]);
retval.username = (string)reader["username"];
retval.surname = (string)reader["lastname"];
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.passwordHash = (string) reader["passwordHash"];
retval.passwordSalt = (string) reader["passwordSalt"];
retval.homeRegion = Convert.ToUInt64(reader["homeRegion"].ToString());
retval.homeLocation = new LLVector3(
@ -427,18 +435,17 @@ namespace OpenSim.Framework.Data.MySQL
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.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"]);
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
{
@ -448,7 +455,6 @@ namespace OpenSim.Framework.Data.MySQL
}
/// <summary>
/// Inserts a new row into the log database
/// </summary>
@ -459,7 +465,8 @@ namespace OpenSim.Framework.Data.MySQL
/// <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)
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)";
@ -493,89 +500,97 @@ namespace OpenSim.Framework.Data.MySQL
}
/// <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)
{
MainLog.Instance.Error(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(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,
LLUUID profileImage, 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"] = LLUUID.Zero.ToStringHyphenated();
parameters["?profileFirstImage"] = LLUUID.Zero.ToStringHyphenated();
bool returnval = false;
try
{
IDbCommand result = Query(sql, parameters);
if (result.ExecuteNonQuery() == 1)
returnval = true;
result.Dispose();
}
catch (Exception e)
{
MainLog.Instance.Error(e.ToString());
return false;
}
return returnval;
}
/// <summary>
@ -585,13 +600,18 @@ namespace OpenSim.Framework.Data.MySQL
/// <returns>Success?</returns>
public bool insertRegion(RegionProfileData 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 ";
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);";
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>();
@ -626,7 +646,6 @@ namespace OpenSim.Framework.Data.MySQL
try
{
IDbCommand result = Query(sql, parameters);
//Console.WriteLine(result.CommandText);
@ -646,4 +665,4 @@ namespace OpenSim.Framework.Data.MySQL
return returnval;
}
}
}
}

View File

@ -29,7 +29,6 @@ using System;
using System.Collections.Generic;
using System.Data;
using libsecondlife;
using OpenSim.Framework;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.MySQL
@ -37,7 +36,7 @@ namespace OpenSim.Framework.Data.MySQL
/// <summary>
/// A database interface class to a user profile storage system
/// </summary>
class MySQLUserData : IUserData
internal class MySQLUserData : IUserData
{
/// <summary>
/// Database manager for MySQL
@ -59,7 +58,9 @@ namespace OpenSim.Framework.Data.MySQL
string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
database =
new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
settingPort);
}
/// <summary>
@ -88,11 +89,12 @@ namespace OpenSim.Framework.Data.MySQL
param["?first"] = user;
param["?second"] = last;
IDbCommand result = database.Query("SELECT * FROM users WHERE username = ?first AND lastname = ?second", param);
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();
@ -201,21 +203,25 @@ namespace OpenSim.Framework.Data.MySQL
/// <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();
MainLog.Instance.Error(e.ToString());
}
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();
MainLog.Instance.Error(e.ToString());
}
}
/// <summary>
@ -226,8 +232,8 @@ namespace OpenSim.Framework.Data.MySQL
{
// Do nothing.
}
public bool UpdateUserProfile(UserProfileData user)
{
return true;
@ -277,4 +283,4 @@ namespace OpenSim.Framework.Data.MySQL
return "0.1";
}
}
}
}

View File

@ -1,24 +1,28 @@
using System.Reflection;
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("")]
[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)]
[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")]
[assembly : Guid("e49826b2-dcef-41be-a5bd-596733fa3304")]
// Version information for an assembly consists of the following four values:
//
@ -29,5 +33,6 @@ using System.Runtime.InteropServices;
//
// 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")]
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]

View File

@ -1,24 +1,28 @@
using System.Reflection;
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("")]
[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)]
[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")]
[assembly : Guid("6113d5ce-4547-49f4-9236-0dcc503457b1")]
// Version information for an assembly consists of the following four values:
//
@ -29,5 +33,6 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.4.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly : AssemblyVersion("0.4.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]

View File

@ -26,15 +26,11 @@
*
*/
using System;
using System.IO;
using libsecondlife;
using OpenSim.Framework;
using System.Data;
using System.Data.SqlTypes;
using System.Reflection;
using libsecondlife;
using Mono.Data.SqliteClient;
using OpenSim.Framework.Console;
using OpenSim.Framework;
using OpenSim.Framework.Interfaces;
namespace OpenSim.Framework.Data.SQLite
{
@ -46,11 +42,11 @@ namespace OpenSim.Framework.Data.SQLite
/// <summary>
/// The database manager
/// </summary>
/// <summary>
/// Artificial constructor called upon plugin load
/// </summary>
private const string assetSelect = "select * from assets";
private DataSet ds;
private SqliteDataAdapter da;
@ -58,13 +54,14 @@ namespace OpenSim.Framework.Data.SQLite
{
SqliteConnection conn = new SqliteConnection("URI=file:" + dbfile + ",version=3");
TestTables(conn);
ds = new DataSet();
da = new SqliteDataAdapter(new SqliteCommand(assetSelect, conn));
lock (ds) {
lock (ds)
{
ds.Tables.Add(createAssetsTable());
setupAssetCommands(da, conn);
try
{
@ -75,11 +72,11 @@ namespace OpenSim.Framework.Data.SQLite
MainLog.Instance.Verbose("AssetStorage", "Caught fill error on asset table");
}
}
return;
}
public AssetBase FetchAsset(LLUUID uuid)
public AssetBase FetchAsset(LLUUID uuid)
{
AssetBase asset = new AssetBase();
DataRow row = ds.Tables["assets"].Rows.Find(uuid);
@ -92,27 +89,28 @@ namespace OpenSim.Framework.Data.SQLite
return null;
}
}
public void CreateAsset(AssetBase asset)
public void CreateAsset(AssetBase asset)
{
// no difference for now
UpdateAsset(asset);
}
public void UpdateAsset(AssetBase asset)
public void UpdateAsset(AssetBase asset)
{
LogAssetLoad(asset);
DataTable assets = ds.Tables["assets"];
lock(ds) {
lock (ds)
{
DataRow row = assets.Rows.Find(asset.FullID);
if (row == null)
if (row == null)
{
row = assets.NewRow();
fillAssetRow(row, asset);
assets.Rows.Add(row);
}
else
else
{
fillAssetRow(row, asset);
}
@ -124,9 +122,10 @@ namespace OpenSim.Framework.Data.SQLite
string temporary = asset.Temporary ? "Temporary" : "Stored";
string local = asset.Local ? "Local" : "Remote";
MainLog.Instance.Verbose("ASSETSTORAGE",
string.Format("Loaded {6} {5} Asset: [{0}][{3}/{4}] \"{1}\":{2} ({7} bytes)",
asset.FullID, asset.Name, asset.Description, asset.Type, asset.InvType, temporary, local, asset.Data.Length) );
MainLog.Instance.Verbose("ASSETSTORAGE",
string.Format("Loaded {6} {5} Asset: [{0}][{3}/{4}] \"{1}\":{2} ({7} bytes)",
asset.FullID, asset.Name, asset.Description, asset.Type,
asset.InvType, temporary, local, asset.Data.Length));
}
public bool ExistsAsset(LLUUID uuid)
@ -137,23 +136,26 @@ namespace OpenSim.Framework.Data.SQLite
public void DeleteAsset(LLUUID uuid)
{
lock (ds) {
lock (ds)
{
DataRow row = ds.Tables["assets"].Rows.Find(uuid);
if (row != null) {
if (row != null)
{
row.Delete();
}
}
}
public void CommitAssets() // force a sync to the database
{
MainLog.Instance.Verbose("AssetStorage", "Attempting commit");
lock (ds) {
lock (ds)
{
da.Update(ds, "assets");
ds.AcceptChanges();
}
}
/***********************************************************************
*
* Database Definition Functions
@ -161,24 +163,24 @@ namespace OpenSim.Framework.Data.SQLite
* This should be db agnostic as we define them in ADO.NET terms
*
**********************************************************************/
private DataTable createAssetsTable()
{
DataTable assets = new DataTable("assets");
createCol(assets, "UUID", typeof(System.String));
createCol(assets, "Name", typeof(System.String));
createCol(assets, "Description", typeof(System.String));
createCol(assets, "Type", typeof(System.Int32));
createCol(assets, "InvType", typeof(System.Int32));
createCol(assets, "Local", typeof(System.Boolean));
createCol(assets, "Temporary", typeof(System.Boolean));
createCol(assets, "Data", typeof(System.Byte[]));
createCol(assets, "UUID", typeof (String));
createCol(assets, "Name", typeof (String));
createCol(assets, "Description", typeof (String));
createCol(assets, "Type", typeof (Int32));
createCol(assets, "InvType", typeof (Int32));
createCol(assets, "Local", typeof (Boolean));
createCol(assets, "Temporary", typeof (Boolean));
createCol(assets, "Data", typeof (Byte[]));
// Add in contraints
assets.PrimaryKey = new DataColumn[] { assets.Columns["UUID"] };
assets.PrimaryKey = new DataColumn[] {assets.Columns["UUID"]};
return assets;
}
/***********************************************************************
*
* Convert between ADO.NET <=> OpenSim Objects
@ -193,19 +195,19 @@ namespace OpenSim.Framework.Data.SQLite
// interesting has to be done to actually get these values
// back out. Not enough time to figure it out yet.
AssetBase asset = new AssetBase();
asset.FullID = new LLUUID((String)row["UUID"]);
asset.Name = (String)row["Name"];
asset.Description = (String)row["Description"];
asset.FullID = new LLUUID((String) row["UUID"]);
asset.Name = (String) row["Name"];
asset.Description = (String) row["Description"];
asset.Type = Convert.ToSByte(row["Type"]);
asset.InvType = Convert.ToSByte(row["InvType"]);
asset.Local = Convert.ToBoolean(row["Local"]);
asset.Temporary = Convert.ToBoolean(row["Temporary"]);
asset.Data = (byte[])row["Data"];
asset.Data = (byte[]) row["Data"];
return asset;
}
private void fillAssetRow(DataRow row, AssetBase asset)
{
row["UUID"] = asset.FullID;
@ -225,8 +227,10 @@ namespace OpenSim.Framework.Data.SQLite
row["Data"] = asset.Data;
// ADO.NET doesn't handle NULL very well
foreach (DataColumn col in ds.Tables["assets"].Columns) {
if (row[col] == null) {
foreach (DataColumn col in ds.Tables["assets"].Columns)
{
if (row[col] == null)
{
row[col] = "";
}
}
@ -250,18 +254,18 @@ namespace OpenSim.Framework.Data.SQLite
da.UpdateCommand.Connection = conn;
SqliteCommand delete = new SqliteCommand("delete from assets where UUID = :UUID");
delete.Parameters.Add(createSqliteParameter("UUID", typeof(System.String)));
delete.Parameters.Add(createSqliteParameter("UUID", typeof (String)));
delete.Connection = conn;
da.DeleteCommand = delete;
}
private void InitDB(SqliteConnection conn)
{
string createAssets = defineTable(createAssetsTable());
SqliteCommand pcmd = new SqliteCommand(createAssets, conn);
conn.Open();
pcmd.ExecuteNonQuery();
conn.Close();
conn.Close();
}
private bool TestTables(SqliteConnection conn)
@ -269,9 +273,12 @@ namespace OpenSim.Framework.Data.SQLite
SqliteCommand cmd = new SqliteCommand(assetSelect, conn);
SqliteDataAdapter pDa = new SqliteDataAdapter(cmd);
DataSet tmpDS = new DataSet();
try {
try
{
pDa.Fill(tmpDS, "assets");
} catch (Mono.Data.SqliteClient.SqliteSyntaxException) {
}
catch (SqliteSyntaxException)
{
MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating");
InitDB(conn);
}
@ -279,14 +286,18 @@ namespace OpenSim.Framework.Data.SQLite
}
#region IPlugin interface
public string Version {
public string Version
{
get
{
System.Reflection.Module module = this.GetType().Module;
Module module = GetType().Module;
string dllName = module.Assembly.ManifestModule.Name;
Version dllVersion = module.Assembly.GetName().Version;
return string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, dllVersion.Revision);
return
string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
dllVersion.Revision);
}
}
@ -295,9 +306,11 @@ namespace OpenSim.Framework.Data.SQLite
Initialise("AssetStorage.db", "");
}
public string Name {
public string Name
{
get { return "SQLite Asset storage engine"; }
}
#endregion
}
}
}

View File

@ -26,13 +26,8 @@
*
*/
using System;
using System.IO;
using libsecondlife;
using OpenSim.Framework;
using System.Data;
using System.Data.SqlTypes;
using Mono.Data.SqliteClient;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.SQLite
{
@ -48,8 +43,8 @@ namespace OpenSim.Framework.Data.SQLite
* This should be db agnostic as we define them in ADO.NET terms
*
**********************************************************************/
protected static void createCol(DataTable dt, string name, System.Type type)
protected static void createCol(DataTable dt, string name, Type type)
{
DataColumn col = new DataColumn(name, type);
dt.Columns.Add(col);
@ -77,7 +72,8 @@ namespace OpenSim.Framework.Data.SQLite
* generate these strings instead of typing them out.
*/
string[] cols = new string[dt.Columns.Count];
for (int i = 0; i < dt.Columns.Count; i++) {
for (int i = 0; i < dt.Columns.Count; i++)
{
DataColumn col = dt.Columns[i];
cols[i] = col.ColumnName;
}
@ -92,7 +88,7 @@ namespace OpenSim.Framework.Data.SQLite
// this provides the binding for all our parameters, so
// much less code than it used to be
foreach (DataColumn col in dt.Columns)
foreach (DataColumn col in dt.Columns)
{
cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType));
}
@ -106,7 +102,8 @@ namespace OpenSim.Framework.Data.SQLite
foreach (DataColumn col in dt.Columns)
{
if (subsql.Length > 0)
{ // a map function would rock so much here
{
// a map function would rock so much here
subsql += ", ";
}
subsql += col.ColumnName + "= :" + col.ColumnName;
@ -118,7 +115,7 @@ namespace OpenSim.Framework.Data.SQLite
// this provides the binding for all our parameters, so
// much less code than it used to be
foreach (DataColumn col in dt.Columns)
foreach (DataColumn col in dt.Columns)
{
cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType));
}
@ -133,11 +130,12 @@ namespace OpenSim.Framework.Data.SQLite
foreach (DataColumn col in dt.Columns)
{
if (subsql.Length > 0)
{ // a map function would rock so much here
{
// a map function would rock so much here
subsql += ",\n";
}
subsql += col.ColumnName + " " + sqliteType(col.DataType);
if(col == dt.PrimaryKey[0])
if (col == dt.PrimaryKey[0])
{
subsql += " primary key";
}
@ -167,7 +165,7 @@ namespace OpenSim.Framework.Data.SQLite
/// for us.
///</summary>
///<returns>a built sqlite parameter</returns>
protected static SqliteParameter createSqliteParameter(string name, System.Type type)
protected static SqliteParameter createSqliteParameter(string name, Type type)
{
SqliteParameter param = new SqliteParameter();
param.ParameterName = ":" + name;
@ -182,53 +180,87 @@ namespace OpenSim.Framework.Data.SQLite
* Type conversion functions
*
**********************************************************************/
protected static DbType dbtypeFromType(Type type)
{
if (type == typeof(System.String)) {
if (type == typeof (String))
{
return DbType.String;
} else if (type == typeof(System.Int32)) {
}
else if (type == typeof (Int32))
{
return DbType.Int32;
} else if (type == typeof(System.UInt32)) {
}
else if (type == typeof (UInt32))
{
return DbType.UInt32;
} else if (type == typeof(System.Int64)) {
}
else if (type == typeof (Int64))
{
return DbType.Int64;
} else if (type == typeof(System.UInt64)) {
}
else if (type == typeof (UInt64))
{
return DbType.UInt64;
} else if (type == typeof(System.Double)) {
}
else if (type == typeof (Double))
{
return DbType.Double;
} else if (type == typeof(System.Boolean)) {
}
else if (type == typeof (Boolean))
{
return DbType.Boolean;
} else if (type == typeof(System.Byte[])) {
}
else if (type == typeof (Byte[]))
{
return DbType.Binary;
} else {
}
else
{
return DbType.String;
}
}
// this is something we'll need to implement for each db
// slightly differently.
protected static string sqliteType(Type type)
{
if (type == typeof(System.String)) {
if (type == typeof (String))
{
return "varchar(255)";
} else if (type == typeof(System.Int32)) {
}
else if (type == typeof (Int32))
{
return "integer";
} else if (type == typeof(System.UInt32)) {
}
else if (type == typeof (UInt32))
{
return "integer";
} else if (type == typeof(System.Int64)) {
}
else if (type == typeof (Int64))
{
return "varchar(255)";
} else if (type == typeof(System.UInt64)) {
}
else if (type == typeof (UInt64))
{
return "varchar(255)";
} else if (type == typeof(System.Double)) {
}
else if (type == typeof (Double))
{
return "float";
} else if (type == typeof(System.Boolean)) {
}
else if (type == typeof (Boolean))
{
return "integer";
} else if (type == typeof(System.Byte[])) {
}
else if (type == typeof (Byte[]))
{
return "blob";
} else {
}
else
{
return "string";
}
}
}
}
}

View File

@ -192,4 +192,4 @@ namespace OpenSim.Framework.Data.SQLite
return null;
}
}
}
}

View File

@ -28,22 +28,14 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using OpenSim.Framework.Console;
using OpenSim.Framework;
using OpenSim.Framework;
using libsecondlife;
using System.Data;
using System.Data.SqlTypes;
using System.Reflection;
using libsecondlife;
using Mono.Data.SqliteClient;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.SQLite
{
public class SQLiteInventoryStore : SQLiteBase, IInventoryData
{
private const string invItemsSelect = "select * from inventoryitems";
@ -96,14 +88,14 @@ namespace OpenSim.Framework.Data.SQLite
public InventoryItemBase buildItem(DataRow row)
{
InventoryItemBase item = new InventoryItemBase();
item.inventoryID = new LLUUID((string)row["UUID"]);
item.assetID = new LLUUID((string)row["assetID"]);
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.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"]);
@ -147,7 +139,7 @@ namespace OpenSim.Framework.Data.SQLite
fillFolderRow(inventoryRow, folder);
}
this.invFoldersDa.Update(ds, "inventoryfolders");
invFoldersDa.Update(ds, "inventoryfolders");
}
private void addItem(InventoryItemBase item)
@ -165,7 +157,7 @@ namespace OpenSim.Framework.Data.SQLite
{
fillItemRow(inventoryRow, item);
}
this.invItemsDa.Update(ds, "inventoryitems");
invItemsDa.Update(ds, "inventoryitems");
}
public void Shutdown()
@ -195,12 +187,14 @@ namespace OpenSim.Framework.Data.SQLite
/// <returns>A string containing the plugin version</returns>
public string getVersion()
{
System.Reflection.Module module = this.GetType().Module;
Module module = GetType().Module;
string dllName = module.Assembly.ManifestModule.Name;
Version dllVersion = module.Assembly.GetName().Version;
return string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, dllVersion.Revision);
return
string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
dllVersion.Revision);
}
/// <summary>
@ -306,7 +300,7 @@ namespace OpenSim.Framework.Data.SQLite
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
getInventoryFolders(ref folders, parentID);
for(int i=0; i<folders.Count; i++)
for (int i = 0; i < folders.Count; i++)
getInventoryFolders(ref folders, folders[i].folderID);
return folders;
@ -320,9 +314,12 @@ namespace OpenSim.Framework.Data.SQLite
public InventoryItemBase getInventoryItem(LLUUID item)
{
DataRow row = ds.Tables["inventoryitems"].Rows.Find(item);
if (row != null) {
if (row != null)
{
return buildItem(row);
} else {
}
else
{
return null;
}
}
@ -334,19 +331,21 @@ namespace OpenSim.Framework.Data.SQLite
/// <returns>A class containing folder information</returns>
public InventoryFolderBase getInventoryFolder(LLUUID folder)
{
// TODO: Deep voodoo here. If you enable this code then
// multi region breaks. No idea why, but I figured it was
// better to leave multi region at this point. It does mean
// that you don't get to see system textures why creating
// clothes and the like. :(
DataRow row = ds.Tables["inventoryfolders"].Rows.Find(folder);
if (row != null) {
// TODO: Deep voodoo here. If you enable this code then
// multi region breaks. No idea why, but I figured it was
// better to leave multi region at this point. It does mean
// that you don't get to see system textures why creating
// clothes and the like. :(
DataRow row = ds.Tables["inventoryfolders"].Rows.Find(folder);
if (row != null)
{
return buildFolder(row);
} else {
}
else
{
return null;
}
}
}
/// <summary>
@ -355,7 +354,7 @@ namespace OpenSim.Framework.Data.SQLite
/// <param name="item">The item to be created</param>
public void addInventoryItem(InventoryItemBase item)
{
this.addItem(item);
addItem(item);
}
/// <summary>
@ -364,7 +363,7 @@ namespace OpenSim.Framework.Data.SQLite
/// <param name="item">The updated item</param>
public void updateInventoryItem(InventoryItemBase item)
{
this.addItem(item);
addItem(item);
}
/// <summary>
@ -376,12 +375,12 @@ namespace OpenSim.Framework.Data.SQLite
DataTable inventoryItemTable = ds.Tables["inventoryitems"];
DataRow inventoryRow = inventoryItemTable.Rows.Find(itemID);
if (inventoryRow != null)
{
inventoryRow.Delete();
}
if (inventoryRow != null)
{
inventoryRow.Delete();
}
this.invItemsDa.Update(ds, "inventoryitems");
invItemsDa.Update(ds, "inventoryitems");
}
@ -394,7 +393,7 @@ namespace OpenSim.Framework.Data.SQLite
{
List<InventoryItemBase> items = getInventoryInFolder(folderId);
foreach(InventoryItemBase i in items)
foreach (InventoryItemBase i in items)
deleteInventoryItem(i.inventoryID);
}
@ -404,7 +403,7 @@ namespace OpenSim.Framework.Data.SQLite
/// <param name="folder">The inventory folder</param>
public void addInventoryFolder(InventoryFolderBase folder)
{
this.addFolder(folder);
addFolder(folder);
}
/// <summary>
@ -413,7 +412,7 @@ namespace OpenSim.Framework.Data.SQLite
/// <param name="folder">The inventory folder</param>
public void updateInventoryFolder(InventoryFolderBase folder)
{
this.addFolder(folder);
addFolder(folder);
}
@ -427,7 +426,7 @@ namespace OpenSim.Framework.Data.SQLite
public void deleteInventoryFolder(LLUUID folderID)
{
List<InventoryFolderBase> subFolders = getFolderHierarchy(folderID);
DataTable inventoryFolderTable = ds.Tables["inventoryfolders"];
DataRow inventoryRow;
@ -450,7 +449,7 @@ namespace OpenSim.Framework.Data.SQLite
inventoryRow.Delete();
}
this.invFoldersDa.Update(ds, "inventoryfolders");
invFoldersDa.Update(ds, "inventoryfolders");
}
/***********************************************************************
@ -458,43 +457,43 @@ namespace OpenSim.Framework.Data.SQLite
* Data Table definitions
*
**********************************************************************/
private static DataTable createInventoryItemsTable()
{
DataTable inv = new DataTable("inventoryitems");
createCol(inv, "UUID", typeof(System.String)); //inventoryID
createCol(inv, "assetID", typeof(System.String));
createCol(inv, "assetType", typeof(System.Int32));
createCol(inv, "invType", typeof(System.Int32));
createCol(inv, "parentFolderID", typeof(System.String));
createCol(inv, "avatarID", typeof(System.String));
createCol(inv, "creatorsID", typeof(System.String));
createCol(inv, "inventoryName", typeof(System.String));
createCol(inv, "inventoryDescription", typeof(System.String));
createCol(inv, "UUID", typeof (String)); //inventoryID
createCol(inv, "assetID", typeof (String));
createCol(inv, "assetType", typeof (Int32));
createCol(inv, "invType", typeof (Int32));
createCol(inv, "parentFolderID", typeof (String));
createCol(inv, "avatarID", typeof (String));
createCol(inv, "creatorsID", typeof (String));
createCol(inv, "inventoryName", typeof (String));
createCol(inv, "inventoryDescription", typeof (String));
// permissions
createCol(inv, "inventoryNextPermissions", typeof(System.Int32));
createCol(inv, "inventoryCurrentPermissions", typeof(System.Int32));
createCol(inv, "inventoryBasePermissions", typeof(System.Int32));
createCol(inv, "inventoryEveryOnePermissions", typeof(System.Int32));
inv.PrimaryKey = new DataColumn[] { inv.Columns["UUID"] };
createCol(inv, "inventoryNextPermissions", typeof (Int32));
createCol(inv, "inventoryCurrentPermissions", typeof (Int32));
createCol(inv, "inventoryBasePermissions", typeof (Int32));
createCol(inv, "inventoryEveryOnePermissions", typeof (Int32));
inv.PrimaryKey = new DataColumn[] {inv.Columns["UUID"]};
return inv;
}
private DataTable createInventoryFoldersTable()
{
DataTable fol = new DataTable("inventoryfolders");
createCol(fol, "UUID", typeof(System.String)); //folderID
createCol(fol, "name", typeof(System.String));
createCol(fol, "agentID", typeof(System.String));
createCol(fol, "parentID", typeof(System.String));
createCol(fol, "type", typeof(System.Int32));
createCol(fol, "version", typeof(System.Int32));
fol.PrimaryKey = new DataColumn[] { fol.Columns["UUID"] };
createCol(fol, "UUID", typeof (String)); //folderID
createCol(fol, "name", typeof (String));
createCol(fol, "agentID", typeof (String));
createCol(fol, "parentID", typeof (String));
createCol(fol, "type", typeof (Int32));
createCol(fol, "version", typeof (Int32));
fol.PrimaryKey = new DataColumn[] {fol.Columns["UUID"]};
return fol;
}
@ -507,7 +506,7 @@ namespace OpenSim.Framework.Data.SQLite
da.UpdateCommand.Connection = conn;
SqliteCommand delete = new SqliteCommand("delete from inventoryitems where UUID = :UUID");
delete.Parameters.Add(createSqliteParameter("UUID", typeof(System.String)));
delete.Parameters.Add(createSqliteParameter("UUID", typeof (String)));
delete.Connection = conn;
da.DeleteCommand = delete;
}
@ -521,7 +520,7 @@ namespace OpenSim.Framework.Data.SQLite
da.UpdateCommand.Connection = conn;
SqliteCommand delete = new SqliteCommand("delete from inventoryfolders where UUID = :UUID");
delete.Parameters.Add(createSqliteParameter("UUID", typeof(System.String)));
delete.Parameters.Add(createSqliteParameter("UUID", typeof (String)));
delete.Connection = conn;
da.DeleteCommand = delete;
}
@ -529,10 +528,10 @@ namespace OpenSim.Framework.Data.SQLite
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.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;
@ -554,17 +553,18 @@ namespace OpenSim.Framework.Data.SQLite
* Test and Initialization code
*
**********************************************************************/
private void InitDB(SqliteConnection conn)
{
string createInventoryItems = defineTable(createInventoryItemsTable());
string createInventoryFolders = defineTable(createInventoryFoldersTable());
SqliteCommand pcmd = new SqliteCommand(createInventoryItems, conn);
SqliteCommand scmd = new SqliteCommand(createInventoryFolders, conn);
conn.Open();
pcmd.ExecuteNonQuery();
scmd.ExecuteNonQuery();
conn.Close();
conn.Close();
}
private bool TestTables(SqliteConnection conn)
@ -575,10 +575,13 @@ namespace OpenSim.Framework.Data.SQLite
SqliteDataAdapter sDa = new SqliteDataAdapter(invFoldersSelectCmd);
DataSet tmpDS = new DataSet();
try {
try
{
pDa.Fill(tmpDS, "inventoryitems");
sDa.Fill(tmpDS, "inventoryfolders");
} catch (Mono.Data.SqliteClient.SqliteSyntaxException) {
}
catch (SqliteSyntaxException)
{
MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating");
InitDB(conn);
}
@ -586,14 +589,18 @@ namespace OpenSim.Framework.Data.SQLite
pDa.Fill(tmpDS, "inventoryitems");
sDa.Fill(tmpDS, "inventoryfolders");
foreach (DataColumn col in createInventoryItemsTable().Columns) {
if (! tmpDS.Tables["inventoryitems"].Columns.Contains(col.ColumnName) ) {
foreach (DataColumn col in createInventoryItemsTable().Columns)
{
if (! tmpDS.Tables["inventoryitems"].Columns.Contains(col.ColumnName))
{
MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName);
return false;
}
}
foreach (DataColumn col in createInventoryFoldersTable().Columns) {
if (! tmpDS.Tables["inventoryfolders"].Columns.Contains(col.ColumnName) ) {
foreach (DataColumn col in createInventoryFoldersTable().Columns)
{
if (! tmpDS.Tables["inventoryfolders"].Columns.Contains(col.ColumnName))
{
MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName);
return false;
}
@ -601,8 +608,4 @@ namespace OpenSim.Framework.Data.SQLite
return true;
}
}
}
}

View File

@ -30,13 +30,14 @@ using System.Collections.Generic;
using System.Data;
using System.Data.SQLite;
using libsecondlife;
using Mono.Data.SqliteClient;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.SQLite
{
class SQLiteManager : SQLiteBase
internal class SQLiteManager : SQLiteBase
{
IDbConnection dbcon;
private IDbConnection dbcon;
/// <summary>
/// Initialises and creates a new SQLite connection and maintains it.
@ -78,15 +79,15 @@ namespace OpenSim.Framework.Data.SQLite
/// <returns>A SQLite DB Command</returns>
public IDbCommand Query(string sql, Dictionary<string, string> parameters)
{
SQLiteCommand dbcommand = (SQLiteCommand)dbcon.CreateCommand();
SQLiteCommand dbcommand = (SQLiteCommand) dbcon.CreateCommand();
dbcommand.CommandText = sql;
foreach (KeyValuePair<string, string> param in parameters)
{
SQLiteParameter paramx = new SQLiteParameter(param.Key,param.Value);
SQLiteParameter paramx = new SQLiteParameter(param.Key, param.Value);
dbcommand.Parameters.Add(paramx);
}
return (IDbCommand)dbcommand;
return (IDbCommand) dbcommand;
}
private bool TestTables(SQLiteConnection conn)
@ -98,7 +99,7 @@ namespace OpenSim.Framework.Data.SQLite
{
pDa.Fill(tmpDS, "regions");
}
catch (Mono.Data.SqliteClient.SqliteSyntaxException)
catch (SqliteSyntaxException)
{
MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating");
InitDB(conn);
@ -110,39 +111,39 @@ namespace OpenSim.Framework.Data.SQLite
{
DataTable regions = new DataTable("regions");
createCol(regions, "regionHandle", typeof(ulong));
createCol(regions, "regionName", typeof(System.String));
createCol(regions, "uuid", typeof(System.String));
createCol(regions, "regionHandle", typeof (ulong));
createCol(regions, "regionName", typeof (String));
createCol(regions, "uuid", typeof (String));
createCol(regions, "regionRecvKey", typeof(System.String));
createCol(regions, "regionSecret", typeof(System.String));
createCol(regions, "regionSendKey", typeof(System.String));
createCol(regions, "regionDataURI", typeof(System.String));
createCol(regions, "serverIP", typeof(System.String));
createCol(regions, "serverPort", typeof(System.String));
createCol(regions, "serverURI", typeof(System.String));
createCol(regions, "regionRecvKey", typeof (String));
createCol(regions, "regionSecret", typeof (String));
createCol(regions, "regionSendKey", typeof (String));
createCol(regions, "locX", typeof( uint));
createCol(regions, "locY", typeof( uint));
createCol(regions, "locZ", typeof( uint));
createCol(regions, "regionDataURI", typeof (String));
createCol(regions, "serverIP", typeof (String));
createCol(regions, "serverPort", typeof (String));
createCol(regions, "serverURI", typeof (String));
createCol(regions, "eastOverrideHandle", typeof( ulong ));
createCol(regions, "westOverrideHandle", typeof( ulong ));
createCol(regions, "southOverrideHandle", typeof( ulong ));
createCol(regions, "northOverrideHandle", typeof( ulong ));
createCol(regions, "regionAssetURI", typeof(System.String));
createCol(regions, "regionAssetRecvKey", typeof(System.String));
createCol(regions, "regionAssetSendKey", typeof(System.String));
createCol(regions, "locX", typeof (uint));
createCol(regions, "locY", typeof (uint));
createCol(regions, "locZ", typeof (uint));
createCol(regions, "regionUserURI", typeof(System.String));
createCol(regions, "regionUserRecvKey", typeof(System.String));
createCol(regions, "regionUserSendKey", typeof(System.String));
createCol(regions, "eastOverrideHandle", typeof (ulong));
createCol(regions, "westOverrideHandle", typeof (ulong));
createCol(regions, "southOverrideHandle", typeof (ulong));
createCol(regions, "northOverrideHandle", typeof (ulong));
createCol(regions, "regionAssetURI", typeof (String));
createCol(regions, "regionAssetRecvKey", typeof (String));
createCol(regions, "regionAssetSendKey", typeof (String));
createCol(regions, "regionUserURI", typeof (String));
createCol(regions, "regionUserRecvKey", typeof (String));
createCol(regions, "regionUserSendKey", typeof (String));
// Add in contraints
regions.PrimaryKey = new DataColumn[] { regions.Columns["UUID"] };
regions.PrimaryKey = new DataColumn[] {regions.Columns["UUID"]};
return regions;
}
@ -168,42 +169,42 @@ namespace OpenSim.Framework.Data.SQLite
if (reader.Read())
{
// Region Main
retval.regionHandle = (ulong)reader["regionHandle"];
retval.regionName = (string)reader["regionName"];
retval.UUID = new LLUUID((string)reader["uuid"]);
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"];
retval.regionRecvKey = (string) reader["regionRecvKey"];
retval.regionSecret = (string) reader["regionSecret"];
retval.regionSendKey = (string) reader["regionSendKey"];
// Region Server
retval.regionDataURI = (string)reader["regionDataURI"];
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.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"]);
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"];
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"];
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"];
retval.regionUserURI = (string) reader["regionUserURI"];
retval.regionUserRecvKey = (string) reader["regionUserRecvKey"];
retval.regionUserSendKey = (string) reader["regionUserSendKey"];
}
else
{
@ -219,12 +220,15 @@ namespace OpenSim.Framework.Data.SQLite
/// <returns>Success?</returns>
public bool insertRow(RegionProfileData profile)
{
string sql = "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
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 +=
"@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>();
@ -271,4 +275,4 @@ namespace OpenSim.Framework.Data.SQLite
return returnval;
}
}
}
}

View File

@ -26,12 +26,8 @@
*
*/
using System;
using System.IO;
using libsecondlife;
using OpenSim.Framework;
using OpenSim.Framework;
using System.Data;
using System.Data.SqlTypes;
using libsecondlife;
using Mono.Data.SqliteClient;
using OpenSim.Framework.Console;
@ -45,30 +41,31 @@ namespace OpenSim.Framework.Data.SQLite
/// <summary>
/// The database manager
/// </summary>
/// <summary>
/// Artificial constructor called upon plugin load
/// </summary>
private const string userSelect = "select * from users";
private DataSet ds;
private SqliteDataAdapter da;
public void Initialise()
{
SqliteConnection conn = new SqliteConnection("URI=file:userprofiles.db,version=3");
TestTables(conn);
ds = new DataSet();
da = new SqliteDataAdapter(new SqliteCommand(userSelect, conn));
lock (ds) {
lock (ds)
{
ds.Tables.Add(createUsersTable());
ds.Tables.Add(createUserAgentsTable());
setupUserCommands(da, conn);
da.Fill(ds.Tables["users"]);
}
return;
}
@ -79,16 +76,21 @@ namespace OpenSim.Framework.Data.SQLite
/// <returns>A user profile</returns>
public UserProfileData GetUserByUUID(LLUUID uuid)
{
lock (ds) {
lock (ds)
{
DataRow row = ds.Tables["users"].Rows.Find(uuid);
if(row != null) {
if (row != null)
{
UserProfileData user = buildUserProfile(row);
row = ds.Tables["useragents"].Rows.Find(uuid);
if(row != null) {
if (row != null)
{
user.currentAgent = buildUserAgent(row);
}
return user;
} else {
}
else
{
return null;
}
}
@ -113,16 +115,21 @@ namespace OpenSim.Framework.Data.SQLite
public UserProfileData GetUserByName(string fname, string lname)
{
string select = "surname = '" + lname + "' and username = '" + fname + "'";
lock (ds) {
lock (ds)
{
DataRow[] rows = ds.Tables["users"].Select(select);
if(rows.Length > 0) {
if (rows.Length > 0)
{
UserProfileData user = buildUserProfile(rows[0]);
DataRow row = ds.Tables["useragents"].Rows.Find(user.UUID);
if(row != null) {
if (row != null)
{
user.currentAgent = buildUserAgent(row);
}
return user;
} else {
}
else
{
return null;
}
}
@ -134,7 +141,7 @@ namespace OpenSim.Framework.Data.SQLite
/// <param name="uuid">The users account ID</param>
/// <returns>A matching users profile</returns>
public UserAgentData GetAgentByUUID(LLUUID uuid)
{
{
try
{
return GetUserByUUID(uuid).currentAgent;
@ -165,7 +172,7 @@ namespace OpenSim.Framework.Data.SQLite
{
try
{
return GetUserByName(fname,lname).currentAgent;
return GetUserByName(fname, lname).currentAgent;
}
catch (Exception)
{
@ -180,8 +187,9 @@ namespace OpenSim.Framework.Data.SQLite
public void AddNewUserProfile(UserProfileData user)
{
DataTable users = ds.Tables["users"];
lock (ds) {
DataRow row = users.Rows.Find(user.UUID);
lock (ds)
{
DataRow row = users.Rows.Find(user.UUID);
if (row == null)
{
row = users.NewRow();
@ -192,10 +200,11 @@ namespace OpenSim.Framework.Data.SQLite
{
fillUserRow(row, user);
}
if(user.currentAgent != null) {
if (user.currentAgent != null)
{
DataTable ua = ds.Tables["useragents"];
row = ua.Rows.Find(user.UUID);
row = ua.Rows.Find(user.UUID);
if (row == null)
{
row = ua.NewRow();
@ -207,12 +216,13 @@ namespace OpenSim.Framework.Data.SQLite
fillUserAgentRow(row, user.currentAgent);
}
}
MainLog.Instance.Verbose("SQLITE", "Syncing user database: " + ds.Tables["users"].Rows.Count + " users stored");
MainLog.Instance.Verbose("SQLITE",
"Syncing user database: " + ds.Tables["users"].Rows.Count + " users stored");
// save changes off to disk
da.Update(ds, "users");
}
}
/// <summary>
/// Creates a new user profile
/// </summary>
@ -220,10 +230,13 @@ namespace OpenSim.Framework.Data.SQLite
/// <returns>True on success, false on error</returns>
public bool UpdateUserProfile(UserProfileData user)
{
try {
try
{
AddNewUserProfile(user);
return true;
} catch (Exception) {
}
catch (Exception)
{
return false;
}
}
@ -279,51 +292,51 @@ namespace OpenSim.Framework.Data.SQLite
{
return "0.1";
}
/***********************************************************************
*
* DataTable creation
*
**********************************************************************/
/***********************************************************************
/***********************************************************************
*
* Database Definition Functions
*
* This should be db agnostic as we define them in ADO.NET terms
*
**********************************************************************/
private DataTable createUsersTable()
{
DataTable users = new DataTable("users");
createCol(users, "UUID", typeof(System.String));
createCol(users, "username", typeof(System.String));
createCol(users, "surname", typeof(System.String));
createCol(users, "passwordHash", typeof(System.String));
createCol(users, "passwordSalt", typeof(System.String));
createCol(users, "UUID", typeof (String));
createCol(users, "username", typeof (String));
createCol(users, "surname", typeof (String));
createCol(users, "passwordHash", typeof (String));
createCol(users, "passwordSalt", typeof (String));
createCol(users, "homeRegionX", typeof(System.Int32));
createCol(users, "homeRegionY", typeof(System.Int32));
createCol(users, "homeLocationX", typeof(System.Double));
createCol(users, "homeLocationY", typeof(System.Double));
createCol(users, "homeLocationZ", typeof(System.Double));
createCol(users, "homeLookAtX", typeof(System.Double));
createCol(users, "homeLookAtY", typeof(System.Double));
createCol(users, "homeLookAtZ", typeof(System.Double));
createCol(users, "created", typeof(System.Int32));
createCol(users, "lastLogin", typeof(System.Int32));
createCol(users, "rootInventoryFolderID", typeof(System.String));
createCol(users, "userInventoryURI", typeof(System.String));
createCol(users, "userAssetURI", typeof(System.String));
createCol(users, "profileCanDoMask", typeof(System.Int32));
createCol(users, "profileWantDoMask", typeof(System.Int32));
createCol(users, "profileAboutText", typeof(System.String));
createCol(users, "profileFirstText", typeof(System.String));
createCol(users, "profileImage", typeof(System.String));
createCol(users, "profileFirstImage", typeof(System.String));
createCol(users, "homeRegionX", typeof (Int32));
createCol(users, "homeRegionY", typeof (Int32));
createCol(users, "homeLocationX", typeof (Double));
createCol(users, "homeLocationY", typeof (Double));
createCol(users, "homeLocationZ", typeof (Double));
createCol(users, "homeLookAtX", typeof (Double));
createCol(users, "homeLookAtY", typeof (Double));
createCol(users, "homeLookAtZ", typeof (Double));
createCol(users, "created", typeof (Int32));
createCol(users, "lastLogin", typeof (Int32));
createCol(users, "rootInventoryFolderID", typeof (String));
createCol(users, "userInventoryURI", typeof (String));
createCol(users, "userAssetURI", typeof (String));
createCol(users, "profileCanDoMask", typeof (Int32));
createCol(users, "profileWantDoMask", typeof (Int32));
createCol(users, "profileAboutText", typeof (String));
createCol(users, "profileFirstText", typeof (String));
createCol(users, "profileImage", typeof (String));
createCol(users, "profileFirstImage", typeof (String));
// Add in contraints
users.PrimaryKey = new DataColumn[] { users.Columns["UUID"] };
users.PrimaryKey = new DataColumn[] {users.Columns["UUID"]};
return users;
}
@ -331,27 +344,27 @@ namespace OpenSim.Framework.Data.SQLite
{
DataTable ua = new DataTable("useragents");
// this is the UUID of the user
createCol(ua, "UUID", typeof(System.String));
createCol(ua, "agentIP", typeof(System.String));
createCol(ua, "agentPort", typeof(System.Int32));
createCol(ua, "agentOnline", typeof(System.Boolean));
createCol(ua, "sessionID", typeof(System.String));
createCol(ua, "secureSessionID", typeof(System.String));
createCol(ua, "regionID", typeof(System.String));
createCol(ua, "loginTime", typeof(System.Int32));
createCol(ua, "logoutTime", typeof(System.Int32));
createCol(ua, "currentRegion", typeof(System.String));
createCol(ua, "currentHandle", typeof(System.Int32));
createCol(ua, "UUID", typeof (String));
createCol(ua, "agentIP", typeof (String));
createCol(ua, "agentPort", typeof (Int32));
createCol(ua, "agentOnline", typeof (Boolean));
createCol(ua, "sessionID", typeof (String));
createCol(ua, "secureSessionID", typeof (String));
createCol(ua, "regionID", typeof (String));
createCol(ua, "loginTime", typeof (Int32));
createCol(ua, "logoutTime", typeof (Int32));
createCol(ua, "currentRegion", typeof (String));
createCol(ua, "currentHandle", typeof (Int32));
// vectors
createCol(ua, "currentPosX", typeof(System.Double));
createCol(ua, "currentPosY", typeof(System.Double));
createCol(ua, "currentPosZ", typeof(System.Double));
createCol(ua, "currentPosX", typeof (Double));
createCol(ua, "currentPosY", typeof (Double));
createCol(ua, "currentPosZ", typeof (Double));
// constraints
ua.PrimaryKey = new DataColumn[] { ua.Columns["UUID"] };
ua.PrimaryKey = new DataColumn[] {ua.Columns["UUID"]};
return ua;
}
/***********************************************************************
*
* Convert between ADO.NET <=> OpenSim Objects
@ -366,35 +379,35 @@ namespace OpenSim.Framework.Data.SQLite
// interesting has to be done to actually get these values
// back out. Not enough time to figure it out yet.
UserProfileData user = new UserProfileData();
user.UUID = new LLUUID((String)row["UUID"]);
user.username = (String)row["username"];
user.surname = (String)row["surname"];
user.passwordHash = (String)row["passwordHash"];
user.passwordSalt = (String)row["passwordSalt"];
user.UUID = new LLUUID((String) row["UUID"]);
user.username = (String) row["username"];
user.surname = (String) row["surname"];
user.passwordHash = (String) row["passwordHash"];
user.passwordSalt = (String) row["passwordSalt"];
user.homeRegionX = Convert.ToUInt32(row["homeRegionX"]);
user.homeRegionY = Convert.ToUInt32(row["homeRegionY"]);
user.homeLocation = new LLVector3(
Convert.ToSingle(row["homeLocationX"]),
Convert.ToSingle(row["homeLocationY"]),
Convert.ToSingle(row["homeLocationZ"])
);
Convert.ToSingle(row["homeLocationX"]),
Convert.ToSingle(row["homeLocationY"]),
Convert.ToSingle(row["homeLocationZ"])
);
user.homeLookAt = new LLVector3(
Convert.ToSingle(row["homeLookAtX"]),
Convert.ToSingle(row["homeLookAtY"]),
Convert.ToSingle(row["homeLookAtZ"])
);
Convert.ToSingle(row["homeLookAtX"]),
Convert.ToSingle(row["homeLookAtY"]),
Convert.ToSingle(row["homeLookAtZ"])
);
user.created = Convert.ToInt32(row["created"]);
user.lastLogin = Convert.ToInt32(row["lastLogin"]);
user.rootInventoryFolderID = new LLUUID((String)row["rootInventoryFolderID"]);
user.userInventoryURI = (String)row["userInventoryURI"];
user.userAssetURI = (String)row["userAssetURI"];
user.rootInventoryFolderID = new LLUUID((String) row["rootInventoryFolderID"]);
user.userInventoryURI = (String) row["userInventoryURI"];
user.userAssetURI = (String) row["userAssetURI"];
user.profileCanDoMask = Convert.ToUInt32(row["profileCanDoMask"]);
user.profileWantDoMask = Convert.ToUInt32(row["profileWantDoMask"]);
user.profileAboutText = (String)row["profileAboutText"];
user.profileFirstText = (String)row["profileFirstText"];
user.profileImage = new LLUUID((String)row["profileImage"]);
user.profileFirstImage = new LLUUID((String)row["profileFirstImage"]);
user.profileAboutText = (String) row["profileAboutText"];
user.profileFirstText = (String) row["profileFirstText"];
user.profileImage = new LLUUID((String) row["profileImage"]);
user.profileFirstImage = new LLUUID((String) row["profileFirstImage"]);
return user;
}
@ -405,8 +418,8 @@ namespace OpenSim.Framework.Data.SQLite
row["surname"] = user.surname;
row["passwordHash"] = user.passwordHash;
row["passwordSalt"] = user.passwordSalt;
row["homeRegionX"] = user.homeRegionX;
row["homeRegionY"] = user.homeRegionY;
row["homeLocationX"] = user.homeLocation.X;
@ -427,10 +440,12 @@ namespace OpenSim.Framework.Data.SQLite
row["profileFirstText"] = user.profileFirstText;
row["profileImage"] = user.profileImage;
row["profileFirstImage"] = user.profileFirstImage;
// ADO.NET doesn't handle NULL very well
foreach (DataColumn col in ds.Tables["users"].Columns) {
if (row[col] == null) {
foreach (DataColumn col in ds.Tables["users"].Columns)
{
if (row[col] == null)
{
row[col] = "";
}
}
@ -439,33 +454,33 @@ namespace OpenSim.Framework.Data.SQLite
private UserAgentData buildUserAgent(DataRow row)
{
UserAgentData ua = new UserAgentData();
ua.UUID = new LLUUID((String)row["UUID"]);
ua.agentIP = (String)row["agentIP"];
ua.UUID = new LLUUID((String) row["UUID"]);
ua.agentIP = (String) row["agentIP"];
ua.agentPort = Convert.ToUInt32(row["agentPort"]);
ua.agentOnline = Convert.ToBoolean(row["agentOnline"]);
ua.sessionID = new LLUUID((String)row["sessionID"]);
ua.secureSessionID = new LLUUID((String)row["secureSessionID"]);
ua.regionID = new LLUUID((String)row["regionID"]);
ua.sessionID = new LLUUID((String) row["sessionID"]);
ua.secureSessionID = new LLUUID((String) row["secureSessionID"]);
ua.regionID = new LLUUID((String) row["regionID"]);
ua.loginTime = Convert.ToInt32(row["loginTime"]);
ua.logoutTime = Convert.ToInt32(row["logoutTime"]);
ua.currentRegion = new LLUUID((String)row["currentRegion"]);
ua.currentRegion = new LLUUID((String) row["currentRegion"]);
ua.currentHandle = Convert.ToUInt32(row["currentHandle"]);
ua.currentPos = new LLVector3(
Convert.ToSingle(row["currentPosX"]),
Convert.ToSingle(row["currentPosY"]),
Convert.ToSingle(row["currentPosZ"])
);
Convert.ToSingle(row["currentPosX"]),
Convert.ToSingle(row["currentPosY"]),
Convert.ToSingle(row["currentPosZ"])
);
return ua;
}
private void fillUserAgentRow(DataRow row, UserAgentData ua)
{
row["UUID"] = ua.UUID;
row["agentIP"] = ua.agentIP;
row["agentPort"] = ua.agentPort;
row["agentOnline"] = ua.agentOnline;
row["sessionID"] = ua.sessionID;
row["agentIP"] = ua.agentIP;
row["agentPort"] = ua.agentPort;
row["agentOnline"] = ua.agentOnline;
row["sessionID"] = ua.sessionID;
row["secureSessionID"] = ua.secureSessionID;
row["regionID"] = ua.regionID;
row["loginTime"] = ua.loginTime;
@ -496,18 +511,18 @@ namespace OpenSim.Framework.Data.SQLite
da.UpdateCommand.Connection = conn;
SqliteCommand delete = new SqliteCommand("delete from users where UUID = :UUID");
delete.Parameters.Add(createSqliteParameter("UUID", typeof(System.String)));
delete.Parameters.Add(createSqliteParameter("UUID", typeof (String)));
delete.Connection = conn;
da.DeleteCommand = delete;
}
private void InitDB(SqliteConnection conn)
{
string createUsers = defineTable(createUsersTable());
SqliteCommand pcmd = new SqliteCommand(createUsers, conn);
conn.Open();
pcmd.ExecuteNonQuery();
conn.Close();
conn.Close();
}
private bool TestTables(SqliteConnection conn)
@ -515,14 +530,16 @@ namespace OpenSim.Framework.Data.SQLite
SqliteCommand cmd = new SqliteCommand(userSelect, conn);
SqliteDataAdapter pDa = new SqliteDataAdapter(cmd);
DataSet tmpDS = new DataSet();
try {
try
{
pDa.Fill(tmpDS, "users");
} catch (Mono.Data.SqliteClient.SqliteSyntaxException) {
}
catch (SqliteSyntaxException)
{
MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating");
InitDB(conn);
}
return true;
}
}
}
}

View File

@ -106,6 +106,5 @@ namespace OpenSim.Framework.Data
DataResponse AddProfile(RegionProfileData profile);
ReservationData GetReservationAtPoint(uint x, uint y);
}
}
}

View File

@ -63,7 +63,9 @@ namespace OpenSim.Framework.Data
/// </summary>
public interface ILogData
{
void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,string logMessage);
void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,
string logMessage);
/// <summary>
/// Initialises the interface
/// </summary>
@ -86,5 +88,4 @@ namespace OpenSim.Framework.Data
/// <returns>A string containing the plugin version</returns>
string getVersion();
}
}
}

View File

@ -27,6 +27,7 @@
*/
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
@ -52,7 +53,8 @@ namespace OpenSim.Framework.Data
RegexOptions.Compiled |
RegexOptions.CultureInvariant);
}
static private Regex _iniKeyValuePatternRegex;
private static Regex _iniKeyValuePatternRegex;
public IniFile(string iniFileName)
{
@ -62,7 +64,7 @@ namespace OpenSim.Framework.Data
public string ParseFileReadValue(string key)
{
using (StreamReader reader =
new StreamReader(_iniFileName))
new StreamReader(_iniFileName))
{
do
{
@ -72,18 +74,16 @@ namespace OpenSim.Framework.Data
if (match.Success)
{
string currentKey =
match.Groups["Key"].Value as string;
match.Groups["Key"].Value as string;
if (currentKey != null &&
currentKey.Trim().CompareTo(key) == 0)
currentKey.Trim().CompareTo(key) == 0)
{
string value =
match.Groups["Value"].Value as string;
match.Groups["Value"].Value as string;
return value;
}
}
}
while (reader.Peek() != -1);
} while (reader.Peek() != -1);
}
return null;
}
@ -91,6 +91,8 @@ namespace OpenSim.Framework.Data
public string IniFileName
{
get { return _iniFileName; }
} private string _iniFileName;
}
private string _iniFileName;
}
}
}

View File

@ -1,24 +1,28 @@
using System.Reflection;
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("")]
[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)]
[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")]
[assembly : Guid("3a711c34-b0c0-4264-b0fe-f366eabf9d7b")]
// Version information for an assembly consists of the following four values:
//
@ -29,5 +33,6 @@ using System.Runtime.InteropServices;
//
// 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")]
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]

View File

@ -25,11 +25,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using libsecondlife;
using Nwc.XmlRpc;
using System;
using System.Collections;
using libsecondlife;
using Nwc.XmlRpc;
namespace OpenSim.Framework.Data
{
@ -57,6 +57,7 @@ namespace OpenSim.Framework.Data
/// Coordinates of the region
/// </summary>
public uint regionLocX;
public uint regionLocY;
public uint regionLocZ; // Reserved (round-robin, layers, etc)
@ -65,6 +66,7 @@ namespace OpenSim.Framework.Data
/// </summary>
/// <remarks>Not very secure, needs improvement.</remarks>
public string regionSendKey = "";
public string regionRecvKey = "";
public string regionSecret = "";
@ -77,6 +79,7 @@ namespace OpenSim.Framework.Data
/// Information about the server that the region is currently hosted on
/// </summary>
public string serverIP = "";
public uint serverPort;
public string serverURI = "";
@ -88,6 +91,7 @@ namespace OpenSim.Framework.Data
/// 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;
@ -102,6 +106,7 @@ namespace OpenSim.Framework.Data
/// Region Asset Details
/// </summary>
public string regionAssetURI = "";
public string regionAssetSendKey = "";
public string regionAssetRecvKey = "";
@ -109,6 +114,7 @@ namespace OpenSim.Framework.Data
/// Region Userserver Details
/// </summary>
public string regionUserURI = "";
public string regionUserSendKey = "";
public string regionUserRecvKey = "";
@ -124,7 +130,8 @@ namespace OpenSim.Framework.Data
/// <param name="gridserver_url"></param>
/// <param name="?"></param>
/// <returns></returns>
public RegionProfileData RequestSimProfileData(LLUUID region_uuid, string gridserver_url, string gridserver_sendkey, string gridserver_recvkey)
public RegionProfileData RequestSimProfileData(LLUUID region_uuid, string gridserver_url,
string gridserver_sendkey, string gridserver_recvkey)
{
Hashtable requestData = new Hashtable();
requestData["region_uuid"] = region_uuid.UUID.ToString();
@ -134,7 +141,7 @@ namespace OpenSim.Framework.Data
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
Hashtable responseData = (Hashtable)GridResp.Value;
Hashtable responseData = (Hashtable) GridResp.Value;
if (responseData.ContainsKey("error"))
{
@ -142,21 +149,23 @@ namespace OpenSim.Framework.Data
}
RegionProfileData simData = new RegionProfileData();
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.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"];
simData.UUID = new LLUUID((string) responseData["region_UUID"]);
simData.regionName = (string) responseData["region_name"];
return simData;
return simData;
}
public RegionProfileData RequestSimProfileData(ulong region_handle, string gridserver_url, string gridserver_sendkey, string gridserver_recvkey)
public RegionProfileData RequestSimProfileData(ulong region_handle, string gridserver_url,
string gridserver_sendkey, string gridserver_recvkey)
{
Hashtable requestData = new Hashtable();
requestData["region_handle"] = region_handle.ToString();
@ -166,7 +175,7 @@ namespace OpenSim.Framework.Data
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
Hashtable responseData = (Hashtable)GridResp.Value;
Hashtable responseData = (Hashtable) GridResp.Value;
if (responseData.ContainsKey("error"))
{
@ -174,19 +183,19 @@ namespace OpenSim.Framework.Data
}
RegionProfileData simData = new RegionProfileData();
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.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"];
simData.UUID = new LLUUID((string) responseData["region_UUID"]);
simData.regionName = (string) responseData["region_name"];
return simData;
return simData;
}
}
}
}

View File

@ -36,7 +36,7 @@ namespace OpenSim.Framework.Data
public int reservationMinY = 0;
public int reservationMaxX = 65536;
public int reservationMaxY = 65536;
public string reservationName = "";
public string reservationCompany = "";
public bool status = true;
@ -44,4 +44,4 @@ namespace OpenSim.Framework.Data
public string gridSendKey = "";
public string gridRecvKey = "";
}
}
}

View File

@ -27,7 +27,6 @@
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework
{
@ -37,15 +36,15 @@ namespace OpenSim.Framework
// permissions rather than just the first. Deny permissions will
// override all others.
#region ACL Core Class
/// <summary>
/// Access Control List Engine
/// </summary>
public class ACL
{
Dictionary<string, Role> Roles = new Dictionary<string, Role>();
Dictionary<string, Resource> Resources = new Dictionary<string, Resource>();
private Dictionary<string, Role> Roles = new Dictionary<string, Role>();
private Dictionary<string, Resource> Resources = new Dictionary<string, Resource>();
public ACL AddRole(Role role)
{
@ -114,9 +113,11 @@ namespace OpenSim.Framework
return this;
}
}
#endregion
#region Exceptions
/// <summary>
/// Thrown when an ACL attempts to add a duplicate role.
/// </summary>
@ -139,6 +140,7 @@ namespace OpenSim.Framework
return "This ACL already contains a role called '" + m_role.Name + "'.";
}
}
#endregion
#region Roles and Resources
@ -146,7 +148,12 @@ namespace OpenSim.Framework
/// <summary>
/// Does this Role have permission to access a specified Resource?
/// </summary>
public enum Permission { Deny, None, Allow };
public enum Permission
{
Deny,
None,
Allow
} ;
/// <summary>
/// A role class, for use with Users or Groups
@ -227,7 +234,7 @@ namespace OpenSim.Framework
#region Tests
class ACLTester
internal class ACLTester
{
public ACLTester()
{
@ -249,9 +256,8 @@ namespace OpenSim.Framework
acl.GrantPermission("Guests", "CanBuild");
acl.HasPermission("JoeGuest", "CanBuild");
}
}
#endregion
}
}

View File

@ -27,8 +27,6 @@
*/
using System.Collections.Generic;
using libsecondlife;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework;
namespace OpenSim.Framework
{
@ -38,15 +36,14 @@ namespace OpenSim.Framework
public AgentCircuitManager()
{
}
public virtual AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode)
{
AgentCircuitData validcircuit = null;
if (this.AgentCircuits.ContainsKey(circuitcode))
if (AgentCircuits.ContainsKey(circuitcode))
{
validcircuit = this.AgentCircuits[circuitcode];
validcircuit = AgentCircuits[circuitcode];
}
AuthenticateResponse user = new AuthenticateResponse();
if (validcircuit == null)
@ -79,50 +76,50 @@ namespace OpenSim.Framework
public virtual void AddNewCircuit(uint circuitCode, AgentCircuitData agentData)
{
if (this.AgentCircuits.ContainsKey(circuitCode))
if (AgentCircuits.ContainsKey(circuitCode))
{
this.AgentCircuits[circuitCode] = agentData;
AgentCircuits[circuitCode] = agentData;
}
else
{
this.AgentCircuits.Add(circuitCode, agentData);
AgentCircuits.Add(circuitCode, agentData);
}
}
public LLVector3 GetPosition(uint circuitCode)
{
LLVector3 vec = new LLVector3();
if (this.AgentCircuits.ContainsKey(circuitCode))
if (AgentCircuits.ContainsKey(circuitCode))
{
vec = this.AgentCircuits[circuitCode].startpos;
vec = AgentCircuits[circuitCode].startpos;
}
return vec;
}
public void UpdateAgentData(AgentCircuitData agentData)
{
if (this.AgentCircuits.ContainsKey((uint)agentData.circuitcode))
if (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);
AgentCircuits[(uint) agentData.circuitcode].firstname = agentData.firstname;
AgentCircuits[(uint) agentData.circuitcode].lastname = agentData.lastname;
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))
if (AgentCircuits.ContainsKey(circuitcode))
{
this.AgentCircuits[circuitcode].child = childstatus;
AgentCircuits[circuitcode].child = childstatus;
}
}
public bool GetAgentChildStatus(uint circuitcode)
{
if (this.AgentCircuits.ContainsKey(circuitcode))
if (AgentCircuits.ContainsKey(circuitcode))
{
return this.AgentCircuits[circuitcode].child;
return AgentCircuits[circuitcode].child;
}
return false;
}

View File

@ -25,15 +25,18 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using libsecondlife;
using System;
using libsecondlife;
namespace OpenSim.Framework
{
[Serializable]
public class AgentCircuitData
{
public AgentCircuitData() { }
public AgentCircuitData()
{
}
public LLUUID AgentID;
public LLUUID SessionID;
public LLUUID SecureSessionID;
@ -44,6 +47,6 @@ namespace OpenSim.Framework
public bool child;
public LLUUID InventoryFolder;
public LLUUID BaseFolder;
public string CapsPath = "";
public string CapsPath = "";
}
}
}

View File

@ -28,8 +28,6 @@
using System.Collections.Generic;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim.Framework;
namespace OpenSim.Framework
{
@ -39,7 +37,7 @@ namespace OpenSim.Framework
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 int LastCached; //maybe used by opensim app, time this was last stored/compared to user server
public LLUUID AgentID;
public AvatarWearable[] Wearables;
@ -47,12 +45,12 @@ namespace OpenSim.Framework
{
InventoryFolders = new Dictionary<LLUUID, InventoryFolder>();
InventoryItems = new Dictionary<LLUUID, InventoryItem>();
this.Initialise();
Initialise();
}
public virtual void Initialise()
{
Wearables = new AvatarWearable[13];
Wearables = new AvatarWearable[13];
for (int i = 0; i < 13; i++)
{
Wearables[i] = new AvatarWearable();
@ -63,27 +61,27 @@ namespace OpenSim.Framework
{
InventoryFolder Folder = new InventoryFolder();
Folder.FolderID = folderID;
Folder.OwnerID = this.AgentID;
Folder.OwnerID = AgentID;
Folder.DefaultType = type;
this.InventoryFolders.Add(Folder.FolderID, Folder);
InventoryFolders.Add(Folder.FolderID, Folder);
return (true);
}
public void CreateRootFolder(LLUUID newAgentID, bool createTextures)
{
this.AgentID = newAgentID;
AgentID = newAgentID;
InventoryRoot = new InventoryFolder();
InventoryRoot.FolderID = LLUUID.Random();
InventoryRoot.ParentID = new LLUUID();
InventoryRoot.Version = 1;
InventoryRoot.DefaultType = 8;
InventoryRoot.OwnerID = this.AgentID;
InventoryRoot.OwnerID = AgentID;
InventoryRoot.FolderName = "My Inventory";
InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot);
InventoryRoot.OwnerID = this.AgentID;
InventoryRoot.OwnerID = AgentID;
if (createTextures)
{
this.CreateNewFolder(LLUUID.Random(), 0, "Textures", InventoryRoot.FolderID);
CreateNewFolder(LLUUID.Random(), 0, "Textures", InventoryRoot.FolderID);
}
}
@ -91,32 +89,32 @@ namespace OpenSim.Framework
{
InventoryFolder Folder = new InventoryFolder();
Folder.FolderID = folderID;
Folder.OwnerID = this.AgentID;
Folder.OwnerID = AgentID;
Folder.DefaultType = type;
Folder.FolderName = folderName;
this.InventoryFolders.Add(Folder.FolderID, Folder);
InventoryFolders.Add(Folder.FolderID, Folder);
return (true);
}
public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parentID)
{
if (!this.InventoryFolders.ContainsKey(folderID))
if (!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.OwnerID = AgentID;
Folder.DefaultType = type;
Folder.FolderName = folderName;
Folder.ParentID = parentID;
this.InventoryFolders.Add(Folder.FolderID, Folder);
InventoryFolders.Add(Folder.FolderID, Folder);
}
return (true);
}
public bool HasFolder(LLUUID folderID)
{
if (this.InventoryFolders.ContainsKey(folderID))
if (InventoryFolders.ContainsKey(folderID))
{
return true;
}
@ -125,7 +123,7 @@ namespace OpenSim.Framework
public LLUUID GetFolderID(string folderName)
{
foreach (InventoryFolder inv in this.InventoryFolders.Values)
foreach (InventoryFolder inv in InventoryFolders.Values)
{
if (inv.FolderName == folderName)
{
@ -137,11 +135,12 @@ namespace OpenSim.Framework
public bool UpdateItemAsset(LLUUID itemID, AssetBase asset)
{
if(this.InventoryItems.ContainsKey(itemID))
if (InventoryItems.ContainsKey(itemID))
{
InventoryItem Item = this.InventoryItems[itemID];
InventoryItem Item = InventoryItems[itemID];
Item.AssetID = asset.FullID;
System.Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated() + " so it now is set to asset " + asset.FullID.ToStringHyphenated());
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;
@ -150,10 +149,10 @@ namespace OpenSim.Framework
public bool UpdateItemDetails(LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet)
{
System.Console.WriteLine("updating inventory item details");
if (this.InventoryItems.ContainsKey(itemID))
if (InventoryItems.ContainsKey(itemID))
{
System.Console.WriteLine("changing name to "+ Util.FieldToString(packet.Name));
InventoryItem Item = this.InventoryItems[itemID];
System.Console.WriteLine("changing name to " + Util.FieldToString(packet.Name));
InventoryItem Item = 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
@ -163,7 +162,7 @@ namespace OpenSim.Framework
public LLUUID AddToInventory(LLUUID folderID, AssetBase asset)
{
if (this.InventoryFolders.ContainsKey(folderID))
if (InventoryFolders.ContainsKey(folderID))
{
LLUUID NewItemID = LLUUID.Random();
@ -176,7 +175,7 @@ namespace OpenSim.Framework
Item.Name = asset.Name;
Item.Description = asset.Description;
Item.InvType = asset.InvType;
this.InventoryItems.Add(Item.ItemID, Item);
InventoryItems.Add(Item.ItemID, Item);
InventoryFolder Folder = InventoryFolders[Item.FolderID];
Folder.Items.Add(Item);
return (Item.ItemID);
@ -190,10 +189,10 @@ namespace OpenSim.Framework
public bool DeleteFromInventory(LLUUID itemID)
{
bool res = false;
if (this.InventoryItems.ContainsKey(itemID))
if (InventoryItems.ContainsKey(itemID))
{
InventoryItem item = this.InventoryItems[itemID];
this.InventoryItems.Remove(itemID);
InventoryItem item = InventoryItems[itemID];
InventoryItems.Remove(itemID);
foreach (InventoryFolder fold in InventoryFolders.Values)
{
if (fold.Items.Contains(item))
@ -203,7 +202,6 @@ namespace OpenSim.Framework
}
}
res = true;
}
return res;
}
@ -225,7 +223,6 @@ namespace OpenSim.Framework
Items = new List<InventoryItem>();
//Subfolders = new List<InventoryFolder>();
}
}
public class InventoryItem
@ -237,12 +234,12 @@ namespace OpenSim.Framework
public LLUUID CreatorID;
public sbyte InvType;
public sbyte Type;
public string Name ="";
public string Name = "";
public string Description;
public InventoryItem()
{
this.CreatorID = LLUUID.Zero;
CreatorID = LLUUID.Zero;
}
public string ExportString()
@ -251,11 +248,11 @@ namespace OpenSim.Framework
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\tparent_id\t" + ItemID.ToString() + "\n";
result += "\t\ttype\t" + typ + "\n";
result += "\t\tname\t" + Name + "|\n";
result += "\t}\n";
return result;
}
}
}
}

View File

@ -36,10 +36,9 @@ namespace OpenSim.Framework
public AvatarWearable()
{
}
public AvatarWearable( LLUUID itemId, LLUUID assetId )
public AvatarWearable(LLUUID itemId, LLUUID assetId)
{
AssetID = assetId;
ItemID = itemId;
@ -69,4 +68,4 @@ namespace OpenSim.Framework
}
}
}
}
}

View File

@ -44,7 +44,6 @@ namespace OpenSim.Framework
public AssetBase()
{
}
public AssetBase(LLUUID assetId, string name)
@ -53,4 +52,4 @@ namespace OpenSim.Framework
Name = name;
}
}
}
}

View File

@ -26,10 +26,6 @@
*
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework
{
/// <summary>
@ -48,18 +44,22 @@ namespace OpenSim.Framework
public AssetConfig(string description, string filename)
{
configMember = new ConfigurationMember(filename, description, this.loadConfigurationOptions, this.handleIncomingConfiguration);
configMember =
new ConfigurationMember(filename, description, loadConfigurationOptions, 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_startup_message",
ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
"Default Startup Message", "Welcome to OGS", false);
configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false);
configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Http Listener port", DefaultHttpPort.ToString(), false);
configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false);
configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
"Http Listener port", DefaultHttpPort.ToString(), false);
}
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
@ -67,17 +67,17 @@ namespace OpenSim.Framework
switch (configuration_key)
{
case "default_startup_message":
this.DefaultStartupMsg = (string)configuration_result;
DefaultStartupMsg = (string) configuration_result;
break;
case "database_provider":
this.DatabaseProvider = (string)configuration_result;
DatabaseProvider = (string) configuration_result;
break;
case "http_port":
HttpPort = (uint)configuration_result;
HttpPort = (uint) configuration_result;
break;
}
return true;
}
}
}
}

View File

@ -38,22 +38,22 @@ namespace OpenSim.Framework
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;
Data = a.Data;
FullID = a.FullID;
Type = a.Type;
InvType = a.InvType;
Name = a.Name;
Description = a.Description;
InternData();
}
private void InternData()
{
string temp = Encoding.UTF8.GetString(Data).Trim();
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);
}
}
}
}

View File

@ -29,19 +29,20 @@ using libsecondlife;
namespace OpenSim.Framework
{
public class AssetStorage
{
public class AssetStorage
{
public AssetStorage()
{
}
public AssetStorage() {
}
public AssetStorage(LLUUID assetUUID)
{
UUID = assetUUID;
}
public AssetStorage(LLUUID assetUUID) {
UUID=assetUUID;
}
public byte[] Data;
public sbyte Type;
public string Name;
public LLUUID UUID;
}
}
public byte[] Data;
public sbyte Type;
public string Name;
public LLUUID UUID;
}
}

View File

@ -25,8 +25,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using OpenSim.Framework;
namespace OpenSim.Framework
{
public class AuthenticateResponse
@ -36,8 +34,6 @@ namespace OpenSim.Framework
public AuthenticateResponse()
{
}
}
}
}

View File

@ -55,4 +55,4 @@ namespace OpenSim.Framework
}
}
}
}
}

View File

@ -26,16 +26,14 @@
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife.Packets;
using OpenSim.Framework.Interfaces;
using libsecondlife;
using libsecondlife.Packets;
namespace OpenSim.Framework
{
public delegate void ForEachClientDelegate(IClientAPI client);
public class ClientManager
{
private Dictionary<uint, IClientAPI> m_clients;
@ -63,7 +61,7 @@ namespace OpenSim.Framework
m_clients.Add(id, client);
}
public void InPacket(uint circuitCode, libsecondlife.Packets.Packet packet)
public void InPacket(uint circuitCode, Packet packet)
{
IClientAPI client;
@ -83,10 +81,10 @@ namespace OpenSim.Framework
}
}
public void CloseAllCircuits( LLUUID agentId )
public void CloseAllCircuits(LLUUID agentId)
{
uint[] circuits = GetAllCircuits(agentId);
foreach (uint circuit in circuits )
foreach (uint circuit in circuits)
{
IClientAPI client;
if (m_clients.TryGetValue(circuit, out client))
@ -94,7 +92,7 @@ namespace OpenSim.Framework
Remove(circuit);
client.Close();
}
}
}
}
private uint[] GetAllCircuits(LLUUID agentId)
@ -103,16 +101,16 @@ namespace OpenSim.Framework
foreach (KeyValuePair<uint, IClientAPI> pair in m_clients)
{
if( pair.Value.AgentId == agentId )
if (pair.Value.AgentId == agentId)
{
circuits.Add( pair.Key );
circuits.Add(pair.Key);
}
}
return circuits.ToArray();
}
public void ViewerEffectHandler(IClientAPI sender, ViewerEffectPacket.EffectBlock[] effectBlock)
{
ViewerEffectPacket packet = new ViewerEffectPacket();
@ -134,4 +132,4 @@ namespace OpenSim.Framework
return m_clients.TryGetValue(circuitId, out user);
}
}
}
}

View File

@ -27,22 +27,19 @@
*/
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 System.Globalization;
using System.Net;
using System.Reflection;
using libsecondlife;
using OpenSim.Framework.Console;
namespace OpenSim.Framework
{
public class ConfigurationMember
{
public delegate bool ConfigurationOptionResult(string configuration_key, object configuration_result);
public delegate void ConfigurationOptionsLoad();
private List<ConfigurationOption> configurationOptions = new List<ConfigurationOption>();
@ -53,22 +50,26 @@ namespace OpenSim.Framework
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)
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;
configurationFilename = configuration_filename;
configurationDescription = configuration_description;
loadFunction = load_function;
resultFunction = result_function;
}
public void setConfigurationFilename(string filename)
{
configurationFilename = filename;
}
public void setConfigurationDescription(string desc)
{
configurationDescription = desc;
@ -83,7 +84,11 @@ namespace OpenSim.Framework
{
configurationPluginFilename = dll_filename;
}
public void addConfigurationOption(string configuration_key, ConfigurationOption.ConfigurationTypes configuration_type, string configuration_question, string configuration_default, bool use_default_no_prompt)
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;
@ -92,7 +97,8 @@ namespace OpenSim.Framework
configOption.configurationType = configuration_type;
configOption.configurationUseDefaultNoPrompt = use_default_no_prompt;
if ((configuration_key != "" && configuration_question != "") || (configuration_key != "" && use_default_no_prompt))
if ((configuration_key != "" && configuration_question != "") ||
(configuration_key != "" && use_default_no_prompt))
{
if (!configurationOptions.Contains(configOption))
{
@ -101,32 +107,37 @@ namespace OpenSim.Framework
}
else
{
MainLog.Instance.Notice("Required fields for adding a configuration option is invalid. Will not add this option (" + configuration_key + ")");
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);
configurationPlugin = LoadConfigDll(configurationPluginFilename);
configurationOptions.Clear();
if(loadFunction == null)
if (loadFunction == null)
{
MainLog.Instance.Error("Load Function for '" + this.configurationDescription + "' is null. Refusing to run configuration.");
MainLog.Instance.Error("Load Function for '" + configurationDescription +
"' is null. Refusing to run configuration.");
return;
}
if(resultFunction == null)
if (resultFunction == null)
{
MainLog.Instance.Error("Result Function for '" + this.configurationDescription + "' is null. Refusing to run configuration.");
MainLog.Instance.Error("Result Function for '" + configurationDescription +
"' is null. Refusing to run configuration.");
return;
}
MainLog.Instance.Verbose("Calling Configuration Load Function...");
this.loadFunction();
loadFunction();
if(configurationOptions.Count <= 0)
if (configurationOptions.Count <= 0)
{
MainLog.Instance.Error("No configuration options were specified for '" + this.configurationOptions + "'. Refusing to continue configuration.");
MainLog.Instance.Error("No configuration options were specified for '" + configurationOptions +
"'. Refusing to continue configuration.");
return;
}
@ -157,7 +168,6 @@ namespace OpenSim.Framework
bool ignoreNextFromConfig = false;
while (convertSuccess == false)
{
string console_result = "";
string attribute = null;
if (useFile)
@ -180,16 +190,20 @@ namespace OpenSim.Framework
}
else
{
if (configurationDescription.Trim() != "")
{
console_result = MainLog.Instance.CmdPrompt(configurationDescription + ": " + configOption.configurationQuestion, configOption.configurationDefault);
console_result =
MainLog.Instance.CmdPrompt(
configurationDescription + ": " + configOption.configurationQuestion,
configOption.configurationDefault);
}
else
{
console_result = MainLog.Instance.CmdPrompt(configOption.configurationQuestion, configOption.configurationDefault);
console_result =
MainLog.Instance.CmdPrompt(configOption.configurationQuestion,
configOption.configurationDefault);
}
}
}
}
else
{
@ -252,7 +266,6 @@ namespace OpenSim.Framework
{
convertSuccess = true;
return_result = intResult;
}
errorMessage = "a signed 32 bit integer (int)";
break;
@ -307,7 +320,6 @@ namespace OpenSim.Framework
{
convertSuccess = true;
return_result = uintResult;
}
errorMessage = "an unsigned 32 bit integer (uint)";
break;
@ -322,7 +334,9 @@ namespace OpenSim.Framework
break;
case ConfigurationOption.ConfigurationTypes.TYPE_FLOAT:
float floatResult;
if (float.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, out floatResult))
if (
float.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo,
out floatResult))
{
convertSuccess = true;
return_result = floatResult;
@ -331,7 +345,9 @@ namespace OpenSim.Framework
break;
case ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE:
double doubleResult;
if (Double.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, out doubleResult))
if (
Double.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo,
out doubleResult))
{
convertSuccess = true;
return_result = doubleResult;
@ -348,9 +364,10 @@ namespace OpenSim.Framework
}
if (!this.resultFunction(configOption.configurationKey, return_result))
if (!resultFunction(configOption.configurationKey, return_result))
{
Console.MainLog.Instance.Notice("The handler for the last configuration option denied that input, please try again.");
MainLog.Instance.Notice(
"The handler for the last configuration option denied that input, please try again.");
convertSuccess = false;
ignoreNextFromConfig = true;
}
@ -359,19 +376,27 @@ namespace OpenSim.Framework
{
if (configOption.configurationUseDefaultNoPrompt)
{
MainLog.Instance.Error("CONFIG", string.Format("[{3}]:[{1}] is not valid default for parameter [{0}].\nThe configuration result must be parsable to {2}.\n", configOption.configurationKey, console_result, errorMessage, configurationFilename));
MainLog.Instance.Error("CONFIG",
string.Format(
"[{3}]:[{1}] is not valid default for parameter [{0}].\nThe configuration result must be parsable to {2}.\n",
configOption.configurationKey, console_result, errorMessage,
configurationFilename));
convertSuccess = true;
}
else
{
MainLog.Instance.Warn("CONFIG", string.Format("[{3}]:[{1}] is not a valid value [{0}].\nThe configuration result must be parsable to {2}.\n", configOption.configurationKey, console_result, errorMessage, configurationFilename));
MainLog.Instance.Warn("CONFIG",
string.Format(
"[{3}]:[{1}] is not a valid value [{0}].\nThe configuration result must be parsable to {2}.\n",
configOption.configurationKey, console_result, errorMessage,
configurationFilename));
ignoreNextFromConfig = true;
}
}
}
}
if(useFile)
if (useFile)
{
configurationPlugin.Commit();
configurationPlugin.Close();
@ -393,7 +418,8 @@ namespace OpenSim.Framework
if (typeInterface != null)
{
plug = (IGenericConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
plug =
(IGenericConfig) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
}
}
}
@ -405,10 +431,10 @@ namespace OpenSim.Framework
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();
configurationPlugin.LoadData();
configurationPlugin.SetAttribute(configuration_key, configuration_value);
configurationPlugin.Commit();
configurationPlugin.Close();
}
}
}
}

View File

@ -26,10 +26,6 @@
*
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework
{
public class ConfigurationOption
@ -40,7 +36,7 @@ namespace OpenSim.Framework
TYPE_STRING_NOT_EMPTY,
TYPE_UINT16,
TYPE_UINT32,
TYPE_UINT64,
TYPE_UINT64,
TYPE_INT16,
TYPE_INT32,
TYPE_INT64,
@ -52,7 +48,7 @@ namespace OpenSim.Framework
TYPE_LLVECTOR3,
TYPE_FLOAT,
TYPE_DOUBLE
};
} ;
public string configurationKey = "";
public string configurationQuestion = "";
@ -61,4 +57,4 @@ namespace OpenSim.Framework
public ConfigurationTypes configurationType = ConfigurationTypes.TYPE_STRING;
public bool configurationUseDefaultNoPrompt = false;
}
}
}

View File

@ -27,31 +27,23 @@
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Threading;
namespace OpenSim.Framework
{
public class Culture
{
private static readonly CultureInfo m_cultureInfo = new System.Globalization.CultureInfo("en-US", true);
private static readonly CultureInfo m_cultureInfo = new CultureInfo("en-US", true);
public static NumberFormatInfo NumberFormatInfo
{
get
{
return m_cultureInfo.NumberFormat;
}
get { return m_cultureInfo.NumberFormat; }
}
public static IFormatProvider FormatProvider
{
get
{
return m_cultureInfo;
}
get { return m_cultureInfo; }
}
public static void SetCurrentCulture()
@ -59,4 +51,4 @@ namespace OpenSim.Framework
Thread.CurrentThread.CurrentCulture = m_cultureInfo;
}
}
}
}

View File

@ -25,24 +25,20 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.IO;
using libsecondlife;
using OpenSim.Framework;
using System.Globalization;
namespace OpenSim.Framework
{
public class EstateSettings
{
//Settings to this island
private float m_billableFactor;
public float billableFactor
{
get
{
return m_billableFactor;
}
get { return m_billableFactor; }
set
{
m_billableFactor = value;
@ -52,12 +48,10 @@ namespace OpenSim.Framework
private uint m_estateID;
public uint estateID
{
get
{
return m_estateID;
}
get { return m_estateID; }
set
{
m_estateID = value;
@ -67,12 +61,10 @@ namespace OpenSim.Framework
private uint m_parentEstateID;
public uint parentEstateID
{
get
{
return m_parentEstateID;
}
get { return m_parentEstateID; }
set
{
m_parentEstateID = value;
@ -81,12 +73,10 @@ namespace OpenSim.Framework
}
private byte m_maxAgents;
public byte maxAgents
{
get
{
return m_maxAgents;
}
get { return m_maxAgents; }
set
{
m_maxAgents = value;
@ -95,12 +85,10 @@ namespace OpenSim.Framework
}
private float m_objectBonusFactor;
public float objectBonusFactor
{
get
{
return m_objectBonusFactor;
}
get { return m_objectBonusFactor; }
set
{
m_objectBonusFactor = value;
@ -109,12 +97,10 @@ namespace OpenSim.Framework
}
private int m_redirectGridX;
public int redirectGridX
{
get
{
return m_redirectGridX;
}
get { return m_redirectGridX; }
set
{
m_redirectGridX = value;
@ -123,12 +109,10 @@ namespace OpenSim.Framework
}
private int m_redirectGridY;
public int redirectGridY
{
get
{
return m_redirectGridY;
}
get { return m_redirectGridY; }
set
{
m_redirectGridY = value;
@ -137,12 +121,10 @@ namespace OpenSim.Framework
}
private Simulator.RegionFlags m_regionFlags;
public Simulator.RegionFlags regionFlags
{
get
{
return m_regionFlags;
}
get { return m_regionFlags; }
set
{
m_regionFlags = value;
@ -152,12 +134,10 @@ namespace OpenSim.Framework
private Simulator.SimAccess m_simAccess;
public Simulator.SimAccess simAccess
{
get
{
return m_simAccess;
}
get { return m_simAccess; }
set
{
m_simAccess = value;
@ -166,12 +146,10 @@ namespace OpenSim.Framework
}
private float m_sunHour;
public float sunHour
{
get
{
return m_sunHour;
}
get { return m_sunHour; }
set
{
m_sunHour = value;
@ -180,12 +158,10 @@ namespace OpenSim.Framework
}
private float m_terrainRaiseLimit;
public float terrainRaiseLimit
{
get
{
return m_terrainRaiseLimit;
}
get { return m_terrainRaiseLimit; }
set
{
m_terrainRaiseLimit = value;
@ -194,12 +170,10 @@ namespace OpenSim.Framework
}
private float m_terrainLowerLimit;
public float terrainLowerLimit
{
get
{
return m_terrainLowerLimit;
}
get { return m_terrainLowerLimit; }
set
{
m_terrainLowerLimit = value;
@ -208,12 +182,10 @@ namespace OpenSim.Framework
}
private bool m_useFixedSun;
public bool useFixedSun
{
get
{
return m_useFixedSun;
}
get { return m_useFixedSun; }
set
{
m_useFixedSun = value;
@ -223,12 +195,10 @@ namespace OpenSim.Framework
private int m_pricePerMeter;
public int pricePerMeter
{
get
{
return m_pricePerMeter;
}
get { return m_pricePerMeter; }
set
{
m_pricePerMeter = value;
@ -238,12 +208,10 @@ namespace OpenSim.Framework
private ushort m_regionWaterHeight;
public ushort regionWaterHeight
{
get
{
return m_regionWaterHeight;
}
get { return m_regionWaterHeight; }
set
{
m_regionWaterHeight = value;
@ -253,12 +221,10 @@ namespace OpenSim.Framework
private bool m_regionAllowTerraform;
public bool regionAllowTerraform
{
get
{
return m_regionAllowTerraform;
}
get { return m_regionAllowTerraform; }
set
{
m_regionAllowTerraform = value;
@ -266,16 +232,14 @@ namespace OpenSim.Framework
}
}
// Region Information
// Low resolution 'base' textures. No longer used.
private LLUUID m_terrainBase0;
public LLUUID terrainBase0
{
get
{
return m_terrainBase0;
}
get { return m_terrainBase0; }
set
{
m_terrainBase0 = value;
@ -284,12 +248,10 @@ namespace OpenSim.Framework
}
private LLUUID m_terrainBase1;
public LLUUID terrainBase1
{
get
{
return m_terrainBase1;
}
get { return m_terrainBase1; }
set
{
m_terrainBase1 = value;
@ -298,12 +260,10 @@ namespace OpenSim.Framework
}
private LLUUID m_terrainBase2;
public LLUUID terrainBase2
{
get
{
return m_terrainBase2;
}
get { return m_terrainBase2; }
set
{
m_terrainBase2 = value;
@ -312,12 +272,10 @@ namespace OpenSim.Framework
}
private LLUUID m_terrainBase3;
public LLUUID terrainBase3
{
get
{
return m_terrainBase3;
}
get { return m_terrainBase3; }
set
{
m_terrainBase3 = value;
@ -328,53 +286,46 @@ namespace OpenSim.Framework
// Higher resolution terrain textures
private LLUUID m_terrainDetail0;
public LLUUID terrainDetail0
{
get
{
return m_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;
}
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;
}
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;
}
get { return m_terrainDetail3; }
set
{
m_terrainDetail3 = value;
@ -384,12 +335,10 @@ namespace OpenSim.Framework
// First quad - each point is bilinearly interpolated at each meter of terrain
private float m_terrainStartHeight0;
public float terrainStartHeight0
{
get
{
return m_terrainStartHeight0;
}
get { return m_terrainStartHeight0; }
set
{
m_terrainStartHeight0 = value;
@ -399,12 +348,10 @@ namespace OpenSim.Framework
private float m_terrainStartHeight1;
public float terrainStartHeight1
{
get
{
return m_terrainStartHeight1;
}
get { return m_terrainStartHeight1; }
set
{
m_terrainStartHeight1 = value;
@ -413,12 +360,10 @@ namespace OpenSim.Framework
}
private float m_terrainStartHeight2;
public float terrainStartHeight2
{
get
{
return m_terrainStartHeight2;
}
get { return m_terrainStartHeight2; }
set
{
m_terrainStartHeight2 = value;
@ -427,28 +372,25 @@ namespace OpenSim.Framework
}
private float m_terrainStartHeight3;
public float terrainStartHeight3
{
get
{
return m_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;
}
get { return m_terrainHeightRange0; }
set
{
m_terrainHeightRange0 = value;
@ -457,12 +399,10 @@ namespace OpenSim.Framework
}
private float m_terrainHeightRange1;
public float terrainHeightRange1
{
get
{
return m_terrainHeightRange1;
}
get { return m_terrainHeightRange1; }
set
{
m_terrainHeightRange1 = value;
@ -471,12 +411,10 @@ namespace OpenSim.Framework
}
private float m_terrainHeightRange2;
public float terrainHeightRange2
{
get
{
return m_terrainHeightRange2;
}
get { return m_terrainHeightRange2; }
set
{
m_terrainHeightRange2 = value;
@ -485,26 +423,23 @@ namespace OpenSim.Framework
}
private float m_terrainHeightRange3;
public float terrainHeightRange3
{
get
{
return m_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;
}
get { return m_terrainFile; }
set
{
m_terrainFile = value;
@ -513,12 +448,10 @@ namespace OpenSim.Framework
}
private double m_terrainMultiplier;
public double terrainMultiplier
{
get
{
return m_terrainMultiplier;
}
get { return m_terrainMultiplier; }
set
{
m_terrainMultiplier = value;
@ -527,12 +460,10 @@ namespace OpenSim.Framework
}
private float m_waterHeight;
public float waterHeight
{
get
{
return m_waterHeight;
}
get { return m_waterHeight; }
set
{
m_waterHeight = value;
@ -541,73 +472,112 @@ namespace OpenSim.Framework
}
private LLUUID m_terrainImageID;
public LLUUID terrainImageID
{
get
{
return m_terrainImageID;
}
get { return m_terrainImageID; }
set
{
m_terrainImageID = value;
configMember.forceSetConfigurationOption("terrain_image_id", m_terrainImageID.ToString());
}
}
private ConfigurationMember configMember;
public EstateSettings()
{
// Temporary hack to prevent multiple loadings.
if (configMember == null)
{
configMember = new ConfigurationMember(Path.Combine(Util.configDir(), "estate_settings.xml"), "ESTATE SETTINGS", this.loadConfigurationOptions, this.handleIncomingConfiguration);
configMember =
new ConfigurationMember(Path.Combine(Util.configDir(), "estate_settings.xml"), "ESTATE SETTINGS",
loadConfigurationOptions, 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("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("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_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_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_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_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);
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)
@ -615,123 +585,123 @@ namespace OpenSim.Framework
switch (configuration_key)
{
case "billable_factor":
this.m_billableFactor = (float)configuration_result;
m_billableFactor = (float) configuration_result;
break;
case "estate_id":
this.m_estateID = (uint)configuration_result;
m_estateID = (uint) configuration_result;
break;
case "parent_estate_id":
this.m_parentEstateID = (uint)configuration_result;
m_parentEstateID = (uint) configuration_result;
break;
case "max_agents":
this.m_maxAgents = (byte)configuration_result;
m_maxAgents = (byte) configuration_result;
break;
case "object_bonus_factor":
this.m_objectBonusFactor = (float)configuration_result;
m_objectBonusFactor = (float) configuration_result;
break;
case "redirect_grid_x":
this.m_redirectGridX = (int)configuration_result;
m_redirectGridX = (int) configuration_result;
break;
case "redirect_grid_y":
this.m_redirectGridY = (int)configuration_result;
m_redirectGridY = (int) configuration_result;
break;
case "region_flags":
this.m_regionFlags = (Simulator.RegionFlags)((uint)configuration_result);
m_regionFlags = (Simulator.RegionFlags) ((uint) configuration_result);
break;
case "sim_access":
this.m_simAccess = (Simulator.SimAccess)((byte)configuration_result);
m_simAccess = (Simulator.SimAccess) ((byte) configuration_result);
break;
case "sun_hour":
this.m_sunHour = (float)configuration_result;
m_sunHour = (float) configuration_result;
break;
case "terrain_raise_limit":
this.m_terrainRaiseLimit = (float)configuration_result;
m_terrainRaiseLimit = (float) configuration_result;
break;
case "terrain_lower_limit":
this.m_terrainLowerLimit = (float)configuration_result;
m_terrainLowerLimit = (float) configuration_result;
break;
case "use_fixed_sun":
this.m_useFixedSun = (bool)configuration_result;
m_useFixedSun = (bool) configuration_result;
break;
case "price_per_meter":
this.m_pricePerMeter = System.Convert.ToInt32(configuration_result);
m_pricePerMeter = Convert.ToInt32(configuration_result);
break;
case "region_water_height":
this.m_regionWaterHeight = (ushort)configuration_result;
m_regionWaterHeight = (ushort) configuration_result;
break;
case "region_allow_terraform":
this.m_regionAllowTerraform = (bool)configuration_result;
m_regionAllowTerraform = (bool) configuration_result;
break;
case "terrain_base_0":
this.m_terrainBase0 = (LLUUID)configuration_result;
m_terrainBase0 = (LLUUID) configuration_result;
break;
case "terrain_base_1":
this.m_terrainBase1 = (LLUUID)configuration_result;
m_terrainBase1 = (LLUUID) configuration_result;
break;
case "terrain_base_2":
this.m_terrainBase2 = (LLUUID)configuration_result;
m_terrainBase2 = (LLUUID) configuration_result;
break;
case "terrain_base_3":
this.m_terrainBase3 = (LLUUID)configuration_result;
m_terrainBase3 = (LLUUID) configuration_result;
break;
case "terrain_detail_0":
this.m_terrainDetail0 = (LLUUID)configuration_result;
m_terrainDetail0 = (LLUUID) configuration_result;
break;
case "terrain_detail_1":
this.m_terrainDetail1 = (LLUUID)configuration_result;
m_terrainDetail1 = (LLUUID) configuration_result;
break;
case "terrain_detail_2":
this.m_terrainDetail2 = (LLUUID)configuration_result;
m_terrainDetail2 = (LLUUID) configuration_result;
break;
case "terrain_detail_3":
this.m_terrainDetail3 = (LLUUID)configuration_result;
m_terrainDetail3 = (LLUUID) configuration_result;
break;
case "terrain_start_height_0":
this.m_terrainStartHeight0 = (float)configuration_result;
m_terrainStartHeight0 = (float) configuration_result;
break;
case "terrain_start_height_1":
this.m_terrainStartHeight1 = (float)configuration_result;
m_terrainStartHeight1 = (float) configuration_result;
break;
case "terrain_start_height_2":
this.m_terrainStartHeight2 = (float)configuration_result;
m_terrainStartHeight2 = (float) configuration_result;
break;
case "terrain_start_height_3":
this.m_terrainStartHeight3 = (float)configuration_result;
m_terrainStartHeight3 = (float) configuration_result;
break;
case "terrain_height_range_0":
this.m_terrainHeightRange0 = (float)configuration_result;
m_terrainHeightRange0 = (float) configuration_result;
break;
case "terrain_height_range_1":
this.m_terrainHeightRange1 = (float)configuration_result;
m_terrainHeightRange1 = (float) configuration_result;
break;
case "terrain_height_range_2":
this.m_terrainHeightRange2 = (float)configuration_result;
m_terrainHeightRange2 = (float) configuration_result;
break;
case "terrain_height_range_3":
this.m_terrainHeightRange3 = (float)configuration_result;
m_terrainHeightRange3 = (float) configuration_result;
break;
case "terrain_file":
this.m_terrainFile = (string)configuration_result;
m_terrainFile = (string) configuration_result;
break;
case "terrain_multiplier":
this.m_terrainMultiplier = System.Convert.ToDouble(configuration_result);
m_terrainMultiplier = Convert.ToDouble(configuration_result);
break;
case "water_height":
double tmpVal = (double) configuration_result;
this.m_waterHeight = (float) tmpVal;
m_waterHeight = (float) tmpVal;
break;
case "terrain_image_id":
this.m_terrainImageID = (LLUUID)configuration_result;
m_terrainImageID = (LLUUID) configuration_result;
break;
}
return true;
}
}
}
}

View File

@ -26,10 +26,6 @@
*
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework
{
public class GridConfig
@ -50,30 +46,49 @@ namespace OpenSim.Framework
public static uint DefaultHttpPort = 8001;
public uint HttpPort = DefaultHttpPort;
private ConfigurationMember configMember;
public GridConfig(string description, string filename)
{
configMember = new ConfigurationMember(filename, description, this.loadConfigurationOptions, this.handleIncomingConfiguration);
configMember =
new ConfigurationMember(filename, description, loadConfigurationOptions, 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:" + AssetConfig.DefaultHttpPort.ToString() + "/", 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("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:" + AssetConfig.DefaultHttpPort.ToString() + "/",
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:" + UserConfig.DefaultHttpPort.ToString() + "/", 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("default_user_server",
ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
"Default User Server URI",
"http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString() + "/", 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);
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);
configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Http Listener port", DefaultHttpPort.ToString(), false);
configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
"Http Listener port", DefaultHttpPort.ToString(), false);
}
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
@ -81,41 +96,41 @@ namespace OpenSim.Framework
switch (configuration_key)
{
case "grid_owner":
this.GridOwner = (string)configuration_result;
GridOwner = (string) configuration_result;
break;
case "default_asset_server":
this.DefaultAssetServer = (string)configuration_result;
DefaultAssetServer = (string) configuration_result;
break;
case "asset_send_key":
this.AssetSendKey = (string)configuration_result;
AssetSendKey = (string) configuration_result;
break;
case "asset_recv_key":
this.AssetRecvKey = (string)configuration_result;
AssetRecvKey = (string) configuration_result;
break;
case "default_user_server":
this.DefaultUserServer = (string)configuration_result;
DefaultUserServer = (string) configuration_result;
break;
case "user_send_key":
this.UserSendKey = (string)configuration_result;
UserSendKey = (string) configuration_result;
break;
case "user_recv_key":
this.UserRecvKey = (string)configuration_result;
UserRecvKey = (string) configuration_result;
break;
case "sim_send_key":
this.SimSendKey = (string)configuration_result;
SimSendKey = (string) configuration_result;
break;
case "sim_recv_key":
this.SimRecvKey = (string)configuration_result;
SimRecvKey = (string) configuration_result;
break;
case "database_provider":
this.DatabaseProvider = (string)configuration_result;
DatabaseProvider = (string) configuration_result;
break;
case "http_port":
HttpPort = (uint)configuration_result;
HttpPort = (uint) configuration_result;
break;
}
return true;
}
}
}
}

View File

@ -26,15 +26,11 @@
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework;
using libsecondlife;
namespace OpenSim.Framework
{
public interface IAssetProvider : IPlugin
public interface IAssetProvider : IPlugin
{
AssetBase FetchAsset(LLUUID uuid);
void CreateAsset(AssetBase asset);
@ -42,4 +38,4 @@ namespace OpenSim.Framework
bool ExistsAsset(LLUUID uuid);
void CommitAssets(); // force a sync to the database
}
}
}

View File

@ -28,14 +28,12 @@
using System;
using System.Collections.Generic;
using libsecondlife;
using OpenSim.Framework;
namespace OpenSim.Framework
{
/// <summary>
/// Description of IAssetServer.
/// </summary>
public interface IAssetServer
{
void SetReceiver(IAssetReceiver receiver);
@ -68,4 +66,4 @@ namespace OpenSim.Framework
public LLUUID AssetID;
public bool IsTexture;
}
}
}

View File

@ -30,31 +30,28 @@ using System.Collections.Generic;
using System.Net;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim.Framework;
namespace OpenSim.Framework
{
// Base Args Interface
public interface IEventArgs
{
IScene Scene
{
get;
set;
}
IScene Scene { get; set; }
IClientAPI Sender
{
get;
set;
}
IClientAPI Sender { get; set; }
}
public delegate void ViewerEffectEventHandler(IClientAPI sender, ViewerEffectPacket.EffectBlock[] effectBlock);
public delegate void ChatFromViewer(Object sender, ChatFromViewerArgs e);
public enum ChatTypeEnum { Whisper = 0, Say = 1, Shout = 2, Broadcast = 0xFF };
public enum ChatTypeEnum
{
Whisper = 0,
Say = 1,
Shout = 2,
Broadcast = 0xFF
} ;
/// <summary>
/// ChatFromViewer Arguments
@ -163,68 +160,127 @@ namespace OpenSim.Framework
public delegate void TextureRequest(Object sender, TextureRequestArgs e);
public delegate void ImprovedInstantMessage(LLUUID fromAgentID, LLUUID fromAgentSession, LLUUID toAgentID, LLUUID imSessionID, uint timestamp, string fromAgentName, string message, byte dialog); // Cut down from full list
public delegate void ImprovedInstantMessage(
LLUUID fromAgentID, LLUUID fromAgentSession, LLUUID toAgentID, LLUUID imSessionID, uint timestamp,
string fromAgentName, string message, byte dialog); // 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 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(IClientAPI remoteClient, 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 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 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 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 AgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID);
public delegate void AgentSit(IClientAPI remoteClient, LLUUID agentID);
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 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 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 UpdateInventoryItemTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, LLUUID itemID);
public delegate void UpdateInventoryItemTransaction(
IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, LLUUID itemID);
public delegate void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID);
public delegate void UpdateTaskInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID folderID, uint localID);
public delegate void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID);
public delegate void UDPAssetUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, bool storeLocal);
public delegate void UDPAssetUploadRequest(
IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, bool storeLocal);
public delegate void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data);
public delegate void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName);
public delegate void ConfirmXfer(IClientAPI remoteClient, ulong xferID, uint packetID);
public interface IClientAPI
@ -298,37 +354,17 @@ namespace OpenSim.Framework
event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
event EstateOwnerMessageRequest OnEstateOwnerMessage;
LLVector3 StartPos
{
get;
set;
}
LLVector3 StartPos { get; set; }
LLUUID AgentId
{
get;
}
LLUUID AgentId { get; }
LLUUID SessionId
{
get;
}
LLUUID SessionId { get; }
string FirstName
{
get;
}
string FirstName { get; }
string LastName
{
get;
}
string LastName { get; }
uint CircuitCode
{
get;
set;
}
uint CircuitCode { get; set; }
void OutPacket(Packet newPack);
void SendWearables(AvatarWearable[] wearables);
@ -339,28 +375,46 @@ namespace OpenSim.Framework
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(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent, LLUUID imSessionID, string fromName, byte dialog, uint timeStamp);
void SendInstantMessage(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent,
LLUUID imSessionID, string fromName, byte dialog, uint timeStamp);
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 );
void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint);
AgentCircuitData RequestClientInfo();
void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint newRegionExternalEndPoint, string capsURL );
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 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, uint parentID);
void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity, LLQuaternion rotation);
void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID,
LLVector3 Pos, byte[] textureEntry, uint parentID);
void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position,
LLVector3 velocity, LLQuaternion rotation);
void SendCoarseLocationUpdate(List<LLVector3> CoarseLocations);
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 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);
@ -375,10 +429,13 @@ namespace OpenSim.Framework
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 );
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);
void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, string flAbout,
uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, LLUUID partnerID);
void SetDebug(int newDebug);
void InPacket(Packet NewPack);
void Close();
@ -387,4 +444,4 @@ namespace OpenSim.Framework
event Action<IClientAPI> OnConnectionClosed;
void SendLogoutPacket();
}
}
}

View File

@ -37,4 +37,4 @@ namespace OpenSim.Framework
void Commit();
void Close();
}
}
}

View File

@ -26,10 +26,6 @@
*
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework
{
/// <summary>
@ -54,4 +50,4 @@ namespace OpenSim.Framework
/// </summary>
void Initialise();
}
}
}

View File

@ -27,14 +27,15 @@
*/
using System.Collections.Generic;
using libsecondlife;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework;
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
@ -45,4 +46,4 @@ namespace OpenSim.Framework
event AcknowledgeAgentCross OnAcknowledgeAgentCrossed;
event UpdateNeighbours OnNeighboursUpdate;
}
}
}

View File

@ -26,7 +26,6 @@
*
*/
using libsecondlife;
using OpenSim.Framework;
namespace OpenSim.Framework
{
@ -34,14 +33,11 @@ namespace OpenSim.Framework
{
void AddNewClient(IClientAPI client, bool child);
void RemoveClient(LLUUID agentID);
RegionInfo RegionInfo { get; }
object SyncRoot { get; }
uint NextLocalId { get; }
ClientManager ClientManager
{
get;
}
ClientManager ClientManager { get; }
}
}
}

View File

@ -26,7 +26,6 @@
*
*/
using libsecondlife;
using OpenSim.Framework;
namespace OpenSim.Framework
{
@ -132,4 +131,4 @@ namespace OpenSim.Framework
/// </summary>
void Initialise();
}
}
}

View File

@ -26,7 +26,6 @@
*
*/
using libsecondlife;
using OpenSim.Framework;
namespace OpenSim.Framework.Interfaces
{

Some files were not shown because too many files have changed in this diff Show More