Responsible for maintaining inventory structure. Inventory constructs nodes and manages node children as is necessary to maintain a coherant hirarchy. Other classes should not manipulate or create InventoryNodes explicitly. When A node's parent changes (when a folder is moved, for example) simply pass Inventory the updated InventoryFolder and it will make the appropriate changes to its internal representation.
        public override string Execute(string[] args, UUID fromAgentID)
        {
            Manager = Client.Inventory;
            Inventory = Client.InventoryStore;

            if (args.Length == 0)
                return "Current folder: " + Client.CurrentDirectory.Name;

            string path = args[0];
            for(int i = 1; i < args.Length; ++i)
            {
                path += " " + args[i];
            }

            List<InventoryBase> results = Inventory.InventoryFromPath(path, Client.CurrentDirectory, true);
            if (results.Count == 0)
                return "Can not find inventory at: " + path;
            InventoryFolder destFolder = null;
            foreach (InventoryBase ib in results)
            {
                if (ib is InventoryFolder) 
                {
                    destFolder = ib as InventoryFolder;
                    break;
                }
            }
            if (destFolder == null)
                return path + " is not a folder.";

            Client.CurrentDirectory = destFolder;
            return "Current folder: " + Client.CurrentDirectory.Name;
        }
 public InventoryBackup(RadegastInstance instance)
 {
     InitializeComponent();
     Disposed += new System.EventHandler(InventoryBackup_Disposed);
     this.instance = instance;
     inv = client.Inventory.Store;
 }
Example #3
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length > 1)
            {
                return(ShowUsage()); // " 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(TheBotClient.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 WriteLine 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(Success(displayString));
        }
        public void Init()
        {
            Assert.IsTrue(Client.Network.Connected, "Client is not connected to the grid");

            Inventory = new Inventory(Client.Inventory, Client.Inventory.InventorySkeleton);
            Assert.IsNotNull(Inventory.RootFolder, "Root folder is null.");
            Assert.AreNotEqual(UUID.Zero, Inventory.RootUUID, "Root UUID is zero.");
        }
Example #5
0
        /// <summary>
        /// Initialize everything that needs to be initialized once we're logged in.
        /// </summary>
        /// <param name="login">The status of the login</param>
        /// <param name="message">Error message on failure, MOTD on success.</param>
        public void  LoginHandler(LoginStatus login, string message)
        {
            if (login == LoginStatus.Success)
            {
                // Create the stores:
                InventoryStore = new Inventory(Inventory, Inventory.InventorySkeleton);
                LibraryStore = new Inventory(Inventory, Inventory.LibrarySkeleton);

                // Start in the inventory root folder:
                CurrentDirectory = InventoryStore.RootFolder;
            }
        }
Example #6
0
 public InventoryBackup(RadegastInstance instance, UUID rootFolder)
 {
     InitializeComponent();
     Disposed += new System.EventHandler(InventoryBackup_Disposed);
     this.instance = instance;
     inv = client.Inventory.Store;
     rootNode = inv.RootNode;
     if (inv.Items.ContainsKey(rootFolder) && inv.Items[rootFolder].Data is InventoryFolder)
     {
         rootNode = inv.GetNodeFor(rootFolder);
     }
 }
Example #7
0
        public override string Execute(string[] args, UUID fromAgentID)
        {
            Manager = Client.Inventory;
            Inventory = Client.InventoryStore;

            StringBuilder result = new StringBuilder();

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

            return result.ToString();
        }
        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 #9
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            Manager = Client.Inventory;
            Inventory = Manager.Store;

            StringBuilder result = new StringBuilder();

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

            return Success(result.ToString());
            ;
        }
Example #10
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            Manager   = Client.Inventory;
            Inventory = Manager.Store;

            StringBuilder result = new StringBuilder();

            InventoryFolder rootFolder = Inventory.RootFolder;

            PrintFolder(rootFolder, result, 0);

            return(Success(result.ToString()));

            ;
        }
Example #11
0
        internal Closet(PluginControl pc)
            : base(pc)
        {
            Title = "inventory";
            inv = control.instance.Client.Inventory.Store;
            selected = inv.RootNode.Data;

            control.listener.CreateGrammar(
                INVNAME,
                new string[] {
                    "read it",
                    "go there",
                    "close the closet",
                    "describe it" });
        }
