예제 #1
0
        /// <summary>
        /// Create an inventory item and upload asset data
        /// </summary>
        /// <param name="data">Asset data</param>
        /// <param name="name">Inventory item name</param>
        /// <param name="description">Inventory item description</param>
        /// <param name="assetType">Asset type</param>
        /// <param name="invType">Inventory type</param>
        /// <param name="folderID">Put newly created inventory in this folder</param>
        /// <param name="callback">Delegate that will receive feedback on success or failure</param>
        public void RequestCreateItemFromAsset(byte[] data, string name, string description, AssetType assetType,
            InventoryType invType, UUID folderID, ItemCreatedFromAssetCallback callback)
        {
            Permissions permissions = new Permissions();
            permissions.EveryoneMask = PermissionMask.None;
            permissions.GroupMask = PermissionMask.None;
            permissions.NextOwnerMask = PermissionMask.All;

            RequestCreateItemFromAsset(data, name, description, assetType, invType, folderID, permissions, callback);
        }
예제 #2
0
        public static Permissions FromOSD(OSD llsd)
        {
            Permissions permissions = new Permissions();
            OSDMap map = llsd as OSDMap;

            if (map != null)
            {
                permissions.BaseMask = (PermissionMask)map["base_mask"].AsUInteger();
                permissions.EveryoneMask = (PermissionMask)map["everyone_mask"].AsUInteger();
                permissions.GroupMask = (PermissionMask)map["group_mask"].AsUInteger();
                permissions.NextOwnerMask = (PermissionMask)map["next_owner_mask"].AsUInteger();
                permissions.OwnerMask = (PermissionMask)map["owner_mask"].AsUInteger();
            }

            return permissions;
        }
예제 #3
0
 public bool Equals(Permissions other)
 {
     return this == other;
 }
예제 #4
0
 /// <summary>
 /// Attach an item to our agent specifying attachment details
 /// </summary>
 /// <param name="itemID">The <seealso cref="OpenMetaverse.UUID"/> of the item to attach</param>
 /// <param name="ownerID">The <seealso cref="OpenMetaverse.UUID"/> attachments owner</param>
 /// <param name="name">The name of the attachment</param>
 /// <param name="description">The description of the attahment</param>
 /// <param name="perms">The <seealso cref="OpenMetaverse.Permissions"/> to apply when attached</param>
 /// <param name="itemFlags">The <seealso cref="OpenMetaverse.InventoryItemFlags"/> of the attachment</param>
 /// <param name="attachPoint">The <seealso cref="OpenMetaverse.AttachmentPoint"/> on the agent
 /// to attach the item to</param>
 public void Attach(UUID itemID, UUID ownerID, string name, string description,
     Permissions perms, uint itemFlags, AttachmentPoint attachPoint)
 {
     Attach(itemID, ownerID, name, description, perms, itemFlags, attachPoint, true);
 }
예제 #5
0
        /// <summary>
        /// Attach an item to our agent specifying attachment details
        /// </summary>
        /// <param name="itemID">The <seealso cref="OpenMetaverse.UUID"/> of the item to attach</param>
        /// <param name="ownerID">The <seealso cref="OpenMetaverse.UUID"/> attachments owner</param>
        /// <param name="name">The name of the attachment</param>
        /// <param name="description">The description of the attahment</param>
        /// <param name="perms">The <seealso cref="OpenMetaverse.Permissions"/> to apply when attached</param>
        /// <param name="itemFlags">The <seealso cref="OpenMetaverse.InventoryItemFlags"/> of the attachment</param>
        /// <param name="attachPoint">The <seealso cref="OpenMetaverse.AttachmentPoint"/> on the agent
        /// <param name="replace">If true replace existing attachment on this attachment point, otherwise add to it (multi-attachments)</param>
        /// to attach the item to</param>
        public void Attach(UUID itemID, UUID ownerID, string name, string description,
            Permissions perms, uint itemFlags, AttachmentPoint attachPoint, bool replace)
        {
            // TODO: At some point it might be beneficial to have AppearanceManager track what we
            // are currently wearing for attachments to make enumeration and detachment easier
            RezSingleAttachmentFromInvPacket attach = new RezSingleAttachmentFromInvPacket();

            attach.AgentData.AgentID = Client.Self.AgentID;
            attach.AgentData.SessionID = Client.Self.SessionID;

            attach.ObjectData.AttachmentPt = replace ? (byte)attachPoint : (byte)(ATTACHMENT_ADD | (byte)attachPoint);
            attach.ObjectData.Description = Utils.StringToBytes(description);
            attach.ObjectData.EveryoneMask = (uint)perms.EveryoneMask;
            attach.ObjectData.GroupMask = (uint)perms.GroupMask;
            attach.ObjectData.ItemFlags = itemFlags;
            attach.ObjectData.ItemID = itemID;
            attach.ObjectData.Name = Utils.StringToBytes(name);
            attach.ObjectData.NextOwnerMask = (uint)perms.NextOwnerMask;
            attach.ObjectData.OwnerID = ownerID;

            Client.Network.SendPacket(attach);
        }
        private void btnUpload_Click(object sender, EventArgs e)
        {
            txtStatus.AppendText("Uploading...");
            btnLoad.Enabled = false;
            btnUpload.Enabled = false;
            AssetID = InventoryID = UUID.Zero;

            string name = Path.GetFileNameWithoutExtension(FileName);
            string desc = string.Format("Uploaded with Radegast on {0}", DateTime.Now.ToLongDateString());

            Permissions perms = new Permissions();
            perms.EveryoneMask = PermissionMask.All;
            perms.NextOwnerMask = PermissionMask.All;

            client.Inventory.RequestCreateItemFromAsset(UploadData, name, desc, AssetType.Texture, InventoryType.Texture,
                client.Inventory.FindFolderForType(AssetType.Texture), perms, UploadHandler);
        }
