diff --git a/libsecondlife-cs/AssemblyInfo.cs b/libsecondlife-cs/AssemblyInfo.cs index 53f2eb42..3888026f 100644 --- a/libsecondlife-cs/AssemblyInfo.cs +++ b/libsecondlife-cs/AssemblyInfo.cs @@ -9,9 +9,9 @@ using System.Runtime.CompilerServices; [assembly: AssemblyTitle("libsecondlife")] [assembly: AssemblyDescription("Networking layer for the Second Life world")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Second Life Reverse Engineering Team")] +[assembly: AssemblyCompany("libsecondlife Team")] [assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("(c) 2006 Second Life Reverse Engineering Team")] +[assembly: AssemblyCopyright("(c) 2006 libsecondlife Team")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -26,7 +26,7 @@ using System.Runtime.CompilerServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.0.5.0")] +[assembly: AssemblyVersion("0.0.6.0")] // // In order to sign your assembly you must specify a key to use. Refer to the diff --git a/libsecondlife-cs/AssetSystem/AssetManager.cs b/libsecondlife-cs/AssetSystem/AssetManager.cs index 98db53fd..eb00772c 100644 --- a/libsecondlife-cs/AssetSystem/AssetManager.cs +++ b/libsecondlife-cs/AssetSystem/AssetManager.cs @@ -25,7 +25,7 @@ */ using System; -using System.Collections; +using System.Collections.Generic; using libsecondlife; @@ -48,7 +48,7 @@ namespace libsecondlife.AssetSystem private SecondLife slClient; private TransferRequest curUploadRequest = null; - private Hashtable htDownloadRequests = new Hashtable(); + private Dictionary htDownloadRequests = new Dictionary(); private class TransferRequest { diff --git a/libsecondlife-cs/AssetSystem/AssetPacketHelpers.cs b/libsecondlife-cs/AssetSystem/AssetPacketHelpers.cs index d9337bb3..2080f9f4 100644 --- a/libsecondlife-cs/AssetSystem/AssetPacketHelpers.cs +++ b/libsecondlife-cs/AssetSystem/AssetPacketHelpers.cs @@ -25,7 +25,7 @@ */ using System; -using System.Collections; +using System.Collections.Generic; using libsecondlife; using libsecondlife.InventorySystem; diff --git a/libsecondlife-cs/AssetSystem/ImageManager.cs b/libsecondlife-cs/AssetSystem/ImageManager.cs index 92eb318e..f528b925 100644 --- a/libsecondlife-cs/AssetSystem/ImageManager.cs +++ b/libsecondlife-cs/AssetSystem/ImageManager.cs @@ -25,7 +25,7 @@ */ using System; -using System.Collections; +using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; @@ -43,7 +43,7 @@ namespace libsecondlife.AssetSystem private ImagePacketHelpers ImagePacketHelper; - private Hashtable htDownloadRequests = new Hashtable(); + private Dictionary htDownloadRequests = new Dictionary(); private class TransferRequest { @@ -210,5 +210,5 @@ namespace libsecondlife.AssetSystem { Console.WriteLine(packet); } - } + } } \ No newline at end of file diff --git a/libsecondlife-cs/AssetSystem/ImagePacketHelpers.cs b/libsecondlife-cs/AssetSystem/ImagePacketHelpers.cs index d67d770b..89b8866d 100644 --- a/libsecondlife-cs/AssetSystem/ImagePacketHelpers.cs +++ b/libsecondlife-cs/AssetSystem/ImagePacketHelpers.cs @@ -25,7 +25,7 @@ */ using System; -using System.Collections; +using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; diff --git a/libsecondlife-cs/Avatar.cs b/libsecondlife-cs/Avatar.cs index ac4a5d63..508f7474 100644 --- a/libsecondlife-cs/Avatar.cs +++ b/libsecondlife-cs/Avatar.cs @@ -27,7 +27,7 @@ using System; using System.Timers; using System.Net; -using System.Collections; +using System.Collections.Generic; using libsecondlife.Packets; namespace libsecondlife @@ -473,7 +473,7 @@ namespace libsecondlife { if (Client.Grid.Regions.ContainsKey(simName.ToLower())) { - return Teleport(((GridRegion)Client.Grid.Regions[simName.ToLower()]).RegionHandle, position, lookAt); + return Teleport(Client.Grid.Regions[simName.ToLower()].RegionHandle, position, lookAt); } else { diff --git a/libsecondlife-cs/GridManager.cs b/libsecondlife-cs/GridManager.cs index 1f38bb2b..234ec401 100644 --- a/libsecondlife-cs/GridManager.cs +++ b/libsecondlife-cs/GridManager.cs @@ -25,7 +25,7 @@ */ using System; -using System.Collections; +using System.Collections.Generic; using libsecondlife.Packets; namespace libsecondlife @@ -72,7 +72,7 @@ namespace libsecondlife public event AddRegionCallback OnRegionAdd; /// A hashtable of all the regions, indexed by region ID - public Hashtable Regions; + public Dictionary Regions; /// Current direction of the sun public LLVector3 SunDirection; @@ -85,7 +85,7 @@ namespace libsecondlife public GridManager(SecondLife client) { Client = client; - Regions = new Hashtable(); + Regions = new Dictionary(); SunDirection = new LLVector3(); Client.Network.RegisterCallback(PacketType.MapBlockReply, new PacketCallback(MapBlockReplyHandler)); @@ -154,13 +154,13 @@ namespace libsecondlife public GridRegion GetSim(string name) { if(Regions.ContainsKey(name)) - return (GridRegion)Regions[name]; + return Regions[name]; AddSim(name); System.Threading.Thread.Sleep(1000); if(Regions.ContainsKey(name)) - return (GridRegion)Regions[name]; + return Regions[name]; else { //TODO: Put some better handling inplace here with some retry code diff --git a/libsecondlife-cs/GroupManager.cs b/libsecondlife-cs/GroupManager.cs index d7e508ab..4b18ca71 100644 --- a/libsecondlife-cs/GroupManager.cs +++ b/libsecondlife-cs/GroupManager.cs @@ -25,7 +25,7 @@ */ using System; -using System.Collections; +using System.Collections.Generic; using System.Threading; using libsecondlife.Packets; @@ -53,14 +53,13 @@ namespace libsecondlife public string Title; public string Description; public ulong Powers; - /// (LLUUID,GroupMember) Contains all the group members - /// belonging to this role - public Hashtable Members; + /// Contains all the group members belonging to this role + public Dictionary Members; public GroupRole(LLUUID id) { ID = id; - Members = new Hashtable(); + Members = new Dictionary(); } } @@ -87,12 +86,12 @@ namespace libsecondlife public int Contribution; public int GroupMembershipCount; public int GroupRolesCount; - /// (LLUUID,?) - public Hashtable Titles; - /// (LLUUID,GroupRole) List of all the roles in this group - public Hashtable Roles; - /// (LLUUID,GroupMember) List of all the members in this group - public Hashtable Members; + /// + public Dictionary Titles; + /// List of all the roles in this group + public Dictionary Roles; + /// List of all the members in this group + public Dictionary Members; /// Used for internal state tracking public LLUUID TitlesRequestID; /// Used for internal state tracking @@ -105,9 +104,9 @@ namespace libsecondlife ID = id; InsigniaID = new LLUUID(); - Titles = new Hashtable(); - Roles = new Hashtable(); - Members = new Hashtable(); + Titles = new Dictionary(); + Roles = new Dictionary(); + Members = new Dictionary(); TitlesRequestID = new LLUUID(); RolesRequestID = new LLUUID(); @@ -129,7 +128,7 @@ namespace libsecondlife public delegate void GroupsUpdatedCallback(); /// - public Hashtable Groups; + public Dictionary Groups; private Mutex GroupsMutex; /// Called whenever the group membership list is updated @@ -139,7 +138,7 @@ namespace libsecondlife public GroupManager(SecondLife client) { - Groups = new Hashtable(); + Groups = new Dictionary(); GroupsMutex = new Mutex(false, "GroupsMutex"); Client = client; @@ -202,7 +201,7 @@ namespace libsecondlife // Attempt to locate the group that these titles belong to if (Groups.ContainsKey(titles.AgentData.GroupID)) { - thisGroup = (Group)Groups[titles.AgentData.GroupID]; + thisGroup = Groups[titles.AgentData.GroupID]; } else { @@ -236,7 +235,7 @@ namespace libsecondlife // Attempt to locate the group that these titles belong to if (Groups.ContainsKey(profile.GroupData.GroupID)) { - thisGroup = (Group)Groups[profile.GroupData.GroupID]; + thisGroup = Groups[profile.GroupData.GroupID]; } else { @@ -274,7 +273,7 @@ namespace libsecondlife if (Groups.ContainsKey(members.GroupData.GroupID)) { - thisGroup = (Group)Groups[members.GroupData.GroupID]; + thisGroup = Groups[members.GroupData.GroupID]; } else { @@ -314,7 +313,7 @@ namespace libsecondlife if (Groups.ContainsKey(roles.GroupData.GroupID)) { - thisGroup = (Group)Groups[roles.GroupData.GroupID]; + thisGroup = Groups[roles.GroupData.GroupID]; } else { @@ -326,7 +325,7 @@ namespace libsecondlife { if (thisGroup.Roles.ContainsKey(block.RoleID)) { - thisRole = (GroupRole)thisGroup.Roles[block.RoleID]; + thisRole = thisGroup.Roles[block.RoleID]; } else { @@ -356,7 +355,7 @@ namespace libsecondlife if (Groups.ContainsKey(members.AgentData.GroupID)) { - thisGroup = (Group)Groups[members.AgentData.GroupID]; + thisGroup = Groups[members.AgentData.GroupID]; } else { @@ -368,7 +367,7 @@ namespace libsecondlife { if (thisGroup.Roles.ContainsKey(block.RoleID)) { - thisRole = (GroupRole)thisGroup.Roles[block.RoleID]; + thisRole = thisGroup.Roles[block.RoleID]; } else { @@ -378,7 +377,7 @@ namespace libsecondlife if (thisGroup.Members.ContainsKey(block.MemberID)) { - thisMember = (GroupMember)thisGroup.Members[block.MemberID]; + thisMember = thisGroup.Members[block.MemberID]; } else { diff --git a/libsecondlife-cs/InventorySystem/InventoryFolder.cs b/libsecondlife-cs/InventorySystem/InventoryFolder.cs index cedddbcb..7ce79d7a 100644 --- a/libsecondlife-cs/InventorySystem/InventoryFolder.cs +++ b/libsecondlife-cs/InventorySystem/InventoryFolder.cs @@ -1,163 +1,169 @@ -using System.Collections; +using System.Collections.Generic; using System; using libsecondlife; namespace libsecondlife.InventorySystem { - /// - /// Summary description for InventoryFolder. - /// - public class InventoryFolder : InventoryBase - { - public string Name - { - get { return _Name; } - set - { - _Name = value; - base.iManager.FolderRename( this ); - } - } + /// + /// Summary description for InventoryFolder. + /// + public class InventoryFolder : InventoryBase + { + public string Name + { + get { return _Name; } + set + { + _Name = value; + base.iManager.FolderRename(this); + } + } - private LLUUID _FolderID; - public LLUUID FolderID - { - get { return _FolderID; } - } + private LLUUID _FolderID; + public LLUUID FolderID + { + get { return _FolderID; } + } - private LLUUID _ParentID; - public LLUUID ParentID - { - get { return _ParentID; } - set - { - InventoryFolder ifParent = iManager.getFolder( this.ParentID ); - ifParent.alContents.Remove( this ); + private LLUUID _ParentID; + public LLUUID ParentID + { + get { return _ParentID; } + set + { + InventoryFolder ifParent = iManager.getFolder(this.ParentID); + ifParent.alContents.Remove(this); - ifParent = iManager.getFolder( value ); - ifParent.alContents.Add( this ); + ifParent = iManager.getFolder(value); + ifParent.alContents.Add(this); - this._ParentID = value; + this._ParentID = value; - base.iManager.FolderMove( this, value ); - } - } + base.iManager.FolderMove(this, value); + } + } - internal sbyte _Type; - public sbyte Type - { - get { return _Type; } - } - - public ArrayList alContents = new ArrayList(); + internal sbyte _Type; + public sbyte Type + { + get { return _Type; } + } - internal InventoryFolder( InventoryManager manager ) : base(manager) - { - _Name = ""; - _FolderID = new LLUUID(); - _ParentID = new LLUUID(); - _Type = -1; - } + public List alContents = new List(); - internal InventoryFolder( InventoryManager manager, String name, LLUUID folderID, LLUUID parentID ) : base(manager) - { - this._Name = name; - this._FolderID = folderID; - this._ParentID = parentID; - this._Type = 0; - } + internal InventoryFolder(InventoryManager manager) + : base(manager) + { + _Name = ""; + _FolderID = new LLUUID(); + _ParentID = new LLUUID(); + _Type = -1; + } - internal InventoryFolder( InventoryManager manager, String name, LLUUID folderID, LLUUID parentID, sbyte Type ) : base(manager) - { - this._Name = name; - this._FolderID = folderID; - this._ParentID = parentID; - this._Type = Type; - } + internal InventoryFolder(InventoryManager manager, String name, LLUUID folderID, LLUUID parentID) + : base(manager) + { + this._Name = name; + this._FolderID = folderID; + this._ParentID = parentID; + this._Type = 0; + } - internal InventoryFolder( InventoryManager manager, Hashtable htData ) : base(manager) - { - this._Name = (string)htData["name"]; - this._FolderID = new LLUUID( (string)htData["folder_id"] ); - this._ParentID = new LLUUID( (string)htData["parent_id"] ); - this._Type = sbyte.Parse( htData["type_default"].ToString() ); - } + internal InventoryFolder(InventoryManager manager, String name, LLUUID folderID, LLUUID parentID, sbyte Type) + : base(manager) + { + this._Name = name; + this._FolderID = folderID; + this._ParentID = parentID; + this._Type = Type; + } + + internal InventoryFolder(InventoryManager manager, Dictionary htData) + : base(manager) + { + this._Name = htData["name"]; + this._FolderID = new LLUUID(htData["folder_id"]); + this._ParentID = new LLUUID(htData["parent_id"]); + this._Type = sbyte.Parse(htData["type_default"].ToString()); + } - public InventoryFolder CreateFolder( string name ) - { - return base.iManager.FolderCreate( name, FolderID ); - } + public InventoryFolder CreateFolder(string name) + { + return base.iManager.FolderCreate(name, FolderID); + } - public void Delete() - { - iManager.getFolder( this.ParentID ).alContents.Remove(this); - iManager.FolderRemove(this); - } + public void Delete() + { + iManager.getFolder(this.ParentID).alContents.Remove(this); + iManager.FolderRemove(this); + } - public void MoveTo( InventoryFolder newParent ) - { - MoveTo( newParent.FolderID ); - } + public void MoveTo(InventoryFolder newParent) + { + MoveTo(newParent.FolderID); + } - public void MoveTo( LLUUID newParentID ) - { - this.ParentID = newParentID; - } + public void MoveTo(LLUUID newParentID) + { + this.ParentID = newParentID; + } - public InventoryNotecard NewNotecard( string name, string description, string body ) - { - return base.iManager.NewNotecard( name, description, body, this.FolderID ); - } + public InventoryNotecard NewNotecard(string name, string description, string body) + { + return base.iManager.NewNotecard(name, description, body, this.FolderID); + } - public InventoryImage NewImage( string name, string description, byte[] j2cdata ) - { - return base.iManager.NewImage( name, description, j2cdata, this.FolderID ); - } + public InventoryImage NewImage(string name, string description, byte[] j2cdata) + { + return base.iManager.NewImage(name, description, j2cdata, this.FolderID); + } - public ArrayList GetItemByName( string name ) - { - ArrayList items = new ArrayList(); - foreach( InventoryBase ib in alContents ) - { - if( ib is InventoryFolder ) - { - items.AddRange( ((InventoryFolder)ib).GetItemByName(name) ); - } else if ( ib is InventoryItem ) { - if( ((InventoryItem)ib).Name.Equals( name ) ) - { - items.Add( ib ); - } - } - } + public List GetItemByName(string name) + { + List items = new List(); + foreach (InventoryBase ib in alContents) + { + if (ib is InventoryFolder) + { + items.AddRange(((InventoryFolder)ib).GetItemByName(name)); + } + else if (ib is InventoryItem) + { + if (((InventoryItem)ib).Name.Equals(name)) + { + items.Add(ib); + } + } + } - return items; - } + return items; + } /// /// Output this folder as XML /// /// Include an asset data as well, TRUE/FALSE override public string toXML(bool outputAssets) - { - string output = " - /// Base class for most inventory items, providing a lot of general inventory management functions. - /// - public class InventoryItem : InventoryBase - { - private const uint FULL_MASK_PERMISSIONS = 2147483647; + /// + /// Base class for most inventory items, providing a lot of general inventory management functions. + /// + public class InventoryItem : InventoryBase + { + private const uint FULL_MASK_PERMISSIONS = 2147483647; - public string Name - { - get{ return base._Name; } - set - { - _Name = value; - UpdateItem(); - } - } + public string Name + { + get { return base._Name; } + set + { + _Name = value; + UpdateItem(); + } + } - internal LLUUID _FolderID = new LLUUID(); - public LLUUID FolderID - { - get{ return _FolderID; } - set - { - InventoryFolder iTargetFolder = base.iManager.getFolder( value ); - if( iTargetFolder == null ) - { - throw new Exception("Target Folder [" + value + "] does not exist."); - } + internal LLUUID _FolderID = new LLUUID(); + public LLUUID FolderID + { + get { return _FolderID; } + set + { + InventoryFolder iTargetFolder = base.iManager.getFolder(value); + if (iTargetFolder == null) + { + throw new Exception("Target Folder [" + value + "] does not exist."); + } - base.iManager.getFolder( this.FolderID ).alContents.Remove( this ); - iTargetFolder.alContents.Add( this ); + base.iManager.getFolder(this.FolderID).alContents.Remove(this); + iTargetFolder.alContents.Add(this); - _FolderID = value; - UpdateItem(); - } - } + _FolderID = value; + UpdateItem(); + } + } - internal LLUUID _ItemID = null; - public LLUUID ItemID - { - set { + internal LLUUID _ItemID = null; + public LLUUID ItemID + { + set + { if (_ItemID == null) { _ItemID = value; @@ -58,80 +59,81 @@ namespace libsecondlife.InventorySystem throw new Exception("You can not change an item's ID once it's been set."); } } - get { return _ItemID; } - } + get { return _ItemID; } + } - internal sbyte _InvType = 0; - public sbyte InvType - { - get{ return _InvType; } - } + internal sbyte _InvType = 0; + public sbyte InvType + { + get { return _InvType; } + } - internal sbyte _Type = 0; - public sbyte Type - { - get{ return _Type; } - set - { - _Type = value; - UpdateItem(); - } - } - - - internal string _Description = ""; - public string Description - { - get{ return _Description; } - set - { - _Description = value; - UpdateItem(); - } - } - - internal uint _CRC = 0; - public uint CRC - { - get { return _CRC; } - set - { - _CRC = value; - } - } + internal sbyte _Type = 0; + public sbyte Type + { + get { return _Type; } + set + { + _Type = value; + UpdateItem(); + } + } - internal LLUUID _OwnerID = new LLUUID(); - public LLUUID OwnerID - { - get { return _OwnerID; } - } + internal string _Description = ""; + public string Description + { + get { return _Description; } + set + { + _Description = value; + UpdateItem(); + } + } - internal LLUUID _CreatorID = new LLUUID(); - public LLUUID CreatorID - { - get { return _CreatorID; } - } + internal uint _CRC = 0; + public uint CRC + { + get { return _CRC; } + set + { + _CRC = value; + } + } - internal Asset _Asset; - public Asset Asset - { - get { - if( _Asset != null ) - { - return _Asset; - } - else - { - if( (AssetID != null) && (AssetID != new LLUUID()) ) - { - base.iManager.AssetManager.GetInventoryAsset( this ); - return Asset; - } - } - return null; - } - } + + internal LLUUID _OwnerID = new LLUUID(); + public LLUUID OwnerID + { + get { return _OwnerID; } + } + + internal LLUUID _CreatorID = new LLUUID(); + public LLUUID CreatorID + { + get { return _CreatorID; } + } + + internal Asset _Asset; + public Asset Asset + { + get + { + if (_Asset != null) + { + return _Asset; + } + else + { + if ((AssetID != null) && (AssetID != new LLUUID())) + { + base.iManager.AssetManager.GetInventoryAsset(this); + return Asset; + } + } + return null; + } + } internal LLUUID _TransactionID = new LLUUID(); public LLUUID TransactionID @@ -139,188 +141,191 @@ namespace libsecondlife.InventorySystem get { return _TransactionID; } } - internal LLUUID _AssetID = new LLUUID(); - public LLUUID AssetID - { - get { return _AssetID; } - } + internal LLUUID _AssetID = new LLUUID(); + public LLUUID AssetID + { + get { return _AssetID; } + } - internal LLUUID _GroupID = new LLUUID(); - public LLUUID GroupID - { - get { return _GroupID; } - set - { - _GroupID = value; - UpdateItem(); - } - } + internal LLUUID _GroupID = new LLUUID(); + public LLUUID GroupID + { + get { return _GroupID; } + set + { + _GroupID = value; + UpdateItem(); + } + } - internal bool _GroupOwned = false; - public bool GroupOwned - { - get { return _GroupOwned; } - set - { - _GroupOwned = value; - UpdateItem(); - } - } + internal bool _GroupOwned = false; + public bool GroupOwned + { + get { return _GroupOwned; } + set + { + _GroupOwned = value; + UpdateItem(); + } + } - internal int _CreationDate = (int)((TimeSpan)(DateTime.UtcNow - new DateTime(1970, 1, 1))).TotalSeconds; - public int CreationDate - { - get { return _CreationDate; } - } + internal int _CreationDate = (int)((TimeSpan)(DateTime.UtcNow - new DateTime(1970, 1, 1))).TotalSeconds; + public int CreationDate + { + get { return _CreationDate; } + } - internal byte _SaleType = 0; - public byte SaleType - { - get { return _SaleType; } - set - { - _SaleType = value; - UpdateItem(); - } - } + internal byte _SaleType = 0; + public byte SaleType + { + get { return _SaleType; } + set + { + _SaleType = value; + UpdateItem(); + } + } - internal uint _BaseMask = FULL_MASK_PERMISSIONS; - public uint BaseMask - { - get { return _BaseMask; } - } + internal uint _BaseMask = FULL_MASK_PERMISSIONS; + public uint BaseMask + { + get { return _BaseMask; } + } - internal int _SalePrice = 0; - public int SalePrice - { - get { return _SalePrice; } - set - { - _SalePrice = value; - UpdateItem(); - } - } + internal int _SalePrice = 0; + public int SalePrice + { + get { return _SalePrice; } + set + { + _SalePrice = value; + UpdateItem(); + } + } - internal uint _EveryoneMask = 0; - public uint EveryoneMask - { - get { return _EveryoneMask; } - set - { - _EveryoneMask = value; - UpdateItem(); - } - } + internal uint _EveryoneMask = 0; + public uint EveryoneMask + { + get { return _EveryoneMask; } + set + { + _EveryoneMask = value; + UpdateItem(); + } + } - internal uint _Flags = 0; - public uint Flags - { - get { return _Flags; } - set - { - _Flags = value; - UpdateItem(); - } - } + internal uint _Flags = 0; + public uint Flags + { + get { return _Flags; } + set + { + _Flags = value; + UpdateItem(); + } + } - internal uint _NextOwnerMask = FULL_MASK_PERMISSIONS; - public uint NextOwnerMask - { - get { return _NextOwnerMask; } - set - { - _NextOwnerMask = value; - UpdateItem(); - } - } + internal uint _NextOwnerMask = FULL_MASK_PERMISSIONS; + public uint NextOwnerMask + { + get { return _NextOwnerMask; } + set + { + _NextOwnerMask = value; + UpdateItem(); + } + } - internal uint _GroupMask = 0; - public uint GroupMask - { - get { return _GroupMask; } - set - { - _GroupMask = value; - UpdateItem(); - } - } + internal uint _GroupMask = 0; + public uint GroupMask + { + get { return _GroupMask; } + set + { + _GroupMask = value; + UpdateItem(); + } + } - internal uint _OwnerMask = FULL_MASK_PERMISSIONS; - public uint OwnerMask - { - get { return _OwnerMask; } - } + internal uint _OwnerMask = FULL_MASK_PERMISSIONS; + public uint OwnerMask + { + get { return _OwnerMask; } + } - internal InventoryItem(InventoryManager manager) : base(manager) - { - } + internal InventoryItem(InventoryManager manager) + : base(manager) + { + } internal InventoryItem(InventoryManager manager, InventoryDescendentsPacket.ItemDataBlock itemData) : base(manager) { - _Name = System.Text.Encoding.UTF8.GetString(itemData.Name).Trim().Replace("\0", ""); - _Description = System.Text.Encoding.UTF8.GetString(itemData.Description).Trim().Replace("\0", ""); + _Name = System.Text.Encoding.UTF8.GetString(itemData.Name).Trim().Replace("\0", ""); + _Description = System.Text.Encoding.UTF8.GetString(itemData.Description).Trim().Replace("\0", ""); _CreationDate = itemData.CreationDate; - - _InvType = itemData.InvType; - _Type = itemData.Type; - _AssetID = itemData.AssetID; + _InvType = itemData.InvType; + _Type = itemData.Type; + + _AssetID = itemData.AssetID; _FolderID = itemData.FolderID; _GroupOwned = itemData.GroupOwned; - _GroupID = itemData.GroupID; - _GroupMask = itemData.GroupMask; + _GroupID = itemData.GroupID; + _GroupMask = itemData.GroupMask; _CreatorID = itemData.CreatorID; - _OwnerID = itemData.OwnerID; + _OwnerID = itemData.OwnerID; _OwnerMask = itemData.OwnerMask; - - _Flags = itemData.Flags; - _BaseMask = itemData.BaseMask; - _EveryoneMask = itemData.EveryoneMask; + + _Flags = itemData.Flags; + _BaseMask = itemData.BaseMask; + _EveryoneMask = itemData.EveryoneMask; _NextOwnerMask = itemData.NextOwnerMask; - _SaleType = itemData.SaleType; + _SaleType = itemData.SaleType; _SalePrice = itemData.SalePrice; _CRC = itemData.CRC; } - internal InventoryItem( InventoryManager manager, string name, LLUUID folderID, sbyte invType, sbyte type, LLUUID uuidOwnerCreater ) : base(manager) - { - _Name = name; - _FolderID = folderID; - _InvType = invType; - _Type = type; - _OwnerID = uuidOwnerCreater; - _CreatorID = uuidOwnerCreater; + internal InventoryItem(InventoryManager manager, string name, LLUUID folderID, sbyte invType, sbyte type, LLUUID uuidOwnerCreater) + : base(manager) + { + _Name = name; + _FolderID = folderID; + _InvType = invType; + _Type = type; + _OwnerID = uuidOwnerCreater; + _CreatorID = uuidOwnerCreater; - UpdateCRC(); - } + UpdateCRC(); + } - internal InventoryItem( InventoryManager manager, string name, string description, LLUUID folderID, sbyte invType, sbyte type, LLUUID uuidOwnerCreater ) : base(manager) - { - _Name = name; - _Description = description; - _FolderID = folderID; - _InvType = invType; - _Type = type; - _OwnerID = uuidOwnerCreater; - _CreatorID = uuidOwnerCreater; + internal InventoryItem(InventoryManager manager, string name, string description, LLUUID folderID, sbyte invType, sbyte type, LLUUID uuidOwnerCreater) + : base(manager) + { + _Name = name; + _Description = description; + _FolderID = folderID; + _InvType = invType; + _Type = type; + _OwnerID = uuidOwnerCreater; + _CreatorID = uuidOwnerCreater; - UpdateCRC(); - } + UpdateCRC(); + } /// /// protected void SetAssetTransactionIDs(LLUUID assetID, LLUUID transactionID) { - _AssetID = assetID; + _AssetID = assetID; _TransactionID = transactionID; UpdateItem(); } @@ -329,153 +334,157 @@ namespace libsecondlife.InventorySystem /// /// public override bool Equals(object o) - { - if( (o is InventoryItem) == false ) - { - return false; - } + { + if ((o is InventoryItem) == false) + { + return false; + } - return this._ItemID == ((InventoryItem)o)._ItemID; - } + return this._ItemID == ((InventoryItem)o)._ItemID; + } /// /// public override int GetHashCode() - { - return this._ItemID.GetHashCode(); - } + { + return this._ItemID.GetHashCode(); + } /// /// CompareTo provided so that items can be sorted by name /// /// - public int CompareTo(object obj) - { - if(obj is InventoryBase) - { - InventoryBase temp = (InventoryBase) obj; - return this._Name.CompareTo(temp._Name); - } - throw new ArgumentException("object is not an InventoryItem"); - } + public int CompareTo(object obj) + { + if (obj is InventoryBase) + { + InventoryBase temp = (InventoryBase)obj; + return this._Name.CompareTo(temp._Name); + } + throw new ArgumentException("object is not an InventoryItem"); + } - private void UpdateItem() - { - UpdateCRC(); - base.iManager.ItemUpdate( this ); - } + private void UpdateItem() + { + UpdateCRC(); + base.iManager.ItemUpdate(this); + } - private void UpdateCRC() - { - _CRC = InventoryPacketHelper.InventoryUpdateCRC(this); - } + private void UpdateCRC() + { + _CRC = InventoryPacketHelper.InventoryUpdateCRC(this); + } /// /// Move this item to the target folder /// /// public void MoveTo(InventoryFolder targetFolder) - { - this.FolderID = targetFolder.FolderID; - } + { + this.FolderID = targetFolder.FolderID; + } /// /// Move this item to the target folder /// /// public void MoveTo(LLUUID targetFolderID) - { - this.FolderID = targetFolderID; - } + { + this.FolderID = targetFolderID; + } /// /// If you have Copy permission, a copy is placed in the target folder /// /// public void CopyTo(LLUUID targetFolder) - { - base.iManager.ItemCopy( this.ItemID, targetFolder ); - } + { + base.iManager.ItemCopy(this.ItemID, targetFolder); + } /// /// Give this item to another agent. If you have Copy permission, a copy will be given /// /// public void GiveTo(LLUUID ToAgentID) - { - base.iManager.ItemGiveTo( this, ToAgentID ); - } + { + base.iManager.ItemGiveTo(this, ToAgentID); + } /// /// Delete this item from Second Life /// public void Delete() - { - base.iManager.getFolder( this.FolderID ).alContents.Remove( this ); - base.iManager.ItemRemove( this ); + { + base.iManager.getFolder(this.FolderID).alContents.Remove(this); + base.iManager.ItemRemove(this); - } + } /// /// /// virtual internal void SetAssetData(byte[] assetData) - { - if( _Asset == null ) - { - if( AssetID != null ) - { - _Asset = new Asset( AssetID, Type, assetData ); - } else { - _Asset = new Asset( LLUUID.GenerateUUID(), Type, assetData ); - _AssetID = _Asset.AssetID; - } - } else { - _Asset.AssetData = assetData; - } - } + { + if (_Asset == null) + { + if (AssetID != null) + { + _Asset = new Asset(AssetID, Type, assetData); + } + else + { + _Asset = new Asset(LLUUID.GenerateUUID(), Type, assetData); + _AssetID = _Asset.AssetID; + } + } + else + { + _Asset.AssetData = assetData; + } + } /// /// Output this item as XML /// /// Include an asset data as well, TRUE/FALSE override public string toXML(bool outputAssets) - { - string output = " - /// Summary description for Inventory. - /// - public class InventoryManager - { + /// + /// Summary description for Inventory. + /// + public class InventoryManager + { private const bool DEBUG_PACKETS = true; - // Reference to the SLClient Library - private SecondLife slClient; + // Reference to the SLClient Library + private SecondLife slClient; - // Reference to the Asset Manager - private static AssetManager slAssetManager; - internal AssetManager AssetManager - { - get{ return slAssetManager; } - } + // Reference to the Asset Manager + private static AssetManager slAssetManager; + internal AssetManager AssetManager + { + get { return slAssetManager; } + } public InventoryPacketHelper InvPacketHelper = null; - // UUID of Root Inventory Folder - private LLUUID uuidRootFolder; + // UUID of Root Inventory Folder + private LLUUID uuidRootFolder; - // Setup a hashtable to easily lookup folders by UUID - private Hashtable htFoldersByUUID = new Hashtable(); - - // Setup a Hashtable to track download progress - private Hashtable htFolderDownloadStatus; - private ArrayList alFolderRequestQueue; + // Setup a hashtable to easily lookup folders by UUID + private Dictionary htFoldersByUUID = new Dictionary(); + + // Setup a Hashtable to track download progress + private Dictionary htFolderDownloadStatus; + private List alFolderRequestQueue; // Used to track current item being created private InventoryItem iiCreationInProgress; private bool ItemCreationInProgress; - private uint LastPacketRecieved; + private uint LastPacketRecieved; - // Each InventorySystem needs to be initialized with a client and root folder. - public InventoryManager( SecondLife client, LLUUID rootFolder ) - { - slClient = client; - if( slAssetManager == null ) - { - slAssetManager = new AssetManager( slClient ); - } + // Each InventorySystem needs to be initialized with a client and root folder. + public InventoryManager(SecondLife client, LLUUID rootFolder) + { + slClient = client; + if (slAssetManager == null) + { + slAssetManager = new AssetManager(slClient); + } InvPacketHelper = new InventoryPacketHelper(slClient.Network.AgentID, slClient.Network.SessionID); - uuidRootFolder = rootFolder; - - resetFoldersByUUID(); - - // Setup the callback for Inventory Downloads - PacketCallback InventoryDescendentsCallback = new PacketCallback(InventoryDescendentsHandler); - slClient.Network.RegisterCallback(PacketType.InventoryDescendents, InventoryDescendentsCallback); + uuidRootFolder = rootFolder; + + resetFoldersByUUID(); + + // Setup the callback for Inventory Downloads + PacketCallback InventoryDescendentsCallback = new PacketCallback(InventoryDescendentsHandler); + slClient.Network.RegisterCallback(PacketType.InventoryDescendents, InventoryDescendentsCallback); // Setup the callback for Inventory Creation Update PacketCallback UpdateCreateInventoryItemCallback = new PacketCallback(UpdateCreateInventoryItemHandler); slClient.Network.RegisterCallback(PacketType.UpdateCreateInventoryItem, UpdateCreateInventoryItemCallback); - - } - // Used primarily for debugging and testing - public AssetManager getAssetManager() - { - Console.WriteLine("It is not recommended that you access the asset manager directly"); - return AssetManager; - } + } - private void resetFoldersByUUID() - { - // Init folder structure with root - htFoldersByUUID = new Hashtable(); - - InventoryFolder ifRootFolder = new InventoryFolder(this, "My Inventory", uuidRootFolder, null); - htFoldersByUUID[uuidRootFolder] = ifRootFolder; - } + // Used primarily for debugging and testing + public AssetManager getAssetManager() + { + Console.WriteLine("It is not recommended that you access the asset manager directly"); + return AssetManager; + } - public InventoryFolder getRootFolder() - { - return (InventoryFolder)htFoldersByUUID[uuidRootFolder]; - } + private void resetFoldersByUUID() + { + // Init folder structure with root + htFoldersByUUID = new Dictionary(); - public InventoryFolder getFolder( LLUUID folderID ) - { - return (InventoryFolder)htFoldersByUUID[folderID]; - } + InventoryFolder ifRootFolder = new InventoryFolder(this, "My Inventory", uuidRootFolder, null); + htFoldersByUUID[uuidRootFolder] = ifRootFolder; + } - public InventoryFolder getFolder( String sFolderPath ) - { - string sSecretConst = "+@#%$#$%^%^%$^$%SV$#%FR$G"; - sFolderPath = sFolderPath.Replace("//",sSecretConst); + public InventoryFolder getRootFolder() + { + return htFoldersByUUID[uuidRootFolder]; + } + + public InventoryFolder getFolder(LLUUID folderID) + { + return htFoldersByUUID[folderID]; + } + + public InventoryFolder getFolder(String sFolderPath) + { + string sSecretConst = "+@#%$#$%^%^%$^$%SV$#%FR$G"; + sFolderPath = sFolderPath.Replace("//", sSecretConst); if (sFolderPath.StartsWith("/")) { @@ -138,109 +138,111 @@ namespace libsecondlife.InventorySystem } char[] seperators = { '/' }; - string[] sFolderPathParts = sFolderPath.Split(seperators); + string[] sFolderPathParts = sFolderPath.Split(seperators); - for( int i = 0; i pathParts = new Queue(sFolderPathParts); return getFolder(pathParts); - } - private InventoryFolder getFolder( Queue qFolderPath ) - { - return getFolder( qFolderPath, getRootFolder() ); - } + } + private InventoryFolder getFolder(Queue qFolderPath) + { + return getFolder(qFolderPath, getRootFolder()); + } - private InventoryFolder getFolder( Queue qFolderPath, InventoryFolder ifRoot ) - { - string sCurFolder = (string)qFolderPath.Dequeue(); - - foreach( InventoryBase ibFolder in ifRoot.alContents ) - { - if( ibFolder is libsecondlife.InventorySystem.InventoryFolder ) - { - if( ((InventoryFolder)ibFolder).Name.Equals( sCurFolder ) ) - { - if( qFolderPath.Count == 0 ) - { - return (InventoryFolder)ibFolder; - } - else - { - return getFolder( qFolderPath, (InventoryFolder)ibFolder ); - } - } - } - } - - return null; - } + private InventoryFolder getFolder(Queue qFolderPath, InventoryFolder ifRoot) + { + string sCurFolder = qFolderPath.Dequeue(); - private void RequestFolder( DescendentRequest dr ) - { - Packet packet = InvPacketHelper.FetchInventoryDescendents( - dr.FolderID - , dr.FetchFolders - , dr.FetchItems); + foreach (InventoryBase ibFolder in ifRoot.alContents) + { + if (ibFolder is libsecondlife.InventorySystem.InventoryFolder) + { + if (((InventoryFolder)ibFolder).Name.Equals(sCurFolder)) + { + if (qFolderPath.Count == 0) + { + return (InventoryFolder)ibFolder; + } + else + { + return getFolder(qFolderPath, (InventoryFolder)ibFolder); + } + } + } + } - htFolderDownloadStatus[dr.FolderID] = dr; + return null; + } - slClient.Network.SendPacket(packet); - } + private void RequestFolder(DescendentRequest dr) + { + Packet packet = InvPacketHelper.FetchInventoryDescendents( + dr.FolderID + , dr.FetchFolders + , dr.FetchItems); - internal InventoryFolder FolderCreate( String name, LLUUID parentid ) - { - InventoryFolder ifolder = new InventoryFolder( this, name, LLUUID.GenerateUUID(), parentid ); - ifolder._Type = -1; + htFolderDownloadStatus[dr.FolderID] = dr; - if( htFoldersByUUID.Contains(ifolder.ParentID) ) - { - if( ((InventoryFolder)htFoldersByUUID[ifolder.ParentID]).alContents.Contains(ifolder) == false) - { - // Add new folder to the contents of the parent folder. - ((InventoryFolder)htFoldersByUUID[ifolder.ParentID]).alContents.Add( ifolder ); - } - } else { - throw new Exception("Parent Folder " + ifolder.ParentID + " does not exist in this Inventory Manager."); - } + slClient.Network.SendPacket(packet); + } - if( htFoldersByUUID.Contains( ifolder.FolderID ) == false ) - { - htFoldersByUUID[ifolder.FolderID] = ifolder; - } + internal InventoryFolder FolderCreate(String name, LLUUID parentid) + { + InventoryFolder ifolder = new InventoryFolder(this, name, LLUUID.GenerateUUID(), parentid); + ifolder._Type = -1; + + if (htFoldersByUUID.ContainsKey(ifolder.ParentID)) + { + if (((InventoryFolder)htFoldersByUUID[ifolder.ParentID]).alContents.Contains(ifolder) == false) + { + // Add new folder to the contents of the parent folder. + ((InventoryFolder)htFoldersByUUID[ifolder.ParentID]).alContents.Add(ifolder); + } + } + else + { + throw new Exception("Parent Folder " + ifolder.ParentID + " does not exist in this Inventory Manager."); + } + + if (htFoldersByUUID.ContainsKey(ifolder.FolderID) == false) + { + htFoldersByUUID[ifolder.FolderID] = ifolder; + } Packet packet = InvPacketHelper.CreateInventoryFolder(ifolder.Name, ifolder.ParentID, ifolder.Type, ifolder.FolderID); - slClient.Network.SendPacket(packet); + slClient.Network.SendPacket(packet); - return ifolder; - } + return ifolder; + } - internal void FolderRemove( InventoryFolder ifolder ) - { - FolderRemove( ifolder.FolderID ); - } - - internal void FolderRemove( LLUUID folderID ) - { - htFoldersByUUID.Remove( folderID ); + internal void FolderRemove(InventoryFolder ifolder) + { + FolderRemove(ifolder.FolderID); + } + + internal void FolderRemove(LLUUID folderID) + { + htFoldersByUUID.Remove(folderID); Packet packet = InvPacketHelper.RemoveInventoryFolder(folderID); - slClient.Network.SendPacket(packet); - } + slClient.Network.SendPacket(packet); + } - internal void FolderMove( InventoryFolder iFolder, LLUUID newParentID ) - { + internal void FolderMove(InventoryFolder iFolder, LLUUID newParentID) + { Packet packet = InvPacketHelper.MoveInventoryFolder(newParentID, iFolder.FolderID); - slClient.Network.SendPacket(packet); - } + slClient.Network.SendPacket(packet); + } - internal void FolderRename( InventoryFolder ifolder ) - { + internal void FolderRename(InventoryFolder ifolder) + { Packet packet = InvPacketHelper.UpdateInventoryFolder(ifolder.Name, ifolder.ParentID, ifolder.Type, ifolder.FolderID); - slClient.Network.SendPacket(packet); - } + slClient.Network.SendPacket(packet); + } internal void ItemCreate(InventoryItem iitem) { @@ -251,7 +253,7 @@ namespace libsecondlife.InventorySystem else { ItemCreationInProgress = true; - iiCreationInProgress = iitem; + iiCreationInProgress = iitem; } Packet packet = InvPacketHelper.CreateInventoryItem(iitem); @@ -264,141 +266,143 @@ namespace libsecondlife.InventorySystem } } - internal void ItemUpdate( InventoryItem iitem ) - { + internal void ItemUpdate(InventoryItem iitem) + { Packet packet = InvPacketHelper.UpdateInventoryItem(iitem); - slClient.Network.SendPacket(packet); - } + slClient.Network.SendPacket(packet); + } - internal void ItemCopy( LLUUID ItemID, LLUUID TargetFolderID ) - { + internal void ItemCopy(LLUUID ItemID, LLUUID TargetFolderID) + { Packet packet = InvPacketHelper.CopyInventoryItem(ItemID, TargetFolderID); - slClient.Network.SendPacket(packet); - } + slClient.Network.SendPacket(packet); + } - internal void ItemGiveTo( InventoryItem iitem, LLUUID ToAgentID ) - { - LLUUID MessageID = LLUUID.GenerateUUID(); + internal void ItemGiveTo(InventoryItem iitem, LLUUID ToAgentID) + { + LLUUID MessageID = LLUUID.GenerateUUID(); - Packet packet = InvPacketHelper.ImprovedInstantMessage( - MessageID - , ToAgentID - , slClient.Avatar.FirstName + " " + slClient.Avatar.LastName - , slClient.Avatar.Position - , iitem - ); + Packet packet = InvPacketHelper.ImprovedInstantMessage( + MessageID + , ToAgentID + , slClient.Avatar.FirstName + " " + slClient.Avatar.LastName + , slClient.Avatar.Position + , iitem + ); - slClient.Network.SendPacket(packet); + slClient.Network.SendPacket(packet); - } + } - internal void ItemRemove( InventoryItem iitem ) - { - InventoryFolder ifolder = getFolder( iitem.FolderID ); - ifolder.alContents.Remove( iitem ); + internal void ItemRemove(InventoryItem iitem) + { + InventoryFolder ifolder = getFolder(iitem.FolderID); + ifolder.alContents.Remove(iitem); Packet packet = InvPacketHelper.RemoveInventoryItem(iitem.ItemID); - slClient.Network.SendPacket(packet); - } + slClient.Network.SendPacket(packet); + } - internal InventoryNotecard NewNotecard( string Name, string Description, string Body, LLUUID FolderID ) - { - InventoryNotecard iNotecard = new InventoryNotecard( this, Name, Description, FolderID, slClient.Network.AgentID ); + internal InventoryNotecard NewNotecard(string Name, string Description, string Body, LLUUID FolderID) + { + InventoryNotecard iNotecard = new InventoryNotecard(this, Name, Description, FolderID, slClient.Network.AgentID); - // Create this notecard on the server. - ItemCreate(iNotecard ); + // Create this notecard on the server. + ItemCreate(iNotecard); - if( (Body != null) && (Body.Equals("") != true) ) - { - iNotecard.Body = Body; - } + if ((Body != null) && (Body.Equals("") != true)) + { + iNotecard.Body = Body; + } - return iNotecard; - } + return iNotecard; + } - internal InventoryImage NewImage( string Name, string Description, byte[] j2cdata, LLUUID FolderID ) - { - InventoryImage iImage = new InventoryImage( this, Name, Description, FolderID, slClient.Network.AgentID ); + internal InventoryImage NewImage(string Name, string Description, byte[] j2cdata, LLUUID FolderID) + { + InventoryImage iImage = new InventoryImage(this, Name, Description, FolderID, slClient.Network.AgentID); - // Create this image on the server. + // Create this image on the server. ItemCreate(iImage); - if( (j2cdata != null) && (j2cdata.Length != 0) ) - { - iImage.J2CData = j2cdata; - } + if ((j2cdata != null) && (j2cdata.Length != 0)) + { + iImage.J2CData = j2cdata; + } - return iImage; - } + return iImage; + } - public void DownloadInventory() - { - resetFoldersByUUID(); + public void DownloadInventory() + { + resetFoldersByUUID(); - if( htFolderDownloadStatus == null ) - { - // Create status table - htFolderDownloadStatus = new Hashtable(); - } else { - if( htFolderDownloadStatus.Count != 0 ) - { - throw new Exception("Inventory Download requested while previous download in progress."); - } - } + if (htFolderDownloadStatus == null) + { + // Create status table + htFolderDownloadStatus = new Dictionary(); + } + else + { + if (htFolderDownloadStatus.Count != 0) + { + throw new Exception("Inventory Download requested while previous download in progress."); + } + } - if( alFolderRequestQueue == null ) - { - alFolderRequestQueue = new ArrayList(); - } + if (alFolderRequestQueue == null) + { + alFolderRequestQueue = new List(); + } - // Set last packet received to now, just so out time-out timer works + // Set last packet received to now, just so out time-out timer works LastPacketRecieved = Helpers.GetUnixTime(); - // Send Packet requesting the root Folder, - // this should recurse through all folders - RequestFolder( new DescendentRequest(uuidRootFolder) ); + // Send Packet requesting the root Folder, + // this should recurse through all folders + RequestFolder(new DescendentRequest(uuidRootFolder)); - while ( (htFolderDownloadStatus.Count > 0) || (alFolderRequestQueue.Count > 0) ) - { - if( htFolderDownloadStatus.Count == 0 ) - { - DescendentRequest dr = (DescendentRequest)alFolderRequestQueue[0]; - alFolderRequestQueue.RemoveAt(0); - RequestFolder( dr ); - } + while ((htFolderDownloadStatus.Count > 0) || (alFolderRequestQueue.Count > 0)) + { + if (htFolderDownloadStatus.Count == 0) + { + DescendentRequest dr = (DescendentRequest)alFolderRequestQueue[0]; + alFolderRequestQueue.RemoveAt(0); + RequestFolder(dr); + } if ((Helpers.GetUnixTime() - LastPacketRecieved) > 10) - { + { Console.WriteLine("Time-out while waiting for packets (" + (Helpers.GetUnixTime() - LastPacketRecieved) + " seconds since last packet)"); - Console.WriteLine("Current Status:"); + Console.WriteLine("Current Status:"); - // have to make a seperate list otherwise we run into modifying the original array - // while still enumerating it. - ArrayList alRestartList = new ArrayList(); + // have to make a seperate list otherwise we run into modifying the original array + // while still enumerating it. + List alRestartList = new List(); - if (htFolderDownloadStatus[0] != null) + //if (htFolderDownloadStatus[0] != null) + //{ + // Console.WriteLine(htFolderDownloadStatus[0].GetType()); + //} + + foreach (DescendentRequest dr in htFolderDownloadStatus.Values) { - Console.WriteLine(htFolderDownloadStatus[0].GetType()); + Console.WriteLine(dr.FolderID + " " + dr.Expected + " / " + dr.Received + " / " + dr.LastReceived); + + alRestartList.Add(dr); } - foreach( DescendentRequest dr in htFolderDownloadStatus.Values ) - { - Console.WriteLine( dr.FolderID + " " + dr.Expected + " / " + dr.Received + " / " + dr.LastReceived ); - - alRestartList.Add( dr ); - } - LastPacketRecieved = Helpers.GetUnixTime(); - foreach( DescendentRequest dr in alRestartList ) - { - RequestFolder( dr ); - } + foreach (DescendentRequest dr in alRestartList) + { + RequestFolder(dr); + } - } - slClient.Tick(); + } + slClient.Tick(); - } - } + } + } @@ -411,8 +415,8 @@ namespace libsecondlife.InventorySystem UpdateCreateInventoryItemPacket reply = (UpdateCreateInventoryItemPacket)packet; // User internal variable references, so we don't fire off any update code by using the public accessors - - iiCreationInProgress._ItemID = reply.InventoryData[0].ItemID; + + iiCreationInProgress._ItemID = reply.InventoryData[0].ItemID; iiCreationInProgress._GroupOwned = reply.InventoryData[0].GroupOwned; iiCreationInProgress._SaleType = reply.InventoryData[0].SaleType; @@ -447,30 +451,30 @@ namespace libsecondlife.InventorySystem } - public void InventoryDescendentsHandler(Packet packet, Simulator simulator) - { + public void InventoryDescendentsHandler(Packet packet, Simulator simulator) + { InventoryDescendentsPacket reply = (InventoryDescendentsPacket)packet; LastPacketRecieved = Helpers.GetUnixTime(); - InventoryItem invItem; - InventoryFolder invFolder; + InventoryItem invItem; + InventoryFolder invFolder; - LLUUID uuidFolderID = new LLUUID(); + LLUUID uuidFolderID = new LLUUID(); - int iDescendentsExpected = int.MaxValue; - int iDescendentsReceivedThisBlock = 0; + int iDescendentsExpected = int.MaxValue; + int iDescendentsReceivedThisBlock = 0; foreach (InventoryDescendentsPacket.ItemDataBlock itemBlock in reply.ItemData) { - // There is always an item block, even if there isn't any items - // the "filler" block will not have a name + // There is always an item block, even if there isn't any items + // the "filler" block will not have a name if (itemBlock.Name.Length != 0) { iDescendentsReceivedThisBlock++; invItem = new InventoryItem(this, itemBlock); - + InventoryFolder ifolder = (InventoryFolder)htFoldersByUUID[invItem.FolderID]; if (ifolder.alContents.Contains(invItem) == false) @@ -496,88 +500,88 @@ namespace libsecondlife.InventorySystem foreach (InventoryDescendentsPacket.FolderDataBlock folderBlock in reply.FolderData) { - String name = System.Text.Encoding.UTF8.GetString(folderBlock.Name).Trim().Replace("\0", ""); - LLUUID folderid = folderBlock.FolderID; - LLUUID parentid = folderBlock.ParentID; - sbyte type = folderBlock.Type; + String name = System.Text.Encoding.UTF8.GetString(folderBlock.Name).Trim().Replace("\0", ""); + LLUUID folderid = folderBlock.FolderID; + LLUUID parentid = folderBlock.ParentID; + sbyte type = folderBlock.Type; - // There is always an folder block, even if there isn't any folders - // the "filler" block will not have a name + // There is always an folder block, even if there isn't any folders + // the "filler" block will not have a name if (folderBlock.Name.Length != 0) { - invFolder = new InventoryFolder(this, name, folderid, parentid); + invFolder = new InventoryFolder(this, name, folderid, parentid); - iDescendentsReceivedThisBlock++; + iDescendentsReceivedThisBlock++; - // Add folder to Parent - InventoryFolder ifolder = (InventoryFolder)htFoldersByUUID[invFolder.ParentID]; - if( ifolder.alContents.Contains(invFolder) == false ) - { - ifolder.alContents.Add(invFolder); - } + // Add folder to Parent + InventoryFolder ifolder = (InventoryFolder)htFoldersByUUID[invFolder.ParentID]; + if (ifolder.alContents.Contains(invFolder) == false) + { + ifolder.alContents.Add(invFolder); + } - // Add folder to UUID Lookup - htFoldersByUUID[invFolder.FolderID] = invFolder; - + // Add folder to UUID Lookup + htFoldersByUUID[invFolder.FolderID] = invFolder; - // It's not the root, should be safe to "recurse" - if( !invFolder.FolderID.Equals( uuidRootFolder ) ) - { - bool alreadyQueued = false; - foreach( DescendentRequest dr in alFolderRequestQueue ) - { - if( dr.FolderID == invFolder.FolderID ) - { - alreadyQueued = true; - break; - } - } - - if( !alreadyQueued ) - { - alFolderRequestQueue.Add( new DescendentRequest( invFolder.FolderID ) ); - } - } - } - } + + // It's not the root, should be safe to "recurse" + if (!invFolder.FolderID.Equals(uuidRootFolder)) + { + bool alreadyQueued = false; + foreach (DescendentRequest dr in alFolderRequestQueue) + { + if (dr.FolderID == invFolder.FolderID) + { + alreadyQueued = true; + break; + } + } + + if (!alreadyQueued) + { + alFolderRequestQueue.Add(new DescendentRequest(invFolder.FolderID)); + } + } + } + } // Check how many descendents we're actually supposed to receive iDescendentsExpected = reply.AgentData.Descendents; uuidFolderID = reply.AgentData.FolderID; - // Update download status for this folder - if( iDescendentsReceivedThisBlock >= iDescendentsExpected ) - { - // We received all the descendents we're expecting for this folder - // in this packet, so go ahead and remove folder from status list. - htFolderDownloadStatus.Remove(uuidFolderID); - } - else - { + // Update download status for this folder + if (iDescendentsReceivedThisBlock >= iDescendentsExpected) + { + // We received all the descendents we're expecting for this folder + // in this packet, so go ahead and remove folder from status list. + htFolderDownloadStatus.Remove(uuidFolderID); + } + else + { - // This one packet didn't have all the descendents we're expecting - // so update the total we're expecting, and update the total downloaded + // This one packet didn't have all the descendents we're expecting + // so update the total we're expecting, and update the total downloaded - DescendentRequest dr = (DescendentRequest)htFolderDownloadStatus[uuidFolderID]; - dr.Expected = iDescendentsExpected; - dr.Received += iDescendentsReceivedThisBlock; + DescendentRequest dr = (DescendentRequest)htFolderDownloadStatus[uuidFolderID]; + dr.Expected = iDescendentsExpected; + dr.Received += iDescendentsReceivedThisBlock; dr.LastReceived = Helpers.GetUnixTime(); - if( dr.Received >= dr.Expected ) - { - // Looks like after updating, we have all the descendents, - // remove from folder status. - htFolderDownloadStatus.Remove(uuidFolderID); - } - else - { - htFolderDownloadStatus[uuidFolderID] = dr; -// Console.WriteLine( uuidFolderID + " is expecting " + (iDescendentsExpected - iStatus[1]) + " more packets." ); - } - } - } + if (dr.Received >= dr.Expected) + { + // Looks like after updating, we have all the descendents, + // remove from folder status. + htFolderDownloadStatus.Remove(uuidFolderID); + } + else + { + htFolderDownloadStatus[uuidFolderID] = dr; + // Console.WriteLine( uuidFolderID + " is expecting " + (iDescendentsExpected - iStatus[1]) + " more packets." ); + } + } + } private class DescendentRequest { diff --git a/libsecondlife-cs/InventorySystem/InventoryPacketHelper.cs b/libsecondlife-cs/InventorySystem/InventoryPacketHelper.cs index b344fd34..3a5e5af1 100644 --- a/libsecondlife-cs/InventorySystem/InventoryPacketHelper.cs +++ b/libsecondlife-cs/InventorySystem/InventoryPacketHelper.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; diff --git a/libsecondlife-cs/JSON/JSONArray.cs b/libsecondlife-cs/JSON/JSONArray.cs index 893d9df3..a6b54ce0 100644 --- a/libsecondlife-cs/JSON/JSONArray.cs +++ b/libsecondlife-cs/JSON/JSONArray.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using System.Text; namespace Nii.JSON @@ -59,7 +59,7 @@ namespace Nii.JSON public class JSONArray { /// The ArrayList where the JSONArray's properties are kept. - private ArrayList myArrayList; + private List myArrayList; /// @@ -67,7 +67,7 @@ namespace Nii.JSON /// public JSONArray() { - myArrayList = new ArrayList(); + myArrayList = new List(); } /// diff --git a/libsecondlife-cs/JSON/JSONFacade.cs b/libsecondlife-cs/JSON/JSONFacade.cs index eeb3f2de..916d8d98 100644 --- a/libsecondlife-cs/JSON/JSONFacade.cs +++ b/libsecondlife-cs/JSON/JSONFacade.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using System.Collections.Specialized; using System.Reflection; using System.Text; @@ -16,10 +16,10 @@ namespace Nii.JSON /// /// /// - public static IDictionary fromJSON(string sJSON) + public static Dictionary fromJSON(string sJSON) { JSONObject jsob = new JSONObject(sJSON); - IDictionary idict = jsob.getDictionary(); + Dictionary idict = jsob.getDictionary(); return idict; } } diff --git a/libsecondlife-cs/JSON/JSONObject.cs b/libsecondlife-cs/JSON/JSONObject.cs index 47597c80..21d76aa0 100644 --- a/libsecondlife-cs/JSON/JSONObject.cs +++ b/libsecondlife-cs/JSON/JSONObject.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using System.Globalization; @@ -134,10 +134,10 @@ namespace Nii.JSON } ///The hash map where the JSONObject's properties are kept. - private Hashtable myHashMap; + private Dictionary myHashMap; ///A shadow list of keys to enable access by sequence of insertion - private ArrayList myKeyIndexList; + private List myKeyIndexList; /// /// It is sometimes more convenient and less ambiguous to have a NULL @@ -152,8 +152,8 @@ namespace Nii.JSON /// public JSONObject() { - myHashMap = new Hashtable(); - myKeyIndexList = new ArrayList(); + myHashMap = new Dictionary(); + myKeyIndexList = new List(); } /// @@ -225,7 +225,7 @@ namespace Nii.JSON /// C# convenience method /// /// The Hashtable - public IDictionary getDictionary() + public Dictionary getDictionary() { return myHashMap; } diff --git a/libsecondlife-cs/NetworkManager.cs b/libsecondlife-cs/NetworkManager.cs index 65839711..e004b025 100644 --- a/libsecondlife-cs/NetworkManager.cs +++ b/libsecondlife-cs/NetworkManager.cs @@ -27,7 +27,7 @@ using System; using System.Text; using System.Timers; -using System.Collections; +using System.Collections.Generic; using System.Net; using System.Net.Sockets; using System.Threading; @@ -138,16 +138,16 @@ namespace libsecondlife private SecondLife Client; private NetworkManager Network; - private Hashtable Callbacks; + private Dictionary> Callbacks; private ushort Sequence; private byte[] RecvBuffer; private Mutex RecvBufferMutex = new Mutex(false, "RecvBufferMutex"); private Socket Connection; private AsyncCallback ReceivedData; - private Hashtable NeedAck; + private Dictionary NeedAck; private Mutex NeedAckMutex; - private SortedList Inbox; - private ArrayList PendingAcks; + private SortedList Inbox; + private List PendingAcks; private Mutex InboxMutex; private bool connected; private uint circuitCode; @@ -163,7 +163,7 @@ namespace libsecondlife /// /// /// - public Simulator(SecondLife client, Hashtable callbacks, uint circuit, + public Simulator(SecondLife client, Dictionary> callbacks, uint circuit, IPAddress ip, int port) { Client = client; @@ -180,11 +180,11 @@ namespace libsecondlife AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); // Initialize the hashtable for reliable packets waiting on ACKs from the server - NeedAck = new Hashtable(); + NeedAck = new Dictionary(); // Initialize the lists of sequence numbers we've received so far - Inbox = new SortedList(); - PendingAcks = new ArrayList(); + Inbox = new SortedList(); + PendingAcks = new List(); NeedAckMutex = new Mutex(false, "NeedAckMutex"); InboxMutex = new Mutex(false, "InboxMutex"); @@ -458,7 +458,7 @@ namespace libsecondlife { InboxMutex.WaitOne(); - if (Inbox.Contains(packet.Header.Sequence)) + if (Inbox.ContainsKey(packet.Header.Sequence)) { Client.Log("Received a duplicate " + packet.Type.ToString() + ", sequence=" + packet.Header.Sequence + ", resent=" + ((packet.Header.Resent) ? "Yes" : "No"), @@ -536,7 +536,7 @@ namespace libsecondlife { if (Callbacks.ContainsKey(packet.Type)) { - ArrayList callbackArray = (ArrayList)Callbacks[packet.Type]; + List callbackArray = Callbacks[packet.Type]; // Fire any registered callbacks foreach (PacketCallback callback in callbackArray) @@ -550,7 +550,7 @@ namespace libsecondlife if (Callbacks.ContainsKey(PacketType.Default)) { - ArrayList callbackArray = (ArrayList)Callbacks[PacketType.Default]; + List callbackArray = Callbacks[PacketType.Default]; // Fire any registered callbacks foreach (PacketCallback callback in callbackArray) @@ -643,7 +643,7 @@ namespace libsecondlife /// The complete hashtable of all the login values returned by the /// RPC login server, converted to native data types wherever possible /// - public Hashtable LoginValues; + public Dictionary LoginValues; /// /// Shows whether the network layer is logged in to the grid or not /// @@ -662,9 +662,9 @@ namespace libsecondlife /// public DisconnectCallback OnDisconnected; - private Hashtable Callbacks; + private Dictionary> Callbacks; private SecondLife Client; - private ArrayList Simulators; + private List Simulators; private Mutex SimulatorsMutex; private System.Timers.Timer DisconnectTimer; private bool connected; @@ -676,9 +676,9 @@ namespace libsecondlife public NetworkManager(SecondLife client) { Client = client; - Simulators = new ArrayList(); + Simulators = new List(); SimulatorsMutex = new Mutex(false, "SimulatorsMutex"); - Callbacks = new Hashtable(); + Callbacks = new Dictionary>(); CurrentSim = null; LoginValues = null; @@ -703,10 +703,10 @@ namespace libsecondlife { if (!Callbacks.ContainsKey(type)) { - Callbacks[type] = new ArrayList(); + Callbacks[type] = new List(); } - ArrayList callbackArray = (ArrayList)Callbacks[type]; + List callbackArray = Callbacks[type]; callbackArray.Add(callback); } @@ -724,7 +724,7 @@ namespace libsecondlife return; } - ArrayList callbackArray = (ArrayList)Callbacks[type]; + List callbackArray = Callbacks[type]; if (callbackArray.Contains(callback)) { @@ -787,15 +787,16 @@ namespace libsecondlife /// /// /// - public static Hashtable DefaultLoginValues(string firstName, string lastName, string password, - string userAgent, string author) + public static Dictionary DefaultLoginValues( + string firstName, string lastName, string password, string userAgent, string author) { return DefaultLoginValues(firstName, lastName, password, "00:00:00:00:00:00", "last", 1, 50, 50, 50, "Win", "0", userAgent, author); } - public static Hashtable DefaultLoginValues(string firstName, string lastName, string password, string mac, - string startLocation, string platform, string viewerDigest, string userAgent, string author) + public static Dictionary DefaultLoginValues(string firstName, + string lastName, string password, string mac, string startLocation, string platform, + string viewerDigest, string userAgent, string author) { return DefaultLoginValues(firstName, lastName, password, mac, startLocation, 1, 50, 50, 50, platform, viewerDigest, userAgent, author); @@ -818,11 +819,11 @@ namespace libsecondlife /// /// /// - public static Hashtable DefaultLoginValues(string firstName, string lastName, string password, string mac, - string startLocation, int major, int minor, int patch, int build, string platform, string viewerDigest, - string userAgent, string author) + public static Dictionary DefaultLoginValues(string firstName, + string lastName, string password, string mac, string startLocation, int major, int minor, + int patch, int build, string platform, string viewerDigest, string userAgent, string author) { - Hashtable values = new Hashtable(); + Dictionary values = new Dictionary(); // Generate an MD5 hash of the password MD5 md5 = new MD5CryptoServiceProvider(); @@ -850,7 +851,7 @@ namespace libsecondlife values["author"] = author; // Build the options array - ArrayList optionsArray = new ArrayList(); + List optionsArray = new List(); optionsArray.Add("inventory-root"); optionsArray.Add("inventory-skeleton"); optionsArray.Add("inventory-lib-root"); @@ -876,7 +877,7 @@ namespace libsecondlife /// /// /// - public bool Login(Hashtable loginParams) + public bool Login(Dictionary loginParams) { return Login(loginParams, "https://login.agni.lindenlab.com/cgi-bin/login.cgi"); } @@ -887,7 +888,7 @@ namespace libsecondlife /// /// /// - public bool Login(Hashtable loginParams, string url) + public bool Login(Dictionary loginParams, string url) { XmlRpcResponse result; XmlRpcRequest xmlrpc = new XmlRpcRequest(); @@ -914,7 +915,7 @@ namespace libsecondlife return false; } - LoginValues = (Hashtable)result.Value; + LoginValues = (Dictionary)result.Value; if ((string)LoginValues["login"] == "indeterminate") { @@ -936,7 +937,7 @@ namespace libsecondlife System.Text.RegularExpressions.Regex LLSDtoJSON = new System.Text.RegularExpressions.Regex(@"('|r([0-9])|r(\-))"); string json; - IDictionary jsonObject = null; + Dictionary jsonObject = null; LLVector3 vector = null; LLVector3 posVector = null; LLVector3 lookatVector = null; @@ -944,7 +945,7 @@ namespace libsecondlife try { - if (LoginValues.Contains("look_at")) + if (LoginValues.ContainsKey("look_at")) { // Replace LLSD variables with object representations @@ -962,9 +963,9 @@ namespace libsecondlife LoginValues["look_at"] = vector; } - if (LoginValues.Contains("home")) + if (LoginValues.ContainsKey("home")) { - Hashtable home; + Dictionary home; // Convert LLSD string to JSON json = LLSDtoJSON.Replace((string)LoginValues["home"], "$2"); @@ -990,7 +991,7 @@ namespace libsecondlife Client.Avatar.LookAt = lookatVector; // Create a hashtable to hold the home values - home = new Hashtable(); + home = new Dictionary(); home["position"] = posVector; home["look_at"] = lookatVector; home["region_handle"] = regionHandle; diff --git a/libsecondlife-cs/ObjectManager.cs b/libsecondlife-cs/ObjectManager.cs index f9f4e000..7a9352a9 100644 --- a/libsecondlife-cs/ObjectManager.cs +++ b/libsecondlife-cs/ObjectManager.cs @@ -25,7 +25,7 @@ */ using System; -using System.Collections; +using System.Collections.Generic; using libsecondlife.Packets; namespace libsecondlife diff --git a/libsecondlife-cs/Parcel.cs b/libsecondlife-cs/Parcel.cs index 521a27ca..0fc7b73d 100644 --- a/libsecondlife-cs/Parcel.cs +++ b/libsecondlife-cs/Parcel.cs @@ -26,7 +26,7 @@ using System; using System.Timers; -using System.Collections; +using System.Collections.Generic; using libsecondlife.Packets; namespace libsecondlife @@ -347,7 +347,7 @@ namespace libsecondlife public class ParcelManager { /// - public ArrayList ParcelsForSale; + public List ParcelsForSale; private SecondLife Client; private bool ReservedNewbie; @@ -366,7 +366,7 @@ namespace libsecondlife public ParcelManager(SecondLife client) { Client = client; - ParcelsForSale = new ArrayList(); + ParcelsForSale = new List(); // Setup the callbacks Client.Network.RegisterCallback(PacketType.DirLandReply, new PacketCallback(DirLandReplyHandler)); diff --git a/libsecondlife-cs/ProtocolManager.cs b/libsecondlife-cs/ProtocolManager.cs index 596eda8a..c04e8ddc 100644 --- a/libsecondlife-cs/ProtocolManager.cs +++ b/libsecondlife-cs/ProtocolManager.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using System.IO; namespace libsecondlife @@ -119,7 +119,7 @@ namespace libsecondlife /// public int Count; /// - public ArrayList Fields; + public List Fields; /// /// @@ -164,7 +164,7 @@ namespace libsecondlife /// public bool Encoded; /// - public ArrayList Blocks; + public List Blocks; } /// @@ -173,9 +173,9 @@ namespace libsecondlife public class ProtocolManager { /// - public Hashtable TypeSizes; + public Dictionary TypeSizes; /// - public Hashtable KeywordPositions; + public Dictionary KeywordPositions; /// public MapPacket[] LowMaps; /// @@ -202,7 +202,7 @@ namespace libsecondlife HighMaps = new MapPacket[256]; // Build the type size hash table - TypeSizes = new Hashtable(); + TypeSizes = new Dictionary(); TypeSizes.Add(FieldType.U8, 1); TypeSizes.Add(FieldType.U16, 2); TypeSizes.Add(FieldType.U32, 4); @@ -384,7 +384,7 @@ namespace libsecondlife string line; StreamReader file; - KeywordPositions = new Hashtable(); + KeywordPositions = new Dictionary(); // Load the keyword file try @@ -547,7 +547,7 @@ namespace libsecondlife LowMaps[fixedID].Name = tokens[0]; LowMaps[fixedID].Trusted = (tokens[3] == "Trusted"); LowMaps[fixedID].Encoded = (tokens[4] == "Zerocoded"); - LowMaps[fixedID].Blocks = new ArrayList(); + LowMaps[fixedID].Blocks = new List(); currentPacket = LowMaps[fixedID]; } @@ -559,7 +559,7 @@ namespace libsecondlife LowMaps[low].Name = tokens[0]; LowMaps[low].Trusted = (tokens[2] == "Trusted"); LowMaps[low].Encoded = (tokens[3] == "Zerocoded"); - LowMaps[low].Blocks = new ArrayList(); + LowMaps[low].Blocks = new List(); currentPacket = LowMaps[low]; @@ -573,7 +573,7 @@ namespace libsecondlife MediumMaps[medium].Name = tokens[0]; MediumMaps[medium].Trusted = (tokens[2] == "Trusted"); MediumMaps[medium].Encoded = (tokens[3] == "Zerocoded"); - MediumMaps[medium].Blocks = new ArrayList(); + MediumMaps[medium].Blocks = new List(); currentPacket = MediumMaps[medium]; @@ -587,7 +587,7 @@ namespace libsecondlife HighMaps[high].Name = tokens[0]; HighMaps[high].Trusted = (tokens[2] == "Trusted"); HighMaps[high].Encoded = (tokens[3] == "Zerocoded"); - HighMaps[high].Blocks = new ArrayList(); + HighMaps[high].Blocks = new List(); currentPacket = HighMaps[high]; @@ -649,7 +649,7 @@ namespace libsecondlife currentBlock.Name = tokens[0]; currentBlock.KeywordPosition = KeywordPosition(currentBlock.Name); - currentBlock.Fields = new ArrayList(); + currentBlock.Fields = new List(); currentPacket.Blocks.Add(currentBlock); if (tokens[1] == "Single") diff --git a/libsecondlife-cs/SecondLife.cs b/libsecondlife-cs/SecondLife.cs index ac9a2d96..04c413cb 100644 --- a/libsecondlife-cs/SecondLife.cs +++ b/libsecondlife-cs/SecondLife.cs @@ -25,7 +25,7 @@ */ using System; -using System.Collections; +using System.Collections.Generic; using System.Threading; using libsecondlife.Packets; @@ -55,7 +55,7 @@ namespace libsecondlife /// public MainAvatar Avatar; /// - public Hashtable Avatars; + public Dictionary Avatars; /// public Mutex AvatarsMutex; /// @@ -77,7 +77,7 @@ namespace libsecondlife Network = new NetworkManager(this); Parcels = new ParcelManager(this); Avatar = new MainAvatar(this); - Avatars = new Hashtable(); + Avatars = new Dictionary(); AvatarsMutex = new Mutex(false, "AvatarsMutex"); Grid = new GridManager(this); Objects = new ObjectManager(this); diff --git a/libsecondlife-cs/XmlRpcCS/XmlRpcDeserializer.cs b/libsecondlife-cs/XmlRpcCS/XmlRpcDeserializer.cs index cb9b7b1c..c84ae482 100644 --- a/libsecondlife-cs/XmlRpcCS/XmlRpcDeserializer.cs +++ b/libsecondlife-cs/XmlRpcCS/XmlRpcDeserializer.cs @@ -1,180 +1,180 @@ namespace Nwc.XmlRpc { - using System; - using System.Collections; - using System.IO; - using System.Xml; - using System.Globalization; + using System; + using System.Collections.Generic; + using System.IO; + using System.Xml; + using System.Globalization; - /// Parser context, we maintain contexts in a stack to avoiding recursion. - struct Context - { - public String Name; - public Object Container; - } + /// Parser context, we maintain contexts in a stack to avoiding recursion. + struct Context + { + public String Name; + public Object Container; + } - /// Basic XML-RPC data deserializer. - /// Uses XmlTextReader to parse the XML data. This level of the class - /// only handles the tokens common to both Requests and Responses. This class is not useful in and of itself - /// but is designed to be subclassed. - public class XmlRpcDeserializer : XmlRpcXmlTokens - { - private static DateTimeFormatInfo _dateFormat = new DateTimeFormatInfo(); + /// Basic XML-RPC data deserializer. + /// Uses XmlTextReader to parse the XML data. This level of the class + /// only handles the tokens common to both Requests and Responses. This class is not useful in and of itself + /// but is designed to be subclassed. + public class XmlRpcDeserializer : XmlRpcXmlTokens + { + private static DateTimeFormatInfo _dateFormat = new DateTimeFormatInfo(); - private Object _container; - private Stack _containerStack; + private Object _container; + private Stack _containerStack; - /// Protected reference to last text. - protected String _text; - /// Protected reference to last deserialized value. - protected Object _value; - /// Protected reference to last name field. - protected String _name; + /// Protected reference to last text. + protected String _text; + /// Protected reference to last deserialized value. + protected Object _value; + /// Protected reference to last name field. + protected String _name; - /// Basic constructor. - public XmlRpcDeserializer() - { - Reset(); - _dateFormat.FullDateTimePattern = ISO_DATETIME; - } + /// Basic constructor. + public XmlRpcDeserializer() + { + Reset(); + _dateFormat.FullDateTimePattern = ISO_DATETIME; + } - /// Static method that parses XML data into a response using the Singleton. - /// StreamReader containing an XML-RPC response. - /// Object object resulting from the deserialization. - virtual public Object Deserialize(TextReader xmlData) - { - return null; - } + /// Static method that parses XML data into a response using the Singleton. + /// StreamReader containing an XML-RPC response. + /// Object object resulting from the deserialization. + virtual public Object Deserialize(TextReader xmlData) + { + return null; + } - /// Protected method to parse a node in an XML-RPC XML stream. - /// Method deals with elements common to all XML-RPC data, subclasses of - /// this object deal with request/response spefic elements. - /// XmlTextReader of the in progress parsing data stream. - protected void DeserializeNode(XmlTextReader reader) - { - switch (reader.NodeType) - { - case XmlNodeType.Element: - if (Logger.Delegate != null) - Logger.WriteEntry("START " + reader.Name, LogLevel.Information); - switch (reader.Name) - { - case VALUE: - _value = null; - _text = null; - break; - case STRUCT: - PushContext(); - _container = new Hashtable(); - break; - case ARRAY: - PushContext(); - _container = new ArrayList(); - break; - } - break; - case XmlNodeType.EndElement: - if (Logger.Delegate != null) - Logger.WriteEntry("END " + reader.Name, LogLevel.Information); - switch (reader.Name) - { - case BASE64: - _value = Convert.FromBase64String(_text); - break; - case BOOLEAN: - int val = Int16.Parse(_text); - if (val == 0) - _value = false; - else if (val == 1) - _value = true; - break; - case STRING: - _value = _text; - break; - case DOUBLE: - _value = Double.Parse(_text); - break; - case INT: - case ALT_INT: - _value = Int32.Parse(_text); - break; - case DATETIME: + /// Protected method to parse a node in an XML-RPC XML stream. + /// Method deals with elements common to all XML-RPC data, subclasses of + /// this object deal with request/response spefic elements. + /// XmlTextReader of the in progress parsing data stream. + protected void DeserializeNode(XmlTextReader reader) + { + switch (reader.NodeType) + { + case XmlNodeType.Element: + if (Logger.Delegate != null) + Logger.WriteEntry("START " + reader.Name, LogLevel.Information); + switch (reader.Name) + { + case VALUE: + _value = null; + _text = null; + break; + case STRUCT: + PushContext(); + _container = new Dictionary(); + break; + case ARRAY: + PushContext(); + _container = new List(); + break; + } + break; + case XmlNodeType.EndElement: + if (Logger.Delegate != null) + Logger.WriteEntry("END " + reader.Name, LogLevel.Information); + switch (reader.Name) + { + case BASE64: + _value = Convert.FromBase64String(_text); + break; + case BOOLEAN: + int val = Int16.Parse(_text); + if (val == 0) + _value = false; + else if (val == 1) + _value = true; + break; + case STRING: + _value = _text; + break; + case DOUBLE: + _value = Double.Parse(_text); + break; + case INT: + case ALT_INT: + _value = Int32.Parse(_text); + break; + case DATETIME: #if __MONO__ _value = DateParse(_text); #else - _value = DateTime.ParseExact(_text, "F", _dateFormat); + _value = DateTime.ParseExact(_text, "F", _dateFormat); #endif - break; - case NAME: - _name = _text; - break; - case VALUE: - if (_value == null) - _value = _text; // some kits don't use tag, they just do + break; + case NAME: + _name = _text; + break; + case VALUE: + if (_value == null) + _value = _text; // some kits don't use tag, they just do - if ((_container != null) && (_container is IList)) // in an array? If so add value to it. - ((IList)_container).Add(_value); - break; - case MEMBER: - if ((_container != null) && (_container is IDictionary)) // in an struct? If so add value to it. - ((IDictionary)_container).Add(_name, _value); - break; - case ARRAY: - case STRUCT: - _value = _container; - PopContext(); - break; - } - break; - case XmlNodeType.Text: - if (Logger.Delegate != null) - Logger.WriteEntry("Text " + reader.Value, LogLevel.Information); - _text = reader.Value; - break; - default: - break; - } - } + if ((_container != null) && (_container is List)) // in an array? If so add value to it. + ((List)_container).Add(_value); + break; + case MEMBER: + if ((_container != null) && (_container is Dictionary)) // in an struct? If so add value to it. + ((Dictionary)_container).Add(_name, _value); + break; + case ARRAY: + case STRUCT: + _value = _container; + PopContext(); + break; + } + break; + case XmlNodeType.Text: + if (Logger.Delegate != null) + Logger.WriteEntry("Text " + reader.Value, LogLevel.Information); + _text = reader.Value; + break; + default: + break; + } + } - /// Static method that parses XML in a String into a - /// request using the Singleton. - /// String containing an XML-RPC request. - /// XmlRpcRequest object resulting from the parse. - public Object Deserialize(String xmlData) - { - StringReader sr = new StringReader(xmlData); - return Deserialize(sr); - } + /// Static method that parses XML in a String into a + /// request using the Singleton. + /// String containing an XML-RPC request. + /// XmlRpcRequest object resulting from the parse. + public Object Deserialize(String xmlData) + { + StringReader sr = new StringReader(xmlData); + return Deserialize(sr); + } - /// Pop a Context of the stack, an Array or Struct has closed. - private void PopContext() - { - Context c = (Context)_containerStack.Pop(); - _container = c.Container; - _name = c.Name; - } + /// Pop a Context of the stack, an Array or Struct has closed. + private void PopContext() + { + Context c = (Context)_containerStack.Pop(); + _container = c.Container; + _name = c.Name; + } - /// Push a Context on the stack, an Array or Struct has opened. - private void PushContext() - { - Context context; + /// Push a Context on the stack, an Array or Struct has opened. + private void PushContext() + { + Context context; - context.Container = _container; - context.Name = _name; + context.Container = _container; + context.Name = _name; - _containerStack.Push(context); - } + _containerStack.Push(context); + } - /// Reset the internal state of the deserializer. - protected void Reset() - { - _text = null; - _value = null; - _name = null; - _container = null; - _containerStack = new Stack(); - } - } + /// Reset the internal state of the deserializer. + protected void Reset() + { + _text = null; + _value = null; + _name = null; + _container = null; + _containerStack = new Stack(); + } + } } diff --git a/libsecondlife-cs/XmlRpcCS/XmlRpcRequest.cs b/libsecondlife-cs/XmlRpcCS/XmlRpcRequest.cs index 2ae5c67c..e0a5c33e 100644 --- a/libsecondlife-cs/XmlRpcCS/XmlRpcRequest.cs +++ b/libsecondlife-cs/XmlRpcCS/XmlRpcRequest.cs @@ -1,96 +1,92 @@ namespace Nwc.XmlRpc { - using System; - using System.Collections; - using System.IO; - using System.Xml; - using System.Net; - using System.Text; - using System.Reflection; + using System; + using System.Collections.Generic; + using System.IO; + using System.Xml; + using System.Net; + using System.Text; + using System.Reflection; - internal class AcceptAllCertificatePolicy : ICertificatePolicy - { - public AcceptAllCertificatePolicy() + /// Class supporting the request side of an XML-RPC transaction. + public class XmlRpcRequest { + private String _methodName = null; + private Encoding _encoding = new ASCIIEncoding(); + private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer(); + private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer(); + + /// ArrayList containing the parameters. + protected List _params = null; + + /// Instantiate an XmlRpcRequest + public XmlRpcRequest() + { + _params = new List(); + } + + /// ArrayList containing the parameters for the request. + public virtual List Params + { + get { return _params; } + } + + /// String conntaining the method name, both object and method, that the request will be sent to. + public virtual String MethodName + { + get { return _methodName; } + set { _methodName = value; } + } + + /// Send the request to the server. + /// String The url of the XML-RPC server. + /// XmlRpcResponse The response generated. + public XmlRpcResponse Send(String url) + { + // Override SSL authentication mechanisms + //ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy(); + ServicePointManager.ServerCertificateValidationCallback += + new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult); + + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); + if (request == null) + throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR, + XmlRpcErrorCodes.TRANSPORT_ERROR_MSG + ": Could not create request with " + url); + request.Method = "POST"; + request.ContentType = "text/xml"; + request.AllowWriteStreamBuffering = true; + request.KeepAlive = false; + request.Timeout = 15000; // miliseconds adjust as you see fit + + Stream stream = request.GetRequestStream(); + XmlTextWriter xml = new XmlTextWriter(stream, _encoding); + _serializer.Serialize(xml, this); + xml.Flush(); + xml.Close(); + + HttpWebResponse response = (HttpWebResponse)request.GetResponse(); + StreamReader input = new StreamReader(response.GetResponseStream()); + + XmlRpcResponse resp = (XmlRpcResponse)_deserializer.Deserialize(input); + input.Close(); + response.Close(); + return resp; + } + + private bool CheckValidationResult(Object sender, + System.Security.Cryptography.X509Certificates.X509Certificate certificate, + System.Security.Cryptography.X509Certificates.X509Chain chain, + System.Net.Security.SslPolicyErrors sslPolicyErrors) + { + // Always accept + return true; + } + + /// Produce String representation of the object. + /// String representation of the object. + override public String ToString() + { + return _serializer.Serialize(this); + } } - - public bool CheckValidationResult(ServicePoint sPoint, - System.Security.Cryptography.X509Certificates.X509Certificate cert, - WebRequest wRequest,int certProb) - { - // Always accept - return true; - } - } - - /// Class supporting the request side of an XML-RPC transaction. - public class XmlRpcRequest - { - private String _methodName = null; - private Encoding _encoding = new ASCIIEncoding(); - private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer(); - private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer(); - - /// ArrayList containing the parameters. - protected IList _params = null; - - /// Instantiate an XmlRpcRequest - public XmlRpcRequest() - { - _params = new ArrayList(); - } - - /// ArrayList conntaining the parameters for the request. - public virtual IList Params - { - get { return _params; } - } - - /// String conntaining the method name, both object and method, that the request will be sent to. - public virtual String MethodName - { - get { return _methodName; } - set { _methodName = value; } - } - - /// Send the request to the server. - /// String The url of the XML-RPC server. - /// XmlRpcResponse The response generated. - public XmlRpcResponse Send(String url) - { - // Override SSL authentication mechanisms - ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy(); - - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); - if (request == null) - throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR, - XmlRpcErrorCodes.TRANSPORT_ERROR_MSG +": Could not create request with " + url); - request.Method = "POST"; - request.ContentType = "text/xml"; - request.AllowWriteStreamBuffering = true; - request.KeepAlive = false; - request.Timeout = 15000; // miliseconds adjust as you see fit - - Stream stream = request.GetRequestStream(); - XmlTextWriter xml = new XmlTextWriter(stream, _encoding); - _serializer.Serialize(xml, this); - xml.Flush(); - xml.Close(); - - HttpWebResponse response = (HttpWebResponse)request.GetResponse(); - StreamReader input = new StreamReader(response.GetResponseStream()); - - XmlRpcResponse resp = (XmlRpcResponse)_deserializer.Deserialize(input); - input.Close(); - response.Close(); - return resp; - } - - /// Produce String representation of the object. - /// String representation of the object. - override public String ToString() - { - return _serializer.Serialize(this); - } - } } diff --git a/libsecondlife-cs/XmlRpcCS/XmlRpcRequestDeserializer.cs b/libsecondlife-cs/XmlRpcCS/XmlRpcRequestDeserializer.cs index 75e3e179..97a6046a 100644 --- a/libsecondlife-cs/XmlRpcCS/XmlRpcRequestDeserializer.cs +++ b/libsecondlife-cs/XmlRpcCS/XmlRpcRequestDeserializer.cs @@ -1,7 +1,7 @@ namespace Nwc.XmlRpc { using System; - using System.Collections; + using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Xml; diff --git a/libsecondlife-cs/XmlRpcCS/XmlRpcRequestSerializer.cs b/libsecondlife-cs/XmlRpcCS/XmlRpcRequestSerializer.cs index ab4834d7..c66401d5 100644 --- a/libsecondlife-cs/XmlRpcCS/XmlRpcRequestSerializer.cs +++ b/libsecondlife-cs/XmlRpcCS/XmlRpcRequestSerializer.cs @@ -1,7 +1,7 @@ namespace Nwc.XmlRpc { using System; - using System.Collections; + using System.Collections.Generic; using System.Xml; using System.IO; diff --git a/libsecondlife-cs/XmlRpcCS/XmlRpcResponse.cs b/libsecondlife-cs/XmlRpcCS/XmlRpcResponse.cs index eaa40875..536ac150 100644 --- a/libsecondlife-cs/XmlRpcCS/XmlRpcResponse.cs +++ b/libsecondlife-cs/XmlRpcCS/XmlRpcResponse.cs @@ -1,73 +1,76 @@ namespace Nwc.XmlRpc { - using System; - using System.Collections; - using System.IO; - using System.Xml; + using System; + using System.Collections.Generic; + using System.IO; + using System.Xml; - /// Class designed to represent an XML-RPC response. - public class XmlRpcResponse - { - private Object _value; - /// bool indicating if this response represents a fault. - public bool IsFault; + /// Class designed to represent an XML-RPC response. + public class XmlRpcResponse + { + private Object _value; + /// bool indicating if this response represents a fault. + public bool IsFault; - /// Basic constructor - public XmlRpcResponse() - { - Value = null; - IsFault = false; - } + /// Basic constructor + public XmlRpcResponse() + { + Value = null; + IsFault = false; + } - /// The data value of the response, may be fault data. - public Object Value - { - get { return _value; } - set { - IsFault = false; - _value = value; - } - } + /// The data value of the response, may be fault data. + public Object Value + { + get { return _value; } + set + { + IsFault = false; + _value = value; + } + } - /// The faultCode if this is a fault. - public int FaultCode - { - get { - if (!IsFault) - return 0; - else - return (int)((Hashtable)_value)[XmlRpcXmlTokens.FAULT_CODE]; - } - } + /// The faultCode if this is a fault. + public int FaultCode + { + get + { + if (!IsFault) + return 0; + else + return (int)((Dictionary)_value)[XmlRpcXmlTokens.FAULT_CODE]; + } + } - /// The faultString if this is a fault. - public String FaultString - { - get { - if (!IsFault) - return ""; - else - return (String)((Hashtable)_value)[XmlRpcXmlTokens.FAULT_STRING]; - } - } + /// The faultString if this is a fault. + public String FaultString + { + get + { + if (!IsFault) + return ""; + else + return (String)((Dictionary)_value)[XmlRpcXmlTokens.FAULT_STRING]; + } + } - /// Set this response to be a fault. - /// int the numeric faultCode value. - /// String the faultString value. - public void SetFault(int code, String message) - { - Hashtable fault = new Hashtable(); - fault.Add("faultCode", code); - fault.Add("faultString", message); - Value = fault; - IsFault = true; - } + /// Set this response to be a fault. + /// int the numeric faultCode value. + /// String the faultString value. + public void SetFault(int code, String message) + { + Dictionary fault = new Dictionary(); + fault.Add("faultCode", code); + fault.Add("faultString", message); + Value = fault; + IsFault = true; + } - /// Form a useful string representation of the object, in this case the XML response. - /// String The XML serialized XML-RPC response. - override public String ToString() - { - return XmlRpcResponseSerializer.Singleton.Serialize(this); - } - } + /// Form a useful string representation of the object, in this case the XML response. + /// String The XML serialized XML-RPC response. + override public String ToString() + { + return XmlRpcResponseSerializer.Singleton.Serialize(this); + } + } } diff --git a/libsecondlife-cs/XmlRpcCS/XmlRpcResponseDeserializer.cs b/libsecondlife-cs/XmlRpcCS/XmlRpcResponseDeserializer.cs index 980d1bb6..df48c15e 100644 --- a/libsecondlife-cs/XmlRpcCS/XmlRpcResponseDeserializer.cs +++ b/libsecondlife-cs/XmlRpcCS/XmlRpcResponseDeserializer.cs @@ -1,7 +1,7 @@ namespace Nwc.XmlRpc { using System; - using System.Collections; + using System.Collections.Generic; using System.IO; using System.Xml; diff --git a/libsecondlife-cs/XmlRpcCS/XmlRpcResponseSerializer.cs b/libsecondlife-cs/XmlRpcCS/XmlRpcResponseSerializer.cs index 65dc60f8..5a7010c0 100644 --- a/libsecondlife-cs/XmlRpcCS/XmlRpcResponseSerializer.cs +++ b/libsecondlife-cs/XmlRpcCS/XmlRpcResponseSerializer.cs @@ -1,7 +1,7 @@ namespace Nwc.XmlRpc { using System; - using System.Collections; + using System.Collections.Generic; using System.Xml; /// Class responsible for serializing an XML-RPC response. diff --git a/libsecondlife-cs/XmlRpcCS/XmlRpcSerializer.cs b/libsecondlife-cs/XmlRpcCS/XmlRpcSerializer.cs index 58c98177..98ee67d4 100644 --- a/libsecondlife-cs/XmlRpcCS/XmlRpcSerializer.cs +++ b/libsecondlife-cs/XmlRpcCS/XmlRpcSerializer.cs @@ -1,109 +1,109 @@ namespace Nwc.XmlRpc { - using System; - using System.Collections; - using System.IO; - using System.Xml; + using System; + using System.Collections.Generic; + using System.IO; + using System.Xml; - /// Base class of classes serializing data to XML-RPC's XML format. - /// This class handles the basic type conversions like Integer to <i4>. - /// - public class XmlRpcSerializer : XmlRpcXmlTokens - { + /// Base class of classes serializing data to XML-RPC's XML format. + /// This class handles the basic type conversions like Integer to <i4>. + /// + public class XmlRpcSerializer : XmlRpcXmlTokens + { - /// Serialize the XmlRpcRequest to the output stream. - /// An XmlTextWriter stream to write data to. - /// An Object to serialize. - /// - virtual public void Serialize(XmlTextWriter output, Object obj) - { - } + /// Serialize the XmlRpcRequest to the output stream. + /// An XmlTextWriter stream to write data to. + /// An Object to serialize. + /// + virtual public void Serialize(XmlTextWriter output, Object obj) + { + } - /// Serialize the XmlRpcRequest to a String. - /// Note this may represent a real memory hog for a large request. - /// An Object to serialize. - /// String containing XML-RPC representation of the request. - /// - public String Serialize(Object obj) - { - StringWriter strBuf = new StringWriter(); - XmlTextWriter xml = new XmlTextWriter(strBuf); - xml.Formatting = Formatting.Indented; - xml.Indentation = 4; - Serialize(xml, obj); - xml.Flush(); - String returns = strBuf.ToString(); - xml.Close(); - return returns; - } + /// Serialize the XmlRpcRequest to a String. + /// Note this may represent a real memory hog for a large request. + /// An Object to serialize. + /// String containing XML-RPC representation of the request. + /// + public String Serialize(Object obj) + { + StringWriter strBuf = new StringWriter(); + XmlTextWriter xml = new XmlTextWriter(strBuf); + xml.Formatting = Formatting.Indented; + xml.Indentation = 4; + Serialize(xml, obj); + xml.Flush(); + String returns = strBuf.ToString(); + xml.Close(); + return returns; + } - /// Serialize the object to the output stream. - /// An XmlTextWriter stream to write data to. - /// An Object to serialize. - public void SerializeObject(XmlTextWriter output, Object obj) - { - if (obj == null) - return; + /// Serialize the object to the output stream. + /// An XmlTextWriter stream to write data to. + /// An Object to serialize. + public void SerializeObject(XmlTextWriter output, Object obj) + { + if (obj == null) + return; - if (obj is byte[]) - { - byte[] ba = (byte[])obj; - output.WriteStartElement(BASE64); - output.WriteBase64(ba,0,ba.Length); - output.WriteEndElement(); - } - else if (obj is String) - { - output.WriteElementString(STRING,obj.ToString()); - } - else if (obj is Int32) - { - output.WriteElementString(INT,obj.ToString()); - } - else if (obj is DateTime) - { - output.WriteElementString(DATETIME,((DateTime)obj).ToString(ISO_DATETIME)); - } - else if (obj is Double) - { - output.WriteElementString(DOUBLE,obj.ToString()); - } - else if (obj is Boolean) - { - output.WriteElementString(BOOLEAN, ((((Boolean)obj) == true)?"1":"0")); - } - else if (obj is IList) - { - output.WriteStartElement(ARRAY); - output.WriteStartElement(DATA); - if (((ArrayList)obj).Count > 0) - { - foreach (Object member in ((IList)obj)) - { - output.WriteStartElement(VALUE); - SerializeObject(output,member); - output.WriteEndElement(); - } - } - output.WriteEndElement(); - output.WriteEndElement(); - } - else if (obj is IDictionary) - { - IDictionary h = (IDictionary)obj; - output.WriteStartElement(STRUCT); - foreach (String key in h.Keys) - { - output.WriteStartElement(MEMBER); - output.WriteElementString(NAME,key); - output.WriteStartElement(VALUE); - SerializeObject(output,h[key]); - output.WriteEndElement(); - output.WriteEndElement(); - } - output.WriteEndElement(); - } + if (obj is byte[]) + { + byte[] ba = (byte[])obj; + output.WriteStartElement(BASE64); + output.WriteBase64(ba, 0, ba.Length); + output.WriteEndElement(); + } + else if (obj is String) + { + output.WriteElementString(STRING, obj.ToString()); + } + else if (obj is Int32) + { + output.WriteElementString(INT, obj.ToString()); + } + else if (obj is DateTime) + { + output.WriteElementString(DATETIME, ((DateTime)obj).ToString(ISO_DATETIME)); + } + else if (obj is Double) + { + output.WriteElementString(DOUBLE, obj.ToString()); + } + else if (obj is Boolean) + { + output.WriteElementString(BOOLEAN, ((((Boolean)obj) == true) ? "1" : "0")); + } + else if (obj is List) + { + output.WriteStartElement(ARRAY); + output.WriteStartElement(DATA); + if (((List)obj).Count > 0) + { + foreach (Object member in ((List)obj)) + { + output.WriteStartElement(VALUE); + SerializeObject(output, member); + output.WriteEndElement(); + } + } + output.WriteEndElement(); + output.WriteEndElement(); + } + else if (obj is Dictionary) + { + Dictionary h = (Dictionary)obj; + output.WriteStartElement(STRUCT); + foreach (String key in h.Keys) + { + output.WriteStartElement(MEMBER); + output.WriteElementString(NAME, key); + output.WriteStartElement(VALUE); + SerializeObject(output, h[key]); + output.WriteEndElement(); + output.WriteEndElement(); + } + output.WriteEndElement(); + } - } - } + } + } } diff --git a/libsecondlife-cs/examples/IA_ImageTool/ImageTool.cs b/libsecondlife-cs/examples/IA_ImageTool/ImageTool.cs index 6daf99f9..c2b5b8ae 100644 --- a/libsecondlife-cs/examples/IA_ImageTool/ImageTool.cs +++ b/libsecondlife-cs/examples/IA_ImageTool/ImageTool.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using System.IO; using IA_SimpleInventory; diff --git a/libsecondlife-cs/examples/IA_SimpleInventory/IA_SimpleInventory.cs b/libsecondlife-cs/examples/IA_SimpleInventory/IA_SimpleInventory.cs index 04b58af8..8830ac0c 100644 --- a/libsecondlife-cs/examples/IA_SimpleInventory/IA_SimpleInventory.cs +++ b/libsecondlife-cs/examples/IA_SimpleInventory/IA_SimpleInventory.cs @@ -25,24 +25,24 @@ */ using System; -using System.Collections; +using System.Collections.Generic; using libsecondlife; using libsecondlife.InventorySystem; namespace IA_SimpleInventory { - /// - /// A simple base application for building console applications that access SL Inventory - /// - public class SimpleInventory - { - protected SecondLife client; - protected InventoryManager AgentInventory; + /// + /// A simple base application for building console applications that access SL Inventory + /// + public class SimpleInventory + { + protected SecondLife client; + protected InventoryManager AgentInventory; - protected bool DownloadInventoryOnConnect = true; + protected bool DownloadInventoryOnConnect = true; - public static void Main( string[] args ) + public static void Main(string[] args) { if (args.Length < 3) @@ -58,7 +58,7 @@ namespace IA_SimpleInventory } protected SimpleInventory() - { + { try { client = new SecondLife(); @@ -68,55 +68,55 @@ namespace IA_SimpleInventory // Error initializing the client Console.WriteLine(); Console.WriteLine(e.ToString()); - } - } + } + } protected void Connect(string FirstName, string LastName, string Password) - { + { Console.WriteLine("Attempting to connect and login to SecondLife."); - // Setup Login to Second Life - Hashtable loginParams = NetworkManager.DefaultLoginValues(FirstName, LastName, Password, "00:00:00:00:00:00", - "last", "Win", "0", "createnotecard", "static.sprocket@gmail.com"); - Hashtable loginReply = new Hashtable(); + // Setup Login to Second Life + Dictionary loginParams = NetworkManager.DefaultLoginValues(FirstName, LastName, + Password, "00:00:00:00:00:00", "last", "Win", "0", "createnotecard", "static.sprocket@gmail.com"); + Dictionary loginReply = new Dictionary(); - // Login - if (!client.Network.Login(loginParams)) - { - // Login failed - Console.WriteLine("Error logging in: " + client.Network.LoginError); - return; - } + // Login + if (!client.Network.Login(loginParams)) + { + // Login failed + Console.WriteLine("Error logging in: " + client.Network.LoginError); + return; + } - // Login was successful + // Login was successful Console.WriteLine("Login was successful."); Console.WriteLine("AgentID: " + client.Network.AgentID); Console.WriteLine("SessionID: " + client.Network.SessionID); // Get Root Inventory Folder UUID Console.WriteLine("Pulling root folder UUID from login data."); - ArrayList alInventoryRoot = (ArrayList)client.Network.LoginValues["inventory-root"]; - Hashtable htInventoryRoot = (Hashtable)alInventoryRoot[0]; - LLUUID agentRootFolderID = new LLUUID( (string)htInventoryRoot["folder_id"] ); + List alInventoryRoot = (List)client.Network.LoginValues["inventory-root"]; + Dictionary htInventoryRoot = (Dictionary)alInventoryRoot[0]; + LLUUID agentRootFolderID = new LLUUID((string)htInventoryRoot["folder_id"]); - // Initialize Inventory Manager object + // Initialize Inventory Manager object Console.WriteLine("Initializing Inventory Manager."); AgentInventory = new InventoryManager(client, agentRootFolderID); - if( DownloadInventoryOnConnect ) - { - // and request an inventory download + if (DownloadInventoryOnConnect) + { + // and request an inventory download Console.WriteLine("Downloading Inventory."); AgentInventory.DownloadInventory(); - } - } + } + } - protected void Disconnect() - { - // Logout of Second Life - Console.WriteLine("Request logout"); - client.Network.Logout(); - } + protected void Disconnect() + { + // Logout of Second Life + Console.WriteLine("Request logout"); + client.Network.Logout(); + } protected void doStuff() { @@ -125,5 +125,5 @@ namespace IA_SimpleInventory Console.WriteLine(AgentInventory.getRootFolder().toXML(false)); } - } + } } diff --git a/libsecondlife-cs/examples/ParcelDownload/ParcelDownload.cs b/libsecondlife-cs/examples/ParcelDownload/ParcelDownload.cs index 1d80894b..b09cf21f 100644 --- a/libsecondlife-cs/examples/ParcelDownload/ParcelDownload.cs +++ b/libsecondlife-cs/examples/ParcelDownload/ParcelDownload.cs @@ -25,7 +25,7 @@ */ using System; -using System.Collections; +using System.Collections.Generic; using libsecondlife; namespace ParcelDownloader @@ -52,8 +52,8 @@ namespace ParcelDownloader client = new SecondLife(); - Hashtable loginParams = NetworkManager.DefaultLoginValues(args[0], args[1], args[2], "00:00:00:00:00:00", - "last", "Win", "0", "ParcelDownload", "Adam \"Zaius\" Frisby "); + Dictionary loginParams = NetworkManager.DefaultLoginValues(args[0], args[1], args[2], + "00:00:00:00:00:00", "last", "Win", "0", "ParcelDownload", "Adam \"Zaius\" Frisby "); if (!client.Network.Login(loginParams)) { diff --git a/libsecondlife-cs/examples/Teleport/Teleport.cs b/libsecondlife-cs/examples/Teleport/Teleport.cs index 6469c954..01189c51 100644 --- a/libsecondlife-cs/examples/Teleport/Teleport.cs +++ b/libsecondlife-cs/examples/Teleport/Teleport.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using libsecondlife; @@ -77,9 +77,10 @@ namespace Teleport Console.WriteLine("Attempting to connect and login to SecondLife."); // Setup Login to Second Life - Hashtable loginParams = NetworkManager.DefaultLoginValues(FirstName, LastName, Password, "00:00:00:00:00:00", - "last", "Win", "0", "createnotecard", "static.sprocket@gmail.com"); - Hashtable loginReply = new Hashtable(); + Dictionary loginParams = NetworkManager.DefaultLoginValues(FirstName, + LastName, Password, "00:00:00:00:00:00", "last", "Win", "0", "createnotecard", + "static.sprocket@gmail.com"); + Dictionary loginReply = new Dictionary(); // Login if (!client.Network.Login(loginParams)) diff --git a/libsecondlife-cs/examples/botmanager/botmanager.cs b/libsecondlife-cs/examples/botmanager/botmanager.cs index 084dc56f..3a899a97 100644 --- a/libsecondlife-cs/examples/botmanager/botmanager.cs +++ b/libsecondlife-cs/examples/botmanager/botmanager.cs @@ -25,7 +25,6 @@ */ using System; -using System.Collections; using System.Collections.Generic; using System.Threading; using libsecondlife; @@ -67,8 +66,8 @@ namespace botmanager { Kill(); } - - Hashtable loginParams = NetworkManager.DefaultLoginValues(FirstName, LastName, + + Dictionary loginParams = NetworkManager.DefaultLoginValues(FirstName, LastName, Password, "00:00:00:00:00:00", "last", "Win", "0", "botmanager", "contact@libsecondlife.org"); diff --git a/libsecondlife-cs/examples/groupmanager/frmGroupInfo.cs b/libsecondlife-cs/examples/groupmanager/frmGroupInfo.cs index fee84042..a3a4929a 100644 --- a/libsecondlife-cs/examples/groupmanager/frmGroupInfo.cs +++ b/libsecondlife-cs/examples/groupmanager/frmGroupInfo.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; diff --git a/libsecondlife-cs/examples/groupmanager/frmGroupManager.cs b/libsecondlife-cs/examples/groupmanager/frmGroupManager.cs index 8c3fa006..ae375e01 100644 --- a/libsecondlife-cs/examples/groupmanager/frmGroupManager.cs +++ b/libsecondlife-cs/examples/groupmanager/frmGroupManager.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; @@ -31,7 +31,7 @@ namespace groupmanager { lstGroups.Items.Clear(); - foreach (Group group in client.Groups.Groups) + foreach (Group group in client.Groups.Groups.Values) { lstGroups.Items.Add(group); } @@ -54,7 +54,7 @@ namespace groupmanager cmdConnect.Text = "Disconnect"; txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = false; - Hashtable loginParams = NetworkManager.DefaultLoginValues(txtFirstName.Text, + Dictionary loginParams = NetworkManager.DefaultLoginValues(txtFirstName.Text, txtLastName.Text, txtPassword.Text, "00:00:00:00:00:00", "last", "Win", "0", "groupmanager", "jhurliman@wsu.edu"); diff --git a/libsecondlife-cs/examples/name2key/name2key.cs b/libsecondlife-cs/examples/name2key/name2key.cs index a33279d8..066c5151 100644 --- a/libsecondlife-cs/examples/name2key/name2key.cs +++ b/libsecondlife-cs/examples/name2key/name2key.cs @@ -25,7 +25,7 @@ */ using System; -using System.Collections; +using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; @@ -76,8 +76,8 @@ namespace name2key client.Network.RegisterCallback(PacketType.DirPeopleReply, new PacketCallback(QueryHandler)); // Setup the login values - Hashtable loginParams = NetworkManager.DefaultLoginValues(args[0], args[1], args[2], "00:00:00:00:00:00", - "last", "Win", "0", "name2key", "jhurliman@wsu.edu"); + Dictionary loginParams = NetworkManager.DefaultLoginValues(args[0], args[1], args[2], + "00:00:00:00:00:00", "last", "Win", "0", "name2key", "jhurliman@wsu.edu"); if (!client.Network.Login(loginParams)) { diff --git a/libsecondlife-cs/examples/primexport/frmPrimExport.cs b/libsecondlife-cs/examples/primexport/frmPrimExport.cs index 6fd802e3..1073a023 100644 --- a/libsecondlife-cs/examples/primexport/frmPrimExport.cs +++ b/libsecondlife-cs/examples/primexport/frmPrimExport.cs @@ -4,7 +4,7 @@ using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; -using System.Collections; +using System.Collections.Generic; using libsecondlife; namespace primexport @@ -320,7 +320,7 @@ namespace primexport cmdConnect.Text = "Disconnect"; txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = false; - Hashtable loginParams = NetworkManager.DefaultLoginValues(txtFirstName.Text, + Dictionary loginParams = NetworkManager.DefaultLoginValues(txtFirstName.Text, txtLastName.Text, txtPassword.Text, "00:00:00:00:00:00", "last", "Win", "0", "primexport", "jhurliman@wsu.edu"); diff --git a/libsecondlife-cs/examples/primexport/primexport.cs b/libsecondlife-cs/examples/primexport/primexport.cs index 76874a86..bc96d57b 100644 --- a/libsecondlife-cs/examples/primexport/primexport.cs +++ b/libsecondlife-cs/examples/primexport/primexport.cs @@ -25,7 +25,7 @@ */ using System; -using System.Collections; +using System.Collections.Generic; using libsecondlife; namespace primexport diff --git a/libsecondlife-cs/examples/slaccountant/frmSLAccountant.cs b/libsecondlife-cs/examples/slaccountant/frmSLAccountant.cs index 817aa451..4c99feee 100644 --- a/libsecondlife-cs/examples/slaccountant/frmSLAccountant.cs +++ b/libsecondlife-cs/examples/slaccountant/frmSLAccountant.cs @@ -26,7 +26,7 @@ using System; using System.Drawing; -using System.Collections; +using System.Collections.Generic; using System.ComponentModel; using System.Windows.Forms; using System.Data; @@ -400,7 +400,7 @@ namespace SLAccountant cmdConnect.Text = "Disconnect"; txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = false; - Hashtable loginParams = NetworkManager.DefaultLoginValues(txtFirstName.Text, + Dictionary loginParams = NetworkManager.DefaultLoginValues(txtFirstName.Text, txtLastName.Text, txtPassword.Text, "00:00:00:00:00:00", "last", "Win", "0", "accountant", "jhurliman@wsu.edu"); diff --git a/libsecondlife-cs/examples/sldump/sldump.cs b/libsecondlife-cs/examples/sldump/sldump.cs index af2c0abb..9473c2bd 100644 --- a/libsecondlife-cs/examples/sldump/sldump.cs +++ b/libsecondlife-cs/examples/sldump/sldump.cs @@ -25,7 +25,7 @@ */ using System; -using System.Collections; +using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; @@ -105,13 +105,12 @@ namespace sldump client.Network.RegisterCallback(PacketType.Default, new PacketCallback(DefaultHandler)); client.Network.OnDisconnected += new DisconnectCallback(DisconnectHandler); - Hashtable loginParams = NetworkManager.DefaultLoginValues(args[0], args[1], args[2], - "b15396fa7ec5f19ff1131800673aa132", "last", "Win", "0", "sldump", - "contact@libsecondlife.org"); + Dictionary loginParams = NetworkManager.DefaultLoginValues(args[0], args[1], args[2], + "0", "last", "Win", "0", "sldump", "contact@libsecondlife.org"); // An example of how to pass additional options to the login server - loginParams["id0"] = "65e142a8d3c1ee6632259f111cb168c6"; - loginParams["viewer_digest"] = "0e63550f-0991-a092-3158-b4206e728ffa"; + //loginParams["id0"] = "65e142a8d3c1ee6632259f111cb168c9"; + //loginParams["viewer_digest"] = "0e63550f-0991-a092-3158-b4206e728ffa"; if (!client.Network.Login(loginParams/*, "http://127.0.0.1:8080/"*/)) { diff --git a/libsecondlife-cs/libsecondlife.csproj b/libsecondlife-cs/libsecondlife.csproj index b18b8af8..447840fc 100644 --- a/libsecondlife-cs/libsecondlife.csproj +++ b/libsecondlife-cs/libsecondlife.csproj @@ -189,8 +189,7 @@ - - + diff --git a/libsecondlife-cs/libsecondlife.sln b/libsecondlife-cs/libsecondlife.sln index 66500afb..e3a17041 100644 --- a/libsecondlife-cs/libsecondlife.sln +++ b/libsecondlife-cs/libsecondlife.sln @@ -38,8 +38,8 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Debug|Any CPU.ActiveCfg = Debug|.NET 1.1 - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Debug|Any CPU.Build.0 = Debug|.NET 1.1 + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Debug|Any CPU.Build.0 = Debug|Any CPU {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|Any CPU.ActiveCfg = Release|Any CPU {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|Any CPU.Build.0 = Release|Any CPU {F6258A68-C624-46A0-BA73-B55D21BB0A3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -62,8 +62,8 @@ Global {77E5330D-8A8C-41B4-A2D1-6F06FE45ED6D}.Debug|Any CPU.Build.0 = Debug|Any CPU {77E5330D-8A8C-41B4-A2D1-6F06FE45ED6D}.Release|Any CPU.ActiveCfg = Release|Any CPU {77E5330D-8A8C-41B4-A2D1-6F06FE45ED6D}.Release|Any CPU.Build.0 = Release|Any CPU - {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Debug|Any CPU.ActiveCfg = Debug|.NET 1.1 - {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Debug|Any CPU.Build.0 = Debug|.NET 1.1 + {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Debug|Any CPU.Build.0 = Debug|Any CPU {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Release|Any CPU.ActiveCfg = Release|Any CPU {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Release|Any CPU.Build.0 = Release|Any CPU {C59B1312-57EF-4146-B6B2-1C7B6DC4638B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU diff --git a/libsecondlife-cs/mapgenerator/ProtocolManager.cs b/libsecondlife-cs/mapgenerator/ProtocolManager.cs index 9456be49..1bec2d9c 100644 --- a/libsecondlife-cs/mapgenerator/ProtocolManager.cs +++ b/libsecondlife-cs/mapgenerator/ProtocolManager.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using System.IO; namespace libsecondlife @@ -119,7 +119,7 @@ namespace libsecondlife /// public int Count; /// - public ArrayList Fields; + public List Fields; /// /// @@ -164,7 +164,7 @@ namespace libsecondlife /// public bool Encoded; /// - public ArrayList Blocks; + public List Blocks; } /// @@ -173,9 +173,9 @@ namespace libsecondlife public class ProtocolManager { /// - public Hashtable TypeSizes; + public Dictionary TypeSizes; /// - public Hashtable KeywordPositions; + public Dictionary KeywordPositions; /// public MapPacket[] LowMaps; /// @@ -199,7 +199,7 @@ namespace libsecondlife HighMaps = new MapPacket[256]; // Build the type size hash table - TypeSizes = new Hashtable(); + TypeSizes = new Dictionary(); TypeSizes.Add(FieldType.U8, 1); TypeSizes.Add(FieldType.U16, 2); TypeSizes.Add(FieldType.U32, 4); @@ -381,7 +381,7 @@ namespace libsecondlife string line; StreamReader file; - KeywordPositions = new Hashtable(); + KeywordPositions = new Dictionary(); // Load the keyword file try @@ -544,7 +544,7 @@ namespace libsecondlife LowMaps[fixedID].Name = tokens[0]; LowMaps[fixedID].Trusted = (tokens[3] == "Trusted"); LowMaps[fixedID].Encoded = (tokens[4] == "Zerocoded"); - LowMaps[fixedID].Blocks = new ArrayList(); + LowMaps[fixedID].Blocks = new List(); currentPacket = LowMaps[fixedID]; } @@ -556,7 +556,7 @@ namespace libsecondlife LowMaps[low].Name = tokens[0]; LowMaps[low].Trusted = (tokens[2] == "Trusted"); LowMaps[low].Encoded = (tokens[3] == "Zerocoded"); - LowMaps[low].Blocks = new ArrayList(); + LowMaps[low].Blocks = new List(); currentPacket = LowMaps[low]; @@ -570,7 +570,7 @@ namespace libsecondlife MediumMaps[medium].Name = tokens[0]; MediumMaps[medium].Trusted = (tokens[2] == "Trusted"); MediumMaps[medium].Encoded = (tokens[3] == "Zerocoded"); - MediumMaps[medium].Blocks = new ArrayList(); + MediumMaps[medium].Blocks = new List(); currentPacket = MediumMaps[medium]; @@ -584,7 +584,7 @@ namespace libsecondlife HighMaps[high].Name = tokens[0]; HighMaps[high].Trusted = (tokens[2] == "Trusted"); HighMaps[high].Encoded = (tokens[3] == "Zerocoded"); - HighMaps[high].Blocks = new ArrayList(); + HighMaps[high].Blocks = new List(); currentPacket = HighMaps[high]; @@ -647,7 +647,7 @@ namespace libsecondlife currentBlock.Name = tokens[0]; currentBlock.KeywordPosition = KeywordPosition(currentBlock.Name); - currentBlock.Fields = new ArrayList(); + currentBlock.Fields = new List(); currentPacket.Blocks.Add(currentBlock); if (tokens[1] == "Single") diff --git a/libsecondlife-cs/tests/DebugServer.cs b/libsecondlife-cs/tests/DebugServer.cs index e7ddb9c3..4d866559 100644 --- a/libsecondlife-cs/tests/DebugServer.cs +++ b/libsecondlife-cs/tests/DebugServer.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using System.IO; using System.Net; using System.Net.Sockets; diff --git a/libsecondlife-cs/tests/Tests.cs b/libsecondlife-cs/tests/Tests.cs index e17d5284..d502df64 100644 --- a/libsecondlife-cs/tests/Tests.cs +++ b/libsecondlife-cs/tests/Tests.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using System.Net; using libsecondlife; using libsecondlife.Packets; diff --git a/libsecondlife-cs/tests/libsecondlife.Tests.csproj b/libsecondlife-cs/tests/libsecondlife.Tests.csproj index a835735d..9875a633 100644 --- a/libsecondlife-cs/tests/libsecondlife.Tests.csproj +++ b/libsecondlife-cs/tests/libsecondlife.Tests.csproj @@ -49,8 +49,7 @@ - - +