Ejemplo n.º 1
0
        public virtual bool CreateUserRootFolder(UUID principalID)
        {
            bool result = false;

            InventoryFolderBase rootFolder = GetRootFolder(principalID);

            if (rootFolder == null)
            {
                List<InventoryFolderBase> rootFolders = GetInventorySkeleton(principalID);
                if (rootFolders.Count == 0)
                    rootFolder = CreateFolder(principalID, UUID.Zero, (int) AssetType.RootFolder, "My Inventory");
                else
                {
                    rootFolder = new InventoryFolderBase
                                     {
                                         Name = "My Inventory",
                                         Type = (short) AssetType.RootFolder,
                                         Version = 1,
                                         ID = rootFolders[0].ParentID,
                                         Owner = principalID,
                                         ParentID = UUID.Zero
                                     };


                    m_Database.StoreFolder(rootFolder);
                }
                result = true;
            }
            return result;
        }
Ejemplo n.º 2
0
 // Constructors
 public InventoryFolderImpl(InventoryFolderBase folderbase)
 {
     Owner = folderbase.Owner;
     ID = folderbase.ID;
     Name = folderbase.Name;
     ParentID = folderbase.ParentID;
     Type = folderbase.Type;
     Version = folderbase.Version;
 }
 public override bool AddFolder(InventoryFolderBase folder)
 {
     string invserverURL = "";
     if (GetHandlers.GetIsForeign (folder.Owner, "InventoryServerURI", m_registry, out invserverURL))
     {
         XInventoryServicesConnector xinv = new XInventoryServicesConnector (invserverURL + "xinventory");
         return xinv.AddFolder (folder);
     }
     return base.AddFolder (folder);
 }
        public override bool AddFolder(InventoryFolderBase folder)
        {
            object remoteValue = DoRemote(folder);
            if (remoteValue != null || m_doRemoteOnly)
                return remoteValue != null && (bool)remoteValue;

            string invserverURL = "";
            if (GetHandlers.GetIsForeign (folder.Owner, "InventoryServerURI", m_registry, out invserverURL))
            {
                XInventoryServicesConnector xinv = new XInventoryServicesConnector (invserverURL + "xinventory");
                return xinv.AddFolder (folder);
            }
            return base.AddFolder (folder);
        }
