Example #1
0
        public override string Execute(string[] args, UUID fromAgentID)
        {
            if (args.Length < 2)
            {
                return "Usage: give <agent uuid> <item1> [item2] [item3] [...]";
            }
            UUID dest;
            if (!UUID.TryParse(args[0], out dest))
            {
                return "First argument expected agent UUID.";
            }
            Manager = Client.Inventory;
            Inventory = Client.InventoryStore;
            string ret = "";
            string nl = "\n";
            for (int i = 1; i < args.Length; ++i)
            {
                string itemPath = args[i];

                List<InventoryBase> results = Inventory.InventoryFromPath(itemPath, Client.CurrentDirectory, true);

                if (results.Count == 0)
                {
                    ret += "No inventory item at " + itemPath + " found." + nl;
                }
                else
                {
                    results[0].Give(dest, true);
                    ret += "Gave " + results[0].Name + nl;
                }
            }
            return ret;
        }
Example #2
0
        public override string Execute(string[] args, UUID fromAgentID)
        {
            if (args.Length > 1)
            {
                return("Usage: ls [-l]");
            }
            bool longDisplay = false;

            if (args.Length > 0 && args[0] == "-l")
            {
                longDisplay = true;
            }

            Manager   = Client.Inventory;
            Inventory = Manager.Store;
            // WARNING: Uses local copy of inventory contents, need to download them first.
            List <InventoryBase> contents = Inventory.GetContents(Client.CurrentDirectory);
            string displayString          = "";
            string nl = "\n"; // New line character

            // Pretty simple, just print out the contents.
            foreach (InventoryBase b in contents)
            {
                if (longDisplay)
                {
                    // Generate a nicely formatted description of the item.
                    // It kinda looks like the output of the unix ls.
                    // starts with 'd' if the inventory is a folder, '-' if not.
                    // 9 character permissions string
                    // UUID of object
                    // Name of object
                    if (b is InventoryFolder)
                    {
                        InventoryFolder folder = b as InventoryFolder;
                        displayString += "d--------- ";
                        displayString += folder.UUID;
                        displayString += " " + folder.Name;
                    }
                    else if (b is InventoryItem)
                    {
                        InventoryItem item = b as InventoryItem;
                        displayString += "-";
                        displayString += PermMaskString(item.Permissions.OwnerMask);
                        displayString += PermMaskString(item.Permissions.GroupMask);
                        displayString += PermMaskString(item.Permissions.EveryoneMask);
                        displayString += " " + item.UUID;
                        displayString += " " + item.Name;
                        displayString += nl;
                        displayString += "  AssetID: " + item.AssetUUID;
                    }
                }
                else
                {
                    displayString += b.Name;
                }
                displayString += nl;
            }
            return(displayString);
        }
Example #3
0
        public override string Execute(string[] args, UUID fromAgentID)
        {
            if (args.Length < 2)
            {
                return("Usage: give <agent uuid> itemname");
            }
            UUID dest;

            if (!UUID.TryParse(args[0], out dest))
            {
                return("First argument expected agent UUID.");
            }
            Manager   = Client.Inventory;
            Inventory = Manager.Store;
            string ret = "";
            string nl  = "\n";

            string target = String.Empty;

            for (int ct = 0; ct < args.Length; ct++)
            {
                target = target + args[ct] + " ";
            }
            target = target.TrimEnd();

            string inventoryName = target;
            // WARNING: Uses local copy of inventory contents, need to download them first.
            List <InventoryBase> contents = Inventory.GetContents(Client.CurrentDirectory);
            bool found = false;

            foreach (InventoryBase b in contents)
            {
                if (inventoryName == b.Name || inventoryName == b.UUID.ToString())
                {
                    found = true;
                    if (b is InventoryItem)
                    {
                        InventoryItem item = b as InventoryItem;
                        Manager.GiveItem(item.UUID, item.Name, item.AssetType, dest, true);
                        ret += "Gave " + item.Name + " (" + item.AssetType + ")" + nl;
                    }
                    else
                    {
                        ret += "Unable to give folder " + b.Name + nl;
                    }
                }
            }
            if (!found)
            {
                ret += "No inventory item named " + inventoryName + " found." + nl;
            }

            return(ret);
        }