예제 #7
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            bool tmp = chkTemp.Checked;
            txtStatus.AppendText("Uploading...");
            btnLoad.Enabled = false;
            btnUpload.Enabled = false;
            AssetID = InventoryID = UUID.Zero;

            TextureName = Path.GetFileNameWithoutExtension(FileName);
            if (tmp) TextureName += " (temp)";
            TextureDescription = string.Format("Uploaded with Radegast on {0}", DateTime.Now.ToLongDateString());

            Permissions perms = new Permissions();
            perms.EveryoneMask = PermissionMask.All;
            perms.NextOwnerMask = PermissionMask.All;

            if (!tmp)
            {
                client.Settings.CAPS_TIMEOUT = 180 * 1000;
                client.Inventory.RequestCreateItemFromAsset(UploadData, TextureName, TextureDescription, AssetType.Texture, InventoryType.Texture,
                    client.Inventory.FindFolderForType(AssetType.Texture), perms, UploadHandler);
            }
            else
            {
                TransactionID = UUID.Random();
                client.Assets.RequestUpload(out AssetID, AssetType.Texture, UploadData, true, TransactionID);
            }
        }
예제 #8
0
        /// <summary>
        /// Decode the raw asset data including the Linden Text properties
        /// </summary>
        /// <returns>true if the AssetData was successfully decoded</returns>
        public override bool Decode()
        {
            string data = Utils.BytesToString(AssetData);
            EmbeddedItems = new List<InventoryItem>();
            BodyText = string.Empty;

            try
            {
                string[] lines = data.Split('\n');
                int i = 0;
                Match m;

                // Version
                if (!(m = Regex.Match(lines[i++], @"Linden text version\s+(\d+)")).Success)
                    throw new Exception("could not determine version");
                int notecardVersion = int.Parse(m.Groups[1].Value);
                if (notecardVersion < 1 || notecardVersion > 2)
                    throw new Exception("unsuported version");
                if (!(m = Regex.Match(lines[i++], @"\s*{$")).Success)
                    throw new Exception("wrong format");

                // Embedded items header
                if (!(m = Regex.Match(lines[i++], @"LLEmbeddedItems version\s+(\d+)")).Success)
                    throw new Exception("could not determine embedded items version version");
                if (m.Groups[1].Value != "1")
                    throw new Exception("unsuported embedded item version");
                if (!(m = Regex.Match(lines[i++], @"\s*{$")).Success)
                    throw new Exception("wrong format");

                // Item count
                if (!(m = Regex.Match(lines[i++], @"count\s+(\d+)")).Success)
                    throw new Exception("wrong format");
                int count = int.Parse(m.Groups[1].Value);

                // Decode individual items
                for (int n = 0; n < count; n++)
                {
                    if (!(m = Regex.Match(lines[i++], @"\s*{$")).Success)
                        throw new Exception("wrong format");

                    // Index
                    if (!(m = Regex.Match(lines[i++], @"ext char index\s+(\d+)")).Success)
                        throw new Exception("missing ext char index");
                    //warning CS0219: The variable `index' is assigned but its value is never used
                    //int index = int.Parse(m.Groups[1].Value);

                    // Inventory item
                    if (!(m = Regex.Match(lines[i++], @"inv_item\s+0")).Success)
                        throw new Exception("missing inv item");

                    // Item itself
                    UUID uuid = UUID.Zero;
                    UUID creatorID = UUID.Zero;
                    UUID ownerID = UUID.Zero;
                    UUID lastOwnerID = UUID.Zero;
                    UUID groupID = UUID.Zero;
                    Permissions permissions = Permissions.NoPermissions;
                    int salePrice = 0;
                    SaleType saleType = SaleType.Not;
                    UUID parentUUID = UUID.Zero;
                    UUID assetUUID = UUID.Zero;
                    AssetType assetType = AssetType.Unknown;
                    InventoryType inventoryType = InventoryType.Unknown;
                    uint flags = 0;
                    string name = string.Empty;
                    string description = string.Empty;
                    DateTime creationDate = Utils.Epoch;

                    while (true)
                    {
                        if (!(m = Regex.Match(lines[i++], @"([^\s]+)(\s+)?(.*)?")).Success)
                            throw new Exception("wrong format");
                        string key = m.Groups[1].Value;
                        string val = m.Groups[3].Value;
                        if (key == "{")
                            continue;
                        if (key == "}")
                            break;
                        else if (key == "permissions")
                        {
                            uint baseMask = 0;
                            uint ownerMask = 0;
                            uint groupMask = 0;
                            uint everyoneMask = 0;
                            uint nextOwnerMask = 0;

                            while (true)
                            {
                                if (!(m = Regex.Match(lines[i++], @"([^\s]+)(\s+)?([^\s]+)?")).Success)
                                    throw new Exception("wrong format");
                                string pkey = m.Groups[1].Value;
                                string pval = m.Groups[3].Value;

                                if (pkey == "{")
                                    continue;
                                if (pkey == "}")
                                    break;
                                else if (pkey == "creator_id")
                                {
                                    creatorID = new UUID(pval);
                                }
                                else if (pkey == "owner_id")
                                {
                                    ownerID = new UUID(pval);
                                }
                                else if (pkey == "last_owner_id")
                                {
                                    lastOwnerID = new UUID(pval);
                                }
                                else if (pkey == "group_id")
                                {
                                    groupID = new UUID(pval);
                                }
                                else if (pkey == "base_mask")
                                {
                                    baseMask = uint.Parse(pval, System.Globalization.NumberStyles.AllowHexSpecifier);
                                }
                                else if (pkey == "owner_mask")
                                {
                                    ownerMask = uint.Parse(pval, System.Globalization.NumberStyles.AllowHexSpecifier);
                                }
                                else if (pkey == "group_mask")
                                {
                                    groupMask = uint.Parse(pval, System.Globalization.NumberStyles.AllowHexSpecifier);
                                }
                                else if (pkey == "everyone_mask")
                                {
                                    everyoneMask = uint.Parse(pval, System.Globalization.NumberStyles.AllowHexSpecifier);
                                }
                                else if (pkey == "next_owner_mask")
                                {
                                    nextOwnerMask = uint.Parse(pval, System.Globalization.NumberStyles.AllowHexSpecifier);
                                }
                            }
                            permissions = new Permissions(baseMask, everyoneMask, groupMask, nextOwnerMask, ownerMask);
                        }
                        else if (key == "sale_info")
                        {
                            while (true)
                            {
                                if (!(m = Regex.Match(lines[i++], @"([^\s]+)(\s+)?([^\s]+)?")).Success)
                                    throw new Exception("wrong format");
                                string pkey = m.Groups[1].Value;
                                string pval = m.Groups[3].Value;

                                if (pkey == "{")
                                    continue;
                                if (pkey == "}")
                                    break;
                                else if (pkey == "sale_price")
                                {
                                    salePrice = int.Parse(pval);
                                }
                                else if (pkey == "sale_type")
                                {
                                    saleType = Utils.StringToSaleType(pval);
                                }
                            }
                        }
                        else if (key == "item_id")
                        {
                            uuid = new UUID(val);
                        }
                        else if (key == "parent_id")
                        {
                            parentUUID = new UUID(val);
                        }
                        else if (key == "asset_id")
                        {
                            assetUUID = new UUID(val);
                        }
                        else if (key == "type")
                        {
                            assetType = Utils.StringToAssetType(val);
                        }
                        else if (key == "inv_type")
                        {
                            inventoryType = Utils.StringToInventoryType(val);
                        }
                        else if (key == "flags")
                        {
                            flags = uint.Parse(val, System.Globalization.NumberStyles.AllowHexSpecifier);
                        }
                        else if (key == "name")
                        {
                            name = val.Remove(val.LastIndexOf("|"));
                        }
                        else if (key == "desc")
                        {
                            description = val.Remove(val.LastIndexOf("|"));
                        }
                        else if (key == "creation_date")
                        {
                            creationDate = Utils.UnixTimeToDateTime(int.Parse(val));
                        }
                    }
                    InventoryItem finalEmbedded = InventoryManager.CreateInventoryItem(inventoryType, uuid);

                    finalEmbedded.CreatorID = creatorID;
                    finalEmbedded.OwnerID = ownerID;
                    finalEmbedded.LastOwnerID = lastOwnerID;
                    finalEmbedded.GroupID = groupID;
                    finalEmbedded.Permissions = permissions;
                    finalEmbedded.SalePrice = salePrice;
                    finalEmbedded.SaleType = saleType;
                    finalEmbedded.ParentUUID = parentUUID;
                    finalEmbedded.AssetUUID = assetUUID;
                    finalEmbedded.AssetType = assetType;
                    finalEmbedded.Flags = flags;
                    finalEmbedded.Name = name;
                    finalEmbedded.Description = description;
                    finalEmbedded.CreationDate = creationDate;

                    EmbeddedItems.Add(finalEmbedded);

                    if (!(m = Regex.Match(lines[i++], @"\s*}$")).Success)
                        throw new Exception("wrong format");

                }

                // Text size
                if (!(m = Regex.Match(lines[i++], @"\s*}$")).Success)
                    throw new Exception("wrong format");
                if (!(m = Regex.Match(lines[i++], @"Text length\s+(\d+)")).Success)
                    throw new Exception("could not determine text length");

                // Read the rest of the notecard
                while (i < lines.Length)
                {
                    BodyText += lines[i++] + "\n";
                }
                BodyText = BodyText.Remove(BodyText.LastIndexOf("}"));
                return true;
            }
            catch (Exception ex)
            {
                Logger.Log("Decoding notecard asset failed: " + ex.Message, Helpers.LogLevel.Error);
                return false;
            }
        }