Ejemplo n.º 5
0
 public override void FromOSD(OSDMap map)
 {
     OSDArray items = (OSDArray)map["Items"];
     Items = items.ConvertAll<InventoryItemBase>((osd) =>
     {
         InventoryItemBase item = new InventoryItemBase();
         item.FromOSD((OSDMap)osd);
         return item;
     }
     );
     OSDArray folders = (OSDArray)map["Folders"];
     Folders = folders.ConvertAll<InventoryFolderBase>((osd) =>
     {
         InventoryFolderBase folder = new InventoryFolderBase();
         folder.FromOSD((OSDMap)osd);
         return folder;
     }
     );
     UserID = map["UserID"];
 }
        public virtual bool AddFolder(InventoryFolderBase folder)
        {
            if (folder == null)
                return false;

            Dictionary<string, object> ret = MakeRequest("ADDFOLDER",
                                                         new Dictionary<string, object>
                                                             {
                                                                 {"ParentID", folder.ParentID.ToString()},
                                                                 {"Type", folder.Type.ToString()},
                                                                 {"Version", folder.Version.ToString()},
                                                                 {"Name", folder.Name},
                                                                 {"Owner", folder.Owner.ToString()},
                                                                 {"ID", folder.ID.ToString()}
                                                             });

            if (ret == null)
                return false;

            return bool.Parse(ret["RESULT"].ToString());
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Move the inventory folder to another place in the user's inventory
 /// </summary>
 /// <param name="remoteClient">The client that requested the change</param>
 /// <param name="folderID">The folder UUID to move</param>
 /// <param name="parentID">The folder to move the folder (folderID) into</param>
 protected void HandleMoveInventoryFolder(IClientAPI remoteClient, UUID folderID, UUID parentID)
 {
     InventoryFolderBase folder = new InventoryFolderBase(folderID, remoteClient.AgentId);
     folder = m_scene.InventoryService.GetFolder(folder);
     if (folder != null)
     {
         folder.ParentID = parentID;
         if (!m_scene.InventoryService.MoveFolder(folder))
             MainConsole.Instance.WarnFormat("[AGENT INVENTORY]: could not move folder {0}", folderID);
         else
             MainConsole.Instance.DebugFormat("[AGENT INVENTORY]: folder {0} moved to parent {1}", folderID, parentID);
     }
     else
     {
         MainConsole.Instance.WarnFormat("[AGENT INVENTORY]: request to move folder {0} but folder not found", folderID);
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Handle an inventory folder creation request from the client.
 /// </summary>
 /// <param name="remoteClient"></param>
 /// <param name="folderID"></param>
 /// <param name="folderType"></param>
 /// <param name="folderName"></param>
 /// <param name="parentID"></param>
 protected void HandleCreateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort folderType,
                                         string folderName, UUID parentID)
 {
     InventoryFolderBase folder = new InventoryFolderBase(folderID, folderName, remoteClient.AgentId, (short)folderType, parentID, 1);
     if (!m_scene.InventoryService.AddFolder(folder))
     {
         MainConsole.Instance.WarnFormat(
              "[AGENT INVENTORY]: Failed to create folder for user {0} {1}",
              remoteClient.Name, remoteClient.AgentId);
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Send an update to the client about the given folder
        /// </summary>
        /// <param name="client">The client to send the update to</param>
        /// <param name="folder">The folder that we need to send</param>
        /// <param name="fetchFolders">Should we fetch folders inside of this folder</param>
        /// <param name="fetchItems">Should we fetch items inside of this folder</param>
        protected void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems)
        {
            if (folder == null)
                return;

            // Fetch the folder contents
            InventoryCollection contents = m_scene.InventoryService.GetFolderContent(client.AgentId, folder.ID);

            // Fetch the folder itself to get its current version
            InventoryFolderBase containingFolder = new InventoryFolderBase(folder.ID, client.AgentId);
            containingFolder = m_scene.InventoryService.GetFolder(containingFolder);

            //MainConsole.Instance.DebugFormat("[AGENT INVENTORY]: Sending inventory folder contents ({0} nodes) for \"{1}\" to {2} {3}",
            //    contents.Folders.Count + contents.Items.Count, containingFolder.Name, client.FirstName, client.LastName);

            if (containingFolder != null)
                client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, containingFolder.Version, fetchFolders, fetchItems);
        }
Ejemplo n.º 10
0
 private void NewFolder(UUID userID, string newFolderName, string folder)
 {
     UUID folderID = UUID.Zero;
     if (UUID.TryParse(folder, out folderID))
     {
         InventoryFolderBase fbase = new InventoryFolderBase(UUID.Random(), newFolderName, userID, folderID);
         fbase.Type = (short)AssetType.Folder;
         m_InventoryService.AddFolder(fbase);
     }
 }
Ejemplo n.º 11
0
        private void Delete(UUID userID, List<string> nodes, List<string> types)
        {
            List<UUID> items = new List<UUID>();
            List<UUID> folders = new List<UUID>();
            SplitNodes(userID, nodes, types, items, folders);

            var trash = m_InventoryService.GetFolderForType(userID, InventoryType.Folder, AssetType.TrashFolder);
            if (trash != null)
            {
                List<InventoryItemBase> its = new List<InventoryItemBase>();
                foreach (UUID uuid in items)
                {
                    InventoryItemBase itbase = new InventoryItemBase();
                    itbase.ID = uuid;
                    itbase.Folder = UUID.Zero;
                    its.Add(itbase);
                }
                m_InventoryService.MoveItems(userID, its);

                bool purgeTrash = false;
                foreach (UUID uuid in folders)
                {
                    InventoryFolderBase fbase = new InventoryFolderBase(uuid, userID);
                    //if (uuid == trash)
                    //    purgeTrash = true;
                    //else
                    {
                        fbase.ParentID = UUID.Zero;
                        m_InventoryService.MoveFolder(fbase);
                    }
                }
                if (purgeTrash)
                {
                    InventoryFolderBase fbase = new InventoryFolderBase(UUID.Zero, userID);
                    m_InventoryService.PurgeFolder(fbase);
                }
            }
        }
 ///<summary>
 ///  Create the archive name for a particular folder.
 ///</summary>
 ///These names are prepended with an inventory folder's UUID so that more than one folder can have the
 ///same name
 ///<param name = "folder"></param>
 ///<returns></returns>
 public static string CreateArchiveFolderName(InventoryFolderBase folder)
 {
     return CreateArchiveFolderName(folder.Name, folder.ID);
 }
        /// <summary>
        ///   Purge an inventory folder of all its items and subfolders.
        /// </summary>
        /// <param name = "folder"></param>
        /// <returns>true if the folder was successfully purged</returns>
        public bool PurgeFolder(InventoryFolderBase folder)
        {
            NameValueCollection requestArgs = new NameValueCollection
                                                  {
                                                      {"RequestMethod", "PurgeInventoryFolder"},
                                                      {"OwnerID", folder.Owner.ToString()},
                                                      {"FolderID", folder.ID.ToString()}
                                                  };

            OSDMap response = WebUtils.PostToService(m_serverUrl, requestArgs);
            bool success = response["Success"].AsBoolean();

            if (!success)
            {
                MainConsole.Instance.Warn("[SIMIAN INVENTORY CONNECTOR]: Error purging folder " + folder.ID + " for " + folder.Owner +
                           ": " +
                           response["Message"].AsString());
            }

            return success;
        }
        /// <summary>
        ///   Get a folder, given by its UUID
        /// </summary>
        /// <param name = "folder"></param>
        /// <returns></returns>
        public InventoryFolderBase GetFolder(InventoryFolderBase folder)
        {
            NameValueCollection requestArgs = new NameValueCollection
                                                  {
                                                      {"RequestMethod", "GetInventoryNode"},
                                                      {"ItemID", folder.ID.ToString()},
                                                      {"OwnerID", folder.Owner.ToString()},
                                                      {"IncludeFolders", "1"},
                                                      {"IncludeItems", "0"},
                                                      {"ChildrenOnly", "1"}
                                                  };

            OSDMap response = WebUtils.PostToService(m_serverUrl, requestArgs);
            if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
            {
                OSDArray items = (OSDArray) response["Items"];
                List<InventoryFolderBase> folders = GetFoldersFromResponse(items, folder.ID, true);

                if (folders.Count > 0)
                    return folders[0];
            }

            return null;
        }
        /// <summary>
        ///   Add a new folder to the user's inventory
        /// </summary>
        /// <param name = "folder"></param>
        /// <returns>true if the folder was successfully added</returns>
        public bool AddFolder(InventoryFolderBase folder)
        {
            NameValueCollection requestArgs = new NameValueCollection
                                                  {
                                                      {"RequestMethod", "AddInventoryFolder"},
                                                      {"FolderID", folder.ID.ToString()},
                                                      {"ParentID", folder.ParentID.ToString()},
                                                      {"OwnerID", folder.Owner.ToString()},
                                                      {"Name", folder.Name},
                                                      {"ContentType", SLUtil.SLAssetTypeToContentType(folder.Type)}
                                                  };

            OSDMap response = WebUtils.PostToService(m_serverUrl, requestArgs);
            bool success = response["Success"].AsBoolean();

            if (!success)
            {
                MainConsole.Instance.Warn("[SIMIAN INVENTORY CONNECTOR]: Error creating folder " + folder.Name + " for " + folder.Owner +
                           ": " +
                           response["Message"].AsString());
            }

            return success;
        }
 /// <summary>
 ///   Constructor
 /// </summary>
 public InventoryArchiveWriteRequest(
     Guid id, InventoryArchiverModule module, IRegistryCore registry,
     UserAccount userInfo, string invPath, Stream saveStream, bool UseAssets, InventoryFolderBase folderBase,
     List<AssetBase> assetsToAdd)
 {
     m_id = id;
     m_module = module;
     m_registry = registry;
     m_userInfo = userInfo;
     m_invPath = invPath;
     m_saveStream = saveStream;
     m_assetGatherer = new UuidGatherer(m_registry.RequestModuleInterface<IAssetService>());
     m_saveAssets = UseAssets;
     m_defaultFolderToSave = folderBase;
     m_assetsToAdd = assetsToAdd;
 }
        /// <summary>
        ///   Save an inventory folder
        /// </summary>
        /// <param name = "inventoryFolder">The inventory folder to save</param>
        /// <param name = "path">The path to which the folder should be saved</param>
        /// <param name = "saveThisFolderItself">If true, save this folder itself.  If false, only saves contents</param>
        protected void SaveInvFolder(InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself)
        {
            if (saveThisFolderItself)
            {
                path += CreateArchiveFolderName(inventoryFolder);

                // We need to make sure that we record empty folders
                m_archiveWriter.WriteDir(path);
            }

            InventoryCollection contents
                = m_registry.RequestModuleInterface<IInventoryService>().GetFolderContent(inventoryFolder.Owner,
                                                                                          inventoryFolder.ID);

            foreach (InventoryFolderBase childFolder in contents.Folders)
            {
                SaveInvFolder(childFolder, path, true);
            }

            foreach (InventoryItemBase item in contents.Items)
            {
                SaveInvItem(item, path);
            }
        }
 /// <summary>
 ///   Update a folder in the user's inventory
 /// </summary>
 /// <param name = "folder"></param>
 /// <returns>true if the folder was successfully updated</returns>
 public bool UpdateFolder(InventoryFolderBase folder)
 {
     return AddFolder(folder);
 }
 public override bool PurgeFolder(InventoryFolderBase folder)
 {
     // NOGO
     return false;
 }
 /// <summary>
 ///   Update an item in the user's inventory
 /// </summary>
 /// <param name = "item"></param>
 /// <returns>true if the item was successfully updated</returns>
 public bool UpdateItem(InventoryItemBase item)
 {
     if (item.AssetID != UUID.Zero)
     {
         return AddItem(item);
     }
     else
     {
         // This is actually a folder update
         InventoryFolderBase folder = new InventoryFolderBase(item.ID, item.Name, item.Owner,
                                                              (short) item.AssetType, item.Folder, 0);
         return UpdateFolder(folder);
     }
 }
Ejemplo n.º 21
0
        private void Move(UUID userID, List<string> nodes, List<string> types, string folder)
        {
            UUID folderID = UUID.Zero;
            if (UUID.TryParse(folder, out folderID))
            {
                List<UUID> items = new List<UUID>();
                List<UUID> folders = new List<UUID>();
                SplitNodes(userID, nodes, types, items, folders);

                List<InventoryItemBase> its = new List<InventoryItemBase>();
                foreach (UUID uuid in items)
                {
                    InventoryItemBase itbase = new InventoryItemBase();
                    itbase.ID = uuid;
                    itbase.Folder = folderID;
                    its.Add(itbase);
                }
                m_InventoryService.MoveItems(userID, its);

                foreach (UUID uuid in folders)
                {
                    InventoryFolderBase fbase = new InventoryFolderBase();
                    fbase.ID = uuid;
                    fbase.ParentID = folderID;
                    m_InventoryService.MoveFolder(fbase);
                }
            }
        }
        public virtual bool MoveFolder(InventoryFolderBase folder)
        {
            if (folder == null)
                return false;

            Dictionary<string, object> ret = MakeRequest("MOVEFOLDER",
                                                         new Dictionary<string, object>
                                                             {
                                                                 {"ParentID", folder.ParentID.ToString()},
                                                                 {"ID", folder.ID.ToString()},
                                                                 {"PRINCIPAL", folder.Owner.ToString()}
                                                             });

            if (ret == null)
                return false;

            return bool.Parse(ret["RESULT"].ToString());
        }
Ejemplo n.º 23
0
        public byte[] CreateInventoryCategory(string path, Stream request, OSHttpRequest httpRequest,
                                                                    OSHttpResponse httpResponse)
        {
            OSDMap map = (OSDMap)OSDParser.DeserializeLLSDXml(request);
            UUID folder_id = map["folder_id"].AsUUID();
            UUID parent_id = map["parent_id"].AsUUID();
            int type = map["type"].AsInteger();
            string name = map["name"].AsString();

            UUID newFolderId = UUID.Random();
            InventoryFolderBase newFolder
                = new InventoryFolderBase(
                    newFolderId, name, m_service.AgentID, (short)type, parent_id, 1);
            m_inventoryService.AddFolder(newFolder);
            OSDMap resp = new OSDMap();
            resp["folder_id"] = folder_id;
            resp["parent_id"] = parent_id;
            resp["type"] = type;
            resp["name"] = name;

            return OSDParser.SerializeLLSDXmlBytes(map);
        }
 public bool ForcePurgeFolder(InventoryFolderBase folder)
 {
     return false;
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Move the given items from the object task inventory to the agent's inventory
        /// </summary>
        /// <param name="destID"></param>
        /// <param name="name"></param>
        /// <param name="host"></param>
        /// <param name="items"></param>
        /// <returns></returns>
        public UUID MoveTaskInventoryItemsToUserInventory (UUID destID, string name, ISceneChildEntity host, List<UUID> items)
        {
            //InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(destID);

            UUID newFolderID = UUID.Random();

           // InventoryFolderBase newFolder = new InventoryFolderBase(newFolderID, name, destID, -1, rootFolder.ID, rootFolder.Version);
           // m_scene.InventoryService.AddFolder(newFolder);

            //int countLeft = items.Count;
            //foreach (UUID itemID in items)
            Util.FireAndForget((o) => 
            {
                //InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(destID, host, itemID);
             InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(destID);
               InventoryFolderBase newFolder = new InventoryFolderBase(newFolderID, name, destID, -1, rootFolder.ID, rootFolder.Version); 
               m_scene.InventoryService.AddFolder(newFolder);

                //if (agentItem != null)
                foreach (UUID itemID in items)

                {
                    //agentItem.Folder = newFolderID;
                 InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(destID, host, itemID);

                   // m_scene.InventoryService.AddItemAsync(agentItem, (itm) =>
                   /*if (agentItem != null)
                    {
                        if (--countLeft == 0)
                        {
                            IScenePresence avatar;
                            if (m_scene.TryGetScenePresence(destID, out avatar))
                            {
                                SendInventoryUpdate(avatar.ControllingClient, rootFolder, true, false);
                                SendInventoryUpdate(avatar.ControllingClient, newFolder, false, true);
                            }
                        }
                    });
                    */
                    agentItem.Folder = newFolderID;
                    m_scene.InventoryService.AddItem(agentItem); 
                }
           // }
      IScenePresence avatar;  
                    if (m_scene.TryGetScenePresence(destID, out avatar))  
                    {  
                        SendInventoryUpdate(avatar.ControllingClient, rootFolder, true, false);  
                        SendInventoryUpdate(avatar.ControllingClient, newFolder, false, true);  
                    }  
               });  

            return newFolderID;
        }
        public virtual bool PurgeFolder(InventoryFolderBase folder)
        {
            if (folder == null)
                return false;

            Dictionary<string, object> ret = MakeRequest("PURGEFOLDER",
                                                         new Dictionary<string, object>
                                                             {
                                                                 {"ID", folder.ID.ToString()}
                                                             });

            if (ret == null)
                return false;

            return bool.Parse(ret["RESULT"].ToString());
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Handle a client request to update the inventory folder
        /// </summary>
        ///
        /// FIXME: We call add new inventory folder because in the data layer, we happen to use an SQL REPLACE
        /// so this will work to rename an existing folder.  Needless to say, to rely on this is very confusing,
        /// and needs to be changed.
        ///
        /// <param name="remoteClient"></param>
        /// <param name="folderID"></param>
        /// <param name="type"></param>
        /// <param name="name"></param>
        /// <param name="parentID"></param>
        protected void HandleUpdateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort type, string name,
                                                UUID parentID)
        {
            //            MainConsole.Instance.DebugFormat(
            //                "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId);

            InventoryFolderBase folder = new InventoryFolderBase(folderID, remoteClient.AgentId);
            folder = m_scene.InventoryService.GetFolder(folder);
            if (folder != null)
            {
                folder.Name = name;
                folder.Type = (short)type;
                folder.ParentID = parentID;
                if (!m_scene.InventoryService.UpdateFolder(folder))
                {
                    MainConsole.Instance.ErrorFormat(
                         "[AGENT INVENTORY]: Failed to update folder for user {0} {1}",
                         remoteClient.Name, remoteClient.AgentId);
                }
            }
        }
        public virtual InventoryFolderBase GetFolder(InventoryFolderBase folder)
        {
            if (folder == null)
                return null;

            try
            {
                Dictionary<string, object> ret = MakeRequest("GETFOLDER",
                                                             new Dictionary<string, object>
                                                                 {
                                                                     {"ID", folder.ID.ToString()}
                                                                 });

                if (ret == null)
                    return null;
                if (ret.Count == 0)
                    return null;

                return BuildFolder((Dictionary<string, object>)ret["folder"]);
            }
            catch (Exception e)
            {
                MainConsole.Instance.DebugFormat("[XINVENTORY CONNECTOR STUB]: Exception in GetFolder: {0}", e.Message);
            }

            return null;
        }
Ejemplo n.º 29
0
 /// <summary>
 /// This should delete all the items and folders in the given directory.
 /// </summary>
 /// <param name="remoteClient"></param>
 /// <param name="folderID"></param>
 protected void HandlePurgeInventoryDescendents(IClientAPI remoteClient, UUID folderID)
 {
     InventoryFolderBase folder = new InventoryFolderBase(folderID, remoteClient.AgentId);
     Util.FireAndForget(PurgeFolderAsync, folder);
 }
        private InventoryFolderBase BuildFolder(Dictionary<string, object> data)
        {
            InventoryFolderBase folder = new InventoryFolderBase();

            try
            {
                folder.ParentID = new UUID(data["ParentID"].ToString());
                folder.Type = short.Parse(data["Type"].ToString());
                folder.Version = ushort.Parse(data["Version"].ToString());
                folder.Name = data["Name"].ToString();
                folder.Owner = new UUID(data["Owner"].ToString());
                folder.ID = new UUID(data["ID"].ToString());
            }
            catch (Exception e)
            {
                MainConsole.Instance.DebugFormat("[XINVENTORY CONNECTOR STUB]: Exception building folder: {0}", e.Message);
            }

            return folder;
        }