public void SLUtilTypeConvertTests()
        {
            int[] assettypes = new int[] { -1, 0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22
                                           , 23, 24, 25, 46, 47, 48 };
            string[] contenttypes = new string[]
            {
                "application/octet-stream",
                "image/x-j2c",
                "audio/ogg",
                "application/vnd.ll.callingcard",
                "application/vnd.ll.landmark",
                "application/vnd.ll.clothing",
                "application/vnd.ll.primitive",
                "application/vnd.ll.notecard",
                "application/vnd.ll.folder",
                "application/vnd.ll.rootfolder",
                "application/vnd.ll.lsltext",
                "application/vnd.ll.lslbyte",
                "image/tga",
                "application/vnd.ll.bodypart",
                "application/vnd.ll.trashfolder",
                "application/vnd.ll.snapshotfolder",
                "application/vnd.ll.lostandfoundfolder",
                "audio/x-wav",
                "image/tga",
                "image/jpeg",
                "application/vnd.ll.animation",
                "application/vnd.ll.gesture",
                "application/x-metaverse-simstate",
                "application/vnd.ll.favoritefolder",
                "application/vnd.ll.link",
                "application/vnd.ll.linkfolder",
                "application/vnd.ll.currentoutfitfolder",
                "application/vnd.ll.outfitfolder",
                "application/vnd.ll.myoutfitsfolder"
            };
            for (int i = 0; i < assettypes.Length; i++)
            {
                Assert.That(SLUtil.SLAssetTypeToContentType(assettypes[i]) == contenttypes[i], "Expecting {0} but got {1}", contenttypes[i], SLUtil.SLAssetTypeToContentType(assettypes[i]));
            }

            for (int i = 0; i < contenttypes.Length; i++)
            {
                int expected;
                if (contenttypes[i] == "image/tga")
                {
                    expected = 12;  // if we know only the content-type "image/tga", then we assume the asset type is TextureTGA; not ImageTGA
                }
                else
                {
                    expected = assettypes[i];
                }
                Assert.AreEqual(expected, SLUtil.ContentTypeToSLAssetType(contenttypes[i]),
                                String.Format("Incorrect AssetType mapped from Content-Type {0}", contenttypes[i]));
            }

            int[]    inventorytypes  = new int[] { -1, 0, 1, 2, 3, 6, 7, 8, 9, 10, 15, 17, 18, 20 };
            string[] invcontenttypes = new string[]
            {
                "application/octet-stream",
                "image/x-j2c",
                "audio/ogg",
                "application/vnd.ll.callingcard",
                "application/vnd.ll.landmark",
                "application/vnd.ll.primitive",
                "application/vnd.ll.notecard",
                "application/vnd.ll.folder",
                "application/vnd.ll.rootfolder",
                "application/vnd.ll.lsltext",
                "image/x-j2c",
                "application/vnd.ll.primitive",
                "application/vnd.ll.clothing",
                "application/vnd.ll.gesture"
            };

            for (int i = 0; i < inventorytypes.Length; i++)
            {
                Assert.AreEqual(invcontenttypes[i], SLUtil.SLInvTypeToContentType(inventorytypes[i]),
                                String.Format("Incorrect Content-Type mapped from InventoryType {0}", inventorytypes[i]));
            }

            invcontenttypes = new string[]
            {
                "image/x-j2c", "image/jp2", "image/tga",
                "image/jpeg", "application/ogg", "audio/ogg",
                "audio/x-wav", "application/vnd.ll.callingcard",
                "application/x-metaverse-callingcard",
                "application/vnd.ll.landmark",
                "application/x-metaverse-landmark",
                "application/vnd.ll.clothing",
                "application/x-metaverse-clothing", "application/vnd.ll.bodypart",
                "application/x-metaverse-bodypart", "application/vnd.ll.primitive",
                "application/x-metaverse-primitive", "application/vnd.ll.notecard",
                "application/x-metaverse-notecard", "application/vnd.ll.folder",
                "application/vnd.ll.rootfolder", "application/vnd.ll.lsltext",
                "application/x-metaverse-lsl", "application/vnd.ll.lslbyte",
                "application/x-metaverse-lso", "application/vnd.ll.trashfolder",
                "application/vnd.ll.snapshotfolder",
                "application/vnd.ll.lostandfoundfolder", "application/vnd.ll.animation",
                "application/x-metaverse-animation", "application/vnd.ll.gesture",
                "application/x-metaverse-gesture", "application/x-metaverse-simstate",
                "application/octet-stream"
            };
            sbyte[] invtypes = new sbyte[]
            {
                0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 18, 18, 18, 18, 6, 6, 7, 7, 8, 9, 10, 10, 10, 10
                , 8, 8, 8, 19, 19, 20, 20, 15, -1
            };

            for (int i = 0; i < invtypes.Length; i++)
            {
                Assert.AreEqual(invtypes[i], SLUtil.ContentTypeToSLInvType(invcontenttypes[i]),
                                String.Format("Incorrect InventoryType mapped from Content-Type {0}", invcontenttypes[i]));
            }
        }
        private List <InventoryItemBase> GetItemsFromResponse(OSDArray items)
        {
            List <InventoryItemBase> invItems = new List <InventoryItemBase>(items.Count);

            for (int i = 0; i < items.Count; i++)
            {
                OSDMap item = items[i] as OSDMap;

                if (item != null && item["Type"].AsString() == "Item")
                {
                    InventoryItemBase invItem = new InventoryItemBase();

                    invItem.AssetID         = item["AssetID"].AsUUID();
                    invItem.AssetType       = SLUtil.ContentTypeToSLAssetType(item["ContentType"].AsString());
                    invItem.CreationDate    = item["CreationDate"].AsInteger();
                    invItem.CreatorId       = item["CreatorID"].AsString();
                    invItem.CreatorData     = item["CreatorData"].AsString();
                    invItem.CreatorIdAsUuid = item["CreatorID"].AsUUID();
                    invItem.Description     = item["Description"].AsString();
                    invItem.Folder          = item["ParentID"].AsUUID();
                    invItem.ID      = item["ID"].AsUUID();
                    invItem.InvType = SLUtil.ContentTypeToSLInvType(item["ContentType"].AsString());
                    invItem.Name    = item["Name"].AsString();
                    invItem.Owner   = item["OwnerID"].AsUUID();

                    OSDMap extraData = item["ExtraData"] as OSDMap;
                    if (extraData != null && extraData.Count > 0)
                    {
                        invItem.Flags      = extraData["Flags"].AsUInteger();
                        invItem.GroupID    = extraData["GroupID"].AsUUID();
                        invItem.GroupOwned = extraData["GroupOwned"].AsBoolean();
                        invItem.SalePrice  = extraData["SalePrice"].AsInteger();
                        invItem.SaleType   = (byte)extraData["SaleType"].AsInteger();

                        OSDMap perms = extraData["Permissions"] as OSDMap;
                        if (perms != null)
                        {
                            invItem.BasePermissions     = perms["BaseMask"].AsUInteger();
                            invItem.CurrentPermissions  = perms["OwnerMask"].AsUInteger();
                            invItem.EveryOnePermissions = perms["EveryoneMask"].AsUInteger();
                            invItem.GroupPermissions    = perms["GroupMask"].AsUInteger();
                            invItem.NextPermissions     = perms["NextOwnerMask"].AsUInteger();
                        }

                        if (extraData.ContainsKey("LinkedItemType"))
                        {
                            invItem.AssetType = SLUtil.ContentTypeToSLAssetType(extraData["LinkedItemType"].AsString());
                        }
                    }

                    if (invItem.BasePermissions == 0)
                    {
                        m_log.InfoFormat("[SIMIAN INVENTORY CONNECTOR]: Forcing item permissions to full for item {0} ({1})",
                                         invItem.Name, invItem.ID);
                        invItem.BasePermissions     = (uint)PermissionMask.All;
                        invItem.CurrentPermissions  = (uint)PermissionMask.All;
                        invItem.EveryOnePermissions = (uint)PermissionMask.All;
                        invItem.GroupPermissions    = (uint)PermissionMask.All;
                        invItem.NextPermissions     = (uint)PermissionMask.All;
                    }

                    invItems.Add(invItem);
                }
            }

//            m_log.Debug("[SIMIAN INVENTORY CONNECTOR]: Parsed " + invItems.Count + " items from SimianGrid response");
            return(invItems);
        }
