示例#1
0
        public LibraryService(IConfigSource config)
            : base(config)
        {
            string pLibrariesLocation = Path.Combine("inventory", "Libraries.xml");
            string pLibName = "OpenSim Library";

            IConfig libConfig = config.Configs["LibraryService"];
            if (libConfig != null)
            {
                pLibrariesLocation = libConfig.GetString("DefaultLibrary", pLibrariesLocation);
                pLibName = libConfig.GetString("LibraryName", pLibName);
            }

            m_log.Debug("[LIBRARY]: Starting library service...");

            m_LibraryRootFolder = new InventoryFolderImpl();
            m_LibraryRootFolder.Owner = libOwner;
            m_LibraryRootFolder.ID = new UUID("00000112-000f-0000-0000-000100bba000");
            m_LibraryRootFolder.Name = pLibName;
            m_LibraryRootFolder.ParentID = UUID.Zero;
            m_LibraryRootFolder.Type = (short)8;
            m_LibraryRootFolder.Version = (ushort)1;

            libraryFolders.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder);

            LoadLibraries(pLibrariesLocation);
        }
        /// <summary>
        /// Get a child folder
        /// </summary>
        /// <param name="folderID"></param>
        /// <returns>The folder if it exists, null if it doesn't</returns>
        public InventoryFolderImpl GetChildFolder(UUID folderID)
        {
            InventoryFolderImpl folder = null;

            lock (m_childFolders)
            {
                m_childFolders.TryGetValue(folderID, out folder);
            }

            return(folder);
        }
示例#3
0
        public override void RequestInventoryForUser(UUID userID, InventoryReceiptCallback callback)
        {
            m_log.InfoFormat("[LOCAL INVENTORY SERVICE]: Requesting inventory for user {0}", userID);

            List<InventoryFolderImpl> folders = new List<InventoryFolderImpl>();
            List<InventoryItemBase> items = new List<InventoryItemBase>();

            List<InventoryFolderBase> skeletonFolders = GetInventorySkeleton(userID);

            if (skeletonFolders != null)
            {
               
                InventoryFolderImpl rootFolder = null;

                // Need to retrieve the root folder on the first pass
                foreach (InventoryFolderBase folder in skeletonFolders)
                {
                    if (folder.ParentID == UUID.Zero)
                    {
                        rootFolder = new InventoryFolderImpl(folder);
                        folders.Add(rootFolder);
                        items.AddRange(RequestFolderItems(rootFolder.ID));
                        break; // Only 1 root folder per user
                    }
                }

                if (rootFolder != null)
                {
                    foreach (InventoryFolderBase folder in skeletonFolders)
                    {
                        if (folder.ID != rootFolder.ID)
                        {
                            folders.Add(new InventoryFolderImpl(folder));
                            items.AddRange(RequestFolderItems(folder.ID));
                        }
                    }
                }

                m_log.InfoFormat(
                    "[LOCAL INVENTORY SERVICE]: Received inventory response for user {0} containing {1} folders and {2} items",
                    userID, folders.Count, items.Count);
            }
            else
            {
                m_log.WarnFormat("[LOCAL INVENTORY SERVICE]: User {0} inventory not available", userID);
            }

            callback(folders, items);
        }
        /// <summary>
        /// Removes the given child subfolder.
        /// </summary>
        /// <param name="folderID"></param>
        /// <returns>
        /// The folder removed, or null if the folder was not present.
        /// </returns>
        public InventoryFolderImpl RemoveChildFolder(UUID folderID)
        {
            InventoryFolderImpl removedFolder = null;

            lock (m_childFolders)
            {
                if (m_childFolders.ContainsKey(folderID))
                {
                    removedFolder = m_childFolders[folderID];
                    m_childFolders.Remove(folderID);
                }
            }

            return(removedFolder);
        }
 /// <summary>
 /// Create a new subfolder.
 /// </summary>
 /// <param name="folderID"></param>
 /// <param name="folderName"></param>
 /// <param name="type"></param>
 /// <returns>The newly created subfolder.  Returns null if the folder already exists</returns>
 public InventoryFolderImpl CreateChildFolder(UUID folderID, string folderName, ushort type)
 {
     try
     {
         return(m_childFolders.AddIfNotExists(folderID, delegate()
         {
             InventoryFolderImpl subFold = new InventoryFolderImpl();
             subFold.Name = folderName;
             subFold.ID = folderID;
             subFold.Type = (short)type;
             subFold.ParentID = this.ID;
             subFold.Owner = Owner;
             return subFold;
         }));
     }
     catch (ThreadedClasses.RwLockedDictionary <UUID, InventoryFolderImpl> .KeyAlreadyExistsException)
     {
         return(null);
     }
 }
 /// <summary>
 /// Create a new subfolder.
 /// </summary>
 /// <param name="folderID"></param>
 /// <param name="folderName"></param>
 /// <param name="type"></param>
 /// <returns>The newly created subfolder.  Returns null if the folder already exists</returns>
 public InventoryFolderImpl CreateChildFolder(UUID folderID, string folderName, ushort type)
 {
     try
     {
         return m_childFolders.AddIfNotExists(folderID, delegate()
         {
             InventoryFolderImpl subFold = new InventoryFolderImpl();
             subFold.Name = folderName;
             subFold.ID = folderID;
             subFold.Type = (short)type;
             subFold.ParentID = this.ID;
             subFold.Owner = Owner;
             return subFold;
         });
     }
     catch(ThreadedClasses.RwLockedDictionary<UUID, InventoryFolderImpl>.KeyAlreadyExistsException)
     {
         return null;
     }
 }
        /// <summary>
        /// Create a new subfolder.
        /// </summary>
        /// <param name="folderID"></param>
        /// <param name="folderName"></param>
        /// <param name="type"></param>
        /// <returns>The newly created subfolder.  Returns null if the folder already exists</returns>
        public InventoryFolderImpl CreateChildFolder(UUID folderID, string folderName, ushort type)
        {
            lock (m_childFolders)
            {
                if (!m_childFolders.ContainsKey(folderID))
                {
                    InventoryFolderImpl subFold = new InventoryFolderImpl();
                    subFold.Name     = folderName;
                    subFold.ID       = folderID;
                    subFold.Type     = (short)type;
                    subFold.ParentID = this.ID;
                    subFold.Owner    = Owner;
                    m_childFolders.Add(subFold.ID, subFold);

                    return(subFold);
                }
            }

            return(null);
        }