예제 #9
0
        public override bool Decode()
        {
            int version = -1;
            Permissions = new Permissions();
            string data = Utils.BytesToString(AssetData);

            data = data.Replace("\r", String.Empty);
            string[] lines = data.Split('\n');
            for (int stri = 0; stri < lines.Length; stri++)
            {
                if (stri == 0)
                {
                    string versionstring = lines[stri];
                    version = Int32.Parse(versionstring.Split(' ')[2]);
                    if (version != 22 && version != 18)
                        return false;
                }
                else if (stri == 1)
                {
                    Name = lines[stri];
                }
                else if (stri == 2)
                {
                    Description = lines[stri];
                }
                else
                {
                    string line = lines[stri].Trim();
                    string[] fields = line.Split('\t');

                    if (fields.Length == 1)
                    {
                        fields = line.Split(' ');
                        if (fields[0] == "parameters")
                        {
                            int count = Int32.Parse(fields[1]) + stri;
                            for (; stri < count; )
                            {
                                stri++;
                                line = lines[stri].Trim();
                                fields = line.Split(' ');

                                int id = Int32.Parse(fields[0]);
                                if (fields[1] == ",")
                                    fields[1] = "0";
                                else
                                    fields[1] = fields[1].Replace(',', '.');

                                float weight = float.Parse(fields[1], System.Globalization.NumberStyles.Float,
                                    Utils.EnUsCulture.NumberFormat);

                                Params[id] = weight;
                            }
                        }
                        else if (fields[0] == "textures")
                        {
                            int count = Int32.Parse(fields[1]) + stri;
                            for (; stri < count; )
                            {
                                stri++;
                                line = lines[stri].Trim();
                                fields = line.Split(' ');

                                AppearanceManager.TextureIndex id = (AppearanceManager.TextureIndex)Int32.Parse(fields[0]);
                                UUID texture = new UUID(fields[1]);

                                Textures[id] = texture;
                            }
                        }
                        else if (fields[0] == "type")
                        {
                            WearableType = (WearableType)Int32.Parse(fields[1]);
                        }

                    }
                    else if (fields.Length == 2)
                    {
                        switch (fields[0])
                        {
                            case "creator_mask":
                                // Deprecated, apply this as the base mask
                                Permissions.BaseMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;
                            case "base_mask":
                                Permissions.BaseMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;
                            case "owner_mask":
                                Permissions.OwnerMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;
                            case "group_mask":
                                Permissions.GroupMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;
                            case "everyone_mask":
                                Permissions.EveryoneMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;
                            case "next_owner_mask":
                                Permissions.NextOwnerMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;
                            case "creator_id":
                                Creator = new UUID(fields[1]);
                                break;
                            case "owner_id":
                                Owner = new UUID(fields[1]);
                                break;
                            case "last_owner_id":
                                LastOwner = new UUID(fields[1]);
                                break;
                            case "group_id":
                                Group = new UUID(fields[1]);
                                break;
                            case "group_owned":
                                GroupOwned = (Int32.Parse(fields[1]) != 0);
                                break;
                            case "sale_type":
                                ForSale = InventoryManager.StringToSaleType(fields[1]);
                                break;
                            case "sale_price":
                                SalePrice = Int32.Parse(fields[1]);
                                break;
                            case "sale_info":
                                // Container for sale_type and sale_price, ignore
                                break;
                            default:
                                return false;
                        }
                    }
                }
            }

            return true;
        }
