* Rex merge, Framework (some problems in one or two files).

afrisby-3
Adam Frisby 2008-02-25 17:54:58 +00:00
parent 8df0331405
commit 4853884c30
133 changed files with 31412 additions and 26213 deletions

View File

@ -1,263 +1,263 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
namespace OpenSim.Framework
{
// ACL Class
// Modelled after the structure of the Zend ACL Framework Library
// with one key difference - the tree will search for all matching
// 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
{
private Dictionary<string, Role> Roles = new Dictionary<string, Role>();
private Dictionary<string, Resource> Resources = new Dictionary<string, Resource>();
public ACL AddRole(Role role)
{
if (Roles.ContainsKey(role.Name))
throw new AlreadyContainsRoleException(role);
Roles.Add(role.Name, role);
return this;
}
public ACL AddResource(Resource resource)
{
Resources.Add(resource.Name, resource);
return this;
}
public Permission HasPermission(string role, string resource)
{
if (!Roles.ContainsKey(role))
throw new KeyNotFoundException();
if (!Resources.ContainsKey(resource))
throw new KeyNotFoundException();
return Roles[role].RequestPermission(resource);
}
public ACL GrantPermission(string role, string resource)
{
if (!Roles.ContainsKey(role))
throw new KeyNotFoundException();
if (!Resources.ContainsKey(resource))
throw new KeyNotFoundException();
Roles[role].GivePermission(resource, Permission.Allow);
return this;
}
public ACL DenyPermission(string role, string resource)
{
if (!Roles.ContainsKey(role))
throw new KeyNotFoundException();
if (!Resources.ContainsKey(resource))
throw new KeyNotFoundException();
Roles[role].GivePermission(resource, Permission.Deny);
return this;
}
public ACL ResetPermission(string role, string resource)
{
if (!Roles.ContainsKey(role))
throw new KeyNotFoundException();
if (!Resources.ContainsKey(resource))
throw new KeyNotFoundException();
Roles[role].GivePermission(resource, Permission.None);
return this;
}
}
#endregion
#region Exceptions
/// <summary>
/// Thrown when an ACL attempts to add a duplicate role.
/// </summary>
public class AlreadyContainsRoleException : Exception
{
protected Role m_role;
public Role ErrorRole
{
get { return m_role; }
}
public AlreadyContainsRoleException(Role role)
{
m_role = role;
}
public override string ToString()
{
return "This ACL already contains a role called '" + m_role.Name + "'.";
}
}
#endregion
#region Roles and Resources
/// <summary>
/// Does this Role have permission to access a specified Resource?
/// </summary>
public enum Permission
{
Deny,
None,
Allow
} ;
/// <summary>
/// A role class, for use with Users or Groups
/// </summary>
public class Role
{
private string m_name;
private Role[] m_parents;
private Dictionary<string, Permission> m_resources = new Dictionary<string, Permission>();
public string Name
{
get { return m_name; }
}
public Permission RequestPermission(string resource)
{
return RequestPermission(resource, Permission.None);
}
public Permission RequestPermission(string resource, Permission current)
{
// Deny permissions always override any others
if (current == Permission.Deny)
return current;
Permission temp = Permission.None;
// Pickup non-None permissions
if (m_resources.ContainsKey(resource) && m_resources[resource] != Permission.None)
temp = m_resources[resource];
if (m_parents != null)
{
foreach (Role parent in m_parents)
{
temp = parent.RequestPermission(resource, temp);
}
}
return temp;
}
public void GivePermission(string resource, Permission perm)
{
m_resources[resource] = perm;
}
public Role(string name)
{
m_name = name;
m_parents = null;
}
public Role(string name, Role[] parents)
{
m_name = name;
m_parents = parents;
}
}
public class Resource
{
private string m_name;
public string Name
{
get { return m_name; }
}
public Resource(string name)
{
m_name = name;
}
}
#endregion
#region Tests
internal class ACLTester
{
public ACLTester()
{
ACL acl = new ACL();
Role Guests = new Role("Guests");
acl.AddRole(Guests);
Role[] parents = new Role[0];
parents[0] = Guests;
Role JoeGuest = new Role("JoeGuest", parents);
acl.AddRole(JoeGuest);
Resource CanBuild = new Resource("CanBuild");
acl.AddResource(CanBuild);
acl.GrantPermission("Guests", "CanBuild");
acl.HasPermission("JoeGuest", "CanBuild");
}
}
#endregion
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
namespace OpenSim.Framework
{
// ACL Class
// Modelled after the structure of the Zend ACL Framework Library
// with one key difference - the tree will search for all matching
// 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
{
private Dictionary<string, Role> Roles = new Dictionary<string, Role>();
private Dictionary<string, Resource> Resources = new Dictionary<string, Resource>();
public ACL AddRole(Role role)
{
if (Roles.ContainsKey(role.Name))
throw new AlreadyContainsRoleException(role);
Roles.Add(role.Name, role);
return this;
}
public ACL AddResource(Resource resource)
{
Resources.Add(resource.Name, resource);
return this;
}
public Permission HasPermission(string role, string resource)
{
if (!Roles.ContainsKey(role))
throw new KeyNotFoundException();
if (!Resources.ContainsKey(resource))
throw new KeyNotFoundException();
return Roles[role].RequestPermission(resource);
}
public ACL GrantPermission(string role, string resource)
{
if (!Roles.ContainsKey(role))
throw new KeyNotFoundException();
if (!Resources.ContainsKey(resource))
throw new KeyNotFoundException();
Roles[role].GivePermission(resource, Permission.Allow);
return this;
}
public ACL DenyPermission(string role, string resource)
{
if (!Roles.ContainsKey(role))
throw new KeyNotFoundException();
if (!Resources.ContainsKey(resource))
throw new KeyNotFoundException();
Roles[role].GivePermission(resource, Permission.Deny);
return this;
}
public ACL ResetPermission(string role, string resource)
{
if (!Roles.ContainsKey(role))
throw new KeyNotFoundException();
if (!Resources.ContainsKey(resource))
throw new KeyNotFoundException();
Roles[role].GivePermission(resource, Permission.None);
return this;
}
}
#endregion
#region Exceptions
/// <summary>
/// Thrown when an ACL attempts to add a duplicate role.
/// </summary>
public class AlreadyContainsRoleException : Exception
{
protected Role m_role;
public Role ErrorRole
{
get { return m_role; }
}
public AlreadyContainsRoleException(Role role)
{
m_role = role;
}
public override string ToString()
{
return "This ACL already contains a role called '" + m_role.Name + "'.";
}
}
#endregion
#region Roles and Resources
/// <summary>
/// Does this Role have permission to access a specified Resource?
/// </summary>
public enum Permission
{
Deny,
None,
Allow
} ;
/// <summary>
/// A role class, for use with Users or Groups
/// </summary>
public class Role
{
private string m_name;
private Role[] m_parents;
private Dictionary<string, Permission> m_resources = new Dictionary<string, Permission>();
public string Name
{
get { return m_name; }
}
public Permission RequestPermission(string resource)
{
return RequestPermission(resource, Permission.None);
}
public Permission RequestPermission(string resource, Permission current)
{
// Deny permissions always override any others
if (current == Permission.Deny)
return current;
Permission temp = Permission.None;
// Pickup non-None permissions
if (m_resources.ContainsKey(resource) && m_resources[resource] != Permission.None)
temp = m_resources[resource];
if (m_parents != null)
{
foreach (Role parent in m_parents)
{
temp = parent.RequestPermission(resource, temp);
}
}
return temp;
}
public void GivePermission(string resource, Permission perm)
{
m_resources[resource] = perm;
}
public Role(string name)
{
m_name = name;
m_parents = null;
}
public Role(string name, Role[] parents)
{
m_name = name;
m_parents = parents;
}
}
public class Resource
{
private string m_name;
public string Name
{
get { return m_name; }
}
public Resource(string name)
{
m_name = name;
}
}
#endregion
#region Tests
internal class ACLTester
{
public ACLTester()
{
ACL acl = new ACL();
Role Guests = new Role("Guests");
acl.AddRole(Guests);
Role[] parents = new Role[0];
parents[0] = Guests;
Role JoeGuest = new Role("JoeGuest", parents);
acl.AddRole(JoeGuest);
Resource CanBuild = new Resource("CanBuild");
acl.AddResource(CanBuild);
acl.GrantPermission("Guests", "CanBuild");
acl.HasPermission("JoeGuest", "CanBuild");
}
}
#endregion
}

View File

@ -1,111 +1,111 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using libsecondlife;
namespace OpenSim.Framework
{
public class AgentCircuitData
{
public AgentCircuitData()
{
}
public AgentCircuitData(sAgentCircuitData cAgent)
{
AgentID = new LLUUID(cAgent.AgentID);
SessionID = new LLUUID(cAgent.SessionID);
SecureSessionID = new LLUUID(cAgent.SecureSessionID);
startpos = new LLVector3(cAgent.startposx, cAgent.startposy, cAgent.startposz);
firstname = cAgent.firstname;
lastname = cAgent.lastname;
circuitcode = cAgent.circuitcode;
child = cAgent.child;
InventoryFolder = new LLUUID(cAgent.InventoryFolder);
BaseFolder = new LLUUID(cAgent.BaseFolder);
CapsPath = cAgent.CapsPath;
ClientVersion = cAgent.ClientVersion; //rex
}
public LLUUID AgentID;
public LLUUID SessionID;
public LLUUID SecureSessionID;
public LLVector3 startpos;
public string firstname;
public string lastname;
public uint circuitcode;
public bool child;
public LLUUID InventoryFolder;
public LLUUID BaseFolder;
public string CapsPath = "";
public string ClientVersion = "not set"; //rex
public string authenticationAddr;
public string asAddress = "";
}
[Serializable]
public class sAgentCircuitData
{
public sAgentCircuitData()
{
}
public sAgentCircuitData(AgentCircuitData cAgent)
{
AgentID = cAgent.AgentID.UUID;
SessionID = cAgent.SessionID.UUID;
SecureSessionID = cAgent.SecureSessionID.UUID;
startposx = cAgent.startpos.X;
startposy = cAgent.startpos.Y;
startposz = cAgent.startpos.Z;
firstname = cAgent.firstname;
lastname = cAgent.lastname;
circuitcode = cAgent.circuitcode;
child = cAgent.child;
InventoryFolder = cAgent.InventoryFolder.UUID;
BaseFolder = cAgent.BaseFolder.UUID;
CapsPath = cAgent.CapsPath;
ClientVersion = cAgent.ClientVersion; //rex
}
public Guid AgentID;
public Guid SessionID;
public Guid SecureSessionID;
public float startposx;
public float startposy;
public float startposz;
public string firstname;
public string lastname;
public uint circuitcode;
public bool child;
public Guid InventoryFolder;
public Guid BaseFolder;
public string CapsPath = "";
public string ClientVersion = "not set"; //rex
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using libsecondlife;
namespace OpenSim.Framework
{
public class AgentCircuitData
{
public AgentCircuitData()
{
}
public AgentCircuitData(sAgentCircuitData cAgent)
{
AgentID = new LLUUID(cAgent.AgentID);
SessionID = new LLUUID(cAgent.SessionID);
SecureSessionID = new LLUUID(cAgent.SecureSessionID);
startpos = new LLVector3(cAgent.startposx, cAgent.startposy, cAgent.startposz);
firstname = cAgent.firstname;
lastname = cAgent.lastname;
circuitcode = cAgent.circuitcode;
child = cAgent.child;
InventoryFolder = new LLUUID(cAgent.InventoryFolder);
BaseFolder = new LLUUID(cAgent.BaseFolder);
CapsPath = cAgent.CapsPath;
ClientVersion = cAgent.ClientVersion; //rex
}
public LLUUID AgentID;
public LLUUID SessionID;
public LLUUID SecureSessionID;
public LLVector3 startpos;
public string firstname;
public string lastname;
public uint circuitcode;
public bool child;
public LLUUID InventoryFolder;
public LLUUID BaseFolder;
public string CapsPath = String.Empty;
public string ClientVersion = "not set"; //rex
public string authenticationAddr;
public string asAddress = "";
}
[Serializable]
public class sAgentCircuitData
{
public sAgentCircuitData()
{
}
public sAgentCircuitData(AgentCircuitData cAgent)
{
AgentID = cAgent.AgentID.UUID;
SessionID = cAgent.SessionID.UUID;
SecureSessionID = cAgent.SecureSessionID.UUID;
startposx = cAgent.startpos.X;
startposy = cAgent.startpos.Y;
startposz = cAgent.startpos.Z;
firstname = cAgent.firstname;
lastname = cAgent.lastname;
circuitcode = cAgent.circuitcode;
child = cAgent.child;
InventoryFolder = cAgent.InventoryFolder.UUID;
BaseFolder = cAgent.BaseFolder.UUID;
CapsPath = cAgent.CapsPath;
ClientVersion = cAgent.ClientVersion; //rex
}
public Guid AgentID;
public Guid SessionID;
public Guid SecureSessionID;
public float startposx;
public float startposy;
public float startposz;
public string firstname;
public string lastname;
public uint circuitcode;
public bool child;
public Guid InventoryFolder;
public Guid BaseFolder;
public string CapsPath = String.Empty;
public string ClientVersion = "not set"; //rex
}
}

View File

@ -1,258 +1,258 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Collections.Generic;
using libsecondlife;
using libsecondlife.Packets;
namespace OpenSim.Framework
{
public class AgentInventory
{
//Holds the local copy of Inventory info for a agent
public Dictionary<LLUUID, InventoryFolder> InventoryFolders;
public Dictionary<LLUUID, InventoryItem> InventoryItems;
public InventoryFolder InventoryRoot;
public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server
public LLUUID AgentID;
public AvatarWearable[] Wearables;
public AgentInventory()
{
InventoryFolders = new Dictionary<LLUUID, InventoryFolder>();
InventoryItems = new Dictionary<LLUUID, InventoryItem>();
Initialise();
}
public virtual void Initialise()
{
Wearables = new AvatarWearable[13];
for (int i = 0; i < 13; i++)
{
Wearables[i] = new AvatarWearable();
}
}
public bool CreateNewFolder(LLUUID folderID, ushort type)
{
InventoryFolder Folder = new InventoryFolder();
Folder.FolderID = folderID;
Folder.OwnerID = AgentID;
Folder.DefaultType = type;
InventoryFolders.Add(Folder.FolderID, Folder);
return (true);
}
public void CreateRootFolder(LLUUID newAgentID, bool createTextures)
{
AgentID = newAgentID;
InventoryRoot = new InventoryFolder();
InventoryRoot.FolderID = LLUUID.Random();
InventoryRoot.ParentID = LLUUID.Zero;
InventoryRoot.Version = 1;
InventoryRoot.DefaultType = 8;
InventoryRoot.OwnerID = AgentID;
InventoryRoot.FolderName = "My Inventory";
InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot);
InventoryRoot.OwnerID = AgentID;
if (createTextures)
{
CreateNewFolder(LLUUID.Random(), 0, "Textures", InventoryRoot.FolderID);
}
}
public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName)
{
InventoryFolder Folder = new InventoryFolder();
Folder.FolderID = folderID;
Folder.OwnerID = AgentID;
Folder.DefaultType = type;
Folder.FolderName = folderName;
InventoryFolders.Add(Folder.FolderID, Folder);
return (true);
}
public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parentID)
{
if (!InventoryFolders.ContainsKey(folderID))
{
System.Console.WriteLine("creating new folder called " + folderName + " in agents inventory");
InventoryFolder Folder = new InventoryFolder();
Folder.FolderID = folderID;
Folder.OwnerID = AgentID;
Folder.DefaultType = type;
Folder.FolderName = folderName;
Folder.ParentID = parentID;
InventoryFolders.Add(Folder.FolderID, Folder);
}
return (true);
}
public bool HasFolder(LLUUID folderID)
{
if (InventoryFolders.ContainsKey(folderID))
{
return true;
}
return false;
}
public LLUUID GetFolderID(string folderName)
{
foreach (InventoryFolder inv in InventoryFolders.Values)
{
if (inv.FolderName == folderName)
{
return inv.FolderID;
}
}
return LLUUID.Zero;
}
public bool UpdateItemAsset(LLUUID itemID, AssetBase asset)
{
if (InventoryItems.ContainsKey(itemID))
{
InventoryItem Item = InventoryItems[itemID];
Item.AssetID = asset.FullID;
System.Console.WriteLine("updated inventory item " + itemID.ToString() +
" so it now is set to asset " + asset.FullID.ToString());
//TODO need to update the rest of the info
}
return true;
}
public bool UpdateItemDetails(LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet)
{
System.Console.WriteLine("updating inventory item details");
if (InventoryItems.ContainsKey(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.ToString());
//TODO need to update the rest of the info
}
return true;
}
public LLUUID AddToInventory(LLUUID folderID, AssetBase asset)
{
if (InventoryFolders.ContainsKey(folderID))
{
LLUUID NewItemID = LLUUID.Random();
InventoryItem Item = new InventoryItem();
Item.FolderID = folderID;
Item.OwnerID = AgentID;
Item.AssetID = asset.FullID;
Item.ItemID = NewItemID;
Item.Type = asset.Type;
Item.Name = asset.Name;
Item.Description = asset.Description;
Item.InvType = asset.InvType;
InventoryItems.Add(Item.ItemID, Item);
InventoryFolder Folder = InventoryFolders[Item.FolderID];
Folder.Items.Add(Item);
return (Item.ItemID);
}
else
{
return (null);
}
}
public bool DeleteFromInventory(LLUUID itemID)
{
bool res = false;
if (InventoryItems.ContainsKey(itemID))
{
InventoryItem item = InventoryItems[itemID];
InventoryItems.Remove(itemID);
foreach (InventoryFolder fold in InventoryFolders.Values)
{
if (fold.Items.Contains(item))
{
fold.Items.Remove(item);
break;
}
}
res = true;
}
return res;
}
}
public class InventoryFolder
{
public List<InventoryItem> Items;
//public List<InventoryFolder> Subfolders;
public LLUUID FolderID;
public LLUUID OwnerID;
public LLUUID ParentID = LLUUID.Zero;
public string FolderName;
public ushort DefaultType;
public ushort Version;
public InventoryFolder()
{
Items = new List<InventoryItem>();
//Subfolders = new List<InventoryFolder>();
}
}
public class InventoryItem
{
public LLUUID FolderID;
public LLUUID OwnerID;
public LLUUID ItemID;
public LLUUID AssetID;
public LLUUID CreatorID;
public sbyte InvType;
public sbyte Type;
public string Name = "";
public string Description;
public InventoryItem()
{
CreatorID = LLUUID.Zero;
}
public string ExportString()
{
string typ = "notecard";
string result = "";
result += "\tinv_object\t0\n\t{\n";
result += "\t\tobj_id\t%s\n";
result += "\t\tparent_id\t" + ItemID.ToString() + "\n";
result += "\t\ttype\t" + typ + "\n";
result += "\t\tname\t" + Name + "|\n";
result += "\t}\n";
return result;
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Collections.Generic;
using libsecondlife;
using libsecondlife.Packets;
namespace OpenSim.Framework
{
public class AgentInventory
{
//Holds the local copy of Inventory info for a agent
public Dictionary<LLUUID, InventoryFolder> InventoryFolders;
public Dictionary<LLUUID, InventoryItem> InventoryItems;
public InventoryFolder InventoryRoot;
public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server
public LLUUID AgentID;
public AvatarWearable[] Wearables;
public AgentInventory()
{
InventoryFolders = new Dictionary<LLUUID, InventoryFolder>();
InventoryItems = new Dictionary<LLUUID, InventoryItem>();
Initialise();
}
public virtual void Initialise()
{
Wearables = new AvatarWearable[13];
for (int i = 0; i < 13; i++)
{
Wearables[i] = new AvatarWearable();
}
}
public bool CreateNewFolder(LLUUID folderID, ushort type)
{
InventoryFolder Folder = new InventoryFolder();
Folder.FolderID = folderID;
Folder.OwnerID = AgentID;
Folder.DefaultType = type;
InventoryFolders.Add(Folder.FolderID, Folder);
return (true);
}
public void CreateRootFolder(LLUUID newAgentID, bool createTextures)
{
AgentID = newAgentID;
InventoryRoot = new InventoryFolder();
InventoryRoot.FolderID = LLUUID.Random();
InventoryRoot.ParentID = LLUUID.Zero;
InventoryRoot.Version = 1;
InventoryRoot.DefaultType = 8;
InventoryRoot.OwnerID = AgentID;
InventoryRoot.FolderName = "My Inventory";
InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot);
InventoryRoot.OwnerID = AgentID;
if (createTextures)
{
CreateNewFolder(LLUUID.Random(), 0, "Textures", InventoryRoot.FolderID);
}
}
public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName)
{
InventoryFolder Folder = new InventoryFolder();
Folder.FolderID = folderID;
Folder.OwnerID = AgentID;
Folder.DefaultType = type;
Folder.FolderName = folderName;
InventoryFolders.Add(Folder.FolderID, Folder);
return (true);
}
public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parentID)
{
if (!InventoryFolders.ContainsKey(folderID))
{
System.Console.WriteLine("creating new folder called " + folderName + " in agents inventory");
InventoryFolder Folder = new InventoryFolder();
Folder.FolderID = folderID;
Folder.OwnerID = AgentID;
Folder.DefaultType = type;
Folder.FolderName = folderName;
Folder.ParentID = parentID;
InventoryFolders.Add(Folder.FolderID, Folder);
}
return (true);
}
public bool HasFolder(LLUUID folderID)
{
if (InventoryFolders.ContainsKey(folderID))
{
return true;
}
return false;
}
public LLUUID GetFolderID(string folderName)
{
foreach (InventoryFolder inv in InventoryFolders.Values)
{
if (inv.FolderName == folderName)
{
return inv.FolderID;
}
}
return LLUUID.Zero;
}
public bool UpdateItemAsset(LLUUID itemID, AssetBase asset)
{
if (InventoryItems.ContainsKey(itemID))
{
InventoryItem Item = InventoryItems[itemID];
Item.AssetID = asset.FullID;
System.Console.WriteLine("updated inventory item " + itemID.ToString() +
" so it now is set to asset " + asset.FullID.ToString());
//TODO need to update the rest of the info
}
return true;
}
public bool UpdateItemDetails(LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet)
{
System.Console.WriteLine("updating inventory item details");
if (InventoryItems.ContainsKey(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.ToString());
//TODO need to update the rest of the info
}
return true;
}
public LLUUID AddToInventory(LLUUID folderID, AssetBase asset)
{
if (InventoryFolders.ContainsKey(folderID))
{
LLUUID NewItemID = LLUUID.Random();
InventoryItem Item = new InventoryItem();
Item.FolderID = folderID;
Item.OwnerID = AgentID;
Item.AssetID = asset.FullID;
Item.ItemID = NewItemID;
Item.Type = asset.Type;
Item.Name = asset.Name;
Item.Description = asset.Description;
Item.InvType = asset.InvType;
InventoryItems.Add(Item.ItemID, Item);
InventoryFolder Folder = InventoryFolders[Item.FolderID];
Folder.Items.Add(Item);
return (Item.ItemID);
}
else
{
return (null);
}
}
public bool DeleteFromInventory(LLUUID itemID)
{
bool res = false;
if (InventoryItems.ContainsKey(itemID))
{
InventoryItem item = InventoryItems[itemID];
InventoryItems.Remove(itemID);
foreach (InventoryFolder fold in InventoryFolders.Values)
{
if (fold.Items.Contains(item))
{
fold.Items.Remove(item);
break;
}
}
res = true;
}
return res;
}
}
public class InventoryFolder
{
public List<InventoryItem> Items;
//public List<InventoryFolder> Subfolders;
public LLUUID FolderID;
public LLUUID OwnerID;
public LLUUID ParentID = LLUUID.Zero;
public string FolderName;
public ushort DefaultType;
public ushort Version;
public InventoryFolder()
{
Items = new List<InventoryItem>();
//Subfolders = new List<InventoryFolder>();
}
}
public class InventoryItem
{
public LLUUID FolderID;
public LLUUID OwnerID;
public LLUUID ItemID;
public LLUUID AssetID;
public LLUUID CreatorID;
public sbyte InvType;
public sbyte Type;
public string Name = System.String.Empty;
public string Description;
public InventoryItem()
{
CreatorID = LLUUID.Zero;
}
public string ExportString()
{
string typ = "notecard";
string result = System.String.Empty;
result += "\tinv_object\t0\n\t{\n";
result += "\t\tobj_id\t%s\n";
result += "\t\tparent_id\t" + ItemID.ToString() + "\n";
result += "\t\ttype\t" + typ + "\n";
result += "\t\tname\t" + Name + "|\n";
result += "\t}\n";
return result;
}
}
}

View File

@ -1,36 +1,64 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly : AssemblyTitle("OpenSim.FrameWork")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("")]
[assembly : AssemblyProduct("OpenSim.FrameWork")]
[assembly : AssemblyCopyright("Copyright © 2007")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly : ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly : Guid("a08e20c7-f191-4137-b1f0-9291408fa521")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly : AssemblyTitle("OpenSim.FrameWork")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("")]
[assembly : AssemblyProduct("OpenSim.FrameWork")]
[assembly : AssemblyCopyright("Copyright © OpenSimulator.org Developers 2007-2008")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly : ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly : Guid("a08e20c7-f191-4137-b1f0-9291408fa521")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]

View File

@ -1,56 +1,56 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using libsecondlife;
namespace OpenSim.Framework
{
[Serializable]
public class AssetBase
{
public byte[] Data;
public LLUUID FullID;
public sbyte Type;
public sbyte InvType;
public string Name = "";
public string Description = "";
public string MediaURL = "";//rex
public bool Local = false;
public bool Temporary = false;
public AssetBase()
{
}
public AssetBase(LLUUID assetId, string name)
{
FullID = assetId;
Name = name;
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using libsecondlife;
namespace OpenSim.Framework
{
[Serializable]
public class AssetBase
{
public byte[] Data;
public LLUUID FullID;
public sbyte Type;
public sbyte InvType;
public string Name = String.Empty;
public string Description = String.Empty;
public string MediaURL = "";//rex
public bool Local = false;
public bool Temporary = false;
public AssetBase()
{
}
public AssetBase(LLUUID assetId, string name)
{
FullID = assetId;
Name = name;
}
}
}

View File

@ -1,83 +1,86 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace OpenSim.Framework
{
/// <summary>
/// UserConfig -- For User Server Configuration
/// </summary>
public class AssetConfig
{
public string DefaultStartupMsg = "";
public string DatabaseProvider = "";
public static uint DefaultHttpPort = 8003;
public uint HttpPort = DefaultHttpPort;
private ConfigurationMember configMember;
public AssetConfig(string description, string filename)
{
configMember =
new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, true);
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("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)
{
switch (configuration_key)
{
case "default_startup_message":
DefaultStartupMsg = (string) configuration_result;
break;
case "database_provider":
DatabaseProvider = (string) configuration_result;
break;
case "http_port":
HttpPort = (uint) configuration_result;
break;
}
return true;
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using OpenSim.Framework.Console;
namespace OpenSim.Framework
{
/// <summary>
/// UserConfig -- For User Server Configuration
/// </summary>
public class AssetConfig
{
public string DefaultStartupMsg = String.Empty;
public string DatabaseProvider = String.Empty;
public static uint DefaultHttpPort = 8003;
public uint HttpPort = DefaultHttpPort;
private ConfigurationMember configMember;
public AssetConfig(string description, string filename)
{
configMember =
new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, true);
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("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)
{
switch (configuration_key)
{
case "default_startup_message":
DefaultStartupMsg = (string) configuration_result;
break;
case "database_provider":
DatabaseProvider = (string) configuration_result;
break;
case "http_port":
HttpPort = (uint) configuration_result;
break;
}
return true;
}
}
}

View File

@ -1,164 +1,164 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using libsecondlife;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
/// <summary>
/// Loads assets from the filesystem location. Not yet a plugin, though it should be.
/// </summary>
namespace OpenSim.Framework.AssetLoader.Filesystem
{
public class AssetLoaderFileSystem : IAssetLoader
{
protected AssetBase CreateAsset(string assetIdStr, string name, string path, bool isImage)
{
AssetBase asset = new AssetBase(
new LLUUID(assetIdStr),
name
);
if (!String.IsNullOrEmpty(path))
{
MainLog.Instance.Verbose("ASSETS", "Loading: [{0}][{1}]", name, path);
LoadAsset(asset, isImage, path);
}
else
{
MainLog.Instance.Verbose("ASSETS", "Instantiated: [{0}]", name);
}
return asset;
}
protected void LoadAsset(AssetBase info, bool image, string path)
{
FileInfo fInfo = new FileInfo(path);
long numBytes = fInfo.Length;
FileStream fStream = new FileStream(path, FileMode.Open, FileAccess.Read);
byte[] idata = new byte[numBytes];
BinaryReader br = new BinaryReader(fStream);
idata = br.ReadBytes((int) numBytes);
br.Close();
fStream.Close();
info.Data = idata;
//info.loaded=true;
}
public void ForEachDefaultXmlAsset(Action<AssetBase> action)
{
string assetSetFilename = Path.Combine(Util.assetsDir(), "AssetSets.xml");
ForEachDefaultXmlAsset(assetSetFilename, action);
}
public void ForEachDefaultXmlAsset(string assetSetFilename, Action<AssetBase> action)
{
List<AssetBase> assets = new List<AssetBase>();
if (File.Exists(assetSetFilename))
{
string assetSetPath = "ERROR";
try
{
XmlConfigSource source = new XmlConfigSource(assetSetFilename);
for (int i = 0; i < source.Configs.Count; i++)
{
assetSetPath = source.Configs[i].GetString("file", "");
LoadXmlAssetSet(Path.Combine(Util.assetsDir(), assetSetPath), assets);
}
}
catch (XmlException e)
{
MainLog.Instance.Error("ASSETS", "Error loading {0} : {1}", assetSetPath, e);
}
}
else
{
MainLog.Instance.Error(
"ASSETS",
"Asset set control file assets/AssetSets.xml does not exist! No assets loaded.");
}
assets.ForEach(action);
}
/// <summary>
/// Use the asset set information at path to load assets
/// </summary>
/// <param name="path"></param>
/// <param name="assets"></param>
protected void LoadXmlAssetSet(string assetSetPath, List<AssetBase> assets)
{
MainLog.Instance.Verbose("ASSETS", "Loading asset set {0}", assetSetPath);
if (File.Exists(assetSetPath))
{
try
{
XmlConfigSource source = new XmlConfigSource(assetSetPath);
String dir = Path.GetDirectoryName(assetSetPath);
for (int i = 0; i < source.Configs.Count; i++)
{
string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToString());
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);
string assetPath = Path.Combine(dir, source.Configs[i].GetString("fileName", ""));
AssetBase newAsset = CreateAsset(assetIdStr, name, assetPath, false);
newAsset.Type = type;
newAsset.InvType = invType;
assets.Add(newAsset);
}
}
catch (XmlException e)
{
MainLog.Instance.Error("ASSETS", "Error loading {0} : {1}", assetSetPath, e);
}
}
else
{
MainLog.Instance.Error("ASSETS", "Asset set file {0} does not exist!", assetSetPath);
}
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using libsecondlife;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
/// <summary>
/// Loads assets from the filesystem location. Not yet a plugin, though it should be.
/// </summary>
namespace OpenSim.Framework.AssetLoader.Filesystem
{
public class AssetLoaderFileSystem : IAssetLoader
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
protected AssetBase CreateAsset(string assetIdStr, string name, string path, bool isImage)
{
AssetBase asset = new AssetBase(
new LLUUID(assetIdStr),
name
);
if (!String.IsNullOrEmpty(path))
{
m_log.InfoFormat("[ASSETS]: Loading: [{0}][{1}]", name, path);
LoadAsset(asset, isImage, path);
}
else
{
m_log.InfoFormat("[ASSETS]: Instantiated: [{0}]", name);
}
return asset;
}
protected void LoadAsset(AssetBase info, bool image, string path)
{
FileInfo fInfo = new FileInfo(path);
long numBytes = fInfo.Length;
FileStream fStream = new FileStream(path, FileMode.Open, FileAccess.Read);
byte[] idata = new byte[numBytes];
BinaryReader br = new BinaryReader(fStream);
idata = br.ReadBytes((int) numBytes);
br.Close();
fStream.Close();
info.Data = idata;
//info.loaded=true;
}
public void ForEachDefaultXmlAsset(Action<AssetBase> action)
{
string assetSetFilename = Path.Combine(Util.assetsDir(), "AssetSets.xml");
ForEachDefaultXmlAsset(assetSetFilename, action);
}
public void ForEachDefaultXmlAsset(string assetSetFilename, Action<AssetBase> action)
{
List<AssetBase> assets = new List<AssetBase>();
if (File.Exists(assetSetFilename))
{
string assetSetPath = "ERROR";
try
{
XmlConfigSource source = new XmlConfigSource(assetSetFilename);
for (int i = 0; i < source.Configs.Count; i++)
{
assetSetPath = source.Configs[i].GetString("file", String.Empty);
LoadXmlAssetSet(Path.Combine(Util.assetsDir(), assetSetPath), assets);
}
}
catch (XmlException e)
{
m_log.ErrorFormat("[ASSETS]: Error loading {0} : {1}", assetSetPath, e);
}
}
else
{
m_log.Error("[ASSETS]: Asset set control file assets/AssetSets.xml does not exist! No assets loaded.");
}
assets.ForEach(action);
}
/// <summary>
/// Use the asset set information at path to load assets
/// </summary>
/// <param name="path"></param>
/// <param name="assets"></param>
protected void LoadXmlAssetSet(string assetSetPath, List<AssetBase> assets)
{
m_log.InfoFormat("[ASSETS]: Loading asset set {0}", assetSetPath);
if (File.Exists(assetSetPath))
{
try
{
XmlConfigSource source = new XmlConfigSource(assetSetPath);
String dir = Path.GetDirectoryName(assetSetPath);
for (int i = 0; i < source.Configs.Count; i++)
{
string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToString());
string name = source.Configs[i].GetString("name", String.Empty);
sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0);
sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0);
string assetPath = Path.Combine(dir, source.Configs[i].GetString("fileName", String.Empty));
AssetBase newAsset = CreateAsset(assetIdStr, name, assetPath, false);
newAsset.Type = type;
newAsset.InvType = invType;
assets.Add(newAsset);
}
}
catch (XmlException e)
{
m_log.ErrorFormat("[ASSETS]: Error loading {0} : {1}", assetSetPath, e);
}
}
else
{
m_log.ErrorFormat("[ASSETS]: Asset set file {0} does not exist!", assetSetPath);
}
}
}
}

View File

@ -1,10 +1,38 @@
using libsecondlife;
namespace OpenSim.Framework
{
public struct AssetRequest
{
public LLUUID AssetID;
public bool IsTexture;
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using libsecondlife;
namespace OpenSim.Framework
{
public struct AssetRequest
{
public LLUUID AssetID;
public bool IsTexture;
}
}

View File

@ -1,68 +1,73 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Collections.Generic;
using System.Threading;
namespace OpenSim.Framework
{
public class BlockingQueue<T>
{
private readonly Queue<T> m_queue = new Queue<T>();
private readonly object m_queueSync = new object();
public void Enqueue(T value)
{
lock (m_queueSync)
{
m_queue.Enqueue(value);
Monitor.Pulse(m_queueSync);
}
}
public T Dequeue()
{
lock (m_queueSync)
{
if (m_queue.Count < 1)
{
Monitor.Wait(m_queueSync);
}
return m_queue.Dequeue();
}
}
public bool Contains(T item)
{
lock (m_queueSync)
{
return m_queue.Contains(item);
}
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Collections.Generic;
using System.Threading;
namespace OpenSim.Framework
{
public class BlockingQueue<T>
{
private readonly Queue<T> m_queue = new Queue<T>();
private readonly object m_queueSync = new object();
public void Enqueue(T value)
{
lock (m_queueSync)
{
m_queue.Enqueue(value);
Monitor.Pulse(m_queueSync);
}
}
public T Dequeue()
{
lock (m_queueSync)
{
if (m_queue.Count < 1)
{
Monitor.Wait(m_queueSync);
}
return m_queue.Dequeue();
}
}
public bool Contains(T item)
{
lock (m_queueSync)
{
return m_queue.Contains(item);
}
}
public int Count()
{
return m_queue.Count;
}
}
}

View File

@ -1,50 +1,53 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
namespace OpenSim.Framework
{
[Serializable]
public class ChildAgentDataUpdate
{
public ChildAgentDataUpdate()
{
}
public sLLVector3 Position;
public ulong regionHandle;
public float drawdistance;
public sLLVector3 cameraPosition;
public sLLVector3 Velocity;
public float AVHeight;
public Guid AgentID;
public float godlevel;
public byte[] throttles;
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
namespace OpenSim.Framework
{
[Serializable]
public class ChildAgentDataUpdate
{
public ChildAgentDataUpdate()
{
}
public sLLVector3 Position;
public ulong regionHandle;
public float drawdistance;
public sLLVector3 cameraPosition;
public sLLVector3 Velocity;
public float AVHeight;
public Guid AgentID;
public float godlevel;
public byte[] throttles;
public bool alwaysrun;
public Guid ActiveGroupID;
public uint GroupAccess;
}
}

View File

@ -1,181 +1,197 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Collections.Generic;
using libsecondlife;
using libsecondlife.Packets;
namespace OpenSim.Framework
{
public delegate void ForEachClientDelegate(IClientAPI client);
public class ClientManager
{
private Dictionary<uint, IClientAPI> m_clients;
public void ForEachClient(ForEachClientDelegate whatToDo)
{
// Wasteful, I know
IClientAPI[] LocalClients = new IClientAPI[0];
lock (m_clients)
{
LocalClients = new IClientAPI[m_clients.Count];
m_clients.Values.CopyTo(LocalClients, 0);
}
for (int i = 0; i < LocalClients.Length; i++)
{
try
{
whatToDo(LocalClients[i]);
}
catch (System.Exception e)
{
OpenSim.Framework.Console.MainLog.Instance.Warn("CLIENT", "Unable to do ForEachClient for one of the clients" + "\n Reason: " + e.ToString());
}
}
}
public ClientManager()
{
m_clients = new Dictionary<uint, IClientAPI>();
}
private void Remove(uint id)
{
m_clients.Remove(id);
}
public void Add(uint id, IClientAPI client)
{
m_clients.Add(id, client);
}
public void InPacket(uint circuitCode, Packet packet)
{
IClientAPI client;
if (m_clients.TryGetValue(circuitCode, out client))
{
client.InPacket(packet);
}
}
public void CloseAllAgents(uint circuitCode)
{
IClientAPI client;
if (m_clients.TryGetValue(circuitCode, out client))
{
CloseAllCircuits(client.AgentId);
}
}
public void CloseAllCircuits(LLUUID agentId)
{
uint[] circuits = GetAllCircuits(agentId);
// We're using a for loop here so changes to the circuits don't cause it to completely fail.
for (int i = 0; i < circuits.Length; i++)
{
IClientAPI client;
try
{
if (m_clients.TryGetValue(circuits[i], out client))
{
Remove(client.CircuitCode);
client.Close(false);
}
}
catch (System.Exception e)
{
OpenSim.Framework.Console.MainLog.Instance.Error("CLIENT", string.Format("Unable to shutdown circuit for: {0}\n Reason: {1}", agentId, e));
}
}
}
private uint[] GetAllCircuits(LLUUID agentId)
{
List<uint> circuits = new List<uint>();
// Wasteful, I know
IClientAPI[] LocalClients = new IClientAPI[0];
lock (m_clients)
{
LocalClients = new IClientAPI[m_clients.Count];
m_clients.Values.CopyTo(LocalClients, 0);
}
for (int i = 0; i < LocalClients.Length; i++ )
{
if (LocalClients[i].AgentId == agentId)
{
circuits.Add(LocalClients[i].CircuitCode);
}
}
return circuits.ToArray();
}
public void ViewerEffectHandler(IClientAPI sender, ViewerEffectPacket.EffectBlock[] effectBlock)
{
ViewerEffectPacket packet = (ViewerEffectPacket) PacketPool.Instance.GetPacket(PacketType.ViewerEffect);
// TODO: don't create new blocks if recycling an old packet
packet.Effect = effectBlock;
// Wasteful, I know
IClientAPI[] LocalClients = new IClientAPI[0];
lock (m_clients)
{
LocalClients = new IClientAPI[m_clients.Count];
m_clients.Values.CopyTo(LocalClients, 0);
}
for (int i = 0; i < LocalClients.Length; i++)
{
if (LocalClients[i].AgentId != sender.AgentId)
{
packet.AgentData.AgentID = LocalClients[i].AgentId;
packet.AgentData.SessionID = LocalClients[i].SessionId;
LocalClients[i].OutPacket(packet, ThrottleOutPacketType.Task);
}
}
}
public bool TryGetClient(uint circuitId, out IClientAPI user)
{
return m_clients.TryGetValue(circuitId, out user);
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using libsecondlife;
using libsecondlife.Packets;
namespace OpenSim.Framework
{
public delegate void ForEachClientDelegate(IClientAPI client);
public class ClientManager
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private Dictionary<uint, IClientAPI> m_clients;
public void ForEachClient(ForEachClientDelegate whatToDo)
{
// Wasteful, I know
IClientAPI[] LocalClients = new IClientAPI[0];
lock (m_clients)
{
LocalClients = new IClientAPI[m_clients.Count];
m_clients.Values.CopyTo(LocalClients, 0);
}
for (int i = 0; i < LocalClients.Length; i++)
{
try
{
whatToDo(LocalClients[i]);
}
catch (System.Exception e)
{
m_log.Warn("[CLIENT]: Unable to do ForEachClient for one of the clients" + "\n Reason: " + e.ToString());
}
}
}
public ClientManager()
{
m_clients = new Dictionary<uint, IClientAPI>();
}
public void Remove(uint id)
{
//m_log.InfoFormat("[CLIENT]: Removing client with code {0}, current count {1}", id, m_clients.Count);
lock (m_clients)
{
m_clients.Remove(id);
}
m_log.InfoFormat("[CLIENT]: Removed client with code {0}, new client count {1}", id, m_clients.Count);
}
public void Add(uint id, IClientAPI client)
{
lock (m_clients)
{
m_clients.Add(id, client);
}
}
public void InPacket(uint circuitCode, Packet packet)
{
IClientAPI client;
bool tryGetRet = false;
lock (m_clients)
tryGetRet = m_clients.TryGetValue(circuitCode, out client);
if(tryGetRet)
{
client.InPacket(packet);
}
}
public void CloseAllAgents(uint circuitCode)
{
IClientAPI client;
bool tryGetRet = false;
lock (m_clients)
tryGetRet = m_clients.TryGetValue(circuitCode, out client);
if (tryGetRet)
{
CloseAllCircuits(client.AgentId);
}
}
public void CloseAllCircuits(LLUUID agentId)
{
uint[] circuits = GetAllCircuits(agentId);
// We're using a for loop here so changes to the circuits don't cause it to completely fail.
for (int i = 0; i < circuits.Length; i++)
{
IClientAPI client;
try
{
bool tryGetRet = false;
lock (m_clients)
tryGetRet = m_clients.TryGetValue(circuits[i], out client);
if(tryGetRet)
{
Remove(client.CircuitCode);
client.Close(false);
}
}
catch (System.Exception e)
{
m_log.Error(string.Format("[CLIENT]: Unable to shutdown circuit for: {0}\n Reason: {1}", agentId, e));
}
}
}
private uint[] GetAllCircuits(LLUUID agentId)
{
List<uint> circuits = new List<uint>();
// Wasteful, I know
IClientAPI[] LocalClients = new IClientAPI[0];
lock (m_clients)
{
LocalClients = new IClientAPI[m_clients.Count];
m_clients.Values.CopyTo(LocalClients, 0);
}
for (int i = 0; i < LocalClients.Length; i++ )
{
if (LocalClients[i].AgentId == agentId)
{
circuits.Add(LocalClients[i].CircuitCode);
}
}
return circuits.ToArray();
}
public void ViewerEffectHandler(IClientAPI sender, ViewerEffectPacket.EffectBlock[] effectBlock)
{
ViewerEffectPacket packet = (ViewerEffectPacket) PacketPool.Instance.GetPacket(PacketType.ViewerEffect);
// TODO: don't create new blocks if recycling an old packet
packet.Effect = effectBlock;
// Wasteful, I know
IClientAPI[] LocalClients = new IClientAPI[0];
lock (m_clients)
{
LocalClients = new IClientAPI[m_clients.Count];
m_clients.Values.CopyTo(LocalClients, 0);
}
for (int i = 0; i < LocalClients.Length; i++)
{
if (LocalClients[i].AgentId != sender.AgentId)
{
packet.AgentData.AgentID = LocalClients[i].AgentId;
packet.AgentData.SessionID = LocalClients[i].SessionId;
packet.Header.Reliable = false;
LocalClients[i].OutPacket(packet, ThrottleOutPacketType.Task);
}
}
}
public bool TryGetClient(uint circuitId, out IClientAPI user)
{
lock (m_clients)
{
return m_clients.TryGetValue(circuitId, out user);
}
}
}
}

View File

@ -1,54 +1,54 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using OpenSim.Framework.Servers;
namespace OpenSim.Framework.Communications
{
public class CAPSService
{
private BaseHttpServer m_server;
public CAPSService(BaseHttpServer httpServer)
{
m_server = httpServer;
AddCapsSeedHandler("/CapsSeed/", CapsRequest);
}
private void AddCapsSeedHandler(string path, RestMethod 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);
return "";
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using OpenSim.Framework.Servers;
namespace OpenSim.Framework.Communications
{
public class CAPSService
{
private readonly BaseHttpServer m_server;
public CAPSService(BaseHttpServer httpServer)
{
m_server = httpServer;
AddCapsSeedHandler("/CapsSeed/", CapsRequest);
}
private void AddCapsSeedHandler(string path, RestMethod 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);
return System.String.Empty;
}
}
}

View File

@ -0,0 +1,206 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
//moved to a module, left here until the module is found to have no problems
/*
using System;
using System.Collections.Generic;
using libsecondlife;
namespace OpenSim.Framework.Communications.Cache
{
/// <summary>
/// Provider handlers for processing asset transactions originating from the agent. This encompasses
/// clothing creation and update as well as asset uploads.
/// </summary>
public class AgentAssetTransactionsManager
{
private static readonly log4net.ILog m_log
= log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Fields
public CommunicationsManager CommsManager;
/// <summary>
/// Each agent has its own singleton collection of transactions
/// </summary>
private Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions =
new Dictionary<LLUUID, AgentAssetTransactions>();
/// <summary>
/// Should we dump uploaded assets to the filesystem?
/// </summary>
private bool m_dumpAssetsToFile;
public AgentAssetTransactionsManager(CommunicationsManager commsManager, bool dumpAssetsToFile)
{
CommsManager = commsManager;
m_dumpAssetsToFile = dumpAssetsToFile;
}
/// <summary>
/// Get the collection of asset transactions for the given user. If one does not already exist, it
/// is created.
/// </summary>
/// <param name="userID"></param>
/// <returns></returns>
private AgentAssetTransactions GetUserTransactions(LLUUID userID)
{
lock (AgentTransactions)
{
if (!AgentTransactions.ContainsKey(userID))
{
AgentAssetTransactions transactions
= new AgentAssetTransactions(userID, this, m_dumpAssetsToFile);
AgentTransactions.Add(userID, transactions);
}
return AgentTransactions[userID];
}
}
/// <summary>
/// Remove the given agent asset transactions. This should be called when a client is departing
/// from a scene (and hence won't be making any more transactions here).
/// </summary>
/// <param name="userID"></param>
public void RemoveAgentAssetTransactions(LLUUID userID)
{
m_log.DebugFormat("Removing agent asset transactions structure for agent {0}", userID);
lock (AgentTransactions)
{
AgentTransactions.Remove(userID);
}
}
/// <summary>
/// Create an inventory item from data that has been received through a transaction.
///
/// This is called when new clothing or body parts are created. It may also be called in other
/// situations.
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="transactionID"></param>
/// <param name="folderID"></param>
/// <param name="callbackID"></param>
/// <param name="description"></param>
/// <param name="name"></param>
/// <param name="invType"></param>
/// <param name="type"></param>
/// <param name="wearableType"></param>
/// <param name="nextOwnerMask"></param>
public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
uint callbackID, string description, string name, sbyte invType,
sbyte type, byte wearableType, uint nextOwnerMask)
{
m_log.DebugFormat(
"[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name);
AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
transactions.RequestCreateInventoryItem(
remoteClient, transactionID, folderID, callbackID, description,
name, invType, type, wearableType, nextOwnerMask);
}
/// <summary>
/// Update an inventory item with data that has been received through a transaction.
///
/// This is called when clothing or body parts are updated (for instance, with new textures or
/// colours). It may also be called in other situations.
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="transactionID"></param>
/// <param name="item"></param>
public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID,
InventoryItemBase item)
{
m_log.DebugFormat(
"[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}",
item.inventoryName);
AgentAssetTransactions transactions
= CommsManager.TransactionsManager.GetUserTransactions(remoteClient.AgentId);
transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item);
}
/// <summary>
/// Request that a client (agent) begin an asset transfer.
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="assetID"></param>
/// <param name="transaction"></param>
/// <param name="type"></param>
/// <param name="data"></param></param>
/// <param name="tempFile"></param>
public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type,
byte[] data, bool storeLocal, bool tempFile)
{
// Console.WriteLine("asset upload of " + assetID);
AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
if (uploader != null)
{
// Upload has already compelted uploading...
if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile))
{
//[commenting out as this removal breaks uploads]
/*lock (transactions.XferUploaders)
{
// XXX Weak ass way of doing this by directly manipulating this public dictionary, purely temporary
transactions.XferUploaders.Remove(uploader.TransactionID);
//m_log.InfoFormat("[ASSET TRANSACTIONS] Current uploaders: {0}", transactions.XferUploaders.Count);
}*/
/* }
}
}
/// <summary>
/// Handle asset transfer data packets received in response to the asset upload request in
/// HandleUDPUploadRequest()
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="xferID"></param>
/// <param name="packetID"></param>
/// <param name="data"></param>
public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
{
AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
transactions.HandleXfer(xferID, packetID, data);
}
}
}
*/

File diff suppressed because it is too large Load Diff

View File

@ -1,234 +1,236 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.IO;
using Db4objects.Db4o;
using Db4objects.Db4o.Query;
using libsecondlife;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Communications.Cache
{
public class LocalAssetServer : AssetServerBase
{
private IObjectContainer db;
public LocalAssetServer()
{
bool yapfile;
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");
if (!yapfile)
{
SetUpAssetDatabase();
}
}
public void CreateAndCommitAsset(AssetBase asset)
{
AssetStorage store = new AssetStorage();
store.Data = asset.Data;
store.Name = asset.Name;
store.UUID = asset.FullID;
db.Set(store);
db.Commit();
}
public override void Close()
{
base.Close();
if (db != null)
{
MainLog.Instance.Verbose("ASSETSERVER", "Closing local asset server database");
db.Close();
}
}
// rex new function for "replace assets" functionality
public override LLUUID ExistsAsset(sbyte assetType, string name)
{
IObjectSet result = db.Query(new AssetTypeNameQuery(assetType, name));
AssetStorage foundAsset = null;
if (result.Count > 0)
{
foundAsset = (AssetStorage)result.Next();
return foundAsset.UUID;
}
return LLUUID.Zero;
}
// rex new function
public override bool ExistsAsset(LLUUID assetID)
{
IObjectSet result = db.Query(new AssetUUIDQuery(assetID));
if (result.Count > 0)
return true;
else
return false;
}
// rex new function
public override AssetBase FetchAsset(LLUUID assetID)
{
byte[] idata = null;
bool found = false;
AssetStorage foundAsset = null;
IObjectSet result = db.Query(new AssetUUIDQuery(assetID));
if (result.Count > 0)
{
foundAsset = (AssetStorage)result.Next();
found = true;
}
AssetBase asset = new AssetBase();
if (found)
{
asset.FullID = foundAsset.UUID;
asset.Type = foundAsset.Type;
asset.InvType = foundAsset.Type;
asset.Name = foundAsset.Name;
idata = foundAsset.Data;
asset.Data = idata;
return asset;
}
else
{
return null;
}
}
protected override AssetBase GetAsset(AssetRequest req)
{
byte[] idata = null;
bool found = false;
AssetStorage foundAsset = null;
IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID));
if (result.Count > 0)
{
foundAsset = (AssetStorage) result.Next();
found = true;
}
AssetBase asset = new AssetBase();
if (found)
{
asset.FullID = foundAsset.UUID;
asset.Type = foundAsset.Type;
asset.InvType = foundAsset.Type;
asset.Name = foundAsset.Name;
idata = foundAsset.Data;
asset.Data = idata;
return asset;
}
else
{
return null;
}
}
protected override void StoreAsset(AssetBase asset)
{
AssetStorage store = new AssetStorage();
store.Data = asset.Data;
store.Name = asset.Name;
store.UUID = asset.FullID;
db.Set(store);
CommitAssets();
}
// rex overrided function for "replace assets" functionality to work with local assetserver
public override void UpdateAsset(AssetBase asset)
{
lock (m_syncLock)
{
IObjectSet result = db.Query(new AssetUUIDQuery(asset.FullID));
AssetStorage foundAsset = null;
int i;
for (i = 0; i < result.Count; i++)
{
foundAsset = (AssetStorage)result.Next();
db.Delete(foundAsset);
}
StoreAsset(asset);
}
}
protected override void CommitAssets()
{
db.Commit();
}
protected virtual void SetUpAssetDatabase()
{
MainLog.Instance.Verbose("LOCAL ASSET SERVER", "Setting up asset database");
base.LoadDefaultAssets();
}
}
public class AssetUUIDQuery : Predicate
{
private LLUUID _findID;
public AssetUUIDQuery(LLUUID find)
{
_findID = find;
}
public bool Match(AssetStorage asset)
{
return (asset.UUID == _findID);
}
}
// rex new class for "replace assets" functionality
public class AssetTypeNameQuery : Predicate
{
private sbyte _findType;
private string _findName;
public AssetTypeNameQuery(sbyte type, string name)
{
_findType = type;
_findName = name;
}
public bool Match(AssetStorage asset)
{
return ((asset.Type == _findType) && (asset.Name == _findName));
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.IO;
using Db4objects.Db4o;
using Db4objects.Db4o.Query;
using libsecondlife;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Communications.Cache
{
public class LocalAssetServer : AssetServerBase
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private IObjectContainer db;
public LocalAssetServer()
{
bool yapfile;
yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap"));
db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap"));
m_log.Info("[ASSETS]: Db4 Asset database creation");
if (!yapfile)
{
SetUpAssetDatabase();
}
}
public void CreateAndCommitAsset(AssetBase asset)
{
AssetStorage store = new AssetStorage();
store.Data = asset.Data;
store.Name = asset.Name;
store.UUID = asset.FullID;
db.Set(store);
db.Commit();
}
public override void Close()
{
base.Close();
if (db != null)
{
m_log.Info("[ASSETSERVER]: Closing local asset server database");
db.Close();
}
}
// rex new function for "replace assets" functionality
public override LLUUID ExistsAsset(sbyte assetType, string name)
{
IObjectSet result = db.Query(new AssetTypeNameQuery(assetType, name));
AssetStorage foundAsset = null;
if (result.Count > 0)
{
foundAsset = (AssetStorage)result.Next();
return foundAsset.UUID;
}
return LLUUID.Zero;
}
// rex new function
public override bool ExistsAsset(LLUUID assetID)
{
IObjectSet result = db.Query(new AssetUUIDQuery(assetID));
if (result.Count > 0)
return true;
else
return false;
}
// rex new function
public override AssetBase FetchAsset(LLUUID assetID)
{
byte[] idata = null;
bool found = false;
AssetStorage foundAsset = null;
IObjectSet result = db.Query(new AssetUUIDQuery(assetID));
if (result.Count > 0)
{
foundAsset = (AssetStorage)result.Next();
found = true;
}
AssetBase asset = new AssetBase();
if (found)
{
asset.FullID = foundAsset.UUID;
asset.Type = foundAsset.Type;
asset.InvType = foundAsset.Type;
asset.Name = foundAsset.Name;
idata = foundAsset.Data;
asset.Data = idata;
return asset;
}
else
{
return null;
}
}
protected override AssetBase GetAsset(AssetRequest req)
{
byte[] idata = null;
bool found = false;
AssetStorage foundAsset = null;
IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID));
if (result.Count > 0)
{
foundAsset = (AssetStorage) result.Next();
found = true;
}
AssetBase asset = new AssetBase();
if (found)
{
asset.FullID = foundAsset.UUID;
asset.Type = foundAsset.Type;
asset.InvType = foundAsset.Type;
asset.Name = foundAsset.Name;
idata = foundAsset.Data;
asset.Data = idata;
return asset;
}
else
{
return null;
}
}
protected override void StoreAsset(AssetBase asset)
{
AssetStorage store = new AssetStorage();
store.Data = asset.Data;
store.Name = asset.Name;
store.UUID = asset.FullID;
db.Set(store);
CommitAssets();
}
// rex overrided function for "replace assets" functionality to work with local assetserver
public override void UpdateAsset(AssetBase asset)
{
lock (m_syncLock)
{
IObjectSet result = db.Query(new AssetUUIDQuery(asset.FullID));
AssetStorage foundAsset = null;
int i;
for (i = 0; i < result.Count; i++)
{
foundAsset = (AssetStorage)result.Next();
db.Delete(foundAsset);
}
StoreAsset(asset);
}
}
protected override void CommitAssets()
{
db.Commit();
}
protected virtual void SetUpAssetDatabase()
{
m_log.Info("[LOCAL ASSET SERVER]: Setting up asset database");
base.LoadDefaultAssets();
}
}
public class AssetUUIDQuery : Predicate
{
private LLUUID _findID;
public AssetUUIDQuery(LLUUID find)
{
_findID = find;
}
public bool Match(AssetStorage asset)
{
return (asset.UUID == _findID);
}
}
// rex new class for "replace assets" functionality
public class AssetTypeNameQuery : Predicate
{
private sbyte _findType;
private string _findName;
public AssetTypeNameQuery(sbyte type, string name)
{
_findType = type;
_findName = name;
}
public bool Match(AssetStorage asset)
{
return ((asset.Type == _findType) && (asset.Name == _findName));
}
}
}

View File

@ -1,193 +1,201 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Threading;
using libsecondlife;
using OpenSim.Framework.Console;
using OpenSim.Framework.AssetLoader.Filesystem;
namespace OpenSim.Framework.Communications.Cache
{
public abstract class AssetServerBase : IAssetServer
{
protected IAssetReceiver m_receiver;
protected BlockingQueue<AssetRequest> m_assetRequests;
protected Thread m_localAssetServerThread;
protected IAssetProvider m_assetProvider;
protected object m_syncLock = new object();
// Temporarily hardcoded - should be a plugin
protected IAssetLoader assetLoader = new AssetLoaderFileSystem();
protected abstract void StoreAsset(AssetBase asset);
protected abstract void CommitAssets();
public abstract LLUUID ExistsAsset(sbyte assetType, string name); // rex new function for "replace assets" functionality
/// <summary>
/// This method must be implemented by a subclass to retrieve the asset named in the
/// AssetRequest. If the asset is not found, null should be returned.
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
protected abstract AssetBase GetAsset(AssetRequest req);
/// <summary>
/// Process an asset request. This method will call GetAsset(AssetRequest req)
/// on the subclass.
/// </summary>
/// <param name="req"></param>
protected virtual void ProcessRequest(AssetRequest req)
{
AssetBase asset = GetAsset(req);
if (asset != null)
{
MainLog.Instance.Verbose(
"ASSET", "Asset {0} received from asset server", req.AssetID);
m_receiver.AssetReceived(asset, req.IsTexture);
}
else
{
MainLog.Instance.Error(
"ASSET", "Asset {0} not found by asset server", req.AssetID);
m_receiver.AssetNotFound(req.AssetID);
}
}
public virtual void LoadDefaultAssets()
{
MainLog.Instance.Verbose("ASSETSERVER", "Setting up asset database");
assetLoader.ForEachDefaultXmlAsset(StoreAsset);
CommitAssets();
}
public AssetServerBase()
{
MainLog.Instance.Verbose("ASSETSERVER", "Starting asset storage system");
m_assetRequests = new BlockingQueue<AssetRequest>();
m_localAssetServerThread = new Thread(RunRequests);
m_localAssetServerThread.IsBackground = true;
m_localAssetServerThread.Start();
}
private void RunRequests()
{
while (true) // Since it's a 'blocking queue'
{
try
{
AssetRequest req = m_assetRequests.Dequeue();
ProcessRequest(req);
}
catch (Exception e)
{
MainLog.Instance.Error("ASSETSERVER", e.Message);
}
}
}
public void SetReceiver(IAssetReceiver receiver)
{
m_receiver = receiver;
}
public void RequestAsset(LLUUID assetID, bool isTexture)
{
AssetRequest req = new AssetRequest();
req.AssetID = assetID;
req.IsTexture = isTexture;
m_assetRequests.Enqueue(req);
MainLog.Instance.Verbose("ASSET", "Added {0} to request queue", assetID);
}
public virtual void UpdateAsset(AssetBase asset)
{
lock (m_syncLock)
{
m_assetProvider.UpdateAsset(asset);
m_assetProvider.CommitAssets();
}
}
public void StoreAndCommitAsset(AssetBase asset)
{
lock (m_syncLock)
{
StoreAsset(asset);
CommitAssets();
}
}
// rex, new function
public List<AssetBase> GetAssetList(int vAssetType)
{
lock (m_syncLock)
{
return m_assetProvider.GetAssetList(vAssetType);
}
}
// rex, new function
public virtual AssetBase FetchAsset(LLUUID assetID)
{
lock (m_syncLock)
{
return m_assetProvider.FetchAsset(assetID);
}
}
// rex, new function
public virtual bool ExistsAsset(LLUUID assetID)
{
lock (m_syncLock)
{
return m_assetProvider.ExistsAsset(assetID);
}
}
public virtual void Close()
{
m_localAssetServerThread.Abort();
}
public void SetServerInfo(string ServerUrl, string ServerKey)
{
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Threading;
using libsecondlife;
using OpenSim.Framework.Console;
using OpenSim.Framework.AssetLoader.Filesystem;
namespace OpenSim.Framework.Communications.Cache
{
public abstract class AssetServerBase : IAssetServer
{
private static readonly log4net.ILog m_log
= log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
protected IAssetReceiver m_receiver;
protected BlockingQueue<AssetRequest> m_assetRequests;
protected Thread m_localAssetServerThread;
protected IAssetProvider m_assetProvider;
protected object m_syncLock = new object();
// Temporarily hardcoded - should be a plugin
protected IAssetLoader assetLoader = new AssetLoaderFileSystem();
protected abstract void StoreAsset(AssetBase asset);
protected abstract void CommitAssets();
public abstract LLUUID ExistsAsset(sbyte assetType, string name); // rex new function for "replace assets" functionality
/// <summary>
/// This method must be implemented by a subclass to retrieve the asset named in the
/// AssetRequest. If the asset is not found, null should be returned.
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
protected abstract AssetBase GetAsset(AssetRequest req);
/// <summary>
/// Process an asset request. This method will call GetAsset(AssetRequest req)
/// on the subclass.
/// </summary>
/// <param name="req"></param>
protected virtual void ProcessRequest(AssetRequest req)
{
AssetBase asset = GetAsset(req);
if (asset != null)
{
//m_log.InfoFormat("[ASSETSERVER]: Asset {0} received from asset server", req.AssetID);
m_receiver.AssetReceived(asset, req.IsTexture);
}
else
{
m_log.ErrorFormat("[ASSET SERVER]: Asset {0} not found by asset server", req.AssetID);
m_receiver.AssetNotFound(req.AssetID);
}
}
public virtual void LoadDefaultAssets()
{
m_log.Info("[ASSET SERVER]: Setting up asset database");
assetLoader.ForEachDefaultXmlAsset(StoreAsset);
CommitAssets();
}
public AssetServerBase()
{
m_log.Info("[ASSET SERVER]: Starting asset storage system");
m_assetRequests = new BlockingQueue<AssetRequest>();
m_localAssetServerThread = new Thread(RunRequests);
m_localAssetServerThread.Name = "LocalAssetServerThread";
m_localAssetServerThread.IsBackground = true;
m_localAssetServerThread.Start();
OpenSim.Framework.ThreadTracker.Add(m_localAssetServerThread);
}
private void RunRequests()
{
while (true) // Since it's a 'blocking queue'
{
try
{
AssetRequest req = m_assetRequests.Dequeue();
ProcessRequest(req);
}
catch (Exception e)
{
m_log.Error("[ASSET SERVER]: " + e.ToString());
}
}
}
/// <summary>
/// The receiver will be called back with asset data once it comes in.
/// </summary>
/// <param name="receiver"></param>
public void SetReceiver(IAssetReceiver receiver)
{
m_receiver = receiver;
}
public void RequestAsset(LLUUID assetID, bool isTexture)
{
AssetRequest req = new AssetRequest();
req.AssetID = assetID;
req.IsTexture = isTexture;
m_assetRequests.Enqueue(req);
#if DEBUG
m_log.InfoFormat("[ASSET SERVER]: Added {0} to request queue", assetID);
#endif
}
public virtual void UpdateAsset(AssetBase asset)
{
lock (m_syncLock)
{
m_assetProvider.UpdateAsset(asset);
m_assetProvider.CommitAssets();
}
}
public void StoreAndCommitAsset(AssetBase asset)
{
lock (m_syncLock)
{
StoreAsset(asset);
CommitAssets();
}
}
// rex, new function
public List<AssetBase> GetAssetList(int vAssetType)
{
lock (m_syncLock)
{
return m_assetProvider.GetAssetList(vAssetType);
}
}
// rex, new function
public virtual AssetBase FetchAsset(LLUUID assetID)
{
lock (m_syncLock)
{
return m_assetProvider.FetchAsset(assetID);
}
}
// rex, new function
public virtual bool ExistsAsset(LLUUID assetID)
{
lock (m_syncLock)
{
return m_assetProvider.ExistsAsset(assetID);
}
}
public virtual void Close()
{
m_localAssetServerThread.Abort();
}
public void SetServerInfo(string ServerUrl, string ServerKey)
{
}
}
}

View File

@ -1,109 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Collections.Generic;
using libsecondlife;
namespace OpenSim.Framework.Communications.Cache
{
public class AssetTransactionManager
{
// Fields
public CommunicationsManager CommsManager;
public Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions =
new Dictionary<LLUUID, AgentAssetTransactions>();
private bool m_dumpAssetsToFile;
public AssetTransactionManager(CommunicationsManager commsManager, bool dumpAssetsToFile)
{
CommsManager = commsManager;
m_dumpAssetsToFile = dumpAssetsToFile;
}
// Methods
public AgentAssetTransactions AddUser(LLUUID userID)
{
lock (AgentTransactions)
{
if (!AgentTransactions.ContainsKey(userID))
{
AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile);
AgentTransactions.Add(userID, transactions);
return transactions;
}
}
return null;
}
public AgentAssetTransactions GetUserTransActions(LLUUID userID)
{
if (AgentTransactions.ContainsKey(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)
{
AgentAssetTransactions transactions = GetUserTransActions(remoteClient.AgentId);
if (transactions != null)
{
transactions.RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description,
name, invType, type, wearableType, nextOwnerMask);
}
}
public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type,
byte[] data, bool storeLocal, bool tempFile)
{
// Console.WriteLine("asset upload of " + assetID);
AgentAssetTransactions transactions = GetUserTransActions(remoteClient.AgentId);
if (transactions != null)
{
AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
if (uploader != null)
{
uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile);
}
}
}
public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
{
AgentAssetTransactions transactions = GetUserTransActions(remoteClient.AgentId);
if (transactions != null)
{
transactions.HandleXfer(xferID, packetID, data);
}
}
}
}

View File

@ -1,128 +1,134 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.IO;
using System.Xml.Serialization;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
namespace OpenSim.Framework.Communications.Cache
{
public class GridAssetClient : AssetServerBase
{
private string _assetServerUrl;
public GridAssetClient(string serverUrl)
{
_assetServerUrl = serverUrl;
}
#region IAssetServer Members
protected override AssetBase GetAsset(AssetRequest req)
{
Stream s = null;
try
{
MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", req.AssetID.ToString());
RestClient rc = new RestClient(_assetServerUrl);
rc.AddResourcePath("assets");
rc.AddResourcePath(req.AssetID.ToString());
if (req.IsTexture)
rc.AddQueryParameter("texture");
rc.RequestMethod = "GET";
s = rc.Request();
if (s.Length > 0)
{
XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
return (AssetBase) xs.Deserialize(s);
}
}
catch (Exception e)
{
MainLog.Instance.Error("ASSETCACHE", e.Message);
MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", req.AssetID.ToString());
MainLog.Instance.Error("ASSETCACHE", e.StackTrace);
}
return null;
}
public override void UpdateAsset(AssetBase asset)
{
throw new Exception("The method or operation is not implemented.");
}
protected override void StoreAsset(AssetBase asset)
{
try
{
// MemoryStream s = new MemoryStream();
// XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
// xs.Serialize(s, asset);
// RestClient rc = new RestClient(_assetServerUrl);
MainLog.Instance.Verbose("ASSET", "Storing asset");
//rc.AddResourcePath("assets");
// rc.RequestMethod = "POST";
// rc.Request(s);
//MainLog.Instance.Verbose("ASSET", "Stored {0}", rc);
MainLog.Instance.Verbose("ASSET", "Sending to " + _assetServerUrl + "/assets/");
RestObjectPoster.BeginPostObject<AssetBase>(_assetServerUrl + "/assets/", asset);
}
catch (Exception e)
{
MainLog.Instance.Error("ASSETS", e.Message);
}
}
protected override void CommitAssets()
{
}
public override void Close()
{
throw new Exception("The method or operation is not implemented.");
}
// rex new function for "replace assets" functionality
// TODO: implementation by someone
public override libsecondlife.LLUUID ExistsAsset(sbyte assetType, string name)
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
}
}
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.IO;
using System.Xml.Serialization;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
namespace OpenSim.Framework.Communications.Cache
{
public class GridAssetClient : AssetServerBase
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private string _assetServerUrl;
public GridAssetClient(string serverUrl)
{
_assetServerUrl = serverUrl;
}
#region IAssetServer Members
protected override AssetBase GetAsset(AssetRequest req)
{
Stream s = null;
try
{
#if DEBUG
//m_log.DebugFormat("[GRID ASSET CLIENT]: Querying for {0}", req.AssetID.ToString());
#endif
RestClient rc = new RestClient(_assetServerUrl);
rc.AddResourcePath("assets");
rc.AddResourcePath(req.AssetID.ToString());
if (req.IsTexture)
rc.AddQueryParameter("texture");
rc.RequestMethod = "GET";
s = rc.Request();
if (s.Length > 0)
{
XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
return (AssetBase) xs.Deserialize(s);
}
}
catch (Exception e)
{
m_log.Error("[GRID ASSET CLIENT]: " + e.Message);
m_log.DebugFormat("[GRID ASSET CLIENT]: Getting asset {0}", req.AssetID.ToString());
m_log.Error("[GRID ASSET CLIENT]: " + e.StackTrace);
}
return null;
}
public override void UpdateAsset(AssetBase asset)
{
throw new Exception("The method or operation is not implemented.");
}
protected override void StoreAsset(AssetBase asset)
{
try
{
// MemoryStream s = new MemoryStream();
// XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
// xs.Serialize(s, asset);
// RestClient rc = new RestClient(_assetServerUrl);
m_log.Info("[GRID ASSET CLIENT]: Storing asset");
//rc.AddResourcePath("assets");
// rc.RequestMethod = "POST";
// rc.Request(s);
//m_log.InfoFormat("[ASSET]: Stored {0}", rc);
m_log.Info("[GRID ASSET CLIENT]: Sending to " + _assetServerUrl + "/assets/");
RestObjectPoster.BeginPostObject<AssetBase>(_assetServerUrl + "/assets/", asset);
}
catch (Exception e)
{
m_log.Error("[GRID ASSET CLIENT]: " + e.Message);
}
}
protected override void CommitAssets()
{
}
public override void Close()
{
throw new Exception("The method or operation is not implemented.");
}
// rex new function for "replace assets" functionality
// TODO: implementation by someone
public override libsecondlife.LLUUID ExistsAsset(sbyte assetType, string name)
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
}
}

View File

@ -1,281 +1,278 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Collections.Generic;
using System.IO;
using System.Xml;
using libsecondlife;
using Nini.Config;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Communications.Cache
{
/// <summary>
/// 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 : InventoryFolderImpl
{
private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000");
/// <summary>
/// Holds the root library folder and all its descendents. This is really only used during inventory
/// setup so that we don't have to repeatedly search the tree of library folders.
/// </summary>
protected Dictionary<LLUUID, InventoryFolderImpl> libraryFolders
= new Dictionary<LLUUID, InventoryFolderImpl>();
public LibraryRootFolder()
{
MainLog.Instance.Verbose("LIBRARYINVENTORY", "Loading library inventory");
agentID = libOwner;
folderID = new LLUUID("00000112-000f-0000-0000-000100bba000");
name = "OpenSim Library";
parentID = LLUUID.Zero;
type = (short) 8;
version = (ushort) 1;
libraryFolders.Add(folderID, this);
LoadLibraries(Path.Combine(Util.inventoryDir(), "Libraries.xml"));
// CreateLibraryItems();
}
/// <summary>
/// Hardcoded item creation. Please don't add any more items here - future items should be created
/// in the xml in the bin/inventory folder.
/// </summary>
///
/// Commented the following out due to sending it all through xml, remove this section once this is provin to work stable.
///
//private void CreateLibraryItems()
//{
// InventoryItemBase item =
// CreateItem(new LLUUID("66c41e39-38f9-f75a-024e-585989bfaba9"),
// new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"), "Default Shape", "Default Shape",
// (int) AssetType.Bodypart, (int) InventoryType.Wearable, folderID);
// item.inventoryCurrentPermissions = 0;
// item.inventoryNextPermissions = 0;
// Items.Add(item.inventoryID, item);
// item =
// CreateItem(new LLUUID("77c41e39-38f9-f75a-024e-585989bfabc9"),
// new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"), "Default Skin", "Default Skin",
// (int) AssetType.Bodypart, (int) InventoryType.Wearable, folderID);
// item.inventoryCurrentPermissions = 0;
// item.inventoryNextPermissions = 0;
// Items.Add(item.inventoryID, item);
// item =
// CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-585989bf0000"),
// new LLUUID("00000000-38f9-1111-024e-222222111110"), "Default Shirt", "Default Shirt",
// (int) AssetType.Clothing, (int) InventoryType.Wearable, folderID);
// item.inventoryCurrentPermissions = 0;
// item.inventoryNextPermissions = 0;
// Items.Add(item.inventoryID, item);
// item =
// CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-5859892f1111"),
// new LLUUID("00000000-38f9-1111-024e-222222111120"), "Default Pants", "Default Pants",
// (int) AssetType.Clothing, (int) InventoryType.Wearable, folderID);
// item.inventoryCurrentPermissions = 0;
// item.inventoryNextPermissions = 0;
// Items.Add(item.inventoryID, item);
//}
public InventoryItemBase CreateItem(LLUUID inventoryID, LLUUID assetID, string name, string description,
int assetType, int invType, LLUUID parentFolderID)
{
InventoryItemBase item = new InventoryItemBase();
item.avatarID = libOwner;
item.creatorsID = libOwner;
item.inventoryID = inventoryID;
item.assetID = assetID;
item.inventoryDescription = description;
item.inventoryName = name;
item.assetType = assetType;
item.invType = invType;
item.parentFolderID = parentFolderID;
item.inventoryBasePermissions = 0x7FFFFFFF;
item.inventoryEveryOnePermissions = 0x7FFFFFFF;
item.inventoryCurrentPermissions = 0x7FFFFFFF;
item.inventoryNextPermissions = 0x7FFFFFFF;
return item;
}
/// <summary>
/// Use the asset set information at path to load assets
/// </summary>
/// <param name="path"></param>
/// <param name="assets"></param>
protected void LoadLibraries(string librariesControlPath)
{
MainLog.Instance.Verbose(
"LIBRARYINVENTORY", "Loading libraries control file {0}", librariesControlPath);
LoadFromFile(librariesControlPath, "Libraries control", ReadLibraryFromConfig);
}
/// <summary>
/// Read a library set from config
/// </summary>
/// <param name="config"></param>
protected void ReadLibraryFromConfig(IConfig config)
{
string foldersPath
= Path.Combine(
Util.inventoryDir(), config.GetString("foldersFile", ""));
LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig);
string itemsPath
= Path.Combine(
Util.inventoryDir(), config.GetString("itemsFile", ""));
LoadFromFile(itemsPath, "Library items", ReadItemFromConfig);
}
/// <summary>
/// Read a library inventory folder from a loaded configuration
/// </summary>
/// <param name="source"></param>
private void ReadFolderFromConfig(IConfig config)
{
InventoryFolderImpl folderInfo = new InventoryFolderImpl();
folderInfo.folderID = new LLUUID(config.GetString("folderID", folderID.ToString()));
folderInfo.name = config.GetString("name", "unknown");
folderInfo.parentID = new LLUUID(config.GetString("parentFolderID", folderID.ToString()));
folderInfo.type = (short)config.GetInt("type", 8);
folderInfo.agentID = libOwner;
folderInfo.version = 1;
if (libraryFolders.ContainsKey(folderInfo.parentID))
{
InventoryFolderImpl parentFolder = libraryFolders[folderInfo.parentID];
libraryFolders.Add(folderInfo.folderID, folderInfo);
parentFolder.SubFolders.Add(folderInfo.folderID, folderInfo);
// MainLog.Instance.Verbose(
// "LIBRARYINVENTORY", "Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID);
}
else
{
MainLog.Instance.Warn(
"LIBRARYINVENTORY",
"Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!",
folderInfo.name, folderInfo.folderID, folderInfo.parentID);
}
}
/// <summary>
/// Read a library inventory item metadata from a loaded configuration
/// </summary>
/// <param name="source"></param>
private void ReadItemFromConfig(IConfig config)
{
InventoryItemBase item = new InventoryItemBase();
item.avatarID = libOwner;
item.creatorsID = libOwner;
item.inventoryID = new LLUUID(config.GetString("inventoryID", folderID.ToString()));
item.assetID = new LLUUID(config.GetString("assetID", LLUUID.Random().ToString()));
item.parentFolderID = new LLUUID(config.GetString("folderID", folderID.ToString()));
item.inventoryDescription = config.GetString("description", "");
item.inventoryName = config.GetString("name", "");
item.assetType = config.GetInt("assetType", 0);
item.invType = config.GetInt("inventoryType", 0);
item.inventoryCurrentPermissions = (uint)config.GetLong("currentPermissions", 0x7FFFFFFF);
item.inventoryNextPermissions = (uint)config.GetLong("nextPermissions", 0x7FFFFFFF);
item.inventoryEveryOnePermissions = (uint)config.GetLong("everyonePermissions", 0x7FFFFFFF);
item.inventoryBasePermissions = (uint)config.GetLong("basePermissions", 0x7FFFFFFF);
if (libraryFolders.ContainsKey(item.parentFolderID))
{
InventoryFolderImpl parentFolder = libraryFolders[item.parentFolderID];
parentFolder.Items.Add(item.inventoryID, item);
}
else
{
MainLog.Instance.Warn(
"LIBRARYINVENTORY",
"Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!",
item.inventoryName, item.inventoryID, item.parentFolderID);
}
}
private delegate void ConfigAction(IConfig config);
/// <summary>
/// Load the given configuration at a path and perform an action on each Config contained within it
/// </summary>
/// <param name="path"></param>
/// <param name="fileDescription"></param>
/// <param name="action"></param>
private void LoadFromFile(string path, string fileDescription, ConfigAction action)
{
if (File.Exists(path))
{
try
{
XmlConfigSource source = new XmlConfigSource(path);
for (int i = 0; i < source.Configs.Count; i++)
{
action(source.Configs[i]);
}
}
catch (XmlException e)
{
MainLog.Instance.Error(
"LIBRARYINVENTORY", "Error loading {0} : {1}", path, e);
}
}
else
{
MainLog.Instance.Error(
"LIBRARYINVENTORY", "{0} file {1} does not exist!", fileDescription, path);
}
}
/// <summary>
/// Looks like a simple getter, but is written like this for some consistency with the other Request
/// methods in the superclass
/// </summary>
/// <returns></returns>
public Dictionary<LLUUID, InventoryFolderImpl> RequestSelfAndDescendentFolders()
{
return libraryFolders;
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using libsecondlife;
using Nini.Config;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Communications.Cache
{
/// <summary>
/// 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 : InventoryFolderImpl
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000");
/// <summary>
/// Holds the root library folder and all its descendents. This is really only used during inventory
/// setup so that we don't have to repeatedly search the tree of library folders.
/// </summary>
protected Dictionary<LLUUID, InventoryFolderImpl> libraryFolders
= new Dictionary<LLUUID, InventoryFolderImpl>();
public LibraryRootFolder()
{
m_log.Info("[LIBRARY INVENTORY]: Loading library inventory");
agentID = libOwner;
folderID = new LLUUID("00000112-000f-0000-0000-000100bba000");
name = "OpenSim Library";
parentID = LLUUID.Zero;
type = (short) 8;
version = (ushort) 1;
libraryFolders.Add(folderID, this);
LoadLibraries(Path.Combine(Util.inventoryDir(), "Libraries.xml"));
// CreateLibraryItems();
}
/// <summary>
/// Hardcoded item creation. Please don't add any more items here - future items should be created
/// in the xml in the bin/inventory folder.
/// </summary>
///
/// Commented the following out due to sending it all through xml, remove this section once this is provin to work stable.
///
//private void CreateLibraryItems()
//{
// InventoryItemBase item =
// CreateItem(new LLUUID("66c41e39-38f9-f75a-024e-585989bfaba9"),
// new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"), "Default Shape", "Default Shape",
// (int) AssetType.Bodypart, (int) InventoryType.Wearable, folderID);
// item.inventoryCurrentPermissions = 0;
// item.inventoryNextPermissions = 0;
// Items.Add(item.inventoryID, item);
// item =
// CreateItem(new LLUUID("77c41e39-38f9-f75a-024e-585989bfabc9"),
// new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"), "Default Skin", "Default Skin",
// (int) AssetType.Bodypart, (int) InventoryType.Wearable, folderID);
// item.inventoryCurrentPermissions = 0;
// item.inventoryNextPermissions = 0;
// Items.Add(item.inventoryID, item);
// item =
// CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-585989bf0000"),
// new LLUUID("00000000-38f9-1111-024e-222222111110"), "Default Shirt", "Default Shirt",
// (int) AssetType.Clothing, (int) InventoryType.Wearable, folderID);
// item.inventoryCurrentPermissions = 0;
// item.inventoryNextPermissions = 0;
// Items.Add(item.inventoryID, item);
// item =
// CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-5859892f1111"),
// new LLUUID("00000000-38f9-1111-024e-222222111120"), "Default Pants", "Default Pants",
// (int) AssetType.Clothing, (int) InventoryType.Wearable, folderID);
// item.inventoryCurrentPermissions = 0;
// item.inventoryNextPermissions = 0;
// Items.Add(item.inventoryID, item);
//}
public InventoryItemBase CreateItem(LLUUID inventoryID, LLUUID assetID, string name, string description,
int assetType, int invType, LLUUID parentFolderID)
{
InventoryItemBase item = new InventoryItemBase();
item.avatarID = libOwner;
item.creatorsID = libOwner;
item.inventoryID = inventoryID;
item.assetID = assetID;
item.inventoryDescription = description;
item.inventoryName = name;
item.assetType = assetType;
item.invType = invType;
item.parentFolderID = parentFolderID;
item.inventoryBasePermissions = 0x7FFFFFFF;
item.inventoryEveryOnePermissions = 0x7FFFFFFF;
item.inventoryCurrentPermissions = 0x7FFFFFFF;
item.inventoryNextPermissions = 0x7FFFFFFF;
return item;
}
/// <summary>
/// Use the asset set information at path to load assets
/// </summary>
/// <param name="path"></param>
/// <param name="assets"></param>
protected void LoadLibraries(string librariesControlPath)
{
m_log.InfoFormat(
"[LIBRARY INVENTORY]: Loading libraries control file {0}", librariesControlPath);
LoadFromFile(librariesControlPath, "Libraries control", ReadLibraryFromConfig);
}
/// <summary>
/// Read a library set from config
/// </summary>
/// <param name="config"></param>
protected void ReadLibraryFromConfig(IConfig config)
{
string foldersPath
= Path.Combine(
Util.inventoryDir(), config.GetString("foldersFile", System.String.Empty));
LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig);
string itemsPath
= Path.Combine(
Util.inventoryDir(), config.GetString("itemsFile", System.String.Empty));
LoadFromFile(itemsPath, "Library items", ReadItemFromConfig);
}
/// <summary>
/// Read a library inventory folder from a loaded configuration
/// </summary>
/// <param name="source"></param>
private void ReadFolderFromConfig(IConfig config)
{
InventoryFolderImpl folderInfo = new InventoryFolderImpl();
folderInfo.folderID = new LLUUID(config.GetString("folderID", folderID.ToString()));
folderInfo.name = config.GetString("name", "unknown");
folderInfo.parentID = new LLUUID(config.GetString("parentFolderID", folderID.ToString()));
folderInfo.type = (short)config.GetInt("type", 8);
folderInfo.agentID = libOwner;
folderInfo.version = 1;
if (libraryFolders.ContainsKey(folderInfo.parentID))
{
InventoryFolderImpl parentFolder = libraryFolders[folderInfo.parentID];
libraryFolders.Add(folderInfo.folderID, folderInfo);
parentFolder.SubFolders.Add(folderInfo.folderID, folderInfo);
// m_log.InfoFormat("[LIBRARY INVENTORY]: Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID);
}
else
{
m_log.WarnFormat(
"[LIBRARY INVENTORY]: Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!",
folderInfo.name, folderInfo.folderID, folderInfo.parentID);
}
}
/// <summary>
/// Read a library inventory item metadata from a loaded configuration
/// </summary>
/// <param name="source"></param>
private void ReadItemFromConfig(IConfig config)
{
InventoryItemBase item = new InventoryItemBase();
item.avatarID = libOwner;
item.creatorsID = libOwner;
item.inventoryID = new LLUUID(config.GetString("inventoryID", folderID.ToString()));
item.assetID = new LLUUID(config.GetString("assetID", LLUUID.Random().ToString()));
item.parentFolderID = new LLUUID(config.GetString("folderID", folderID.ToString()));
item.inventoryDescription = config.GetString("description", System.String.Empty);
item.inventoryName = config.GetString("name", System.String.Empty);
item.assetType = config.GetInt("assetType", 0);
item.invType = config.GetInt("inventoryType", 0);
item.inventoryCurrentPermissions = (uint)config.GetLong("currentPermissions", 0x7FFFFFFF);
item.inventoryNextPermissions = (uint)config.GetLong("nextPermissions", 0x7FFFFFFF);
item.inventoryEveryOnePermissions = (uint)config.GetLong("everyonePermissions", 0x7FFFFFFF);
item.inventoryBasePermissions = (uint)config.GetLong("basePermissions", 0x7FFFFFFF);
if (libraryFolders.ContainsKey(item.parentFolderID))
{
InventoryFolderImpl parentFolder = libraryFolders[item.parentFolderID];
parentFolder.Items.Add(item.inventoryID, item);
}
else
{
m_log.WarnFormat(
"[LIBRARY INVENTORY]: Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!",
item.inventoryName, item.inventoryID, item.parentFolderID);
}
}
private delegate void ConfigAction(IConfig config);
/// <summary>
/// Load the given configuration at a path and perform an action on each Config contained within it
/// </summary>
/// <param name="path"></param>
/// <param name="fileDescription"></param>
/// <param name="action"></param>
private void LoadFromFile(string path, string fileDescription, ConfigAction action)
{
if (File.Exists(path))
{
try
{
XmlConfigSource source = new XmlConfigSource(path);
for (int i = 0; i < source.Configs.Count; i++)
{
action(source.Configs[i]);
}
}
catch (XmlException e)
{
m_log.ErrorFormat("[LIBRARY INVENTORY]: Error loading {0} : {1}", path, e);
}
}
else
{
m_log.ErrorFormat("[LIBRARY INVENTORY]: {0} file {1} does not exist!", fileDescription, path);
}
}
/// <summary>
/// Looks like a simple getter, but is written like this for some consistency with the other Request
/// methods in the superclass
/// </summary>
/// <returns></returns>
public Dictionary<LLUUID, InventoryFolderImpl> RequestSelfAndDescendentFolders()
{
return libraryFolders;
}
}
}

View File

@ -1,107 +1,108 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Reflection;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Communications.Cache
{
public class SQLAssetServer : AssetServerBase
{
public SQLAssetServer(string pluginName)
{
AddPlugin(pluginName);
}
public SQLAssetServer(IAssetProvider assetProvider)
{
m_assetProvider = assetProvider;
}
public void AddPlugin(string FileName)
{
MainLog.Instance.Verbose("SQLAssetServer", "AssetStorage: Attempting to load " + FileName);
Assembly pluginAssembly = Assembly.LoadFrom(FileName);
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (!pluginType.IsAbstract)
{
Type typeInterface = pluginType.GetInterface("IAssetProvider", true);
if (typeInterface != null)
{
IAssetProvider plug =
(IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
m_assetProvider = plug;
m_assetProvider.Initialise();
MainLog.Instance.Verbose("AssetStorage",
"Added " + m_assetProvider.Name + " " +
m_assetProvider.Version);
}
}
}
}
public override void Close()
{
base.Close();
m_assetProvider.CommitAssets();
}
// rex new function for "replace assets" functionality
public override libsecondlife.LLUUID ExistsAsset(sbyte assetType, string name)
{
return m_assetProvider.ExistsAsset(assetType, name);
}
protected override AssetBase GetAsset(AssetRequest req)
{
AssetBase asset;
lock (m_syncLock)
{
asset = m_assetProvider.FetchAsset(req.AssetID);
}
return asset;
}
protected override void StoreAsset(AssetBase asset)
{
m_assetProvider.CreateAsset(asset);
}
protected override void CommitAssets()
{
m_assetProvider.CommitAssets();
}
}
}
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Reflection;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Communications.Cache
{
public class SQLAssetServer : AssetServerBase
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public SQLAssetServer(string pluginName)
{
AddPlugin(pluginName);
}
public SQLAssetServer(IAssetProvider assetProvider)
{
m_assetProvider = assetProvider;
}
public void AddPlugin(string FileName)
{
m_log.Info("[SQLAssetServer]: AssetStorage: Attempting to load " + FileName);
Assembly pluginAssembly = Assembly.LoadFrom(FileName);
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (!pluginType.IsAbstract)
{
Type typeInterface = pluginType.GetInterface("IAssetProvider", true);
if (typeInterface != null)
{
IAssetProvider plug =
(IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
m_assetProvider = plug;
m_assetProvider.Initialise();
m_log.Info("[AssetStorage]: " +
"Added " + m_assetProvider.Name + " " +
m_assetProvider.Version);
}
}
}
}
public override void Close()
{
base.Close();
m_assetProvider.CommitAssets();
}
// rex new function for "replace assets" functionality
public override libsecondlife.LLUUID ExistsAsset(sbyte assetType, string name)
{
return m_assetProvider.ExistsAsset(assetType, name);
}
protected override AssetBase GetAsset(AssetRequest req)
{
AssetBase asset;
lock (m_syncLock)
{
asset = m_assetProvider.FetchAsset(req.AssetID);
}
return asset;
}
protected override void StoreAsset(AssetBase asset)
{
m_assetProvider.CreateAsset(asset);
}
protected override void CommitAssets()
{
m_assetProvider.CommitAssets();
}
}
}

View File

@ -1,368 +1,372 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Collections.Generic;
using libsecondlife;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Communications.Cache
{
public class UserProfileCacheService
{
// Fields
private readonly CommunicationsManager m_parent;
private readonly Dictionary<LLUUID, CachedUserInfo> m_userProfiles = new Dictionary<LLUUID, CachedUserInfo>();
public LibraryRootFolder libraryRoot = new LibraryRootFolder();
public RexWorldAssetsFolder worldlibraryRoot = null; // rex added
// Methods
public UserProfileCacheService(CommunicationsManager parent)
{
m_parent = parent;
// rex, added worldlibrary
if (GlobalSettings.Instance.ConfigSource.Configs["Startup"].GetBoolean("worldlibraryfolder", true))
{
worldlibraryRoot = new RexWorldAssetsFolder(m_parent.AssetCache);
libraryRoot.CreateNewSubFolder(new LLUUID("00000112-000f-0000-0000-000100bba005"), "World Library", (ushort)8);
}
// rexend
}
/// <summary>
/// A new user has moved into a region in this instance
/// so get info from servers
/// </summary>
/// <param name="userID"></param>
public void AddNewUser(LLUUID userID)
{
// Potential fix - Multithreading issue.
lock (m_userProfiles)
{
if (!m_userProfiles.ContainsKey(userID))
{
CachedUserInfo userInfo = new CachedUserInfo(m_parent);
userInfo.UserProfile = m_parent.UserService.GetUserProfile(userID, "");
if (userInfo.UserProfile != null)
{
// The request itself will occur when the agent finishes logging on to the region
// so there's no need to do it here.
//RequestInventoryForUser(userID, userInfo);
m_userProfiles.Add(userID, userInfo);
}
else
{
MainLog.Instance.Error("USERCACHE", "User profile for user {0} not found", userID);
}
}
}
}
//Rex mode
/// <summary>
/// A new user has moved into a region in this instance
/// so get info from servers
/// </summary>
/// <param name="userID"></param>
public void AddNewUser(LLUUID userID, string authAddr)
{
// Potential fix - Multithreading issue.
lock (m_userProfiles)
{
if (!m_userProfiles.ContainsKey(userID))
{
CachedUserInfo userInfo = new CachedUserInfo(m_parent);
userInfo.UserProfile = m_parent.UserService.GetUserProfile(userID, authAddr);
if (userInfo.UserProfile != null)
{
//RequestInventoryForUser(userID, userInfo);
// The request itself will occur when the agent finishes logging on to the region
// so there's no need to do it here.
//RequestInventoryForUser(userID, userInfo);
m_userProfiles.Add(userID, userInfo);
}
else
{
System.Console.WriteLine("CACHE", "User profile for user not found");
}
}
}
}
public void UpdateUserInventory(LLUUID userID)
{
CachedUserInfo userInfo = GetUserDetails(userID);
if (userInfo != null)
{
RequestInventoryForUser(userID, userInfo);
}
}
public CachedUserInfo GetUserDetails(LLUUID userID)
{
if (m_userProfiles.ContainsKey(userID))
return m_userProfiles[userID];
else
return null;
}
public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType,
string folderName, LLUUID parentID)
{
CachedUserInfo userProfile;
if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
{
if (userProfile.RootFolder != null)
{
if (userProfile.RootFolder.folderID == parentID)
{
InventoryFolderImpl createdFolder =
userProfile.RootFolder.CreateNewSubFolder(folderID, folderName, folderType);
if (createdFolder != null)
{
InventoryFolderBase createdBaseFolder = new InventoryFolderBase();
createdBaseFolder.agentID = createdFolder.agentID;
createdBaseFolder.folderID = createdFolder.folderID;
createdBaseFolder.name = createdFolder.name;
createdBaseFolder.parentID = createdFolder.parentID;
createdBaseFolder.type = createdFolder.type;
createdBaseFolder.version = createdFolder.version;
m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder);
}
}
else
{
InventoryFolderImpl folder = userProfile.RootFolder.HasSubFolder(parentID);
if (folder != null)
{
folder.CreateNewSubFolder(folderID, folderName, folderType);
}
}
}
}
}
public void HandleUpdateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort type, string name,
LLUUID parentID)
{
CachedUserInfo userProfile;
if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
{
if (userProfile.RootFolder != null)
{
InventoryFolderBase baseFolder = new InventoryFolderBase();
baseFolder.agentID = remoteClient.AgentId;
baseFolder.folderID = folderID;
baseFolder.name = name;
baseFolder.parentID = parentID;
baseFolder.type = (short) type;
baseFolder.version = userProfile.RootFolder.version;
m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, baseFolder);
}
}
}
public void HandleMoveInventoryFolder(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID)
{
CachedUserInfo userProfile;
if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
{
if (userProfile.RootFolder != null)
{
InventoryFolderBase baseFolder = new InventoryFolderBase();
baseFolder.agentID = remoteClient.AgentId;
baseFolder.folderID = folderID;
baseFolder.parentID = parentID;
m_parent.InventoryService.MoveInventoryFolder(remoteClient.AgentId, baseFolder);
}
}
}
/// <summary>
/// Tell the client about the various child items and folders contained in the requested folder.
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="folderID"></param>
/// <param name="ownerID"></param>
/// <param name="fetchFolders"></param>
/// <param name="fetchItems"></param>
/// <param name="sortOrder"></param>
public void HandleFetchInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID,
bool fetchFolders, bool fetchItems, int sortOrder)
{
// XXX We're not handling sortOrder yet!
InventoryFolderImpl fold = null;
// rex, added worldassetfolder
if (worldlibraryRoot != null)
{
if (folderID == worldlibraryRoot.folderID)
{
remoteClient.SendInventoryFolderDetails(
worldlibraryRoot.agentID, worldlibraryRoot.folderID, worldlibraryRoot.RequestListOfItems(),
worldlibraryRoot.RequestListOfFolders(), fetchFolders, fetchItems);
return;
}
if ((fold = worldlibraryRoot.HasSubFolder(folderID)) != null)
{
worldlibraryRoot.UpdateWorldAssetFolders();
remoteClient.SendInventoryFolderDetails(
worldlibraryRoot.agentID, folderID, fold.RequestListOfItems(),
fold.RequestListOfFolders(), fetchFolders, fetchItems);
return;
}
}
// rex-end
if (folderID == libraryRoot.folderID)
{
remoteClient.SendInventoryFolderDetails(
libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems(),
libraryRoot.RequestListOfFolders(), fetchFolders, fetchItems);
return;
}
if ((fold = libraryRoot.HasSubFolder(folderID)) != null)
{
remoteClient.SendInventoryFolderDetails(
libraryRoot.agentID, folderID, fold.RequestListOfItems(),
fold.RequestListOfFolders(), fetchFolders, fetchItems);
return;
}
CachedUserInfo userProfile;
if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
{
if (userProfile.RootFolder != null)
{
if (userProfile.RootFolder.folderID == folderID)
{
remoteClient.SendInventoryFolderDetails(
remoteClient.AgentId, folderID, userProfile.RootFolder.RequestListOfItems(),
userProfile.RootFolder.RequestListOfFolders(),
fetchFolders, fetchItems);
return;
}
else
{
if ((fold = userProfile.RootFolder.HasSubFolder(folderID)) != null)
{
remoteClient.SendInventoryFolderDetails(
remoteClient.AgentId, folderID, fold.RequestListOfItems(),
fold.RequestListOfFolders(), fetchFolders, fetchItems);
return;
}
}
}
else
{
MainLog.Instance.Error(
"INVENTORYCACHE", "Could not find root folder for user {0}", remoteClient.Name);
return;
}
}
else
{
MainLog.Instance.Error(
"INVENTORYCACHE",
"Could not find user profile for {0} for folder {1}",
remoteClient.Name, folderID);
return;
}
// If we've reached this point then we couldn't find the folder, even though the client thinks
// it exists
MainLog.Instance.Error(
"INVENTORYCACHE",
"Could not find folder {0} for user {1}",
folderID, remoteClient.Name);
}
public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, LLUUID folderID)
{
CachedUserInfo userProfile;
if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
{
if (userProfile.RootFolder != null)
{
InventoryFolderImpl subFolder = userProfile.RootFolder.HasSubFolder(folderID);
if (subFolder != null)
{
List<InventoryItemBase> items = subFolder.RequestListOfItems();
foreach (InventoryItemBase item in items)
{
userProfile.DeleteItem(remoteClient.AgentId, item);
}
}
}
}
}
public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID)
{
if (ownerID == libraryRoot.agentID)
{
//Console.WriteLine("request info for library item");
return;
}
CachedUserInfo userProfile;
if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
{
if (userProfile.RootFolder != null)
{
InventoryItemBase item = userProfile.RootFolder.HasItem(itemID);
if (item != null)
{
remoteClient.SendInventoryItemDetails(ownerID, item);
}
}
}
}
private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo)
{
m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive);
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using libsecondlife;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Communications.Cache
{
public class UserProfileCacheService
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Fields
private readonly CommunicationsManager m_parent;
private readonly Dictionary<LLUUID, CachedUserInfo> m_userProfiles = new Dictionary<LLUUID, CachedUserInfo>();
public LibraryRootFolder libraryRoot = new LibraryRootFolder();
public RexWorldAssetsFolder worldlibraryRoot = null; // rex added
// Methods
public UserProfileCacheService(CommunicationsManager parent)
{
m_parent = parent;
// rex, added worldlibrary
if (GlobalSettings.Instance.ConfigSource.Configs["Startup"].GetBoolean("worldlibraryfolder", true))
{
worldlibraryRoot = new RexWorldAssetsFolder(m_parent.AssetCache);
libraryRoot.CreateNewSubFolder(new LLUUID("00000112-000f-0000-0000-000100bba005"), "World Library", (ushort)8);
}
// rexend
}
/// <summary>
/// A new user has moved into a region in this instance
/// so get info from servers
/// </summary>
/// <param name="userID"></param>
public void AddNewUser(LLUUID userID)
{
// Potential fix - Multithreading issue.
lock (m_userProfiles)
{
if (!m_userProfiles.ContainsKey(userID))
{
CachedUserInfo userInfo = new CachedUserInfo(m_parent);
userInfo.UserProfile = m_parent.UserService.GetUserProfile(userID, "");
if (userInfo.UserProfile != null)
{
// The request itself will occur when the agent finishes logging on to the region
// so there's no need to do it here.
//RequestInventoryForUser(userID, userInfo);
m_userProfiles.Add(userID, userInfo);
}
else
{
m_log.ErrorFormat("[USERCACHE]: User profile for user {0} not found", userID);
}
}
}
}
//Rex mode
/// <summary>
/// A new user has moved into a region in this instance
/// so get info from servers
/// </summary>
/// <param name="userID"></param>
public void AddNewUser(LLUUID userID, string authAddr)
{
// Potential fix - Multithreading issue.
lock (m_userProfiles)
{
if (!m_userProfiles.ContainsKey(userID))
{
CachedUserInfo userInfo = new CachedUserInfo(m_parent);
userInfo.UserProfile = m_parent.UserService.GetUserProfile(userID, authAddr);
if (userInfo.UserProfile != null)
{
//RequestInventoryForUser(userID, userInfo);
// The request itself will occur when the agent finishes logging on to the region
// so there's no need to do it here.
//RequestInventoryForUser(userID, userInfo);
m_userProfiles.Add(userID, userInfo);
}
else
{
System.Console.WriteLine("CACHE", "User profile for user not found");
}
}
}
}
public void UpdateUserInventory(LLUUID userID)
{
CachedUserInfo userInfo = GetUserDetails(userID);
if (userInfo != null)
{
RequestInventoryForUser(userID, userInfo);
}
}
public CachedUserInfo GetUserDetails(LLUUID userID)
{
if (m_userProfiles.ContainsKey(userID))
return m_userProfiles[userID];
else
return null;
}
public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType,
string folderName, LLUUID parentID)
{
CachedUserInfo userProfile;
if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
{
if (userProfile.RootFolder != null)
{
if (userProfile.RootFolder.folderID == parentID)
{
InventoryFolderImpl createdFolder =
userProfile.RootFolder.CreateNewSubFolder(folderID, folderName, folderType);
if (createdFolder != null)
{
InventoryFolderBase createdBaseFolder = new InventoryFolderBase();
createdBaseFolder.agentID = createdFolder.agentID;
createdBaseFolder.folderID = createdFolder.folderID;
createdBaseFolder.name = createdFolder.name;
createdBaseFolder.parentID = createdFolder.parentID;
createdBaseFolder.type = createdFolder.type;
createdBaseFolder.version = createdFolder.version;
m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder);
}
}
else
{
InventoryFolderImpl folder = userProfile.RootFolder.HasSubFolder(parentID);
if (folder != null)
{
folder.CreateNewSubFolder(folderID, folderName, folderType);
}
}
}
}
}
public void HandleUpdateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort type, string name,
LLUUID parentID)
{
CachedUserInfo userProfile;
if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
{
if (userProfile.RootFolder != null)
{
InventoryFolderBase baseFolder = new InventoryFolderBase();
baseFolder.agentID = remoteClient.AgentId;
baseFolder.folderID = folderID;
baseFolder.name = name;
baseFolder.parentID = parentID;
baseFolder.type = (short) type;
baseFolder.version = userProfile.RootFolder.version;
m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, baseFolder);
}
}
}
public void HandleMoveInventoryFolder(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID)
{
CachedUserInfo userProfile;
if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
{
if (userProfile.RootFolder != null)
{
InventoryFolderBase baseFolder = new InventoryFolderBase();
baseFolder.agentID = remoteClient.AgentId;
baseFolder.folderID = folderID;
baseFolder.parentID = parentID;
m_parent.InventoryService.MoveInventoryFolder(remoteClient.AgentId, baseFolder);
}
}
}
/// <summary>
/// Tell the client about the various child items and folders contained in the requested folder.
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="folderID"></param>
/// <param name="ownerID"></param>
/// <param name="fetchFolders"></param>
/// <param name="fetchItems"></param>
/// <param name="sortOrder"></param>
public void HandleFetchInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID,
bool fetchFolders, bool fetchItems, int sortOrder)
{
// XXX We're not handling sortOrder yet!
InventoryFolderImpl fold = null;
// rex, added worldassetfolder
if (worldlibraryRoot != null)
{
if (folderID == worldlibraryRoot.folderID)
{
remoteClient.SendInventoryFolderDetails(
worldlibraryRoot.agentID, worldlibraryRoot.folderID, worldlibraryRoot.RequestListOfItems(),
worldlibraryRoot.RequestListOfFolders(), fetchFolders, fetchItems);
return;
}
if ((fold = worldlibraryRoot.HasSubFolder(folderID)) != null)
{
worldlibraryRoot.UpdateWorldAssetFolders();
remoteClient.SendInventoryFolderDetails(
worldlibraryRoot.agentID, folderID, fold.RequestListOfItems(),
fold.RequestListOfFolders(), fetchFolders, fetchItems);
return;
}
}
// rex-end
if (folderID == libraryRoot.folderID)
{
remoteClient.SendInventoryFolderDetails(
libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems(),
libraryRoot.RequestListOfFolders(), fetchFolders, fetchItems);
return;
}
if ((fold = libraryRoot.HasSubFolder(folderID)) != null)
{
remoteClient.SendInventoryFolderDetails(
libraryRoot.agentID, folderID, fold.RequestListOfItems(),
fold.RequestListOfFolders(), fetchFolders, fetchItems);
return;
}
CachedUserInfo userProfile;
if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
{
if (userProfile.RootFolder != null)
{
if (userProfile.RootFolder.folderID == folderID)
{
remoteClient.SendInventoryFolderDetails(
remoteClient.AgentId, folderID, userProfile.RootFolder.RequestListOfItems(),
userProfile.RootFolder.RequestListOfFolders(),
fetchFolders, fetchItems);
return;
}
else
{
if ((fold = userProfile.RootFolder.HasSubFolder(folderID)) != null)
{
remoteClient.SendInventoryFolderDetails(
remoteClient.AgentId, folderID, fold.RequestListOfItems(),
fold.RequestListOfFolders(), fetchFolders, fetchItems);
return;
}
}
}
else
{
m_log.ErrorFormat("[INVENTORYCACHE]: Could not find root folder for user {0}", remoteClient.Name);
return;
}
}
else
{
m_log.ErrorFormat("[INVENTORYCACHE]: " +
"Could not find user profile for {0} for folder {1}",
remoteClient.Name, folderID);
return;
}
// If we've reached this point then we couldn't find the folder, even though the client thinks
// it exists
m_log.ErrorFormat("[INVENTORYCACHE]: " +
"Could not find folder {0} for user {1}",
folderID, remoteClient.Name);
}
public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, LLUUID folderID)
{
// m_log.InfoFormat("[INVENTORYCACHE]: Purging folder {0} for {1} uuid {2}",
// folderID, remoteClient.Name, remoteClient.AgentId);
CachedUserInfo userProfile;
if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
{
if (userProfile.RootFolder != null)
{
InventoryFolderImpl subFolder = userProfile.RootFolder.HasSubFolder(folderID);
if (subFolder != null)
{
List<InventoryItemBase> items = subFolder.RequestListOfItems();
foreach (InventoryItemBase item in items)
{
userProfile.DeleteItem(remoteClient.AgentId, item);
}
}
}
}
}
public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID)
{
if (ownerID == libraryRoot.agentID)
{
//Console.WriteLine("request info for library item");
return;
}
CachedUserInfo userProfile;
if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
{
if (userProfile.RootFolder != null)
{
InventoryItemBase item = userProfile.RootFolder.HasItem(itemID);
if (item != null)
{
remoteClient.SendInventoryItemDetails(ownerID, item);
}
}
}
}
private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo)
{
m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,44 +1,45 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using libsecondlife;
namespace OpenSim.Region.Capabilities
{
[LLSDType("MAP")]
public class LLSDAssetUploadComplete
{
public string new_asset = "";
public LLUUID new_inventory_item = LLUUID.Zero;
public string state = "";
//public bool success = false;
public LLSDAssetUploadComplete()
{
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using libsecondlife;
using System;
namespace OpenSim.Region.Capabilities
{
[LLSDType("MAP")]
public class LLSDAssetUploadComplete
{
public string new_asset = String.Empty;
public LLUUID new_inventory_item = LLUUID.Zero;
public string state = String.Empty;
//public bool success = false;
public LLSDAssetUploadComplete()
{
}
}
}

View File

@ -1,46 +1,46 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using libsecondlife;
namespace OpenSim.Region.Capabilities
{
[LLSDMap]
public class LLSDAssetUploadRequest
{
public string asset_type = "";
public string description = "";
public LLUUID folder_id = LLUUID.Zero;
public string inventory_type = "";
public string name = "";
public LLSDAssetUploadRequest()
{
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using libsecondlife;
namespace OpenSim.Region.Capabilities
{
[LLSDMap]
public class LLSDAssetUploadRequest
{
public string asset_type = System.String.Empty;
public string description = System.String.Empty;
public LLUUID folder_id = LLUUID.Zero;
public string inventory_type = System.String.Empty;
public string name = System.String.Empty;
public LLSDAssetUploadRequest()
{
}
}
}

View File

@ -1,41 +1,41 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace OpenSim.Region.Capabilities
{
[LLSDMap]
public class LLSDAssetUploadResponse
{
public string uploader = "";
public string state = "";
public LLSDAssetUploadResponse()
{
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace OpenSim.Region.Capabilities
{
[LLSDMap]
public class LLSDAssetUploadResponse
{
public string uploader = System.String.Empty;
public string state = System.String.Empty;
public LLSDAssetUploadResponse()
{
}
}
}

View File

@ -1,48 +1,50 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace OpenSim.Region.Capabilities
{
[LLSDType("MAP")]
public class LLSDCapsDetails
{
public string MapLayer = "";
public string NewFileAgentInventory = "";
//public string EventQueueGet = "";
// public string RequestTextureDownload = "";
// public string ChatSessionRequest = "";
public string UpdateNotecardAgentInventory = "";
public string UpdateScriptAgentInventory = "";
public string UpdateScriptTaskInventory = "";
// public string ParcelVoiceInfoRequest = "";
public LLSDCapsDetails()
{
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
namespace OpenSim.Region.Capabilities
{
[LLSDType("MAP")]
public class LLSDCapsDetails
{
public string MapLayer = String.Empty;
public string NewFileAgentInventory = String.Empty;
//public string EventQueueGet = String.Empty;
// public string RequestTextureDownload = String.Empty;
// public string ChatSessionRequest = String.Empty;
public string UpdateNotecardAgentInventory = String.Empty;
public string UpdateScriptAgentInventory = String.Empty;
public string UpdateScriptTaskInventory = String.Empty;
// public string ParcelVoiceInfoRequest = String.Empty;
public LLSDCapsDetails()
{
}
}
}

View File

@ -1,42 +1,42 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using libsecondlife;
namespace OpenSim.Region.Capabilities
{
[LLSDMap]
public class LLSDItemUpdate
{
public LLUUID item_id;
public LLSDItemUpdate()
{
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using libsecondlife;
namespace OpenSim.Region.Capabilities
{
[LLSDMap]
public class LLSDItemUpdate
{
public LLUUID item_id;
public LLSDItemUpdate()
{
}
}
}

View File

@ -1,40 +1,40 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace OpenSim.Region.Capabilities
{
[LLSDType("MAP")]
public class LLSDMapRequest
{
public int Flags = 0;
public LLSDMapRequest()
{
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace OpenSim.Region.Capabilities
{
[LLSDType("MAP")]
public class LLSDMapRequest
{
public int Flags = 0;
public LLSDMapRequest()
{
}
}
}

View File

@ -1,32 +1,32 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace OpenSim.Region.Capabilities
{
public delegate TResponse LLSDMethod<TRequest, TResponse>(TRequest request);
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace OpenSim.Region.Capabilities
{
public delegate TResponse LLSDMethod<TRequest, TResponse>(TRequest request);
}

View File

@ -1,69 +1,69 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Collections;
using System.IO;
using System.Text;
using OpenSim.Framework.Servers;
namespace OpenSim.Region.Capabilities
{
public class LLSDStreamhandler<TRequest, TResponse> : BaseStreamHandler
where TRequest : new()
{
private LLSDMethod<TRequest, TResponse> m_method;
public LLSDStreamhandler(string httpMethod, string path, LLSDMethod<TRequest, TResponse> method)
: base(httpMethod, path)
{
m_method = method;
}
public override byte[] Handle(string path, Stream request)
{
//Encoding encoding = Encoding.UTF8;
//StreamReader streamReader = new StreamReader(request, false);
//string requestBody = streamReader.ReadToEnd();
//streamReader.Close();
// libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap)
// libsecondlife.StructuredData.LLSDParser.DeserializeXml(new XmlTextReader(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));
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Collections;
using System.IO;
using System.Text;
using OpenSim.Framework.Servers;
namespace OpenSim.Region.Capabilities
{
public class LLSDStreamhandler<TRequest, TResponse> : BaseStreamHandler
where TRequest : new()
{
private LLSDMethod<TRequest, TResponse> m_method;
public LLSDStreamhandler(string httpMethod, string path, LLSDMethod<TRequest, TResponse> method)
: base(httpMethod, path)
{
m_method = method;
}
public override byte[] Handle(string path, Stream request)
{
//Encoding encoding = Encoding.UTF8;
//StreamReader streamReader = new StreamReader(request, false);
//string requestBody = streamReader.ReadToEnd();
//streamReader.Close();
// libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap)
// libsecondlife.StructuredData.LLSDParser.DeserializeXml(new XmlTextReader(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));
}
}
}

View File

@ -1,51 +1,51 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using libsecondlife;
namespace OpenSim.Region.Capabilities
{
[LLSDMap]
public class LLSDTaskScriptUpdate
{
/// <summary>
/// The item containing the script to update
/// </summary>
public LLUUID item_id;
/// <summary>
/// The task containing the script
/// </summary>
public LLUUID task_id;
/// <summary>
/// Signals whether the script is currently active
/// </summary>
public int is_script_running;
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using libsecondlife;
namespace OpenSim.Region.Capabilities
{
[LLSDMap]
public class LLSDTaskScriptUpdate
{
/// <summary>
/// The item containing the script to update
/// </summary>
public LLUUID item_id;
/// <summary>
/// The task containing the script
/// </summary>
public LLUUID task_id;
/// <summary>
/// Signals whether the script is currently active
/// </summary>
public int is_script_running;
}
}

View File

@ -1,228 +1,260 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using libsecondlife;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
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 UserProfileCacheService m_userProfileCacheService;
public UserProfileCacheService UserProfileCacheService
{
get { return m_userProfileCacheService; }
}
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)
{
m_networkServersInfo = serversInfo;
m_assetCache = assetCache;
m_userProfileCacheService = new UserProfileCacheService(this);
m_transactionsManager = new AssetTransactionManager(this, dumpAssetsToFile);
}
public void doCreate(string[] cmmdParams)
{
switch (cmmdParams[0])
{
case "user":
string firstName;
string lastName;
string password;
uint regX = 1000;
uint regY = 1000;
if (cmmdParams.Length < 2)
{
firstName = MainLog.Instance.CmdPrompt("First name", "Default");
lastName = MainLog.Instance.CmdPrompt("Last name", "User");
password = MainLog.Instance.PasswdPrompt("Password");
regX = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region X", "1000"));
regY = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region Y", "1000"));
}
else
{
firstName = cmmdParams[1];
lastName = cmmdParams[2];
password = cmmdParams[3];
regX = Convert.ToUInt32(cmmdParams[4]);
regY = Convert.ToUInt32(cmmdParams[5]);
}
AddUser(firstName, lastName, password, regX, regY);
break;
}
}
public LLUUID AddUser(string firstName, string lastName, string password, uint regX, uint regY)
{
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + "");
m_userService.AddUserProfile(firstName, lastName, md5PasswdHash, regX, regY);
UserProfileData userProf = UserService.GetUserProfile(firstName, lastName, "");
if (userProf == null)
{
return LLUUID.Zero;
}
else
{
m_inventoryService.CreateNewUserInventory(userProf.UUID);
System.Console.WriteLine("Created new inventory set for " + firstName + " " + lastName);
return userProf.UUID;
}
}
#region Friend Methods
/// <summary>
/// Adds a new friend to the database for XUser
/// </summary>
/// <param name="friendlistowner">The agent that who's friends list is being added to</param>
/// <param name="friend">The agent that being added to the friends list of the friends list owner</param>
/// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param>
public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms)
{
m_userService.AddNewUserFriend(friendlistowner, friend, perms);
}
/// <summary>
/// Delete friend on friendlistowner's friendlist.
/// </summary>
/// <param name="friendlistowner">The agent that who's friends list is being updated</param>
/// <param name="friend">The Ex-friend agent</param>
public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend)
{
m_userService.RemoveUserFriend(friendlistowner, friend);
}
/// <summary>
/// Update permissions for friend on friendlistowner's friendlist.
/// </summary>
/// <param name="friendlistowner">The agent that who's friends list is being updated</param>
/// <param name="friend">The agent that is getting or loosing permissions</param>
/// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param>
public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms)
{
m_userService.UpdateUserFriendPerms(friendlistowner, friend, perms);
}
/// <summary>
/// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for LLUUID friendslistowner
/// </summary>
/// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param>
public List<FriendListItem> GetUserFriendList(LLUUID friendlistowner)
{
return m_userService.GetUserFriendList(friendlistowner);
}
#endregion
#region Packet Handlers
public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client)
{
if (uuid == m_userProfileCacheService.libraryRoot.agentID)
{
remote_client.SendNameReply(uuid, "Mr", "OpenSim");
}
else
{
UserProfileData profileData = m_userService.GetUserProfile(uuid, "");
if (profileData != null)
{
LLUUID profileId = profileData.UUID;
string firstname = profileData.username;
string lastname = profileData.surname;
remote_client.SendNameReply(profileId, firstname, lastname);
}
}
}
public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID queryID, string query)
{
List<AvatarPickerAvatar> pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query);
return pickerlist;
}
#endregion
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using libsecondlife;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
namespace OpenSim.Framework.Communications
{
public class CommunicationsManager
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
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 UserProfileCacheService m_userProfileCacheService;
public UserProfileCacheService UserProfileCacheService
{
get { return m_userProfileCacheService; }
}
// protected AgentAssetTransactionsManager m_transactionsManager;
// public AgentAssetTransactionsManager 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)
{
m_networkServersInfo = serversInfo;
m_assetCache = assetCache;
m_userProfileCacheService = new UserProfileCacheService(this);
// m_transactionsManager = new AgentAssetTransactionsManager(this, dumpAssetsToFile);
}
public void doCreate(string[] cmmdParams)
{
switch (cmmdParams[0])
{
case "user":
string firstName;
string lastName;
string password;
uint regX = 1000;
uint regY = 1000;
if (cmmdParams.Length < 2)
{
firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
password = MainConsole.Instance.PasswdPrompt("Password");
regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", "1000"));
regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", "1000"));
}
else
{
firstName = cmmdParams[1];
lastName = cmmdParams[2];
password = cmmdParams[3];
regX = Convert.ToUInt32(cmmdParams[4]);
regY = Convert.ToUInt32(cmmdParams[5]);
}
if (null == m_userService.GetUserProfile(firstName, lastName))
{
AddUser(firstName, lastName, password, regX, regY);
}
else
{
m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", firstName, lastName);
}
break;
}
}
/// <summary>
/// Persistently adds a user to OpenSim.
/// </summary>
/// <param name="firstName"></param>
/// <param name="lastName"></param>
/// <param name="password"></param>
/// <param name="regX"></param>
/// <param name="regY"></param>
/// <returns>The UUID of the added user. Returns null if the add was unsuccessful</returns>
public LLUUID AddUser(string firstName, string lastName, string password, uint regX, uint regY)
{
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty);
m_userService.AddUserProfile(firstName, lastName, md5PasswdHash, regX, regY);
UserProfileData userProf = UserService.GetUserProfile(firstName, lastName, "");
if (userProf == null)
{
return LLUUID.Zero;
}
else
{
m_inventoryService.CreateNewUserInventory(userProf.UUID);
System.Console.WriteLine("[USERS]: Created new inventory set for " + firstName + " " + lastName);
return userProf.UUID;
}
}
#region Friend Methods
/// <summary>
/// Adds a new friend to the database for XUser
/// </summary>
/// <param name="friendlistowner">The agent that who's friends list is being added to</param>
/// <param name="friend">The agent that being added to the friends list of the friends list owner</param>
/// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param>
public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms)
{
m_userService.AddNewUserFriend(friendlistowner, friend, perms);
}
/// <summary>
/// Logs off a user and does the appropriate communications
/// </summary>
/// <param name="userid"></param>
/// <param name="regionid"></param>
/// <param name="regionhandle"></param>
/// <param name="posx"></param>
/// <param name="posy"></param>
/// <param name="posz"></param>
public void LogOffUser(LLUUID userid, LLUUID regionid, ulong regionhandle, float posx, float posy, float posz)
{
m_userService.LogOffUser(userid, regionid, regionhandle, posx, posy, posz);
}
/// <summary>
/// Delete friend on friendlistowner's friendlist.
/// </summary>
/// <param name="friendlistowner">The agent that who's friends list is being updated</param>
/// <param name="friend">The Ex-friend agent</param>
public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend)
{
m_userService.RemoveUserFriend(friendlistowner, friend);
}
/// <summary>
/// Update permissions for friend on friendlistowner's friendlist.
/// </summary>
/// <param name="friendlistowner">The agent that who's friends list is being updated</param>
/// <param name="friend">The agent that is getting or loosing permissions</param>
/// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param>
public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms)
{
m_userService.UpdateUserFriendPerms(friendlistowner, friend, perms);
}
/// <summary>
/// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for LLUUID friendslistowner
/// </summary>
/// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param>
public List<FriendListItem> GetUserFriendList(LLUUID friendlistowner)
{
return m_userService.GetUserFriendList(friendlistowner);
}
#endregion
#region Packet Handlers
public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client)
{
if (uuid == m_userProfileCacheService.libraryRoot.agentID)
{
remote_client.SendNameReply(uuid, "Mr", "OpenSim");
}
else
{
UserProfileData profileData = m_userService.GetUserProfile(uuid, "");
if (profileData != null)
{
LLUUID profileId = profileData.UUID;
string firstname = profileData.username;
string lastname = profileData.surname;
remote_client.SendNameReply(profileId, firstname, lastname);
}
}
}
public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID queryID, string query)
{
List<AvatarPickerAvatar> pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query);
return pickerlist;
}
#endregion
}
}

View File

@ -1,48 +1,50 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using libsecondlife;
namespace OpenSim.Framework.Communications
{
public interface IInterRegionCommunications
{
string rdebugRegionName { get; set; }
bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData);
bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData);
bool RegionUp(SearializableRegionInfo region, ulong regionhandle);
bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData);
bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying);
bool ExpectPrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isFlying);
bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId);
bool AcknowledgePrimCrossed(ulong regionHandle, LLUUID primID);
void TellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID);
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using libsecondlife;
namespace OpenSim.Framework.Communications
{
public interface IInterRegionCommunications
{
string rdebugRegionName { get; set; }
bool Available { get; }
void CheckRegion(string address, uint port);
bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData);
bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData);
bool RegionUp(SearializableRegionInfo region, ulong regionhandle);
bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData);
bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying);
bool ExpectPrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isFlying);
bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId);
bool AcknowledgePrimCrossed(ulong regionHandle, LLUUID primID);
bool TellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID);
}
}

View File

@ -1,55 +1,100 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Collections.Generic;
using libsecondlife;
using OpenSim.Framework.Communications.Cache;
namespace OpenSim.Framework.Communications
{
public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolderImpl folderInfo);
public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo);
public interface IInventoryServices
{
void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack);
void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder);
void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder);
void AddNewInventoryItem(LLUUID userID, InventoryItemBase item);
void DeleteInventoryItem(LLUUID userID, InventoryItemBase item);
void CreateNewUserInventory(LLUUID user);
/// <summary>
/// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree)
/// </summary>
/// <param name="userID"></param>
/// <returns></returns>
List<InventoryFolderBase> RequestFirstLevelFolders(LLUUID userID);
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Collections.Generic;
using libsecondlife;
using OpenSim.Framework.Communications.Cache;
namespace OpenSim.Framework.Communications
{
public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolderImpl folderInfo);
public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo);
/// <summary>
/// Defines all the operations one can perform on a user's inventory.
/// </summary>
public interface IInventoryServices
{
void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack);
/// <summary>
/// Add a new folder to the given user's inventory
/// </summary>
/// <param name="userID"></param>
/// <param name="folder"></param>
void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder);
void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder);
/// <summary>
/// Add a new item to the given user's inventory
/// </summary>
/// <param name="userID"></param>
/// <param name="item"></param>
void AddNewInventoryItem(LLUUID userID, InventoryItemBase item);
/// <summary>
/// Delete an item from the given user's inventory
/// </summary>
/// <param name="userID"></param>
/// <param name="item"></param>
void DeleteInventoryItem(LLUUID userID, InventoryItemBase item);
/// <summary>
/// Create a new inventory for the given user
/// </summary>
/// <param name="user"></param>
void CreateNewUserInventory(LLUUID user);
bool HasInventoryForUser(LLUUID userID);
/// <summary>
/// Retrieve the root inventory folder for the given user.
/// </summary>
/// <param name="userID"></param>
/// <returns>null if no root folder was found</returns>
InventoryFolderBase RequestRootFolder(LLUUID userID);
/// <summary>
/// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree)
/// for the given user.
/// </summary>
/// <param name="userID"></param>
/// <returns></returns>
List<InventoryFolderBase> RequestFirstLevelFolders(LLUUID userID);
/// <summary>
/// Returns the named folder in that users inventory, returns null if folder is not found.
/// </summary>
/// <param name="userID"></param>
/// <param name="folderName"></param>
/// <returns></returns>
InventoryFolderBase RequestNamedFolder(LLUUID userID, string folderName);
}
}

View File

@ -1,390 +1,389 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Reflection;
using libsecondlife;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Communications
{
public abstract class InventoryServiceBase : IInventoryServices
{
protected Dictionary<string, IInventoryData> m_plugins = new Dictionary<string, IInventoryData>();
//protected IAssetServer m_assetServer;
public InventoryServiceBase()
{
//m_assetServer = assetServer;
}
/// <summary>
/// Adds a new user server plugin - plugins will be requested in the order they were loaded.
/// </summary>
/// <param name="FileName">The filename to the user server plugin DLL</param>
public void AddPlugin(string FileName)
{
if (!String.IsNullOrEmpty(FileName))
{
MainLog.Instance.Verbose("AGENTINVENTORY", "Inventorystorage: Attempting to load " + FileName);
Assembly pluginAssembly = Assembly.LoadFrom(FileName);
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (!pluginType.IsAbstract)
{
Type typeInterface = pluginType.GetInterface("IInventoryData", true);
if (typeInterface != null)
{
IInventoryData plug =
(IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
plug.Initialise();
m_plugins.Add(plug.getName(), plug);
MainLog.Instance.Verbose("AGENTINVENTORY", "Added IInventoryData Interface");
}
}
}
}
}
public List<InventoryFolderBase> RequestFirstLevelFolders(Guid rawUserID)
{
LLUUID userID = new LLUUID(rawUserID);
return RequestFirstLevelFolders(userID);
}
/// <summary>
/// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree)
/// </summary>
/// <param name="userID"></param>
/// <returns></returns>
public List<InventoryFolderBase> RequestFirstLevelFolders(LLUUID userID)
{
List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>();
InventoryFolderBase rootFolder = null;
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
rootFolder = plugin.Value.getUserRootFolder(userID);
if (rootFolder != null)
{
MainLog.Instance.Verbose(
"INVENTORY",
"Found root folder for user with ID " + userID + ". Retrieving inventory contents.");
inventoryList = plugin.Value.getInventoryFolders(rootFolder.folderID);
inventoryList.Insert(0, rootFolder);
return inventoryList;
}
}
MainLog.Instance.Warn(
"INVENTORY", "Could not find a root folder belonging to user with ID " + userID);
return inventoryList;
}
/// <summary>
/// Get the root folder for a user
/// </summary>
/// <param name="userID"></param>
/// <returns>null if no root folder was found</returns>
public InventoryFolderBase RequestUsersRoot(LLUUID userID)
{
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
return plugin.Value.getUserRootFolder(userID);
}
return null;
}
/// <summary>
///
/// </summary>
public void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder)
{
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
plugin.Value.moveInventoryFolder(folder);
}
}
/// <summary>
///
/// </summary>
/// <param name="parentFolderID"></param>
/// <returns></returns>
public List<InventoryFolderBase> RequestSubFolders(LLUUID parentFolderID)
{
List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>();
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
return plugin.Value.getInventoryFolders(parentFolderID);
}
return inventoryList;
}
public List<InventoryItemBase> RequestFolderItems(LLUUID folderID)
{
List<InventoryItemBase> itemsList = new List<InventoryItemBase>();
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
itemsList = plugin.Value.getInventoryInFolder(folderID);
return itemsList;
}
return itemsList;
}
public void AddFolder(InventoryFolderBase folder)
{
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
plugin.Value.addInventoryFolder(folder);
}
}
public void MoveFolder(InventoryFolderBase folder)
{
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
plugin.Value.moveInventoryFolder(folder);
}
}
public void AddItem(InventoryItemBase item)
{
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
plugin.Value.addInventoryItem(item);
}
}
public void DeleteItem(InventoryItemBase item)
{
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
plugin.Value.deleteInventoryItem(item.inventoryID);
}
}
/// <summary>
///
/// </summary>
/// <param name="inventory"></param>
public void AddNewInventorySet(UsersInventory inventory)
{
foreach (InventoryFolderBase folder in inventory.Folders.Values)
{
AddFolder(folder);
}
}
/// <summary>
/// Create a new set of inventory folders for the given user.
/// </summary>
/// <param name="user"></param>
public void CreateNewUserInventory(LLUUID user)
{
InventoryFolderBase existingRootFolder = RequestUsersRoot(user);
if (null != existingRootFolder)
{
MainLog.Instance.Error(
"AGENTINVENTORY",
"Did not create a new inventory for user {0} since they already have "
+ "a root inventory folder with id {1}", user, existingRootFolder);
}
else
{
UsersInventory inven = new UsersInventory();
inven.CreateNewInventorySet(user);
AddNewInventorySet(inven);
}
}
public class UsersInventory
{
public Dictionary<LLUUID, InventoryFolderBase> Folders = new Dictionary<LLUUID, InventoryFolderBase>();
public Dictionary<LLUUID, InventoryItemBase> Items = new Dictionary<LLUUID, InventoryItemBase>();
public UsersInventory()
{
}
public virtual void CreateNewInventorySet(LLUUID user)
{
InventoryFolderBase folder = new InventoryFolderBase();
folder.parentID = LLUUID.Zero;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "My Inventory";
folder.type = 8;
folder.version = 1;
Folders.Add(folder.folderID, folder);
LLUUID rootFolder = folder.folderID;
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Accessories";
folder.type = 8;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Animations";
folder.type = 20;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "BodyParts";
folder.type = 13;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Clothing";
folder.type = 5;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Gestures";
folder.type = 21;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Landmarks";
folder.type = 3;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Lost And Found";
folder.type = 3;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Notecards";
folder.type = 7;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Objects";
folder.type = 6;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Photo Album";
folder.type = 15;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Scripts";
folder.type = 10;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Sounds";
folder.type = 1;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Textures";
folder.type = 0;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Trash";
folder.type = 14;
folder.version = 1;
Folders.Add(folder.folderID, folder);
}
}
public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack,
InventoryItemInfo itemCallBack);
public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder);
public abstract void MoveExistingInventoryFolder(InventoryFolderBase folder);
public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item);
public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item);
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Reflection;
using libsecondlife;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Communications
{
public abstract class InventoryServiceBase : IInventoryServices
{
private static readonly log4net.ILog m_log
= log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
protected Dictionary<string, IInventoryData> m_plugins = new Dictionary<string, IInventoryData>();
#region Plugin methods
/// <summary>
/// Adds a new user server plugin - plugins will be requested in the order they were loaded.
/// </summary>
/// <param name="FileName">The filename to the user server plugin DLL</param>
public void AddPlugin(string FileName)
{
if (!String.IsNullOrEmpty(FileName))
{
m_log.Info("[AGENTINVENTORY]: Inventorystorage: Attempting to load " + FileName);
Assembly pluginAssembly = Assembly.LoadFrom(FileName);
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (!pluginType.IsAbstract)
{
Type typeInterface = pluginType.GetInterface("IInventoryData", true);
if (typeInterface != null)
{
IInventoryData plug =
(IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
plug.Initialise();
m_plugins.Add(plug.getName(), plug);
m_log.Info("[AGENTINVENTORY]: Added IInventoryData Interface");
}
}
}
}
}
#endregion
#region IInventoryServices methods
// See IInventoryServices
public List<InventoryFolderBase> RequestFirstLevelFolders(Guid rawUserID)
{
LLUUID userID = new LLUUID(rawUserID);
return RequestFirstLevelFolders(userID);
}
// See IInventoryServices
public List<InventoryFolderBase> RequestFirstLevelFolders(LLUUID userID)
{
List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>();
InventoryFolderBase rootFolder = null;
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
rootFolder = plugin.Value.getUserRootFolder(userID);
if (rootFolder != null)
{
m_log.Info(
"[INVENTORY]: Found root folder for user with ID " + userID + ". Retrieving inventory contents.");
inventoryList = plugin.Value.getInventoryFolders(rootFolder.folderID);
inventoryList.Insert(0, rootFolder);
return inventoryList;
}
}
m_log.Warn(
"[INVENTORY]: Could not find a root folder belonging to user with ID " + userID);
return inventoryList;
}
// See IInventoryServices
public InventoryFolderBase RequestUsersRoot(LLUUID userID)
{
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
return plugin.Value.getUserRootFolder(userID);
}
return null;
}
// See IInventoryServices
public void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder)
{
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
plugin.Value.moveInventoryFolder(folder);
}
}
public virtual bool HasInventoryForUser(LLUUID userID)
{
return false;
}
// See IInventoryServices
public InventoryFolderBase RequestRootFolder(LLUUID userID)
{
return RequestUsersRoot(userID);
}
// See IInventoryServices
public virtual InventoryFolderBase RequestNamedFolder(LLUUID userID, string folderName)
{
return null;
}
// See IInventoryServices
public void CreateNewUserInventory(LLUUID user)
{
InventoryFolderBase existingRootFolder = RequestUsersRoot(user);
if (null != existingRootFolder)
{
m_log.ErrorFormat("[AGENTINVENTORY]: " +
"Did not create a new inventory for user {0} since they already have "
+ "a root inventory folder with id {1}", user, existingRootFolder);
}
else
{
UsersInventory inven = new UsersInventory();
inven.CreateNewInventorySet(user);
AddNewInventorySet(inven);
}
}
public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack,
InventoryItemInfo itemCallBack);
public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder);
public abstract void MoveExistingInventoryFolder(InventoryFolderBase folder);
public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item);
public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item);
#endregion
#region Methods used by GridInventoryService
public List<InventoryFolderBase> RequestSubFolders(LLUUID parentFolderID)
{
List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>();
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
return plugin.Value.getInventoryFolders(parentFolderID);
}
return inventoryList;
}
public List<InventoryItemBase> RequestFolderItems(LLUUID folderID)
{
List<InventoryItemBase> itemsList = new List<InventoryItemBase>();
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
itemsList = plugin.Value.getInventoryInFolder(folderID);
return itemsList;
}
return itemsList;
}
#endregion
protected void AddFolder(InventoryFolderBase folder)
{
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
plugin.Value.addInventoryFolder(folder);
}
}
protected void MoveFolder(InventoryFolderBase folder)
{
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
plugin.Value.moveInventoryFolder(folder);
}
}
protected void AddItem(InventoryItemBase item)
{
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
plugin.Value.addInventoryItem(item);
}
}
protected void DeleteItem(InventoryItemBase item)
{
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
plugin.Value.deleteInventoryItem(item.inventoryID);
}
}
private void AddNewInventorySet(UsersInventory inventory)
{
foreach (InventoryFolderBase folder in inventory.Folders.Values)
{
AddFolder(folder);
}
}
private class UsersInventory
{
public Dictionary<LLUUID, InventoryFolderBase> Folders = new Dictionary<LLUUID, InventoryFolderBase>();
public Dictionary<LLUUID, InventoryItemBase> Items = new Dictionary<LLUUID, InventoryItemBase>();
public virtual void CreateNewInventorySet(LLUUID user)
{
InventoryFolderBase folder = new InventoryFolderBase();
folder.parentID = LLUUID.Zero;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "My Inventory";
folder.type = 8;
folder.version = 1;
Folders.Add(folder.folderID, folder);
LLUUID rootFolder = folder.folderID;
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Accessories";
folder.type = 8;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Animations";
folder.type = 20;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "BodyParts";
folder.type = 13;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Clothing";
folder.type = 5;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Gestures";
folder.type = 21;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Landmarks";
folder.type = 3;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Lost And Found";
folder.type = 3;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Notecards";
folder.type = 7;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Objects";
folder.type = 6;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Photo Album";
folder.type = 15;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Scripts";
folder.type = 10;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Sounds";
folder.type = 1;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Textures";
folder.type = 0;
folder.version = 1;
Folders.Add(folder.folderID, folder);
folder = new InventoryFolderBase();
folder.parentID = rootFolder;
folder.agentID = user;
folder.folderID = LLUUID.Random();
folder.name = "Trash";
folder.type = 14;
folder.version = 1;
Folders.Add(folder.folderID, folder);
}
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,65 +1,65 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly : AssemblyTitle("OpenGrid.Framework.Communications")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("")]
[assembly : AssemblyProduct("OpenGrid.Framework.Communications")]
[assembly : AssemblyCopyright("Copyright © 2007")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly : ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly : Guid("13e7c396-78a9-4a5c-baf2-6f980ea75d95")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly : AssemblyTitle("OpenGrid.Framework.Communications")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("")]
[assembly : AssemblyProduct("OpenGrid.Framework.Communications")]
[assembly : AssemblyCopyright("Copyright © OpenSimulator.org Developers 2007-2008")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly : ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly : Guid("13e7c396-78a9-4a5c-baf2-6f980ea75d95")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]

View File

@ -1,443 +1,446 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
using System.Web;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Communications
{
/// <summary>
/// Implementation of a generic REST client
/// </summary>
/// <remarks>
/// This class is a generic implementation of a REST (Representational State Transfer) web service. This
/// class is designed to execute both synchroneously and asynchroneously.
///
/// Internally the implementation works as a two stage asynchroneous web-client.
/// When the request is initiated, RestClient will query asynchroneously for for a web-response,
/// sleeping until the initial response is returned by the server. Once the initial response is retrieved
/// the second stage of asynchroneous requests will be triggered, in an attempt to read of the response
/// object into a memorystream as a sequence of asynchroneous reads.
///
/// The asynchronisity of RestClient is designed to move as much processing into the back-ground, allowing
/// other threads to execute, while it waits for a response from the web-service. RestClient it self, can be
/// invoked by the caller in either synchroneous mode or asynchroneous mode.
/// </remarks>
public class RestClient
{
private string realuri;
#region member variables
/// <summary>
/// The base Uri of the web-service e.g. http://www.google.com
/// </summary>
private string _url;
/// <summary>
/// Path elements of the query
/// </summary>
private List<string> _pathElements = new List<string>();
/// <summary>
/// Parameter elements of the query, e.g. min=34
/// </summary>
private Dictionary<string, string> _parameterElements = new Dictionary<string, string>();
/// <summary>
/// Request method. E.g. GET, POST, PUT or DELETE
/// </summary>
private string _method;
/// <summary>
/// Temporary buffer used to store bytes temporarily as they come in from the server
/// </summary>
private byte[] _readbuf;
/// <summary>
/// MemoryStream representing the resultiong resource
/// </summary>
private Stream _resource;
/// <summary>
/// WebRequest object, held as a member variable
/// </summary>
private HttpWebRequest _request;
/// <summary>
/// WebResponse object, held as a member variable, so we can close it
/// </summary>
private HttpWebResponse _response;
/// <summary>
/// This flag will help block the main synchroneous method, in case we run in synchroneous mode
/// </summary>
public static ManualResetEvent _allDone = new ManualResetEvent(false);
/// <summary>
/// Default time out period
/// </summary>
private const int DefaultTimeout = 10*1000; // 10 seconds timeout
/// <summary>
/// Default Buffer size of a block requested from the web-server
/// </summary>
private const int BufferSize = 4096; // Read blocks of 4 KB.
/// <summary>
/// if an exception occours during async processing, we need to save it, so it can be
/// rethrown on the primary thread;
/// </summary>
private Exception _asyncException;
#endregion member variables
#region constructors
/// <summary>
/// Instantiate a new RestClient
/// </summary>
/// <param name="url">Web-service to query, e.g. http://osgrid.org:8003</param>
public RestClient(string url)
{
_url = url;
_readbuf = new byte[BufferSize];
_resource = new MemoryStream();
_request = null;
_response = null;
_lock = new object();
}
private object _lock;
#endregion constructors
/// <summary>
/// Add a path element to the query, e.g. assets
/// </summary>
/// <param name="element">path entry</param>
public void AddResourcePath(string element)
{
if (isSlashed(element))
_pathElements.Add(element.Substring(0, element.Length - 1));
else
_pathElements.Add(element);
}
/// <summary>
/// Add a query parameter to the Url
/// </summary>
/// <param name="name">Name of the parameter, e.g. min</param>
/// <param name="value">Value of the parameter, e.g. 42</param>
public void AddQueryParameter(string name, string value)
{
_parameterElements.Add(HttpUtility.UrlEncode(name), HttpUtility.UrlEncode(value));
}
/// <summary>
/// Add a query parameter to the Url
/// </summary>
/// <param name="name">Name of the parameter, e.g. min</param>
public void AddQueryParameter(string name)
{
_parameterElements.Add(HttpUtility.UrlEncode(name), null);
}
/// <summary>
/// Web-Request method, e.g. GET, PUT, POST, DELETE
/// </summary>
public string RequestMethod
{
get { return _method; }
set { _method = value; }
}
/// <summary>
/// True if string contains a trailing slash '/'
/// </summary>
/// <param name="s">string to be examined</param>
/// <returns>true if slash is present</returns>
private bool isSlashed(string s)
{
return s.Substring(s.Length - 1, 1) == "/";
}
/// <summary>
/// return a slash or blank. A slash will be returned if the string does not contain one
/// </summary>
/// <param name="s">stromg to be examined</param>
/// <returns>slash '/' if not already present</returns>
private string slash(string s)
{
return isSlashed(s) ? "" : "/";
}
/// <summary>
/// Build a Uri based on the initial Url, path elements and parameters
/// </summary>
/// <returns>fully constructed Uri</returns>
private Uri buildUri()
{
StringBuilder sb = new StringBuilder();
sb.Append(_url);
foreach (string e in _pathElements)
{
sb.Append("/");
sb.Append(e);
}
bool firstElement = true;
foreach (KeyValuePair<string, string> kv in _parameterElements)
{
if (firstElement)
{
sb.Append("?");
firstElement = false;
}
else
sb.Append("&");
sb.Append(kv.Key);
if (kv.Value != null && kv.Value.Length != 0)
{
sb.Append("=");
sb.Append(kv.Value);
}
}
realuri = sb.ToString();
MainLog.Instance.Verbose("REST", "RestURL: {0}", realuri);
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>
/// <param name="ar"></param>
private void StreamIsReadyDelegate(IAsyncResult ar)
{
try
{
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);
// TODO! Implement timeout, without killing the server
//ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true);
}
else
{
s.Close();
_allDone.Set();
}
}
catch (Exception e)
{
_allDone.Set();
_asyncException = e;
}
}
/// <summary>
/// Async method, invoked when the initial response if received from the server
/// </summary>
/// <param name="ar"></param>
private void ResponseIsReadyDelegate(IAsyncResult ar)
{
try
{
// grab response
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);
// TODO! Implement timeout, without killing the server
// wait until completed, or we timed out
// ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true);
}
catch (Exception e)
{
_allDone.Set();
_asyncException = e;
}
}
// Abort the request if the timer fires.
private static void TimeoutCallback(object state, bool timedOut)
{
if (timedOut)
{
HttpWebRequest request = state as HttpWebRequest;
if (request != null)
{
request.Abort();
}
}
}
#endregion Async communications with server
/// <summary>
/// Perform synchroneous request
/// </summary>
public Stream Request()
{
lock (_lock)
{
_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();
Stream src = _response.GetResponseStream();
int length = src.Read(_readbuf, 0, BufferSize);
while (length > 0)
{
_resource.Write(_readbuf, 0, length);
length = src.Read(_readbuf, 0, BufferSize);
}
// TODO! Implement timeout, without killing the server
// this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted
//ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true);
// _allDone.WaitOne();
if (_response != null)
_response.Close();
if (_asyncException != null)
throw _asyncException;
if (_resource != null)
{
_resource.Flush();
_resource.Seek(0, SeekOrigin.Begin);
}
return _resource;
}
}
public Stream Request(Stream src)
{
_request = (HttpWebRequest) WebRequest.Create(buildUri());
_request.KeepAlive = false;
_request.ContentType = "application/xml";
_request.Timeout = 900000;
_request.Method = RequestMethod;
_asyncException = null;
_request.ContentLength = src.Length;
MainLog.Instance.Verbose("REST", "Request Length {0}", _request.ContentLength);
MainLog.Instance.Verbose("REST", "Sending Web Request {0}", buildUri());
src.Seek(0, SeekOrigin.Begin);
MainLog.Instance.Verbose("REST", "Seek is ok");
Stream dst = _request.GetRequestStream();
MainLog.Instance.Verbose("REST", "GetRequestStream is ok");
byte[] buf = new byte[1024];
int length = src.Read(buf, 0, 1024);
MainLog.Instance.Verbose("REST", "First Read is ok");
while (length > 0)
{
dst.Write(buf, 0, length);
length = src.Read(buf, 0, 1024);
}
_response = (HttpWebResponse) _request.GetResponse();
// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request);
// TODO! Implement timeout, without killing the server
// this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted
//ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true);
return null;
}
#region Async Invocation
public IAsyncResult BeginRequest(AsyncCallback callback, object state)
{
/// <summary>
/// In case, we are invoked asynchroneously this object will keep track of the state
/// </summary>
AsyncResult<Stream> ar = new AsyncResult<Stream>(callback, state);
ThreadPool.QueueUserWorkItem(RequestHelper, ar);
return ar;
}
public Stream EndRequest(IAsyncResult asyncResult)
{
AsyncResult<Stream> ar = (AsyncResult<Stream>) asyncResult;
// Wait for operation to complete, then return result or
// throw exception
return ar.EndInvoke();
}
private void RequestHelper(Object asyncResult)
{
// We know that it's really an AsyncResult<DateTime> object
AsyncResult<Stream> ar = (AsyncResult<Stream>) asyncResult;
try
{
// Perform the operation; if sucessful set the result
Stream s = Request();
ar.SetAsCompleted(s, false);
}
catch (Exception e)
{
// If operation fails, set the exception
ar.HandleException(e, false);
}
}
#endregion Async Invocation
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
using System.Web;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Communications
{
/// <summary>
/// Implementation of a generic REST client
/// </summary>
/// <remarks>
/// This class is a generic implementation of a REST (Representational State Transfer) web service. This
/// class is designed to execute both synchroneously and asynchroneously.
///
/// Internally the implementation works as a two stage asynchroneous web-client.
/// When the request is initiated, RestClient will query asynchroneously for for a web-response,
/// sleeping until the initial response is returned by the server. Once the initial response is retrieved
/// the second stage of asynchroneous requests will be triggered, in an attempt to read of the response
/// object into a memorystream as a sequence of asynchroneous reads.
///
/// The asynchronisity of RestClient is designed to move as much processing into the back-ground, allowing
/// other threads to execute, while it waits for a response from the web-service. RestClient it self, can be
/// invoked by the caller in either synchroneous mode or asynchroneous mode.
/// </remarks>
public class RestClient
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private string realuri;
#region member variables
/// <summary>
/// The base Uri of the web-service e.g. http://www.google.com
/// </summary>
private string _url;
/// <summary>
/// Path elements of the query
/// </summary>
private List<string> _pathElements = new List<string>();
/// <summary>
/// Parameter elements of the query, e.g. min=34
/// </summary>
private Dictionary<string, string> _parameterElements = new Dictionary<string, string>();
/// <summary>
/// Request method. E.g. GET, POST, PUT or DELETE
/// </summary>
private string _method;
/// <summary>
/// Temporary buffer used to store bytes temporarily as they come in from the server
/// </summary>
private byte[] _readbuf;
/// <summary>
/// MemoryStream representing the resultiong resource
/// </summary>
private Stream _resource;
/// <summary>
/// WebRequest object, held as a member variable
/// </summary>
private HttpWebRequest _request;
/// <summary>
/// WebResponse object, held as a member variable, so we can close it
/// </summary>
private HttpWebResponse _response;
/// <summary>
/// This flag will help block the main synchroneous method, in case we run in synchroneous mode
/// </summary>
public static ManualResetEvent _allDone = new ManualResetEvent(false);
/// <summary>
/// Default time out period
/// </summary>
private const int DefaultTimeout = 10*1000; // 10 seconds timeout
/// <summary>
/// Default Buffer size of a block requested from the web-server
/// </summary>
private const int BufferSize = 4096; // Read blocks of 4 KB.
/// <summary>
/// if an exception occours during async processing, we need to save it, so it can be
/// rethrown on the primary thread;
/// </summary>
private Exception _asyncException;
#endregion member variables
#region constructors
/// <summary>
/// Instantiate a new RestClient
/// </summary>
/// <param name="url">Web-service to query, e.g. http://osgrid.org:8003</param>
public RestClient(string url)
{
_url = url;
_readbuf = new byte[BufferSize];
_resource = new MemoryStream();
_request = null;
_response = null;
_lock = new object();
}
private object _lock;
#endregion constructors
/// <summary>
/// Add a path element to the query, e.g. assets
/// </summary>
/// <param name="element">path entry</param>
public void AddResourcePath(string element)
{
if (isSlashed(element))
_pathElements.Add(element.Substring(0, element.Length - 1));
else
_pathElements.Add(element);
}
/// <summary>
/// Add a query parameter to the Url
/// </summary>
/// <param name="name">Name of the parameter, e.g. min</param>
/// <param name="value">Value of the parameter, e.g. 42</param>
public void AddQueryParameter(string name, string value)
{
_parameterElements.Add(HttpUtility.UrlEncode(name), HttpUtility.UrlEncode(value));
}
/// <summary>
/// Add a query parameter to the Url
/// </summary>
/// <param name="name">Name of the parameter, e.g. min</param>
public void AddQueryParameter(string name)
{
_parameterElements.Add(HttpUtility.UrlEncode(name), null);
}
/// <summary>
/// Web-Request method, e.g. GET, PUT, POST, DELETE
/// </summary>
public string RequestMethod
{
get { return _method; }
set { _method = value; }
}
/// <summary>
/// True if string contains a trailing slash '/'
/// </summary>
/// <param name="s">string to be examined</param>
/// <returns>true if slash is present</returns>
private bool isSlashed(string s)
{
return s.Substring(s.Length - 1, 1) == "/";
}
/// <summary>
/// return a slash or blank. A slash will be returned if the string does not contain one
/// </summary>
/// <param name="s">stromg to be examined</param>
/// <returns>slash '/' if not already present</returns>
private string slash(string s)
{
return isSlashed(s) ? String.Empty : "/";
}
/// <summary>
/// Build a Uri based on the initial Url, path elements and parameters
/// </summary>
/// <returns>fully constructed Uri</returns>
private Uri buildUri()
{
StringBuilder sb = new StringBuilder();
sb.Append(_url);
foreach (string e in _pathElements)
{
sb.Append("/");
sb.Append(e);
}
bool firstElement = true;
foreach (KeyValuePair<string, string> kv in _parameterElements)
{
if (firstElement)
{
sb.Append("?");
firstElement = false;
}
else
sb.Append("&");
sb.Append(kv.Key);
if (kv.Value != null && kv.Value.Length != 0)
{
sb.Append("=");
sb.Append(kv.Value);
}
}
realuri = sb.ToString();
m_log.InfoFormat("[REST]: RestURL: {0}", realuri);
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>
/// <param name="ar"></param>
private void StreamIsReadyDelegate(IAsyncResult ar)
{
try
{
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);
// TODO! Implement timeout, without killing the server
//ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true);
}
else
{
s.Close();
_allDone.Set();
}
}
catch (Exception e)
{
_allDone.Set();
_asyncException = e;
}
}
/// <summary>
/// Async method, invoked when the initial response if received from the server
/// </summary>
/// <param name="ar"></param>
private void ResponseIsReadyDelegate(IAsyncResult ar)
{
try
{
// grab response
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);
// TODO! Implement timeout, without killing the server
// wait until completed, or we timed out
// ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true);
}
catch (Exception e)
{
_allDone.Set();
_asyncException = e;
}
}
// Abort the request if the timer fires.
private static void TimeoutCallback(object state, bool timedOut)
{
if (timedOut)
{
HttpWebRequest request = state as HttpWebRequest;
if (request != null)
{
request.Abort();
}
}
}
#endregion Async communications with server
/// <summary>
/// Perform synchroneous request
/// </summary>
public Stream Request()
{
lock (_lock)
{
_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();
Stream src = _response.GetResponseStream();
int length = src.Read(_readbuf, 0, BufferSize);
while (length > 0)
{
_resource.Write(_readbuf, 0, length);
length = src.Read(_readbuf, 0, BufferSize);
}
// TODO! Implement timeout, without killing the server
// this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted
//ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true);
// _allDone.WaitOne();
if (_response != null)
_response.Close();
if (_asyncException != null)
throw _asyncException;
if (_resource != null)
{
_resource.Flush();
_resource.Seek(0, SeekOrigin.Begin);
}
return _resource;
}
}
public Stream Request(Stream src)
{
_request = (HttpWebRequest) WebRequest.Create(buildUri());
_request.KeepAlive = false;
_request.ContentType = "application/xml";
_request.Timeout = 900000;
_request.Method = RequestMethod;
_asyncException = null;
_request.ContentLength = src.Length;
m_log.InfoFormat("[REST]: Request Length {0}", _request.ContentLength);
m_log.InfoFormat("[REST]: Sending Web Request {0}", buildUri());
src.Seek(0, SeekOrigin.Begin);
m_log.Info("[REST]: Seek is ok");
Stream dst = _request.GetRequestStream();
m_log.Info("[REST]: GetRequestStream is ok");
byte[] buf = new byte[1024];
int length = src.Read(buf, 0, 1024);
m_log.Info("[REST]: First Read is ok");
while (length > 0)
{
dst.Write(buf, 0, length);
length = src.Read(buf, 0, 1024);
}
_response = (HttpWebResponse) _request.GetResponse();
// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request);
// TODO! Implement timeout, without killing the server
// this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted
//ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true);
return null;
}
#region Async Invocation
public IAsyncResult BeginRequest(AsyncCallback callback, object state)
{
/// <summary>
/// In case, we are invoked asynchroneously this object will keep track of the state
/// </summary>
AsyncResult<Stream> ar = new AsyncResult<Stream>(callback, state);
ThreadPool.QueueUserWorkItem(RequestHelper, ar);
return ar;
}
public Stream EndRequest(IAsyncResult asyncResult)
{
AsyncResult<Stream> ar = (AsyncResult<Stream>) asyncResult;
// Wait for operation to complete, then return result or
// throw exception
return ar.EndInvoke();
}
private void RequestHelper(Object asyncResult)
{
// We know that it's really an AsyncResult<DateTime> object
AsyncResult<Stream> ar = (AsyncResult<Stream>) asyncResult;
try
{
// Perform the operation; if sucessful set the result
Stream s = Request();
ar.SetAsCompleted(s, false);
}
catch (Exception e)
{
// If operation fails, set the exception
ar.HandleException(e, false);
}
}
#endregion Async Invocation
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,115 +1,117 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.IO;
using System.Net;
using System.Text;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Configuration.HTTP
{
public class HTTPConfiguration : IGenericConfig
{
private RemoteConfigSettings remoteConfigSettings;
private XmlConfiguration xmlConfig;
private string configFileName = "";
public HTTPConfiguration()
{
remoteConfigSettings = new RemoteConfigSettings("remoteconfig.xml");
xmlConfig = new XmlConfiguration();
}
public void SetFileName(string fileName)
{
configFileName = fileName;
}
public void LoadData()
{
try
{
StringBuilder sb = new StringBuilder();
byte[] buf = new byte[8192];
HttpWebRequest request =
(HttpWebRequest) WebRequest.Create(remoteConfigSettings.baseConfigURL + configFileName);
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
Stream resStream = response.GetResponseStream();
string tempString = null;
int count = 0;
do
{
count = resStream.Read(buf, 0, buf.Length);
if (count != 0)
{
tempString = Encoding.ASCII.GetString(buf, 0, count);
sb.Append(tempString);
}
} while (count > 0);
LoadDataFromString(sb.ToString());
}
catch (WebException)
{
MainLog.Instance.Warn("Unable to connect to remote configuration file (" +
remoteConfigSettings.baseConfigURL + configFileName +
"). Creating local file instead.");
xmlConfig.SetFileName(configFileName);
xmlConfig.LoadData();
}
}
public void LoadDataFromString(string data)
{
xmlConfig.LoadDataFromString(data);
}
public string GetAttribute(string attributeName)
{
return xmlConfig.GetAttribute(attributeName);
}
public bool SetAttribute(string attributeName, string attributeValue)
{
return true;
}
public void Commit()
{
}
public void Close()
{
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.IO;
using System.Net;
using System.Text;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Configuration.HTTP
{
public class HTTPConfiguration : IGenericConfig
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private RemoteConfigSettings remoteConfigSettings;
private XmlConfiguration xmlConfig;
private string configFileName = System.String.Empty;
public HTTPConfiguration()
{
remoteConfigSettings = new RemoteConfigSettings("remoteconfig.xml");
xmlConfig = new XmlConfiguration();
}
public void SetFileName(string fileName)
{
configFileName = fileName;
}
public void LoadData()
{
try
{
StringBuilder sb = new StringBuilder();
byte[] buf = new byte[8192];
HttpWebRequest request =
(HttpWebRequest) WebRequest.Create(remoteConfigSettings.baseConfigURL + configFileName);
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
Stream resStream = response.GetResponseStream();
string tempString = null;
int count = 0;
do
{
count = resStream.Read(buf, 0, buf.Length);
if (count != 0)
{
tempString = Encoding.ASCII.GetString(buf, 0, count);
sb.Append(tempString);
}
} while (count > 0);
LoadDataFromString(sb.ToString());
}
catch (WebException)
{
m_log.Warn("Unable to connect to remote configuration file (" +
remoteConfigSettings.baseConfigURL + configFileName +
"). Creating local file instead.");
xmlConfig.SetFileName(configFileName);
xmlConfig.LoadData();
}
}
public void LoadDataFromString(string data)
{
xmlConfig.LoadDataFromString(data);
}
public string GetAttribute(string attributeName)
{
return xmlConfig.GetAttribute(attributeName);
}
public bool SetAttribute(string attributeName, string attributeValue)
{
return true;
}
public void Commit()
{
}
public void Close()
{
}
}
}

View File

@ -1,62 +1,62 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace OpenSim.Framework.Configuration.HTTP
{
public class RemoteConfigSettings
{
private ConfigurationMember configMember;
public string baseConfigURL = "";
public RemoteConfigSettings(string filename)
{
configMember =
new ConfigurationMember(filename, "REMOTE CONFIG SETTINGS", loadConfigurationOptions,
handleIncomingConfiguration,true);
configMember.forceConfigurationPluginLibrary("OpenSim.Framework.Configuration.XML.dll");
configMember.performConfigurationRetrieve();
}
public void loadConfigurationOptions()
{
configMember.addConfigurationOption("base_config_url",
ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
"URL Containing Configuration Files", "http://localhost/", false);
}
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
{
if (configuration_key == "base_config_url")
{
baseConfigURL = (string) configuration_result;
}
return true;
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace OpenSim.Framework.Configuration.HTTP
{
public class RemoteConfigSettings
{
private ConfigurationMember configMember;
public string baseConfigURL = System.String.Empty;
public RemoteConfigSettings(string filename)
{
configMember =
new ConfigurationMember(filename, "REMOTE CONFIG SETTINGS", loadConfigurationOptions,
handleIncomingConfiguration,true);
configMember.forceConfigurationPluginLibrary("OpenSim.Framework.Configuration.XML.dll");
configMember.performConfigurationRetrieve();
}
public void loadConfigurationOptions()
{
configMember.addConfigurationOption("base_config_url",
ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
"URL Containing Configuration Files", "http://localhost/", false);
}
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
{
if (configuration_key == "base_config_url")
{
baseConfigURL = (string) configuration_result;
}
return true;
}
}
}

View File

@ -1,139 +1,139 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.IO;
using System.Xml;
namespace OpenSim.Framework.Configuration
{
public class XmlConfiguration : IGenericConfig
{
private XmlDocument doc;
private XmlNode rootNode;
private XmlNode configNode;
private string fileName;
private bool createdFile = false;
public void SetFileName(string file)
{
fileName = file;
}
private void LoadDataToClass()
{
rootNode = doc.FirstChild;
if (rootNode.Name != "Root")
throw new Exception("Error: Invalid .xml File. Missing <Root>");
configNode = rootNode.FirstChild;
if (configNode.Name != "Config")
throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>");
}
public void LoadData()
{
lock (this)
{
doc = new XmlDocument();
if (File.Exists(fileName))
{
XmlTextReader reader = new XmlTextReader(fileName);
reader.WhitespaceHandling = WhitespaceHandling.None;
doc.Load(reader);
reader.Close();
}
else
{
createdFile = true;
rootNode = doc.CreateNode(XmlNodeType.Element, "Root", "");
doc.AppendChild(rootNode);
configNode = doc.CreateNode(XmlNodeType.Element, "Config", "");
rootNode.AppendChild(configNode);
}
LoadDataToClass();
if (createdFile)
{
Commit();
}
}
}
public void LoadDataFromString(string data)
{
doc = new XmlDocument();
doc.LoadXml(data);
LoadDataToClass();
}
public string GetAttribute(string attributeName)
{
string result = null;
if (configNode.Attributes[attributeName] != null)
{
result = ((XmlAttribute) configNode.Attributes.GetNamedItem(attributeName)).Value;
}
return result;
}
public bool SetAttribute(string attributeName, string attributeValue)
{
if (configNode.Attributes[attributeName] != null)
{
((XmlAttribute) configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue;
}
else
{
XmlAttribute attri;
attri = doc.CreateAttribute(attributeName);
attri.Value = attributeValue;
configNode.Attributes.Append(attri);
}
return true;
}
public void Commit()
{
if (!Directory.Exists(Util.configDir()))
{
Directory.CreateDirectory(Util.configDir());
}
doc.Save(fileName);
}
public void Close()
{
configNode = null;
rootNode = null;
doc = null;
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.IO;
using System.Xml;
namespace OpenSim.Framework.Configuration
{
public class XmlConfiguration : IGenericConfig
{
private XmlDocument doc;
private XmlNode rootNode;
private XmlNode configNode;
private string fileName;
private bool createdFile = false;
public void SetFileName(string file)
{
fileName = file;
}
private void LoadDataToClass()
{
rootNode = doc.FirstChild;
if (rootNode.Name != "Root")
throw new Exception("Error: Invalid .xml File. Missing <Root>");
configNode = rootNode.FirstChild;
if (configNode.Name != "Config")
throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>");
}
public void LoadData()
{
lock (this)
{
doc = new XmlDocument();
if (File.Exists(fileName))
{
XmlTextReader reader = new XmlTextReader(fileName);
reader.WhitespaceHandling = WhitespaceHandling.None;
doc.Load(reader);
reader.Close();
}
else
{
createdFile = true;
rootNode = doc.CreateNode(XmlNodeType.Element, "Root", String.Empty);
doc.AppendChild(rootNode);
configNode = doc.CreateNode(XmlNodeType.Element, "Config", String.Empty);
rootNode.AppendChild(configNode);
}
LoadDataToClass();
if (createdFile)
{
Commit();
}
}
}
public void LoadDataFromString(string data)
{
doc = new XmlDocument();
doc.LoadXml(data);
LoadDataToClass();
}
public string GetAttribute(string attributeName)
{
string result = null;
if (configNode.Attributes[attributeName] != null)
{
result = ((XmlAttribute) configNode.Attributes.GetNamedItem(attributeName)).Value;
}
return result;
}
public bool SetAttribute(string attributeName, string attributeValue)
{
if (configNode.Attributes[attributeName] != null)
{
((XmlAttribute) configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue;
}
else
{
XmlAttribute attri;
attri = doc.CreateAttribute(attributeName);
attri.Value = attributeValue;
configNode.Attributes.Append(attri);
}
return true;
}
public void Commit()
{
if (!Directory.Exists(Util.configDir()))
{
Directory.CreateDirectory(Util.configDir());
}
doc.Save(fileName);
}
public void Close()
{
configNode = null;
rootNode = null;
doc = null;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,63 +1,65 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace OpenSim.Framework
{
public class ConfigurationOption
{
public delegate bool ConfigurationOptionShouldBeAsked(string configuration_key);
public enum ConfigurationTypes
{
TYPE_STRING,
TYPE_STRING_NOT_EMPTY,
TYPE_UINT16,
TYPE_UINT32,
TYPE_UINT64,
TYPE_INT16,
TYPE_INT32,
TYPE_INT64,
TYPE_IP_ADDRESS,
TYPE_CHARACTER,
TYPE_BOOLEAN,
TYPE_BYTE,
TYPE_LLUUID,
TYPE_LLVECTOR3,
TYPE_FLOAT,
TYPE_DOUBLE
} ;
public string configurationKey = "";
public string configurationQuestion = "";
public string configurationDefault = "";
public ConfigurationTypes configurationType = ConfigurationTypes.TYPE_STRING;
public bool configurationUseDefaultNoPrompt = false;
public ConfigurationOptionShouldBeAsked shouldIBeAsked; //Should I be asked now? Based on previous answers
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
namespace OpenSim.Framework
{
public class ConfigurationOption
{
public delegate bool ConfigurationOptionShouldBeAsked(string configuration_key);
public enum ConfigurationTypes
{
TYPE_STRING,
TYPE_STRING_NOT_EMPTY,
TYPE_UINT16,
TYPE_UINT32,
TYPE_UINT64,
TYPE_INT16,
TYPE_INT32,
TYPE_INT64,
TYPE_IP_ADDRESS,
TYPE_CHARACTER,
TYPE_BOOLEAN,
TYPE_BYTE,
TYPE_LLUUID,
TYPE_LLVECTOR3,
TYPE_FLOAT,
TYPE_DOUBLE
} ;
public string configurationKey = String.Empty;
public string configurationQuestion = String.Empty;
public string configurationDefault = String.Empty;
public ConfigurationTypes configurationType = ConfigurationTypes.TYPE_STRING;
public bool configurationUseDefaultNoPrompt = false;
public ConfigurationOptionShouldBeAsked shouldIBeAsked; //Should I be asked now? Based on previous answers
}
}

View File

@ -1,58 +1,58 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Reflection;
using System.Runtime.InteropServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly : AssemblyTitle("ServerConsole")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("")]
[assembly : AssemblyProduct("ServerConsole")]
[assembly : AssemblyCopyright("")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly : ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly : AssemblyVersion("1.0.*")]
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Reflection;
using System.Runtime.InteropServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly : AssemblyTitle("ServerConsole")]
[assembly : AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly : AssemblyProduct("ServerConsole")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly : ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly : AssemblyVersion("1.0.*")]

View File

@ -1,482 +1,424 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
namespace OpenSim.Framework.Console
{
public enum LogPriority : int
{
CRITICAL,
HIGH,
MEDIUM,
NORMAL,
LOW,
VERBOSE,
EXTRAVERBOSE
}
public class LogBase
{
private object m_syncRoot = new object();
private StreamWriter Log;
public conscmd_callback cmdparser;
public string componentname;
private bool m_verbose;
public LogBase(string LogFile, string componentname, conscmd_callback cmdparser, bool verbose)
{
this.componentname = componentname;
this.cmdparser = cmdparser;
m_verbose = verbose;
System.Console.WriteLine("Creating new local console");
if (String.IsNullOrEmpty(LogFile))
{
LogFile = componentname + ".log";
}
System.Console.WriteLine("Logs will be saved to current directory in " + LogFile);
Log = File.AppendText(LogFile);
Log.WriteLine("========================================================================");
Log.WriteLine(componentname + " Started at " + DateTime.Now.ToString());
}
public void Close()
{
Log.WriteLine("Shutdown at " + DateTime.Now.ToString());
Log.Close();
}
/// <summary>
/// derive an ansi color from a string, ignoring the darker colors.
/// This is used to help automatically bin component tags with colors
/// in various print functions.
/// </summary>
/// <param name="input">arbitrary string for input</param>
/// <returns>an ansii color</returns>
private ConsoleColor DeriveColor(string input)
{
int colIdx = (input.ToUpper().GetHashCode()%6) + 9;
return (ConsoleColor) colIdx;
}
/// <summary>
/// Sends a warning to the current log output
/// </summary>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Warn(string format, params object[] args)
{
WriteNewLine(ConsoleColor.Yellow, format, args);
return;
}
/// <summary>
/// Sends a warning to the current log output
/// </summary>
/// <param name="sender">The module that sent this message</param>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Warn(string sender, string format, params object[] args)
{
WritePrefixLine(DeriveColor(sender), sender);
WriteNewLine(ConsoleColor.Yellow, format, args);
return;
}
/// <summary>
/// Sends a notice to the current log output
/// </summary>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Notice(string format, params object[] args)
{
WriteNewLine(ConsoleColor.White, format, args);
return;
}
/// <summary>
/// Sends a notice to the current log output
/// </summary>
/// <param name="sender">The module that sent this message</param>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Notice(string sender, string format, params object[] args)
{
WritePrefixLine(DeriveColor(sender), sender);
WriteNewLine(ConsoleColor.White, format, args);
return;
}
/// <summary>
/// Sends an error to the current log output
/// </summary>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Error(string format, params object[] args)
{
WriteNewLine(ConsoleColor.Red, format, args);
return;
}
/// <summary>
/// Sends an error to the current log output
/// </summary>
/// <param name="sender">The module that sent this message</param>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Error(string sender, string format, params object[] args)
{
WritePrefixLine(DeriveColor(sender), sender);
Error(format, args);
return;
}
/// <summary>
/// Sends an informational message to the current log output
/// </summary>
/// <param name="sender">The module that sent this message</param>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Verbose(string sender, string format, params object[] args)
{
if (m_verbose)
{
WritePrefixLine(DeriveColor(sender), sender);
WriteNewLine(ConsoleColor.Gray, format, args);
return;
}
}
/// <summary>
/// Sends a status message to the current log output
/// </summary>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Status(string format, params object[] args)
{
WriteNewLine(ConsoleColor.Blue, format, args);
return;
}
/// <summary>
/// Sends a status message to the current log output
/// </summary>
/// <param name="sender">The module that sent this message</param>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Status(string sender, string format, params object[] args)
{
WritePrefixLine(DeriveColor(sender), sender);
WriteNewLine(ConsoleColor.Blue, format, args);
return;
}
[Conditional("DEBUG")]
public void Debug(string format, params object[] args)
{
WriteNewLine(ConsoleColor.Gray, format, args);
return;
}
[Conditional("DEBUG")]
public void Debug(string sender, string format, params object[] args)
{
WritePrefixLine(DeriveColor(sender), sender);
WriteNewLine(ConsoleColor.Gray, format, args);
return;
}
private void WriteNewLine(ConsoleColor color, string format, params object[] args)
{
lock (m_syncRoot)
{
string now = DateTime.Now.ToString("[MM-dd hh:mm:ss] ");
Log.Write(now);
try
{
Log.WriteLine(format, args);
Log.Flush();
}
catch (FormatException)
{
System.Console.WriteLine(args);
}
System.Console.Write(now);
try
{
if (color != ConsoleColor.White)
System.Console.ForegroundColor = color;
System.Console.WriteLine(format, args);
System.Console.ResetColor();
}
catch (ArgumentNullException)
{
// Some older systems dont support coloured text.
System.Console.WriteLine(format, args);
}
catch (FormatException)
{
// Some older systems dont support coloured text.
System.Console.WriteLine(args);
}
return;
}
}
private void WritePrefixLine(ConsoleColor color, string sender)
{
lock (m_syncRoot)
{
sender = sender.ToUpper();
Log.WriteLine("[" + sender + "] ");
Log.Flush();
System.Console.Write("[");
try
{
System.Console.ForegroundColor = color;
System.Console.Write(sender);
System.Console.ResetColor();
}
catch (ArgumentNullException)
{
// Some older systems dont support coloured text.
System.Console.WriteLine(sender);
}
System.Console.Write("] \t");
return;
}
}
public string ReadLine()
{
try
{
string TempStr = System.Console.ReadLine();
Log.WriteLine(TempStr);
return TempStr;
}
catch (Exception e)
{
MainLog.Instance.Error("Console", "System.Console.ReadLine exception " + e.ToString());
return "";
}
}
public int Read()
{
int TempInt = System.Console.Read();
Log.Write((char) TempInt);
return TempInt;
}
public IPAddress CmdPromptIPAddress(string prompt, string defaultvalue)
{
IPAddress address;
string addressStr;
while (true)
{
addressStr = MainLog.Instance.CmdPrompt(prompt, defaultvalue);
if (IPAddress.TryParse(addressStr, out address))
{
break;
}
else
{
MainLog.Instance.Error("Illegal address. Please re-enter.");
}
}
return address;
}
public uint CmdPromptIPPort(string prompt, string defaultvalue)
{
uint port;
string portStr;
while (true)
{
portStr = MainLog.Instance.CmdPrompt(prompt, defaultvalue);
if (uint.TryParse(portStr, out port))
{
if (port >= IPEndPoint.MinPort && port <= IPEndPoint.MaxPort)
{
break;
}
}
MainLog.Instance.Error("Illegal address. Please re-enter.");
}
return port;
}
// Displays a prompt and waits for the user to enter a string, then returns that string
// Done with no echo and suitable for passwords
public string PasswdPrompt(string prompt)
{
// FIXME: Needs to be better abstracted
Log.WriteLine(prompt);
Notice(prompt);
ConsoleColor oldfg = System.Console.ForegroundColor;
System.Console.ForegroundColor = System.Console.BackgroundColor;
string temp = System.Console.ReadLine();
System.Console.ForegroundColor = oldfg;
return temp;
}
// Displays a command prompt and waits for the user to enter a string, then returns that string
public string CmdPrompt(string prompt)
{
Notice(String.Format("{0}: ", prompt));
return ReadLine();
}
// Displays a command prompt and returns a default value if the user simply presses enter
public string CmdPrompt(string prompt, string defaultresponse)
{
string temp = CmdPrompt(String.Format("{0} [{1}]", prompt, defaultresponse));
if (temp == "")
{
return defaultresponse;
}
else
{
return temp;
}
}
// Displays a command prompt and returns a default value, user may only enter 1 of 2 options
public string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB)
{
bool itisdone = false;
string temp = CmdPrompt(prompt, defaultresponse);
while (itisdone == false)
{
if ((temp == OptionA) || (temp == OptionB))
{
itisdone = true;
}
else
{
Notice("Valid options are " + OptionA + " or " + OptionB);
temp = CmdPrompt(prompt, defaultresponse);
}
}
return temp;
}
// Runs a command with a number of parameters
public Object RunCmd(string Cmd, string[] cmdparams)
{
cmdparser.RunCmd(Cmd, cmdparams);
return null;
}
// Shows data about something
public void ShowCommands(string ShowWhat)
{
cmdparser.Show(ShowWhat);
}
public void MainLogPrompt()
{
string tempstr = CmdPrompt(componentname + "# ");
MainLogRunCommand(tempstr);
}
public void MainLogRunCommand(string command)
{
string[] tempstrarray;
tempstrarray = command.Split(' ');
string cmd = tempstrarray[0];
Array.Reverse(tempstrarray);
Array.Resize<string>(ref tempstrarray, tempstrarray.Length - 1);
Array.Reverse(tempstrarray);
string[] cmdparams = (string[]) tempstrarray;
try
{
RunCmd(cmd, cmdparams);
}
catch (Exception e)
{
MainLog.Instance.Error("Console", "Command failed with exception " + e.ToString());
}
}
public string LineInfo
{
get
{
string result = String.Empty;
string stacktrace = Environment.StackTrace;
List<string> lines = new List<string>(stacktrace.Split(new string[] {"at "}, StringSplitOptions.None));
if (lines.Count > 4)
{
lines.RemoveRange(0, 4);
string tmpLine = lines[0];
int inIndex = tmpLine.IndexOf(" in ");
if (inIndex > -1)
{
result = tmpLine.Substring(0, inIndex);
int lineIndex = tmpLine.IndexOf(":line ");
if (lineIndex > -1)
{
lineIndex += 6;
result += ", line " + tmpLine.Substring(lineIndex, (tmpLine.Length - lineIndex) - 5);
}
}
}
return result;
}
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
namespace OpenSim.Framework.Console
{
public class ConsoleBase
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private readonly object m_syncRoot = new object();
public conscmd_callback m_cmdParser;
public string m_componentName;
public ConsoleBase(string componentname, conscmd_callback cmdparser)
{
m_componentName = componentname;
m_cmdParser = cmdparser;
System.Console.WriteLine("Creating new local console");
m_log.Info("[" + m_componentName + "]: Started at " + DateTime.Now.ToString());
}
public void Close()
{
m_log.Info("[" + m_componentName + "]: Shutdown at " + DateTime.Now.ToString());
}
/// <summary>
/// derive an ansi color from a string, ignoring the darker colors.
/// This is used to help automatically bin component tags with colors
/// in various print functions.
/// </summary>
/// <param name="input">arbitrary string for input</param>
/// <returns>an ansii color</returns>
private ConsoleColor DeriveColor(string input)
{
int colIdx = (input.ToUpper().GetHashCode() % 6) + 9;
return (ConsoleColor) colIdx;
}
/// <summary>
/// Sends a warning to the current console output
/// </summary>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Warn(string format, params object[] args)
{
WriteNewLine(ConsoleColor.Yellow, format, args);
}
/// <summary>
/// Sends a warning to the current console output
/// </summary>
/// <param name="sender">The module that sent this message</param>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Warn(string sender, string format, params object[] args)
{
WritePrefixLine(DeriveColor(sender), sender);
WriteNewLine(ConsoleColor.Yellow, format, args);
}
/// <summary>
/// Sends a notice to the current console output
/// </summary>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Notice(string format, params object[] args)
{
WriteNewLine(ConsoleColor.White, format, args);
}
/// <summary>
/// Sends a notice to the current console output
/// </summary>
/// <param name="sender">The module that sent this message</param>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Notice(string sender, string format, params object[] args)
{
WritePrefixLine(DeriveColor(sender), sender);
WriteNewLine(ConsoleColor.White, format, args);
}
/// <summary>
/// Sends an error to the current console output
/// </summary>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Error(string format, params object[] args)
{
WriteNewLine(ConsoleColor.Red, format, args);
}
/// <summary>
/// Sends an error to the current console output
/// </summary>
/// <param name="sender">The module that sent this message</param>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Error(string sender, string format, params object[] args)
{
WritePrefixLine(DeriveColor(sender), sender);
Error(format, args);
}
/// <summary>
/// Sends a status message to the current console output
/// </summary>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Status(string format, params object[] args)
{
WriteNewLine(ConsoleColor.Blue, format, args);
}
/// <summary>
/// Sends a status message to the current console output
/// </summary>
/// <param name="sender">The module that sent this message</param>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Status(string sender, string format, params object[] args)
{
WritePrefixLine(DeriveColor(sender), sender);
WriteNewLine(ConsoleColor.Blue, format, args);
}
[Conditional("DEBUG")]
public void Debug(string format, params object[] args)
{
WriteNewLine(ConsoleColor.Gray, format, args);
}
[Conditional("DEBUG")]
public void Debug(string sender, string format, params object[] args)
{
WritePrefixLine(DeriveColor(sender), sender);
WriteNewLine(ConsoleColor.Gray, format, args);
}
private void WriteNewLine(ConsoleColor color, string format, params object[] args)
{
try
{
lock (m_syncRoot)
{
try
{
if (color != ConsoleColor.White)
System.Console.ForegroundColor = color;
System.Console.WriteLine(format, args);
System.Console.ResetColor();
}
catch (ArgumentNullException)
{
// Some older systems dont support coloured text.
System.Console.WriteLine(format, args);
}
catch (FormatException)
{
System.Console.WriteLine(args);
}
}
}
catch (ObjectDisposedException)
{
}
}
private void WritePrefixLine(ConsoleColor color, string sender)
{
try
{
lock (m_syncRoot)
{
sender = sender.ToUpper();
System.Console.WriteLine("[" + sender + "] ");
System.Console.Write("[");
try
{
System.Console.ForegroundColor = color;
System.Console.Write(sender);
System.Console.ResetColor();
}
catch (ArgumentNullException)
{
// Some older systems dont support coloured text.
System.Console.WriteLine(sender);
}
System.Console.Write("] \t");
}
}
catch (ObjectDisposedException)
{
}
}
public string ReadLine()
{
try
{
return System.Console.ReadLine();
}
catch (Exception e)
{
m_log.Error("[Console]: System.Console.ReadLine exception " + e.ToString());
return String.Empty;
}
}
public int Read()
{
return System.Console.Read();
}
public IPAddress CmdPromptIPAddress(string prompt, string defaultvalue)
{
IPAddress address;
string addressStr;
while (true)
{
addressStr = CmdPrompt(prompt, defaultvalue);
if (IPAddress.TryParse(addressStr, out address))
{
break;
}
else
{
m_log.Error("Illegal address. Please re-enter.");
}
}
return address;
}
public uint CmdPromptIPPort(string prompt, string defaultvalue)
{
uint port;
string portStr;
while (true)
{
portStr = CmdPrompt(prompt, defaultvalue);
if (uint.TryParse(portStr, out port))
{
if (port >= IPEndPoint.MinPort && port <= IPEndPoint.MaxPort)
{
break;
}
}
m_log.Error("Illegal address. Please re-enter.");
}
return port;
}
// Displays a prompt and waits for the user to enter a string, then returns that string
// (Done with no echo and suitable for passwords - currently disabled)
public string PasswdPrompt(string prompt)
{
// FIXME: Needs to be better abstracted
System.Console.WriteLine(String.Format("{0}: ", prompt));
//ConsoleColor oldfg = System.Console.ForegroundColor;
//System.Console.ForegroundColor = System.Console.BackgroundColor;
string temp = System.Console.ReadLine();
//System.Console.ForegroundColor = oldfg;
return temp;
}
// Displays a command prompt and waits for the user to enter a string, then returns that string
public string CmdPrompt(string prompt)
{
System.Console.WriteLine(String.Format("{0}: ", prompt));
return ReadLine();
}
// Displays a command prompt and returns a default value if the user simply presses enter
public string CmdPrompt(string prompt, string defaultresponse)
{
string temp = CmdPrompt(String.Format("{0} [{1}]", prompt, defaultresponse));
if (temp == String.Empty)
{
return defaultresponse;
}
else
{
return temp;
}
}
// Displays a command prompt and returns a default value, user may only enter 1 of 2 options
public string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB)
{
bool itisdone = false;
string temp = CmdPrompt(prompt, defaultresponse);
while (itisdone == false)
{
if ((temp == OptionA) || (temp == OptionB))
{
itisdone = true;
}
else
{
System.Console.WriteLine("Valid options are " + OptionA + " or " + OptionB);
temp = CmdPrompt(prompt, defaultresponse);
}
}
return temp;
}
// Runs a command with a number of parameters
public Object RunCmd(string Cmd, string[] cmdparams)
{
m_cmdParser.RunCmd(Cmd, cmdparams);
return null;
}
// Shows data about something
public void ShowCommands(string ShowWhat)
{
m_cmdParser.Show(ShowWhat);
}
public void Prompt()
{
string tempstr = CmdPrompt(m_componentName + "# ");
RunCommand(tempstr);
}
public void RunCommand(string command)
{
string[] tempstrarray;
tempstrarray = command.Split(' ');
string cmd = tempstrarray[0];
Array.Reverse(tempstrarray);
Array.Resize<string>(ref tempstrarray, tempstrarray.Length - 1);
Array.Reverse(tempstrarray);
string[] cmdparams = (string[]) tempstrarray;
try
{
RunCmd(cmd, cmdparams);
}
catch (Exception e)
{
m_log.ErrorFormat("[Console]: Command [{0}] failed with exception {1}", command, e.ToString());
}
}
public string LineInfo
{
get
{
string result = String.Empty;
string stacktrace = Environment.StackTrace;
List<string> lines = new List<string>(stacktrace.Split(new string[] {"at "}, StringSplitOptions.None));
if (lines.Count > 4)
{
lines.RemoveRange(0, 4);
string tmpLine = lines[0];
int inIndex = tmpLine.IndexOf(" in ");
if (inIndex > -1)
{
result = tmpLine.Substring(0, inIndex);
int lineIndex = tmpLine.IndexOf(":line ");
if (lineIndex > -1)
{
lineIndex += 6;
result += ", line " + tmpLine.Substring(lineIndex, (tmpLine.Length - lineIndex) - 5);
}
}
}
return result;
}
}
}
}

View File

@ -1,40 +1,41 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace OpenSim.Framework.Console
{
public class MainLog
{
private static LogBase instance;
public static LogBase Instance
{
get { return instance; }
set { instance = value; }
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace OpenSim.Framework.Console
{
public class MainConsole
{
private static ConsoleBase instance;
public static ConsoleBase Instance
{
get { return instance; }
set { instance = value; }
}
}
}

View File

@ -0,0 +1,115 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using log4net.Core;
using log4net.Layout;
using log4net.Appender;
using log4net.Util;
namespace OpenSim.Framework.Console
{
public class OpenSimAppender : AnsiColorTerminalAppender
{
override protected void Append(LoggingEvent le)
{
try {
string loggingMessage = RenderLoggingEvent(le);
string regex = @"^(?<Front>.*?)\[(?<Category>[^\]]+)\]:?(?<End>.*)";
Regex RE = new Regex(regex, RegexOptions.Multiline);
MatchCollection matches = RE.Matches(loggingMessage);
// Get some direct matches $1 $4 is a
if (matches.Count == 1)
{
System.Console.Write(matches[0].Groups["Front"].Value);
System.Console.Write("[");
WriteColorText(DeriveColor(matches[0].Groups["Category"].Value), matches[0].Groups["Category"].Value);
System.Console.Write("]:");
if (le.Level == Level.Error)
{
WriteColorText(ConsoleColor.Red, matches[0].Groups["End"].Value);
}
else if (le.Level == Level.Warn)
{
WriteColorText(ConsoleColor.Yellow, matches[0].Groups["End"].Value);
}
else
{
System.Console.Write(matches[0].Groups["End"].Value);
}
System.Console.WriteLine();
}
else
{
System.Console.Write(loggingMessage);
}
}
catch (Exception e)
{
System.Console.WriteLine("Couldn't write out log message", e.ToString());
}
}
private void WriteColorText(ConsoleColor color, string sender)
{
try
{
lock (this)
{
try
{
System.Console.ForegroundColor = color;
System.Console.Write(sender);
System.Console.ResetColor();
}
catch (ArgumentNullException)
{
// Some older systems dont support coloured text.
System.Console.WriteLine(sender);
}
}
}
catch (ObjectDisposedException)
{
}
}
private ConsoleColor DeriveColor(string input)
{
int colIdx = (input.ToUpper().GetHashCode() % 6) + 9;
return (ConsoleColor) colIdx;
}
}
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework
{
public class Constants
{
public const uint RegionSize = 256;
}
}

View File

@ -1,54 +1,54 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Globalization;
using System.Threading;
namespace OpenSim.Framework
{
public class Culture
{
private static readonly CultureInfo m_cultureInfo = new CultureInfo("en-US", true);
public static NumberFormatInfo NumberFormatInfo
{
get { return m_cultureInfo.NumberFormat; }
}
public static IFormatProvider FormatProvider
{
get { return m_cultureInfo; }
}
public static void SetCurrentCulture()
{
Thread.CurrentThread.CurrentCulture = m_cultureInfo;
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Globalization;
using System.Threading;
namespace OpenSim.Framework
{
public class Culture
{
private static readonly CultureInfo m_cultureInfo = new CultureInfo("en-US", true);
public static NumberFormatInfo NumberFormatInfo
{
get { return m_cultureInfo.NumberFormat; }
}
public static IFormatProvider FormatProvider
{
get { return m_cultureInfo; }
}
public static void SetCurrentCulture()
{
Thread.CurrentThread.CurrentCulture = m_cultureInfo;
}
}
}

View File

@ -1,277 +1,282 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.IO;
using libsecondlife;
namespace OpenSim.Framework.Data.DB4o
{
/// <summary>
/// A User storage interface for the DB4o database system
/// </summary>
public class DB4oUserData : IUserData
{
/// <summary>
/// The database manager
/// </summary>
private DB4oUserManager manager;
/// <summary>
/// Artificial constructor called upon plugin load
/// </summary>
public void Initialise()
{
manager = new DB4oUserManager(Path.Combine(Util.dataDir(), "userprofiles.yap"));
}
/// <summary>
/// Loads a specified user profile from a UUID
/// </summary>
/// <param name="uuid">The users UUID</param>
/// <returns>A user profile</returns>
public UserProfileData GetUserByUUID(LLUUID uuid)
{
if (manager.userProfiles.ContainsKey(uuid))
return manager.userProfiles[uuid];
return null;
}
/// <summary>
/// Loads a specified user profile from a account
/// </summary>
/// <param name="uuid">The users account</param>
/// <returns>A user profile</returns>
public UserProfileData GetUserByAccount(string account)
{
if (manager.userProfiles.ContainsKey(account))
return manager.userProfiles[account];
return null;
}
/// <summary>
/// Returns a user by searching for its name
/// </summary>
/// <param name="name">The users account name</param>
/// <returns>A matching users profile</returns>
public UserProfileData GetUserByName(string name)
{
return GetUserByName(name.Split(' ')[0], name.Split(' ')[1]);
}
/// <summary>
/// Returns a user by searching for its name
/// </summary>
/// <param name="fname">The first part of the users account name</param>
/// <param name="lname">The second part of the users account name</param>
/// <returns>A matching users profile</returns>
public UserProfileData GetUserByName(string fname, string lname)
{
foreach (UserProfileData profile in manager.userProfiles.Values)
{
if (profile.username == fname && profile.surname == lname)
return profile;
}
return null;
}
/// <summary>
/// Returns a user by UUID direct
/// </summary>
/// <param name="uuid">The users account ID</param>
/// <returns>A matching users profile</returns>
public UserAgentData GetAgentByUUID(LLUUID uuid)
{
try
{
return GetUserByUUID(uuid).currentAgent;
}
catch (Exception)
{
return null;
}
}
/// <summary>
/// Returns a session by account name
/// </summary>
/// <param name="name">The account name</param>
/// <returns>The users session agent</returns>
public UserAgentData GetAgentByName(string name)
{
return GetAgentByName(name.Split(' ')[0], name.Split(' ')[1]);
}
/// <summary>
/// Returns a session by account name
/// </summary>
/// <param name="fname">The first part of the users account name</param>
/// <param name="lname">The second part of the users account name</param>
/// <returns>A user agent</returns>
public UserAgentData GetAgentByName(string fname, string lname)
{
try
{
return GetUserByName(fname, lname).currentAgent;
}
catch (Exception)
{
return null;
}
}
#region User Friends List Data
public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms)
{
//MainLog.Instance.Verbose("FRIEND", "Stub AddNewUserFriend called");
}
public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend)
{
//MainLog.Instance.Verbose("FRIEND", "Stub RemoveUserFriend called");
}
public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms)
{
//MainLog.Instance.Verbose("FRIEND", "Stub UpdateUserFriendPerms called");
}
public List<FriendListItem> GetUserFriendList(LLUUID friendlistowner)
{
//MainLog.Instance.Verbose("FRIEND", "Stub GetUserFriendList called");
return new List<FriendListItem>();
}
#endregion
public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid)
{
//MainLog.Instance.Verbose("USER", "Stub UpdateUserCUrrentRegion called");
}
public void LogOffUser(LLUUID avatarid)
{
//MainLog.Instance.Verbose("USER", "Stub LogOffUser called");
}
public List<Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
{
//Do nothing yet
List<Framework.AvatarPickerAvatar> returnlist = new List<Framework.AvatarPickerAvatar>();
return returnlist;
}
/// <summary>
/// Creates a new user profile
/// </summary>
/// <param name="user">The profile to add to the database</param>
public void AddNewUserProfile(UserProfileData user)
{
try
{
manager.UpdateRecord(user);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
/// <summary>
/// Creates a new user profile
/// </summary>
/// <param name="user">The profile to add to the database</param>
/// <returns>True on success, false on error</returns>
public bool UpdateUserProfile(UserProfileData user)
{
try
{
return manager.UpdateRecord(user);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return false;
}
}
/// <summary>
/// Creates a new user agent
/// </summary>
/// <param name="agent">The agent to add to the database</param>
public void AddNewUserAgent(UserAgentData agent)
{
// Do nothing. yet.
}
/// <summary>
/// Transfers money between two user accounts
/// </summary>
/// <param name="from">Starting account</param>
/// <param name="to">End account</param>
/// <param name="amount">The amount to move</param>
/// <returns>Success?</returns>
public bool MoneyTransferRequest(LLUUID from, LLUUID to, uint amount)
{
return true;
}
/// <summary>
/// Transfers inventory between two accounts
/// </summary>
/// <remarks>Move to inventory server</remarks>
/// <param name="from">Senders account</param>
/// <param name="to">Receivers account</param>
/// <param name="item">Inventory item</param>
/// <returns>Success?</returns>
public bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
{
return true;
}
/// <summary>
/// Returns the name of the storage provider
/// </summary>
/// <returns>Storage provider name</returns>
public string getName()
{
return "DB4o Userdata";
}
/// <summary>
/// Returns the version of the storage provider
/// </summary>
/// <returns>Storage provider version</returns>
public string GetVersion()
{
return "0.1";
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.IO;
using libsecondlife;
namespace OpenSim.Framework.Data.DB4o
{
/// <summary>
/// A User storage interface for the DB4o database system
/// </summary>
public class DB4oUserData : IUserData
{
//private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// The database manager
/// </summary>
private DB4oUserManager manager;
/// <summary>
/// Artificial constructor called upon plugin load
/// </summary>
public void Initialise()
{
manager = new DB4oUserManager(Path.Combine(Util.dataDir(), "userprofiles.yap"));
}
/// <summary>
/// Loads a specified user profile from a UUID
/// </summary>
/// <param name="uuid">The users UUID</param>
/// <returns>A user profile</returns>
public UserProfileData GetUserByUUID(LLUUID uuid)
{
if (manager.userProfiles.ContainsKey(uuid))
return manager.userProfiles[uuid];
return null;
}
/// <summary>
/// Loads a specified user profile from a account
/// </summary>
/// <param name="uuid">The users account</param>
/// <returns>A user profile</returns>
public UserProfileData GetUserByAccount(string account)
{
if (manager.userProfiles.ContainsKey(account))
return manager.userProfiles[account];
return null;
}
/// <summary>
/// Returns a user by searching for its name
/// </summary>
/// <param name="name">The users account name</param>
/// <returns>A matching users profile</returns>
public UserProfileData GetUserByName(string name)
{
return GetUserByName(name.Split(' ')[0], name.Split(' ')[1]);
}
/// <summary>
/// Returns a user by searching for its name
/// </summary>
/// <param name="fname">The first part of the users account name</param>
/// <param name="lname">The second part of the users account name</param>
/// <returns>A matching users profile</returns>
public UserProfileData GetUserByName(string fname, string lname)
{
foreach (UserProfileData profile in manager.userProfiles.Values)
{
if (profile.username == fname && profile.surname == lname)
return profile;
}
return null;
}
/// <summary>
/// Returns a user by UUID direct
/// </summary>
/// <param name="uuid">The users account ID</param>
/// <returns>A matching users profile</returns>
public UserAgentData GetAgentByUUID(LLUUID uuid)
{
try
{
return GetUserByUUID(uuid).currentAgent;
}
catch (Exception)
{
return null;
}
}
/// <summary>
/// Returns a session by account name
/// </summary>
/// <param name="name">The account name</param>
/// <returns>The users session agent</returns>
public UserAgentData GetAgentByName(string name)
{
return GetAgentByName(name.Split(' ')[0], name.Split(' ')[1]);
}
/// <summary>
/// Returns a session by account name
/// </summary>
/// <param name="fname">The first part of the users account name</param>
/// <param name="lname">The second part of the users account name</param>
/// <returns>A user agent</returns>
public UserAgentData GetAgentByName(string fname, string lname)
{
try
{
return GetUserByName(fname, lname).currentAgent;
}
catch (Exception)
{
return null;
}
}
public void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey)
{
UserProfileData user = GetUserByUUID(AgentID);
user.webLoginKey = WebLoginKey;
UpdateUserProfile(user);
}
#region User Friends List Data
public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms)
{
//m_log.Info("[FRIEND]: Stub AddNewUserFriend called");
}
public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend)
{
//m_log.Info("[FRIEND]: Stub RemoveUserFriend called");
}
public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms)
{
//m_log.Info("[FRIEND]: Stub UpdateUserFriendPerms called");
}
public List<FriendListItem> GetUserFriendList(LLUUID friendlistowner)
{
//m_log.Info("[FRIEND]: Stub GetUserFriendList called");
return new List<FriendListItem>();
}
#endregion
public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid)
{
//m_log.Info("[USER]: Stub UpdateUserCUrrentRegion called");
}
public List<Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
{
//Do nothing yet
List<Framework.AvatarPickerAvatar> returnlist = new List<Framework.AvatarPickerAvatar>();
return returnlist;
}
/// <summary>
/// Creates a new user profile
/// </summary>
/// <param name="user">The profile to add to the database</param>
public void AddNewUserProfile(UserProfileData user)
{
try
{
manager.UpdateRecord(user);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
/// <summary>
/// Creates a new user profile
/// </summary>
/// <param name="user">The profile to add to the database</param>
/// <returns>True on success, false on error</returns>
public bool UpdateUserProfile(UserProfileData user)
{
try
{
return manager.UpdateRecord(user);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return false;
}
}
/// <summary>
/// Creates a new user agent
/// </summary>
/// <param name="agent">The agent to add to the database</param>
public void AddNewUserAgent(UserAgentData agent)
{
// Do nothing. yet.
}
/// <summary>
/// Transfers money between two user accounts
/// </summary>
/// <param name="from">Starting account</param>
/// <param name="to">End account</param>
/// <param name="amount">The amount to move</param>
/// <returns>Success?</returns>
public bool MoneyTransferRequest(LLUUID from, LLUUID to, uint amount)
{
return true;
}
/// <summary>
/// Transfers inventory between two accounts
/// </summary>
/// <remarks>Move to inventory server</remarks>
/// <param name="from">Senders account</param>
/// <param name="to">Receivers account</param>
/// <param name="item">Inventory item</param>
/// <returns>Success?</returns>
public bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
{
return true;
}
/// <summary>
/// Returns the name of the storage provider
/// </summary>
/// <returns>Storage provider name</returns>
public string getName()
{
return "DB4o Userdata";
}
/// <summary>
/// Returns the version of the storage provider
/// </summary>
/// <returns>Storage provider version</returns>
public string GetVersion()
{
return "0.1";
}
}
}

View File

@ -1,38 +1,66 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly : AssemblyTitle("OpenSim.Framework.Data.DB4o")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("")]
[assembly : AssemblyProduct("OpenSim.Framework.Data.DB4o")]
[assembly : AssemblyCopyright("Copyright © 2007")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly : ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly : Guid("57991e15-79da-41b7-aa06-2e6b49165a63")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly : AssemblyTitle("OpenSim.Framework.Data.DB4o")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("")]
[assembly : AssemblyProduct("OpenSim.Framework.Data.DB4o")]
[assembly : AssemblyCopyright("Copyright © OpenSimulator.org Developers 2007-2008")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly : ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly : Guid("57991e15-79da-41b7-aa06-2e6b49165a63")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]

View File

@ -1,240 +1,242 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using libsecondlife;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.MSSQL
{
internal class MSSQLAssetData : IAssetProvider
{
private MSSQLManager database;
#region IAssetProvider Members
private void UpgradeAssetsTable(string tableName)
{
// null as the version, indicates that the table didn't exist
if (tableName == null)
{
MainLog.Instance.Notice("ASSETS", "Creating new database tables");
database.ExecuteResourceSql("CreateAssetsTable.sql");
return;
}
}
/// <summary>
/// Ensure that the assets related tables exists and are at the latest version
/// </summary>
private void TestTables()
{
Dictionary<string, string> tableList = new Dictionary<string, string>();
tableList["assets"] = null;
database.GetTableVersion(tableList);
UpgradeAssetsTable(tableList["assets"]);
}
public AssetBase FetchAsset(LLUUID assetID)
{
AssetBase asset = null;
Dictionary<string, string> param = new Dictionary<string, string>();
param["id"] = assetID.ToString();
IDbCommand result = database.Query("SELECT * FROM assets WHERE id = @id", param);
IDataReader reader = result.ExecuteReader();
asset = database.getAssetRow(reader);
reader.Close();
result.Dispose();
return asset;
}
public void CreateAsset(AssetBase asset)
{
if (ExistsAsset((LLUUID) asset.FullID))
{
return;
}
SqlCommand cmd =
new SqlCommand(
"INSERT INTO assets ([id], [name], [mediaUrl], [description], [assetType], [invType], [local], [temporary], [data])" +
" VALUES " +
"(@id, @name, @mediaUrl, @description, @assetType, @invType, @local, @temporary, @data)",
database.getConnection());
using (cmd)
{
//SqlParameter p = cmd.Parameters.Add("id", SqlDbType.NVarChar);
//p.Value = asset.FullID.ToString();
cmd.Parameters.AddWithValue("id", asset.FullID.ToString());
cmd.Parameters.AddWithValue("name", asset.Name);
cmd.Parameters.AddWithValue("mediaUrl", asset.MediaURL);
cmd.Parameters.AddWithValue("description", asset.Description);
SqlParameter e = cmd.Parameters.Add("assetType", SqlDbType.TinyInt);
e.Value = asset.Type;
SqlParameter f = cmd.Parameters.Add("invType", SqlDbType.TinyInt);
f.Value = asset.InvType;
SqlParameter g = cmd.Parameters.Add("local", SqlDbType.TinyInt);
g.Value = asset.Local;
SqlParameter h = cmd.Parameters.Add("temporary", SqlDbType.TinyInt);
h.Value = asset.Temporary;
SqlParameter i = cmd.Parameters.Add("data", SqlDbType.Image);
i.Value = asset.Data;
try
{
cmd.ExecuteNonQuery();
}
catch (Exception)
{
throw;
}
cmd.Dispose();
}
}
public void UpdateAsset(AssetBase asset)
{
SqlCommand command = new SqlCommand("UPDATE assets set id = @id, " +
"name = @name, " +
"mediaUrl = @mediaUrl, "+
"description = @description," +
"assetType = @assetType," +
"invType = @invType," +
"local = @local," +
"temporary = @temporary," +
"data = @data where " +
"id = @keyId;", database.getConnection());
SqlParameter param1 = new SqlParameter("@id", asset.FullID.ToString());
SqlParameter param2 = new SqlParameter("@name", asset.Name);
SqlParameter param3 = new SqlParameter("@mediaUrl", asset.MediaURL);
SqlParameter param4 = new SqlParameter("@description", asset.Description);
SqlParameter param5 = new SqlParameter("@assetType", Convert.ToBoolean(asset.Type));
SqlParameter param6 = new SqlParameter("@invType", Convert.ToBoolean(asset.InvType));
SqlParameter param7 = new SqlParameter("@local", asset.Local);
SqlParameter param8 = new SqlParameter("@temporary", asset.Temporary);
SqlParameter param9 = new SqlParameter("@data", asset.Data);
SqlParameter param10 = new SqlParameter("@keyId", asset.FullID.ToString());
command.Parameters.Add(param1);
command.Parameters.Add(param2);
command.Parameters.Add(param3);
command.Parameters.Add(param4);
command.Parameters.Add(param5);
command.Parameters.Add(param6);
command.Parameters.Add(param7);
command.Parameters.Add(param8);
command.Parameters.Add(param9);
command.Parameters.Add(param10);
try
{
command.ExecuteNonQuery();
}
catch (Exception e)
{
MainLog.Instance.Error(e.ToString());
}
}
public bool ExistsAsset(LLUUID uuid)
{
if (FetchAsset(uuid) != null)
{
return true;
}
return false;
}
// rex, new function, fixme not implemented
public List<AssetBase> GetAssetList(int vAssetType)
{
List<AssetBase> retvals = new List<AssetBase>();
return retvals;
}
/// <summary>
/// All writes are immediately commited to the database, so this is a no-op
/// </summary>
public void CommitAssets()
{
}
// rex new function for "replace assets" functionality
// TODO: actual implementation by someone, should return LLUUID of an asset
// with matching type & name, or zero if not in DB
public LLUUID ExistsAsset(sbyte type, string name)
{
return LLUUID.Zero;
}
#endregion
#region IPlugin Members
public void Initialise()
{
IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini");
string settingDataSource = GridDataMySqlFile.ParseFileReadValue("data_source");
string settingInitialCatalog = GridDataMySqlFile.ParseFileReadValue("initial_catalog");
string settingPersistSecurityInfo = GridDataMySqlFile.ParseFileReadValue("persist_security_info");
string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id");
string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
database =
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
settingPassword);
TestTables();
}
public string Version
{
// get { return database.getVersion(); }
get { return database.getVersion(); }
}
public string Name
{
get { return "MSSQL Asset storage engine"; }
}
#endregion
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using libsecondlife;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.MSSQL
{
internal class MSSQLAssetData : IAssetProvider
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private MSSQLManager database;
#region IAssetProvider Members
private void UpgradeAssetsTable(string tableName)
{
// null as the version, indicates that the table didn't exist
if (tableName == null)
{
m_log.Info("[ASSETS]: Creating new database tables");
database.ExecuteResourceSql("CreateAssetsTable.sql");
return;
}
}
/// <summary>
/// Ensure that the assets related tables exists and are at the latest version
/// </summary>
private void TestTables()
{
Dictionary<string, string> tableList = new Dictionary<string, string>();
tableList["assets"] = null;
database.GetTableVersion(tableList);
UpgradeAssetsTable(tableList["assets"]);
}
public AssetBase FetchAsset(LLUUID assetID)
{
AssetBase asset = null;
Dictionary<string, string> param = new Dictionary<string, string>();
param["id"] = assetID.ToString();
IDbCommand result = database.Query("SELECT * FROM assets WHERE id = @id", param);
IDataReader reader = result.ExecuteReader();
asset = database.getAssetRow(reader);
reader.Close();
result.Dispose();
return asset;
}
public void CreateAsset(AssetBase asset)
{
if (ExistsAsset((LLUUID) asset.FullID))
{
return;
}
SqlCommand cmd =
new SqlCommand(
"INSERT INTO assets ([id], [name], [mediaUrl], [description], [assetType], [invType], [local], [temporary], [data])" +
" VALUES " +
"(@id, @name, @mediaUrl, @description, @assetType, @invType, @local, @temporary, @data)",
database.getConnection());
using (cmd)
{
//SqlParameter p = cmd.Parameters.Add("id", SqlDbType.NVarChar);
//p.Value = asset.FullID.ToString();
cmd.Parameters.AddWithValue("id", asset.FullID.ToString());
cmd.Parameters.AddWithValue("name", asset.Name);
cmd.Parameters.AddWithValue("mediaUrl", asset.MediaURL);
cmd.Parameters.AddWithValue("description", asset.Description);
SqlParameter e = cmd.Parameters.Add("assetType", SqlDbType.TinyInt);
e.Value = asset.Type;
SqlParameter f = cmd.Parameters.Add("invType", SqlDbType.TinyInt);
f.Value = asset.InvType;
SqlParameter g = cmd.Parameters.Add("local", SqlDbType.TinyInt);
g.Value = asset.Local;
SqlParameter h = cmd.Parameters.Add("temporary", SqlDbType.TinyInt);
h.Value = asset.Temporary;
SqlParameter i = cmd.Parameters.Add("data", SqlDbType.Image);
i.Value = asset.Data;
try
{
cmd.ExecuteNonQuery();
}
catch (Exception)
{
throw;
}
cmd.Dispose();
}
}
public void UpdateAsset(AssetBase asset)
{
SqlCommand command = new SqlCommand("UPDATE assets set id = @id, " +
"name = @name, " +
"mediaUrl = @mediaUrl, "+
"description = @description," +
"assetType = @assetType," +
"invType = @invType," +
"local = @local," +
"temporary = @temporary," +
"data = @data where " +
"id = @keyId;", database.getConnection());
SqlParameter param1 = new SqlParameter("@id", asset.FullID.ToString());
SqlParameter param2 = new SqlParameter("@name", asset.Name);
SqlParameter param3 = new SqlParameter("@mediaUrl", asset.MediaURL);
SqlParameter param4 = new SqlParameter("@description", asset.Description);
SqlParameter param5 = new SqlParameter("@assetType", Convert.ToBoolean(asset.Type));
SqlParameter param6 = new SqlParameter("@invType", Convert.ToBoolean(asset.InvType));
SqlParameter param7 = new SqlParameter("@local", asset.Local);
SqlParameter param8 = new SqlParameter("@temporary", asset.Temporary);
SqlParameter param9 = new SqlParameter("@data", asset.Data);
SqlParameter param10 = new SqlParameter("@keyId", asset.FullID.ToString());
command.Parameters.Add(param1);
command.Parameters.Add(param2);
command.Parameters.Add(param3);
command.Parameters.Add(param4);
command.Parameters.Add(param5);
command.Parameters.Add(param6);
command.Parameters.Add(param7);
command.Parameters.Add(param8);
command.Parameters.Add(param9);
command.Parameters.Add(param10);
try
{
command.ExecuteNonQuery();
}
catch (Exception e)
{
m_log.Error(e.ToString());
}
}
public bool ExistsAsset(LLUUID uuid)
{
if (FetchAsset(uuid) != null)
{
return true;
}
return false;
}
// rex, new function, fixme not implemented
public List<AssetBase> GetAssetList(int vAssetType)
{
List<AssetBase> retvals = new List<AssetBase>();
return retvals;
}
/// <summary>
/// All writes are immediately commited to the database, so this is a no-op
/// </summary>
public void CommitAssets()
{
}
// rex new function for "replace assets" functionality
// TODO: actual implementation by someone, should return LLUUID of an asset
// with matching type & name, or zero if not in DB
public LLUUID ExistsAsset(sbyte type, string name)
{
return LLUUID.Zero;
}
#endregion
#region IPlugin Members
public void Initialise()
{
IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini");
string settingDataSource = GridDataMySqlFile.ParseFileReadValue("data_source");
string settingInitialCatalog = GridDataMySqlFile.ParseFileReadValue("initial_catalog");
string settingPersistSecurityInfo = GridDataMySqlFile.ParseFileReadValue("persist_security_info");
string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id");
string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
database =
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
settingPassword);
TestTables();
}
public string Version
{
// get { return database.getVersion(); }
get { return database.getVersion(); }
}
public string Name
{
get { return "MSSQL Asset storage engine"; }
}
#endregion
}
}

View File

@ -1,309 +1,327 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Data;
using System.Security.Cryptography;
using System.Text;
using libsecondlife;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.MSSQL
{
/// <summary>
/// A grid data interface for Microsoft SQL Server
/// </summary>
public class SqlGridData : IGridData
{
/// <summary>
/// Database manager
/// </summary>
private MSSQLManager database;
/// <summary>
/// Initialises the Grid Interface
/// </summary>
public void Initialise()
{
IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini");
string settingDataSource = GridDataMySqlFile.ParseFileReadValue("data_source");
string settingInitialCatalog = GridDataMySqlFile.ParseFileReadValue("initial_catalog");
string settingPersistSecurityInfo = GridDataMySqlFile.ParseFileReadValue("persist_security_info");
string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id");
string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
database =
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
settingPassword);
}
/// <summary>
/// Shuts down the grid interface
/// </summary>
public void Close()
{
database.Close();
}
/// <summary>
/// Returns the storage system name
/// </summary>
/// <returns>A string containing the storage system name</returns>
public string getName()
{
return "Sql OpenGridData";
}
/// <summary>
/// Returns the storage system version
/// </summary>
/// <returns>A string containing the storage system version</returns>
public string getVersion()
{
return "0.1";
}
/// <summary>
/// Returns a list of regions within the specified ranges
/// </summary>
/// <param name="a">minimum X coordinate</param>
/// <param name="b">minimum Y coordinate</param>
/// <param name="c">maximum X coordinate</param>
/// <param name="d">maximum Y coordinate</param>
/// <returns>An array of region profiles</returns>
public RegionProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
{
return null;
}
/// <summary>
/// Returns a sim profile from it's location
/// </summary>
/// <param name="handle">Region location handle</param>
/// <returns>Sim profile</returns>
public RegionProfileData GetProfileByHandle(ulong handle)
{
IDataReader reader = null;
try
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["handle"] = handle.ToString();
IDbCommand result = database.Query("SELECT * FROM regions WHERE regionHandle = @handle", param);
reader = result.ExecuteReader();
RegionProfileData row = database.getRegionRow(reader);
reader.Close();
result.Dispose();
return row;
}
catch (Exception)
{
if (reader != null)
{
reader.Close();
}
}
return null;
}
/// <summary>
/// // Returns a list of avatar and UUIDs that match the query
/// </summary>
public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
{
List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
string[] querysplit;
querysplit = query.Split(' ');
if (querysplit.Length == 2)
{
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["first"] = querysplit[0];
param["second"] = querysplit[1];
IDbCommand result =
database.Query(
"SELECT UUID,username,surname FROM users WHERE username = @first AND lastname = @second",
param);
IDataReader reader = result.ExecuteReader();
while (reader.Read())
{
AvatarPickerAvatar user = new AvatarPickerAvatar();
user.AvatarID = new LLUUID((string) reader["UUID"]);
user.firstName = (string) reader["username"];
user.lastName = (string) reader["surname"];
returnlist.Add(user);
}
reader.Close();
result.Dispose();
}
}
catch (Exception e)
{
database.Reconnect();
MainLog.Instance.Error(e.ToString());
return returnlist;
}
}
else if (querysplit.Length == 1)
{
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["first"] = querysplit[0];
param["second"] = querysplit[1];
IDbCommand result =
database.Query(
"SELECT UUID,username,surname FROM users WHERE username = @first OR lastname = @second",
param);
IDataReader reader = result.ExecuteReader();
while (reader.Read())
{
AvatarPickerAvatar user = new AvatarPickerAvatar();
user.AvatarID = new LLUUID((string) reader["UUID"]);
user.firstName = (string) reader["username"];
user.lastName = (string) reader["surname"];
returnlist.Add(user);
}
reader.Close();
result.Dispose();
}
}
catch (Exception e)
{
database.Reconnect();
MainLog.Instance.Error(e.ToString());
return returnlist;
}
}
return returnlist;
}
/// <summary>
/// Returns a sim profile from it's UUID
/// </summary>
/// <param name="uuid">The region UUID</param>
/// <returns>The sim profile</returns>
public RegionProfileData GetProfileByLLUUID(LLUUID uuid)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["uuid"] = uuid.ToString();
IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = @uuid", param);
IDataReader reader = result.ExecuteReader();
RegionProfileData row = database.getRegionRow(reader);
reader.Close();
result.Dispose();
return row;
}
/// <summary>
/// Adds a new specified region to the database
/// </summary>
/// <param name="profile">The profile to add</param>
/// <returns>A dataresponse enum indicating success</returns>
public DataResponse AddProfile(RegionProfileData profile)
{
try
{
if (GetProfileByLLUUID(profile.UUID) != null)
{
return DataResponse.RESPONSE_OK;
}
}
catch (Exception)
{
System.Console.WriteLine("No regions found. Create new one.");
}
if (database.insertRegionRow(profile))
{
return DataResponse.RESPONSE_OK;
}
else
{
return DataResponse.RESPONSE_ERROR;
}
}
/// <summary>
/// DEPRECIATED. Attempts to authenticate a region by comparing a shared secret.
/// </summary>
/// <param name="uuid">The UUID of the challenger</param>
/// <param name="handle">The attempted regionHandle of the challenger</param>
/// <param name="authkey">The secret</param>
/// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey)
{
bool throwHissyFit = false; // Should be true by 1.0
if (throwHissyFit)
throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
RegionProfileData data = GetProfileByLLUUID(uuid);
return (handle == data.regionHandle && authkey == data.regionSecret);
}
/// <summary>
/// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region
/// </summary>
/// <remarks>This requires a security audit.</remarks>
/// <param name="uuid"></param>
/// <param name="handle"></param>
/// <param name="authhash"></param>
/// <param name="challenge"></param>
/// <returns></returns>
public bool AuthenticateSim(LLUUID uuid, ulong handle, string authhash, string challenge)
{
SHA512Managed HashProvider = new SHA512Managed();
ASCIIEncoding TextProvider = new ASCIIEncoding();
byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge);
byte[] hash = HashProvider.ComputeHash(stream);
return false;
}
public ReservationData GetReservationAtPoint(uint x, uint y)
{
return null;
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Data;
using System.Security.Cryptography;
using System.Text;
using libsecondlife;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.MSSQL
{
/// <summary>
/// A grid data interface for Microsoft SQL Server
/// </summary>
public class MSSQLGridData : IGridData
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Database manager
/// </summary>
private MSSQLManager database;
private string m_regionsTableName;
/// <summary>
/// Initialises the Grid Interface
/// </summary>
public void Initialise()
{
IniFile iniFile = new IniFile("mssql_connection.ini");
string settingDataSource = iniFile.ParseFileReadValue("data_source");
string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog");
string settingPersistSecurityInfo = iniFile.ParseFileReadValue("persist_security_info");
string settingUserId = iniFile.ParseFileReadValue("user_id");
string settingPassword = iniFile.ParseFileReadValue("password");
m_regionsTableName = iniFile.ParseFileReadValue("regionstablename");
if (m_regionsTableName == null)
{
m_regionsTableName = "regions";
}
database =
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
settingPassword);
TestTables();
}
private void TestTables()
{
IDbCommand cmd = database.Query("SELECT TOP 1 * FROM "+m_regionsTableName, new Dictionary<string, string>());
try
{
cmd.ExecuteNonQuery();
cmd.Dispose();
}
catch (Exception)
{
m_log.Info("[DATASTORE]: MSSQL Database doesn't exist... creating");
database.ExecuteResourceSql("Mssql-regions.sql");
}
}
/// <summary>
/// Shuts down the grid interface
/// </summary>
public void Close()
{
database.Close();
}
/// <summary>
/// Returns the storage system name
/// </summary>
/// <returns>A string containing the storage system name</returns>
public string getName()
{
return "Sql OpenGridData";
}
/// <summary>
/// Returns the storage system version
/// </summary>
/// <returns>A string containing the storage system version</returns>
public string getVersion()
{
return "0.1";
}
/// <summary>
/// Returns a list of regions within the specified ranges
/// </summary>
/// <param name="a">minimum X coordinate</param>
/// <param name="b">minimum Y coordinate</param>
/// <param name="c">maximum X coordinate</param>
/// <param name="d">maximum Y coordinate</param>
/// <returns>An array of region profiles</returns>
public RegionProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
{
return null;
}
/// <summary>
/// Returns a sim profile from it's location
/// </summary>
/// <param name="handle">Region location handle</param>
/// <returns>Sim profile</returns>
public RegionProfileData GetProfileByHandle(ulong handle)
{
IDataReader reader = null;
try
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["handle"] = handle.ToString();
IDbCommand result = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE regionHandle = @handle", param);
reader = result.ExecuteReader();
RegionProfileData row = database.getRegionRow(reader);
reader.Close();
result.Dispose();
return row;
}
catch (Exception)
{
if (reader != null)
{
reader.Close();
}
}
return null;
}
/// <summary>
/// Returns a sim profile from it's UUID
/// </summary>
/// <param name="uuid">The region UUID</param>
/// <returns>The sim profile</returns>
public RegionProfileData GetProfileByLLUUID(LLUUID uuid)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["uuid"] = uuid.ToString();
IDbCommand result = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE uuid = @uuid", param);
IDataReader reader = result.ExecuteReader();
RegionProfileData row = database.getRegionRow(reader);
reader.Close();
result.Dispose();
return row;
}
/// <summary>
/// Adds a new specified region to the database
/// </summary>
/// <param name="profile">The profile to add</param>
/// <returns>A dataresponse enum indicating success</returns>
public DataResponse AddProfile(RegionProfileData profile)
{
try
{
if (GetProfileByLLUUID(profile.UUID) != null)
{
return DataResponse.RESPONSE_OK;
}
}
catch (Exception)
{
System.Console.WriteLine("No regions found. Create new one.");
}
if ( insertRegionRow(profile))
{
return DataResponse.RESPONSE_OK;
}
else
{
return DataResponse.RESPONSE_ERROR;
}
}
/// <summary>
/// Creates a new region in the database
/// </summary>
/// <param name="profile">The region profile to insert</param>
/// <returns>Successful?</returns>
public bool insertRegionRow(RegionProfileData profile)
{
//Insert new region
string sql =
"INSERT INTO " + m_regionsTableName + " ([regionHandle], [regionName], [uuid], [regionRecvKey], [regionSecret], [regionSendKey], [regionDataURI], ";
sql +=
"[serverIP], [serverPort], [serverURI], [locX], [locY], [locZ], [eastOverrideHandle], [westOverrideHandle], [southOverrideHandle], [northOverrideHandle], [regionAssetURI], [regionAssetRecvKey], ";
sql +=
"[regionAssetSendKey], [regionUserURI], [regionUserRecvKey], [regionUserSendKey], [regionMapTexture], [serverHttpPort], [serverRemotingPort]) VALUES ";
sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, ";
sql +=
"@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, ";
sql +=
"@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey, @regionMapTexture, @serverHttpPort, @serverRemotingPort);";
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters["regionHandle"] = profile.regionHandle.ToString();
parameters["regionName"] = profile.regionName;
parameters["uuid"] = profile.UUID.ToString();
parameters["regionRecvKey"] = profile.regionRecvKey;
parameters["regionSecret"] = profile.regionSecret;
parameters["regionSendKey"] = profile.regionSendKey;
parameters["regionDataURI"] = profile.regionDataURI;
parameters["serverIP"] = profile.serverIP;
parameters["serverPort"] = profile.serverPort.ToString();
parameters["serverURI"] = profile.serverURI;
parameters["locX"] = profile.regionLocX.ToString();
parameters["locY"] = profile.regionLocY.ToString();
parameters["locZ"] = profile.regionLocZ.ToString();
parameters["eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString();
parameters["westOverrideHandle"] = profile.regionWestOverrideHandle.ToString();
parameters["northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString();
parameters["southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString();
parameters["regionAssetURI"] = profile.regionAssetURI;
parameters["regionAssetRecvKey"] = profile.regionAssetRecvKey;
parameters["regionAssetSendKey"] = profile.regionAssetSendKey;
parameters["regionUserURI"] = profile.regionUserURI;
parameters["regionUserRecvKey"] = profile.regionUserRecvKey;
parameters["regionUserSendKey"] = profile.regionUserSendKey;
parameters["regionMapTexture"] = profile.regionMapTextureID.ToString();
parameters["serverHttpPort"] = profile.httpPort.ToString();
parameters["serverRemotingPort"] = profile.remotingPort.ToString();
bool returnval = false;
try
{
IDbCommand result = database.Query(sql, parameters);
if (result.ExecuteNonQuery() == 1)
returnval = true;
result.Dispose();
}
catch (Exception e)
{
m_log.Error("MSSQLManager : " + e.ToString());
}
return returnval;
}
/// <summary>
/// DEPRECIATED. Attempts to authenticate a region by comparing a shared secret.
/// </summary>
/// <param name="uuid">The UUID of the challenger</param>
/// <param name="handle">The attempted regionHandle of the challenger</param>
/// <param name="authkey">The secret</param>
/// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey)
{
bool throwHissyFit = false; // Should be true by 1.0
if (throwHissyFit)
throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
RegionProfileData data = GetProfileByLLUUID(uuid);
return (handle == data.regionHandle && authkey == data.regionSecret);
}
/// <summary>
/// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region
/// </summary>
/// <remarks>This requires a security audit.</remarks>
/// <param name="uuid"></param>
/// <param name="handle"></param>
/// <param name="authhash"></param>
/// <param name="challenge"></param>
/// <returns></returns>
public bool AuthenticateSim(LLUUID uuid, ulong handle, string authhash, string challenge)
{
SHA512Managed HashProvider = new SHA512Managed();
ASCIIEncoding TextProvider = new ASCIIEncoding();
byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge);
byte[] hash = HashProvider.ComputeHash(stream);
return false;
}
public ReservationData GetReservationAtPoint(uint x, uint y)
{
return null;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,105 +1,120 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace OpenSim.Framework.Data.MSSQL
{
/// <summary>
/// An interface to the log database for MySQL
/// </summary>
internal class MSSQLLogData : ILogData
{
/// <summary>
/// The database manager
/// </summary>
public MSSQLManager database;
/// <summary>
/// Artificial constructor called when the plugin is loaded
/// </summary>
public void Initialise()
{
IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini");
string settingDataSource = GridDataMySqlFile.ParseFileReadValue("data_source");
string settingInitialCatalog = GridDataMySqlFile.ParseFileReadValue("initial_catalog");
string settingPersistSecurityInfo = GridDataMySqlFile.ParseFileReadValue("persist_security_info");
string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id");
string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
database =
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
settingPassword);
}
/// <summary>
/// Saves a log item to the database
/// </summary>
/// <param name="serverDaemon">The daemon triggering the event</param>
/// <param name="target">The target of the action (region / agent UUID, etc)</param>
/// <param name="methodCall">The method call where the problem occured</param>
/// <param name="arguments">The arguments passed to the method</param>
/// <param name="priority">How critical is this?</param>
/// <param name="logMessage">The message to log</param>
public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,
string logMessage)
{
try
{
database.insertLogRow(serverDaemon, target, methodCall, arguments, priority, logMessage);
}
catch
{
database.Reconnect();
}
}
/// <summary>
/// Returns the name of this DB provider
/// </summary>
/// <returns>A string containing the DB provider name</returns>
public string getName()
{
return "MSSQL Logdata Interface";
}
/// <summary>
/// Closes the database provider
/// </summary>
public void Close()
{
// Do nothing.
}
/// <summary>
/// Returns the version of this DB provider
/// </summary>
/// <returns>A string containing the provider version</returns>
public string getVersion()
{
return "0.1";
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Collections.Generic;
using System.Data;
namespace OpenSim.Framework.Data.MSSQL
{
/// <summary>
/// An interface to the log database for MySQL
/// </summary>
internal class MSSQLLogData : ILogData
{
/// <summary>
/// The database manager
/// </summary>
public MSSQLManager database;
/// <summary>
/// Artificial constructor called when the plugin is loaded
/// </summary>
public void Initialise()
{
IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini");
string settingDataSource = GridDataMySqlFile.ParseFileReadValue("data_source");
string settingInitialCatalog = GridDataMySqlFile.ParseFileReadValue("initial_catalog");
string settingPersistSecurityInfo = GridDataMySqlFile.ParseFileReadValue("persist_security_info");
string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id");
string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
database =
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
settingPassword);
IDbCommand cmd = database.Query("select top 1 * from logs", new Dictionary<string, string>());
try
{
cmd.ExecuteNonQuery();
cmd.Dispose();
}
catch
{
database.ExecuteResourceSql("Mssql-logs.sql");
}
}
/// <summary>
/// Saves a log item to the database
/// </summary>
/// <param name="serverDaemon">The daemon triggering the event</param>
/// <param name="target">The target of the action (region / agent UUID, etc)</param>
/// <param name="methodCall">The method call where the problem occured</param>
/// <param name="arguments">The arguments passed to the method</param>
/// <param name="priority">How critical is this?</param>
/// <param name="logMessage">The message to log</param>
public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,
string logMessage)
{
try
{
database.insertLogRow(serverDaemon, target, methodCall, arguments, priority, logMessage);
}
catch
{
database.Reconnect();
}
}
/// <summary>
/// Returns the name of this DB provider
/// </summary>
/// <returns>A string containing the DB provider name</returns>
public string getName()
{
return "MSSQL Logdata Interface";
}
/// <summary>
/// Closes the database provider
/// </summary>
public void Close()
{
// Do nothing.
}
/// <summary>
/// Returns the version of this DB provider
/// </summary>
/// <returns>A string containing the provider version</returns>
public string getVersion()
{
return "0.1";
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,38 +1,66 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly : AssemblyTitle("OpenSim.Framework.Data.MSSQL")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("")]
[assembly : AssemblyProduct("OpenSim.Framework.Data.MSSQL")]
[assembly : AssemblyCopyright("Copyright © 2007")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly : ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly : Guid("0e1c1ca4-2cf2-4315-b0e7-432c02feea8a")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly : AssemblyTitle("OpenSim.Framework.Data.MSSQL")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("")]
[assembly : AssemblyProduct("OpenSim.Framework.Data.MSSQL")]
[assembly : AssemblyCopyright("Copyright © OpenSimulator.org Developers 2007-2008")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly : ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly : Guid("0e1c1ca4-2cf2-4315-b0e7-432c02feea8a")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,14 @@
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
SET ANSI_PADDING ON
CREATE TABLE [dbo].[userfriends](
[ownerID] [varchar](50) COLLATE Latin1_General_CI_AS NOT NULL,
[friendID] [varchar](50) COLLATE Latin1_General_CI_AS NOT NULL,
[friendPerms] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[datetimestamp] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
SET ANSI_PADDING OFF

View File

@ -0,0 +1,40 @@
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
SET ANSI_PADDING ON
CREATE TABLE [dbo].[regions](
[regionHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[regionName] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[uuid] [varchar](255) COLLATE Latin1_General_CI_AS NOT NULL,
[regionRecvKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[regionSecret] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[regionSendKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[regionDataURI] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[serverIP] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[serverPort] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[serverURI] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[locX] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[locY] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[locZ] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[eastOverrideHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[westOverrideHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[southOverrideHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[northOverrideHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[regionAssetURI] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[regionAssetRecvKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[regionAssetSendKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[regionUserURI] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[regionUserRecvKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[regionUserSendKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[regionMapTexture] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[serverHttpPort] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
[serverRemotingPort] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
PRIMARY KEY CLUSTERED
(
[uuid] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
SET ANSI_PADDING OFF

View File

@ -1,194 +1,214 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Data;
using libsecondlife;
using MySql.Data.MySqlClient;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.MySQL
{
internal class MySQLAssetData : IAssetProvider
{
private MySQLManager _dbConnection;
#region IAssetProvider Members
private void UpgradeAssetsTable(string oldVersion)
{
// null as the version, indicates that the table didn't exist
if (oldVersion == null)
{
MainLog.Instance.Notice("ASSETS", "Creating new database tables");
_dbConnection.ExecuteResourceSql("CreateAssetsTable.sql");
return;
}
}
/// <summary>
/// Ensure that the assets related tables exists and are at the latest version
/// </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)
{
AssetBase asset = null;
lock (_dbConnection)
{
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();
try
{
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
{
if (dbReader.Read())
{
asset = new AssetBase();
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"];
}
dbReader.Close();
cmd.Dispose();
}
}
catch (Exception)
{
MainLog.Instance.Warn("ASSETS", "MySql failure fetching asset");
}
}
return asset;
}
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);
// need to ensure we dispose
using (cmd)
{
MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16);
p.Value = asset.FullID.GetBytes();
cmd.Parameters.AddWithValue("?name", asset.Name);
cmd.Parameters.AddWithValue("?description", asset.Description);
cmd.Parameters.AddWithValue("?assetType", asset.Type);
cmd.Parameters.AddWithValue("?invType", asset.InvType);
cmd.Parameters.AddWithValue("?local", asset.Local);
cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
cmd.Parameters.AddWithValue("?data", asset.Data);
cmd.ExecuteNonQuery();
cmd.Dispose();
}
}
public void UpdateAsset(AssetBase asset)
{
CreateAsset(asset);
}
public bool ExistsAsset(LLUUID uuid)
{
throw new Exception("The method or operation is not implemented.");
}
// rex, new function, fixme not implemented
public List<AssetBase> GetAssetList(int vAssetType)
{
List<AssetBase> retvals = new List<AssetBase>();
return retvals;
}
/// <summary>
/// All writes are immediately commited to the database, so this is a no-op
/// </summary>
public void CommitAssets()
{
}
// rex new function for "replace assets" functionality
// TODO: actual implementation by someone, should return LLUUID of an asset
// with matching type & name, or zero if not in DB
public LLUUID ExistsAsset(sbyte type, string name)
{
return LLUUID.Zero;
}
#endregion
#region IPlugin Members
public void Initialise()
{
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
string hostname = GridDataMySqlFile.ParseFileReadValue("hostname");
string database = GridDataMySqlFile.ParseFileReadValue("database");
string username = GridDataMySqlFile.ParseFileReadValue("username");
string password = GridDataMySqlFile.ParseFileReadValue("password");
string pooling = GridDataMySqlFile.ParseFileReadValue("pooling");
string port = GridDataMySqlFile.ParseFileReadValue("port");
_dbConnection = new MySQLManager(hostname, database, username, password, pooling, port);
TestTables();
}
public string Version
{
get { return _dbConnection.getVersion(); }
}
public string Name
{
get { return "MySQL Asset storage engine"; }
}
#endregion
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Data;
using libsecondlife;
using MySql.Data.MySqlClient;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.MySQL
{
internal class MySQLAssetData : IAssetProvider
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private MySQLManager _dbConnection;
#region IAssetProvider Members
private void UpgradeAssetsTable(string oldVersion)
{
// null as the version, indicates that the table didn't exist
if (oldVersion == null)
{
m_log.Info("[ASSETS]: Creating new database tables");
_dbConnection.ExecuteResourceSql("CreateAssetsTable.sql");
return;
}
}
/// <summary>
/// Ensure that the assets related tables exists and are at the latest version
/// </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)
{
AssetBase asset = null;
lock (_dbConnection)
{
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();
try
{
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
{
if (dbReader.Read())
{
asset = new AssetBase();
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"];
}
dbReader.Close();
cmd.Dispose();
}
}
catch (Exception e)
{
m_log.ErrorFormat(
"[ASSETS]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString()
+ Environment.NewLine + "Attempting reconnection", assetID);
_dbConnection.Reconnect();
}
}
return asset;
}
public void CreateAsset(AssetBase asset)
{
lock (_dbConnection)
{
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);
// need to ensure we dispose
try
{
using (cmd)
{
MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16);
p.Value = asset.FullID.GetBytes();
cmd.Parameters.AddWithValue("?name", asset.Name);
cmd.Parameters.AddWithValue("?description", asset.Description);
cmd.Parameters.AddWithValue("?assetType", asset.Type);
cmd.Parameters.AddWithValue("?invType", asset.InvType);
cmd.Parameters.AddWithValue("?local", asset.Local);
cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
cmd.Parameters.AddWithValue("?data", asset.Data);
cmd.ExecuteNonQuery();
cmd.Dispose();
}
}
catch (Exception e)
{
m_log.ErrorFormat(
"[ASSETS]: " +
"MySql failure creating asset {0} with name {1}" + Environment.NewLine + e.ToString()
+ Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name);
_dbConnection.Reconnect();
}
}
}
public void UpdateAsset(AssetBase asset)
{
CreateAsset(asset);
}
public bool ExistsAsset(LLUUID uuid)
{
throw new Exception("The method or operation is not implemented.");
}
// rex, new function, fixme not implemented
public List<AssetBase> GetAssetList(int vAssetType)
{
List<AssetBase> retvals = new List<AssetBase>();
return retvals;
}
/// <summary>
/// All writes are immediately commited to the database, so this is a no-op
/// </summary>
public void CommitAssets()
{
}
// rex new function for "replace assets" functionality
// TODO: actual implementation by someone, should return LLUUID of an asset
// with matching type & name, or zero if not in DB
public LLUUID ExistsAsset(sbyte type, string name)
{
return LLUUID.Zero;
}
#endregion
#region IPlugin Members
public void Initialise()
{
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
string hostname = GridDataMySqlFile.ParseFileReadValue("hostname");
string database = GridDataMySqlFile.ParseFileReadValue("database");
string username = GridDataMySqlFile.ParseFileReadValue("username");
string password = GridDataMySqlFile.ParseFileReadValue("password");
string pooling = GridDataMySqlFile.ParseFileReadValue("pooling");
string port = GridDataMySqlFile.ParseFileReadValue("port");
_dbConnection = new MySQLManager(hostname, database, username, password, pooling, port);
TestTables();
}
public string Version
{
get { return _dbConnection.getVersion(); }
}
public string Name
{
get { return "MySQL Asset storage engine"; }
}
#endregion
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Data.Common;
using MySql.Data.MySqlClient;
//using TribalMedia.Framework.Data;
namespace OpenSim.Framework.Data.MySQL
{
/*
public class MySQLDatabaseMapper : OpenSimDatabaseConnector
{
public MySQLDatabaseMapper(string connectionString)
: base(connectionString)
{
}
public override DbConnection GetNewConnection()
{
MySqlConnection connection = new MySqlConnection(m_connectionString);
return connection;
}
public override string CreateParamName(string fieldName)
{
return "?" + fieldName;
}
}*/
}

View File

@ -1,413 +1,331 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Data;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using libsecondlife;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.MySQL
{
/// <summary>
/// A MySQL Interface for the Grid Server
/// </summary>
public class MySQLGridData : IGridData
{
/// <summary>
/// MySQL Database Manager
/// </summary>
private MySQLManager database;
/// <summary>
/// Initialises the Grid Interface
/// </summary>
public void Initialise()
{
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
string settingUsername = GridDataMySqlFile.ParseFileReadValue("username");
string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
database =
new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
settingPort);
TestTables();
}
#region Test and initialization code
/// <summary>
/// Ensure that the user related tables exists and are at the latest version
/// </summary>
private void TestTables()
{
Dictionary<string, string> tableList = new Dictionary<string, string>();
tableList["regions"] = null;
database.GetTableVersion(tableList);
UpgradeRegionsTable(tableList["regions"]);
}
/// <summary>
/// Create or upgrade the table if necessary
/// </summary>
/// <param name="oldVersion">A null indicates that the table does not
/// currently exist</param>
private void UpgradeRegionsTable(string oldVersion)
{
// null as the version, indicates that the table didn't exist
if (oldVersion == null)
{
database.ExecuteResourceSql("CreateRegionsTable.sql");
return;
}
}
#endregion
/// <summary>
/// Shuts down the grid interface
/// </summary>
public void Close()
{
database.Close();
}
/// <summary>
/// Returns the plugin name
/// </summary>
/// <returns>Plugin name</returns>
public string getName()
{
return "MySql OpenGridData";
}
/// <summary>
/// Returns the plugin version
/// </summary>
/// <returns>Plugin version</returns>
public string getVersion()
{
return "0.1";
}
/// <summary>
/// Returns all the specified region profiles within coordates -- coordinates are inclusive
/// </summary>
/// <param name="xmin">Minimum X coordinate</param>
/// <param name="ymin">Minimum Y coordinate</param>
/// <param name="xmax">Maximum X coordinate</param>
/// <param name="ymax">Maximum Y coordinate</param>
/// <returns></returns>
public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax)
{
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["?xmin"] = xmin.ToString();
param["?ymin"] = ymin.ToString();
param["?xmax"] = xmax.ToString();
param["?ymax"] = ymax.ToString();
IDbCommand result =
database.Query(
"SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax",
param);
IDataReader reader = result.ExecuteReader();
RegionProfileData row;
List<RegionProfileData> rows = new List<RegionProfileData>();
while ((row = database.readSimRow(reader)) != null)
{
rows.Add(row);
}
reader.Close();
result.Dispose();
return rows.ToArray();
}
}
catch (Exception e)
{
database.Reconnect();
MainLog.Instance.Error(e.ToString());
return null;
}
}
/// <summary>
/// Returns a sim profile from it's location
/// </summary>
/// <param name="handle">Region location handle</param>
/// <returns>Sim profile</returns>
public RegionProfileData GetProfileByHandle(ulong handle)
{
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["?handle"] = handle.ToString();
IDbCommand result = database.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param);
IDataReader reader = result.ExecuteReader();
RegionProfileData row = database.readSimRow(reader);
reader.Close();
result.Dispose();
return row;
}
}
catch (Exception e)
{
database.Reconnect();
MainLog.Instance.Error(e.ToString());
return null;
}
}
/// <summary>
/// // Returns a list of avatar and UUIDs that match the query
/// </summary>
public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
{
List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]");
string[] querysplit;
querysplit = query.Split(' ');
if (querysplit.Length == 2)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], "") + "%";
param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], "") + "%";
try
{
lock (database)
{
IDbCommand result =
database.Query(
"SELECT UUID,username,surname FROM users WHERE username like ?first AND lastname like ?second LIMIT 100",
param);
IDataReader reader = result.ExecuteReader();
while (reader.Read())
{
AvatarPickerAvatar user = new AvatarPickerAvatar();
user.AvatarID = new LLUUID((string) reader["UUID"]);
user.firstName = (string) reader["username"];
user.lastName = (string) reader["surname"];
returnlist.Add(user);
}
reader.Close();
result.Dispose();
}
}
catch (Exception e)
{
database.Reconnect();
MainLog.Instance.Error(e.ToString());
return returnlist;
}
}
else if (querysplit.Length == 1)
{
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], "") + "%";
IDbCommand result =
database.Query(
"SELECT UUID,username,surname FROM users WHERE username like ?first OR lastname like ?second",
param);
IDataReader reader = result.ExecuteReader();
while (reader.Read())
{
AvatarPickerAvatar user = new AvatarPickerAvatar();
user.AvatarID = new LLUUID((string) reader["UUID"]);
user.firstName = (string) reader["username"];
user.lastName = (string) reader["surname"];
returnlist.Add(user);
}
reader.Close();
result.Dispose();
}
}
catch (Exception e)
{
database.Reconnect();
MainLog.Instance.Error(e.ToString());
return returnlist;
}
}
return returnlist;
}
/// <summary>
/// Returns a sim profile from it's UUID
/// </summary>
/// <param name="uuid">The region UUID</param>
/// <returns>The sim profile</returns>
public RegionProfileData GetProfileByLLUUID(LLUUID uuid)
{
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["?uuid"] = uuid.ToString();
IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = ?uuid", param);
IDataReader reader = result.ExecuteReader();
RegionProfileData row = database.readSimRow(reader);
reader.Close();
result.Dispose();
return row;
}
}
catch (Exception e)
{
database.Reconnect();
MainLog.Instance.Error(e.ToString());
return null;
}
}
/// <summary>
/// Adds a new profile to the database
/// </summary>
/// <param name="profile">The profile to add</param>
/// <returns>Successful?</returns>
public DataResponse AddProfile(RegionProfileData profile)
{
lock (database)
{
if (database.insertRegion(profile))
{
return DataResponse.RESPONSE_OK;
}
else
{
return DataResponse.RESPONSE_ERROR;
}
}
}
/// <summary>
/// DEPRECIATED. Attempts to authenticate a region by comparing a shared secret.
/// </summary>
/// <param name="uuid">The UUID of the challenger</param>
/// <param name="handle">The attempted regionHandle of the challenger</param>
/// <param name="authkey">The secret</param>
/// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey)
{
bool throwHissyFit = false; // Should be true by 1.0
if (throwHissyFit)
throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
RegionProfileData data = GetProfileByLLUUID(uuid);
return (handle == data.regionHandle && authkey == data.regionSecret);
}
/// <summary>
/// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region
/// </summary>
/// <remarks>This requires a security audit.</remarks>
/// <param name="uuid"></param>
/// <param name="handle"></param>
/// <param name="authhash"></param>
/// <param name="challenge"></param>
/// <returns></returns>
public bool AuthenticateSim(LLUUID uuid, ulong handle, string authhash, string challenge)
{
SHA512Managed HashProvider = new SHA512Managed();
ASCIIEncoding TextProvider = new ASCIIEncoding();
byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge);
byte[] hash = HashProvider.ComputeHash(stream);
return false;
}
public ReservationData GetReservationAtPoint(uint x, uint y)
{
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["?x"] = x.ToString();
param["?y"] = y.ToString();
IDbCommand result =
database.Query(
"SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y",
param);
IDataReader reader = result.ExecuteReader();
ReservationData row = database.readReservationRow(reader);
reader.Close();
result.Dispose();
return row;
}
}
catch (Exception e)
{
database.Reconnect();
MainLog.Instance.Error(e.ToString());
return null;
}
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Data;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using libsecondlife;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.MySQL
{
/// <summary>
/// A MySQL Interface for the Grid Server
/// </summary>
public class MySQLGridData : IGridData
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// MySQL Database Manager
/// </summary>
private MySQLManager database;
/// <summary>
/// Initialises the Grid Interface
/// </summary>
public void Initialise()
{
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
string settingUsername = GridDataMySqlFile.ParseFileReadValue("username");
string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
database =
new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
settingPort);
TestTables();
}
#region Test and initialization code
/// <summary>
/// Ensure that the user related tables exists and are at the latest version
/// </summary>
private void TestTables()
{
Dictionary<string, string> tableList = new Dictionary<string, string>();
tableList["regions"] = null;
database.GetTableVersion(tableList);
UpgradeRegionsTable(tableList["regions"]);
}
/// <summary>
/// Create or upgrade the table if necessary
/// </summary>
/// <param name="oldVersion">A null indicates that the table does not
/// currently exist</param>
private void UpgradeRegionsTable(string oldVersion)
{
// null as the version, indicates that the table didn't exist
if (oldVersion == null)
{
database.ExecuteResourceSql("CreateRegionsTable.sql");
return;
}
}
#endregion
/// <summary>
/// Shuts down the grid interface
/// </summary>
public void Close()
{
database.Close();
}
/// <summary>
/// Returns the plugin name
/// </summary>
/// <returns>Plugin name</returns>
public string getName()
{
return "MySql OpenGridData";
}
/// <summary>
/// Returns the plugin version
/// </summary>
/// <returns>Plugin version</returns>
public string getVersion()
{
return "0.1";
}
/// <summary>
/// Returns all the specified region profiles within coordates -- coordinates are inclusive
/// </summary>
/// <param name="xmin">Minimum X coordinate</param>
/// <param name="ymin">Minimum Y coordinate</param>
/// <param name="xmax">Maximum X coordinate</param>
/// <param name="ymax">Maximum Y coordinate</param>
/// <returns></returns>
public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax)
{
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["?xmin"] = xmin.ToString();
param["?ymin"] = ymin.ToString();
param["?xmax"] = xmax.ToString();
param["?ymax"] = ymax.ToString();
IDbCommand result =
database.Query(
"SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax",
param);
IDataReader reader = result.ExecuteReader();
RegionProfileData row;
List<RegionProfileData> rows = new List<RegionProfileData>();
while ((row = database.readSimRow(reader)) != null)
{
rows.Add(row);
}
reader.Close();
result.Dispose();
return rows.ToArray();
}
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
return null;
}
}
/// <summary>
/// Returns a sim profile from it's location
/// </summary>
/// <param name="handle">Region location handle</param>
/// <returns>Sim profile</returns>
public RegionProfileData GetProfileByHandle(ulong handle)
{
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["?handle"] = handle.ToString();
IDbCommand result = database.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param);
IDataReader reader = result.ExecuteReader();
RegionProfileData row = database.readSimRow(reader);
reader.Close();
result.Dispose();
return row;
}
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
return null;
}
}
/// <summary>
/// Returns a sim profile from it's UUID
/// </summary>
/// <param name="uuid">The region UUID</param>
/// <returns>The sim profile</returns>
public RegionProfileData GetProfileByLLUUID(LLUUID uuid)
{
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["?uuid"] = uuid.ToString();
IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = ?uuid", param);
IDataReader reader = result.ExecuteReader();
RegionProfileData row = database.readSimRow(reader);
reader.Close();
result.Dispose();
return row;
}
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
return null;
}
}
/// <summary>
/// Adds a new profile to the database
/// </summary>
/// <param name="profile">The profile to add</param>
/// <returns>Successful?</returns>
public DataResponse AddProfile(RegionProfileData profile)
{
lock (database)
{
if (database.insertRegion(profile))
{
return DataResponse.RESPONSE_OK;
}
else
{
return DataResponse.RESPONSE_ERROR;
}
}
}
/// <summary>
/// DEPRECIATED. Attempts to authenticate a region by comparing a shared secret.
/// </summary>
/// <param name="uuid">The UUID of the challenger</param>
/// <param name="handle">The attempted regionHandle of the challenger</param>
/// <param name="authkey">The secret</param>
/// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey)
{
bool throwHissyFit = false; // Should be true by 1.0
if (throwHissyFit)
throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
RegionProfileData data = GetProfileByLLUUID(uuid);
return (handle == data.regionHandle && authkey == data.regionSecret);
}
/// <summary>
/// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region
/// </summary>
/// <remarks>This requires a security audit.</remarks>
/// <param name="uuid"></param>
/// <param name="handle"></param>
/// <param name="authhash"></param>
/// <param name="challenge"></param>
/// <returns></returns>
public bool AuthenticateSim(LLUUID uuid, ulong handle, string authhash, string challenge)
{
SHA512Managed HashProvider = new SHA512Managed();
ASCIIEncoding TextProvider = new ASCIIEncoding();
byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge);
byte[] hash = HashProvider.ComputeHash(stream);
return false;
}
public ReservationData GetReservationAtPoint(uint x, uint y)
{
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["?x"] = x.ToString();
param["?y"] = y.ToString();
IDbCommand result =
database.Query(
"SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y",
param);
IDataReader reader = result.ExecuteReader();
ReservationData row = database.readReservationRow(reader);
reader.Close();
result.Dispose();
return row;
}
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
return null;
}
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,38 +1,66 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly : AssemblyTitle("OpenSim.Framework.Data.MySQL")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("")]
[assembly : AssemblyProduct("OpenSim.Framework.Data.MySQL")]
[assembly : AssemblyCopyright("Copyright © 2007")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly : ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly : Guid("e49826b2-dcef-41be-a5bd-596733fa3304")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly : AssemblyTitle("OpenSim.Framework.Data.MySQL")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("")]
[assembly : AssemblyProduct("OpenSim.Framework.Data.MySQL")]
[assembly : AssemblyCopyright("Copyright © OpenSimulator.org Developers 2007-2008")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly : ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly : Guid("e49826b2-dcef-41be-a5bd-596733fa3304")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,42 @@
--
-- Create schema avatar_appearance
--
CREATE DATABASE IF NOT EXISTS avatar_appearance;
USE avatar_appearance;
DROP TABLE IF EXISTS `avatarappearance`;
CREATE TABLE `avatarappearance` (
`UUID` char(36) NOT NULL,
`Serial` int(10) unsigned NOT NULL,
`WearableItem0` char(36) NOT NULL,
`WearableAsset0` char(36) NOT NULL,
`WearableItem1` char(36) NOT NULL,
`WearableAsset1` char(36) NOT NULL,
`WearableItem2` char(36) NOT NULL,
`WearableAsset2` char(36) NOT NULL,
`WearableItem3` char(36) NOT NULL,
`WearableAsset3` char(36) NOT NULL,
`WearableItem4` char(36) NOT NULL,
`WearableAsset4` char(36) NOT NULL,
`WearableItem5` char(36) NOT NULL,
`WearableAsset5` char(36) NOT NULL,
`WearableItem6` char(36) NOT NULL,
`WearableAsset6` char(36) NOT NULL,
`WearableItem7` char(36) NOT NULL,
`WearableAsset7` char(36) NOT NULL,
`WearableItem8` char(36) NOT NULL,
`WearableAsset8` char(36) NOT NULL,
`WearableItem9` char(36) NOT NULL,
`WearableAsset9` char(36) NOT NULL,
`WearableItem10` char(36) NOT NULL,
`WearableAsset10` char(36) NOT NULL,
`WearableItem11` char(36) NOT NULL,
`WearableAsset11` char(36) NOT NULL,
`WearableItem12` char(36) NOT NULL,
`WearableAsset12` char(36) NOT NULL,
PRIMARY KEY (`UUID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -1,11 +1,11 @@
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for users
-- ----------------------------
CREATE TABLE `userfriends` (
`ownerID` VARCHAR(37) NOT NULL,
`friendID` VARCHAR(47) NOT NULL,
`friendPerms` INT NOT NULL,
`datetimestamp` INT NOT NULL,
UNIQUE KEY (`ownerID`, `friendID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.1';
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for users
-- ----------------------------
CREATE TABLE `userfriends` (
`ownerID` VARCHAR(37) NOT NULL,
`friendID` VARCHAR(37) NOT NULL,
`friendPerms` INT NOT NULL,
`datetimestamp` INT NOT NULL,
UNIQUE KEY (`ownerID`, `friendID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.1';

View File

@ -1,38 +1,66 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly : AssemblyTitle("OpenSim.Framework.Data.SQLite")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("")]
[assembly : AssemblyProduct("OpenSim.Framework.Data.SQLite")]
[assembly : AssemblyCopyright("Copyright © 2007")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly : ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly : Guid("6113d5ce-4547-49f4-9236-0dcc503457b1")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly : AssemblyVersion("0.4.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly : AssemblyTitle("OpenSim.Framework.Data.SQLite")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("")]
[assembly : AssemblyProduct("OpenSim.Framework.Data.SQLite")]
[assembly : AssemblyCopyright("Copyright © OpenSimulator.org Developers 2007-2008")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly : ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly : Guid("6113d5ce-4547-49f4-9236-0dcc503457b1")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,13 @@
BEGIN TRANSACTION;
CREATE TABLE assets(
UUID varchar(255) primary key,
Name varchar(255),
Description varchar(255),
Type integer,
InvType integer,
Local integer,
Temporary integer,
Data blob);
COMMIT;

View File

@ -0,0 +1,26 @@
BEGIN TRANSACTION;
CREATE TABLE inventoryitems(
UUID varchar(255) primary key,
assetID varchar(255),
assetType integer,
invType integer,
parentFolderID varchar(255),
avatarID varchar(255),
creatorsID varchar(255),
inventoryName varchar(255),
inventoryDescription varchar(255),
inventoryNextPermissions integer,
inventoryCurrentPermissions integer,
inventoryBasePermissions integer,
inventoryEveryOnePermissions integer);
CREATE TABLE inventoryfolders(
UUID varchar(255) primary key,
name varchar(255),
agentID varchar(255),
parentID varchar(255),
type integer,
version integer);
COMMIT;

View File

@ -0,0 +1,121 @@
BEGIN TRANSACTION;
CREATE TABLE prims(
UUID varchar(255) primary key,
RegionUUID varchar(255),
ParentID integer,
CreationDate integer,
Name varchar(255),
SceneGroupID varchar(255),
Text varchar(255),
Description varchar(255),
SitName varchar(255),
TouchName varchar(255),
CreatorID varchar(255),
OwnerID varchar(255),
GroupID varchar(255),
LastOwnerID varchar(255),
OwnerMask integer,
NextOwnerMask integer,
GroupMask integer,
EveryoneMask integer,
BaseMask integer,
PositionX float,
PositionY float,
PositionZ float,
GroupPositionX float,
GroupPositionY float,
GroupPositionZ float,
VelocityX float,
VelocityY float,
VelocityZ float,
AngularVelocityX float,
AngularVelocityY float,
AngularVelocityZ float,
AccelerationX float,
AccelerationY float,
AccelerationZ float,
RotationX float,
RotationY float,
RotationZ float,
RotationW float,
ObjectFlags integer,
SitTargetOffsetX float NOT NULL default 0,
SitTargetOffsetY float NOT NULL default 0,
SitTargetOffsetZ float NOT NULL default 0,
SitTargetOrientW float NOT NULL default 0,
SitTargetOrientX float NOT NULL default 0,
SitTargetOrientY float NOT NULL default 0,
SitTargetOrientZ float NOT NULL default 0);
CREATE TABLE primshapes(UUID varchar(255) primary key,
Shape integer,
ScaleX float,
ScaleY float,
ScaleZ float,
PCode integer,
PathBegin integer,
PathEnd integer,
PathScaleX integer,
PathScaleY integer,
PathShearX integer,
PathShearY integer,
PathSkew integer,
PathCurve integer,
PathRadiusOffset integer,
PathRevolutions integer,
PathTaperX integer,
PathTaperY integer,
PathTwist integer,
PathTwistBegin integer,
ProfileBegin integer,
ProfileEnd integer,
ProfileCurve integer,
ProfileHollow integer,
Texture blob,
ExtraParams blob);
CREATE TABLE terrain(
RegionUUID varchar(255),
Revision integer,
Heightfield blob);
CREATE TABLE land(
UUID varchar(255) primary key,
RegionUUID varchar(255),
LocalLandID string,
Bitmap blob,
Name varchar(255),
Desc varchar(255),
OwnerUUID varchar(36),
IsGroupOwned string,
Area integer,
AuctionID integer,
Category integer,
ClaimDate integer,
ClaimPrice integer,
GroupUUID varchar(255),
SalePrice integer,
LandStatus integer,
LandFlags string,
LandingType string,
MediaAutoScale string,
MediaTextureUUID varchar(255),
MediaURL varchar(255),
MusicURL varchar(255),
PassHours float,
PassPrice string,
SnapshotUUID varchar(255),
UserLocationX float,
UserLocationY float,
UserLocationZ float,
UserLookAtX float,
UserLookAtY float,
UserLookAtZ float);
CREATE TABLE landaccesslist(
LandUUID varchar(255),
AccessUUID varchar(255),
Flags string);
COMMIT;

View File

@ -0,0 +1,37 @@
BEGIN TRANSACTION;
CREATE TABLE users(
UUID varchar(255) primary key,
username varchar(255),
surname varchar(255),
passwordHash varchar(255),
passwordSalt varchar(255),
homeRegionX integer,
homeRegionY integer,
homeLocationX float,
homeLocationY float,
homeLocationZ float,
homeLookAtX float,
homeLookAtY float,
homeLookAtZ float,
created integer,
lastLogin integer,
rootInventoryFolderID varchar(255),
userInventoryURI varchar(255),
userAssetURI varchar(255),
profileCanDoMask integer,
profileWantDoMask integer,
profileAboutText varchar(255),
profileFirstText varchar(255),
profileImage varchar(255),
profileFirstImage varchar(255),
webLoginKey text default '00000000-0000-0000-0000-000000000000');
CREATE TABLE userfriends(
ownerID varchar(255),
friendID varchar(255),
friendPerms integer,
ownerPerms integer,
datetimestamp integer);
COMMIT;

View File

@ -1,379 +1,391 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Data;
using System.Reflection;
using libsecondlife;
using Mono.Data.SqliteClient;
using OpenSim.Framework.Console;
using System.Collections.Generic; // rex added
namespace OpenSim.Framework.Data.SQLite
{
/// <summary>
/// A User storage interface for the DB4o database system
/// </summary>
public class SQLiteAssetData : SQLiteBase, IAssetProvider
{
/// <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;
public void Initialise(string dbfile, string dbname)
{
SqliteConnection conn = new SqliteConnection("URI=file:" + dbfile + ",version=3");
TestTables(conn);
ds = new DataSet();
da = new SqliteDataAdapter(new SqliteCommand(assetSelect, conn));
lock (ds)
{
ds.Tables.Add(createAssetsTable());
setupAssetCommands(da, conn);
try
{
da.Fill(ds.Tables["assets"]);
}
catch (Exception e)
{
MainLog.Instance.Verbose("SQLITE", e.ToString());
}
}
return;
}
public AssetBase FetchAsset(LLUUID uuid)
{
AssetBase asset = new AssetBase();
DataRow row = ds.Tables["assets"].Rows.Find(Util.ToRawUuidString(uuid));
if (row != null)
{
return buildAsset(row);
}
else
{
return null;
}
}
public void CreateAsset(AssetBase asset)
{
// no difference for now
UpdateAsset(asset);
}
public void UpdateAsset(AssetBase asset)
{
LogAssetLoad(asset);
DataTable assets = ds.Tables["assets"];
lock (ds)
{
DataRow row = assets.Rows.Find(Util.ToRawUuidString(asset.FullID));
if (row == null)
{
row = assets.NewRow();
fillAssetRow(row, asset);
assets.Rows.Add(row);
}
else
{
fillAssetRow(row, asset);
}
}
}
// rex new function for "replace assets" functionality
public LLUUID ExistsAsset(sbyte type, string name)
{
LLUUID retVal = LLUUID.Zero;
lock (ds)
{
string selectExp = "Type = '" + type.ToString() + "' AND Name = '" + name + "'";
DataRow[] match = ds.Tables["assets"].Select(selectExp);
if (match.Length > 0)
{
retVal = new LLUUID((String)match[0]["UUID"]);
}
}
return retVal;
}
private void LogAssetLoad(AssetBase asset)
{
string temporary = asset.Temporary ? "Temporary" : "Stored";
string local = asset.Local ? "Local" : "Remote";
MainLog.Instance.Verbose("SQLITE",
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)
{
DataRow row = ds.Tables["assets"].Rows.Find(Util.ToRawUuidString(uuid));
return (row != null);
}
// rex, new function
public List<AssetBase> GetAssetList(int vAssetType)
{
List<AssetBase> retvals = new List<AssetBase>();
lock (ds)
{
string selectExp = "InvType = '" + vAssetType.ToString() + "'";
DataRow[] allAssets = ds.Tables["assets"].Select(selectExp);
foreach (DataRow row in allAssets)
{
// Do not use buildAsset(row) because we don't want to return the asset.data - Tuco
AssetBase asset = new AssetBase();
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"]);
retvals.Add(asset);
}
}
return retvals;
}
public void DeleteAsset(LLUUID uuid)
{
lock (ds)
{
DataRow row = ds.Tables["assets"].Rows.Find(Util.ToRawUuidString(uuid));
if (row != null)
{
row.Delete();
}
}
}
public void CommitAssets() // force a sync to the database
{
MainLog.Instance.Verbose("SQLITE", "Attempting commit");
lock (ds)
{
da.Update(ds, "assets");
ds.AcceptChanges();
}
}
/***********************************************************************
*
* Database Definition Functions
*
* 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 (String));
createCol(assets, "Name", typeof (String));
createCol(assets, "Description", typeof (String));
createCol(assets, "MediaURL", typeof(String));//rex mediaurl
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"]};
return assets;
}
/***********************************************************************
*
* Convert between ADO.NET <=> OpenSim Objects
*
* These should be database independant
*
**********************************************************************/
private AssetBase buildAsset(DataRow row)
{
// TODO: this doesn't work yet because something more
// 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"];
try
{
asset.MediaURL = (String) row["MediaURL"];//rex mediaurl
}
catch (Exception)
{
asset.MediaURL = ""; // fixme, the row returns null which can't be cast to string, happens with old dbs right now. - Tuco
}
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"];
return asset;
}
private void fillAssetRow(DataRow row, AssetBase asset)
{
row["UUID"] = Util.ToRawUuidString(asset.FullID);
row["Name"] = asset.Name;
if (asset.Description != null)
{
row["Description"] = asset.Description;
}
else
{
row["Description"] = " ";
}
if (asset.MediaURL != null) //rex mediaurl
{
row["MediaURL"] = asset.MediaURL;
}
else
{
row["MediaURL"] = " ";
}
row["Type"] = asset.Type;
row["InvType"] = asset.InvType;
row["Local"] = asset.Local;
row["Temporary"] = asset.Temporary;
row["Data"] = asset.Data;
// ADO.NET doesn't handle NULL very well
foreach (DataColumn col in ds.Tables["assets"].Columns)
{
if (row[col] == null)
{
row[col] = "";
}
}
}
/***********************************************************************
*
* Database Binding functions
*
* These will be db specific due to typing, and minor differences
* in databases.
*
**********************************************************************/
private void setupAssetCommands(SqliteDataAdapter da, SqliteConnection conn)
{
da.InsertCommand = createInsertCommand("assets", ds.Tables["assets"]);
da.InsertCommand.Connection = conn;
da.UpdateCommand = createUpdateCommand("assets", "UUID=:UUID", ds.Tables["assets"]);
da.UpdateCommand.Connection = conn;
SqliteCommand delete = new SqliteCommand("delete from assets where UUID = :UUID");
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();
}
private bool TestTables(SqliteConnection conn)
{
SqliteCommand cmd = new SqliteCommand(assetSelect, conn);
SqliteDataAdapter pDa = new SqliteDataAdapter(cmd);
DataSet tmpDS = new DataSet();
try
{
pDa.Fill(tmpDS, "assets");
}
catch (SqliteSyntaxException)
{
MainLog.Instance.Verbose("SQLITE", "SQLite Database doesn't exist... creating");
InitDB(conn);
}
return true;
}
#region IPlugin interface
public string Version
{
get
{
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);
}
}
public void Initialise()
{
Initialise("AssetStorage.db", "");
}
public string Name
{
get { return "SQLite Asset storage engine"; }
}
#endregion
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Data;
using System.Reflection;
using libsecondlife;
using Mono.Data.SqliteClient;
using OpenSim.Framework.Console;
using System.Collections.Generic; // rex added
namespace OpenSim.Framework.Data.SQLite
{
/// <summary>
/// A User storage interface for the DB4o database system
/// </summary>
public class SQLiteAssetData : SQLiteBase, IAssetProvider
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// The database manager
/// </summary>
/// <summary>
/// Artificial constructor called upon plugin load
/// </summary>
private const string SelectAssetSQL = "select * from assets where UUID=:UUID";
private const string DeleteAssetSQL = "delete from assets where UUID=:UUID";
private const string InsertAssetSQL = "insert into assets(UUID, Name, Description, Type, InvType, Local, Temporary, Data) values(:UUID, :Name, :Description, :Type, :InvType, :Local, :Temporary, :Data)";
private const string UpdateAssetSQL = "update assets set Name=:Name, Description=:Description, Type=:Type, InvType=:InvType, Local=:Local, Temporary=:Temporary, Data=:Data where UUID=:UUID";
private const string assetSelect = "select * from assets";
private SqliteConnection m_conn;
public void Initialise(string dbfile, string dbname)
{
m_conn = new SqliteConnection("URI=file:" + dbfile + ",version=3");
m_conn.Open();
TestTables(m_conn);
return;
}
public AssetBase FetchAsset(LLUUID uuid)
{
using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn))
{
cmd.Parameters.Add(new SqliteParameter(":UUID", Util.ToRawUuidString(uuid)));
using (IDataReader reader = cmd.ExecuteReader())
{
if (reader.Read())
{
AssetBase asset = buildAsset(reader);
reader.Close();
return asset;
}
else
{
reader.Close();
return null;
}
}
}
}
public void CreateAsset(AssetBase asset)
{
m_log.Info("[SQLITE]: Creating Asset " + Util.ToRawUuidString(asset.FullID));
if (ExistsAsset(asset.FullID))
{
m_log.Info("[SQLITE]: Asset exists, updating instead. You should fix the caller for this!");
UpdateAsset(asset);
}
else
{
using (SqliteCommand cmd = new SqliteCommand(InsertAssetSQL, m_conn))
{
cmd.Parameters.Add(new SqliteParameter(":UUID", Util.ToRawUuidString(asset.FullID)));
cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name));
cmd.Parameters.Add(new SqliteParameter(":Description", asset.Description));
cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type));
cmd.Parameters.Add(new SqliteParameter(":InvType", asset.InvType));
cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local));
cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary));
cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data));
cmd.ExecuteNonQuery();
}
}
}
public void UpdateAsset(AssetBase asset)
{
LogAssetLoad(asset);
using (SqliteCommand cmd = new SqliteCommand(UpdateAssetSQL, m_conn))
{
cmd.Parameters.Add(new SqliteParameter(":UUID", Util.ToRawUuidString(asset.FullID)));
cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name));
cmd.Parameters.Add(new SqliteParameter(":Description", asset.Description));
cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type));
cmd.Parameters.Add(new SqliteParameter(":InvType", asset.InvType));
cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local));
cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary));
cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data));
cmd.ExecuteNonQuery();
}
}
// rex new function for "replace assets" functionality
public LLUUID ExistsAsset(sbyte type, string name)
{
LLUUID retVal = LLUUID.Zero;
lock (ds)
{
string selectExp = "Type = '" + type.ToString() + "' AND Name = '" + name + "'";
DataRow[] match = ds.Tables["assets"].Select(selectExp);
if (match.Length > 0)
{
retVal = new LLUUID((String)match[0]["UUID"]);
}
}
return retVal;
}
private void LogAssetLoad(AssetBase asset)
{
string temporary = asset.Temporary ? "Temporary" : "Stored";
string local = asset.Local ? "Local" : "Remote";
m_log.Info("[SQLITE]: " +
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)
{
using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn))
{
cmd.Parameters.Add(new SqliteParameter(":UUID", Util.ToRawUuidString(uuid)));
using (IDataReader reader = cmd.ExecuteReader())
{
if(reader.Read())
{
reader.Close();
return true;
}
else
{
reader.Close();
return false;
}
}
}
}
// rex, new function
public List<AssetBase> GetAssetList(int vAssetType)
{
List<AssetBase> retvals = new List<AssetBase>();
lock (ds)
{
string selectExp = "InvType = '" + vAssetType.ToString() + "'";
DataRow[] allAssets = ds.Tables["assets"].Select(selectExp);
foreach (DataRow row in allAssets)
{
// Do not use buildAsset(row) because we don't want to return the asset.data - Tuco
AssetBase asset = new AssetBase();
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"]);
retvals.Add(asset);
}
}
return retvals;
}
public void DeleteAsset(LLUUID uuid)
{
using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn))
{
cmd.Parameters.Add(new SqliteParameter(":UUID", Util.ToRawUuidString(uuid)));
cmd.ExecuteNonQuery();
}
}
public void CommitAssets() // force a sync to the database
{
m_log.Info("[SQLITE]: Attempting commit");
// lock (ds)
// {
// da.Update(ds, "assets");
// ds.AcceptChanges();
// }
}
/***********************************************************************
*
* Database Definition Functions
*
* 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 (String));
createCol(assets, "Name", typeof (String));
createCol(assets, "Description", typeof (String));
createCol(assets, "MediaURL", typeof(String));//rex mediaurl
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"]};
return assets;
}
/***********************************************************************
*
* Convert between ADO.NET <=> OpenSim Objects
*
* These should be database independant
*
**********************************************************************/
private AssetBase buildAsset(IDataReader row)
{
// TODO: this doesn't work yet because something more
// 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"];
try
{
asset.MediaURL = (String) row["MediaURL"];//rex mediaurl
}
catch (Exception)
{
asset.MediaURL = ""; // fixme, the row returns null which can't be cast to string, happens with old dbs right now. - Tuco
}
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"];
return asset;
}
private void fillAssetRow(DataRow row, AssetBase asset)
{
row["UUID"] = Util.ToRawUuidString(asset.FullID);
row["Name"] = asset.Name;
if (asset.Description != null)
{
row["Description"] = asset.Description;
}
else
{
row["Description"] = " ";
}
if (asset.MediaURL != null) //rex mediaurl
{
row["MediaURL"] = asset.MediaURL;
}
else
{
row["MediaURL"] = " ";
}
row["Type"] = asset.Type;
row["InvType"] = asset.InvType;
row["Local"] = asset.Local;
row["Temporary"] = asset.Temporary;
row["Data"] = asset.Data;
// ADO.NET doesn't handle NULL very well
foreach (DataColumn col in ds.Tables["assets"].Columns)
{
if (row[col] == null)
{
row[col] = "";
}
}
}
/***********************************************************************
*
* Database Binding functions
*
* These will be db specific due to typing, and minor differences
* in databases.
*
**********************************************************************/
private void InitDB(SqliteConnection conn)
{
string createAssets = defineTable(createAssetsTable());
SqliteCommand pcmd = new SqliteCommand(createAssets, conn);
pcmd.ExecuteNonQuery();
}
private bool TestTables(SqliteConnection conn)
{
SqliteCommand cmd = new SqliteCommand(assetSelect, conn);
SqliteDataAdapter pDa = new SqliteDataAdapter(cmd);
DataSet tmpDS = new DataSet();
try
{
pDa.Fill(tmpDS, "assets");
}
catch (SqliteSyntaxException)
{
m_log.Info("[SQLITE]: SQLite Database doesn't exist... creating");
InitDB(conn);
}
return true;
}
#region IPlugin interface
public string Version
{
get
{
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);
}
}
public void Initialise()
{
Initialise("AssetStorage.db", "");
}
public string Name
{
get { return "SQLite Asset storage engine"; }
}
#endregion
}
}

View File

@ -1,269 +1,269 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Data;
using Mono.Data.SqliteClient;
namespace OpenSim.Framework.Data.SQLite
{
/// <summary>
/// A base class for methods needed by all SQLite database classes
/// </summary>
public class SQLiteBase
{
/***********************************************************************
*
* Database Definition Functions
*
* This should be db agnostic as we define them in ADO.NET terms
*
**********************************************************************/
protected static void createCol(DataTable dt, string name, Type type)
{
DataColumn col = new DataColumn(name, type);
dt.Columns.Add(col);
}
/***********************************************************************
*
* SQL Statement Creation Functions
*
* These functions create SQL statements for update, insert, and create.
* They can probably be factored later to have a db independant
* portion and a db specific portion
*
**********************************************************************/
protected static SqliteCommand createInsertCommand(string table, DataTable dt)
{
/**
* This is subtle enough to deserve some commentary.
* Instead of doing *lots* and *lots of hardcoded strings
* for database definitions we'll use the fact that
* realistically all insert statements look like "insert
* into A(b, c) values(:b, :c) on the parameterized query
* front. If we just have a list of b, c, etc... we can
* generate these strings instead of typing them out.
*/
string[] cols = new string[dt.Columns.Count];
for (int i = 0; i < dt.Columns.Count; i++)
{
DataColumn col = dt.Columns[i];
cols[i] = col.ColumnName;
}
string sql = "insert into " + table + "(";
sql += String.Join(", ", cols);
// important, the first ':' needs to be here, the rest get added in the join
sql += ") values (:";
sql += String.Join(", :", cols);
sql += ")";
SqliteCommand cmd = new SqliteCommand(sql);
// this provides the binding for all our parameters, so
// much less code than it used to be
foreach (DataColumn col in dt.Columns)
{
cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType));
}
return cmd;
}
protected static SqliteCommand createUpdateCommand(string table, string pk, DataTable dt)
{
string sql = "update " + table + " set ";
string subsql = "";
foreach (DataColumn col in dt.Columns)
{
if (subsql.Length > 0)
{
// a map function would rock so much here
subsql += ", ";
}
subsql += col.ColumnName + "= :" + col.ColumnName;
}
sql += subsql;
sql += " where " + pk;
SqliteCommand cmd = new SqliteCommand(sql);
// this provides the binding for all our parameters, so
// much less code than it used to be
foreach (DataColumn col in dt.Columns)
{
cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType));
}
return cmd;
}
protected static string defineTable(DataTable dt)
{
string sql = "create table " + dt.TableName + "(";
string subsql = "";
foreach (DataColumn col in dt.Columns)
{
if (subsql.Length > 0)
{
// a map function would rock so much here
subsql += ",\n";
}
subsql += col.ColumnName + " " + sqliteType(col.DataType);
if (dt.PrimaryKey.Length > 0)
{
if (col == dt.PrimaryKey[0])
{
subsql += " primary key";
}
}
}
sql += subsql;
sql += ")";
return sql;
}
/***********************************************************************
*
* Database Binding functions
*
* These will be db specific due to typing, and minor differences
* in databases.
*
**********************************************************************/
///<summary>
/// This is a convenience function that collapses 5 repetitive
/// lines for defining SqliteParameters to 2 parameters:
/// column name and database type.
///
/// It assumes certain conventions like :param as the param
/// name to replace in parametrized queries, and that source
/// version is always current version, both of which are fine
/// for us.
///</summary>
///<returns>a built sqlite parameter</returns>
protected static SqliteParameter createSqliteParameter(string name, Type type)
{
SqliteParameter param = new SqliteParameter();
param.ParameterName = ":" + name;
param.DbType = dbtypeFromType(type);
param.SourceColumn = name;
param.SourceVersion = DataRowVersion.Current;
return param;
}
/***********************************************************************
*
* Type conversion functions
*
**********************************************************************/
protected static DbType dbtypeFromType(Type type)
{
if (type == typeof (String))
{
return DbType.String;
}
else if (type == typeof (Int32))
{
return DbType.Int32;
}
else if (type == typeof (UInt32))
{
return DbType.UInt32;
}
else if (type == typeof (Int64))
{
return DbType.Int64;
}
else if (type == typeof (UInt64))
{
return DbType.UInt64;
}
else if (type == typeof (Double))
{
return DbType.Double;
}
else if (type == typeof (Boolean))
{
return DbType.Boolean;
}
else if (type == typeof (Byte[]))
{
return DbType.Binary;
}
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 (String))
{
return "varchar(255)";
}
else if (type == typeof (Int32))
{
return "integer";
}
else if (type == typeof (UInt32))
{
return "integer";
}
else if (type == typeof (Int64))
{
return "varchar(255)";
}
else if (type == typeof (UInt64))
{
return "varchar(255)";
}
else if (type == typeof (Double))
{
return "float";
}
else if (type == typeof (Boolean))
{
return "integer";
}
else if (type == typeof (Byte[]))
{
return "blob";
}
else
{
return "string";
}
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Data;
using Mono.Data.SqliteClient;
namespace OpenSim.Framework.Data.SQLite
{
/// <summary>
/// A base class for methods needed by all SQLite database classes
/// </summary>
public class SQLiteBase
{
/***********************************************************************
*
* Database Definition Functions
*
* This should be db agnostic as we define them in ADO.NET terms
*
**********************************************************************/
protected static void createCol(DataTable dt, string name, Type type)
{
DataColumn col = new DataColumn(name, type);
dt.Columns.Add(col);
}
/***********************************************************************
*
* SQL Statement Creation Functions
*
* These functions create SQL statements for update, insert, and create.
* They can probably be factored later to have a db independant
* portion and a db specific portion
*
**********************************************************************/
protected static SqliteCommand createInsertCommand(string table, DataTable dt)
{
/**
* This is subtle enough to deserve some commentary.
* Instead of doing *lots* and *lots of hardcoded strings
* for database definitions we'll use the fact that
* realistically all insert statements look like "insert
* into A(b, c) values(:b, :c) on the parameterized query
* front. If we just have a list of b, c, etc... we can
* generate these strings instead of typing them out.
*/
string[] cols = new string[dt.Columns.Count];
for (int i = 0; i < dt.Columns.Count; i++)
{
DataColumn col = dt.Columns[i];
cols[i] = col.ColumnName;
}
string sql = "insert into " + table + "(";
sql += String.Join(", ", cols);
// important, the first ':' needs to be here, the rest get added in the join
sql += ") values (:";
sql += String.Join(", :", cols);
sql += ")";
SqliteCommand cmd = new SqliteCommand(sql);
// this provides the binding for all our parameters, so
// much less code than it used to be
foreach (DataColumn col in dt.Columns)
{
cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType));
}
return cmd;
}
protected static SqliteCommand createUpdateCommand(string table, string pk, DataTable dt)
{
string sql = "update " + table + " set ";
string subsql = String.Empty;
foreach (DataColumn col in dt.Columns)
{
if (subsql.Length > 0)
{
// a map function would rock so much here
subsql += ", ";
}
subsql += col.ColumnName + "= :" + col.ColumnName;
}
sql += subsql;
sql += " where " + pk;
SqliteCommand cmd = new SqliteCommand(sql);
// this provides the binding for all our parameters, so
// much less code than it used to be
foreach (DataColumn col in dt.Columns)
{
cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType));
}
return cmd;
}
protected static string defineTable(DataTable dt)
{
string sql = "create table " + dt.TableName + "(";
string subsql = String.Empty;
foreach (DataColumn col in dt.Columns)
{
if (subsql.Length > 0)
{
// a map function would rock so much here
subsql += ",\n";
}
subsql += col.ColumnName + " " + sqliteType(col.DataType);
if (dt.PrimaryKey.Length > 0)
{
if (col == dt.PrimaryKey[0])
{
subsql += " primary key";
}
}
}
sql += subsql;
sql += ")";
return sql;
}
/***********************************************************************
*
* Database Binding functions
*
* These will be db specific due to typing, and minor differences
* in databases.
*
**********************************************************************/
///<summary>
/// This is a convenience function that collapses 5 repetitive
/// lines for defining SqliteParameters to 2 parameters:
/// column name and database type.
///
/// It assumes certain conventions like :param as the param
/// name to replace in parametrized queries, and that source
/// version is always current version, both of which are fine
/// for us.
///</summary>
///<returns>a built sqlite parameter</returns>
protected static SqliteParameter createSqliteParameter(string name, Type type)
{
SqliteParameter param = new SqliteParameter();
param.ParameterName = ":" + name;
param.DbType = dbtypeFromType(type);
param.SourceColumn = name;
param.SourceVersion = DataRowVersion.Current;
return param;
}
/***********************************************************************
*
* Type conversion functions
*
**********************************************************************/
protected static DbType dbtypeFromType(Type type)
{
if (type == typeof (String))
{
return DbType.String;
}
else if (type == typeof (Int32))
{
return DbType.Int32;
}
else if (type == typeof (UInt32))
{
return DbType.UInt32;
}
else if (type == typeof (Int64))
{
return DbType.Int64;
}
else if (type == typeof (UInt64))
{
return DbType.UInt64;
}
else if (type == typeof (Double))
{
return DbType.Double;
}
else if (type == typeof (Boolean))
{
return DbType.Boolean;
}
else if (type == typeof (Byte[]))
{
return DbType.Binary;
}
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 (String))
{
return "varchar(255)";
}
else if (type == typeof (Int32))
{
return "integer";
}
else if (type == typeof (UInt32))
{
return "integer";
}
else if (type == typeof (Int64))
{
return "varchar(255)";
}
else if (type == typeof (UInt64))
{
return "varchar(255)";
}
else if (type == typeof (Double))
{
return "float";
}
else if (type == typeof (Boolean))
{
return "integer";
}
else if (type == typeof (Byte[]))
{
return "blob";
}
else
{
return "string";
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,278 +1,280 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SQLite;
using libsecondlife;
using Mono.Data.SqliteClient;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.SQLite
{
internal class SQLiteManager : SQLiteBase
{
private IDbConnection dbcon;
/// <summary>
/// Initialises and creates a new SQLite connection and maintains it.
/// </summary>
/// <param name="hostname">The SQLite server being connected to</param>
/// <param name="database">The name of the SQLite database being used</param>
/// <param name="username">The username logging into the database</param>
/// <param name="password">The password for the user logging in</param>
/// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param>
public SQLiteManager(string hostname, string database, string username, string password, string cpooling)
{
try
{
string connectionString = "URI=file:GridServerSqlite.db;";
dbcon = new SQLiteConnection(connectionString);
dbcon.Open();
}
catch (Exception e)
{
throw new Exception("Error initialising SQLite Database: " + e.ToString());
}
}
/// <summary>
/// Shuts down the database connection
/// </summary>
public void Close()
{
dbcon.Close();
dbcon = null;
}
/// <summary>
/// Runs a query with protection against SQL Injection by using parameterised input.
/// </summary>
/// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param>
/// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param>
/// <returns>A SQLite DB Command</returns>
public IDbCommand Query(string sql, Dictionary<string, string> parameters)
{
SQLiteCommand dbcommand = (SQLiteCommand) dbcon.CreateCommand();
dbcommand.CommandText = sql;
foreach (KeyValuePair<string, string> param in parameters)
{
SQLiteParameter paramx = new SQLiteParameter(param.Key, param.Value);
dbcommand.Parameters.Add(paramx);
}
return (IDbCommand) dbcommand;
}
private bool TestTables(SQLiteConnection conn)
{
SQLiteCommand cmd = new SQLiteCommand("SELECT * FROM regions", conn);
SQLiteDataAdapter pDa = new SQLiteDataAdapter(cmd);
DataSet tmpDS = new DataSet();
try
{
pDa.Fill(tmpDS, "regions");
}
catch (SqliteSyntaxException)
{
MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating");
InitDB(conn);
}
return true;
}
private DataTable createRegionsTable()
{
DataTable regions = new DataTable("regions");
createCol(regions, "regionHandle", typeof (ulong));
createCol(regions, "regionName", typeof (String));
createCol(regions, "uuid", typeof (String));
createCol(regions, "regionRecvKey", typeof (String));
createCol(regions, "regionSecret", typeof (String));
createCol(regions, "regionSendKey", typeof (String));
createCol(regions, "regionDataURI", typeof (String));
createCol(regions, "serverIP", typeof (String));
createCol(regions, "serverPort", typeof (String));
createCol(regions, "serverURI", typeof (String));
createCol(regions, "locX", typeof (uint));
createCol(regions, "locY", typeof (uint));
createCol(regions, "locZ", typeof (uint));
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"]};
return regions;
}
private void InitDB(SQLiteConnection conn)
{
string createUsers = defineTable(createRegionsTable());
SQLiteCommand pcmd = new SQLiteCommand(createUsers, conn);
conn.Open();
pcmd.ExecuteNonQuery();
conn.Close();
}
/// <summary>
/// Reads a region row from a database reader
/// </summary>
/// <param name="reader">An active database reader</param>
/// <returns>A region profile</returns>
public RegionProfileData getRow(IDataReader reader)
{
RegionProfileData retval = new RegionProfileData();
if (reader.Read())
{
// Region Main
retval.regionHandle = (ulong) reader["regionHandle"];
retval.regionName = (string) reader["regionName"];
retval.UUID = new LLUUID((string) reader["uuid"]);
// Secrets
retval.regionRecvKey = (string) reader["regionRecvKey"];
retval.regionSecret = (string) reader["regionSecret"];
retval.regionSendKey = (string) reader["regionSendKey"];
// Region Server
retval.regionDataURI = (string) reader["regionDataURI"];
retval.regionOnline = false; // Needs to be pinged before this can be set.
retval.serverIP = (string) reader["serverIP"];
retval.serverPort = (uint) reader["serverPort"];
retval.serverURI = (string) reader["serverURI"];
// Location
retval.regionLocX = (uint) ((int) reader["locX"]);
retval.regionLocY = (uint) ((int) reader["locY"]);
retval.regionLocZ = (uint) ((int) reader["locZ"]);
// Neighbours - 0 = No Override
retval.regionEastOverrideHandle = (ulong) reader["eastOverrideHandle"];
retval.regionWestOverrideHandle = (ulong) reader["westOverrideHandle"];
retval.regionSouthOverrideHandle = (ulong) reader["southOverrideHandle"];
retval.regionNorthOverrideHandle = (ulong) reader["northOverrideHandle"];
// Assets
retval.regionAssetURI = (string) reader["regionAssetURI"];
retval.regionAssetRecvKey = (string) reader["regionAssetRecvKey"];
retval.regionAssetSendKey = (string) reader["regionAssetSendKey"];
// Userserver
retval.regionUserURI = (string) reader["regionUserURI"];
retval.regionUserRecvKey = (string) reader["regionUserRecvKey"];
retval.regionUserSendKey = (string) reader["regionUserSendKey"];
}
else
{
throw new Exception("No rows to return");
}
return retval;
}
/// <summary>
/// Inserts a new region into the database
/// </summary>
/// <param name="profile">The region to insert</param>
/// <returns>Success?</returns>
public bool insertRow(RegionProfileData profile)
{
string sql =
"REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
sql +=
"serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey) VALUES ";
sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, ";
sql +=
"@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, ";
sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);";
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters["regionHandle"] = profile.regionHandle.ToString();
parameters["regionName"] = profile.regionName;
parameters["uuid"] = profile.UUID.ToString();
parameters["regionRecvKey"] = profile.regionRecvKey;
parameters["regionSendKey"] = profile.regionSendKey;
parameters["regionDataURI"] = profile.regionDataURI;
parameters["serverIP"] = profile.serverIP;
parameters["serverPort"] = profile.serverPort.ToString();
parameters["serverURI"] = profile.serverURI;
parameters["locX"] = profile.regionLocX.ToString();
parameters["locY"] = profile.regionLocY.ToString();
parameters["locZ"] = profile.regionLocZ.ToString();
parameters["eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString();
parameters["westOverrideHandle"] = profile.regionWestOverrideHandle.ToString();
parameters["northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString();
parameters["southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString();
parameters["regionAssetURI"] = profile.regionAssetURI;
parameters["regionAssetRecvKey"] = profile.regionAssetRecvKey;
parameters["regionAssetSendKey"] = profile.regionAssetSendKey;
parameters["regionUserURI"] = profile.regionUserURI;
parameters["regionUserRecvKey"] = profile.regionUserRecvKey;
parameters["regionUserSendKey"] = profile.regionUserSendKey;
bool returnval = false;
try
{
IDbCommand result = Query(sql, parameters);
if (result.ExecuteNonQuery() == 1)
returnval = true;
result.Dispose();
}
catch (Exception)
{
return false;
}
return returnval;
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SQLite;
using libsecondlife;
using Mono.Data.SqliteClient;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.SQLite
{
internal class SQLiteManager : SQLiteBase
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private IDbConnection dbcon;
/// <summary>
/// Initialises and creates a new SQLite connection and maintains it.
/// </summary>
/// <param name="hostname">The SQLite server being connected to</param>
/// <param name="database">The name of the SQLite database being used</param>
/// <param name="username">The username logging into the database</param>
/// <param name="password">The password for the user logging in</param>
/// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param>
public SQLiteManager(string hostname, string database, string username, string password, string cpooling)
{
try
{
string connectionString = "URI=file:GridServerSqlite.db;";
dbcon = new SQLiteConnection(connectionString);
dbcon.Open();
}
catch (Exception e)
{
throw new Exception("Error initialising SQLite Database: " + e.ToString());
}
}
/// <summary>
/// Shuts down the database connection
/// </summary>
public void Close()
{
dbcon.Close();
dbcon = null;
}
/// <summary>
/// Runs a query with protection against SQL Injection by using parameterised input.
/// </summary>
/// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param>
/// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param>
/// <returns>A SQLite DB Command</returns>
public IDbCommand Query(string sql, Dictionary<string, string> parameters)
{
SQLiteCommand dbcommand = (SQLiteCommand) dbcon.CreateCommand();
dbcommand.CommandText = sql;
foreach (KeyValuePair<string, string> param in parameters)
{
SQLiteParameter paramx = new SQLiteParameter(param.Key, param.Value);
dbcommand.Parameters.Add(paramx);
}
return (IDbCommand) dbcommand;
}
private bool TestTables(SQLiteConnection conn)
{
SQLiteCommand cmd = new SQLiteCommand("SELECT * FROM regions", conn);
SQLiteDataAdapter pDa = new SQLiteDataAdapter(cmd);
DataSet tmpDS = new DataSet();
try
{
pDa.Fill(tmpDS, "regions");
}
catch (SqliteSyntaxException)
{
m_log.Info("[DATASTORE]: SQLite Database doesn't exist... creating");
InitDB(conn);
}
return true;
}
private DataTable createRegionsTable()
{
DataTable regions = new DataTable("regions");
createCol(regions, "regionHandle", typeof (ulong));
createCol(regions, "regionName", typeof (String));
createCol(regions, "uuid", typeof (String));
createCol(regions, "regionRecvKey", typeof (String));
createCol(regions, "regionSecret", typeof (String));
createCol(regions, "regionSendKey", typeof (String));
createCol(regions, "regionDataURI", typeof (String));
createCol(regions, "serverIP", typeof (String));
createCol(regions, "serverPort", typeof (String));
createCol(regions, "serverURI", typeof (String));
createCol(regions, "locX", typeof (uint));
createCol(regions, "locY", typeof (uint));
createCol(regions, "locZ", typeof (uint));
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"]};
return regions;
}
private void InitDB(SQLiteConnection conn)
{
string createUsers = defineTable(createRegionsTable());
SQLiteCommand pcmd = new SQLiteCommand(createUsers, conn);
conn.Open();
pcmd.ExecuteNonQuery();
conn.Close();
}
/// <summary>
/// Reads a region row from a database reader
/// </summary>
/// <param name="reader">An active database reader</param>
/// <returns>A region profile</returns>
public RegionProfileData getRow(IDataReader reader)
{
RegionProfileData retval = new RegionProfileData();
if (reader.Read())
{
// Region Main
retval.regionHandle = (ulong) reader["regionHandle"];
retval.regionName = (string) reader["regionName"];
retval.UUID = new LLUUID((string) reader["uuid"]);
// Secrets
retval.regionRecvKey = (string) reader["regionRecvKey"];
retval.regionSecret = (string) reader["regionSecret"];
retval.regionSendKey = (string) reader["regionSendKey"];
// Region Server
retval.regionDataURI = (string) reader["regionDataURI"];
retval.regionOnline = false; // Needs to be pinged before this can be set.
retval.serverIP = (string) reader["serverIP"];
retval.serverPort = (uint) reader["serverPort"];
retval.serverURI = (string) reader["serverURI"];
// Location
retval.regionLocX = (uint) ((int) reader["locX"]);
retval.regionLocY = (uint) ((int) reader["locY"]);
retval.regionLocZ = (uint) ((int) reader["locZ"]);
// Neighbours - 0 = No Override
retval.regionEastOverrideHandle = (ulong) reader["eastOverrideHandle"];
retval.regionWestOverrideHandle = (ulong) reader["westOverrideHandle"];
retval.regionSouthOverrideHandle = (ulong) reader["southOverrideHandle"];
retval.regionNorthOverrideHandle = (ulong) reader["northOverrideHandle"];
// Assets
retval.regionAssetURI = (string) reader["regionAssetURI"];
retval.regionAssetRecvKey = (string) reader["regionAssetRecvKey"];
retval.regionAssetSendKey = (string) reader["regionAssetSendKey"];
// Userserver
retval.regionUserURI = (string) reader["regionUserURI"];
retval.regionUserRecvKey = (string) reader["regionUserRecvKey"];
retval.regionUserSendKey = (string) reader["regionUserSendKey"];
}
else
{
throw new Exception("No rows to return");
}
return retval;
}
/// <summary>
/// Inserts a new region into the database
/// </summary>
/// <param name="profile">The region to insert</param>
/// <returns>Success?</returns>
public bool insertRow(RegionProfileData profile)
{
string sql =
"REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
sql +=
"serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey) VALUES ";
sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, ";
sql +=
"@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, ";
sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);";
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters["regionHandle"] = profile.regionHandle.ToString();
parameters["regionName"] = profile.regionName;
parameters["uuid"] = profile.UUID.ToString();
parameters["regionRecvKey"] = profile.regionRecvKey;
parameters["regionSendKey"] = profile.regionSendKey;
parameters["regionDataURI"] = profile.regionDataURI;
parameters["serverIP"] = profile.serverIP;
parameters["serverPort"] = profile.serverPort.ToString();
parameters["serverURI"] = profile.serverURI;
parameters["locX"] = profile.regionLocX.ToString();
parameters["locY"] = profile.regionLocY.ToString();
parameters["locZ"] = profile.regionLocZ.ToString();
parameters["eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString();
parameters["westOverrideHandle"] = profile.regionWestOverrideHandle.ToString();
parameters["northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString();
parameters["southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString();
parameters["regionAssetURI"] = profile.regionAssetURI;
parameters["regionAssetRecvKey"] = profile.regionAssetRecvKey;
parameters["regionAssetSendKey"] = profile.regionAssetSendKey;
parameters["regionUserURI"] = profile.regionUserURI;
parameters["regionUserRecvKey"] = profile.regionUserRecvKey;
parameters["regionUserSendKey"] = profile.regionUserSendKey;
bool returnval = false;
try
{
IDbCommand result = Query(sql, parameters);
if (result.ExecuteNonQuery() == 1)
returnval = true;
result.Dispose();
}
catch (Exception)
{
return false;
}
return returnval;
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,125 +1,122 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Collections.Generic;
using libsecondlife;
namespace OpenSim.Framework.Data
{
public class AvatarPickerAvatar
{
public LLUUID AvatarID;
public string firstName;
public string lastName;
public AvatarPickerAvatar()
{
}
}
public enum DataResponse
{
RESPONSE_OK,
RESPONSE_AUTHREQUIRED,
RESPONSE_INVALIDCREDENTIALS,
RESPONSE_ERROR
}
/// <summary>
/// A standard grid interface
/// </summary>
public interface IGridData
{
/// <summary>
/// Returns a sim profile from a regionHandle
/// </summary>
/// <param name="regionHandle">A 64bit Region Handle</param>
/// <returns>A simprofile</returns>
RegionProfileData GetProfileByHandle(ulong regionHandle);
/// <summary>
/// Returns a sim profile from a UUID
/// </summary>
/// <param name="UUID">A 128bit UUID</param>
/// <returns>A sim profile</returns>
RegionProfileData GetProfileByLLUUID(LLUUID UUID);
/// <summary>
/// Returns all profiles within the specified range
/// </summary>
/// <param name="Xmin">Minimum sim coordinate (X)</param>
/// <param name="Ymin">Minimum sim coordinate (Y)</param>
/// <param name="Xmax">Maximum sim coordinate (X)</param>
/// <param name="Ymin">Maximum sim coordinate (Y)</param>
/// <returns>An array containing all the sim profiles in the specified range</returns>
RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query);
/// <summary>
/// Authenticates a sim by use of its recv key.
/// WARNING: Insecure
/// </summary>
/// <param name="UUID">The UUID sent by the sim</param>
/// <param name="regionHandle">The regionhandle sent by the sim</param>
/// <param name="simrecvkey">The receiving key sent by the sim</param>
/// <returns>Whether the sim has been authenticated</returns>
bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey);
/// <summary>
/// Initialises the interface
/// </summary>
void Initialise();
/// <summary>
/// Closes the interface
/// </summary>
void Close();
/// <summary>
/// The plugin being loaded
/// </summary>
/// <returns>A string containing the plugin name</returns>
string getName();
/// <summary>
/// The plugins version
/// </summary>
/// <returns>A string containing the plugin version</returns>
string getVersion();
/// <summary>
/// Adds a new profile to the database
/// </summary>
/// <param name="profile">The profile to add</param>
/// <returns>RESPONSE_OK if successful, error if not.</returns>
DataResponse AddProfile(RegionProfileData profile);
ReservationData GetReservationAtPoint(uint x, uint y);
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Collections.Generic;
using libsecondlife;
namespace OpenSim.Framework.Data
{
public class AvatarPickerAvatar
{
public LLUUID AvatarID;
public string firstName;
public string lastName;
public AvatarPickerAvatar()
{
}
}
public enum DataResponse
{
RESPONSE_OK,
RESPONSE_AUTHREQUIRED,
RESPONSE_INVALIDCREDENTIALS,
RESPONSE_ERROR
}
/// <summary>
/// A standard grid interface
/// </summary>
public interface IGridData
{
/// <summary>
/// Returns a sim profile from a regionHandle
/// </summary>
/// <param name="regionHandle">A 64bit Region Handle</param>
/// <returns>A simprofile</returns>
RegionProfileData GetProfileByHandle(ulong regionHandle);
/// <summary>
/// Returns a sim profile from a UUID
/// </summary>
/// <param name="UUID">A 128bit UUID</param>
/// <returns>A sim profile</returns>
RegionProfileData GetProfileByLLUUID(LLUUID UUID);
/// <summary>
/// Returns all profiles within the specified range
/// </summary>
/// <param name="Xmin">Minimum sim coordinate (X)</param>
/// <param name="Ymin">Minimum sim coordinate (Y)</param>
/// <param name="Xmax">Maximum sim coordinate (X)</param>
/// <param name="Ymin">Maximum sim coordinate (Y)</param>
/// <returns>An array containing all the sim profiles in the specified range</returns>
RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
/// <summary>
/// Authenticates a sim by use of its recv key.
/// WARNING: Insecure
/// </summary>
/// <param name="UUID">The UUID sent by the sim</param>
/// <param name="regionHandle">The regionhandle sent by the sim</param>
/// <param name="simrecvkey">The receiving key sent by the sim</param>
/// <returns>Whether the sim has been authenticated</returns>
bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey);
/// <summary>
/// Initialises the interface
/// </summary>
void Initialise();
/// <summary>
/// Closes the interface
/// </summary>
void Close();
/// <summary>
/// The plugin being loaded
/// </summary>
/// <returns>A string containing the plugin name</returns>
string getName();
/// <summary>
/// The plugins version
/// </summary>
/// <returns>A string containing the plugin version</returns>
string getVersion();
/// <summary>
/// Adds a new profile to the database
/// </summary>
/// <param name="profile">The profile to add</param>
/// <returns>RESPONSE_OK if successful, error if not.</returns>
DataResponse AddProfile(RegionProfileData profile);
ReservationData GetReservationAtPoint(uint x, uint y);
}
}

View File

@ -0,0 +1,68 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using libsecondlife;
using TribalMedia.Framework.Data;
namespace OpenSim.Framework.Data
{
public class OpenSimDataReader : BaseDataReader
{
public OpenSimDataReader(IDataReader source) : base(source)
{
}
public LLVector3 GetVector(string s)
{
float x = GetFloat(s + "X");
float y = GetFloat(s + "Y");
float z = GetFloat(s + "Z");
LLVector3 vector = new LLVector3(x, y, z);
return vector;
}
public LLQuaternion GetQuaternion(string s)
{
float x = GetFloat(s + "X");
float y = GetFloat(s + "Y");
float z = GetFloat(s + "Z");
float w = GetFloat(s + "W");
LLQuaternion quaternion = new LLQuaternion(x, y, z, w);
return quaternion;
}
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Data;
using System.Data.Common;
using libsecondlife;
using MySql.Data.MySqlClient;
using TribalMedia.Framework.Data;
namespace OpenSim.Framework.Data
{
public abstract class OpenSimDatabaseConnector : BaseDatabaseConnector
{
public OpenSimDatabaseConnector(string connectionString) : base(connectionString)
{
}
public override object ConvertToDbType(object value)
{
if (value is LLUUID)
{
return ((LLUUID) value).UUID.ToString();
}
return base.ConvertToDbType(value);
}
public override BaseDataReader CreateReader(IDataReader reader)
{
return new OpenSimDataReader(reader);
}
}
public class MySQLDatabaseMapper : OpenSimDatabaseConnector
{
public MySQLDatabaseMapper(string connectionString)
: base(connectionString)
{
}
public override DbConnection GetNewConnection()
{
MySqlConnection connection = new MySqlConnection(m_connectionString);
return connection;
}
public override string CreateParamName(string fieldName)
{
return "?" + fieldName;
}
}
}

View File

@ -0,0 +1,103 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Text;
using libsecondlife;
using TribalMedia.Framework.Data;
namespace OpenSim.Framework.Data
{
public class OpenSimObjectFieldMapper<TObject, TField> : ObjectField<TObject, TField>
{
public OpenSimObjectFieldMapper(BaseTableMapper tableMapper, string fieldName,
ObjectGetAccessor<TObject, TField> rowMapperGetAccessor,
ObjectSetAccessor<TObject, TField> rowMapperSetAccessor)
: base(tableMapper, fieldName, rowMapperGetAccessor, rowMapperSetAccessor)
{
}
public override void ExpandField<TObj>(TObj obj, DbCommand command, List<string> fieldNames)
{
string fieldName = FieldName;
object value = GetParamValue(obj);
if (ValueType == typeof(LLVector3))
{
LLVector3 vector = (LLVector3)value;
RawAddParam(command, fieldNames, fieldName + "X", vector.X);
RawAddParam(command, fieldNames, fieldName + "Y", vector.Y);
RawAddParam(command, fieldNames, fieldName + "Z", vector.Z);
}
else if (ValueType == typeof(LLQuaternion))
{
LLQuaternion quaternion = (LLQuaternion)value;
RawAddParam(command, fieldNames, fieldName + "X", quaternion.X);
RawAddParam(command, fieldNames, fieldName + "Y", quaternion.Y);
RawAddParam(command, fieldNames, fieldName + "Z", quaternion.Z);
RawAddParam(command, fieldNames, fieldName + "W", quaternion.W);
}
else
{
base.ExpandField(obj, command, fieldNames);
}
}
protected override object GetValue(BaseDataReader reader)
{
object value;
OpenSimDataReader osreader = (OpenSimDataReader) reader;
if (ValueType == typeof(LLVector3))
{
value = osreader.GetVector(FieldName);
}
else if (ValueType == typeof(LLQuaternion))
{
value = osreader.GetQuaternion(FieldName);
}
else if (ValueType == typeof(LLUUID))
{
Guid guid = reader.GetGuid(FieldName);
value = new LLUUID(guid);
}
else
{
value = base.GetValue(reader);
}
return value;
}
}
}

View File

@ -0,0 +1,41 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Data;
using TribalMedia.Framework.Data;
namespace OpenSim.Framework.Data
{
public abstract class OpenSimTableMapper<TRowMapper, TPrimaryKey> : BaseTableMapper<TRowMapper, TPrimaryKey>
{
public OpenSimTableMapper(BaseDatabaseConnector database, string tableName) : base(database, tableName)
{
}
}
}

View File

@ -0,0 +1,171 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using OpenSim.Framework;
using TribalMedia.Framework.Data;
using libsecondlife;
namespace OpenSim.Framework.Data
{
public class PrimitiveBaseShapeRowMapper : BaseRowMapper<PrimitiveBaseShape>
{
public Guid SceneObjectPartId;
public PrimitiveBaseShapeRowMapper(BaseSchema schema, PrimitiveBaseShape obj) : base(schema, obj)
{
}
}
public class PrimitiveBaseShapeTableMapper : OpenSimTableMapper<PrimitiveBaseShapeRowMapper, Guid>
{
public PrimitiveBaseShapeTableMapper(BaseDatabaseConnector connection, string tableName)
: base(connection, tableName)
{
BaseSchema<PrimitiveBaseShapeRowMapper> rowMapperSchema = new BaseSchema<PrimitiveBaseShapeRowMapper>(this);
m_schema = rowMapperSchema;
m_keyFieldMapper = rowMapperSchema.AddMapping<Guid>("SceneObjectPartId",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.SceneObjectPartId; },
delegate(PrimitiveBaseShapeRowMapper shape, Guid value) { shape.SceneObjectPartId = value; });
rowMapperSchema.AddMapping<byte>("PCode",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PCode; },
delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PCode = value; });
rowMapperSchema.AddMapping<ushort>("PathBegin",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathBegin; },
delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.PathBegin = value; });
rowMapperSchema.AddMapping<ushort>("PathEnd",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathEnd; },
delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.PathEnd = value; });
rowMapperSchema.AddMapping<byte>("PathScaleX",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathScaleX; },
delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathScaleX = value; });
rowMapperSchema.AddMapping<byte>("PathScaleY",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathScaleY; },
delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathScaleY = value; });
rowMapperSchema.AddMapping<byte>("PathShearX",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathShearX; },
delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathShearX = value; });
rowMapperSchema.AddMapping<byte>("PathShearY",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathShearY; },
delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathShearY = value; });
rowMapperSchema.AddMapping<ushort>("ProfileBegin",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileBegin; },
delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileBegin = value; });
rowMapperSchema.AddMapping<ushort>("ProfileEnd",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileEnd; },
delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileEnd = value; });
rowMapperSchema.AddMapping<LLVector3>("Scale",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.Scale; },
delegate(PrimitiveBaseShapeRowMapper shape, LLVector3 value) { shape.Object.Scale = value; });
rowMapperSchema.AddMapping<sbyte>("PathTaperX",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTaperX; },
delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTaperX = value; });
rowMapperSchema.AddMapping<sbyte>("PathTaperY",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTaperY; },
delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTaperY = value; });
rowMapperSchema.AddMapping<sbyte>("PathTwist",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTwist; },
delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTwist = value; });
rowMapperSchema.AddMapping<sbyte>("PathRadiusOffset",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathRadiusOffset; },
delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathRadiusOffset = value; });
rowMapperSchema.AddMapping<byte>("PathRevolutions",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathRevolutions; },
delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathRevolutions = value; });
rowMapperSchema.AddMapping<sbyte>("PathTwistBegin",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTwistBegin; },
delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTwistBegin = value; });
rowMapperSchema.AddMapping<byte>("PathCurve",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathCurve; },
delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathCurve = value; });
rowMapperSchema.AddMapping<byte>("ProfileCurve",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileCurve; },
delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.ProfileCurve = value; });
rowMapperSchema.AddMapping<ushort>("ProfileHollow",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileHollow; },
delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileHollow = value; });
rowMapperSchema.AddMapping<byte[]>("TextureEntry",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.TextureEntry; },
delegate(PrimitiveBaseShapeRowMapper shape, byte[] value) { shape.Object.TextureEntry = value; });
rowMapperSchema.AddMapping<byte[]>("ExtraParams",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ExtraParams; },
delegate(PrimitiveBaseShapeRowMapper shape, byte[] value) { shape.Object.ExtraParams = value; });
}
public override PrimitiveBaseShapeRowMapper FromReader(BaseDataReader reader)
{
PrimitiveBaseShape shape = new PrimitiveBaseShape();
PrimitiveBaseShapeRowMapper mapper = new PrimitiveBaseShapeRowMapper(m_schema, shape);
mapper.FillObject( reader );
return mapper;
}
public bool Update(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape)
{
PrimitiveBaseShapeRowMapper mapper = CreateRowMapper(sceneObjectPartId, primitiveBaseShape);
return Update(sceneObjectPartId, mapper);
}
public bool Add(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape)
{
PrimitiveBaseShapeRowMapper mapper = CreateRowMapper(sceneObjectPartId, primitiveBaseShape);
return Add(mapper);
}
private PrimitiveBaseShapeRowMapper CreateRowMapper(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape)
{
PrimitiveBaseShapeRowMapper mapper = new PrimitiveBaseShapeRowMapper( m_schema, primitiveBaseShape );
mapper.SceneObjectPartId = sceneObjectPartId;
return mapper;
}
}
}

View File

@ -1,38 +1,66 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly : AssemblyTitle("OpenSim.Framework.Data")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("")]
[assembly : AssemblyProduct("OpenSim.Framework.Data")]
[assembly : AssemblyCopyright("Copyright © 2007")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly : ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly : Guid("3a711c34-b0c0-4264-b0fe-f366eabf9d7b")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly : AssemblyTitle("OpenSim.Framework.Data")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("")]
[assembly : AssemblyProduct("OpenSim.Framework.Data")]
[assembly : AssemblyCopyright("Copyright © OpenSimulator.org Developers 2007-2008")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly : ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly : Guid("3a711c34-b0c0-4264-b0fe-f366eabf9d7b")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : AssemblyFileVersion("1.0.0.0")]

View File

@ -1,201 +1,221 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections;
using libsecondlife;
using Nwc.XmlRpc;
namespace OpenSim.Framework.Data
{
/// <summary>
/// A class which contains information known to the grid server about a region
/// </summary>
public class RegionProfileData
{
/// <summary>
/// The name of the region
/// </summary>
public string regionName = "";
/// <summary>
/// A 64-bit number combining map position into a (mostly) unique ID
/// </summary>
public ulong regionHandle;
/// <summary>
/// OGS/OpenSim Specific ID for a region
/// </summary>
public LLUUID UUID;
/// <summary>
/// Coordinates of the region
/// </summary>
public uint regionLocX;
public uint regionLocY;
public uint regionLocZ; // Reserved (round-robin, layers, etc)
/// <summary>
/// Authentication secrets
/// </summary>
/// <remarks>Not very secure, needs improvement.</remarks>
public string regionSendKey = "";
public string regionRecvKey = "";
public string regionSecret = "";
/// <summary>
/// Whether the region is online
/// </summary>
public bool regionOnline;
/// <summary>
/// Information about the server that the region is currently hosted on
/// </summary>
public string serverIP = "";
public uint serverPort;
public string serverURI = "";
public uint httpPort;
public uint remotingPort;
public string httpServerURI = "";
/// <summary>
/// Set of optional overrides. Can be used to create non-eulicidean spaces.
/// </summary>
public ulong regionNorthOverrideHandle;
public ulong regionSouthOverrideHandle;
public ulong regionEastOverrideHandle;
public ulong regionWestOverrideHandle;
/// <summary>
/// Optional: URI Location of the region database
/// </summary>
/// <remarks>Used for floating sim pools where the region data is not nessecarily coupled to a specific server</remarks>
public string regionDataURI = "";
/// <summary>
/// Region Asset Details
/// </summary>
public string regionAssetURI = "";
public string regionAssetSendKey = "";
public string regionAssetRecvKey = "";
/// <summary>
/// Region Userserver Details
/// </summary>
public string regionUserURI = "";
public string regionUserSendKey = "";
public string regionUserRecvKey = "";
/// <summary>
/// Region Map Texture Asset
/// </summary>
public LLUUID regionMapTextureID = new LLUUID("00000000-0000-0000-9999-000000000006");
/// <summary>
/// Get Sim profile data from grid server when in grid mode
/// </summary>
/// <param name="region_uuid"></param>
/// <param name="gridserver_url"></param>
/// <param name="?"></param>
/// <returns></returns>
public 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();
requestData["authkey"] = gridserver_sendkey;
ArrayList SendParams = new ArrayList();
SendParams.Add(requestData);
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
Hashtable responseData = (Hashtable) GridResp.Value;
if (responseData.ContainsKey("error"))
{
return null;
}
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.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/";
simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/";
simData.UUID = new LLUUID((string) responseData["region_UUID"]);
simData.regionName = (string) responseData["region_name"];
return simData;
}
public RegionProfileData RequestSimProfileData(ulong region_handle, string gridserver_url,
string gridserver_sendkey, string gridserver_recvkey)
{
Hashtable requestData = new Hashtable();
requestData["region_handle"] = region_handle.ToString();
requestData["authkey"] = gridserver_sendkey;
ArrayList SendParams = new ArrayList();
SendParams.Add(requestData);
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
Hashtable responseData = (Hashtable) GridResp.Value;
if (responseData.ContainsKey("error"))
{
return null;
}
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.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/";
simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/";
simData.UUID = new LLUUID((string) responseData["region_UUID"]);
simData.regionName = (string) responseData["region_name"];
return simData;
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections;
using libsecondlife;
using Nwc.XmlRpc;
namespace OpenSim.Framework.Data
{
/// <summary>
/// A class which contains information known to the grid server about a region
/// </summary>
public class RegionProfileData
{
/// <summary>
/// The name of the region
/// </summary>
public string regionName = String.Empty;
/// <summary>
/// A 64-bit number combining map position into a (mostly) unique ID
/// </summary>
public ulong regionHandle;
/// <summary>
/// OGS/OpenSim Specific ID for a region
/// </summary>
public LLUUID UUID;
/// <summary>
/// Coordinates of the region
/// </summary>
public uint regionLocX;
public uint regionLocY;
public uint regionLocZ; // Reserved (round-robin, layers, etc)
/// <summary>
/// Authentication secrets
/// </summary>
/// <remarks>Not very secure, needs improvement.</remarks>
public string regionSendKey = String.Empty;
public string regionRecvKey = String.Empty;
public string regionSecret = String.Empty;
/// <summary>
/// Whether the region is online
/// </summary>
public bool regionOnline;
/// <summary>
/// Information about the server that the region is currently hosted on
/// </summary>
public string serverIP = String.Empty;
public uint serverPort;
public string serverURI = String.Empty;
public uint httpPort;
public uint remotingPort;
public string httpServerURI = String.Empty;
/// <summary>
/// Set of optional overrides. Can be used to create non-eulicidean spaces.
/// </summary>
public ulong regionNorthOverrideHandle;
public ulong regionSouthOverrideHandle;
public ulong regionEastOverrideHandle;
public ulong regionWestOverrideHandle;
/// <summary>
/// Optional: URI Location of the region database
/// </summary>
/// <remarks>Used for floating sim pools where the region data is not nessecarily coupled to a specific server</remarks>
public string regionDataURI = String.Empty;
/// <summary>
/// Region Asset Details
/// </summary>
public string regionAssetURI = String.Empty;
public string regionAssetSendKey = String.Empty;
public string regionAssetRecvKey = String.Empty;
/// <summary>
/// Region Userserver Details
/// </summary>
public string regionUserURI = String.Empty;
public string regionUserSendKey = String.Empty;
public string regionUserRecvKey = String.Empty;
/// <summary>
/// Region Map Texture Asset
/// </summary>
public LLUUID regionMapTextureID = new LLUUID("00000000-0000-0000-9999-000000000006");
// part of an initial brutish effort to provide accurate information (as per the xml region spec)
// wrt the ownership of a given region
// the (very bad) assumption is that this value is being read and handled inconsistently or
// not at all. Current strategy is to put the code in place to support the validity of this information
// and to roll forward debugging any issues from that point
//
/// <summary>
/// this particular mod to the file provides support within the spec for RegionProfileData for the
/// owner_uuid for the region
/// </summary>
public LLUUID owner_uuid;
/// <summary>
/// Get Sim profile data from grid server when in grid mode
/// </summary>
/// <param name="region_uuid"></param>
/// <param name="gridserver_url"></param>
/// <param name="?"></param>
/// <returns></returns>
public 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();
requestData["authkey"] = gridserver_sendkey;
ArrayList SendParams = new ArrayList();
SendParams.Add(requestData);
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
Hashtable responseData = (Hashtable) GridResp.Value;
if (responseData.ContainsKey("error"))
{
return null;
}
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 * Constants.RegionSize), (simData.regionLocY * Constants.RegionSize));
simData.serverIP = (string) responseData["sim_ip"];
simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]);
simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]);
simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]);
simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/";
simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/";
simData.UUID = new LLUUID((string) responseData["region_UUID"]);
simData.regionName = (string) responseData["region_name"];
return simData;
}
/// <summary>
/// Request sim profile information from a grid server
/// </summary>
/// <param name="region_handle"></param>
/// <param name="gridserver_url"></param>
/// <param name="gridserver_sendkey"></param>
/// <param name="gridserver_recvkey"></param>
/// <returns>The sim profile. Null if there was a request failure</returns>
public static RegionProfileData RequestSimProfileData(ulong region_handle, string gridserver_url,
string gridserver_sendkey, string gridserver_recvkey)
{
Hashtable requestData = new Hashtable();
requestData["region_handle"] = region_handle.ToString();
requestData["authkey"] = gridserver_sendkey;
ArrayList SendParams = new ArrayList();
SendParams.Add(requestData);
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
Hashtable responseData = (Hashtable) GridResp.Value;
if (responseData.ContainsKey("error"))
{
return null;
}
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 * Constants.RegionSize), (simData.regionLocY * Constants.RegionSize));
simData.serverIP = (string) responseData["sim_ip"];
simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]);
simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]);
simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]);
simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/";
simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/";
simData.UUID = new LLUUID((string) responseData["region_UUID"]);
simData.regionName = (string) responseData["region_name"];
return simData;
}
}
}

View File

@ -1,47 +1,47 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using libsecondlife;
namespace OpenSim.Framework.Data
{
public class ReservationData
{
public LLUUID userUUID = LLUUID.Zero;
public int reservationMinX = 0;
public int reservationMinY = 0;
public int reservationMaxX = 65536;
public int reservationMaxY = 65536;
public string reservationName = "";
public string reservationCompany = "";
public bool status = true;
public string gridSendKey = "";
public string gridRecvKey = "";
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using libsecondlife;
namespace OpenSim.Framework.Data
{
public class ReservationData
{
public LLUUID userUUID = LLUUID.Zero;
public int reservationMinX = 0;
public int reservationMinY = 0;
public int reservationMaxX = 65536;
public int reservationMaxY = 65536;
public string reservationName = System.String.Empty;
public string reservationCompany = System.String.Empty;
public bool status = true;
public string gridSendKey = System.String.Empty;
public string gridRecvKey = System.String.Empty;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,146 +1,149 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace OpenSim.Framework
{
public class GridConfig
{
public string GridOwner = "";
public string DefaultAssetServer = "";
public string AssetSendKey = "";
public string AssetRecvKey = "";
public string DefaultUserServer = "";
public string UserSendKey = "";
public string UserRecvKey = "";
public string SimSendKey = "";
public string SimRecvKey = "";
public string DatabaseProvider = "";
public static uint DefaultHttpPort = 8001;
public uint HttpPort = DefaultHttpPort;
public string AllowForcefulBanlines = "TRUE";
private ConfigurationMember configMember;
public GridConfig(string description, string filename)
{
configMember =
new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, true);
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("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("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
"Http Listener port", DefaultHttpPort.ToString(), false);
configMember.addConfigurationOption("allow_forceful_banlines",
ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Allow Forceful Banlines", "TRUE", true);
}
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
{
switch (configuration_key)
{
case "grid_owner":
GridOwner = (string) configuration_result;
break;
case "default_asset_server":
DefaultAssetServer = (string) configuration_result;
break;
case "asset_send_key":
AssetSendKey = (string) configuration_result;
break;
case "asset_recv_key":
AssetRecvKey = (string) configuration_result;
break;
case "default_user_server":
DefaultUserServer = (string) configuration_result;
break;
case "user_send_key":
UserSendKey = (string) configuration_result;
break;
case "user_recv_key":
UserRecvKey = (string) configuration_result;
break;
case "sim_send_key":
SimSendKey = (string) configuration_result;
break;
case "sim_recv_key":
SimRecvKey = (string) configuration_result;
break;
case "database_provider":
DatabaseProvider = (string) configuration_result;
break;
case "http_port":
HttpPort = (uint) configuration_result;
break;
case "allow_forceful_banlines":
AllowForcefulBanlines = (string) configuration_result;
break;
}
return true;
}
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using OpenSim.Framework.Console;
namespace OpenSim.Framework
{
public class GridConfig
{
public string GridOwner = String.Empty;
public string DefaultAssetServer = String.Empty;
public string AssetSendKey = String.Empty;
public string AssetRecvKey = String.Empty;
public string DefaultUserServer = String.Empty;
public string UserSendKey = String.Empty;
public string UserRecvKey = String.Empty;
public string SimSendKey = String.Empty;
public string SimRecvKey = String.Empty;
public string DatabaseProvider = String.Empty;
public static uint DefaultHttpPort = 8001;
public uint HttpPort = DefaultHttpPort;
public string AllowForcefulBanlines = "TRUE";
private ConfigurationMember configMember;
public GridConfig(string description, string filename)
{
configMember =
new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, true);
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("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("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
"Http Listener port", DefaultHttpPort.ToString(), false);
configMember.addConfigurationOption("allow_forceful_banlines",
ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Allow Forceful Banlines", "TRUE", true);
}
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
{
switch (configuration_key)
{
case "grid_owner":
GridOwner = (string) configuration_result;
break;
case "default_asset_server":
DefaultAssetServer = (string) configuration_result;
break;
case "asset_send_key":
AssetSendKey = (string) configuration_result;
break;
case "asset_recv_key":
AssetRecvKey = (string) configuration_result;
break;
case "default_user_server":
DefaultUserServer = (string) configuration_result;
break;
case "user_send_key":
UserSendKey = (string) configuration_result;
break;
case "user_recv_key":
UserRecvKey = (string) configuration_result;
break;
case "sim_send_key":
SimSendKey = (string) configuration_result;
break;
case "sim_recv_key":
SimRecvKey = (string) configuration_result;
break;
case "database_provider":
DatabaseProvider = (string) configuration_result;
break;
case "http_port":
HttpPort = (uint) configuration_result;
break;
case "allow_forceful_banlines":
AllowForcefulBanlines = (string) configuration_result;
break;
}
return true;
}
}
}

View File

@ -1,44 +1,44 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using libsecondlife;
using System.Collections.Generic; // rex added
namespace OpenSim.Framework
{
public interface IAssetProvider : IPlugin
{
AssetBase FetchAsset(LLUUID uuid);
void CreateAsset(AssetBase asset);
void UpdateAsset(AssetBase asset);
bool ExistsAsset(LLUUID uuid);
void CommitAssets(); // force a sync to the database
LLUUID ExistsAsset(sbyte type, string name); // rex new function for "replace asset" functionality
List<AssetBase> GetAssetList(int vAssetType); // rex, added
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using libsecondlife;
using System.Collections.Generic; // rex added
namespace OpenSim.Framework
{
public interface IAssetProvider : IPlugin
{
AssetBase FetchAsset(LLUUID uuid);
void CreateAsset(AssetBase asset);
void UpdateAsset(AssetBase asset);
bool ExistsAsset(LLUUID uuid);
void CommitAssets(); // force a sync to the database
LLUUID ExistsAsset(sbyte type, string name); // rex new function for "replace asset" functionality
List<AssetBase> GetAssetList(int vAssetType); // rex, added
}
}

View File

@ -1,61 +1,71 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using libsecondlife;
namespace OpenSim.Framework
{
/// <summary>
/// Description of IAssetServer.
/// </summary>
public interface IAssetServer
{
void SetReceiver(IAssetReceiver receiver);
void RequestAsset(LLUUID assetID, bool isTexture);
void UpdateAsset(AssetBase asset);
void StoreAndCommitAsset(AssetBase asset);
void Close();
LLUUID ExistsAsset(sbyte type, string name); // rex new function for "replace asset" functionality
bool ExistsAsset(LLUUID assetID); // rex added
List<AssetBase> GetAssetList(int vAssetType); // rex added
AssetBase FetchAsset(LLUUID assetID); // rex added
}
// could change to delegate?
public interface IAssetReceiver
{
void AssetReceived(AssetBase asset, bool IsTexture);
void AssetNotFound(LLUUID assetID);
}
public interface IAssetPlugin
{
IAssetServer GetAssetServer();
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using libsecondlife;
namespace OpenSim.Framework
{
/// <summary>
/// Description of IAssetServer.
/// </summary>
public interface IAssetServer
{
void SetReceiver(IAssetReceiver receiver);
void RequestAsset(LLUUID assetID, bool isTexture);
void UpdateAsset(AssetBase asset);
void StoreAndCommitAsset(AssetBase asset);
void Close();
LLUUID ExistsAsset(sbyte type, string name); // rex new function for "replace asset" functionality
bool ExistsAsset(LLUUID assetID); // rex added
List<AssetBase> GetAssetList(int vAssetType); // rex added
AssetBase FetchAsset(LLUUID assetID); // rex added
}
// could change to delegate?
public interface IAssetReceiver
{
/// <summary>
/// Call back made when a requested asset has been retrieved by an asset server
/// </summary>
/// <param name="asset"></param>
/// <param name="IsTexture"></param>
void AssetReceived(AssetBase asset, bool IsTexture);
/// <summary>
/// Call back made when an asset server could not retrieve a requested asset
/// </summary>
/// <param name="assetID"></param>
void AssetNotFound(LLUUID assetID);
}
public interface IAssetPlugin
{
IAssetServer GetAssetServer();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,53 +1,53 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace OpenSim.Framework
{
/// <summary>
/// This interface, describes a generic plugin
/// </summary>
public interface IPlugin
{
/// <summary>
/// Returns the plugin version
/// </summary>
/// <returns>Plugin version in MAJOR.MINOR.REVISION.BUILD format</returns>
string Version { get; }
/// <summary>
/// Returns the plugin name
/// </summary>
/// <returns>Plugin name, eg MySQL User Provider</returns>
string Name { get; }
/// <summary>
/// Initialises the plugin (artificial constructor)
/// </summary>
void Initialise();
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace OpenSim.Framework
{
/// <summary>
/// This interface, describes a generic plugin
/// </summary>
public interface IPlugin
{
/// <summary>
/// Returns the plugin version
/// </summary>
/// <returns>Plugin version in MAJOR.MINOR.REVISION.BUILD format</returns>
string Version { get; }
/// <summary>
/// Returns the plugin name
/// </summary>
/// <returns>Plugin name, eg MySQL User Provider</returns>
string Name { get; }
/// <summary>
/// Initialises the plugin (artificial constructor)
/// </summary>
void Initialise();
}
}

View File

@ -1,68 +1,71 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Collections.Generic;
using libsecondlife;
namespace OpenSim.Framework
{
public delegate void ExpectUserDelegate(ulong regionHandle, AgentCircuitData agent);
public delegate void ExpectPrimDelegate(ulong regionHandle, LLUUID primID, string objData);
public delegate void UpdateNeighbours(List<RegionInfo> neighbours);
public delegate void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying);
public delegate void PrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical);
public delegate void AcknowledgeAgentCross(ulong regionHandle, LLUUID agentID);
public delegate void AcknowledgePrimCross(ulong regionHandle, LLUUID PrimID);
public delegate void CloseAgentConnection(ulong regionHandle, LLUUID agentID);
public delegate bool RegionUp(RegionInfo region);
public delegate bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData);
public interface IRegionCommsListener
{
event ExpectUserDelegate OnExpectUser;
event ExpectPrimDelegate OnExpectPrim;
event GenericCall2 OnExpectChildAgent;
event AgentCrossing OnAvatarCrossingIntoRegion;
event PrimCrossing OnPrimCrossingIntoRegion;
event AcknowledgeAgentCross OnAcknowledgeAgentCrossed;
event AcknowledgePrimCross OnAcknowledgePrimCrossed;
event UpdateNeighbours OnNeighboursUpdate;
event CloseAgentConnection OnCloseAgentConnection;
event RegionUp OnRegionUp;
event ChildAgentUpdate OnChildAgentUpdate;
}
}
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Collections.Generic;
using libsecondlife;
namespace OpenSim.Framework
{
public delegate void ExpectUserDelegate(ulong regionHandle, AgentCircuitData agent);
public delegate void ExpectPrimDelegate(ulong regionHandle, LLUUID primID, string objData);
public delegate void UpdateNeighbours(List<RegionInfo> neighbours);
public delegate void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying);
public delegate void PrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical);
public delegate void AcknowledgeAgentCross(ulong regionHandle, LLUUID agentID);
public delegate void AcknowledgePrimCross(ulong regionHandle, LLUUID PrimID);
public delegate bool CloseAgentConnection(ulong regionHandle, LLUUID agentID);
public delegate bool RegionUp(RegionInfo region);
public delegate bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData);
public interface IRegionCommsListener
{
event ExpectUserDelegate OnExpectUser;
event ExpectPrimDelegate OnExpectPrim;
event GenericCall2 OnExpectChildAgent;
event AgentCrossing OnAvatarCrossingIntoRegion;
event PrimCrossing OnPrimCrossingIntoRegion;
event AcknowledgeAgentCross OnAcknowledgeAgentCrossed;
event AcknowledgePrimCross OnAcknowledgePrimCrossed;
event UpdateNeighbours OnNeighboursUpdate;
event CloseAgentConnection OnCloseAgentConnection;
event RegionUp OnRegionUp;
event ChildAgentUpdate OnChildAgentUpdate;
}
}

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