コード例 #1
0
        private void DoCreateItem(uint callbackID)
        {
            m_createItem = false;   // don't create or bill for the same item more than once

            try
            {
                m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(m_asset, AssetRequestInfo.GenericNetRequest());
            }
            catch (AssetServerException e)
            {
                ourClient.SendAgentAlertMessage("Unable to upload asset. Please try again later.", false);
                m_log.ErrorFormat("[ASSET TRANSACTIONS] Asset storage failed: {0}", e);
                return;
            }

            CachedUserInfo userInfo =
                m_userTransactions.Manager.MyScene.CommsManager.UserService.GetUserDetails(
                    ourClient.AgentId);

            if (userInfo != null)
            {
                InventoryItemBase item = new InventoryItemBase();
                item.Owner               = ourClient.AgentId;
                item.CreatorId           = ourClient.AgentId.ToString();
                item.ID                  = UUID.Random();
                item.AssetID             = m_asset.FullID;
                item.Description         = m_description;
                item.Name                = m_name;
                item.AssetType           = type;
                item.InvType             = invType;
                item.Folder              = InventFolder;
                item.BasePermissions     = (uint)(PermissionMask.All | PermissionMask.Export);
                item.CurrentPermissions  = (uint)(PermissionMask.All | PermissionMask.Export);
                item.GroupPermissions    = (uint)PermissionMask.None;
                item.EveryOnePermissions = (uint)PermissionMask.None;
                item.NextPermissions     = nextPerm;
                item.Flags               = (uint)wearableType;

                item.CreationDate = Util.UnixTimeSinceEpoch();

                userInfo.AddItem(item);
                ourClient.SendInventoryItemCreateUpdate(item, callbackID);

                // Charge for the upload if appropriate.
                IMoneyModule mm = ourClient.Scene.RequestModuleInterface <IMoneyModule>();
                if (mm != null)
                {
                    if (mm.UploadChargeApplies((AssetType)m_asset.Type) && !m_asset.Temporary)
                    {
                        mm.ApplyUploadCharge(ourClient.AgentId);
                    }
                }
            }
            else
            {
                m_log.ErrorFormat("[ASSET TRANSACTIONS]: Could not find user {0} for inventory item creation", ourClient.AgentId);
            }
        }
コード例 #2
0
ファイル: AssetXferUploader.cs プロジェクト: boodie/Opensim2
        private void DoCreateItem(uint callbackID)
        {
            m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(m_asset);
            CachedUserInfo userInfo =
                m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails(
                    ourClient.AgentId);

            if (userInfo != null)
            {
                InventoryItemBase item = new InventoryItemBase();
                item.Owner               = ourClient.AgentId;
                item.CreatorId           = ourClient.AgentId.ToString();
                item.ID                  = UUID.Random();
                item.AssetID             = m_asset.FullID;
                item.Description         = m_description;
                item.Name                = m_name;
                item.AssetType           = type;
                item.InvType             = invType;
                item.Folder              = InventFolder;
                item.BasePermissions     = 0x7fffffff;
                item.CurrentPermissions  = 0x7fffffff;
                item.GroupPermissions    = 0;
                item.EveryOnePermissions = 0;
                item.NextPermissions     = nextPerm;
                item.Flags               = (uint)wearableType;
                item.CreationDate        = Util.UnixTimeSinceEpoch();

                userInfo.AddItem(item);
                ourClient.SendInventoryItemCreateUpdate(item, callbackID);
            }
            else
            {
                m_log.ErrorFormat(
                    "[ASSET TRANSACTIONS]: Could not find user {0} for inventory item creation",
                    ourClient.AgentId);
            }
        }