示例#8
0
        /// <summary>
        /// Create a new subfolder.
        /// </summary>
        /// <param name="folderID"></param>
        /// <param name="folderName"></param>
        /// <param name="type"></param>
        /// <returns>The newly created subfolder.  Returns null if the folder already exists</returns>
        public InventoryFolderImpl CreateChildFolder(UUID folderID, string folderName, ushort type)
        {
            lock (m_childFolders)
            {
                if (!m_childFolders.ContainsKey(folderID))
                {
                    InventoryFolderImpl subFold = new InventoryFolderImpl();
                    subFold.Name = folderName;
                    subFold.ID = folderID;
                    subFold.Type = (short)type;
                    subFold.ParentID = this.ID;
                    subFold.Owner = Owner;
                    m_childFolders.Add(subFold.ID, subFold);

                    return subFold;
                }
            }

            return null;
        }
        /// <summary>
        /// Returns the folder requested if it is this folder or is a descendent of this folder.  The search is depth
        /// first.
        /// </summary>
        /// <returns>The requested folder if it exists, null if it does not.</returns>
        public InventoryFolderImpl FindFolder(UUID folderID)
        {
            if (folderID == ID)
            {
                return(this);
            }

            lock (m_childFolders)
            {
                foreach (InventoryFolderImpl folder in m_childFolders.Values)
                {
                    InventoryFolderImpl returnFolder = folder.FindFolder(folderID);

                    if (returnFolder != null)
                    {
                        return(returnFolder);
                    }
                }
            }

            return(null);
        }
        /// <summary>
        /// Callback used by the inventory server GetInventory request
        /// </summary>
        /// <param name="userID"></param>
        private void InventoryResponse(InventoryCollection response)
        {
            UUID userID = response.UserID;
            InventoryReceiptCallback callback = null;
            lock (m_RequestingInventory)
            {
                if (m_RequestingInventory.ContainsKey(userID))
                {
                    callback = m_RequestingInventory[userID];
                    m_RequestingInventory.Remove(userID);
                    lock (m_RequestTime)
                    {
                        if (m_RequestTime.ContainsKey(userID))
                        {
                            m_RequestTime.Remove(userID);
                        }
                    }
                }
                else
                {
                    m_log.WarnFormat(
                        "[INVENTORY CONNECTOR]: " +
                        "Received inventory response for {0} for which we do not have a record of requesting!",
                        userID);
                    return;
                }
            }

            m_log.InfoFormat("[INVENTORY CONNECTOR]: " +
                             "Received inventory response for user {0} containing {1} folders and {2} items",
                             userID, response.Folders.Count, response.Items.Count);

            InventoryFolderImpl rootFolder = null;

            ICollection<InventoryFolderImpl> folders = new List<InventoryFolderImpl>();
            ICollection<InventoryItemBase> items = new List<InventoryItemBase>();

            foreach (InventoryFolderBase folder in response.Folders)
            {
                if (folder.ParentID == UUID.Zero)
                {
                    rootFolder = new InventoryFolderImpl(folder);
                    folders.Add(rootFolder);

                    break;
                }
            }

            if (rootFolder != null)
            {
                foreach (InventoryFolderBase folder in response.Folders)
                {
                    if (folder.ID != rootFolder.ID)
                    {
                        folders.Add(new InventoryFolderImpl(folder));
                    }
                }

                foreach (InventoryItemBase item in response.Items)
                {
                    items.Add(item);
                }
            }
            else
            {
                m_log.ErrorFormat("[INVENTORY CONNECTOR]: Did not get back an inventory containing a root folder for user {0}", userID);
            }

            callback(folders, items);

        }
