diff --git a/OpenMetaverse.StructuredData/JSON/OSDJson.cs b/OpenMetaverse.StructuredData/JSON/OSDJson.cs index 5323f62b..4029ae9c 100644 --- a/OpenMetaverse.StructuredData/JSON/OSDJson.cs +++ b/OpenMetaverse.StructuredData/JSON/OSDJson.cs @@ -35,55 +35,10 @@ namespace OpenMetaverse.StructuredData return OSD.FromReal((double)json); case JsonType.String: string str = (string)json; - if (String.IsNullOrEmpty(str)) - { return new OSD(); - } else - { - switch (str[0]) - { - case 'd': - if (str.StartsWith("date::")) - { - DateTime dt; - if (DateTime.TryParse(str.Substring(6), out dt)) - return OSD.FromDate(dt); - } - break; - case 'u': - if (str.StartsWith("uuid::")) - { - UUID id; - if (UUID.TryParse(str.Substring(6), out id)) - return OSD.FromUUID(id); - } - else if (str.StartsWith("uri::")) - { - try - { - Uri uri = new Uri(str.Substring(5)); - return OSD.FromUri(uri); - } - catch (UriFormatException) { } - } - break; - case 'b': - if (str.StartsWith("b64::")) - { - try - { - byte[] data = Convert.FromBase64String(str.Substring(5)); - return OSD.FromBinary(data); - } - catch (FormatException) { } - } - break; - } - - return OSD.FromString((string)json); - } + return OSD.FromString(str); case JsonType.Array: OSDArray array = new OSDArray(json.Count); for (int i = 0; i < json.Count; i++) @@ -121,15 +76,17 @@ namespace OpenMetaverse.StructuredData case OSDType.Real: return new JsonData(osd.AsReal()); case OSDType.String: - return new JsonData(osd.AsString()); case OSDType.Date: - return new JsonData("date::" + osd.AsString()); case OSDType.URI: - return new JsonData("uri::" + osd.AsString()); case OSDType.UUID: - return new JsonData("uuid::" + osd.AsString()); + return new JsonData(osd.AsString()); case OSDType.Binary: - return new JsonData("b64::" + Convert.ToBase64String(osd.AsBinary())); + byte[] binary = osd.AsBinary(); + JsonData jsonbinarray = new JsonData(); + jsonbinarray.SetJsonType(JsonType.Array); + for (int i = 0; i < binary.Length; i++) + jsonbinarray.Add(new JsonData(binary[i])); + return jsonbinarray; case OSDType.Array: JsonData jsonarray = new JsonData(); jsonarray.SetJsonType(JsonType.Array); diff --git a/OpenMetaverse.StructuredData/StructuredData.cs b/OpenMetaverse.StructuredData/StructuredData.cs index 99d84c83..9149c045 100644 --- a/OpenMetaverse.StructuredData/StructuredData.cs +++ b/OpenMetaverse.StructuredData/StructuredData.cs @@ -902,6 +902,16 @@ namespace OpenMetaverse.StructuredData this.value = new List(); } + public override byte[] AsBinary() + { + byte[] binary = new byte[value.Count]; + + for (int i = 0; i < value.Count; i++) + binary[i] = (byte)value[i].AsInteger(); + + return binary; + } + public override Vector2 AsVector2() { Vector2 vector = Vector2.Zero; diff --git a/OpenMetaverse/AgentManager.cs b/OpenMetaverse/AgentManager.cs index 4f893bf6..f376bcb6 100644 --- a/OpenMetaverse/AgentManager.cs +++ b/OpenMetaverse/AgentManager.cs @@ -663,6 +663,7 @@ namespace OpenMetaverse public InstantMessageOnline Offline; /// Context specific packed data public byte[] BinaryBucket; + //Print the contents of a message public override string ToString() { diff --git a/OpenMetaverse/AssetManager.cs b/OpenMetaverse/AssetManager.cs index d50efb15..b582d8aa 100644 --- a/OpenMetaverse/AssetManager.cs +++ b/OpenMetaverse/AssetManager.cs @@ -35,67 +35,6 @@ namespace OpenMetaverse { #region Enums - /// - /// The different types of grid assets - /// - public enum AssetType : sbyte - { - /// Unknown asset type - Unknown = -1, - /// Texture asset, stores in JPEG2000 J2C stream format - Texture = 0, - /// Sound asset - Sound = 1, - /// Calling card for another avatar - CallingCard = 2, - /// Link to a location in world - Landmark = 3, - // Legacy script asset, you should never see one of these - //[Obsolete] - //Script = 4, - /// Collection of textures and parameters that can be - /// worn by an avatar - Clothing = 5, - /// Primitive that can contain textures, sounds, - /// scripts and more - Object = 6, - /// Notecard asset - Notecard = 7, - /// Holds a collection of inventory items - Folder = 8, - /// Root inventory folder - RootFolder = 9, - /// Linden scripting language script - LSLText = 10, - /// LSO bytecode for a script - LSLBytecode = 11, - /// Uncompressed TGA texture - TextureTGA = 12, - /// Collection of textures and shape parameters that can - /// be worn - Bodypart = 13, - /// Trash folder - TrashFolder = 14, - /// Snapshot folder - SnapshotFolder = 15, - /// Lost and found folder - LostAndFoundFolder = 16, - /// Uncompressed sound - SoundWAV = 17, - /// Uncompressed TGA non-square image, not to be used as a - /// texture - ImageTGA = 18, - /// Compressed JPEG non-square image, not to be used as a - /// texture - ImageJPEG = 19, - /// Animation - Animation = 20, - /// Sequence of animations, sounds, chat, and pauses - Gesture = 21, - /// Simstate file - Simstate = 22, - } - public enum EstateAssetType : int { None = -1, diff --git a/OpenMetaverse/AssetTypes.cs b/OpenMetaverse/AssetTypes.cs index 6a3c0f16..26ec0218 100644 --- a/OpenMetaverse/AssetTypes.cs +++ b/OpenMetaverse/AssetTypes.cs @@ -603,7 +603,7 @@ namespace OpenMetaverse GroupOwned = (Int32.Parse(fields[1]) != 0); break; case "sale_type": - ForSale = InventoryManager.StringToSaleType(fields[1]); + ForSale = Utils.StringToSaleType(fields[1]); break; case "sale_price": SalePrice = Int32.Parse(fields[1]); @@ -644,7 +644,7 @@ namespace OpenMetaverse data.Append("\t}\n"); data.Append("\tsale_info\t0\n"); data.Append("\t{\n"); - data.Append("\t\tsale_type\t"); data.Append(InventoryManager.SaleTypeToString(ForSale)); data.Append(NL); + data.Append("\t\tsale_type\t"); data.Append(Utils.SaleTypeToString(ForSale)); data.Append(NL); data.Append("\t\tsale_price\t"); data.Append(SalePrice); data.Append(NL); data.Append("\t}\n"); data.Append("type "); data.Append((int)WearableType); data.Append(NL); diff --git a/OpenMetaverse/DirectoryManager.cs b/OpenMetaverse/DirectoryManager.cs index b864386f..d20d70fb 100644 --- a/OpenMetaverse/DirectoryManager.cs +++ b/OpenMetaverse/DirectoryManager.cs @@ -517,7 +517,7 @@ namespace OpenMetaverse /// public UUID StartPlacesSearch() { - return StartPlacesSearch(DirFindFlags.AgentOwned, Parcel.ParcelCategory.Any, String.Empty, String.Empty, + return StartPlacesSearch(DirFindFlags.AgentOwned, ParcelCategory.Any, String.Empty, String.Empty, UUID.Zero, UUID.Zero); } @@ -530,7 +530,7 @@ namespace OpenMetaverse /// Transaction (Query) ID which can be associated with results from your request. public UUID StartPlacesSearch(DirFindFlags findFlags, UUID groupID) { - return StartPlacesSearch(findFlags, Parcel.ParcelCategory.Any, String.Empty, String.Empty, groupID, + return StartPlacesSearch(findFlags, ParcelCategory.Any, String.Empty, String.Empty, groupID, UUID.Random()); } @@ -542,7 +542,7 @@ namespace OpenMetaverse /// LLUID of group you want to recieve results for /// Transaction (Query) ID which can be associated with results from your request. /// Transaction (Query) ID which can be associated with results from your request. - public UUID StartPlacesSearch(DirFindFlags findFlags, Parcel.ParcelCategory searchCategory, UUID groupID, UUID transactionID) + public UUID StartPlacesSearch(DirFindFlags findFlags, ParcelCategory searchCategory, UUID groupID, UUID transactionID) { return StartPlacesSearch(findFlags, searchCategory, String.Empty, String.Empty, groupID, transactionID); } @@ -557,7 +557,7 @@ namespace OpenMetaverse /// LLUID of group you want to recieve results for /// Transaction (Query) ID which can be associated with results from your request. /// Transaction (Query) ID which can be associated with results from your request. - public UUID StartPlacesSearch(DirFindFlags findFlags, Parcel.ParcelCategory searchCategory, string searchText, string simulatorName, UUID groupID, UUID transactionID) + public UUID StartPlacesSearch(DirFindFlags findFlags, ParcelCategory searchCategory, string searchText, string simulatorName, UUID groupID, UUID transactionID) { PlacesQueryPacket find = new PlacesQueryPacket(); find.AgentData.AgentID = Client.Self.AgentID; diff --git a/OpenMetaverse/InventoryManager.cs b/OpenMetaverse/InventoryManager.cs index 4e006a56..5cca74d1 100644 --- a/OpenMetaverse/InventoryManager.cs +++ b/OpenMetaverse/InventoryManager.cs @@ -37,79 +37,6 @@ using OpenMetaverse.Packets; namespace OpenMetaverse { #region Enums - /// - /// Inventory Item Types, eg Script, Notecard, Folder, etc - /// - public enum InventoryType : sbyte - { - /// Unknown - Unknown = -1, - /// Texture - Texture = 0, - /// Sound - Sound = 1, - /// Calling Card - CallingCard = 2, - /// Landmark - Landmark = 3, - /* - /// Script - //[Obsolete("See LSL")] Script = 4, - /// Clothing - //[Obsolete("See Wearable")] Clothing = 5, - /// Object, both single and coalesced - */ - Object = 6, - /// Notecard - Notecard = 7, - /// - Category = 8, - /// Folder - Folder = 8, - /// - RootCategory = 9, - /// an LSL Script - LSL = 10, - /* - /// - //[Obsolete("See LSL")] LSLBytecode = 11, - /// - //[Obsolete("See Texture")] TextureTGA = 12, - /// - //[Obsolete] Bodypart = 13, - /// - //[Obsolete] Trash = 14, - */ - /// - Snapshot = 15, - /* - /// - //[Obsolete] LostAndFound = 16, - */ - /// - Attachment = 17, - /// - Wearable = 18, - /// - Animation = 19, - /// - Gesture = 20 - } - - /// - /// Item Sale Status - /// - public enum SaleType : byte - { - /// Not for sale - Not = 0, - /// The original is for sale - Original = 1, - /// Copies are for sale - Copy = 2, - /// The contents of the object are for sale - Contents = 3 - } [Flags] public enum InventorySortOrder : int @@ -190,6 +117,7 @@ namespace OpenMetaverse #endregion Enums #region Inventory Object Classes + /// /// Base Class for Inventory Items /// @@ -1017,15 +945,6 @@ namespace OpenMetaverse #endregion Events - private GridClient _Client; - private Inventory _Store; - //private Random _RandNumbers = new Random(); - private object _CallbacksLock = new object(); - private uint _CallbackPos; - private Dictionary _ItemCreatedCallbacks = new Dictionary(); - private Dictionary _ItemCopiedCallbacks = new Dictionary(); - private List _Searches = new List(); - #region String Arrays /// Partial mapping of AssetTypes to folder names @@ -1055,68 +974,17 @@ namespace OpenMetaverse "Gestures" }; - private static readonly string[] _AssetTypeNames = new string[] - { - "texture", - "sound", - "callcard", - "landmark", - "script", - "clothing", - "object", - "notecard", - "category", - "root", - "lsltext", - "lslbyte", - "txtr_tga", - "bodypart", - "trash", - "snapshot", - "lstndfnd", - "snd_wav", - "img_tga", - "jpeg", - "animatn", - "gesture", - "simstate" - }; - - private static readonly string[] _InventoryTypeNames = new string[] - { - "texture", - "sound", - "callcard", - "landmark", - String.Empty, - String.Empty, - "object", - "notecard", - "category", - "root", - "script", - String.Empty, - String.Empty, - String.Empty, - String.Empty, - "snapshot", - String.Empty, - "attach", - "wearable", - "animation", - "gesture", - }; - - private static readonly string[] _SaleTypeNames = new string[] - { - "not", - "orig", - "copy", - "cntn" - }; - #endregion String Arrays + private GridClient _Client; + private Inventory _Store; + //private Random _RandNumbers = new Random(); + private object _CallbacksLock = new object(); + private uint _CallbackPos; + private Dictionary _ItemCreatedCallbacks = new Dictionary(); + private Dictionary _ItemCopiedCallbacks = new Dictionary(); + private List _Searches = new List(); + #region Properties /// @@ -1965,8 +1833,8 @@ namespace OpenMetaverse { OSDMap query = new OSDMap(); query.Add("folder_id", OSD.FromUUID(folderID)); - query.Add("asset_type", OSD.FromString(AssetTypeToString(assetType))); - query.Add("inventory_type", OSD.FromString(InventoryTypeToString(invType))); + query.Add("asset_type", OSD.FromString(Utils.AssetTypeToString(assetType))); + query.Add("inventory_type", OSD.FromString(Utils.InventoryTypeToString(invType))); query.Add("name", OSD.FromString(name)); query.Add("description", OSD.FromString(description)); @@ -2655,74 +2523,6 @@ namespace OpenMetaverse #region Helper Functions - /// - /// Takes an AssetType and returns the string representation - /// - /// The source - /// The string version of the AssetType - public static string AssetTypeToString(AssetType type) - { - return _AssetTypeNames[(int)type]; - } - - /// - /// Translate a string name of an AssetType into the proper Type - /// - /// A string containing the AssetType name - /// The AssetType which matches the string name, or AssetType.Unknown if no match was found - public static AssetType StringToAssetType(string type) - { - for (int i = 0; i < _AssetTypeNames.Length; i++) - { - if (_AssetTypeNames[i] == type) - return (AssetType)i; - } - - return AssetType.Unknown; - } - - /// - /// Convert an InventoryType to a string - /// - /// The to convert - /// A string representation of the source - public static string InventoryTypeToString(InventoryType type) - { - return _InventoryTypeNames[(int)type]; - } - - /// - /// Convert a string into a valid InventoryType - /// - /// A string representation of the InventoryType to convert - /// A InventoryType object which matched the type - public static InventoryType StringToInventoryType(string type) - { - for (int i = 0; i < _InventoryTypeNames.Length; i++) - { - if (_InventoryTypeNames[i] == type) - return (InventoryType)i; - } - - return InventoryType.Unknown; - } - - public static string SaleTypeToString(SaleType type) - { - return _SaleTypeNames[(int)type]; - } - - public static SaleType StringToSaleType(string value) - { - for (int i = 0; i < _SaleTypeNames.Length; i++) - { - if (value == _SaleTypeNames[i]) - return (SaleType)i; - } - - return SaleType.Not; - } - private uint RegisterItemCreatedCallback(ItemCreatedCallback callback) { lock (_CallbacksLock) @@ -2916,7 +2716,7 @@ namespace OpenMetaverse } else if (key == "type") { - assetType = StringToAssetType(value); + assetType = Utils.StringToAssetType(value); } else if (key == "name") { @@ -3087,7 +2887,7 @@ namespace OpenMetaverse } else if (key == "sale_type") { - saleType = StringToSaleType(value); + saleType = Utils.StringToSaleType(value); } else if (key == "sale_price") { @@ -3108,11 +2908,11 @@ namespace OpenMetaverse } else if (key == "type") { - assetType = StringToAssetType(value); + assetType = Utils.StringToAssetType(value); } else if (key == "inv_type") { - inventoryType = StringToInventoryType(value); + inventoryType = Utils.StringToInventoryType(value); } else if (key == "flags") { diff --git a/OpenMetaverse/Messages/LindenMessages.cs b/OpenMetaverse/Messages/LindenMessages.cs new file mode 100644 index 00000000..b8195996 --- /dev/null +++ b/OpenMetaverse/Messages/LindenMessages.cs @@ -0,0 +1,497 @@ +using System; +using OpenMetaverse.StructuredData; + +namespace OpenMetaverse.Messages.Linden +{ + public class PrimOwnersListMessage + { + public class DataBlock + { + public UUID OwnerID; + public int Count; + public bool IsGroupOwned; + public bool OnlineStatus; + public DateTime TimeStamp; + } + + public DataBlock[] DataBlocks; + + public OSDMap Serialize() + { + OSDMap map = new OSDMap(2); + + OSDArray dataArray = new OSDArray(DataBlocks.Length); + OSDArray dataExtendedArray = new OSDArray(DataBlocks.Length); + + for (int i = 0; i < DataBlocks.Length; i++) + { + OSDMap dataMap = new OSDMap(4); + dataMap["OwnerID"] = OSD.FromUUID(DataBlocks[i].OwnerID); + dataMap["Count"] = OSD.FromInteger(DataBlocks[i].Count); + dataMap["IsGroupOwned"] = OSD.FromBoolean(DataBlocks[i].IsGroupOwned); + dataMap["OnlineStatus"] = OSD.FromBoolean(DataBlocks[i].OnlineStatus); + dataArray.Add(dataMap); + + OSDMap dataExtendedMap = new OSDMap(1); + dataExtendedMap["TimeStamp"] = OSD.FromDate(DataBlocks[i].TimeStamp); + dataExtendedArray.Add(dataExtendedMap); + + } + + map["Data"] = dataArray; + map["DataExtended"] = dataExtendedArray; + + return map; + } + + public void Deserialize(OSDMap map) + { + OSDArray dataArray = (OSDArray)map["Data"]; + OSDArray dataExtendedArray = (OSDArray)map["DataExtended"]; + + DataBlocks = new DataBlock[dataArray.Count]; + for (int i = 0; i < dataArray.Count; i++) + { + OSDMap dataMap = (OSDMap)dataArray[i]; + DataBlock block = new DataBlock(); + block.OwnerID = dataMap["OwnerID"].AsUUID(); + block.Count = dataMap["Count"].AsInteger(); + block.IsGroupOwned = dataMap["IsGroupOwned"].AsBoolean(); + block.OnlineStatus = dataMap["OnlineStatus"].AsBoolean(); // deprecated + + OSDMap dataExtendedMap = (OSDMap)dataExtendedArray[i]; + block.TimeStamp = dataExtendedMap["TimeStamp"].AsDate(); + } + } + } + + /// + /// The details of a single parcel in a region, also contains some regionwide globals + /// + public class ParcelPropertiesMessage + { + public int LocalID; + public Vector3 AABBMax; + public Vector3 AABBMin; + public int Area; + public int AuctionID; + public UUID AuthBuyerID; + public byte[] Bitmap; + public ParcelCategory Category; + public DateTime ClaimDate; + public int ClaimPrice; + public string Desc; + public ParcelFlags ParcelFlags; + public UUID GroupID; + public int GroupPrims; + public bool IsGroupOwned; + public LandingType LandingType; + public int MaxPrims; + public UUID MediaID; + public string MediaURL; + public bool MediaAutoScale; + public string MusicURL; + public string Name; + public int OtherCleanTime; + public int OtherCount; + public int OtherPrims; + public UUID OwnerID; + public int OwnerPrims; + public float ParcelPrimBonus; + public float PassHours; + public int PassPrice; + public int PublicCount; + public bool RegionDenyAnonymous; + public bool RegionPushOverride; + public int RentPrice; + public ParcelResult RequestResult; + public int SalePrice; + public int SelectedPrims; + public int SelfCount; + public int SequenceID; + public int SimWideMaxPrims; + public int SimWideTotalPrims; + public bool SnapSelection; + public UUID SnapshotID; + public ParcelStatus Status; + public int TotalPrims; + public Vector3 UserLocation; + public Vector3 UserLookAt; + + public bool RegionDenyAgeUnverified; + + public string MediaDesc; + public int MediaHeight; + public int MediaWidth; + public bool MediaLoop; + public string MediaType; + public bool ObscureMedia; + public bool ObscureMusic; + + public OSDMap Serialize() + { + + OSDMap map = new OSDMap(3); + + OSDArray dataArray = new OSDArray(1); + OSDMap parcelDataMap = new OSDMap(47); + parcelDataMap["LocalID"] = OSD.FromInteger(LocalID); + parcelDataMap["AABBMax"] = OSD.FromVector3(AABBMax); + parcelDataMap["AABBMin"] = OSD.FromVector3(AABBMin); + parcelDataMap["Area"] = OSD.FromInteger(Area); + parcelDataMap["AuctionID"] = OSD.FromInteger(AuctionID); + parcelDataMap["AuthBuyerID"] = OSD.FromUUID(AuthBuyerID); + parcelDataMap["Bitmap"] = OSD.FromBinary(Bitmap); + parcelDataMap["Category"] = OSD.FromInteger((int)Category); + parcelDataMap["ClaimDate"] = OSD.FromDate(ClaimDate); + parcelDataMap["ClaimPrice"] = OSD.FromInteger(ClaimPrice); + parcelDataMap["Desc"] = OSD.FromString(Desc); + parcelDataMap["ParcelFlags"] = OSD.FromLong((long)ParcelFlags); // verify this! + parcelDataMap["GroupID"] = OSD.FromUUID(GroupID); + parcelDataMap["GroupPrims"] = OSD.FromInteger(GroupPrims); + parcelDataMap["IsGroupOwned"] = OSD.FromBoolean(IsGroupOwned); + parcelDataMap["LandingType"] = OSD.FromInteger((int)LandingType); + parcelDataMap["MaxPrims"] = OSD.FromInteger(MaxPrims); + parcelDataMap["MediaID"] = OSD.FromUUID(MediaID); + parcelDataMap["MediaURL"] = OSD.FromString(MediaURL); + parcelDataMap["MediaAutoScale"] = OSD.FromBoolean(MediaAutoScale); + parcelDataMap["MusicURL"] = OSD.FromString(MusicURL); + parcelDataMap["Name"] = OSD.FromString(Name); + parcelDataMap["OtherCleanTime"] = OSD.FromInteger(OtherCleanTime); + parcelDataMap["OtherCount"] = OSD.FromInteger(OtherCount); + parcelDataMap["OtherPrims"] = OSD.FromInteger(OtherPrims); + parcelDataMap["OwnerID"] = OSD.FromUUID(OwnerID); + parcelDataMap["OwnerPrims"] = OSD.FromInteger(OwnerPrims); + parcelDataMap["ParcelPrimBonus"] = OSD.FromReal((float)ParcelPrimBonus); + parcelDataMap["PassHours"] = OSD.FromReal((float)PassHours); + parcelDataMap["PassPrice"] = OSD.FromInteger(PassPrice); + parcelDataMap["PublicCount"] = OSD.FromInteger(PublicCount); + parcelDataMap["RegionDenyAnonymous"] = OSD.FromBoolean(RegionDenyAnonymous); + parcelDataMap["RegionPushOverride"] = OSD.FromBoolean(RegionPushOverride); + parcelDataMap["RentPrice"] = OSD.FromInteger(RentPrice); + parcelDataMap["RequestResult"] = OSD.FromInteger((int)RequestResult); + parcelDataMap["SalePrice"] = OSD.FromInteger(SalePrice); + parcelDataMap["SelectedPrims"] = OSD.FromInteger(SelectedPrims); + parcelDataMap["SelfCount"] = OSD.FromInteger(SelfCount); + parcelDataMap["SequenceID"] = OSD.FromInteger(SequenceID); + parcelDataMap["SimWideMaxPrims"] = OSD.FromInteger(SimWideMaxPrims); + parcelDataMap["SimWideTotalPrims"] = OSD.FromInteger(SimWideTotalPrims); + parcelDataMap["SnapSelection"] = OSD.FromBoolean(SnapSelection); + parcelDataMap["SnapshotID"] = OSD.FromUUID(SnapshotID); + parcelDataMap["Status"] = OSD.FromInteger((int)Status); + parcelDataMap["TotalPrims"] = OSD.FromInteger(TotalPrims); + parcelDataMap["UserLocation"] = OSD.FromVector3(UserLocation); + parcelDataMap["UserLookAt"] = OSD.FromVector3(UserLookAt); + dataArray.Add(parcelDataMap); + map["ParcelData"] = dataArray; + + OSDArray mediaDataArray = new OSDArray(1); + OSDMap mediaDataMap = new OSDMap(7); + mediaDataMap["MediaDesc"] = OSD.FromString(MediaDesc); + mediaDataMap["MediaHeight"] = OSD.FromInteger(MediaHeight); + mediaDataMap["MediaWidth"] = OSD.FromInteger(MediaWidth); + mediaDataMap["MediaLoop"] = OSD.FromBoolean(MediaLoop); + mediaDataMap["MediaType"] = OSD.FromString(MediaType); + mediaDataMap["ObscureMedia"] = OSD.FromBoolean(ObscureMedia); + mediaDataMap["ObscureMusic"] = OSD.FromBoolean(ObscureMusic); + mediaDataArray.Add(mediaDataMap); + map["MediaData"] = mediaDataArray; + + OSDArray ageVerificationBlockArray = new OSDArray(1); + OSDMap ageVerificationBlockMap = new OSDMap(1); + ageVerificationBlockMap["RegionDenyAgeUnverified"] = OSD.FromBoolean(RegionDenyAgeUnverified); + ageVerificationBlockArray.Add(ageVerificationBlockMap); + map["AgeVerificationBlock"] = ageVerificationBlockArray; + + return map; + } + + public void Deserialize(OSDMap map) + { + OSDMap parcelDataMap = (OSDMap)((OSDArray)map["ParcelData"])[0]; + LocalID = parcelDataMap["LocalID"].AsInteger(); + AABBMax = parcelDataMap["AABBMax"].AsVector3(); + AABBMin = parcelDataMap["AABBMin"].AsVector3(); + Area = parcelDataMap["Area"].AsInteger(); + AuctionID = parcelDataMap["AuctionID"].AsInteger(); + AuthBuyerID = parcelDataMap["AuthBuyerID"].AsUUID(); + Bitmap = parcelDataMap["Bitmap"].AsBinary(); + Category = (ParcelCategory)parcelDataMap["Category"].AsInteger(); + ClaimDate = Utils.UnixTimeToDateTime((uint)parcelDataMap["ClaimDate"].AsInteger()); + ClaimPrice = parcelDataMap["ClaimPrice"].AsInteger(); + Desc = parcelDataMap["Desc"].AsString(); + ParcelFlags = (ParcelFlags)parcelDataMap["ParcelFlags"].AsLong(); // verify this! + GroupID = parcelDataMap["GroupID"].AsUUID(); + GroupPrims = parcelDataMap["GroupPrims"].AsInteger(); + IsGroupOwned = parcelDataMap["IsGroupOwned"].AsBoolean(); + LandingType = (LandingType)parcelDataMap["LandingType"].AsInteger(); + MaxPrims = parcelDataMap["MaxPrims"].AsInteger(); + MediaID = parcelDataMap["MediaID"].AsUUID(); + MediaURL = parcelDataMap["MediaURL"].AsString(); + MediaAutoScale = parcelDataMap["MediaAutoScale"].AsBoolean(); // 0x1 = yes + MusicURL = parcelDataMap["MusicURL"].AsString(); + Name = parcelDataMap["Name"].AsString(); + OtherCleanTime = parcelDataMap["OtherCleanTime"].AsInteger(); + OtherCount = parcelDataMap["OtherCount"].AsInteger(); + OtherPrims = parcelDataMap["OtherPrims"].AsInteger(); + OwnerID = parcelDataMap["OwnerID"].AsUUID(); + OwnerPrims = parcelDataMap["OwnerPrims"].AsInteger(); + ParcelPrimBonus = (float)parcelDataMap["ParcelPrimBonus"].AsReal(); + PassHours = (float)parcelDataMap["PassHours"].AsReal(); + PassPrice = parcelDataMap["PassPrice"].AsInteger(); + PublicCount = parcelDataMap["PublicCount"].AsInteger(); + RegionDenyAnonymous = parcelDataMap["RegionDenyAnonymous"].AsBoolean(); + RegionPushOverride = parcelDataMap["RegionPushOverride"].AsBoolean(); + RentPrice = parcelDataMap["RentPrice"].AsInteger(); + RequestResult = (ParcelResult)parcelDataMap["RequestResult"].AsInteger(); + SalePrice = parcelDataMap["SalePrice"].AsInteger(); + SelectedPrims = parcelDataMap["SelectedPrims"].AsInteger(); + SelfCount = parcelDataMap["SelfCount"].AsInteger(); + SequenceID = parcelDataMap["SequenceID"].AsInteger(); + SimWideMaxPrims = parcelDataMap["SimWideMaxPrims"].AsInteger(); + SimWideTotalPrims = parcelDataMap["SimWideTotalPrims"].AsInteger(); + SnapSelection = parcelDataMap["SnapSelection"].AsBoolean(); + SnapshotID = parcelDataMap["SnapshotID"].AsUUID(); + Status = (ParcelStatus)parcelDataMap["Status"].AsInteger(); + TotalPrims = parcelDataMap["TotalPrims"].AsInteger(); + UserLocation = parcelDataMap["UserLocation"].AsVector3(); + UserLookAt = parcelDataMap["UserLookAt"].AsVector3(); + + OSDMap mediaDataMap = (OSDMap)((OSDArray)map["MediaData"])[0]; + MediaDesc = mediaDataMap["MediaDesc"].AsString(); + MediaHeight = mediaDataMap["MediaHeight"].AsInteger(); + MediaWidth = mediaDataMap["MediaWidth"].AsInteger(); + MediaLoop = mediaDataMap["MediaLoop"].AsBoolean(); + MediaType = mediaDataMap["MediaType"].AsString(); + ObscureMedia = mediaDataMap["ObscureMedia"].AsBoolean(); + ObscureMusic = mediaDataMap["ObscureMusic"].AsBoolean(); + + OSDMap ageVerificationBlockMap = (OSDMap)((OSDArray)map["AgeVerificationBlock"])[0]; + RegionDenyAgeUnverified = ageVerificationBlockMap["RegionDenyAgeUnverified"].AsBoolean(); + } + } + + public class ChatterboxSessionEventMessage + { + public bool Success; + + public OSDMap Serialize() + { + OSDMap map = new OSDMap(1); + map["Success"] = OSD.FromBoolean(Success); + + return map; + } + + public void Deserialize(OSDMap map) + { + Success = map["success"].AsBoolean(); + } + } + + public class ChatterBoxSessionStartMessage + { + public UUID SessionID; + public UUID TempSessionID; + public bool Success; + + public string SessionName; + // FIXME: Replace int with an enum + public int Type; + public bool VoiceEnabled; + public bool ModeratedVoice; + + public OSDMap Serialize() + { + OSDMap map = new OSDMap(4); + map.Add("session_id", OSD.FromUUID(SessionID)); + map.Add("temp_session_id", OSD.FromUUID(TempSessionID)); + map.Add("success", OSD.FromBoolean(Success)); + + OSDMap sessionMap = new OSDMap(4); + sessionMap.Add("type", OSD.FromInteger(Type)); + sessionMap.Add("session_name", OSD.FromString(SessionName)); + sessionMap.Add("voice_enabled", OSD.FromBoolean(VoiceEnabled)); + + + OSDMap moderatedMap = new OSDMap(1); + moderatedMap.Add("voice", OSD.FromBoolean(ModeratedVoice)); + + sessionMap.Add("moderated_mode", moderatedMap); + + map.Add("session_info", sessionMap); + + return map; + } + + public void Deserialize(OSDMap map) + { + SessionID = map["session_id"].AsUUID(); + TempSessionID = map["temp_session_id"].AsUUID(); + Success = map["success"].AsBoolean(); + + if (Success) + { + OSDMap sessionInfoMap = (OSDMap)map["session_info"]; + SessionName = sessionInfoMap["session_name"].AsString(); + Type = sessionInfoMap["type"].AsInteger(); + + OSDMap moderatedModeMap = (OSDMap)sessionInfoMap["moderated_mode"]; + ModeratedVoice = moderatedModeMap["voice"].AsBoolean(); + } + } + } + + public class ChatterBoxInvitationMessage + { + /// Key of sender + public UUID FromAgentID; + /// Name of sender + public string FromAgentName; + /// Key of destination avatar + public UUID ToAgentID; + /// ID of originating estate + public uint ParentEstateID; + /// Key of originating region + public UUID RegionID; + /// Coordinates in originating region + public Vector3 Position; + /// Instant message type + public InstantMessageDialog Dialog; + /// Group IM session toggle + public bool GroupIM; + /// Key of IM session, for Group Messages, the groups UUID + public UUID IMSessionID; + /// Timestamp of the instant message + public DateTime Timestamp; + /// Instant message text + public string Message; + /// Whether this message is held for offline avatars + public InstantMessageOnline Offline; + /// Context specific packed data + public byte[] BinaryBucket; + + public OSDMap Serialize() + { + throw new NotImplementedException(); + } + + public void Deserialize(OSDMap map) + { + OSDMap im = (OSDMap)map["instantmessage"]; + OSDMap msg = (OSDMap)im["message_params"]; + OSDMap msgdata = (OSDMap)msg["data"]; + + FromAgentID = map["from_id"].AsUUID(); + FromAgentName = map["from_name"].AsString(); + ToAgentID = msg["to_id"].AsUUID(); + ParentEstateID = (uint)msg["parent_estate_id"].AsInteger(); + RegionID = msg["region_id"].AsUUID(); + Position = msg["position"].AsVector3(); + Dialog = (InstantMessageDialog)msgdata["type"].AsInteger(); + GroupIM = msg["from_group"].AsBoolean(); + IMSessionID = map["session_id"].AsUUID(); + Timestamp = new DateTime(msgdata["timestamp"].AsInteger()); + Message = msg["message"].AsString(); + Offline = (InstantMessageOnline)msg["offline"].AsInteger(); + BinaryBucket = msgdata["binary_bucket"].AsBinary(); + } + } + + public class ModerateChatSessionsMessage + { + public OSDMap Serialize() + { + throw new NotImplementedException(); + } + + public void Deserialize(OSDMap map) + { + throw new NotImplementedException(); + } + } + + public class ChatterBoxSessionAgentListMessage + { + public OSDMap Serialize() + { + throw new NotImplementedException(); + } + + public void Deserialize(OSDMap map) + { + throw new NotImplementedException(); + } + } + + public class NewFileAgentInventoryMessage + { + public UUID FolderID; + public AssetType AssetType; + public InventoryType InventoryType; + public string Name; + public string Description; + + public OSDMap Serialize() + { + OSDMap map = new OSDMap(5); + map["folder_id"] = OSD.FromUUID(FolderID); + map["asset_type"] = OSD.FromString(Utils.AssetTypeToString(AssetType)); + map["inventory_type"] = OSD.FromString(Utils.InventoryTypeToString(InventoryType)); + map["name"] = OSD.FromString(Name); + map["description"] = OSD.FromString(Description); + + return map; + + } + + public void Deserialize(OSDMap map) + { + FolderID = map["folder_id"].AsUUID(); + AssetType = Utils.StringToAssetType(map["asset_type"].AsString()); + InventoryType = Utils.StringToInventoryType(map["inventory_type"].AsString()); + Name = map["name"].AsString(); + Description = map["description"].AsString(); + } + + } + + public class UpdateNotecardAgentInventoryMessage + { + public UUID ItemID; + + public OSDMap Serialize() + { + OSDMap map = new OSDMap(1); + map["item_id"] = OSD.FromUUID(ItemID); + + return map; + } + + public void Deserialize(OSDMap map) + { + ItemID = map["item_id"].AsUUID(); + } + } + + public class UpdateNotecardTaskInventoryMessage + { + public UUID TaskID; + public UUID ItemID; + + public OSDMap Serialize() + { + OSDMap map = new OSDMap(1); + map["task_id"] = OSD.FromUUID(TaskID); + map["item_id"] = OSD.FromUUID(ItemID); + + return map; + } + + public void Deserialize(OSDMap map) + { + TaskID = map["task_id"].AsUUID(); + ItemID = map["item_id"].AsUUID(); + } + } +} diff --git a/OpenMetaverse/Messages/SimianMessages.cs b/OpenMetaverse/Messages/SimianMessages.cs new file mode 100644 index 00000000..f5ab8dee --- /dev/null +++ b/OpenMetaverse/Messages/SimianMessages.cs @@ -0,0 +1,255 @@ +using System; +using OpenMetaverse.StructuredData; + +namespace OpenMetaverse.Messages.Simian +{ + public class EnableClientMessage + { + public UUID AgentID; + public UUID SessionID; + public UUID SecureSessionID; + public int CircuitCode; + public string FirstName; + public string LastName; + public ulong RegionHandle; + public Uri CallbackUri; + + public OSDMap Serialize() + { + OSDMap map = new OSDMap(7); + map["agent_id"] = OSD.FromUUID(AgentID); + map["session_id"] = OSD.FromUUID(SessionID); + map["secure_session_id"] = OSD.FromUUID(SecureSessionID); + map["circuit_code"] = OSD.FromInteger(CircuitCode); + map["first_name"] = OSD.FromString(FirstName); + map["last_name"] = OSD.FromString(LastName); + map["region_handle"] = OSD.FromULong(RegionHandle); + map["callback_uri"] = OSD.FromUri(CallbackUri); + return map; + } + + public void Deserialize(OSDMap map) + { + AgentID = map["agent_id"].AsUUID(); + SessionID = map["session_id"].AsUUID(); + SecureSessionID = map["secure_session_id"].AsUUID(); + CircuitCode = map["circuit_code"].AsInteger(); + FirstName = map["first_name"].AsString(); + LastName = map["last_name"].AsString(); + RegionHandle = map["region_handle"].AsULong(); + CallbackUri = map["callback_uri"].AsUri(); + } + } + + public class EnableClientReplyMessage + { + public bool Success; + public string Message; + + public OSDMap Serialize() + { + OSDMap map = new OSDMap(2); + map["success"] = OSD.FromBoolean(Success); + map["message"] = OSD.FromString(Message); + return map; + } + + public void Deserialize(OSDMap map) + { + Success = map["success"].AsBoolean(); + Message = map["message"].AsString(); + } + } + + public class EnableClientCompleteMessage + { + public UUID AgentID; + public Uri SeedCapability; + + public OSDMap Serialize() + { + OSDMap map = new OSDMap(2); + map["agent_id"] = OSD.FromUUID(AgentID); + map["seed_capability"] = OSD.FromUri(SeedCapability); + return map; + } + + public void Deserialize(OSDMap map) + { + AgentID = map["agent_id"].AsUUID(); + SeedCapability = map["seed_capability"].AsUri(); + } + } + + public class ChildAgentUpdateMessage + { + public UUID AgentID; + public UUID SessionID; + public Vector3 Position; + public Vector3 Velocity; + public ulong RegionHandle; + public Vector3 CameraPosition; + public Vector3 CameraAtAxis; + public Vector3 CameraLeftAxis; + public Vector3 CameraUpAxis; + + public OSDMap Serialize() + { + OSDMap map = new OSDMap(8); + map["agent_id"] = OSD.FromUUID(AgentID); + map["session_id"] = OSD.FromUUID(SessionID); + map["position"] = OSD.FromVector3(Position); + map["velocity"] = OSD.FromVector3(Velocity); + map["region_handle"] = OSD.FromULong(RegionHandle); + map["cam_position"] = OSD.FromVector3(CameraPosition); + map["cam_at_axis"] = OSD.FromVector3(CameraAtAxis); + map["cam_left_axis"] = OSD.FromVector3(CameraLeftAxis); + map["cam_up_axis"] = OSD.FromVector3(CameraUpAxis); + return map; + } + + public void Deserialize(OSDMap map) + { + AgentID = map["agent_id"].AsUUID(); + SessionID = map["session_id"].AsUUID(); + Position = map["position"].AsVector3(); + Velocity = map["velocity"].AsVector3(); + RegionHandle = map["region_handle"].AsULong(); + CameraPosition = map["cam_position"].AsVector3(); + CameraAtAxis = map["cam_at_axis"].AsVector3(); + CameraLeftAxis = map["cam_left_axis"].AsVector3(); + CameraUpAxis = map["cam_up_axis"].AsVector3(); + } + } + + public class PassObjectMessage + { + public UUID ID; + + public OSDMap Serialize() + { + OSDMap map = new OSDMap(1); + map["id"] = OSD.FromUUID(ID); + return map; + } + + public void Deserialize(OSDMap map) + { + ID = map["id"].AsUUID(); + } + } + + public class PassObjectReplyMessage + { + public bool Success; + public string Message; + + public OSDMap Serialize() + { + OSDMap map = new OSDMap(2); + map["success"] = OSD.FromBoolean(Success); + map["message"] = OSD.FromString(Message); + return map; + } + + public void Deserialize(OSDMap map) + { + Success = map["success"].AsBoolean(); + Message = map["message"].AsString(); + } + } + + public class FetchTerrainMessage + { + public class FetchTerrainBlock + { + public int X; + public int Y; + } + + public FetchTerrainBlock[] Blocks; + + public OSDMap Serialize() + { + OSDMap map = new OSDMap(1); + + OSDArray array = new OSDArray(Blocks.Length); + for (int i = 0; i < Blocks.Length; i++) + { + OSDMap blockMap = new OSDMap(2); + blockMap["x"] = OSD.FromInteger(Blocks[i].X); + blockMap["y"] = OSD.FromInteger(Blocks[i].Y); + array.Add(blockMap); + } + + map["blocks"] = array; + + return map; + } + + public void Deserialize(OSDMap map) + { + OSDArray array = (OSDArray)map["blocks"]; + + Blocks = new FetchTerrainBlock[array.Count]; + + for (int i = 0; i < array.Count; i++) + { + OSDMap blockMap = (OSDMap)array[i]; + + FetchTerrainBlock block = new FetchTerrainBlock(); + block.X = blockMap["x"].AsInteger(); + block.Y = blockMap["y"].AsInteger(); + Blocks[i] = block; + } + } + } + + public class FetchTerrainReplyMessage + { + public class FetchTerrainReplyBlock + { + public int X; + public int Y; + public byte[] Data; + } + + public FetchTerrainReplyBlock[] Blocks; + + public OSDMap Serialize() + { + OSDMap map = new OSDMap(1); + + OSDArray array = new OSDArray(Blocks.Length); + for (int i = 0; i < Blocks.Length; i++) + { + OSDMap blockMap = new OSDMap(2); + blockMap["x"] = OSD.FromInteger(Blocks[i].X); + blockMap["y"] = OSD.FromInteger(Blocks[i].Y); + blockMap["data"] = OSD.FromBinary(Blocks[i].Data); + array.Add(blockMap); + } + + map["blocks"] = array; + + return map; + } + + public void Deserialize(OSDMap map) + { + OSDArray array = (OSDArray)map["blocks"]; + Blocks = new FetchTerrainReplyBlock[array.Count]; + + for (int i = 0; i < array.Count; i++) + { + OSDMap blockMap = (OSDMap)array[i]; + + FetchTerrainReplyBlock block = new FetchTerrainReplyBlock(); + block.X = blockMap["x"].AsInteger(); + block.Y = blockMap["y"].AsInteger(); + block.Data = blockMap["data"].AsBinary(); + Blocks[i] = block; + } + } + } +} diff --git a/OpenMetaverse/ParcelManager.cs b/OpenMetaverse/ParcelManager.cs index 0d14df0e..11cc8442 100644 --- a/OpenMetaverse/ParcelManager.cs +++ b/OpenMetaverse/ParcelManager.cs @@ -98,7 +98,7 @@ namespace OpenMetaverse /// Sequence ID in ParcelPropertiesReply packets (sent when avatar /// tries to cross a parcel border) /// - public enum ParcelStatus : int + public enum ParcelPropertiesStatus : int { /// Parcel is currently selected ParcelSelected = -10000, @@ -196,6 +196,152 @@ namespace OpenMetaverse BorderSouth = 128 } + /// + /// Various parcel properties + /// + [Flags] + public enum ParcelFlags : uint + { + /// No flags set + None = 0, + /// Allow avatars to fly (a client-side only restriction) + AllowFly = 1 << 0, + /// Allow foreign scripts to run + AllowOtherScripts = 1 << 1, + /// This parcel is for sale + ForSale = 1 << 2, + /// Allow avatars to create a landmark on this parcel + AllowLandmark = 1 << 3, + /// Allows all avatars to edit the terrain on this parcel + AllowTerraform = 1 << 4, + /// Avatars have health and can take damage on this parcel. + /// If set, avatars can be killed and sent home here + AllowDamage = 1 << 5, + /// Foreign avatars can create objects here + CreateObjects = 1 << 6, + /// All objects on this parcel can be purchased + ForSaleObjects = 1 << 7, + /// Access is restricted to a group + UseAccessGroup = 1 << 8, + /// Access is restricted to a whitelist + UseAccessList = 1 << 9, + /// Ban blacklist is enabled + UseBanList = 1 << 10, + /// Unknown + UsePassList = 1 << 11, + /// List this parcel in the search directory + ShowDirectory = 1 << 12, + /// Allow personally owned parcels to be deeded to group + AllowDeedToGroup = 1 << 13, + /// If Deeded, owner contributes required tier to group parcel is deeded to + ContributeWithDeed = 1 << 14, + /// Restrict sounds originating on this parcel to the + /// parcel boundaries + SoundLocal = 1 << 15, + /// Objects on this parcel are sold when the land is + /// purchsaed + SellParcelObjects = 1 << 16, + /// Allow this parcel to be published on the web + AllowPublish = 1 << 17, + /// The information for this parcel is mature content + MaturePublish = 1 << 18, + /// The media URL is an HTML page + UrlWebPage = 1 << 19, + /// The media URL is a raw HTML string + UrlRawHtml = 1 << 20, + /// Restrict foreign object pushes + RestrictPushObject = 1 << 21, + /// Ban all non identified/transacted avatars + DenyAnonymous = 1 << 22, + // Ban all identified avatars [OBSOLETE] + //[Obsolete] + //DenyIdentified = 1 << 23, + // Ban all transacted avatars [OBSOLETE] + //[Obsolete] + //DenyTransacted = 1 << 24, + /// Allow group-owned scripts to run + AllowGroupScripts = 1 << 25, + /// Allow object creation by group members or group + /// objects + CreateGroupObjects = 1 << 26, + /// Allow all objects to enter this parcel + AllowAPrimitiveEntry = 1 << 27, + /// Only allow group and owner objects to enter this parcel + AllowGroupObjectEntry = 1 << 28, + /// Voice Enabled on this parcel + AllowVoiceChat = 1 << 29, + /// Use Estate Voice channel for Voice on this parcel + UseEstateVoiceChan = 1 << 30, + /// Deny Age Unverified Users + DenyAgeUnverified = 1U << 31 + } + + /// + /// Parcel ownership status + /// + public enum ParcelStatus : sbyte + { + /// Placeholder + None = -1, + /// Parcel is leased (owned) by an avatar or group + Leased = 0, + /// Parcel is in process of being leased (purchased) by an avatar or group + LeasePending = 1, + /// Parcel has been abandoned back to Governor Linden + Abandoned = 2 + } + + /// + /// Category parcel is listed in under search + /// + public enum ParcelCategory : sbyte + { + /// No assigned category + None = 0, + /// Linden Infohub or public area + Linden, + /// Adult themed area + Adult, + /// Arts and Culture + Arts, + /// Business + Business, + /// Educational + Educational, + /// Gaming + Gaming, + /// Hangout or Club + Hangout, + /// Newcomer friendly + Newcomer, + /// Parks and Nature + Park, + /// Residential + Residential, + /// Shopping + Shopping, + /// Not Used? + Stage, + /// Other + Other, + /// Not an actual category, only used for queries + Any = -1 + } + + /// + /// Type of teleport landing for a parcel + /// + public enum LandingType : byte + { + /// Unset, simulator default + None = 0, + /// Specific landing point set for this parcel + LandingPoint = 1, + /// No landing point set, direct teleports enabled for + /// this parcel + Direct = 2 + } + #endregion Enums #region Structs @@ -270,156 +416,6 @@ namespace OpenMetaverse /// public struct Parcel { - #region Enums - - /// - /// Various parcel properties - /// - [Flags] - public enum ParcelFlags : uint - { - /// No flags set - None = 0, - /// Allow avatars to fly (a client-side only restriction) - AllowFly = 1 << 0, - /// Allow foreign scripts to run - AllowOtherScripts = 1 << 1, - /// This parcel is for sale - ForSale = 1 << 2, - /// Allow avatars to create a landmark on this parcel - AllowLandmark = 1 << 3, - /// Allows all avatars to edit the terrain on this parcel - AllowTerraform = 1 << 4, - /// Avatars have health and can take damage on this parcel. - /// If set, avatars can be killed and sent home here - AllowDamage = 1 << 5, - /// Foreign avatars can create objects here - CreateObjects = 1 << 6, - /// All objects on this parcel can be purchased - ForSaleObjects = 1 << 7, - /// Access is restricted to a group - UseAccessGroup = 1 << 8, - /// Access is restricted to a whitelist - UseAccessList = 1 << 9, - /// Ban blacklist is enabled - UseBanList = 1 << 10, - /// Unknown - UsePassList = 1 << 11, - /// List this parcel in the search directory - ShowDirectory = 1 << 12, - /// Allow personally owned parcels to be deeded to group - AllowDeedToGroup = 1 << 13, - /// If Deeded, owner contributes required tier to group parcel is deeded to - ContributeWithDeed = 1 << 14, - /// Restrict sounds originating on this parcel to the - /// parcel boundaries - SoundLocal = 1 << 15, - /// Objects on this parcel are sold when the land is - /// purchsaed - SellParcelObjects = 1 << 16, - /// Allow this parcel to be published on the web - AllowPublish = 1 << 17, - /// The information for this parcel is mature content - MaturePublish = 1 << 18, - /// The media URL is an HTML page - UrlWebPage = 1 << 19, - /// The media URL is a raw HTML string - UrlRawHtml = 1 << 20, - /// Restrict foreign object pushes - RestrictPushObject = 1 << 21, - /// Ban all non identified/transacted avatars - DenyAnonymous = 1 << 22, - // Ban all identified avatars [OBSOLETE] - //[Obsolete] - //DenyIdentified = 1 << 23, - // Ban all transacted avatars [OBSOLETE] - //[Obsolete] - //DenyTransacted = 1 << 24, - /// Allow group-owned scripts to run - AllowGroupScripts = 1 << 25, - /// Allow object creation by group members or group - /// objects - CreateGroupObjects = 1 << 26, - /// Allow all objects to enter this parcel - AllowAPrimitiveEntry = 1 << 27, - /// Only allow group and owner objects to enter this parcel - AllowGroupObjectEntry = 1 << 28, - /// Voice Enabled on this parcel - AllowVoiceChat = 1 << 29, - /// Use Estate Voice channel for Voice on this parcel - UseEstateVoiceChan = 1 << 30, - /// Deny Age Unverified Users - DenyAgeUnverified = 1U << 31 - } - - /// - /// Parcel ownership status - /// - public enum ParcelStatus : sbyte - { - /// Placeholder - None = -1, - /// Parcel is leased (owned) by an avatar or group - Leased = 0, - /// Parcel is in process of being leased (purchased) by an avatar or group - LeasePending = 1, - /// Parcel has been abandoned back to Governor Linden - Abandoned = 2 - } - - /// - /// Category parcel is listed in under search - /// - public enum ParcelCategory : sbyte - { - /// No assigned category - None = 0, - /// Linden Infohub or public area - Linden, - /// Adult themed area - Adult, - /// Arts and Culture - Arts, - /// Business - Business, - /// Educational - Educational, - /// Gaming - Gaming, - /// Hangout or Club - Hangout, - /// Newcomer friendly - Newcomer, - /// Parks and Nature - Park, - /// Residential - Residential, - /// Shopping - Shopping, - /// Not Used? - Stage, - /// Other - Other, - /// Not an actual category, only used for queries - Any = -1 - } - - /// - /// Type of teleport landing for a parcel - /// - public enum LandingType : byte - { - /// Unset, simulator default - None = 0, - /// Specific landing point set for this parcel - LandingPoint = 1, - /// No landing point set, direct teleports enabled for - /// this parcel - Direct = 2 - } - - #endregion Enums - /// public int SelfCount; /// @@ -1511,7 +1507,7 @@ namespace OpenMetaverse parcel.AuctionID = (uint)parcelDataBlock["AuctionID"].AsInteger(); parcel.AuthBuyerID = parcelDataBlock["AuthBuyerID"].AsUUID(); parcel.Bitmap = parcelDataBlock["Bitmap"].AsBinary(); - parcel.Category = (Parcel.ParcelCategory)parcelDataBlock["Category"].AsInteger(); + parcel.Category = (ParcelCategory)parcelDataBlock["Category"].AsInteger(); parcel.ClaimDate = Utils.UnixTimeToDateTime((uint)parcelDataBlock["ClaimDate"].AsInteger()); parcel.ClaimPrice = parcelDataBlock["ClaimPrice"].AsInteger(); parcel.Desc = parcelDataBlock["Desc"].AsString(); @@ -1520,11 +1516,11 @@ namespace OpenMetaverse byte[] bytes = parcelDataBlock["ParcelFlags"].AsBinary(); if (BitConverter.IsLittleEndian) Array.Reverse(bytes); - parcel.Flags = (Parcel.ParcelFlags)BitConverter.ToUInt32(bytes, 0); + parcel.Flags = (ParcelFlags)BitConverter.ToUInt32(bytes, 0); parcel.GroupID = parcelDataBlock["GroupID"].AsUUID(); parcel.GroupPrims = parcelDataBlock["GroupPrims"].AsInteger(); parcel.IsGroupOwned = parcelDataBlock["IsGroupOwned"].AsBoolean(); - parcel.Landing = (Parcel.LandingType)(byte)parcelDataBlock["LandingType"].AsInteger(); + parcel.Landing = (LandingType)(byte)parcelDataBlock["LandingType"].AsInteger(); parcel.LocalID = parcelDataBlock["LocalID"].AsInteger(); parcel.MaxPrims = parcelDataBlock["MaxPrims"].AsInteger(); parcel.Media.MediaAutoScale = (byte)parcelDataBlock["MediaAutoScale"].AsInteger(); @@ -1554,7 +1550,7 @@ namespace OpenMetaverse parcel.SimWideTotalPrims = parcelDataBlock["SimWideTotalPrims"].AsInteger(); bool snapSelection = parcelDataBlock["SnapSelection"].AsBoolean(); parcel.SnapshotID = parcelDataBlock["SnapshotID"].AsUUID(); - parcel.Status = (Parcel.ParcelStatus)parcelDataBlock["Status"].AsInteger(); + parcel.Status = (ParcelStatus)parcelDataBlock["Status"].AsInteger(); parcel.TotalPrims = parcelDataBlock["TotalPrims"].AsInteger(); parcel.UserLocation = ((OSDArray)parcelDataBlock["UserLocation"]).AsVector3(); parcel.UserLookAt = ((OSDArray)parcelDataBlock["UserLookAt"]).AsVector3(); diff --git a/OpenMetaverse/Types/Enums.cs b/OpenMetaverse/Types/Enums.cs new file mode 100644 index 00000000..272c43cd --- /dev/null +++ b/OpenMetaverse/Types/Enums.cs @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2009, openmetaverse.org + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the openmetaverse.org nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; + +namespace OpenMetaverse +{ + /// + /// The different types of grid assets + /// + public enum AssetType : sbyte + { + /// Unknown asset type + Unknown = -1, + /// Texture asset, stores in JPEG2000 J2C stream format + Texture = 0, + /// Sound asset + Sound = 1, + /// Calling card for another avatar + CallingCard = 2, + /// Link to a location in world + Landmark = 3, + // Legacy script asset, you should never see one of these + //[Obsolete] + //Script = 4, + /// Collection of textures and parameters that can be + /// worn by an avatar + Clothing = 5, + /// Primitive that can contain textures, sounds, + /// scripts and more + Object = 6, + /// Notecard asset + Notecard = 7, + /// Holds a collection of inventory items + Folder = 8, + /// Root inventory folder + RootFolder = 9, + /// Linden scripting language script + LSLText = 10, + /// LSO bytecode for a script + LSLBytecode = 11, + /// Uncompressed TGA texture + TextureTGA = 12, + /// Collection of textures and shape parameters that can + /// be worn + Bodypart = 13, + /// Trash folder + TrashFolder = 14, + /// Snapshot folder + SnapshotFolder = 15, + /// Lost and found folder + LostAndFoundFolder = 16, + /// Uncompressed sound + SoundWAV = 17, + /// Uncompressed TGA non-square image, not to be used as a + /// texture + ImageTGA = 18, + /// Compressed JPEG non-square image, not to be used as a + /// texture + ImageJPEG = 19, + /// Animation + Animation = 20, + /// Sequence of animations, sounds, chat, and pauses + Gesture = 21, + /// Simstate file + Simstate = 22, + } + + /// + /// Inventory Item Types, eg Script, Notecard, Folder, etc + /// + public enum InventoryType : sbyte + { + /// Unknown + Unknown = -1, + /// Texture + Texture = 0, + /// Sound + Sound = 1, + /// Calling Card + CallingCard = 2, + /// Landmark + Landmark = 3, + /* + /// Script + //[Obsolete("See LSL")] Script = 4, + /// Clothing + //[Obsolete("See Wearable")] Clothing = 5, + /// Object, both single and coalesced + */ + Object = 6, + /// Notecard + Notecard = 7, + /// + Category = 8, + /// Folder + Folder = 8, + /// + RootCategory = 9, + /// an LSL Script + LSL = 10, + /* + /// + //[Obsolete("See LSL")] LSLBytecode = 11, + /// + //[Obsolete("See Texture")] TextureTGA = 12, + /// + //[Obsolete] Bodypart = 13, + /// + //[Obsolete] Trash = 14, + */ + /// + Snapshot = 15, + /* + /// + //[Obsolete] LostAndFound = 16, + */ + /// + Attachment = 17, + /// + Wearable = 18, + /// + Animation = 19, + /// + Gesture = 20 + } + + /// + /// Item Sale Status + /// + public enum SaleType : byte + { + /// Not for sale + Not = 0, + /// The original is for sale + Original = 1, + /// Copies are for sale + Copy = 2, + /// The contents of the object are for sale + Contents = 3 + } +} diff --git a/OpenMetaverse/Types/UtilsConversions.cs b/OpenMetaverse/Types/UtilsConversions.cs index 280610cf..6c5039ab 100644 --- a/OpenMetaverse/Types/UtilsConversions.cs +++ b/OpenMetaverse/Types/UtilsConversions.cs @@ -31,6 +31,70 @@ namespace OpenMetaverse { public static partial class Utils { + #region String Arrays + + private static readonly string[] _AssetTypeNames = new string[] + { + "texture", + "sound", + "callcard", + "landmark", + "script", + "clothing", + "object", + "notecard", + "category", + "root", + "lsltext", + "lslbyte", + "txtr_tga", + "bodypart", + "trash", + "snapshot", + "lstndfnd", + "snd_wav", + "img_tga", + "jpeg", + "animatn", + "gesture", + "simstate" + }; + + private static readonly string[] _InventoryTypeNames = new string[] + { + "texture", + "sound", + "callcard", + "landmark", + String.Empty, + String.Empty, + "object", + "notecard", + "category", + "root", + "script", + String.Empty, + String.Empty, + String.Empty, + String.Empty, + "snapshot", + String.Empty, + "attach", + "wearable", + "animation", + "gesture", + }; + + private static readonly string[] _SaleTypeNames = new string[] + { + "not", + "orig", + "copy", + "cntn" + }; + + #endregion String Arrays + #region BytesTo /// @@ -724,6 +788,88 @@ namespace OpenMetaverse #endregion TryParse + #region Enum String Conversion + + /// + /// Takes an AssetType and returns the string representation + /// + /// The source + /// The string version of the AssetType + public static string AssetTypeToString(AssetType type) + { + return _AssetTypeNames[(int)type]; + } + + /// + /// Translate a string name of an AssetType into the proper Type + /// + /// A string containing the AssetType name + /// The AssetType which matches the string name, or AssetType.Unknown if no match was found + public static AssetType StringToAssetType(string type) + { + for (int i = 0; i < _AssetTypeNames.Length; i++) + { + if (_AssetTypeNames[i] == type) + return (AssetType)i; + } + + return AssetType.Unknown; + } + + /// + /// Convert an InventoryType to a string + /// + /// The to convert + /// A string representation of the source + public static string InventoryTypeToString(InventoryType type) + { + return _InventoryTypeNames[(int)type]; + } + + /// + /// Convert a string into a valid InventoryType + /// + /// A string representation of the InventoryType to convert + /// A InventoryType object which matched the type + public static InventoryType StringToInventoryType(string type) + { + for (int i = 0; i < _InventoryTypeNames.Length; i++) + { + if (_InventoryTypeNames[i] == type) + return (InventoryType)i; + } + + return InventoryType.Unknown; + } + + /// + /// Convert a SaleType to a string + /// + /// The to convert + /// A string representation of the source + public static string SaleTypeToString(SaleType type) + { + return _SaleTypeNames[(int)type]; + } + + /// + /// Convert a string into a valid SaleType + /// + /// A string representation of the SaleType to convert + /// A SaleType object which matched the type + public static SaleType StringToSaleType(string value) + { + for (int i = 0; i < _SaleTypeNames.Length; i++) + { + if (value == _SaleTypeNames[i]) + return (SaleType)i; + } + + return SaleType.Not; + } + + #endregion Enum String Conversion + #region Miscellaneous /// diff --git a/prebuild.xml b/prebuild.xml index f1ed0b67..7e45a94b 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -168,6 +168,7 @@ +