コード例 #3
0
        /// <summary>
        /// Execute the request
        /// </summary>
        /// <returns>
        /// A list of the inventory nodes loaded.  If folders were loaded then only the root folders are
        /// returned
        /// </returns>
        public List <InventoryNodeBase> Execute()
        {
            string filePath = "ERROR";
            int    successfulAssetRestores       = 0;
            int    failedAssetRestores           = 0;
            int    successfulItemRestores        = 0;
            List <InventoryNodeBase> nodesLoaded = new List <InventoryNodeBase>();

            if (!m_userInfo.HasReceivedInventory)
            {
                // If the region server has access to the user admin service (by which users are created),
                // then we'll assume that it's okay to fiddle with the user's inventory even if they are not on the
                // server.
                //
                // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might
                // use a remote inventory service, though this is vanishingly rare at the moment.
                if (null == m_commsManager.UserAdminService)
                {
                    m_log.ErrorFormat(
                        "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}",
                        m_userInfo.UserProfile.Name, m_userInfo.UserProfile.ID);

                    return(nodesLoaded);
                }
                else
                {
                    m_userInfo.FetchInventory();
                }
            }

            InventoryFolderImpl rootDestinationFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath);

            if (null == rootDestinationFolder)
            {
                // Possibly provide an option later on to automatically create this folder if it does not exist
                m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath);

                return(nodesLoaded);
            }

            archive = new TarArchiveReader(m_loadStream);

            // In order to load identically named folders, we need to keep track of the folders that we have already
            // created
            Dictionary <string, InventoryFolderImpl> foldersCreated = new Dictionary <string, InventoryFolderImpl>();

            byte[] data;
            TarArchiveReader.TarEntryType entryType;
            while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
            {
                if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
                {
                    if (LoadAsset(filePath, data))
                    {
                        successfulAssetRestores++;
                    }
                    else
                    {
                        failedAssetRestores++;
                    }
                }
                else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH))
                {
                    InventoryFolderImpl foundFolder
                        = ReplicateArchivePathToUserInventory(
                              filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType,
                              rootDestinationFolder, foldersCreated, nodesLoaded);

                    if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
                    {
                        InventoryItemBase item = UserInventoryItemSerializer.Deserialize(data);

                        // Don't use the item ID that's in the file
                        item.ID = UUID.Random();

                        UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_commsManager);
                        if (UUID.Zero != ospResolvedId)
                        {
                            item.CreatorIdAsUuid = ospResolvedId;
                        }

                        item.Owner = m_userInfo.UserProfile.ID;

                        // Reset folder ID to the one in which we want to load it
                        item.Folder = foundFolder.ID;

                        m_userInfo.AddItem(item);
                        successfulItemRestores++;

                        // If we're loading an item directly into the given destination folder then we need to record
                        // it separately from any loaded root folders
                        if (rootDestinationFolder == foundFolder)
                        {
                            nodesLoaded.Add(item);
                        }
                    }
                }
            }

            archive.Close();

            m_log.DebugFormat("[INVENTORY ARCHIVER]: Restored {0} assets", successfulAssetRestores);
            m_log.InfoFormat("[INVENTORY ARCHIVER]: Restored {0} items", successfulItemRestores);

            return(nodesLoaded);
        }
コード例 #4
0
            private void CreateLink()
            {
                if (!_scene.Permissions.CanCreateUserInventory((int)InventoryType.Wearable, _avatarID))
                {
                    return;
                }

                ScenePresence presence;

                if ((presence = _scene.GetScenePresence(_avatarID)) != null)
                {
                    // Don't link to default items
                    if ((_wearableInventoryItemID == AvatarWearable.DEFAULT_EYES_ITEM) ||
                        (_wearableInventoryItemID == AvatarWearable.DEFAULT_BODY_ITEM) ||
                        (_wearableInventoryItemID == AvatarWearable.DEFAULT_HAIR_ITEM) ||
                        (_wearableInventoryItemID == AvatarWearable.DEFAULT_PANTS_ITEM) ||
                        (_wearableInventoryItemID == AvatarWearable.DEFAULT_SHIRT_ITEM) ||
                        (_wearableInventoryItemID == AvatarWearable.DEFAULT_SKIN_ITEM))
                    {
                        return;
                    }

                    CachedUserInfo userInfo = _scene.CommsManager.UserService.GetUserDetails(_avatarID);

                    if (userInfo != null)
                    {
                        InventoryItemBase oldItem = null;
                        try
                        {
                            oldItem = userInfo.FindItem(_wearableInventoryItemID);
                        }
                        catch { }
                        if (oldItem == null)
                        {
                            return;//Item doesn't exist?
                        }
                        InventoryFolderBase CurrentOutfitFolder = GetCurrentOutfitFolder(userInfo);
                        if (CurrentOutfitFolder == null)
                        {
                            return;                              //No COF, just ignore
                        }
                        CurrentOutfitFolder.Version++;
                        userInfo.UpdateFolder(CurrentOutfitFolder);

                        InventoryItemBase item = new InventoryItemBase();
                        item.Owner        = _avatarID;
                        item.CreatorId    = _avatarID.ToString();
                        item.ID           = UUID.Random();
                        item.AssetID      = _wearableInventoryItemID;
                        item.Description  = oldItem.Description;
                        item.Name         = oldItem.Name;
                        item.Flags        = oldItem.Flags;
                        item.AssetType    = (int)AssetType.Link;
                        item.InvType      = (int)InventoryType.Wearable;
                        item.Folder       = CurrentOutfitFolder.ID;
                        item.CreationDate = Util.UnixTimeSinceEpoch();

                        item.BasePermissions     = (uint)(PermissionMask.All | PermissionMask.Export);
                        item.CurrentPermissions  = (uint)(PermissionMask.All | PermissionMask.Export);
                        item.GroupPermissions    = (uint)PermissionMask.None;
                        item.EveryOnePermissions = (uint)PermissionMask.None;
                        item.NextPermissions     = (uint)PermissionMask.All;

                        userInfo.AddItem(item);
                        presence.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
                    }
                    else
                    {
                        m_log.WarnFormat(
                            "No user details associated with client {0} uuid {1} in CreateNewInventoryItem!",
                            presence.Name, presence.UUID);
                    }
                }
                else
                {
                    m_log.ErrorFormat(
                        "ScenePresence for agent uuid {0} unexpectedly not found in HandleLinkInventoryItem",
                        _avatarID);
                }
            }