示例#11
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 protected virtual ArrayList GetLibraryOwner(InventoryFolderImpl libFolder)
 {
     //for now create random inventory library owner
     Hashtable TempHash = new Hashtable();
     TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; // libFolder.Owner
     ArrayList inventoryLibOwner = new ArrayList();
     inventoryLibOwner.Add(TempHash);
     return inventoryLibOwner;
 }
        /// <summary>
        /// Use the asset set information at path to load assets
        /// </summary>
        /// <param name="path"></param>
        /// <param name="assets"></param>
        protected void LoadLibraries(string iarFileName)
        {
            RegionInfo regInfo = new RegionInfo();
            Scene m_MockScene = null;
            //Make the scene for the IAR loader
            if (m_registry is Scene)
                m_MockScene = (Scene)m_registry;
            else
            {
                m_MockScene = new Scene(regInfo);
                m_MockScene.AddModuleInterfaces(m_registry.GetInterfaces());
            }

            UserAccount uinfo = m_MockScene.UserAccountService.GetUserAccount(UUID.Zero, m_service.LibraryOwner);
            //Make the user account for the default IAR
            if (uinfo == null)
            {
                m_log.Warn("Creating user " + m_service.LibraryOwnerName[0] + " " + m_service.LibraryOwnerName[1]);
                m_MockScene.UserAccountService.CreateUser(m_service.LibraryOwnerName[0],
                    m_service.LibraryOwnerName[1], "", "");
                uinfo = m_MockScene.UserAccountService.GetUserAccount(UUID.Zero, m_service.LibraryOwnerName[0],
                    m_service.LibraryOwnerName[1]);
                m_MockScene.InventoryService.CreateUserInventory(uinfo.PrincipalID);
            }

            InventoryCollection col = m_MockScene.InventoryService.GetFolderContent(uinfo.PrincipalID, UUID.Zero);
            bool alreadyExists = false;
            foreach (InventoryFolderBase folder in col.Folders)
            {
                if (folder.Name == iarFileName)
                {
                    alreadyExists = true;
                    break;
                }
            }
            if (alreadyExists)
            {
                m_log.InfoFormat("[LIBRARY INVENTORY]: Found previously loaded iar file {0}, ignoring.", iarFileName);
                return;
            }

            m_log.InfoFormat("[LIBRARY INVENTORY]: Loading iar file {0}", iarFileName);
            InventoryFolderBase rootFolder = m_MockScene.InventoryService.GetRootFolder(uinfo.PrincipalID);

            if (null == rootFolder)
            {
                //We need to create the root folder, otherwise the IAR freaks
                m_MockScene.InventoryService.CreateUserInventory(uinfo.PrincipalID);
            }

            InventoryArchiveReadRequest archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, "/", iarFileName, false);

            try
            {
                List<InventoryNodeBase> nodes = new List<InventoryNodeBase>(archread.Execute(true));
                if (nodes.Count == 0)
                    return;
                InventoryFolderImpl f = new InventoryFolderImpl((InventoryFolderBase)nodes[0]);

                TraverseFolders(f, nodes[0].ID, m_MockScene);
                //This is our loaded folder
                //Fix the name for later
                f.Name = iarFileName;
                f.ParentID = UUID.Zero;
                bool update = m_MockScene.InventoryService.UpdateFolder(f);
                m_service.AddToDefaultInventory(f);
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[LIBRARY MODULE]: Exception when processing archive {0}: {1}", iarFileName, e.StackTrace);
            }
            finally
            {
                archread.Close();
            }
        }
 private void TraverseFolders(InventoryFolderImpl folderimp, UUID ID, Scene m_MockScene)
 {
     InventoryCollection col = m_MockScene.InventoryService.GetFolderContent(m_service.LibraryOwner, ID);
     foreach (InventoryItemBase item in col.Items)
     {
         folderimp.Items.Add(item.ID, item);
     }
     foreach (InventoryFolderBase folder in col.Folders)
     {
         InventoryFolderImpl childFolder = new InventoryFolderImpl(folder);
         foreach (KeyValuePair<String, AssetType> type in m_assetTypes)
         {
             if (childFolder.Name.ToLower().StartsWith(type.Key.ToLower()))
             {
                 childFolder.Type = (short)type.Value;
             }
         }
         TraverseFolders(childFolder, folder.ID, m_MockScene);
         folderimp.AddChildFolder(childFolder);
     }
 }
 /// <summary>
 /// Add a folder that already exists.
 /// </summary>
 /// <param name="folder"></param>
 public void AddChildFolder(InventoryFolderImpl folder)
 {
     folder.ParentID           = ID;
     m_childFolders[folder.ID] = folder;
 }
            public InventoryCapsHandler(Scene scene, UUID agentID, Caps caps)
            {
                m_agentID = agentID;
                m_Caps = caps;
                m_Scene = scene;
                m_httpServer = m_Caps.HttpListener;
                m_regionName = m_Scene.RegionInfo.RegionName;
                m_assetCache = m_Scene.CommsManager.AssetCache;
                m_inventoryProviderSelector = ProviderRegistry.Instance.Get<IInventoryProviderSelector>();
                m_checkedStorageProvider = m_inventoryProviderSelector.GetCheckedProvider(m_Caps.AgentID);
                m_libraryFolder = m_Scene.CommsManager.LibraryRoot;

                m_inventoryPool.Name = "Inventory Caps " + agentID; 
            }
示例#16
0
        private List<InventoryFolderImpl> TraverseFolder(InventoryFolderImpl node)
        {
            List<InventoryFolderImpl> folders = node.RequestListOfFolderImpls();
            List<InventoryFolderImpl> subs = new List<InventoryFolderImpl>();
            foreach (InventoryFolderImpl f in folders)
                subs.AddRange(TraverseFolder(f));

            folders.AddRange(subs);
            return folders;
        }
        /// <summary>
        /// Replicate the inventory paths in the archive to the user's inventory as necessary.
        /// </summary>
        /// <param name="fsPath"></param>
        /// <param name="isDir">Is the path we're dealing with a directory?</param>
        /// <param name="rootDestinationFolder">The root folder for the inventory load</param>
        /// <param name="foldersCreated">
        /// The folders created so far.  This method will add more folders if necessary
        /// </param>
        /// <param name="nodesLoaded">
        /// Track the inventory nodes created.  This is distinct from the folders created since for a particular folder
        /// chain, only the root node needs to be recorded
        /// </param>
        /// <returns>The last user inventory folder created or found for the archive path</returns>
        public InventoryFolderImpl ReplicateArchivePathToUserInventory(
            string fsPath, 
            bool isDir, 
            InventoryFolderImpl rootDestinationFolder, 
            Dictionary <string, InventoryFolderImpl> foldersCreated,
            List<InventoryNodeBase> nodesLoaded)
        {
            fsPath = fsPath.Substring(ArchiveConstants.INVENTORY_PATH.Length);

            // Remove the file portion if we aren't already dealing with a directory path
            if (!isDir)
                fsPath = fsPath.Remove(fsPath.LastIndexOf("/") + 1);

            string originalFsPath = fsPath;

            m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath);

            InventoryFolderImpl foundFolder = null;

            // XXX: Nasty way of dealing with a path that has no directory component
            if (!String.IsNullOrEmpty(fsPath))
            {
                while (null == foundFolder && !String.IsNullOrEmpty(fsPath))
                {
                    if (foldersCreated.ContainsKey(fsPath))
                    {
                        m_log.DebugFormat("[INVENTORY ARCHIVER]: Found previously created fs path {0}", fsPath);
                        foundFolder = foldersCreated[fsPath];
                    }
                    else
                    {
                        // Don't include the last slash
                        int penultimateSlashIndex = fsPath.LastIndexOf("/", fsPath.Length - 2);

                        if (penultimateSlashIndex >= 0)
                        {
                            fsPath = fsPath.Remove(penultimateSlashIndex + 1);
                        }
                        else
                        {
                            m_log.DebugFormat(
                                "[INVENTORY ARCHIVER]: Found no previously created fs path for {0}",
                                originalFsPath);
                            fsPath = String.Empty;
                            foundFolder = rootDestinationFolder;
                        }
                    }
                }
            }
            else
            {
                foundFolder = rootDestinationFolder;
            }

            string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length);
            string[] rawDirsToCreate
                = fsPathSectionToCreate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            int i = 0;

            while (i < rawDirsToCreate.Length)
            {
                m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawDirsToCreate[i]);

                int identicalNameIdentifierIndex
                    = rawDirsToCreate[i].LastIndexOf(
                        ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR);
                string folderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex);

                UUID newFolderId = UUID.Random();
                m_userInfo.CreateFolder(
                    folderName, newFolderId, (short)AssetType.Folder, foundFolder.ID);
                foundFolder = foundFolder.GetChildFolder(newFolderId);

                // Record that we have now created this folder
                fsPath += rawDirsToCreate[i] + "/";
                m_log.DebugFormat("[INVENTORY ARCHIVER]: Recording creation of fs path {0}", fsPath);
                foldersCreated[fsPath] = foundFolder;

                if (0 == i)
                    nodesLoaded.Add(foundFolder);

                i++;
            }         
            
            return foundFolder;
            
            /*
            string[] rawFolders = filePath.Split(new char[] { '/' });

            // Find the folders that do exist along the path given
            int i = 0;
            bool noFolder = false;
            InventoryFolderImpl foundFolder = rootDestinationFolder;
            while (!noFolder && i < rawFolders.Length)
            {
                InventoryFolderImpl folder = foundFolder.FindFolderByPath(rawFolders[i]);
                if (null != folder)
                {
                    m_log.DebugFormat("[INVENTORY ARCHIVER]: Found folder {0}", folder.Name);
                    foundFolder = folder;
                    i++;
                }
                else
                {
                    noFolder = true;
                }
            }

            // Create any folders that did not previously exist
            while (i < rawFolders.Length)
            {
                m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawFolders[i]);

                UUID newFolderId = UUID.Random();
                m_userInfo.CreateFolder(
                    rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
                foundFolder = foundFolder.GetChildFolder(newFolderId);
            }
            */            
        }
