Example #1
0
// static
LLPreviewGesture* LLPreviewGesture::show(const std::string& title, const LLUUID& item_id, const LLUUID& object_id, BOOL take_focus)
{
	LLPreviewGesture* previewp = (LLPreviewGesture*)LLPreview::find(item_id);
	if (previewp)
	{
		previewp->open();   /*Flawfinder: ignore*/
		if (take_focus)
		{
			previewp->setFocus(TRUE);
		}
		return previewp;
	}

	LLPreviewGesture* self = new LLPreviewGesture();

	// Finish internal construction
	self->init(item_id, object_id);

	// Builds and adds to gFloaterView
	gUICtrlFactory->buildFloater(self, "floater_preview_gesture.xml");
	self->setTitle(title);

	// Move window to top-left of screen
	LLMultiFloater* hostp = self->getHost();
	if (hostp == NULL)
	{
		LLRect r = self->getRect();
		LLRect screen = gFloaterView->getRect();
		r.setLeftTopAndSize(0, screen.getHeight(), r.getWidth(), r.getHeight());
		self->setRect(r);
	}
	else
	{
		// re-add to host to update title
		hostp->addFloater(self, TRUE);
	}

	// this will call refresh when we have everything.
	LLViewerInventoryItem* item = (LLViewerInventoryItem*)self->getItem();
	if(item && !item->isComplete())
	{
		LLInventoryGestureAvailable* observer;
		observer = new LLInventoryGestureAvailable();
		observer->watchItem(item_id);
		gInventory.addObserver(observer);
		item->fetchFromServer();
	}
	else
	{
		// not sure this is necessary.
		self->refresh();
	}

	if (take_focus)
	{
		self->setFocus(TRUE);
	}

	return self;
}
Example #2
0
// static
void LLFloaterProperties::onClickUpdate(void* user_data)
{
	LLFloaterProperties* floaterp = (LLFloaterProperties*)user_data;
	if(floaterp)
	{
		LLViewerInventoryItem* item = (LLViewerInventoryItem*)floaterp->findItem();
		if(item)
		{
			std::string str(floaterp->childGetValue("item_text").asString());
			std::string::size_type pos;
			while((pos = str.find("    ")) != std::string::npos)
			{
				str.replace(pos, 4, "\t");
			}
			
			std::istringstream strm(str);
			item->importLegacyStream(strm);

			if(floaterp->mObjectID.isNull())
			{
				// This is in the agent's inventory.
				item->updateServer(FALSE);
				gInventory.updateItem(item);
				gInventory.notifyObservers();

				item->setComplete(FALSE);
				item->fetchFromServer();
			}
			else
			{
				// This is in an object's contents.
				LLViewerObject* object = gObjectList.findObject(floaterp->mObjectID);
				if(object)
				{
					object->updateInventory(
						item,
						TASK_INVENTORY_ITEM_KEY,
						false);
					object->fetchInventoryFromServer();
				}
			}
		}
	}
}
// static
LLPreviewGesture* LLPreviewGesture::show(const std::string& title, const LLUUID& item_id, const LLUUID& object_id, BOOL take_focus)
{
	LLPreviewGesture* previewp = (LLPreviewGesture*)LLPreview::find(item_id);
	if (previewp)
	{
		previewp->open();   /*Flawfinder: ignore*/
		if (take_focus)
		{
			previewp->setFocus(TRUE);
		}
		return previewp;
	}

	LLPreviewGesture* self = new LLPreviewGesture();

	// Finish internal construction
	self->init(item_id, object_id);

	// Builds and adds to gFloaterView
	LLUICtrlFactory::getInstance()->buildFloater(self, "floater_preview_gesture.xml");
	self->setTitle(title);

	// Move window to top-left of screen
	LLMultiFloater* hostp = self->getHost();
	if (hostp == NULL)
	{
		LLRect r = self->getRect();
		LLRect screen = gFloaterView->getRect();
		r.setLeftTopAndSize(0, screen.getHeight(), r.getWidth(), r.getHeight());
		self->setRect(r);
	}
	else
	{
		// re-add to host to update title
		hostp->addFloater(self, TRUE);
	}

	// Start speculative download of sounds and animations
	const LLUUID animation_folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_ANIMATION);
	LLInventoryModelBackgroundFetch::instance().start(animation_folder_id);

	const LLUUID sound_folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_SOUND);
	LLInventoryModelBackgroundFetch::instance().start(sound_folder_id);

	// this will call refresh when we have everything.
	LLViewerInventoryItem* item = (LLViewerInventoryItem*)self->getItem();
	if(item && !item->isFinished())
	{
		LLInventoryGestureAvailable* observer;
		observer = new LLInventoryGestureAvailable();
		observer->watchItem(item_id);
		gInventory.addObserver(observer);
		item->fetchFromServer();
	}
	else
	{
		// not sure this is necessary.
		self->refresh();
	}

	if (take_focus)
	{
		self->setFocus(TRUE);
	}

	return self;
}
Example #4
0
// Updates the user's avatar's appearance
void LLWearable::writeToAvatar( BOOL set_by_user )
{
	LLVOAvatar* avatar = gAgent.getAvatarObject();
	llassert( avatar );
	if( !avatar )
	{
		return;
	}

	ESex old_sex = avatar->getSex();

	// Pull params
	for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() )
	{
		if (((LLViewerVisualParam*)param)->getWearableType() == mType && param->isTweakable())
		{
			S32 param_id = param->getID();
			F32 weight = get_if_there(mVisualParamMap, param_id, param->getDefaultWeight());
			// only animate with user-originated changes
			if (set_by_user)
			{
				param->setAnimationTarget(weight, set_by_user);
			}
			else
			{
				avatar->setVisualParamWeight( param_id, weight, set_by_user );
			}
		}
	}

	// only interpolate with user-originated changes
	if (set_by_user)
	{
		avatar->startAppearanceAnimation(TRUE, TRUE);
	}

	// Pull texture entries
	for( S32 te = 0; te < TEX_NUM_INDICES; te++ )
	{
		if( LLVOAvatar::getTEWearableType((ETextureIndex) te ) == mType )
		{
			const LLUUID& image_id = get_if_there(mTEMap, te, LLVOAvatar::getDefaultTEImageID((ETextureIndex) te ) );
			LLViewerImage* image = gImageList.getImage( image_id );
			avatar->setLocTexTE( te, image, set_by_user );
		}
	}

	avatar->updateVisualParams();

	if( gFloaterCustomize )
	{
		LLViewerInventoryItem* item;
		item = (LLViewerInventoryItem*)gInventory.getItem(gAgent.getWearableItem(mType));
		U32 perm_mask = PERM_NONE;
		BOOL is_complete = FALSE;
		if(item)
		{
			perm_mask = item->getPermissions().getMaskOwner();
			is_complete = item->isComplete();
			if(!is_complete)
			{
				item->fetchFromServer();
			}
		}
		gFloaterCustomize->setWearable(mType, this, perm_mask, is_complete);
		LLFloaterCustomize::setCurrentWearableType( mType );
	}

	ESex new_sex = avatar->getSex();
	if( old_sex != new_sex )
	{
		avatar->updateSexDependentLayerSets( set_by_user );
	}	
	
	avatar->updateMeshTextures();

