Esempio n. 1
0
void LLPanelRequestTools::refresh()
{
	std::string buffer = childGetValue("destination");
	LLCtrlListInterface *list = childGetListInterface("destination");
	if (!list) return;

	list->operateOnAll(LLCtrlListInterface::OP_DELETE);
	list->addSimpleElement(SELECTION);
	list->addSimpleElement(AGENT_REGION);
	for (LLWorld::region_list_t::iterator iter = gWorldp->mActiveRegionList.begin();
		 iter != gWorldp->mActiveRegionList.end(); ++iter)
	{
		LLViewerRegion* regionp = *iter;
		LLString name = regionp->getName();
//MK
		if (RRenabled && gAgent.mRRInterface.mContainsShowloc)
		{
			name = "(Hidden)";
		}
//mk
		if (!name.empty())
		{
			list->addSimpleElement(name);
		}
	}
	if(!buffer.empty())
	{
		list->selectByValue(buffer);
	}
	else
	{
		list->selectByValue(SELECTION);
	}
}
Esempio n. 2
0
	bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
	{
		LLString size = userdata.asString();
		S32 width, height;
		sscanf(size.c_str(), "%d,%d", &width, &height);
		LLViewerWindow::movieSize(width, height);
		return true;
	}
Esempio n. 3
0
LLView* LLSpinCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
	LLString name("spinner");
	node->getAttributeString("name", name);

	LLString label;
	node->getAttributeString("label", label);

	LLRect rect;
	createRect(node, rect, parent, LLRect());

	LLFontGL* font = LLView::selectFont(node);

	F32 initial_value = 0.f;
	node->getAttributeF32("initial_val", initial_value);

	F32 min_value = 0.f;
	node->getAttributeF32("min_val", min_value);

	F32 max_value = 1.f; 
	node->getAttributeF32("max_val", max_value);

	F32 increment = 0.1f;
	node->getAttributeF32("increment", increment);

	U32 precision = 3;
	node->getAttributeU32("decimal_digits", precision);
	
	S32 label_width = llmin(40, rect.getWidth() - 40);
	node->getAttributeS32("label_width", label_width);

	LLUICtrlCallback callback = NULL;

	if(label.empty())
	{
		label.assign( node->getValue() );
	}

	LLSpinCtrl* spinner = new LLSpinCtrl(name,
							rect,
							label,
							font,
							callback,
							NULL,
							initial_value, 
							min_value, 
							max_value, 
							increment,
							"",
							label_width);

	spinner->setPrecision(precision);

	spinner->initFromXML(node, parent);

	return spinner;
}
Esempio n. 4
0
// virtual
void LLPanelDirPlaces::performQuery()
{
	LLString name = childGetValue("name").asString();
	if (name.length() < mMinSearchChars)
	{
		return;
	}

	LLString catstring = childGetValue("Category").asString();
	
	// Because LLParcel::C_ANY is -1, must do special check
	S32 category = 0;
	if (catstring == "any")
	{
		category = LLParcel::C_ANY;
	}
	else
	{
		category = LLParcel::getCategoryFromString(catstring.c_str());
	}

	U32 flags = 0x0;
	bool adult_enabled = gAgent.canAccessAdult();
	bool mature_enabled = gAgent.canAccessMature();

	if (gSavedSettings.getBOOL("ShowPGSims") ||
	    (!adult_enabled && !mature_enabled)) // if they can't have either of the others checked, force this one true 
	{
		flags |= DFQ_INC_PG;
	}

	if( gSavedSettings.getBOOL("ShowMatureSims") && mature_enabled)
	{
		flags |= DFQ_INC_MATURE;
	}

	if( gSavedSettings.getBOOL("ShowAdultSims") && adult_enabled)
	{
		flags |= DFQ_INC_ADULT;
	}
	
	// Pack old query flag in case we are talking to an old server
	if ( ((flags & DFQ_INC_PG) == DFQ_INC_PG) && !((flags & DFQ_INC_MATURE) == DFQ_INC_MATURE) )
	{
		flags |= DFQ_PG_PARCELS_ONLY;
	}
 
	if (0x0 == flags)
	{
		LLNotifyBox::showXml("NoContentToSearch");
		return; 
	}

	queryCore(name, category, flags);
}
Esempio n. 5
0
static LLString get_warn_name(const LLString& name)
{
	LLString warnname = "Warn" + name;
	for (LLString::iterator iter = warnname.begin(); iter != warnname.end(); ++iter)
	{
		char c = *iter;
		if (!isalnum(c))
		{
			*iter = '_';
		}
	}
	return warnname;
}
Esempio n. 6
0
LLXMLNode *LLInventoryItem::exportFileXML(BOOL include_asset_key) const
{
	LLMemType m1(LLMemType::MTYPE_INVENTORY);
	LLXMLNode *ret = new LLXMLNode("item", FALSE);

	ret->createChild("uuid", TRUE)->setUUIDValue(1, &mUUID);
	ret->createChild("parent_uuid", TRUE)->setUUIDValue(1, &mParentUUID);

	mPermissions.exportFileXML()->setParent(ret);

	// Check for permissions to see the asset id, and if so write it
	// out as an asset id. Otherwise, apply our cheesy encryption.
	if(include_asset_key)
	{
		U32 mask = mPermissions.getMaskBase();
		if(((mask & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED)
		   || (mAssetUUID.isNull()))
		{
			ret->createChild("asset_id", FALSE)->setUUIDValue(1, &mAssetUUID);
		}
		else
		{
			LLUUID shadow_id(mAssetUUID);
			LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES);
			cipher.encrypt(shadow_id.mData, UUID_BYTES);

			ret->createChild("shadow_id", FALSE)->setUUIDValue(1, &shadow_id);
		}
	}

	LLString type_str = LLAssetType::lookup(mType);
	LLString inv_type_str = LLInventoryType::lookup(mInventoryType);

	ret->createChild("asset_type", FALSE)->setStringValue(1, &type_str);
	ret->createChild("inventory_type", FALSE)->setStringValue(1, &inv_type_str);
	S32 tmp_flags = (S32) mFlags;
	ret->createChild("flags", FALSE)->setByteValue(4, (U8*)(&tmp_flags), LLXMLNode::ENCODING_HEX);

	mSaleInfo.exportFileXML()->setParent(ret);

	LLString temp;
	temp.assign(mName);
	ret->createChild("name", FALSE)->setStringValue(1, &temp);
	temp.assign(mDescription);
	ret->createChild("description", FALSE)->setStringValue(1, &temp);
	ret->createChild("creation_date", FALSE)->setIntValue(1, &mCreationDate);

	return ret;
}
Esempio n. 7
0
// Reads a .tga file and creates an LLImageTGA with its data.
bool LLImageTGA::loadFile( const LLString& path )
{
	S32 len = path.size();
	if( len < 5 )
	{
		return false;
	}
	
	LLString extension = path.substr( len - 4, 4 );
	LLString::toLower(extension);
	if( ".tga" != extension )
	{
		return false;
	}
	
	FILE* file = LLFile::fopen(path.c_str(), "rb");	/* Flawfinder: ignore */
	if( !file )
	{
		llwarns << "Couldn't open file " << path << llendl;
		return false;
	}

	S32 file_size = 0;
	if (!fseek(file, 0, SEEK_END))
	{
		file_size = ftell(file);
		fseek(file, 0, SEEK_SET);
	}

	U8* buffer = allocateData(file_size);
	S32 bytes_read = fread(buffer, 1, file_size, file);
	if( bytes_read != file_size )
	{
		deleteData();
		llwarns << "Couldn't read file " << path << llendl;
		return false;
	}

	fclose( file );

	if( !updateData() )
	{
		llwarns << "Couldn't decode file " << path << llendl;
		deleteData();
		return false;
	}
	return true;
}
Esempio n. 8
0
BOOL LLAsyncHostByName::startRequest( const LLString& domain_name, LLAsyncHostByNameCallback callback, void* userdata )
{
	if( isPendingRequest() )
	{
		llwarns << "LLAsyncHostByName::startRequest() cancelled existing request." << llendl;
		cancelPendingRequest();
	}

	mCallback = callback;
	mUserdata = userdata;
	memset(mOutputBuffer, 0, sizeof( mOutputBuffer ) );
	mDomainName = domain_name;

	mRequestHandle = WSAAsyncGetHostByName( 
		(HWND)gViewerWindow->getPlatformWindow(),
		LL_WM_HOST_RESOLVED,
		domain_name.c_str(),
		mOutputBuffer,
		sizeof( mOutputBuffer ) );

	if( !mRequestHandle )
	{
		llwarns << "LLAsyncHostByName::startRequest() failed: " << WSAGetLastError() << llendl;
		return FALSE;
	}

	return TRUE;
}
Esempio n. 9
0
void LLSpinCtrl::updateEditor()
{
	LLLocale locale(LLLocale::USER_LOCALE);

	// Don't display very small negative values as -0.000
	F32 displayed_value = clamp_precision((F32)getValue().asReal(), mPrecision);

//	if( S32( displayed_value * pow( 10, mPrecision ) ) == 0 )
//	{
//		displayed_value = 0.f;
//	}

	LLString format = llformat("%%.%df", mPrecision);
	LLString text = llformat(format.c_str(), displayed_value);
	mEditor->setText( text );
}
Esempio n. 10
0
LLSpeaker::LLSpeaker(const LLUUID& id, const LLString& name, const ESpeakerType type) : 
	mStatus(LLSpeaker::STATUS_TEXT_ONLY),
	mLastSpokeTime(0.f), 
	mSpeechVolume(0.f), 
	mHasSpoken(FALSE),
	mDotColor(LLColor4::white),
	mID(id),
	mTyping(FALSE),
	mSortIndex(0),
	mType(type),
	mIsModerator(FALSE),
	mModeratorMutedVoice(FALSE),
	mModeratorMutedText(FALSE)
{
	mHandle.init();
	sSpeakers.insert(std::make_pair(mHandle, this));
	if (name.empty() && type == SPEAKER_AGENT)
	{
		lookupName();
	}
	else
	{
		mDisplayName = name;
	}

	gVoiceClient->setUserVolume(id, gMuteListp->getSavedResidentVolume(id));

	mActivityTimer.resetWithExpiry(SPEAKER_TIMEOUT);
}
Esempio n. 11
0
void LLFloaterAvatarTextures::refresh()
{
	LLVOAvatar *avatarp = find_avatar(mID);
	if (avatarp)
	{
		char firstname[DB_FIRST_NAME_BUF_SIZE];	/*Flawfinder: ignore*/
		char lastname[DB_LAST_NAME_BUF_SIZE];		/*Flawfinder: ignore*/
		if (gCacheName->getName(avatarp->getID(), firstname, lastname))
		{
			LLString name;
			name.assign( firstname );
			name.append( " " );
			name.append( lastname );

			setTitle(mTitle + ": " + name);
		}
		update_texture_ctrl(avatarp, mBakedHead,	LLVOAvatar::TEX_HEAD_BAKED);
		update_texture_ctrl(avatarp, mBakedEyes,	LLVOAvatar::TEX_EYES_BAKED);
		update_texture_ctrl(avatarp, mBakedUpper,	LLVOAvatar::TEX_UPPER_BAKED);
		update_texture_ctrl(avatarp, mBakedLower,	LLVOAvatar::TEX_LOWER_BAKED);
		update_texture_ctrl(avatarp, mBakedSkirt,	LLVOAvatar::TEX_SKIRT_BAKED);

		update_texture_ctrl(avatarp, mMakeup,		LLVOAvatar::TEX_HEAD_BODYPAINT);
		update_texture_ctrl(avatarp, mHair,			LLVOAvatar::TEX_HAIR);
		update_texture_ctrl(avatarp, mEye,			LLVOAvatar::TEX_EYES_IRIS);

		update_texture_ctrl(avatarp, mShirt,		LLVOAvatar::TEX_UPPER_SHIRT);
		update_texture_ctrl(avatarp, mUpperTattoo,	LLVOAvatar::TEX_UPPER_BODYPAINT);
		update_texture_ctrl(avatarp, mUpperJacket,	LLVOAvatar::TEX_UPPER_JACKET);
		update_texture_ctrl(avatarp, mGloves,		LLVOAvatar::TEX_UPPER_GLOVES);
		update_texture_ctrl(avatarp, mUndershirt,	LLVOAvatar::TEX_UPPER_UNDERSHIRT);

		update_texture_ctrl(avatarp, mPants,		LLVOAvatar::TEX_LOWER_PANTS);
		update_texture_ctrl(avatarp, mLowerTattoo,	LLVOAvatar::TEX_LOWER_BODYPAINT);
		update_texture_ctrl(avatarp, mShoes,		LLVOAvatar::TEX_LOWER_SHOES);
		update_texture_ctrl(avatarp, mSocks,		LLVOAvatar::TEX_LOWER_SOCKS);
		update_texture_ctrl(avatarp, mJacket,		LLVOAvatar::TEX_LOWER_JACKET);
		update_texture_ctrl(avatarp, mUnderpants,	LLVOAvatar::TEX_LOWER_UNDERPANTS);
		update_texture_ctrl(avatarp, mSkirt,		LLVOAvatar::TEX_SKIRT);
	}
	else
	{
		setTitle(mTitle + ": INVALID AVATAR (" + mID.asString() + ")");
	}
}
Esempio n. 12
0
void LLSpinCtrl::onEditorCommit( LLUICtrl* caller, void *userdata )
{
	BOOL success = FALSE;
	
	LLSpinCtrl* self = (LLSpinCtrl*) userdata;
	llassert( caller == self->mEditor );

	LLString text = self->mEditor->getText();
	if( LLLineEditor::postvalidateFloat( text ) )
	{
		LLLocale locale(LLLocale::USER_LOCALE);
		F32 val = (F32) atof(text.c_str());

		if (val < self->mMinValue) val = self->mMinValue;
		if (val > self->mMaxValue) val = self->mMaxValue;

		if( self->mValidateCallback )
		{
			F32 saved_val = self->mValue;
			self->mValue = val;
			if( self->mValidateCallback( self, self->mCallbackUserData ) )
			{
				success = TRUE;
				self->onCommit();
			}
			else
			{
				self->mValue = saved_val;
			}
		}
		else
		{
			self->mValue = val;
			self->onCommit();
			success = TRUE;
		}
	}
	self->updateEditor();

	if( !success )
	{
		self->reportInvalidData();		
	}
}
Esempio n. 13
0
// static
void LLFloaterFriends::requestFriendship(const LLUUID& target_id, const LLString& target_name)
{
	// HACK: folder id stored as "message"
	LLUUID calling_card_folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_CALLINGCARD);
	std::string message = calling_card_folder_id.asString();
	send_improved_im(target_id,
					 target_name.c_str(),
					 message.c_str(),
					 IM_ONLINE,
					 IM_FRIENDSHIP_OFFERED);
}
Esempio n. 14
0
void LLButton::setImageOverlay(const LLString &image_name, LLFontGL::HAlign alignment, const LLColor4& color)
{
	if (image_name.empty())
	{
		mImageOverlay = NULL;
	}
	else
	{
		mImageOverlay = LLUI::getUIImageByName(image_name);
		mImageOverlayAlignment = alignment;
		mImageOverlayColor = color;
	}
}
Esempio n. 15
0
void LLButton::addImageAttributeToXML(LLXMLNodePtr node, 
									  const LLString& image_name,
									  const LLUUID&	image_id,
									  const LLString& xml_tag_name) const
{
	if( !image_name.empty() )
	{
		node->createChild(xml_tag_name, TRUE)->setStringValue(image_name);
	}
	else if( image_id != LLUUID::null )
	{
		node->createChild(xml_tag_name + "_id", TRUE)->setUUIDValue(image_id);
	}
}
Esempio n. 16
0
BOOL process_secondlife_url(LLString url)
{
	S32 strpos, strpos2;

	LLString slurlID = "slurl.com/secondlife/";
	strpos = url.find(slurlID);
	
	if (strpos < 0)
	{
		slurlID="secondlife://";
		strpos = url.find(slurlID);
	}
	
	if (strpos >= 0) 
	{
		LLString simname;

		strpos+=slurlID.length();
		strpos2=url.find("/",strpos);
		if (strpos2 < strpos) strpos2=url.length();
		simname="secondlife://" + url.substr(strpos,url.length() - strpos);

		LLURLSimString::setString( simname );
		LLURLSimString::parse();

		// if there is a world map
		if ( gFloaterWorldMap )
		{
			// mark where the destination is
			gFloaterWorldMap->trackURL( LLURLSimString::sInstance.mSimName.c_str(),
										LLURLSimString::sInstance.mX,
										LLURLSimString::sInstance.mY,
										LLURLSimString::sInstance.mZ );

			// display map
			LLFloaterWorldMap::show( NULL, TRUE );
		};

		return TRUE;
	}
	return FALSE;
}
Esempio n. 17
0
void LLControlGroup::setValue(const LLString& name, const LLSD& val)
{
	if (name.empty())
	{
		return;
	}

	LLControlBase* control = getControl(name);
	
	if (control)
	{
		control->set(val);
	}
	else
	{
		CONTROL_ERRS << "Invalid control " << name << llendl;
	}
}
Esempio n. 18
0
BOOL LLAsyncHostByName::startRequest( const LLString& domain_name, LLAsyncHostByNameCallback callback, void* userdata )
{
	struct hostent *response;
	U32 ip;
	BOOL result = FALSE;
	
	response = gethostbyname(domain_name.c_str());
	
	if(response != NULL)
	{
		if(response->h_addrtype == AF_INET)
		{
			ip = ((struct in_addr*)response->h_addr_list[0])->s_addr;
			result = TRUE;
			(*callback)(result, domain_name, ip, userdata);
		}
	}
	return result;
}
Esempio n. 19
0
BOOL
LLMediaImplGStreamer::
load ( const LLString& urlIn )
{
	llinfos << "Setting media URI: " << urlIn << llendl;

 	if (!mPlaybin)
 	{
		return FALSE;
	}

	// set URI
	g_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL);
	//g_object_set (G_OBJECT (mPlaybin), "uri", "file:///tmp/movie", NULL);

	// get playbin's bus - perhaps this can/should be done at init()
	GstBus *bus = llgst_pipeline_get_bus (GST_PIPELINE (mPlaybin));
	if (!bus)
	{
		return FALSE;
	}
	llgst_bus_add_watch (bus, my_bus_callback, this);
	llgst_object_unref (bus);

	if (true) // dummy values
	{
		const int fixedsize = 2;
		mMediaRowbytes = mMediaDepthBytes * fixedsize;
		mMediaWidth = fixedsize;
		mMediaHeight = fixedsize;
		mTextureWidth = fixedsize;
		mTextureHeight = fixedsize;
	}

	BOOL rtn = LLMediaMovieBase::load(urlIn);
	llinfos << "load returns " << int(rtn) << llendl;
	return rtn;
}
Esempio n. 20
0
// Default constructor
LLFloaterAbout::LLFloaterAbout() 
:	LLFloater("floater_about", "FloaterAboutRect", "")
{
	gUICtrlFactory->buildFloater(this, "floater_about.xml");

	// Support for changing product name.
	LLString title("About ");
	title += gSecondLife;
	setTitle(title);

	LLString support;

	// Version string
	LLString version = gSecondLife
		+ llformat(" %d.%d.%d (%d) %s %s",
				   LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH, LL_VIEWER_BUILD,
				   __DATE__, __TIME__);
	support.append(version);
	support.append("\n\n");

	// Position
	LLViewerRegion* region = gAgent.getRegion();
	if (region)
	{
		//XUI:translate
		const LLVector3d &pos = gAgent.getPositionGlobal();
		LLString pos_text = llformat("You are at %.1f, %.1f, %.1f ", 
			pos.mdV[VX], pos.mdV[VY], pos.mdV[VZ]);
		support.append(pos_text);

		LLString region_text = llformat("in %s located at ",
				gAgent.getRegion()->getName().c_str());
		support.append(region_text);

		char buffer[MAX_STRING];		/*Flawfinder: ignore*/
		gAgent.getRegion()->getHost().getHostName(buffer, MAX_STRING);
		support.append(buffer);
		support.append(" (");
		gAgent.getRegion()->getHost().getString(buffer, MAX_STRING);
		support.append(buffer);
		support.append(")\n\n");
	}

	// CPU
	support.append("CPU: ");
	support.append( gSysCPU.getCPUString() );
	support.append("\n");

	U32 memory = gSysMemory.getPhysicalMemory() / 1024 / 1024;
	// For some reason, the reported amount of memory is always wrong by one meg
	memory++;

	LLString mem_text = llformat("Memory: %u MB\n", memory );
	support.append(mem_text);

	support.append("OS Version: ");
	support.append( gSysOS.getOSString().c_str() );
	support.append("\n");

	support.append("Graphics Card Vendor: ");
	support.append( (const char*) glGetString(GL_VENDOR) );
	support.append("\n");

	support.append("Graphics Card: ");
	support.append( (const char*) glGetString(GL_RENDERER) );
	support.append("\n");

	support.append("OpenGL Version: ");
	support.append( (const char*) glGetString(GL_VERSION) );
	support.append("\n");

#if LL_LIBXUL_ENABLED
	support.append("LLMozLib Version: ");
	support.append( (const char*) LLMozLib::getInstance()->getVersion().c_str() );
	support.append("\n");
#endif // LL_LIBXUL_ENABLED

	if (gViewerStats
		&& gPacketsIn > 0)
	{
		LLString packet_loss = llformat("Packets Lost: %.0f/%.0f (%.1f%%)", 
			gViewerStats->mPacketsLostStat.getCurrent(),
			F32(gPacketsIn),
			100.f*gViewerStats->mPacketsLostStat.getCurrent() / F32(gPacketsIn) );
		support.append(packet_loss);
		support.append("\n");
	}

	// MD5 digest of executable
	support.append("Viewer Digest: ");
	char viewer_digest_string[UUID_STR_LENGTH]; /*Flawfinder: ignore*/
	gViewerDigest.toString( viewer_digest_string );
	support.append(viewer_digest_string);

	// Fix views
	childDisable("credits_editor");
	childDisable("support_editor");
	childSetText("support_editor", support);

	center();

	sInstance = this;
}
Esempio n. 21
0
// virtual
BOOL LLPreviewGesture::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
										 EDragAndDropType cargo_type,
										 void* cargo_data,
										 EAcceptance* accept,
										 LLString& tooltip_msg)
{
	BOOL handled = TRUE;
	switch(cargo_type)
	{
	case DAD_ANIMATION:
	case DAD_SOUND:
		{
			// TODO: Don't allow this if you can't transfer the sound/animation

			// make a script step
			LLInventoryItem* item = (LLInventoryItem*)cargo_data;
			if (item
				&& gInventory.getItem(item->getUUID()))
			{
				LLPermissions perm = item->getPermissions();
				if (!((perm.getMaskBase() & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED))
				{
					*accept = ACCEPT_NO;
					if (tooltip_msg.empty())
					{
						tooltip_msg.assign("Only animations and sounds\n"
											"with unrestricted permissions\n"
											"can be added to a gesture.");
					}
					break;
				}
				else if (drop)
				{
					LLScrollListItem* line = NULL;
					if (cargo_type == DAD_ANIMATION)
					{
						line = addStep("Animation");
						LLGestureStepAnimation* anim = (LLGestureStepAnimation*)line->getUserdata();
						anim->mAnimAssetID = item->getAssetUUID();
						anim->mAnimName = item->getName();
					}
					else if (cargo_type == DAD_SOUND)
					{
						line = addStep("Sound");
						LLGestureStepSound* sound = (LLGestureStepSound*)line->getUserdata();
						sound->mSoundAssetID = item->getAssetUUID();
						sound->mSoundName = item->getName();
					}
					updateLabel(line);
					mDirty = TRUE;
					refresh();
				}
				*accept = ACCEPT_YES_COPY_MULTI;
			}
			else
			{
				// Not in user's inventory means it was in object inventory
				*accept = ACCEPT_NO;
			}
			break;
		}
	default:
		*accept = ACCEPT_NO;
		if (tooltip_msg.empty())
		{
			tooltip_msg.assign("Only animations and sounds\n"
								"can be added to a gesture.");
		}
		break;
	}
	return handled;
}
Esempio n. 22
0
// blocking asset fetch which bypasses the VFS
// this is a very limited function for use by the simstate loader and other one-offs
S32 LLHTTPAssetStorage::getURLToFile(const LLUUID& uuid, LLAssetType::EType asset_type, const LLString &url, const char *filename, progress_callback callback, void *userdata)
{
	// *NOTE: There is no guarantee that the uuid and the asset_type match
	// - not that it matters. - Doug
	lldebugs << "LLHTTPAssetStorage::getURLToFile() - " << url << llendl;

	FILE *fp = LLFile::fopen(filename, "wb"); /*Flawfinder: ignore*/
	if (! fp)
	{
		llwarns << "Failed to open " << filename << " for writing" << llendl;
		return LL_ERR_ASSET_REQUEST_FAILED;
	}

	// make sure we use the normal curl setup, even though we don't really need a request object
	LLHTTPAssetRequest req(this, uuid, asset_type, RT_DOWNLOAD, url.c_str(), mCurlMultiHandle);
	req.mFP = fp;
	
	req.setupCurlHandle();
	curl_easy_setopt(req.mCurlHandle, CURLOPT_FOLLOWLOCATION, TRUE);
	curl_easy_setopt(req.mCurlHandle, CURLOPT_WRITEFUNCTION, &curlFileDownCallback);
	curl_easy_setopt(req.mCurlHandle, CURLOPT_WRITEDATA, req.mCurlHandle);

	curl_multi_add_handle(mCurlMultiHandle, req.mCurlHandle);
	llinfos << "Requesting as file " << req.mURLBuffer << llendl;

	// braindead curl loop
	int queue_length;
	CURLMsg *curl_msg;
	LLTimer timeout;
	timeout.setTimerExpirySec(GET_URL_TO_FILE_TIMEOUT);
	bool success = false;
	S32 xfer_result = 0;
	do
	{
		curl_multi_perform(mCurlMultiHandle, &queue_length);
		curl_msg = curl_multi_info_read(mCurlMultiHandle, &queue_length);

		if (callback)
		{
			callback(userdata);
		}

		if ( curl_msg && (CURLMSG_DONE == curl_msg->msg) )
		{
			success = true;
		}
		else if (timeout.hasExpired())
		{
			llwarns << "Request for " << url << " has timed out." << llendl;
			success = false;
			xfer_result = LL_ERR_ASSET_REQUEST_FAILED;
			break;
		}
	} while (!success);

	if (success)
	{
		long curl_result = 0;
		curl_easy_getinfo(curl_msg->easy_handle, CURLINFO_HTTP_CODE, &curl_result);
		
		if (curl_result == HTTP_OK && curl_msg->data.result == CURLE_OK)
		{
			S32 size = ftell(req.mFP);
			if (size > 0)
			{
				// everything seems to be in order
				llinfos << "Success downloading " << req.mURLBuffer << " to file, size " << size << llendl;
			}
			else
			{
				llwarns << "Found " << req.mURLBuffer << " to be zero size" << llendl;
				xfer_result = LL_ERR_ASSET_REQUEST_FAILED;
			}
		}
		else
		{
			xfer_result = curl_result == HTTP_MISSING ? LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE : LL_ERR_ASSET_REQUEST_FAILED;
			llinfos << "Failure downloading " << req.mURLBuffer << 
				" with result " << curl_easy_strerror(curl_msg->data.result) << ", http result " << curl_result << llendl;
		}
	}

	fclose(fp);
	if (xfer_result)
	{
		LLFile::remove(filename);
	}
	return xfer_result;
}
Esempio n. 23
0
// Returns number of controls loaded, so 0 if failure
U32 LLControlGroup::loadFromFile(const LLString& filename, BOOL require_declaration, eControlType declare_as)
{
	LLString name;

	LLXmlTree xml_controls;

	if (!xml_controls.parseFile(filename))
	{
		llwarns << "Unable to open control file " << filename << llendl;
		return 0;
	}

	LLXmlTreeNode* rootp = xml_controls.getRoot();
	if (!rootp || !rootp->hasAttribute("version"))
	{
		llwarns << "No valid settings header found in control file " << filename << llendl;
		return 0;
	}

	U32		item = 0;
	U32		validitems = 0;
	S32 version;
	
	rootp->getAttributeS32("version", version);

	// Check file version
	if (version != CURRENT_VERSION)
	{
		llinfos << filename << " does not appear to be a version " << CURRENT_VERSION << " controls file" << llendl;
		return 0;
	}

	LLXmlTreeNode* child_nodep = rootp->getFirstChild();
	while(child_nodep)
	{
		name = child_nodep->getName();		
		
		BOOL declared = controlExists(name);

		if (require_declaration && !declared)
		{
			// Declaration required, but this name not declared.
			// Complain about non-empty names.
			if (!name.empty())
			{
				//read in to end of line
				llwarns << "LLControlGroup::loadFromFile() : Trying to set \"" << name << "\", setting doesn't exist." << llendl;
			}
			child_nodep = rootp->getNextChild();
			continue;
		}

		// Got an item.  Load it up.
		item++;

		// If not declared, assume it's a string
		if (!declared)
		{
			switch(declare_as)
			{
			case TYPE_COL4:
				declareColor4(name, LLColor4::white, "", NO_PERSIST);
				break;
			case TYPE_COL4U:
				declareColor4U(name, LLColor4U::white, "", NO_PERSIST);
				break;
			case TYPE_STRING:
			default:
				declareString(name, LLString::null, "", NO_PERSIST);
				break;
			}
		}

		// Control name has been declared in code.
		LLControlBase *control = getControl(name);

		llassert(control);

		mLoadedSettings.insert(name);
		
		switch(control->mType)
		{
		case TYPE_F32:
			{
				F32 initial = 0.f;

				child_nodep->getAttributeF32("value", initial);

				control->set(initial);
				validitems++;
			}
			break;
		case TYPE_S32:
			{
				S32 initial = 0;

				child_nodep->getAttributeS32("value", initial);

				control->set(initial);
				validitems++;
			}
			break;
		case TYPE_U32:
			{
				U32 initial = 0;
				child_nodep->getAttributeU32("value", initial);
				control->set((LLSD::Integer) initial);
				validitems++;
			}
			break;
		case TYPE_BOOLEAN:
			{
				BOOL initial = FALSE;

				child_nodep->getAttributeBOOL("value", initial);
				control->set(initial);

				validitems++;
			}
			break;
		case TYPE_STRING:
			{
				LLString string;
				child_nodep->getAttributeString("value", string);
				if (string == LLString::null)
				{
					string = "";
				}
				control->set(string);
				validitems++;
			}
			break;
		case TYPE_VEC3:
			{
				LLVector3 vector;

				child_nodep->getAttributeVector3("value", vector);
				control->set(vector.getValue());
				validitems++;
			}
			break;
		case TYPE_VEC3D:
			{
				LLVector3d vector;

				child_nodep->getAttributeVector3d("value", vector);

				control->set(vector.getValue());
				validitems++;
			}
			break;
		case TYPE_RECT:
			{
				//RN: hack to support reading rectangles from a string
				LLString rect_string;

				child_nodep->getAttributeString("value", rect_string);
				std::istringstream istream(rect_string);
				S32 left, bottom, width, height;

				istream >> left >> bottom >> width >> height;

				LLRect rect;
				rect.setOriginAndSize(left, bottom, width, height);

				control->set(rect.getValue());
				validitems++;
			}
			break;
		case TYPE_COL4U:
			{
				LLColor4U color;

				child_nodep->getAttributeColor4U("value", color);
				control->set(color.getValue());
				validitems++;
			}
			break;
		case TYPE_COL4:
			{
				LLColor4 color;
				
				child_nodep->getAttributeColor4("value", color);
				control->set(color.getValue());
				validitems++;
			}
			break;
		case TYPE_COL3:
			{
				LLVector3 color;
				
				child_nodep->getAttributeVector3("value", color);
                control->set(LLColor3(color.mV).getValue());
				validitems++;
			}
			break;
		}

		child_nodep = rootp->getNextChild();
	}

	return validitems;
}
Esempio n. 24
0
U32 LLControlGroup::loadFromFileLegacy(const LLString& filename, BOOL require_declaration, eControlType declare_as)
{
	U32		item = 0;
	U32		validitems = 0;
	llifstream file;
	S32 version;
	
	file.open(filename.c_str());		/*Flawfinder: ignore*/ 

	if (!file)
	{
		llinfos << "LLControlGroup::loadFromFile unable to open." << llendl;
		return 0;
	}

	// Check file version
	LLString name;
	file >> name;
	file >> version;
	if (name != "version" || version != CURRENT_VERSION)
	{
		llinfos << filename << " does not appear to be a version " << CURRENT_VERSION << " controls file" << llendl;
		return 0;
	}

	while (!file.eof())
	{
		file >> name;
		
		if (name.empty())
		{
			continue;
		}

		if (name.substr(0,2) == "//")
		{
			// This is a comment.
			char buffer[MAX_STRING];		/*Flawfinder: ignore*/
			file.getline(buffer, MAX_STRING);
			continue;
		}

		BOOL declared = mNameTable.find(name) != mNameTable.end();

		if (require_declaration && !declared)
		{
			// Declaration required, but this name not declared.
			// Complain about non-empty names.
			if (!name.empty())
			{
				//read in to end of line
				char buffer[MAX_STRING];		/*Flawfinder: ignore*/
				file.getline(buffer, MAX_STRING);
				llwarns << "LLControlGroup::loadFromFile() : Trying to set \"" << name << "\", setting doesn't exist." << llendl;
			}
			continue;
		}

		// Got an item.  Load it up.
		item++;

		// If not declared, assume it's a string
		if (!declared)
		{
			switch(declare_as)
			{
			case TYPE_COL4:
				declareColor4(name, LLColor4::white, LLString::null, NO_PERSIST);
				break;
			case TYPE_COL4U:
				declareColor4U(name, LLColor4U::white, LLString::null, NO_PERSIST);
				break;
			case TYPE_STRING:
			default:
				declareString(name, LLString::null, LLString::null, NO_PERSIST);
				break;
			}
		}

		// Control name has been declared in code.
		LLControlBase *control = getControl(name);

		llassert(control);

		mLoadedSettings.insert(name);
		
		switch(control->mType)
		{
		case TYPE_F32:
			{
				F32 initial;

				file >> initial;

				control->set(initial);
				validitems++;
			}
			break;
		case TYPE_S32:
			{
				S32 initial;

				file >> initial;

				control->set(initial);
				validitems++;
			}
			break;
		case TYPE_U32:
			{
				U32 initial;

				file >> initial;
				control->set((LLSD::Integer) initial);
				validitems++;
			}
			break;
		case TYPE_BOOLEAN:
			{
				char boolstring[256];		/*Flawfinder: ignore*/
				BOOL valid = FALSE;
				BOOL initial = FALSE;

				file >> boolstring;
				if (!strcmp("TRUE", boolstring))
				{
					initial = TRUE;
					valid = TRUE;
				}
				else if (!strcmp("FALSE", boolstring))
				{
					initial = FALSE;
					valid = TRUE;
				}

				if (valid)
				{
					control->set(initial);
				}
				else
				{
					llinfos << filename << "Item " << item << ": Invalid BOOL control " << name << ", " << boolstring << llendl; 
				}

				validitems++;
			}
			break;
		case TYPE_STRING:
			{
				LLString string;
				
				file >> string;
				
				control->set(string);
				validitems++;
			}
			break;
		case TYPE_VEC3:
			{
				F32 x, y, z;

				file >> x >> y >> z;

				LLVector3 vector(x, y, z);

				control->set(vector.getValue());
				validitems++;
			}
			break;
		case TYPE_VEC3D:
			{
				F64 x, y, z;

				file >> x >> y >> z;

				LLVector3d vector(x, y, z);

				control->set(vector.getValue());
				validitems++;
			}
			break;
		case TYPE_RECT:
			{
				S32 left, bottom, width, height;

				file >> left >> bottom >> width >> height;

				LLRect rect;
				rect.setOriginAndSize(left, bottom, width, height);

				control->set(rect.getValue());
				validitems++;
			}
			break;
		case TYPE_COL4U:
			{
				S32 red, green, blue, alpha;
				LLColor4U color;
				file >> red >> green >> blue >> alpha;
				color.setVec(red, green, blue, alpha);
				control->set(color.getValue());
				validitems++;
			}
			break;
		case TYPE_COL4:
			{
				LLColor4 color;
				file >> color.mV[VRED] >> color.mV[VGREEN]
					 >> color.mV[VBLUE] >> color.mV[VALPHA];
				control->set(color.getValue());
				validitems++;
			}
			break;
		case TYPE_COL3:
			{
				LLColor3 color;
				file >> color.mV[VRED] >> color.mV[VGREEN]
					 >> color.mV[VBLUE];
				control->set(color.getValue());
				validitems++;
			}
			break;
		}
	}

	file.close();

	return validitems;
}
Esempio n. 25
0
bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem)
{
    if(!gAssetStorage)
    {
        llwarns << "Not connected to an asset storage system." << llendl;
        return false;
    }


    LLViewerTextEditor* editor = LLViewerUICtrlFactory::getViewerTextEditorByName(this, "Notecard Editor");

    if(!editor->isPristine())
    {
        // We need to update the asset information
        LLTransactionID tid;
        LLAssetID asset_id;
        tid.generate();
        asset_id = tid.makeAssetID(gAgent.getSecureSessionID());

        LLVFile file(gVFS, asset_id, LLAssetType::AT_NOTECARD, LLVFile::APPEND);

        LLString buffer;
        if (!editor->exportBuffer(buffer))
        {
            return false;
        }

        editor->makePristine();

        S32 size = buffer.length() + 1;
        file.setMaxSize(size);
        file.write((U8*)buffer.c_str(), size);

        const LLInventoryItem* item = getItem();
        // save it out to database
        if (item)
        {
            std::string agent_url = gAgent.getRegion()->getCapability("UpdateNotecardAgentInventory");
            std::string task_url = gAgent.getRegion()->getCapability("UpdateNotecardTaskInventory");
            if (mObjectUUID.isNull() && !agent_url.empty())
            {
                // Saving into agent inventory
                mAssetStatus = PREVIEW_ASSET_LOADING;
                setEnabled(FALSE);
                LLSD body;
                body["item_id"] = mItemUUID;
                llinfos << "Saving notecard " << mItemUUID
                        << " into agent inventory via " << agent_url << llendl;
                LLHTTPClient::post(agent_url, body,
                                   new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD));
            }
            else if (!mObjectUUID.isNull() && !task_url.empty())
            {
                // Saving into task inventory
                mAssetStatus = PREVIEW_ASSET_LOADING;
                setEnabled(FALSE);
                LLSD body;
                body["task_id"] = mObjectUUID;
                body["item_id"] = mItemUUID;
                llinfos << "Saving notecard " << mItemUUID << " into task "
                        << mObjectUUID << " via " << task_url << llendl;
                LLHTTPClient::post(task_url, body,
                                   new LLUpdateTaskInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD));
            }
            else if (gAssetStorage)
            {
                LLSaveNotecardInfo* info = new LLSaveNotecardInfo(this, mItemUUID, mObjectUUID,
                        tid, copyitem);
                gAssetStorage->storeAssetData(tid, LLAssetType::AT_NOTECARD,
                                              &onSaveComplete,
                                              (void*)info,
                                              FALSE);
            }
        }
    }
    return true;
}
Esempio n. 26
0
U32 LLControlGroup::saveToFile(const LLString& filename, BOOL nondefault_only)
{
	const char ENDL = '\n';

	llinfos << "Saving settings to file: " << filename << llendl;

	// place the objects in a temporary container that enforces a sort
	// order to ease manual editing of the file
	LLLinkedList< LLControlBase > controls;
	controls.setInsertBefore( &control_insert_before );
	LLString name;
	for (ctrl_name_table_t::iterator iter = mNameTable.begin();
		 iter != mNameTable.end(); iter++)
	{
		name = iter->first;
		if (name.empty())
		{
			CONTROL_ERRS << "Control with no name found!!!" << llendl;
			break;
		}

		LLControlBase* control = (LLControlBase *)iter->second;
		if (!control)
		{
			llwarns << "Tried to save invalid control: " << name << llendl;
		}

		if( control && control->mPersist )
		{
			if (!(nondefault_only && (control->mIsDefault)))
			{
				controls.addDataSorted( control );
			}
			else
			{
				// Debug spam
				// llinfos << "Skipping " << control->getName() << llendl;
			}
		}
	}

	llofstream file;
	file.open(filename.c_str());		/*Flawfinder: ignore*/

	if (!file.is_open())
	{
		// This is a warning because sometime we want to use settings files which can't be written...
		llwarns << "LLControlGroup::saveToFile unable to open file for writing" << llendl;
		return 0;
	}

	// Write file version
	file << "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n";
	file << "<settings version = \"" << CURRENT_VERSION << "\">\n";
    for( LLControlBase* control = controls.getFirstData();
		 control != NULL;
		 control = controls.getNextData() )
	{
		file << "\t<!--" << control->comment() << "-->" << ENDL;
		name = control->name();
		switch (control->type())
		{
			case TYPE_U32:
			{
				file << "\t<" << name << " value=\"" << (U32) control->get().asInteger() << "\"/>\n";
				break;
			}
			case TYPE_S32:
			{
				file << "\t<" << name << " value=\"" << (S32) control->get().asInteger() << "\"/>\n";
				break;
			}
			case TYPE_F32:
			{
				file << "\t<" << name << " value=\"" << (F32) control->get().asReal() << "\"/>\n";
				break;
			}
			case TYPE_VEC3:
			{
				LLVector3 vector(control->get());
				file << "\t<" << name << " value=\"" << vector.mV[VX] << " " << vector.mV[VY] << " " << vector.mV[VZ] << "\"/>\n";
				break;
			}
			case TYPE_VEC3D:
			{
				LLVector3d vector(control->get());
				file << "\t<" << name << " value=\"" << vector.mdV[VX] << " " << vector.mdV[VY] << " " << vector.mdV[VZ] << "\"/>\n";
				break;
			}
			case TYPE_RECT:
			{
				LLRect rect(control->get());
				file << "\t<" << name << " value=\"" << rect.mLeft << " " << rect.mBottom << " " << rect.getWidth() << " " << rect.getHeight() << "\"/>\n";
				break;
			}
			case TYPE_COL4:
			{
				LLColor4 color(control->get());
				file << "\t<" << name << " value=\"" << color.mV[VRED] << ", " << color.mV[VGREEN] << ", " << color.mV[VBLUE] << ", " << color.mV[VALPHA] << "\"/>\n";
				break;
			}
			case TYPE_COL3:
			{
				LLColor3 color(control->get());
				file << "\t<" << name << " value=\"" << color.mV[VRED] << ", " << color.mV[VGREEN] << ", " << color.mV[VBLUE] << "\"/>\n";
				break;
			}
			case TYPE_BOOLEAN:
			{
				file << "\t<" << name << " value=\"" << (control->get().asBoolean() ? "TRUE" : "FALSE") << "\"/>\n";			
				break;
			}
			case TYPE_STRING:
			{
				file << "\t<" << name << " value=\"" << LLSDXMLFormatter::escapeString(control->get().asString()) << "\"/>\n";
				break;
			}
			default:
			{
				CONTROL_ERRS << "LLControlGroup::saveToFile - unknown control type!" << llendl;
				break;
			}
		}

		// Debug spam
		// llinfos << name << " " << control->getValue().asString() << llendl;
	}// next

	file << "</settings>\n";
	file.close();

	return controls.getLength();
}
Esempio n. 27
0
// static
LLView* LLButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
	LLString name("button");
	node->getAttributeString("name", name);

	LLString label = name;
	node->getAttributeString("label", label);

	LLString label_selected = label;
	node->getAttributeString("label_selected", label_selected);

	LLFontGL* font = selectFont(node);

	LLString	image_unselected;
	if (node->hasAttribute("image_unselected")) node->getAttributeString("image_unselected",image_unselected);
	
	LLString	image_selected;
	if (node->hasAttribute("image_selected")) node->getAttributeString("image_selected",image_selected);
	
	LLString	image_hover_selected;
	if (node->hasAttribute("image_hover_selected")) node->getAttributeString("image_hover_selected",image_hover_selected);
	
	LLString	image_hover_unselected;
	if (node->hasAttribute("image_hover_unselected")) node->getAttributeString("image_hover_unselected",image_hover_unselected);
	
	LLString	image_disabled_selected;
	if (node->hasAttribute("image_disabled_selected")) node->getAttributeString("image_disabled_selected",image_disabled_selected);
	
	LLString	image_disabled;
	if (node->hasAttribute("image_disabled")) node->getAttributeString("image_disabled",image_disabled);

	LLString	image_overlay;
	node->getAttributeString("image_overlay", image_overlay);

	LLFontGL::HAlign image_overlay_alignment = LLFontGL::HCENTER;
	LLString image_overlay_alignment_string;
	if (node->hasAttribute("image_overlay_alignment"))
	{
		node->getAttributeString("image_overlay_alignment", image_overlay_alignment_string);
		image_overlay_alignment = LLFontGL::hAlignFromName(image_overlay_alignment_string);
	}


	LLButton *button = new LLButton(name, 
			LLRect(),
			image_unselected,
			image_selected,
			"", 
			NULL, 
			parent,
			font,
			label,
			label_selected);

	node->getAttributeS32("pad_right", button->mRightHPad);
	node->getAttributeS32("pad_left", button->mLeftHPad);

	BOOL is_toggle = button->getIsToggle();
	node->getAttributeBOOL("toggle", is_toggle);
	button->setIsToggle(is_toggle);

	if(image_hover_selected != LLString::null) button->setImageHoverSelected(image_hover_selected);
	
	if(image_hover_unselected != LLString::null) button->setImageHoverUnselected(image_hover_unselected);
	
	if(image_disabled_selected != LLString::null) button->setImageDisabledSelected(image_disabled_selected );
	
	if(image_disabled != LLString::null) button->setImageDisabled(image_disabled);
	
	if(image_overlay != LLString::null) button->setImageOverlay(image_overlay, image_overlay_alignment);

	if (node->hasAttribute("halign"))
	{
		LLFontGL::HAlign halign = selectFontHAlign(node);
		button->setHAlign(halign);
	}

	if (node->hasAttribute("scale_image"))
	{
		BOOL	needsScale = FALSE;
		node->getAttributeBOOL("scale_image",needsScale);
		button->setScaleImage( needsScale );
	}

	if(label.empty())
	{
		button->setLabelUnselected(node->getTextContents());
	}
	if (label_selected.empty())
	{
		button->setLabelSelected(node->getTextContents());
	}
		
	if (node->hasAttribute("help_url")) 
	{
		LLString	help_url;
		node->getAttributeString("help_url",help_url);
		button->setHelpURLCallback(help_url);
	}

	button->initFromXML(node, parent);
	
	return button;
}
Esempio n. 28
0
void			LLButton::setImageDisabledSelected(const LLString &image_name)
{
	setImageDisabledSelected(image_name.empty() ? NULL : LLUI::getUIImageByName(image_name));
	mImageDisabledSelectedName = image_name;
}
Esempio n. 29
0
void LLFloaterClothing::buildClothingList()
{
	//llinfos << "buildClothingList" << llendl;

	LLScrollListCtrl* list = gUICtrlFactory->getScrollListByName(this, "clothing_list");
	if (!list) return;

	list->operateOnAll(LLCtrlListInterface::OP_DELETE);

	LLInventoryModel::cat_array_t cats;
	LLInventoryModel::item_array_t items;

	LLIsClothing is_clothing;
	gInventory.collectDescendentsIf(gAgent.getInventoryRootID(),
									cats,
									items,
									LLInventoryModel::EXCLUDE_TRASH,
									is_clothing);

	S32 count = items.count();
	for(S32 i = 0; i < count; ++i)
	{
		LLInventoryItem* item = items.get(i);

		LLSD row;
		row["id"] = item->getUUID();

		BOOL item_is_multi = FALSE;
		if ( item->getFlags() & LLInventoryItem::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS )
		{
			item_is_multi = TRUE;
		}

		LLUUID image_id = get_item_icon_uuid(item->getType(),
											 item->getInventoryType(),
											 item->getFlags(), item_is_multi);		// flags = wearable type
		row["columns"][0]["column"] = "icon";
		row["columns"][0]["type"] = "icon";
		row["columns"][0]["value"] = image_id;

		LLString text = item->getName();
		LLString style = "NORMAL";
		if( gAgent.isWearingItem( item->getUUID() ) )
		{
			text.append(" (worn)");
			style = "BOLD";
		}
		row["columns"][1]["column"] = "name";
		row["columns"][1]["value"] = text;
		row["columns"][1]["font"] = "SANSSERIFSMALL";
		row["columns"][1]["font-style"] = style;

		// hidden column for sorting
		U32 flags = item->getFlags();	// flags = wearable type
		enum EWearableType wearable_type = (enum EWearableType)flags;
		const char* wearable_label = LLWearable::typeToTypeLabel(wearable_type);
		//line->addColumn(wearable_label, FONT, -1);	// invisible
		row["columns"][2]["column"] = "sort";
		row["columns"][2]["value"] = wearable_label;

		list->addElement(row);
	}

	if (count > 0)
	{
		mAllowSelection = TRUE;
	}
	else if (LLInventoryModel::backgroundFetchActive())
	{
		// We're loading
		list->addCommentText(LOADING_STRING);
		mAllowSelection = FALSE;
	}
	else
	{
		// Weird case, we're done loading but have no clothing
		list->addCommentText("No clothing found.");
		mAllowSelection = FALSE;
	}
}
Esempio n. 30
0
// Default constructor
LLFloaterAbout::LLFloaterAbout() 
:	LLFloater("floater_about", "FloaterAboutRect", "")
{
	gUICtrlFactory->buildFloater(this, "floater_about.xml");

	// Support for changing product name.
	LLString title("About ");
	title += LLAppViewer::instance()->getSecondLifeTitle();
	setTitle(title);

	LLString support;

	// Version string
	LLString version = LLAppViewer::instance()->getSecondLifeTitle() 
		+ llformat(" %d.%d.%d.%d Netbook Edition v1.2 %s %s", LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH, LL_VIEWER_BUILD, __DATE__, __TIME__);
//MK
	if (RRenabled)
	{
		version += "\n" + gAgent.mRRInterface.getVersion ();
	}
//mk
	support.append(version);
	support.append("\n\n");

	// Position
	LLViewerRegion* region = gAgent.getRegion();
	if (region)
	{
		const LLVector3d &pos = gAgent.getPositionGlobal();
		LLUIString pos_text = childGetText("you_are_at");
		pos_text.setArg("[POSITION]",
						llformat("%.1f, %.1f, %.1f ", pos.mdV[VX], pos.mdV[VY], pos.mdV[VZ]));
//MK
		if (RRenabled && gAgent.mRRInterface.mContainsShowloc)
		{
			pos_text = "(Position hidden)\n";
		}
//mk
		support.append(pos_text);

		LLString region_text = llformat("in %s located at ",
				gAgent.getRegion()->getName().c_str());
//MK
		if (RRenabled && gAgent.mRRInterface.mContainsShowloc)
		{
			region_text = "(Region hidden)\n";
		}
//mk
		support.append(region_text);

//MK
		if (!RRenabled || !gAgent.mRRInterface.mContainsShowloc)
		{
//mk
			char buffer[MAX_STRING];		/*Flawfinder: ignore*/
			gAgent.getRegion()->getHost().getHostName(buffer, MAX_STRING);
			support.append(buffer);
			support.append(" (");
			gAgent.getRegion()->getHost().getString(buffer, MAX_STRING);
			support.append(buffer);
			support.append(")\n");
			support.append(gLastVersionChannel);
			support.append("\n\n");
//MK
		}
		else
		{
			support.append ("(Server info hidden)\n\n");
		}
//mk
	}

	//*NOTE: Do not translate text like GPU, Graphics Card, etc -
	//  Most PC users that know what these mean will be used to the english versions,
	//  and this info sometimes gets sent to support
	
	// CPU
	support.append("CPU: ");
	support.append( gSysCPU.getCPUString() );
	support.append("\n");

	U32 memory = gSysMemory.getPhysicalMemoryKB() / 1024;
	// Moved hack adjustment to Windows memory size into llsys.cpp

	LLString mem_text = llformat("Memory: %u MB\n", memory );
	support.append(mem_text);

	support.append("OS Version: ");
	support.append( LLAppViewer::instance()->getOSInfo().getOSString().c_str() );
	support.append("\n");

	support.append("Graphics Card Vendor: ");
	support.append( (const char*) glGetString(GL_VENDOR) );
	support.append("\n");

	support.append("Graphics Card: ");
	support.append( (const char*) glGetString(GL_RENDERER) );
	support.append("\n");

	support.append("OpenGL Version: ");
	support.append( (const char*) glGetString(GL_VERSION) );
	support.append("\n");

#if LL_LIBXUL_ENABLED
	support.append("LLMozLib Version: ");
	support.append( (const char*) LLMozLib::getInstance()->getVersion().c_str() );
	support.append("\n");
#endif // LL_LIBXUL_ENABLED

	if (gViewerStats
		&& gPacketsIn > 0)
	{
		LLString packet_loss = llformat("Packets Lost: %.0f/%.0f (%.1f%%)", 
			gViewerStats->mPacketsLostStat.getCurrent(),
			F32(gPacketsIn),
			100.f*gViewerStats->mPacketsLostStat.getCurrent() / F32(gPacketsIn) );
		support.append(packet_loss);
		support.append("\n");
	}

	// MD5 digest of executable
	support.append("Viewer Digest: ");
	char viewer_digest_string[UUID_STR_LENGTH]; /*Flawfinder: ignore*/
	gViewerDigest.toString( viewer_digest_string );
	support.append(viewer_digest_string);

	// Fix views
	childDisable("credits_editor");

	LLTextEditor * support_widget = (LLTextEditor *) getChildByName("support_editor", true);
	if (support_widget)
	{
		support_widget->setEnabled( FALSE );
		support_widget->setTakesFocus( TRUE );
		support_widget->setText( support );
		support_widget->setHandleEditKeysDirectly( TRUE );
	}

	center();

	sInstance = this;
}