示例#18
0
        ///<summary>
        /// This method is called if a given model avatar name can not be found. If the external
        /// file has already been loaded once, then control returns immediately. If not, then it
        /// looks for a default appearance file. This file contains XML definitions of zero or more named
        /// avatars, each avatar can specify zero or more "outfits". Each outfit is a collection
        /// of items that together, define a particular ensemble for the avatar. Each avatar should
        /// indicate which outfit is the default, and this outfit will be automatically worn. The
        /// other outfits are provided to allow "real" avatars a way to easily change their outfits.
        /// </summary>

        private bool createDefaultAvatars()
        {
            // Only load once

            if (daload)
            {
                return false;
            }

            m_log.DebugFormat("[RADMIN] Creating default avatar entries");

            daload = true;

            // Load processing starts here...

            try
            {
                string dafn = null;

                //m_config may be null if RemoteAdmin configuration secition is missing or disabled in OpenSim.ini
                if (m_config != null)
                {
                    dafn = m_config.GetString("default_appearance", "default_appearance.xml");
                }

                if (File.Exists(dafn))
                {
                    XmlDocument doc = new XmlDocument();
                    string name     = "*unknown*";
                    string email    = "anon@anon";
                    uint   regX     = 1000;
                    uint   regY     = 1000;
                    string passwd   = UUID.Random().ToString(); // No requirement to sign-in.
                    CachedUserInfo UI;
                    UUID ID = UUID.Zero;
                    AvatarAppearance mava;
                    XmlNodeList avatars;
                    XmlNodeList assets;
                    XmlNode perms = null;
                    bool include = false;
                    bool select  = false;

                    UICallback uic;
                    IInventoryService iserv = m_app.SceneManager.CurrentOrFirstScene.InventoryService;
                    IAssetService     aserv = m_app.SceneManager.CurrentOrFirstScene.AssetService;

                    doc.LoadXml(File.ReadAllText(dafn));

                    // Load up any included assets. Duplicates will be ignored
                    assets = doc.GetElementsByTagName("RequiredAsset");
                    foreach (XmlNode asset in assets)
                    {
                        AssetBase rass   = new AssetBase();
                        rass.FullID      = UUID.Random();
                        rass.Name        = GetStringAttribute(asset,"name","");
                        rass.Description = GetStringAttribute(asset,"desc","");
                        rass.Type        = SByte.Parse(GetStringAttribute(asset,"type",""));
                        rass.Local       = Boolean.Parse(GetStringAttribute(asset,"local",""));
                        rass.Temporary   = Boolean.Parse(GetStringAttribute(asset,"temporary",""));
                        rass.Data        = Convert.FromBase64String(asset.InnerText);
                        aserv.Store(rass);
                    }

                    avatars = doc.GetElementsByTagName("Avatar");

                    // The document may contain multiple avatars

                    foreach (XmlElement avatar in avatars)
                    {
                        m_log.DebugFormat("[RADMIN] Loading appearance for {0}, gender = {1}",
                            GetStringAttribute(avatar,"name","?"), GetStringAttribute(avatar,"gender","?"));

                        // Create the user identified by the avatar entry

                        try
                        {
                            // Only the name value is mandatory
                            name   = GetStringAttribute(avatar,"name",name);
                            email  = GetStringAttribute(avatar,"email",email);
                            regX   = GetUnsignedAttribute(avatar,"regx",regX);
                            regY   = GetUnsignedAttribute(avatar,"regy",regY);
                            passwd = GetStringAttribute(avatar,"password",passwd);

                            string[] nomens = name.Split();
                            UI = m_app.CommunicationsManager.UserProfileCacheService.GetUserDetails(nomens[0], nomens[1]);
                            if (null == UI)
                            {
                                ID = m_app.CommunicationsManager.UserAdminService.AddUser(nomens[0], nomens[1],
                                                                                         passwd, email, regX, regY);
                                if (ID == UUID.Zero)
                                {
                                    m_log.ErrorFormat("[RADMIN] Avatar {0} {1} was not created", nomens[0], nomens[1]);
                                    return false;
                                }
                            }
                            else
                            {
                                ID = UI.UserProfile.ID;
                            }

                            m_log.DebugFormat("[RADMIN] User {0}[{1}] created or retrieved", name, ID);
                            include = true;
                        }
                        catch (Exception e)
                        {
                            m_log.DebugFormat("[RADMIN] Error creating user {0} : {1}", name, e.Message);
                            include = false;
                        }

                        // OK, User has been created OK, now we can install the inventory.
                        // First retrieve the current inventory (the user may already exist)
                        // Note that althought he inventory is retrieved, the hierarchy has
                        // not been interpreted at all.

                        if (include)
                        {
                            uic = new UICallback();
                            // Request the inventory
                            iserv.GetUserInventory(ID, uic.callback);

                            // While the inventory is being fetched, setup for appearance processing
                            if ((mava = m_app.CommunicationsManager.AvatarService.GetUserAppearance(ID)) == null)
                            {
                                mava = new AvatarAppearance();
                            }

                            {
                                AvatarWearable[] wearables = mava.Wearables;
                                for (int i=0; i<wearables.Length; i++)
                                {
                                    wearables[i] = new AvatarWearable();
                                }
                            }

                            // Wait for the inventory to arrive
                            uic.GetInventory();

                            // We can only get dresssed if an inventory is forthcoming
                            if (uic.OK)
                            try
                            {
                                m_log.DebugFormat("[RADMIN] {0} folders, {1} items in inventory",
                                   uic.folders.Count, uic.items.Count);

                                InventoryFolderImpl cfolder = uic.root.FindFolderForType(5);

                                // This should *never* be the case
                                if (cfolder == null)
                                {
                                    cfolder = new InventoryFolderImpl();
                                    cfolder.Name     = "Clothing";
                                    cfolder.Type     = 5;
                                    cfolder.Version  = 1;
                                    cfolder.Owner    = ID;
                                    uic.root.AddChildFolder(cfolder); // make connection
                                    iserv.AddFolder(cfolder);     // store base record
                                    m_log.ErrorFormat("[RADMIN] Created clothing folder for {0}/{1}", name, ID);
                                }

                                // OK, now we have an inventory for the user, read in the outfits from the
                                // default appearance XMl file.

                                XmlNodeList outfits = avatar.GetElementsByTagName("Ensemble");
                                InventoryFolderImpl efolder;
                                string oname;
                                UUID assetid;

                                foreach (XmlElement outfit in outfits)
                                {
                                    m_log.DebugFormat("[RADMIN] Loading outfit {0} for {1}",
                                        GetStringAttribute(outfit,"name","?"), GetStringAttribute(avatar,"name","?"));

                                    oname   = GetStringAttribute(outfit,"name","");
                                    select  = (GetStringAttribute(outfit,"default","no") == "yes");
                                    efolder = null;

                                    // If the folder already exists, re-use it. The defaults may
                                    // change over time. Augment only.
                                    foreach (InventoryFolderImpl folder in uic.folders)
                                    {
                                    if (folder.Name == oname && folder.ParentID == cfolder.ID)
                                        {
                                            efolder = folder;
                                            break;
                                        }
                                    }

                                    // Otherwise, we must create the folder.
                                    if (efolder == null)
                                    {
                                        m_log.DebugFormat("[RADMIN] Creating outfit folder {0} for {1}", oname, name);
                                        efolder          = new InventoryFolderImpl();
                                        efolder.ID       = UUID.Random();
                                        efolder.Name     = oname;
                                        efolder.Type     = 5;
                                        efolder.Version  = 1;
                                        efolder.Owner    = ID;
                                        cfolder.AddChildFolder(efolder); // make connection
                                        iserv.AddFolder(efolder);        // store base record
                                        m_log.DebugFormat("[RADMIN] Adding outfile folder {0} to folder {1}", efolder.ID, cfolder.ID);
                                    }

                                    // Now get the pieces that make up the outfit
                                    XmlNodeList items = outfit.GetElementsByTagName("Item");

                                    foreach (XmlElement item in items)
                                    {
                                        assetid = UUID.Zero;
                                        XmlNodeList children = item.ChildNodes;
                                        foreach (XmlNode child in children)
                                        {
                                            switch (child.Name)
                                            {
                                                case "Permissions" :
                                                    m_log.DebugFormat("[RADMIN] Permissions specified");
                                                    perms = child;
                                                    break;
                                                case "Asset" :
                                                    assetid = new UUID(child.InnerText);
                                                    break;
                                            }
                                        }

                                        InventoryItemBase iitem = null;

                                        if ((iitem = efolder.FindAsset(assetid)) == null)
                                        {
                                            iitem = new InventoryItemBase();
                                            iitem.ID = UUID.Random();
                                            iitem.Name = GetStringAttribute(item,"name","");
                                            iitem.Description = GetStringAttribute(item,"desc","");
                                            iitem.InvType = GetIntegerAttribute(item,"invtype",-1);
                                            iitem.AssetType = GetIntegerAttribute(item,"assettype",-1);
                                            iitem.Flags = GetUnsignedAttribute(item,"flags",0);
                                            iitem.AssetID = assetid; // associated asset
                                            iitem.Folder = efolder.ID; // Parent folder
                                            iitem.Owner = ID; // Agent ID
                                            iitem.BasePermissions = GetUnsignedAttribute(perms,"base",0x7fffffff);
                                            iitem.NextPermissions = GetUnsignedAttribute(perms,"next",0x7fffffff);
                                            iitem.CurrentPermissions = GetUnsignedAttribute(perms,"current",0x7fffffff);
                                            iitem.GroupPermissions = GetUnsignedAttribute(perms,"group",0x7fffffff);
                                            iitem.EveryOnePermissions = GetUnsignedAttribute(perms,"everyone",0x7fffffff);
                                            m_log.DebugFormat("[RADMIN] Adding item {0} to folder {1}", iitem.ID, efolder.ID);
                                            iserv.AddItem(iitem);
                                        }
                                        // Record whether or not the item is to be initially worn
                                        try
                                        {
                                        if (select && (GetStringAttribute(item, "wear", "false") == "true"))
                                            {
                                                mava.Wearables[iitem.Flags].ItemID = iitem.ID;
                                                mava.Wearables[iitem.Flags].AssetID = iitem.AssetID;
                                            }
                                        }
                                        catch {}
                                    } // foreach item in outfit
                                    m_log.DebugFormat("[RADMIN] Outfit {0} load completed", oname);
                                } // foreach outfit
                                m_log.DebugFormat("[RADMIN] Inventory update complete for {0}", name);
                                m_app.CommunicationsManager.AvatarService.UpdateUserAppearance(ID, mava);
                            }
                            catch (Exception e)
                            {
                                m_log.WarnFormat("[RADMIN] Inventory processing incomplete for user {0} : {1}",
                                    name, e.Message);
                            }
                            else
                            {
                                m_log.WarnFormat("[RADMIN] Unable to retrieve inventory for {0}[{1}]",
                                    name, ID);
                                // continue to next avatar
                            }
                        } // End of include
                    }
                    m_log.DebugFormat("[RADMIN] Default avatar loading complete");
                }
                else
                {
                    m_log.DebugFormat("[RADMIN] No default avatar information available");
                    return false;
                }
            }
            catch (Exception e)
            {
                m_log.WarnFormat("[RADMIN] Exception whilst loading default avatars ; {0}", e.Message);
                return false;
            }

            return true;
        }