Esempio n. 3
0
        public void SLUtilTypeConvertTests()
        {
            int[] assettypes = new int[] { -1, 0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22
                                           , 23, 24, 25, 46, 47, 48 };
            string[] contenttypes = new string[]
            {
                "application/octet-stream",
                "image/x-j2c",
                "audio/ogg",
                "application/vnd.ll.callingcard",
                "application/vnd.ll.landmark",
                "application/vnd.ll.clothing",
                "application/vnd.ll.primitive",
                "application/vnd.ll.notecard",
                "application/vnd.ll.folder",
                "application/vnd.ll.rootfolder",
                "application/vnd.ll.lsltext",
                "application/vnd.ll.lslbyte",
                "image/tga",
                "application/vnd.ll.bodypart",
                "application/vnd.ll.trashfolder",
                "application/vnd.ll.snapshotfolder",
                "application/vnd.ll.lostandfoundfolder",
                "audio/x-wav",
                "image/tga",
                "image/jpeg",
                "application/vnd.ll.animation",
                "application/vnd.ll.gesture",
                "application/x-metaverse-simstate",
                "application/vnd.ll.favoritefolder",
                "application/vnd.ll.link",
                "application/vnd.ll.linkfolder",
                "application/vnd.ll.currentoutfitfolder",
                "application/vnd.ll.outfitfolder",
                "application/vnd.ll.myoutfitsfolder"
            };
            for (int i = 0; i < assettypes.Length; i++)
            {
                Assert.That(SLUtil.SLAssetTypeToContentType(assettypes[i]) == contenttypes[i], "Expecting {0} but got {1}", contenttypes[i], SLUtil.SLAssetTypeToContentType(assettypes[i]));
            }

            for (int i = 0; i < contenttypes.Length; i++)
            {
                if (SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == 18)
                {
                    Assert.That(contenttypes[i] == "image/tga");
                }
                else
                {
                    Assert.That(SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == assettypes[i],
                                "Expecting {0} but got {1}", assettypes[i],
                                SLUtil.ContentTypeToSLAssetType(contenttypes[i]));
                }
            }

            int[]    inventorytypes  = new int[] { -1, 0, 1, 2, 3, 6, 7, 8, 9, 10, 15, 17, 18, 20 };
            string[] invcontenttypes = new string[]
            {
                "application/octet-stream",
                "image/x-j2c",
                "audio/ogg",
                "application/vnd.ll.callingcard",
                "application/vnd.ll.landmark",
                "application/vnd.ll.primitive",
                "application/vnd.ll.notecard",
                "application/vnd.ll.folder",
                "application/octet-stream",
                "application/vnd.ll.lsltext",
                "image/x-j2c",
                "application/vnd.ll.primitive",
                "application/vnd.ll.clothing",
                "application/vnd.ll.gesture"
            };

            for (int i = 0; i < inventorytypes.Length; i++)
            {
                Assert.That(SLUtil.SLInvTypeToContentType(inventorytypes[i]) == invcontenttypes[i], "Expected {0}, Got {1}", invcontenttypes[i], SLUtil.SLInvTypeToContentType(inventorytypes[i]));
            }

            invcontenttypes = new string[]
            {
                "image/x-j2c", "image/jp2", "image/tga",
                "image/jpeg", "application/ogg", "audio/ogg",
                "audio/x-wav", "application/vnd.ll.callingcard",
                "application/x-metaverse-callingcard",
                "application/vnd.ll.landmark",
                "application/x-metaverse-landmark",
                "application/vnd.ll.clothing",
                "application/x-metaverse-clothing", "application/vnd.ll.bodypart",
                "application/x-metaverse-bodypart", "application/vnd.ll.primitive",
                "application/x-metaverse-primitive", "application/vnd.ll.notecard",
                "application/x-metaverse-notecard", "application/vnd.ll.folder",
                "application/vnd.ll.rootfolder", "application/vnd.ll.lsltext",
                "application/x-metaverse-lsl", "application/vnd.ll.lslbyte",
                "application/x-metaverse-lso", "application/vnd.ll.trashfolder",
                "application/vnd.ll.snapshotfolder",
                "application/vnd.ll.lostandfoundfolder", "application/vnd.ll.animation",
                "application/x-metaverse-animation", "application/vnd.ll.gesture",
                "application/x-metaverse-gesture", "application/x-metaverse-simstate",
                "application/octet-stream"
            };
            sbyte[] invtypes = new sbyte[]
            {
                0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 18, 18, 18, 18, 6, 6, 7, 7, 8, 9, 10, 10, 10, 10
                , 8, 8, 8, 19, 19, 20, 20, 15, -1
            };

            for (int i = 0; i < invtypes.Length; i++)
            {
                Assert.That(SLUtil.ContentTypeToSLInvType(invcontenttypes[i]) == invtypes[i], "Expected {0}, Got {1}", invtypes[i], SLUtil.ContentTypeToSLInvType(invcontenttypes[i]));
            }
        }