예제 #10
0
 public static bool IsFullPerm(Permissions Permissions)
 {
     if (
         ((Permissions.OwnerMask & PermissionMask.Modify) != 0) &&
         ((Permissions.OwnerMask & PermissionMask.Copy) != 0) &&
         ((Permissions.OwnerMask & PermissionMask.Transfer) != 0)
         )
     {
         return true;
     }
     else
     {
         return false;
     }
 }
예제 #11
0
 public ItemData(UUID uuid, InventoryType type)
 {
     UUID = uuid;
     InventoryType = type;
     ParentUUID = UUID.Zero;
     Name = String.Empty;
     OwnerID = UUID.Zero;
     AssetUUID = UUID.Zero;
     Permissions = new Permissions();
     AssetType = AssetType.Unknown;
     CreatorID = UUID.Zero;
     Description = String.Empty;
     GroupID = UUID.Zero;
     GroupOwned = false;
     SalePrice = 0;
     SaleType = SaleType.Not;
     Flags = 0;
     CreationDate = DateTime.Now;
 }
예제 #12
0
        private bool UploadImage()
        {
            SendToID = UUID.Zero;
            string sendTo = String.Empty;
            if(ccFirstName!=String.Empty) sendTo = ccFirstName + " " + ccLastName;

            if (sendTo.Length > 0)
            {
                AutoResetEvent lookupEvent = new AutoResetEvent(false);
                UUID thisQueryID = UUID.Zero;
                bool lookupSuccess = false;

                EventHandler<DirPeopleReplyEventArgs> callback =
                    delegate(object s, DirPeopleReplyEventArgs ep)
                    {
                        if (ep.QueryID == thisQueryID)
                        {
                            if (ep.MatchedPeople.Count > 0)
                            {
                                SendToID = ep.MatchedPeople[0].AgentID;
                                lookupSuccess = true;
                            }

                            lookupEvent.Set();
                        }
                    };

                Client.Directory.DirPeopleReply += callback;
                thisQueryID = Client.Directory.StartPeopleSearch(sendTo, 0);

                bool eventSuccess = lookupEvent.WaitOne(10 * 1000, false);
                Client.Directory.DirPeopleReply -= callback;

                if (eventSuccess && lookupSuccess)
                {
                    Console.WriteLine("Will send uploaded image to avatar {0} with UUID {1}", sendTo, SendToID.ToString());
                }
                else
                {
                    Console.WriteLine("Could not find avatar {0}. Upload Cancelled.", sendTo);
                    return false;
                }
            }

            if (UploadData != null)
            {
                string name = System.IO.Path.GetFileNameWithoutExtension(FileName);

                Permissions perms = new Permissions();
                perms.EveryoneMask = PermissionMask.All;
                perms.NextOwnerMask = PermissionMask.All;
                Console.WriteLine("Starting uploading of image to Asset Server with name '{0}'", name);
                Client.Inventory.RequestCreateItemFromAsset(UploadData, name, "Uploaded with GridImageUploadCmd", AssetType.Texture,
                    InventoryType.Texture, Client.Inventory.FindFolderForType(AssetType.Texture), perms, ItemCreatedFromAssetCallback);

                return true;
            }
            return false;
        }