Example #12
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            Manager = Client.Inventory;
            Inventory = Client.Inventory.Store;

            if (args.Length > 0)
                return ShowUsage(); // " pwd";
            string pathStr = "";
            string[] path = null;

            InventoryFolder currentFolder = Client.CurrentDirectory;

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

            return Success("Current folder: " + currentFolder.Name);
        }
Example #13
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            Manager   = Client.Inventory;
            Inventory = Manager.Store;

            InventoryFolder rootFolder = Inventory.RootFolder;
            int             found      = 0;
            int             items      = 0;
            int             remed      = 0;

            foreach (KeyValuePair <UUID, InventoryNode> node in MushDLR223.Utilities.LockInfo.CopyOf(Inventory.Items))
            {
                found++;
                var n = node.Value;
                if (n.Parent == null || n.Parent.Data.Name == "TaskInvHolder")
                {
                    var d = n.Data;
                    items++;
                    if (d is InventoryItem)
                    {
                        continue;
                    }
                    if (n.ParentID == UUID.Zero || (n.Parent != null && n.Parent.Data.Name == "TaskInvHolder"))
                    {
                        UUID uuid;
                        if (UUID.TryParse(d.Name, out uuid) || d.Name.ToLower().Contains("taskinv"))
                        {
                            remed++;
                            Client.Inventory.MoveFolder(node.Key,
                                                        Client.Inventory.FindFolderForType(AssetType.TrashFolder));

                            /*
                             * Client.Inventory.RemoveDescendants(node.Key);
                             * Client.Inventory.RemoveFolder(node.Key);
                             * Client.Inventory.RemoveItem(node.Key);
                             */
                        }
                    }
                }
            }

            return(Success("remed=" + remed + " items=" + items + " total=" + found));

            ;
        }
Example #14
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            Manager   = Client.Inventory;
            Inventory = Client.Inventory.Store;

            if (args.Length > 0)
            {
                return(ShowUsage()); // " pwd";
            }
            string pathStr = "";

            string[] path = null;

            InventoryFolder currentFolder = Client.CurrentDirectory;

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

            return(Success("Current folder: " + currentFolder.Name));
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            Manager = Client.Inventory;
            Inventory = Manager.Store;

            InventoryFolder rootFolder = Inventory.RootFolder;
            int found = 0;
            int items = 0;
            int remed = 0;
            foreach (KeyValuePair<UUID, InventoryNode> node in MushDLR223.Utilities.LockInfo.CopyOf(Inventory.Items))
            {
                found++;
                var n = node.Value;
                if (n.Parent == null || n.Parent.Data.Name == "TaskInvHolder")
                {
                    var d = n.Data;
                    items++;
                    if (d is InventoryItem) continue;
                    if (n.ParentID == UUID.Zero || (n.Parent != null && n.Parent.Data.Name == "TaskInvHolder"))
                    {
                        UUID uuid;
                        if (UUID.TryParse(d.Name, out uuid) || d.Name.ToLower().Contains("taskinv"))
                        {
                            remed++;
                            Client.Inventory.MoveFolder(node.Key,
                                                        Client.Inventory.FindFolderForType(AssetType.TrashFolder));
                            /*
                            Client.Inventory.RemoveDescendants(node.Key);
                            Client.Inventory.RemoveFolder(node.Key);
                            Client.Inventory.RemoveItem(node.Key);
                             */
                        }
                    }
                }
            }

            return Success("remed=" + remed + " items=" + items + " total=" + found);
            ;
        }
Example #16
0
        private void productCallback(object obj)
        {
            Manager   = client.Inventory;
            Inventory = Manager.Store;
            if (Inventory == null)
            {
                instance.MainForm.TabConsole.DisplayNotificationInChat(pluginName + ": Waiting for Inventory...");
                return;
            }

            if (isSending == true)
            {
                instance.MainForm.TabConsole.DisplayNotificationInChat(pluginName + ": Waiting...");
                return;
            }
            isSending = true;

            Inventory.RootFolder.OwnerID = client.Self.AgentID;

            Dictionary <string, string> param = new Dictionary <string, string>();

            param.Add("botUUID", client.Self.AgentID.ToString());
            var strContent             = this.RequestVendor("GETOUTSTANDING", param);
            List <DeliveryQueue> queue = this.parseResponse(strContent);

            instance.MainForm.TabConsole.DisplayNotificationInChat(pluginName + ": " + queue.Count + " Items in Queue List");

            // check if something neddc to be done
            if (queue.Count > 0)
            {
                foreach (DeliveryQueue p in queue)
                {
                    this.SendObject(p);
                }
            }

            isSending = false;
        }