//	if( set_by_user )
//	{
//		gAgent.sendAgentSetAppearance();
//	}
}
//static
void LLInventoryModelBackgroundFetch::backgroundFetch()
{
    LLViewerRegion* region = gAgent.getRegion();
    if (!region)
    {
        return;
    }

    if (mBackgroundFetchActive && gAgent.getRegion())
    {
        // If we'll be using the capability, we'll be sending batches and the background thing isn't as important.
        std::string url = region->getCapability("FetchInventory2");
        if (gSavedSettings.getBOOL("UseHTTPInventory") && !url.empty())
        {
            bulkFetch();
            return;
        }

#if 1
        //--------------------------------------------------------------------------------
        // DEPRECATED OLD CODE
        //

        // No more categories to fetch, stop fetch process.
        if (mFetchQueue.empty())
        {
            llinfos << "Inventory fetch completed" << llendl;

            setAllFoldersFetched();
            mBackgroundFetchActive = false;
            mFolderFetchActive = false;

            return;
        }

        F32 fast_fetch_time = lerp(mMinTimeBetweenFetches, mMaxTimeBetweenFetches, 0.1f);
        F32 slow_fetch_time = lerp(mMinTimeBetweenFetches, mMaxTimeBetweenFetches, 0.5f);
        if (mTimelyFetchPending && mFetchTimer.getElapsedTimeF32() > slow_fetch_time)
        {
            // double timeouts on failure
            mMinTimeBetweenFetches = llmin(mMinTimeBetweenFetches * 2.f, 10.f);
            mMaxTimeBetweenFetches = llmin(mMaxTimeBetweenFetches * 2.f, 120.f);
            lldebugs << "Inventory fetch times grown to (" << mMinTimeBetweenFetches << ", " << mMaxTimeBetweenFetches << ")" << llendl;
            // fetch is no longer considered "timely" although we will wait for full time-out.
            mTimelyFetchPending = FALSE;
        }

        while(1)
        {
            if (mFetchQueue.empty())
            {
                break;
            }

            if(gDisconnected)
            {
                // just bail if we are disconnected.
                break;
            }

            const FetchQueueInfo info = mFetchQueue.front();

            if (info.mIsCategory)
            {

                LLViewerInventoryCategory* cat = gInventory.getCategory(info.mUUID);

                // Category has been deleted, remove from queue.
                if (!cat)
                {
                    mFetchQueue.pop_front();
                    continue;
                }

                if (mFetchTimer.getElapsedTimeF32() > mMinTimeBetweenFetches &&
                        LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion())
                {
                    // Category exists but has no children yet, fetch the descendants
                    // for now, just request every time and rely on retry timer to throttle.
                    if (cat->fetch())
                    {
                        mFetchTimer.reset();
                        mTimelyFetchPending = TRUE;
                    }
                    else
                    {
                        //  The catagory also tracks if it has expired and here it says it hasn't
                        //  yet.  Get out of here because nothing is going to happen until we
                        //  update the timers.
                        break;
                    }
                }
                // Do I have all my children?
                else if (gInventory.isCategoryComplete(info.mUUID))
                {
                    // Finished with this category, remove from queue.
                    mFetchQueue.pop_front();

                    // Add all children to queue.
                    LLInventoryModel::cat_array_t* categories;
                    gInventory.getDirectDescendentsOf(cat->getUUID(), categories);
                    for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin();
                            it != categories->end();
                            ++it)
                    {
                        mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(),info.mRecursive));
                    }

                    // We received a response in less than the fast time.
                    if (mTimelyFetchPending && mFetchTimer.getElapsedTimeF32() < fast_fetch_time)
                    {
                        // Shrink timeouts based on success.
                        mMinTimeBetweenFetches = llmax(mMinTimeBetweenFetches * 0.8f, 0.3f);
                        mMaxTimeBetweenFetches = llmax(mMaxTimeBetweenFetches * 0.8f, 10.f);
                        lldebugs << "Inventory fetch times shrunk to (" << mMinTimeBetweenFetches << ", " << mMaxTimeBetweenFetches << ")" << llendl;
                    }

                    mTimelyFetchPending = FALSE;
                    continue;
                }
                else if (mFetchTimer.getElapsedTimeF32() > mMaxTimeBetweenFetches)
                {
                    // Received first packet, but our num descendants does not match db's num descendants
                    // so try again later.
                    mFetchQueue.pop_front();

                    if (mNumFetchRetries++ < MAX_FETCH_RETRIES)
                    {
                        // push on back of queue
                        mFetchQueue.push_back(info);
                    }
                    mTimelyFetchPending = FALSE;
                    mFetchTimer.reset();
                    break;
                }

                // Not enough time has elapsed to do a new fetch
                break;
            }
            else
            {
                LLViewerInventoryItem* itemp = gInventory.getItem(info.mUUID);

                mFetchQueue.pop_front();
                if (!itemp)
                {
                    continue;
                }

                if (mFetchTimer.getElapsedTimeF32() > mMinTimeBetweenFetches)
                {
                    itemp->fetchFromServer();
                    mFetchTimer.reset();
                    mTimelyFetchPending = TRUE;
                }
                else if (itemp->mIsComplete)
                {
                    mTimelyFetchPending = FALSE;
                }
                else if (mFetchTimer.getElapsedTimeF32() > mMaxTimeBetweenFetches)
                {
                    mFetchQueue.push_back(info);
                    mFetchTimer.reset();
                    mTimelyFetchPending = FALSE;
                }
                // Not enough time has elapsed to do a new fetch
                break;
            }
        }

        //
        // DEPRECATED OLD CODE
        //--------------------------------------------------------------------------------
#endif
    }
}