Example #4
0
        public override string Execute(string[] args, UUID fromAgentID)
        {
            if (args.Length < 2)
            {
                return "Usage: give <agent uuid> itemname";
            }
            UUID dest;
            if (!UUID.TryParse(args[0], out dest))
            {
                return "First argument expected agent UUID.";
            }
            Manager = Client.Inventory;
            Inventory = Manager.Store;
            string ret = "";
            string nl = "\n";

            string target = String.Empty;
            for (int ct = 0; ct < args.Length; ct++)
                target = target + args[ct] + " ";
            target = target.TrimEnd();

            string inventoryName = target;
            // WARNING: Uses local copy of inventory contents, need to download them first.
            List<InventoryBase> contents = Inventory.GetContents(Client.CurrentDirectory);
            bool found = false;
            foreach (InventoryBase b in contents)
            {
                if (inventoryName == b.Name || inventoryName == b.UUID.ToString())
                {
                    found = true;
                    if (b is InventoryItem)
                    {
                        InventoryItem item = b as InventoryItem;
                        Manager.GiveItem(item.UUID, item.Name, item.AssetType, dest, true);
                        ret += "Gave " + item.Name + " (" + item.AssetType + ")" + nl;
                    }
                    else
                    {
                        ret += "Unable to give folder " + b.Name + nl;
                    }
                }
            }
            if (!found)
                ret += "No inventory item named " + inventoryName + " found." + nl;

            return ret;
        }
Example #5
0
 public override string Execute(string[] args, Guid fromAgentID)
 {
     if (args.Length < 2)
     {
         return "Usage: give <agent Guid> <item1> [item2] [item3] [...]";
     }
     Guid dest;
     if (!GuidExtensions.TryParse(args[0], out dest))
     {
         return "First argument expected agent Guid.";
     }
     Manager = Client.Inventory;
     Inventory = Manager.Store;
     string ret = "";
     string nl = "\n";
     for (int i = 1; i < args.Length; ++i)
     {
         string inventoryName = args[i];
         // WARNING: Uses local copy of inventory contents, need to download them first.
         List<InventoryBase> contents = Inventory.GetContents(Client.CurrentDirectory);
         bool found = false;
         foreach (InventoryBase b in contents)
         {
             if (inventoryName == b.Name || inventoryName == b.Guid.ToString())
             {
                 found = true;
                 if (b is InventoryItem)
                 {
                     InventoryItem item = b as InventoryItem;
                     Manager.GiveItem(item.Guid, item.Name, item.AssetType, dest, true);
                     ret += "Gave " + item.Name + nl;
                 }
                 else
                 {
                     ret += "Unable to give folder " + b.Name + nl;
                 }
             }
         }
         if (!found)
             ret += "No inventory item named " + inventoryName + " found." + nl;
     }
     return ret;
 }
Example #6
0
        public override string Execute(string[] args, UUID fromAgentID)
        {
            Inventory = Client.Inventory.Store;

            if (args.Length > 1)
            {
                return("Usage: cd [path-to-folder]");
            }
            string pathStr = "";

            string[] path = null;
            if (args.Length == 0)
            {
                path = new string[] { "" };
                // cd without any arguments doesn't do anything.
            }
            else if (args.Length == 1)
            {
                pathStr = args[0];
                path    = pathStr.Split(new char[] { '/' });
                // Use '/' as a path seperator.
            }
            InventoryFolder currentFolder = Client.CurrentDirectory;

            if (pathStr.StartsWith("/"))
            {
                currentFolder = Inventory.RootFolder;
            }

            if (currentFolder == null) // We need this to be set to something.
            {
                return("Error: Client not logged in.");
            }

            // Traverse the path, looking for the
            for (int i = 0; i < path.Length; ++i)
            {
                string nextName = path[i];
                if (string.IsNullOrEmpty(nextName) || nextName == ".")
                {
                    continue; // Ignore '.' and blanks, stay in the current directory.
                }
                if (nextName == ".." && currentFolder != Inventory.RootFolder)
                {
                    // If we encounter .., move to the parent folder.
                    currentFolder = Inventory[currentFolder.ParentUUID] as InventoryFolder;
                }
                else
                {
                    List <InventoryBase> currentContents = Inventory.GetContents(currentFolder);
                    // Try and find an InventoryBase with the corresponding name.
                    bool found = false;
                    foreach (InventoryBase item in currentContents)
                    {
                        // Allow lookup by UUID as well as name:
                        if (item.Name == nextName || item.UUID.ToString() == nextName)
                        {
                            found = true;
                            if (item is InventoryFolder)
                            {
                                currentFolder = item as InventoryFolder;
                            }
                            else
                            {
                                return(item.Name + " is not a folder.");
                            }
                        }
                    }
                    if (!found)
                    {
                        return(nextName + " not found in " + currentFolder.Name);
                    }
                }
            }
            Client.CurrentDirectory = currentFolder;
            return("Current folder: " + currentFolder.Name);
        }