Example #17
0
        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 = UUID.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 = UUID.Zero;
                _Store.LibraryFolder = libraryRootFolder;

                for (int i = 0; i < replyData.LibrarySkeleton.Length; i++)
                    _Store.UpdateNodeFor(replyData.LibrarySkeleton[i]);
            }
        }
        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);
        }
        public InventoryConsole(RadegastInstance instance)
        {
            InitializeComponent();
            Disposed += new EventHandler(InventoryConsole_Disposed);

            TreeUpdateTimer = new System.Timers.Timer()
            {
                Interval = updateInterval,
                Enabled = false,
                SynchronizingObject = invTree
            };
            TreeUpdateTimer.Elapsed += TreeUpdateTimerTick;

            this.instance = instance;
            Manager = client.Inventory;
            Inventory = Manager.Store;
            Inventory.RootFolder.OwnerID = client.Self.AgentID;
            invTree.ImageList = frmMain.ResourceImages;
            invRootNode = AddDir(null, Inventory.RootFolder);
            UpdateStatus("Reading cache");
            Init1();
        }
Example #20
0
 public InitialOutfit(RadegastInstance instance)
 {
     this.Instance = instance;
     Store = Client.Inventory.Store;
 }
        public InventoryConsole(RadegastInstance instance)
        {
            InitializeComponent();
            Disposed += new EventHandler(InventoryConsole_Disposed);

            TreeUpdateTimer = new System.Timers.Timer()
            {
                Interval = updateInterval,
                Enabled = false,
                SynchronizingObject = invTree
            };
            TreeUpdateTimer.Elapsed += TreeUpdateTimerTick;

            this.instance = instance;
            Manager = client.Inventory;
            Inventory = Manager.Store;
            Inventory.RootFolder.OwnerID = client.Self.AgentID;
            invTree.ImageList = frmMain.ResourceImages;
            invRootNode = AddDir(null, Inventory.RootFolder);
            Logger.Log("Reading inventory cache from " + instance.InventoryCacheFileName, Helpers.LogLevel.Debug, client);
            Inventory.RestoreFromDisk(instance.InventoryCacheFileName);
            AddFolderFromStore(invRootNode, Inventory.RootFolder);

            sorter = new InvNodeSorter();

            if (!instance.GlobalSettings.ContainsKey("inv_sort_bydate"))
                instance.GlobalSettings["inv_sort_bydate"] = OSD.FromBoolean(true);
            if (!instance.GlobalSettings.ContainsKey("inv_sort_sysfirst"))
                instance.GlobalSettings["inv_sort_sysfirst"] = OSD.FromBoolean(true);

            sorter.ByDate = instance.GlobalSettings["inv_sort_bydate"].AsBoolean();
            sorter.SystemFoldersFirst = instance.GlobalSettings["inv_sort_sysfirst"].AsBoolean();

            tbtnSortByDate.Checked = sorter.ByDate;
            tbtbSortByName.Checked = !sorter.ByDate;
            tbtnSystemFoldersFirst.Checked = sorter.SystemFoldersFirst;

            invTree.TreeViewNodeSorter = sorter;

            if (instance.MonoRuntime)
            {
                invTree.BackColor = Color.FromKnownColor(KnownColor.Window);
                invTree.ForeColor = invTree.LineColor = Color.FromKnownColor(KnownColor.WindowText);
                InventoryFolder f = new InventoryFolder(UUID.Random());
                f.Name = "";
                f.ParentUUID = UUID.Zero;
                f.PreferredType = AssetType.Unknown;
                TreeNode dirNode = new TreeNode();
                dirNode.Name = f.UUID.ToString();
                dirNode.Text = f.Name;
                dirNode.Tag = f;
                dirNode.ImageIndex = GetDirImageIndex(f.PreferredType.ToString().ToLower());
                dirNode.SelectedImageIndex = dirNode.ImageIndex;
                invTree.Nodes.Add(dirNode);
                invTree.Sort();
            }

            saveAllTToolStripMenuItem.Enabled = false;
            InventoryUpdate = new Thread(new ThreadStart(StartTraverseNodes));
            InventoryUpdate.Name = "InventoryUpdate";
            InventoryUpdate.IsBackground = true;
            InventoryUpdate.Start();

            invRootNode.Expand();

            invTree.AfterExpand += new TreeViewEventHandler(TreeView_AfterExpand);
            invTree.NodeMouseClick += new TreeNodeMouseClickEventHandler(invTree_MouseClick);
            invTree.NodeMouseDoubleClick += new TreeNodeMouseClickEventHandler(invTree_NodeMouseDoubleClick);

            _EditTimer = new System.Threading.Timer(OnLabelEditTimer, null, System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);

            // Callbacks
            Inventory.InventoryObjectAdded += new EventHandler<InventoryObjectAddedEventArgs>(Inventory_InventoryObjectAdded);
            Inventory.InventoryObjectUpdated += new EventHandler<InventoryObjectUpdatedEventArgs>(Inventory_InventoryObjectUpdated);
            Inventory.InventoryObjectRemoved += new EventHandler<InventoryObjectRemovedEventArgs>(Inventory_InventoryObjectRemoved);

            client.Objects.ObjectUpdate += new EventHandler<PrimEventArgs>(Objects_AttachmentUpdate);
            client.Objects.KillObject += new EventHandler<KillObjectEventArgs>(Objects_KillObject);
            client.Appearance.AppearanceSet += new EventHandler<AppearanceSetEventArgs>(Appearance_AppearanceSet);
        }