示例#19
0
        private void LoadPreviouslyLoadedArchives(IRegistryCore registry)
        {
            IUserAccountService UserAccountService = registry.RequestModuleInterface<IUserAccountService>();
            UserAccount uinfo = UserAccountService.GetUserAccount(UUID.Zero, LibraryOwner);
            IInventoryService InventoryService = registry.RequestModuleInterface<IInventoryService>();
            //Make the user account for the default IAR
            if (uinfo == null)
            {
                uinfo = new UserAccount(LibraryOwner);
                uinfo.FirstName = LibraryOwnerName[0];
                uinfo.LastName = LibraryOwnerName[1];
                uinfo.Email = "";
                uinfo.ServiceURLs = new Dictionary<string, object>();
                uinfo.UserLevel = 0;
                uinfo.UserFlags = 0;
                uinfo.ScopeID = UUID.Zero;
                uinfo.UserTitle = "";
                UserAccountService.StoreUserAccount(uinfo);
                InventoryService.CreateUserInventory(uinfo.PrincipalID);
            }
            InventoryCollection col = InventoryService.GetFolderContent(LibraryOwner, UUID.Zero);
            foreach (InventoryFolderBase folder in col.Folders)
            {
                if (folder.Name == "My Inventory") continue; //Pass My Inventory by
                InventoryFolderImpl f = new InventoryFolderImpl(folder);

                TraverseFolders(f, folder.ID, InventoryService);
                //This is our loaded folder
                AddToDefaultInventory(f);
            }
        }