예제 #13
0
        public static Permissions FromOSD(OSD llsd)
        {
            Permissions permissions = new Permissions();
            OSDMap map = (OSDMap)llsd;

            byte[] bytes = map["BaseMask"].AsBinary();
            permissions.BaseMask = (PermissionMask)Utils.BytesToUInt(bytes);
            bytes = map["EveryoneMask"].AsBinary();
            permissions.EveryoneMask = (PermissionMask)Utils.BytesToUInt(bytes);
            bytes = map["GroupMask"].AsBinary();
            permissions.GroupMask = (PermissionMask)Utils.BytesToUInt(bytes);
            bytes = map["NextOwnerMask"].AsBinary();
            permissions.NextOwnerMask = (PermissionMask)Utils.BytesToUInt(bytes);
            bytes = map["OwnerMask"].AsBinary();
            permissions.OwnerMask = (PermissionMask)Utils.BytesToUInt(bytes);

            return permissions;
        }
예제 #14
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            //opensim drew this line because of clients might be hardcoded to only support 255? or was this trying to copy linden?
            try
            {
                //Client.Objects.OnObjectProperties += callback;
                int argsUsed;
                Simulator CurSim = TryGetSim(args, out argsUsed) ?? Client.Network.CurrentSim;
                UUID groupID = UUID.Zero;
                Simulator CurrentSim = CurSim;
                Permissions AddPerms = new Permissions();
                Permissions SubPerms = new Permissions();
                bool doTaskInv = false;
                List<Primitive> TaskPrims = new List<Primitive>();
                List<uint> localIDs = new List<uint>();

                // Reset class-wide variables
                PermsSent = false;
                Objects.Clear();
                PermCount = 0;
                bool oneAtATime = false;

                if (args.Length < 3)
                    return ShowUsage();

                if (!UUIDTryParse(args, 0, out groupID, out argsUsed))
                    return ShowUsage();

                args.AdvanceArgs(argsUsed);
                List<SimObject> PS = WorldSystem.GetSingleArg(args, out argsUsed);
                if (IsEmpty(PS)) return Failure("Cannot find objects from " + args.str);

                PermissionWho who = 0;

                bool deed = false;
                for (int i = argsUsed; i < args.Length; i++)
                {
                    bool add = true;
                    bool setPerms = false;
                    string arg = args[i];
                    int whoint = (int) who;
                    PermissionMask Perms = PermsAdd[whoint];
                    if (arg.StartsWith("+"))
                    {
                        arg = arg.Substring(1);
                    }
                    else if (arg.StartsWith("-"))
                    {
                        arg = arg.Substring(1);
                        add = false;
                        Perms = PermsSub[whoint];
                    }

                    switch (arg.ToLower())
                    {
                            // change owner referall
                        case "who":
                            who = 0;
                            break;

                        case "o":
                            who |= PermissionWho.Owner;
                            break;

                        case "g":
                            who |= PermissionWho.Group;
                            break;

                        case "e":
                            who |= PermissionWho.Everyone;
                            break;

                        case "n":
                            who |= PermissionWho.NextOwner;
                            break;

                        case "a":
                            who = PermissionWho.All;
                            break;

                            // change perms for owner
                        case "copy":
                            Perms |= PermissionMask.Copy;
                            setPerms = true;
                            break;
                        case "mod":
                            Perms |= PermissionMask.Modify;
                            setPerms = true;
                            break;
                        case "xfer":
                            Perms |= PermissionMask.Transfer;
                            setPerms = true;
                            break;
                        case "all":
                            Perms |= PermissionMask.All;
                            setPerms = true;
                            break;
                        case "dmg":
                            Perms |= PermissionMask.Damage;
                            setPerms = true;
                            break;
                        case "move":
                            Perms |= PermissionMask.Move;
                            setPerms = true;
                            break;
                            // dont change perms at all
                        case "noperms":
                            skipPerms = true;
                            break;
                            // deed (implies will use group)
                        case "deed":
                            deed = true;
                            break;
                            // set object group
                        case "group":
                            i++;
                            setGroup = true;
                            groupID = Client.GroupName2UUID(args[i]);
                            break;
                        case "task":
                            doTaskInv = true;
                            break;
                        case "incr":
                            oneAtATime = true;
                            break;
                        default:
                            return ShowUsage();
                    }
                    if (setPerms)
                    {
                        skipPerms = false;
                        if (add)
                        {
                            PermsAdd[whoint] = Perms;
                        }
                        else
                        {
                            PermsSub[whoint] = Perms;
                        }
                    }
                }
                ulong CurrentSimHandle = CurrentSim.Handle;
                foreach (SimObject o in PS)
                {
                    if (o is SimAvatar) continue;
                    if (o.RegionHandle != CurrentSimHandle) continue;
                    // Find the requested prim
                    Primitive rootPrim = o.Prim;
                    if (rootPrim == null) continue;
                    localIDs.Add(rootPrim.LocalID);
                    Objects[rootPrim.ID] = rootPrim;
                    if (doTaskInv)
                    {
                        TaskPrims.Add(rootPrim);
                    }

                    continue;
                    ;
                    UUID rootID = UUID.Zero;
                    if (rootPrim == null)
                        return Failure("Cannot find requested prim " + rootID.ToString());
                    else
                        WriteLine("Found requested prim " + rootPrim.ID.ToString(), Client);

                    if (rootPrim.ParentID != 0)
                    {
                        // This is not actually a root prim, find the root
                        if (!CurrentSim.ObjectsPrimitives.TryGetValue(rootPrim.ParentID, out rootPrim))
                            return Failure("Cannot find root prim for requested object");
                        else
                            WriteLine("Set root prim to " + rootPrim.ID.ToString(), Client);
                    }

                    List<Primitive> childPrims;
                    // Find all of the child objects linked to this root
                    childPrims =
                        CurrentSim.ObjectsPrimitives.FindAll(
                            delegate(Primitive prim) { return prim.ParentID == rootPrim.LocalID; });

                    // Build a dictionary of primitives for referencing later
                    // Objects[rootPrim.ID] = rootPrim;
                    for (int i = 0; i < childPrims.Count; i++)
                        Objects[childPrims[i].ID] = childPrims[i];

                    // Build a list of all the localIDs to set permissions for
                    localIDs.Add(rootPrim.LocalID);
                    for (int i = 0; i < childPrims.Count; i++)
                        localIDs.Add(childPrims[i].LocalID);

                    if (doTaskInv)
                    {
                        TaskPrims.AddRange(childPrims);
                        TaskPrims.Add(rootPrim);
                    }
                }

                WriteLine("Using PermissionMask: +" + PermsAdd.ToString() + " -" + PermsSub.ToString(), Client);


                // Go through each of the three main permissions and enable or disable them

                #region Set Linkset Permissions

                if (oneAtATime)
                {
                    List<uint> smallList = new List<uint>();
                    foreach (var o in Objects.Values)
                    {
                        if (o.OwnerID == Client.Self.AgentID)
                            //if (o.GroupID!=groupID)
                        {
                            if (doTaskInv)
                            {
                                TaskPrims.Add(o);
                            }
                            smallList.Clear();
                            smallList.Add(o.LocalID);
                            SetDeed(CurrentSim, smallList, groupID, deed);
                        }
                    }
                }
                else
                {
                    if (localIDs.Count < 50)
                        SetDeed(CurrentSim, localIDs, groupID, deed);
                    else
                    {
                        List<uint> smallList = new List<uint>();
                        while (localIDs.Count > 0)
                        {
                            if (localIDs.Count < 50)
                            {
                                SetDeed(CurrentSim, localIDs, groupID, deed);
                                break;
                            }
                            smallList.Clear();
                            smallList.AddRange(localIDs.GetRange(0, 50));
                            SetDeed(CurrentSim, smallList, groupID, deed);
                            localIDs.RemoveRange(0, 50);
                        }
                    }
                }

                #endregion Set Linkset Permissions

                // Check each prim for task inventory and set permissions on the task inventory
                int taskItems = 0;
                if (doTaskInv)
                    foreach (Primitive prim in TaskPrims)
                    {
                        if ((prim.Flags & PrimFlags.InventoryEmpty) == 0)
                        {
                            List<InventoryBase> items = Client.Inventory.GetTaskInventory(prim.ID, prim.LocalID, 1000*10);

                            if (items != null)
                            {
                                for (int i = 0; i < items.Count; i++)
                                {
                                    if (!(items[i] is InventoryFolder))
                                    {
                                        InventoryItem item = (InventoryItem) items[i];

                                        // prev and not (W or All)
                                        item.Permissions.GroupMask &=
                                            ~(PermsSub[(int) PermissionWho.Group] | PermsSub[(int) PermissionWho.All]);
                                        item.Permissions.OwnerMask &=
                                            ~(PermsSub[(int) PermissionWho.Owner] | PermsSub[(int) PermissionWho.All]);
                                        item.Permissions.NextOwnerMask &=
                                            ~(PermsSub[(int) PermissionWho.NextOwner] |
                                              PermsSub[(int) PermissionWho.All]);
                                        item.Permissions.EveryoneMask &=
                                            ~(PermsSub[(int) PermissionWho.Everyone] | PermsSub[(int) PermissionWho.All]);

                                        // prev and (W or All)
                                        item.Permissions.GroupMask |= PermsAdd[(int) PermissionWho.Group] |
                                                                      PermsAdd[(int) PermissionWho.All];
                                        item.Permissions.OwnerMask |= PermsAdd[(int) PermissionWho.Owner] |
                                                                      PermsAdd[(int) PermissionWho.All];
                                        item.Permissions.NextOwnerMask |= PermsAdd[(int) PermissionWho.NextOwner] |
                                                                          PermsAdd[(int) PermissionWho.All];
                                        item.Permissions.EveryoneMask |= PermsAdd[(int) PermissionWho.Everyone] |
                                                                         PermsAdd[(int) PermissionWho.All];

                                        Client.Inventory.UpdateTaskInventory(prim.LocalID, item);
                                        ++taskItems;
                                    }
                                }
                            }
                        }
                    }

                return
                    Success("Using PermissionMask: +" + PermsAdd.ToString() + " -" + PermsSub.ToString() + " on " +
                            Objects.Count + " objects and " + taskItems + " inventory items");
            }
            finally
            {
                // Client.Objects.OnObjectProperties -= callback;
            }
        }