Example #22
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public GridClient()
        {
            // These are order-dependant
            Network = new NetworkManager(this);
            Settings = new Settings(this);
            Parcels = new ParcelManager(this);
            Self = new AgentManager(this);
            Avatars = new AvatarManager(this);
            Friends = new FriendsManager(this);
            Grid = new GridManager(this);
            Objects = new ObjectManager(this);
            Groups = new GroupManager(this);
            Assets = new AssetManager(this);
            Appearance = new AppearanceManager(this, Assets);
            Inventory = new InventoryManager(this);
            Directory = new DirectoryManager(this);
            Terrain = new TerrainManager(this);
            Sound = new SoundManager(this);
            Throttle = new AgentThrottle(this);

            if (Settings.ENABLE_INVENTORY_STORE)
                InventoryStore = new Inventory(Inventory);
            if (Settings.ENABLE_LIBRARY_STORE)
                LibraryStore = new Inventory(Inventory);

            Inventory.OnSkeletonsReceived +=
                delegate(InventoryManager manager)
                {
                    if (Settings.ENABLE_INVENTORY_STORE)
                        InventoryStore.InitializeFromSkeleton(Inventory.InventorySkeleton);
                    if (Settings.ENABLE_LIBRARY_STORE)
                        LibraryStore.InitializeFromSkeleton(Inventory.LibrarySkeleton);
                };
        }