示例#20
0
 private void TraverseFolders(InventoryFolderImpl folderimp, UUID ID, IInventoryService InventoryService)
 {
     InventoryCollection col = InventoryService.GetFolderContent(LibraryOwner, ID);
     foreach (InventoryItemBase item in col.Items)
     {
         folderimp.Items.Add(item.ID, item);
     }
     foreach (InventoryFolderBase folder in col.Folders)
     {
         InventoryFolderImpl childFolder = new InventoryFolderImpl(folder);
         TraverseFolders(childFolder, folder.ID, InventoryService);
         folderimp.AddChildFolder(childFolder);
     }
 }
示例#21
0
 public void AddToDefaultInventory(InventoryFolderImpl folder)
 {
     foreach (InventoryFolderImpl f in folder.RequestListOfFolderImpls())
         m_LibraryRootFolder.AddChildFolder(f);
     foreach (InventoryItemBase i in folder.RequestListOfItems())
         m_LibraryRootFolder.Items.Add(i.ID, i);
 }
示例#22
0
        /// <summary>
        /// Read a library inventory folder from a loaded configuration
        /// </summary>
        /// <param name="source"></param>
        private void ReadFolderFromConfig(IConfig config, string path)
        {
            InventoryFolderImpl folderInfo = new InventoryFolderImpl();

            folderInfo.ID = new UUID(config.GetString("folderID", m_LibraryRootFolder.ID.ToString()));
            folderInfo.Name = config.GetString("name", "unknown");
            folderInfo.ParentID = new UUID(config.GetString("parentFolderID", m_LibraryRootFolder.ID.ToString()));
            folderInfo.Type = (short)config.GetInt("type", 8);

            folderInfo.Owner = libOwner;
            folderInfo.Version = 1;

            if (libraryFolders.ContainsKey(folderInfo.ParentID))
            {
                InventoryFolderImpl parentFolder = libraryFolders[folderInfo.ParentID];

                libraryFolders.Add(folderInfo.ID, folderInfo);
                parentFolder.AddChildFolder(folderInfo);

//                 m_log.InfoFormat("[LIBRARY INVENTORY]: Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID);
            }
            else
            {
                m_log.WarnFormat(
                    "[LIBRARY INVENTORY]: Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!",
                    folderInfo.Name, folderInfo.ID, folderInfo.ParentID);
            }
        }
