Пример #1
0
        /// <summary>
        /// Handle a fetch inventory request from the client
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="itemID"></param>
        /// <param name="ownerID"></param>
        public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID)
        {
            if (ownerID == CommsManager.LibraryRoot.Owner)
            {
                //m_log.Debug("request info for library item");
                return;
            }

            CachedUserInfo userProfile = CommsManager.UserService.GetUserDetails(remoteClient.AgentId);

            if (null == userProfile)
            {
                m_log.ErrorFormat(
                    "[AGENT INVENTORY]: Could not find user profile for {0} {1}",
                    remoteClient.Name, remoteClient.AgentId);
                return;
            }

            InventoryItemBase item = userProfile.FindItem(itemID);

            if (item != null)
            {
                remoteClient.SendInventoryItemDetails(ownerID, item);
            }
        }
        /// <summary>
        /// Start the process of requesting a given texture.
        /// </summary>
        /// <param name="sender"> </param>
        /// <param name="e"></param>
        public void TextureRequest(Object sender, TextureRequestArgs e)
        {
            IClientAPI client = (IClientAPI)sender;

            if (e.Priority == 1016001f) // Preview
            {
                if (client.Scene is Scene)
                {
                    Scene scene = (Scene)client.Scene;

                    CachedUserInfo profile = scene.CommsManager.UserService.GetUserDetails(client.AgentId);
                    if (profile == null) // Deny unknown user
                    {
                        return;
                    }

                    if (profile.UserProfile.GodLevel < 200 && profile.FindItem(e.RequestedAssetID) == null) // Deny if not owned
                    {
                        return;
                    }

                    m_log.Debug("Texture preview");
                }
            }

            UserTextureDownloadService textureService;

            if (TryGetUserTextureService(client, out textureService))
            {
                textureService.HandleTextureRequest(e);
            }
        }
        void RemoveInventoryItem(IClientAPI remoteClient, UUID itemID, bool forceDelete)
        {
            if (!_cofSyncEnabled)
            {
                return;
            }

            CachedUserInfo userInfo
                = m_scene.CommsManager.UserService.GetUserDetails(remoteClient.AgentId);

            if (userInfo == null)
            {
                return;
            }

            InventoryItemBase item = userInfo.FindItem(itemID);

            if (item != null && item.AssetType == (int)AssetType.Link)
            {
                lock (_currentlyWaitingCOFBuilds)
                {
                    if (!_viewer2Users.Contains(remoteClient.AgentId))
                    {
                        _viewer2Users.Add(remoteClient.AgentId);
                    }
                    bool add = false;
                    Dictionary <UUID, BuildCOF> waitingCOFs = new Dictionary <UUID, BuildCOF>();
                    if ((add = !_currentlyWaitingCOFBuilds.TryGetValue(remoteClient.AgentId, out waitingCOFs)))
                    {
                        waitingCOFs = new Dictionary <UUID, BuildCOF>();
                    }
                    if (waitingCOFs.ContainsKey(itemID))
                    {
                        BuildCOF cof = waitingCOFs[itemID];
                        cof.COFHasBeenSet();
                        if (cof.Finished())
                        {
                            waitingCOFs.Remove(itemID);
                        }
                    }
                    else
                    {
                        BuildCOF cof = new BuildCOF(ClearWaitingCOF);
                        cof.COFHasBeenSet();
                        waitingCOFs.Add(itemID, cof);
                    }
                    if (add)
                    {
                        _currentlyWaitingCOFBuilds.Add(remoteClient.AgentId, waitingCOFs);
                    }
                }
            }
        }
Пример #4
0
        private void TaskInventoryOfferDecline(IClientAPI client, Scene scene, GridInstantMessage im)
        {
            // The inventory item/folder, back from it's trip
            UUID inventoryEntityID = new UUID(im.imSessionID);

            // Here, the recipient is local and we can assume that the inventory is loaded.
            // Courtesy of the above bulk update, it will have been pushed to the client, too.
            CachedUserInfo userInfo = scene.CommsManager.UserService.GetUserDetails(client.AgentId);

            if (userInfo != null)
            {
                InventoryFolderBase trashFolder = userInfo.FindFolderForType((int)AssetType.TrashFolder);
                if (null == trashFolder)
                {
                    client.SendAgentAlertMessage("Unable to decline received inventory: Trash folder not found.", false);
                    return;
                }

                // Is it a folder or an item?
                if (userInfo.QueryItem(inventoryEntityID))
                {   // It's an item.
                    InventoryItemBase item = userInfo.FindItem(inventoryEntityID);
                    if (item == null)
                    {
                        client.SendAgentAlertMessage("Unable to decline received inventory: item/folder not found.", false);
                        return;
                    }
                    userInfo.MoveItemToTrash(item, trashFolder);
                    scene.AddInventoryItem(client, item);
                    client.SendInventoryItemCreateUpdate(item, 0);
                }
                else
                {   // It's a folder.
                    InventoryFolderBase folder = userInfo.GetFolderAttributes(inventoryEntityID);
                    userInfo.MoveFolder(inventoryEntityID, trashFolder.ID);
                    folder = userInfo.GetFolder(inventoryEntityID);
                    if (folder != null)
                    {
                        client.SendBulkUpdateInventory(folder);
                        // If we don't send the descendents, viewer shows "Loading..." on the trash item.
                        userInfo.SendInventoryDecendents(client, folder.ID, false, true);
                    }
                }
            }
        }