예제 #15
0
        /// <summary>
        /// Create an inventory item and upload asset data
        /// </summary>
        /// <param name="data">Asset data</param>
        /// <param name="name">Inventory item name</param>
        /// <param name="description">Inventory item description</param>
        /// <param name="assetType">Asset type</param>
        /// <param name="invType">Inventory type</param>
        /// <param name="folderID">Put newly created inventory in this folder</param>
        /// <param name="permissions">Permission of the newly created item 
        /// (EveryoneMask, GroupMask, and NextOwnerMask of Permissions struct are supported)</param>
        /// <param name="callback">Delegate that will receive feedback on success or failure</param>
        public void RequestCreateItemFromAsset(byte[] data, string name, string description, AssetType assetType,
            InventoryType invType, UUID folderID, Permissions permissions, ItemCreatedFromAssetCallback callback)
        {
            if (Client.Network.CurrentSim == null || Client.Network.CurrentSim.Caps == null)
                throw new Exception("NewFileAgentInventory capability is not currently available");

            Uri url = Client.Network.CurrentSim.Caps.CapabilityURI("NewFileAgentInventory");

            if (url != null)
            {
                OSDMap query = new OSDMap();
                query.Add("folder_id", OSD.FromUUID(folderID));
                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));
                query.Add("everyone_mask", OSD.FromInteger((int)permissions.EveryoneMask));
                query.Add("group_mask", OSD.FromInteger((int)permissions.GroupMask));
                query.Add("next_owner_mask", OSD.FromInteger((int)permissions.NextOwnerMask));
                query.Add("expected_upload_cost", OSD.FromInteger(Client.Settings.UPLOAD_COST));

                // Make the request
                CapsClient request = new CapsClient(url);
                request.OnComplete += CreateItemFromAssetResponse;
                request.UserData = new object[] { callback, data, Client.Settings.CAPS_TIMEOUT, query };

                request.BeginGetResponse(query, OSDFormat.Xml, Client.Settings.CAPS_TIMEOUT);
            }
            else
            {
                throw new Exception("NewFileAgentInventory capability is not currently available");
            }
        }