示例#23
0
        private void addProperties()
        {
            Owner = libOwner;
            ID = new UUID("00000112-000f-0000-0000-000100bba005");
            this.Name = "World Library";
            this.ParentID = new UUID("00000112-000f-0000-0000-000100bba000");
            Type = (short)8;
            Version = (ushort)1;

            m_WorldTexturesFolder = CreateChildFolder(new UUID("00000112-000f-0000-0000-000100bba006"), "Textures", (ushort)8);

            m_World3DModelsFolder = CreateChildFolder(new UUID("00000112-000f-0000-0000-000100bba007"), "3D Models", (ushort)8);

            m_WorldMaterialScriptsFolder = CreateChildFolder(new UUID("00000112-000f-0000-0000-000100bba008"), "Material Scripts", (ushort)8);

            m_World3DModelAnimationsFolder = CreateChildFolder(new UUID("00000112-000f-0000-0000-000100bba009"), "3D Model Animations", (ushort)8);

            m_WorldParticleScriptsFolder = CreateChildFolder(new UUID("00000112-000f-0000-0000-000100bba010"), "Particle Scripts", (ushort)8);

            m_WorldSoundsFolder = CreateChildFolder(new UUID("00000112-000f-0000-0000-000100bba011"), "Sounds", (ushort)8);

            m_WorldFlashFolder = CreateChildFolder(new UUID("00000112-000f-0000-0000-000100bba012"), "Flash Animations", (ushort)8);

            WorldFolders.Add(m_WorldTexturesFolder);
            WorldFolders.Add(m_World3DModelsFolder);
            WorldFolders.Add(m_WorldMaterialScriptsFolder);
            WorldFolders.Add(m_World3DModelAnimationsFolder);
            WorldFolders.Add(m_WorldParticleScriptsFolder);
            WorldFolders.Add(m_WorldSoundsFolder);
            WorldFolders.Add(m_WorldFlashFolder);
            WorldFolders.Add(this);
        }
示例#24
0
        /// <summary>
        /// This method is called by updateAvatarAppearance once any specified model has been
        /// ratified, or an appropriate default value has been adopted. The intended prototype
        /// is known to exist, as is the target avatar.
        /// </summary>

        private void establishAppearance(UUID dest, UUID srca)
        {
            m_log.DebugFormat("[RADMIN] Initializing inventory for {0} from {1}", dest, srca);

            AvatarAppearance ava = m_app.CommunicationsManager.AvatarService.GetUserAppearance(srca);

            // If the model has no associated appearance we're done.

            // if (ava == null)
            // {
            //     return new AvatarAppearance();
            // }

            if (ava == null)
                return;

            UICallback sic  = new UICallback();
            UICallback dic  = new UICallback();
            IInventoryService iserv = m_app.SceneManager.CurrentOrFirstScene.InventoryService;

            try
            {
                Dictionary<UUID,UUID> imap = new Dictionary<UUID,UUID>();

                iserv.GetUserInventory(dest, dic.callback);
                iserv.GetUserInventory(srca, sic.callback);

                dic.GetInventory();
                sic.GetInventory();

                if (sic.OK && dic.OK)
                {
                    InventoryFolderImpl efolder;
                    InventoryFolderImpl srcf = sic.root.FindFolderForType(5);
                    InventoryFolderImpl dstf = dic.root.FindFolderForType(5);

                    if (srcf == null || dstf == null)
                        throw new Exception("Cannot locate clothing folder(s)");

                    foreach (InventoryFolderImpl folder in sic.folders)
                    {
                        if (folder.ParentID == srcf.ID)
                        {
                            efolder          = new InventoryFolderImpl();
                            efolder.ID       = UUID.Random();
                            efolder.Name     = folder.Name;
                            efolder.Type     = folder.Type;
                            efolder.Version  = folder.Version;
                            efolder.Owner    = dest;
                            dstf.AddChildFolder(efolder);
                            iserv.AddFolder(efolder);
                            m_log.DebugFormat("[RADMIN] Added outfile folder {0} to folder {1}", efolder.ID, srcf.ID);
                            foreach (InventoryItemBase item in sic.items)
                            {
                               if (item.Folder == folder.ID)
                                {
                                    InventoryItemBase dsti = new InventoryItemBase();
                                    dsti.ID = UUID.Random();
                                    dsti.Name = item.Name;
                                    dsti.Description = item.Description;
                                    dsti.InvType = item.InvType;
                                    dsti.AssetType = item.AssetType;
                                    dsti.Flags = item.Flags;
                                    dsti.AssetID = item.AssetID;
                                    dsti.Folder = efolder.ID;
                                    dsti.Owner = dest;
                                    dsti.BasePermissions = item.BasePermissions;
                                    dsti.NextPermissions = item.NextPermissions;
                                    dsti.CurrentPermissions = item.CurrentPermissions;
                                    dsti.GroupPermissions = item.GroupPermissions;
                                    dsti.EveryOnePermissions = item.EveryOnePermissions;
                                    iserv.AddItem(dsti);
                                    imap.Add(item.ID, dsti.ID);
                                    m_log.DebugFormat("[RADMIN] Added item {0} to folder {1}", dsti.ID, efolder.ID);
                                }
                            }
                        }
                    }

                    // Update appearance tables
                    AvatarWearable[] wearables = ava.Wearables;
                    for (int i=0; i<wearables.Length; i++)
                    {
                        if (imap.ContainsKey(wearables[i].ItemID))
                        {
                            AvatarWearable dw = new AvatarWearable();
                            dw.AssetID = wearables[i].AssetID;
                            dw.ItemID  = imap[wearables[i].ItemID];
                            ava.SetWearable(i, dw);
                        }
                    }
                }
                else
                {
                    throw new Exception("Unable to load both inventories");
                }

                m_app.CommunicationsManager.AvatarService.UpdateUserAppearance(dest, ava);
            }
            catch (Exception e)
            {
                m_log.WarnFormat("[RADMIN] Error transferring inventory for {0} : {1}",
                                 dest, e.Message);
                return;
            }

            return;
        }