Example #23
0
 public SimAssetStore(BotClient GC)
 {
     TheStore = this;
     Client = GC;                       
     Manager = Client.Inventory;
     Manager.ItemReceived += Inventory_OnItemReceived;
     Manager.TaskItemReceived += Inventory_OnTaskItemReceived;
     Manager.FolderUpdated += Inventory_OnFolderUpdated;
     Inventory = Manager.Store;
     Client.Network.SimConnected += Ensure_Downloaded;
     SlowConnectedQueue.DebugQueue = true;
     FillAssetNames();
 }
        public override bool Excecute(Automaton am, GridClient client, bool force)
        {
            if (!client.Network.Connected) { result.message = "Not Connected to grid"; return true; }
            if (string.IsNullOrEmpty(path)) path = "";

            string[] pth = path.Split('/');
            if (client.Inventory.Store == null)
            {
                result.message = "inventory not loaded";
                return true;
            }

            inv = client.Inventory.Store;

            InventoryFolder currentFolder = inv.RootFolder;
            if (currentFolder == null)
            {
                result.message = "inventory not loaded";
                return true;
            }
            for (int i = 0; i < pth.Length; ++i)
            {
                string nextName = pth[i];
                if (string.IsNullOrEmpty(nextName) || nextName == ".")
                    continue; // Ignore '.' and blanks, stay in the current directory.

                //List<InventoryBase> currentContents = Inventory.GetContents(currentFolder);
                List<InventoryBase> currentContents = inv.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
                        {
                            result.message = "invalid path";
                            return true;
                        }
                    }
                }
                if (!found)
                {
                    result.message = "invalid path";
                    return true;
                }
            }

            List<InventoryBase> contents = inv.GetContents(currentFolder);

            client.Inventory.RequestFolderContents(currentFolder.UUID, client.Self.AgentID, true, true, InventorySortOrder.ByName);
            result.success = true;
            return true;
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            Manager = Client.Inventory;
            Inventory = Client.Inventory.Store;

            if (args.Length > 1)
                return ShowUsage(); // " 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 Failure("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 Client 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 Failure(item.Name + " is not a folder.");
                            }
                        }
                    }
                    if (!found)
                        return Failure(nextName + " not found in " + currentFolder.Name);
                }
            }
            Client.CurrentDirectory = currentFolder;
            return Success("Current folder: " + currentFolder.Name);
        }
Example #26
0
 //Finds our ppt2os basefolder, or creates one if not existing yet
 private UUID find_ppt2os_folder(GridClient client)
 {
     Manager = client.Inventory;
     Inventory = Manager.Store;
     InventoryFolder rootFolder = Inventory.RootFolder;
     UUID texture_basefolder = client.Inventory.FindFolderForType(AssetType.Texture);
     List<InventoryBase> texture_contents = Inventory.GetContents(texture_basefolder);
     foreach (InventoryBase c in texture_contents)
     {
         InventoryFolder subfolder = c as InventoryFolder;
         if (c is InventoryFolder)
        	{
             if (subfolder.Name == "ppt2os") {
             ppt2os_folder = subfolder.UUID;
             return ppt2os_folder;
             }
         }
     }
     //No folder yet
     if (ppt2os_folder == UUID.Zero) {
         client.Inventory.CreateFolder(texture_basefolder, "ppt2os");
         find_ppt2os_folder(client);
     }
     return ppt2os_folder;
 }
Example #27
0
        private void productCallback(object obj)
        {
            Manager = client.Inventory;
            Inventory = Manager.Store;
            if (Inventory == null)
            {
                instance.MainForm.TabConsole.DisplayNotificationInChat(pluginName + ": Waiting for Inventory...");
                return;
            }

            if (isSending == true)
            {
                instance.MainForm.TabConsole.DisplayNotificationInChat(pluginName + ": Waiting...");
                return;
            }
            isSending = true;

            Inventory.RootFolder.OwnerID = client.Self.AgentID;

            Dictionary<string, string> param = new Dictionary<string, string>();
            param.Add("botUUID", client.Self.AgentID.ToString());
            var strContent = this.RequestVendor("GETOUTSTANDING", param);
            List<DeliveryQueue> queue = this.parseResponse(strContent);
            instance.MainForm.TabConsole.DisplayNotificationInChat(pluginName + ": " + queue.Count + " Items in Queue List");

            // check if something neddc to be done
            if (queue.Count > 0)
            {
                foreach (DeliveryQueue p in queue)
                    this.SendObject(p);
            }

            isSending = false;
        }
Example #28
0
        private void Ensure_Downloaded(object sender, SimConnectedEventArgs e)
        {
            if (!GleanAssetsFromInventory) return;
            if (ensuredDownloadAssetFoldersComplete) return;
            ensuredDownloadAssetFoldersComplete = true;
            Inventory = Manager.Store;
            Inventory.InventoryObjectAdded += Store_OnInventoryObjectAdded;
            Inventory.InventoryObjectUpdated += Store_OnInventoryObjectUpdated;
            Inventory.InventoryObjectRemoved += Store_OnInventoryObjectRemoved;
            Enqueue((DownloadAssetFolders));
            taskQueue.Start();

        }