예제 #16
0
        private void cmdUpload_Click(object sender, EventArgs e)
        {
            SendToID = UUID.Zero;
            string sendTo = txtSendtoName.Text.Trim();

            if (sendTo.Length > 0)
            {
                AutoResetEvent lookupEvent = new AutoResetEvent(false);
                UUID thisQueryID = UUID.Zero;
                bool lookupSuccess = false;

                EventHandler<DirPeopleReplyEventArgs> callback =
                    delegate(object s, DirPeopleReplyEventArgs ep)
                    {
                        if (ep.QueryID == thisQueryID)
                        {
                            if (ep.MatchedPeople.Count > 0)
                            {
                                SendToID = ep.MatchedPeople[0].AgentID;
                                lookupSuccess = true;
                            }

                            lookupEvent.Set();
                        }
                    };

                Client.Directory.DirPeopleReply += callback;
                thisQueryID = Client.Directory.StartPeopleSearch(sendTo, 0);

                bool eventSuccess = lookupEvent.WaitOne(10 * 1000, false);
                Client.Directory.DirPeopleReply -= callback;

                if (eventSuccess && lookupSuccess)
                {
                    Logger.Log("Will send uploaded image to avatar " + SendToID.ToString(), Helpers.LogLevel.Info, Client);
                }
                else
                {
                    MessageBox.Show("Could not find avatar \"" + sendTo + "\", upload cancelled");
                    return;
                }
            }

            if (UploadData != null)
            {
                prgUpload.Value = 0;
                cmdLoad.Enabled = false;
                cmdSave.Enabled = false;
                cmdUpload.Enabled = false;
                grpLogin.Enabled = false;

                string name = System.IO.Path.GetFileNameWithoutExtension(FileName);

                Permissions perms = new Permissions();
                perms.EveryoneMask = PermissionMask.All;
                perms.NextOwnerMask = PermissionMask.All;

                Client.Inventory.RequestCreateItemFromAsset(UploadData, name, "Uploaded with SL Image Upload", AssetType.Texture,
                    InventoryType.Texture, Client.Inventory.FindFolderForType(AssetType.Texture), perms,
                    delegate(bool success, string status, UUID itemID, UUID assetID)
                    {
                        if (this.InvokeRequired)
                            BeginInvoke(new MethodInvoker(EnableControls));
                        else
                            EnableControls();

                        if (success)
                        {
                            AssetID = assetID;
                            UpdateAssetID();

                            // Fix the permissions on the new upload since they are fscked by default
                            InventoryItem item = (InventoryItem)Client.Inventory.Store[itemID];

                            Transferred = UploadData.Length;
                            BeginInvoke((MethodInvoker)delegate() { SetProgress(); });
                        }
                        else
                        {
                            MessageBox.Show("Asset upload failed: " + status);
                        }
                    }
                );
            }
        }