示例#25
0
        public void Initialize(IConfigSource config, IRegistryCore registry)
        {
            string pLibOwnerName = "Library Owner";

            IConfig libConfig = config.Configs["LibraryService"];
            if (libConfig != null)
            {
                pLibName = libConfig.GetString("LibraryName", pLibName);
                pLibOwnerName = libConfig.GetString("LibraryOwnerName", pLibOwnerName);
            }

            libOwnerName = pLibOwnerName.Split(' ');
            if (libOwnerName.Length != 2)
            {
                //Reset it if it isn't the right length
                libOwnerName = new string[2] { "Library", "Owner"};
            }

            //m_log.Debug("[LIBRARY]: Starting library service...");

            m_LibraryRootFolder = new InventoryFolderImpl();
            m_LibraryRootFolder.Owner = libOwner;
            m_LibraryRootFolder.ID = new UUID("00000112-000f-0000-0000-000100bba000");
            m_LibraryRootFolder.Name = pLibName;
            m_LibraryRootFolder.ParentID = UUID.Zero;
            m_LibraryRootFolder.Type = (short)8;
            m_LibraryRootFolder.Version = (ushort)1;

            registry.RegisterModuleInterface<ILibraryService>(this);
        }
示例#26
0
        public void GetInventory()
        {
            Dictionary<UUID, InventoryFolderImpl> fmap = new Dictionary<UUID, InventoryFolderImpl>();

            if (OK == false)
            {
                lock (uilock)
                {
                    if (OK == false)
                        System.Threading.Monitor.Wait(uilock);
                }
            }

            // Got the inventory OK. So now merge the content of the default appearance
            // file with whatever we already have in-world. For convenience we initialize
            // the inventory hierarchy.

            // Find root and build an index

            foreach (InventoryFolderImpl folder in folders)
            {
                if (folder.ParentID == UUID.Zero)
                {
                    if (root == null)
                    {
                        root = folder;
                    }
                    else
                    {
                        throw new Exception("Multiple root folders found");
                    }
                }
                fmap.Add(folder.ID, folder);
            }

            // Hard to continue if the root folder is not there
            if (root == null)
            {
                throw new Exception("Root folder not found");
            }

            // Construct the folder hierarchy
            foreach (InventoryFolderImpl folder in folders)
            {
                if (folder.ID != root.ID)
                {
                    fmap[folder.ParentID].AddChildFolder(folder);
                }
            }

            // Find a home for every pre-existing item
            foreach (InventoryItemBase item in items)
            {
                 fmap[item.Folder].Items.Add(item.ID, item);
            }
        }
 public LocalInventoryService(InventoryFolderImpl lib)
 {
     m_Library = lib;
 }
        /// <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(InventoryFolderImpl inventoryFolder, string path, bool saveThisFolderItself)
        {
            if (saveThisFolderItself)
            {
                path +=
                    string.Format(
                        "{0}{1}{2}/",
                        inventoryFolder.Name,
                        ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR,
                        inventoryFolder.ID);

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

            List<InventoryFolderImpl> childFolders = inventoryFolder.RequestListOfFolderImpls();
            List<InventoryItemBase> items = inventoryFolder.RequestListOfItems();

            /*
            Dictionary identicalFolderNames = new Dictionary<string, int>();

            foreach (InventoryFolderImpl folder in inventories)
            {

                if (!identicalFolderNames.ContainsKey(folder.Name))
                    identicalFolderNames[folder.Name] = 0;
                else
                    identicalFolderNames[folder.Name] = identicalFolderNames[folder.Name]++;

                int folderNameNumber = identicalFolderName[folder.Name];

                SaveInvDir(
                    folder,
                    string.Format(
                        "{0}{1}{2}/",
                        path, ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, folderNameNumber));
            }
            */

            foreach (InventoryFolderImpl childFolder in childFolders)
            {
                SaveInvFolder(childFolder, path, true);
            }

            foreach (InventoryItemBase item in items)
            {
                SaveInvItem(item, path);
            }
        }
示例#29
0
//        private void DumpLibrary()
//        {
//            InventoryFolderImpl lib = m_Library.LibraryRootFolder;
//
//            m_log.DebugFormat(" - folder {0}", lib.Name);
//            DumpFolder(lib);
//        }
//
//        private void DumpLibrary()
//        {
//            InventoryFolderImpl lib = m_Scene.CommsManager.UserProfileCacheService.LibraryRoot;
//
//            m_log.DebugFormat(" - folder {0}", lib.Name);
//            DumpFolder(lib);
//        }

        private void DumpFolder(InventoryFolderImpl folder)
        {
            foreach (InventoryItemBase item in folder.Items.Values)
            {
                m_log.DebugFormat("   --> item {0}", item.Name);
            }
            foreach (InventoryFolderImpl f in folder.RequestListOfFolderImpls())
            {
                m_log.DebugFormat(" - folder {0}", f.Name);
                DumpFolder(f);
            }
        }
示例#30
0
 /// <summary>
 /// Add a folder that already exists.
 /// </summary>
 /// <param name="folder"></param>
 public void AddChildFolder(InventoryFolderImpl folder)
 {
     lock (m_childFolders)
     {
         folder.ParentID = ID;
         m_childFolders[folder.ID] = folder;
     }
 }
示例#31
0
        public void Initialize(IConfigSource config, IRegistryCore registry)
        {
            string pLibOwnerName = "Library Owner";

            IConfig libConfig = config.Configs["LibraryService"];
            if (libConfig != null)
            {
                m_enabled = true;
                pLibName = libConfig.GetString("LibraryName", pLibName);
                libOwnerName = libConfig.GetString("LibraryOwnerName", pLibOwnerName);
            }

            //m_log.Debug("[LIBRARY]: Starting library service...");

            m_LibraryRootFolder = new InventoryFolderImpl();
            m_LibraryRootFolder.Owner = libOwner;
            m_LibraryRootFolder.ID = new UUID("00000112-000f-0000-0000-000100bba000");
            m_LibraryRootFolder.Name = pLibName;
            m_LibraryRootFolder.ParentID = UUID.Zero;
            m_LibraryRootFolder.Type = (short)8;
            m_LibraryRootFolder.Version = (ushort)1;

            registry.RegisterModuleInterface<ILibraryService>(this);
            m_registry = registry;
        }