From 65e1e8d30fa4823a27d2ec2e40ed55093def8e5e Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Sat, 3 Feb 2007 20:34:49 +0000 Subject: [PATCH] Adding ObjectProperties support (closing issues 28 and 29) git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@947 52acb1d6-8a22-11de-b505-999d5b087335 --- libsecondlife-cs/LLObject.cs | 84 ++++++++++ libsecondlife-cs/ObjectManager.cs | 154 ++++++++++++++++-- .../libsecondlife.Utilities.csproj | 5 + 3 files changed, 233 insertions(+), 10 deletions(-) diff --git a/libsecondlife-cs/LLObject.cs b/libsecondlife-cs/LLObject.cs index 6b4f04ff..23492400 100644 --- a/libsecondlife-cs/LLObject.cs +++ b/libsecondlife-cs/LLObject.cs @@ -182,11 +182,82 @@ namespace libsecondlife public ObjectManager.PCode PCode; } + public struct ObjectProperties + { + /// + public LLUUID ObjectID; + /// + public LLUUID CreatorID; + /// + public LLUUID OwnerID; + /// + public LLUUID GroupID; + /// + public ulong CreationDate; + /// + public uint BaseMask; + /// + public uint OwnerMask; + /// + public uint GroupMask; + /// + public uint EveryoneMask; + /// + public uint NextOwnerMask; + /// + public int OwnershipCost; + /// + public byte SaleType; + /// + public int SalePrice; + /// + public byte AggregatePerms; + /// + public byte AggregatePermTextures; + /// + public byte AggregatePermTexturesOwner; + /// + public uint Category; + /// + public short InventorySerial; + /// + public LLUUID ItemID; + /// + public LLUUID FolderID; + /// + public LLUUID FromTaskID; + /// + public LLUUID LastOwnerID; + /// + public string Name; + /// + public string Description; + /// + public string TouchName; + /// + public string SitName; + /// + public LLUUID[] TextureIDs; + } + /// /// /// public struct ObjectPropertiesFamily { + /// + /// + /// + public enum RequestFlagsType + { + /// + BugReportRequest = 1, + /// + ComplaintReportRequest = 2 + } + + /// + public RequestFlagsType RequestFlags; /// public LLUUID ObjectID; /// @@ -269,6 +340,19 @@ namespace libsecondlife internal ObjectData data = new ObjectData(); + public override bool Equals(object obj) + { + LLObject llobj = obj as LLObject; + if (llobj == null) + return false; + return ID.Equals(llobj.ID); + } + + public override int GetHashCode() + { + return ID.GetHashCode(); + } + #region Static Methods /// diff --git a/libsecondlife-cs/ObjectManager.cs b/libsecondlife-cs/ObjectManager.cs index 02166e4f..fef43588 100644 --- a/libsecondlife-cs/ObjectManager.cs +++ b/libsecondlife-cs/ObjectManager.cs @@ -90,7 +90,14 @@ namespace libsecondlife /// /// /// - public delegate void ObjectPropertiesFamilyCallback(Simulator simulator, LLObject.ObjectPropertiesFamily properties); + public delegate void ObjectPropertiesCallback(Simulator simulator, LLObject.ObjectProperties properties); + /// + /// + /// + /// + /// + public delegate void ObjectPropertiesFamilyCallback(Simulator simulator, + LLObject.ObjectPropertiesFamily properties); /// /// /// @@ -386,9 +393,15 @@ namespace libsecondlife /// public event KillObjectCallback OnObjectKilled; /// - /// Thie event will be raised when an object's properties are recieved + /// This event will be raised when an objects properties are received /// from the simulator /// + public event ObjectPropertiesCallback OnObjectProperties; + /// + /// Thie event will be raised when an objects properties family + /// information is recieved from the simulator. ObjectPropertiesFamily + /// is a subset of the fields found in ObjectProperties + /// public event ObjectPropertiesFamilyCallback OnObjectPropertiesFamily; #endregion @@ -400,7 +413,6 @@ namespace libsecondlife /// /// public bool RequestAllObjects = false; - /// /// Used to flag if Object updates should always be decoded, /// even if no object event listenners/callbacks are registered. @@ -765,6 +777,76 @@ namespace libsecondlife Client.Network.SendPacket(objRotPacket, simulator); } + /// + /// + /// + /// + /// + /// + public void SetName(Simulator simulator, uint localID, string name) + { + SetNames(simulator, new uint[] { localID }, new string[] { name }); + } + + /// + /// + /// + /// + /// + /// + public void SetNames(Simulator simulator, uint[] localIDs, string[] names) + { + ObjectNamePacket namePacket = new ObjectNamePacket(); + namePacket.AgentData.AgentID = Client.Network.AgentID; + namePacket.AgentData.SessionID = Client.Network.SessionID; + + namePacket.ObjectData = new ObjectNamePacket.ObjectDataBlock[localIDs.Length]; + + for (int i = 0; i < localIDs.Length; ++i) + { + namePacket.ObjectData[i] = new ObjectNamePacket.ObjectDataBlock(); + namePacket.ObjectData[i].LocalID = localIDs[i]; + namePacket.ObjectData[i].Name = Helpers.StringToField(names[i]); + } + + Client.Network.SendPacket(namePacket, simulator); + } + + /// + /// + /// + /// + /// + /// + public void SetDescription(Simulator simulator, uint localID, string description) + { + SetDescriptions(simulator, new uint[] { localID }, new string[] { description }); + } + + /// + /// + /// + /// + /// + /// + public void SetDescriptions(Simulator simulator, uint[] localIDs, string[] descriptions) + { + ObjectDescriptionPacket descPacket = new ObjectDescriptionPacket(); + descPacket.AgentData.AgentID = Client.Network.AgentID; + descPacket.AgentData.SessionID = Client.Network.SessionID; + + descPacket.ObjectData = new ObjectDescriptionPacket.ObjectDataBlock[localIDs.Length]; + + for (int i = 0; i < localIDs.Length; ++i) + { + descPacket.ObjectData[i] = new ObjectDescriptionPacket.ObjectDataBlock(); + descPacket.ObjectData[i].LocalID = localIDs[i]; + descPacket.ObjectData[i].Description = Helpers.StringToField(descriptions[i]); + } + + Client.Network.SendPacket(descPacket, simulator); + } + /// /// /// @@ -873,13 +955,7 @@ namespace libsecondlife /// public void RequestObjectPropertiesFamily(Simulator simulator, LLUUID objectID) { - RequestObjectPropertiesFamilyPacket properties = new RequestObjectPropertiesFamilyPacket(); - properties.AgentData.AgentID = Client.Network.AgentID; - properties.AgentData.SessionID = Client.Network.SessionID; - properties.ObjectData.ObjectID = objectID; - properties.ObjectData.RequestFlags = 0; - - Client.Network.SendPacket(properties, simulator); + RequestObjectPropertiesFamily(simulator, objectID, true); } /// @@ -893,6 +969,8 @@ namespace libsecondlife properties.AgentData.AgentID = Client.Network.AgentID; properties.AgentData.SessionID = Client.Network.SessionID; properties.ObjectData.ObjectID = objectID; + // TODO: RequestFlags is typically only for bug report submissions, but we might be able to + // use it to pass an arbitrary uint back to the callback properties.ObjectData.RequestFlags = 0; properties.Header.Reliable = reliable; @@ -1629,11 +1707,58 @@ namespace libsecondlife } } + protected void ObjectPropertiesHandler(Packet p, Simulator sim) + { + ObjectPropertiesPacket op = (ObjectPropertiesPacket)p; + ObjectPropertiesPacket.ObjectDataBlock[] datablocks = op.ObjectData; + + for (int i = 0; i < datablocks.Length; ++i) + { + ObjectPropertiesPacket.ObjectDataBlock objectData = datablocks[i]; + LLObject.ObjectProperties props = new LLObject.ObjectProperties(); + + props.AggregatePerms = objectData.AggregatePerms; + props.AggregatePermTextures = objectData.AggregatePermTextures; + props.AggregatePermTexturesOwner = objectData.AggregatePermTexturesOwner; + props.BaseMask = objectData.BaseMask; + props.Category = objectData.Category; + props.CreationDate = objectData.CreationDate; + props.CreatorID = objectData.CreatorID; + props.Description = Helpers.FieldToUTF8String(objectData.Description); + props.EveryoneMask = objectData.EveryoneMask; + props.FolderID = objectData.FolderID; + props.FromTaskID = objectData.FromTaskID; + props.GroupID = objectData.GroupID; + props.GroupMask = objectData.GroupMask; + props.InventorySerial = objectData.InventorySerial; + props.ItemID = objectData.ItemID; + props.LastOwnerID = objectData.LastOwnerID; + props.Name = Helpers.FieldToUTF8String(objectData.Name); + props.NextOwnerMask = objectData.NextOwnerMask; + props.ObjectID = objectData.ObjectID; + props.OwnerID = objectData.OwnerID; + props.OwnerMask = objectData.OwnerMask; + props.OwnershipCost = objectData.OwnershipCost; + props.SalePrice = objectData.SalePrice; + props.SaleType = objectData.SaleType; + props.SitName = Helpers.FieldToUTF8String(objectData.SitName); + props.TouchName = Helpers.FieldToUTF8String(objectData.TouchName); + + int numTextures = objectData.TextureID.Length / 16; + props.TextureIDs = new LLUUID[numTextures]; + for (int j = 0; j < numTextures; ++j) + props.TextureIDs[j] = new LLUUID(objectData.TextureID, j * 16); + + FireOnObjectProperties(sim, props); + } + } + protected void ObjectPropertiesFamilyHandler(Packet p, Simulator sim) { ObjectPropertiesFamilyPacket op = (ObjectPropertiesFamilyPacket)p; LLObject.ObjectPropertiesFamily props = new LLObject.ObjectPropertiesFamily(); + props.RequestFlags = (LLObject.ObjectPropertiesFamily.RequestFlagsType)op.ObjectData.RequestFlags; props.BaseMask = op.ObjectData.BaseMask; props.Category = op.ObjectData.Category; props.Description = Helpers.FieldToString(op.ObjectData.Description); @@ -1696,6 +1821,15 @@ namespace libsecondlife #region Event Notification + protected void FireOnObjectProperties(Simulator sim, LLObject.ObjectProperties props) + { + if (OnObjectProperties != null) + { + try { OnObjectProperties(sim, props); } + catch (Exception e) { Client.Log(e.ToString(), Helpers.LogLevel.Error); } + } + } + protected void FireOnObjectPropertiesFamily(Simulator sim, LLObject.ObjectPropertiesFamily props) { if (OnObjectPropertiesFamily != null) diff --git a/libsecondlife-cs/libsecondlife.Utilities/libsecondlife.Utilities.csproj b/libsecondlife-cs/libsecondlife.Utilities/libsecondlife.Utilities.csproj index a71ad400..2ae3a07d 100644 --- a/libsecondlife-cs/libsecondlife.Utilities/libsecondlife.Utilities.csproj +++ b/libsecondlife-cs/libsecondlife.Utilities/libsecondlife.Utilities.csproj @@ -30,6 +30,7 @@ + @@ -39,6 +40,10 @@ + + {D0DCFDCB-71FA-4343-A8D1-24D4665A94A4} + openjpegnet + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} libsecondlife