예제 #17
0
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 public InventoryItem(SerializationInfo info, StreamingContext ctxt)
     : base(info, ctxt)
 {
     AssetUUID = (UUID)info.GetValue("AssetUUID", typeof(UUID));
     Permissions = (Permissions)info.GetValue("Permissions", typeof(Permissions));
     AssetType = (AssetType)info.GetValue("AssetType", typeof(AssetType));
     InventoryType = (InventoryType)info.GetValue("InventoryType", typeof(InventoryType));
     CreatorID = (UUID)info.GetValue("CreatorID", typeof(UUID));
     Description = (string)info.GetValue("Description", typeof(string));
     GroupID = (UUID)info.GetValue("GroupID", typeof(UUID));
     GroupOwned = (bool)info.GetValue("GroupOwned", typeof(bool));
     SalePrice = (int)info.GetValue("SalePrice", typeof(int));
     SaleType = (SaleType)info.GetValue("SaleType", typeof(SaleType));
     Flags = (uint)info.GetValue("Flags", typeof(uint));
     CreationDate = (DateTime)info.GetValue("CreationDate", typeof(DateTime));
     LastOwnerID = (UUID)info.GetValue("LastOwnerID", typeof(UUID));
 }
예제 #18
0
 public bool Equals(Permissions other)
 {
     return(this == other);
 }