コード例 #1
0
void LLPreviewNotecard::loadAsset()
{
	// request the asset.
	const LLInventoryItem* item = getItem();
	LLViewerTextEditor* editor = getChild<LLViewerTextEditor>("Notecard Editor");

	if (!editor)
		return;


	if(item)
	{
		if (gAgent.allowOperation(PERM_COPY, item->getPermissions(),
									GP_OBJECT_MANIPULATE)
			|| gAgent.isGodlike())
		{
			mAssetID = item->getAssetUUID();
			if(mAssetID.isNull())
			{
				editor->setText(LLStringUtil::null);
				editor->makePristine();
				editor->setEnabled(TRUE);
				mAssetStatus = PREVIEW_ASSET_LOADED;
			}
			else
			{
				LLHost source_sim = LLHost::invalid;
				if (mObjectUUID.notNull())
				{
					LLViewerObject *objectp = gObjectList.findObject(mObjectUUID);
					if (objectp && objectp->getRegion())
					{
						source_sim = objectp->getRegion()->getHost();
					}
					else
					{
						// The object that we're trying to look at disappeared, bail.
						llwarns << "Can't find object " << mObjectUUID << " associated with notecard." << llendl;
						mAssetID.setNull();
						editor->setText(getString("no_object"));
						editor->makePristine();
						editor->setEnabled(FALSE);
						mAssetStatus = PREVIEW_ASSET_LOADED;
						return;
					}
				}
				gAssetStorage->getInvItemAsset(source_sim,
												gAgent.getID(),
												gAgent.getSessionID(),
												item->getPermissions().getOwner(),
												mObjectUUID,
												item->getUUID(),
												item->getAssetUUID(),
												item->getType(),
												&onLoadComplete,
												(void*)new LLUUID(mItemUUID),
												TRUE);
				mAssetStatus = PREVIEW_ASSET_LOADING;
			}
		}
		else
		{
			mAssetID.setNull();
			editor->setText(getString("not_allowed"));
			editor->makePristine();
			editor->setEnabled(FALSE);
			mAssetStatus = PREVIEW_ASSET_LOADED;
		}
		if(!gAgent.allowOperation(PERM_MODIFY, item->getPermissions(),
								GP_OBJECT_MANIPULATE))
		{
			editor->setEnabled(FALSE);
			getChildView("lock")->setVisible( TRUE);
		}
	}
	else
	{
		editor->setText(LLStringUtil::null);
		editor->makePristine();
		editor->setEnabled(TRUE);
		// Don't set asset status here; we may not have set the item id yet
		// (e.g. when this gets called initially)
		//mAssetStatus = PREVIEW_ASSET_LOADED;
	}
}
コード例 #2
0
ファイル: llpreviewnotecard.cpp プロジェクト: Boy/netbook
void LLPreviewNotecard::loadAsset()
{
    // request the asset.
    const LLInventoryItem* item = getItem();
    LLViewerTextEditor* editor = LLViewerUICtrlFactory::getViewerTextEditorByName(this, "Notecard Editor");

    if (!editor)
        return;


    if(item)
    {
        if (gAgent.allowOperation(PERM_COPY, item->getPermissions(),
                                  GP_OBJECT_MANIPULATE)
                || gAgent.isGodlike())
        {
            mAssetID = item->getAssetUUID();
            if(mAssetID.isNull())
            {
                editor->setText(LLString::null);
                editor->makePristine();
                editor->setEnabled(TRUE);
                mAssetStatus = PREVIEW_ASSET_LOADED;
            }
            else
            {
                LLUUID* new_uuid = new LLUUID(mItemUUID);
                LLHost source_sim = LLHost::invalid;
                if (mObjectUUID.notNull())
                {
                    LLViewerObject *objectp = gObjectList.findObject(mObjectUUID);
                    if (objectp && objectp->getRegion())
                    {
                        source_sim = objectp->getRegion()->getHost();
                    }
                    else
                    {
                        // The object that we're trying to look at disappeared, bail.
                        llwarns << "Can't find object " << mObjectUUID << " associated with notecard." << llendl;
                        mAssetID.setNull();
                        editor->setText(childGetText("no_object"));
                        editor->makePristine();
                        editor->setEnabled(FALSE);
                        mAssetStatus = PREVIEW_ASSET_LOADED;
                        delete new_uuid;
                        return;
                    }
                }
                gAssetStorage->getInvItemAsset(source_sim,
                                               gAgent.getID(),
                                               gAgent.getSessionID(),
                                               item->getPermissions().getOwner(),
                                               mObjectUUID,
                                               item->getUUID(),
                                               item->getAssetUUID(),
                                               item->getType(),
                                               &onLoadComplete,
                                               (void*)new_uuid,
                                               TRUE);
                mAssetStatus = PREVIEW_ASSET_LOADING;
            }
        }
        else
        {
            mAssetID.setNull();
            editor->setText(childGetText("not_allowed"));
            editor->makePristine();
            editor->setEnabled(FALSE);
            mAssetStatus = PREVIEW_ASSET_LOADED;
        }
        if(!gAgent.allowOperation(PERM_MODIFY, item->getPermissions(),
                                  GP_OBJECT_MANIPULATE))
        {
            editor->setEnabled(FALSE);
            childSetVisible("lock", TRUE);
        }
    }
    else
    {
        editor->setText(LLString::null);
        editor->makePristine();
        editor->setEnabled(TRUE);
        mAssetStatus = PREVIEW_ASSET_LOADED;
    }
}