public override string Execute(string[] args, LLUUID 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;
                    }
                }
                else
                {
                    displayString += b.Name;
                }
                displayString += nl;
            }
            return(displayString);
        }
Exemplo n.º 2
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            Manager = Client.Inventory;
            Inventory = Manager.Store;

            StringBuilder result = new StringBuilder();

            InventoryFolder rootFolder = Inventory.RootFolder;
            PrintFolder(rootFolder, result, 0);

            return result.ToString();
        }
Exemplo n.º 3
0
        public override string Execute(string[] args, LLUUID 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;
                    }
                }
                else
                {
                    displayString += b.Name;
                }
                displayString += nl;
            }
            return displayString;
        }
Exemplo n.º 4
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            Manager = Client.Inventory;
            Inventory = Manager.Store;

            StringBuilder result = new StringBuilder();

            //Client.Inventory.RequestFolderContents(Client.Inventory.Store.RootFolder.UUID, Client.Self.AgentID,
            //    true, true, InventorySortOrder.ByName);

            //PrintFolder(Inventory.RootNode, result, 0);

            //return result.ToString();

            //FIXME:
            return "This function needs a blocking InventoryManager.FolderContents() to work";
        }
Exemplo n.º 5
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="client">Reference to the SecondLife client</param>
        public InventoryManager(SecondLife client)
        {
            _Client = client;
            _Store = new Inventory(client, this);

            _Client.Network.RegisterCallback(PacketType.UpdateCreateInventoryItem, new NetworkManager.PacketCallback(UpdateCreateInventoryItemHandler));
            _Client.Network.RegisterCallback(PacketType.SaveAssetIntoInventory, new NetworkManager.PacketCallback(SaveAssetIntoInventoryHandler));
            _Client.Network.RegisterCallback(PacketType.BulkUpdateInventory, new NetworkManager.PacketCallback(BulkUpdateInventoryHandler));
            _Client.Network.RegisterCallback(PacketType.MoveInventoryItem, new NetworkManager.PacketCallback(MoveInventoryItemHandler));
            _Client.Network.RegisterCallback(PacketType.InventoryDescendents, new NetworkManager.PacketCallback(InventoryDescendentsHandler));
            _Client.Network.RegisterCallback(PacketType.FetchInventoryReply, new NetworkManager.PacketCallback(FetchInventoryReplyHandler));
            _Client.Network.RegisterCallback(PacketType.ReplyTaskInventory, new NetworkManager.PacketCallback(ReplyTaskInventoryHandler));
            
            // Watch for inventory given to us through instant message
            _Client.Self.OnInstantMessage += new AgentManager.InstantMessageCallback(Self_OnInstantMessage);

            // Register extra parameters with login and parse the inventory data that comes back
            _Client.Network.RegisterLoginResponseCallback(
                new NetworkManager.LoginResponseCallback(Network_OnLoginResponse),
                new string[] {
                    "inventory-root", "inventory-skeleton", "inventory-lib-root",
                    "inventory-lib-owner", "inventory-skel-lib"});
        }
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            Manager   = Client.Inventory;
            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);
        }
Exemplo n.º 7
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            Manager = Client.Inventory;
            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;
        }
        private void Network_OnLoginResponse(bool loginSuccess, bool redirect, string message, string reason, LoginResponseData replyData)
        {
            if (loginSuccess)
            {
                // Initialize the store here so we know who owns it:
                _Store = new Inventory(_Client, this, _Client.Self.AgentID);
                Logger.DebugLog("Setting InventoryRoot to " + replyData.InventoryRoot.ToString(), _Client);
                InventoryFolder rootFolder = new InventoryFolder(replyData.InventoryRoot);
                rootFolder.Name = String.Empty;
                rootFolder.ParentUUID = LLUUID.Zero;
                _Store.RootFolder = rootFolder;

                for (int i = 0; i < replyData.InventorySkeleton.Length; i++)
                    _Store.UpdateNodeFor(replyData.InventorySkeleton[i]);

                InventoryFolder libraryRootFolder = new InventoryFolder(replyData.LibraryRoot);
                libraryRootFolder.Name = String.Empty;
                libraryRootFolder.ParentUUID = LLUUID.Zero;
                _Store.LibraryFolder = libraryRootFolder;

                for(int i = 0; i < replyData.LibrarySkeleton.Length; i++)
                    _Store.UpdateNodeFor(replyData.LibrarySkeleton[i]);
            }
        }