Пример #5
0
        private void TaskInventoryOfferAccept(IClientAPI client, Scene scene, GridInstantMessage im)
        {
            InventoryFolderBase folder = null;
            InventoryItemBase   item   = null;

            // The inventory item/folder, back from it's trip
            UUID inventoryEntityID = new UUID(im.imSessionID);

            // Here, the recipient is local and we can assume that the inventory is loaded.
            // Courtesy of the above bulk update, it will have been pushed to the client, too.
            CachedUserInfo userInfo = scene.CommsManager.UserService.GetUserDetails(client.AgentId);

            if (userInfo != null)
            {
                // Is it a folder or an item?
                if (userInfo.QueryItem(inventoryEntityID))
                {   // It's an item.
                    item = userInfo.FindItem(inventoryEntityID);
                    if (item == null)
                    {
                        client.SendAgentAlertMessage("Unable to accept received inventory: item/folder not found.", false);
                        return;
                    }
                    client.SendInventoryItemCreateUpdate(item, 0);
                }
                else
                {   // It's a folder.
                    folder = userInfo.GetFolder(inventoryEntityID);
                    if (folder != null)
                    {
                        client.SendBulkUpdateInventory(folder);
                        // If we don't send the descendents, viewer shows "Loading..." on the trash item.
                        userInfo.SendInventoryDecendents(client, folder.ID, false, true);
                    }
                }
            }

            //            RelayInventoryOfferIM(scene, im); // we don't need to notify a box that the user accepted this
        }
        private void SetAppearanceAssets(CachedUserInfo profile, ref List <AvatarWearable> wearables, IClientAPI clientView)
        {
            foreach (AvatarWearable wearable in wearables)
            {
                // Skip it if its empty
                if (wearable.ItemID == UUID.Zero)
                {
                    continue;
                }

                // Ignore ruth's assets
                if (((wearable.WearableType == AvatarWearable.BODY) && (wearable.ItemID == AvatarWearable.DEFAULT_BODY_ITEM)) ||
                    ((wearable.WearableType == AvatarWearable.SKIN) && (wearable.ItemID == AvatarWearable.DEFAULT_SKIN_ITEM)) ||
                    ((wearable.WearableType == AvatarWearable.HAIR) && (wearable.ItemID == AvatarWearable.DEFAULT_HAIR_ITEM)) ||
                    ((wearable.WearableType == AvatarWearable.EYES) && (wearable.ItemID == AvatarWearable.DEFAULT_EYES_ITEM)) ||
                    ((wearable.WearableType == AvatarWearable.SHIRT) && (wearable.ItemID == AvatarWearable.DEFAULT_SHIRT_ITEM)) ||
                    ((wearable.WearableType == AvatarWearable.PANTS) && (wearable.ItemID == AvatarWearable.DEFAULT_PANTS_ITEM)))
                {
                    continue;
                }

                // Otherwise look up the asset and store the translated value
                // XXX dont look up stuff we already know about.. save a trip to the asset server

                InventoryItemBase baseItem = profile.FindItem(wearable.ItemID);
                baseItem = profile.ResolveLink(baseItem);


                if (baseItem != null)
                {
                    wearable.AssetID = baseItem.AssetID;
                }
                else
                {
                    m_log.ErrorFormat("[APPEARANCE]: Can't find inventory item {0}", wearable.ItemID);
                }
            }
        }
            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);
                }
            }
Пример #8
0
        private void GridInventoryOffer(GridInstantMessage im)
        {
            if (im.binaryBucket.Length < 1) // Invalid
            {
                m_log.WarnFormat("[INVENTORY TRANSFER]: Invalid IM (binary bucket length {0}).", im.binaryBucket.Length);
                return;
            }

            Scene         scene = FindScene(new UUID(im.toAgentID));
            ScenePresence user  = scene.GetScenePresence(new UUID(im.toAgentID));

            if (user == null) // Shouldn't happen
            {
                m_log.Warn("[INVENTORY TRANSFER]: Can't find recipient");
                return;
            }

            CachedUserInfo userInfo =
                scene.CommsManager.UserService.
                GetUserDetails(user.ControllingClient.AgentId);

            if (userInfo == null)
            {
                m_log.Warn("[INVENTORY TRANSFER]: Can't find user info of recipient");
                return;
            }

            AssetType assetType         = (AssetType)im.binaryBucket[0];
            UUID      inventoryEntityID = UUID.Zero;

            if (im.binaryBucket.Length >= 17) // includes UUID
            {
                inventoryEntityID = new UUID(im.binaryBucket, 1);
            }

            if (AssetType.Folder == assetType)
            {
                if (inventoryEntityID != UUID.Zero)
                {
                    // Get folder info
                    InventoryFolderBase folder = userInfo.GetFolder(inventoryEntityID);
                    if (folder == null)
                    {
                        m_log.WarnFormat("[INVENTORY TRANSFER]: Can't retrieve folder {0} to give.", inventoryEntityID);
                        return;
                    }

                    // Update folder to viewer (makes it appear to user)
                    user.ControllingClient.SendBulkUpdateInventory(folder);
                    userInfo.SendInventoryDecendents(user.ControllingClient, folder.ID, false, true);
                }

                // Deliver message
                user.ControllingClient.SendInstantMessage(im);
            }
            else
            {
                if (inventoryEntityID != UUID.Zero)
                {
                    // Get item info
                    InventoryItemBase item = userInfo.FindItem(inventoryEntityID);
                    if (item == null)
                    {
                        m_log.WarnFormat("[INVENTORY TRANSFER]: Can't retrieve item {0} to give.", inventoryEntityID);
                        return;
                    }

                    // Update item to viewer (makes it appear in proper folder)
                    user.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
                }

                // Deliver message
                user.ControllingClient.SendInstantMessage(im);
            }
        }