void LLViewerImageList::addImage(LLViewerImage *new_image)
{
	if (!new_image)
	{
		llwarning("No image to add to image list", 0);
		return;
	}
	LLUUID image_id = new_image->getID();
	
	LLViewerImage *image = hasImage(image_id);
	if (image)
	{
		llwarns << "Image with ID " << image_id << " already in list" << llendl;
	}
	sNumImages++;
	
	addImageToList(new_image);
	mUUIDMap[image_id] = new_image;
}
Example #2
0
void LLFlatListView::onItemMouseClick(item_pair_t* item_pair, MASK mask)
{
	if (!item_pair) return;

	if (!item_pair->first) 
	{
		llwarning("Attempt to selet an item pair containing null panel item", 0);
		return;
	}

	setFocus(TRUE);
	
	bool select_item = !isSelected(item_pair);

	//*TODO find a better place for that enforcing stuff
	if (mKeepOneItemSelected && numSelected() == 1 && !select_item) return;
	
	if (!(mask & MASK_CONTROL) || !mMultipleSelection) resetSelection();
	selectItemPair(item_pair, select_item);
}
	virtual ~LLOrderMyOutfitsOnDestroy()
	{
		if (!LLApp::isRunning())
		{
			llwarns << "called during shutdown, skipping" << llendl;
			return;
		}
		
		const LLUUID& my_outfits_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS);
		if (my_outfits_id.isNull()) return;

		LLInventoryModel::cat_array_t* cats;
		LLInventoryModel::item_array_t* items;
		gInventory.getDirectDescendentsOf(my_outfits_id, cats, items);
		if (!cats) return;

		//My Outfits should at least contain saved initial outfit and one another outfit
		if (cats->size() < 2)
		{
			llwarning("My Outfits category was not populated properly", 0);
			return;
		}

		llinfos << "Starting updating My Outfits with wearables ordering information" << llendl;

		for (LLInventoryModel::cat_array_t::iterator outfit_iter = cats->begin();
			outfit_iter != cats->end(); ++outfit_iter)
		{
			const LLUUID& cat_id = (*outfit_iter)->getUUID();
			if (cat_id.isNull()) continue;

			// saved initial outfit already contains wearables ordering information
			if (cat_id == LLAppearanceMgr::getInstance()->getBaseOutfitUUID()) continue;

			LLAppearanceMgr::getInstance()->updateClothingOrderingInfo(cat_id);
		}

		llinfos << "Finished updating My Outfits with wearables ordering information" << llendl;
	}
void LLCallFloater::updateSession()
{
	LLVoiceChannel* voice_channel = LLVoiceChannel::getCurrentVoiceChannel();
	if (voice_channel)
	{
		LL_DEBUGS("Voice") << "Current voice channel: " << voice_channel->getSessionID() << LL_ENDL;

		if (mSpeakerManager && voice_channel->getSessionID() == mSpeakerManager->getSessionID())
		{
			LL_DEBUGS("Voice") << "Speaker manager is already set for session: " << voice_channel->getSessionID() << LL_ENDL;
			return;
		}
		else
		{
			mSpeakerManager = NULL;
		}
	}

	const LLUUID& session_id = voice_channel ? voice_channel->getSessionID() : LLUUID::null;

	LLIMModel::LLIMSession* im_session = LLIMModel::getInstance()->findIMSession(session_id);
	if (im_session)
	{
		mSpeakerManager = LLIMModel::getInstance()->getSpeakerManager(session_id);
		switch (im_session->mType)
		{
		case IM_NOTHING_SPECIAL:
		case IM_SESSION_P2P_INVITE:
			mVoiceType = VC_PEER_TO_PEER;

			if (!im_session->mOtherParticipantIsAvatar)
			{
				mVoiceType = VC_PEER_TO_PEER_AVALINE;
			}
			break;
		case IM_SESSION_CONFERENCE_START:
		case IM_SESSION_GROUP_START:
		case IM_SESSION_INVITE:
			if (gAgent.isInGroup(session_id))
			{
				mVoiceType = VC_GROUP_CHAT;
			}
			else
			{
				mVoiceType = VC_AD_HOC_CHAT;				
			}
			break;
		default:
			llwarning("Failed to determine voice call IM type", 0);
			mVoiceType = VC_GROUP_CHAT;
			break;
		}
	}

	if (NULL == mSpeakerManager)
	{
		// By default show nearby chat participants
		mSpeakerManager = LLLocalSpeakerMgr::getInstance();
		LL_DEBUGS("Voice") << "Set DEFAULT speaker manager" << LL_ENDL;
		mVoiceType = VC_LOCAL_CHAT;
	}

	updateTitle();

	// Hide "Leave Call" button for nearby chat
	bool is_local_chat = mVoiceType == VC_LOCAL_CHAT;
	getChildView("leave_call_btn_panel")->setVisible( !is_local_chat);

	refreshParticipantList();
	updateAgentModeratorState();

	// Show floater for voice calls & only in CONNECTED to voice channel state
	if (!is_local_chat &&
	    voice_channel &&
	    LLVoiceChannel::STATE_CONNECTED == voice_channel->getState())
	{
		LLIMFloater* im_floater = LLIMFloater::findInstance(session_id);
		bool show_me = !(im_floater && im_floater->getVisible());
		if (show_me) 
		{
			setVisible(true);
		}
	}

// [RLVa:KB] - Checked: 2010-06-05 (RLVa-1.2.0d) | Added: RLVa-1.2.0d
	mAvatarList->setRlvCheckShowNames(is_local_chat);
// [/RLVa:KB]
}
Example #5
0
BOOL decode_vorbis_file(LLVFS *vfs, const LLUUID &in_uuid, char *out_fname)
{
	ov_callbacks vfs_callbacks;
	vfs_callbacks.read_func = vfs_read;
	vfs_callbacks.seek_func = vfs_seek;
	vfs_callbacks.close_func = vfs_close;
	vfs_callbacks.tell_func = vfs_tell;

	char pcmout[4096]; /*Flawfinder: ignore*/

	unsigned char temp[64];	/*Flawfinder: ignore*/

	LLVFile *in_vfile;

	U32 data_length = 0;

	llinfos << "Vorbis decode from vfile: " << in_uuid << llendl;

	in_vfile = new LLVFile(vfs, in_uuid, LLAssetType::AT_SOUND);
	if (! in_vfile->getSize())
	{
		llwarning("unable to open vorbis source vfile for reading",0);
		return(FALSE);
	}
	apr_file_t* outfp = ll_apr_file_open(out_fname,LL_APR_WPB);
	if (!outfp)
	{
		llwarning("unable to open vorbis destination file for writing",0);
		return(FALSE);		
	}
	else
	{
		// write the .wav format header
		//"RIFF"
		temp[0] = 0x52;
		temp[1] = 0x49;
		temp[2] = 0x46;
		temp[3] = 0x46;
		
		// length = datalen + 36 (to be filled in later)
		temp[4] = 0x00;
		temp[5] = 0x00;
		temp[6] = 0x00;
		temp[7] = 0x00;
		
		//"WAVE"
		temp[8] = 0x57;
		temp[9] = 0x41;
		temp[10] = 0x56;
		temp[11] = 0x45;

		// "fmt "
		temp[12] = 0x66;
		temp[13] = 0x6D;
		temp[14] = 0x74;
		temp[15] = 0x20;

		// chunk size = 16
		temp[16] = 0x10;
		temp[17] = 0x00;
		temp[18] = 0x00;
		temp[19] = 0x00;

		// format (1 = PCM)
		temp[20] = 0x01;
		temp[21] = 0x00;

		// number of channels
		temp[22] = 0x01;
		temp[23] = 0x00;

		// samples per second
		temp[24] = 0x44;
		temp[25] = 0xAC;
		temp[26] = 0x00;
		temp[27] = 0x00;

		// average bytes per second
		temp[28] = 0x88;
		temp[29] = 0x58;
		temp[30] = 0x01;
		temp[31] = 0x00;

		// bytes to output at a single time
		temp[32] = 0x02;
		temp[33] = 0x00;
		 
		// 16 bits per sample
		temp[34] = 0x10;
		temp[35] = 0x00;

		// "data"
		temp[36] = 0x64;
		temp[37] = 0x61;
		temp[38] = 0x74;
		temp[39] = 0x61;


		// these are the length of the data chunk, to be filled in later
		temp[40] = 0x00;
		temp[41] = 0x00;
		temp[42] = 0x00;
		temp[43] = 0x00;


		ll_apr_file_write(outfp, temp, 44);
	}

	OggVorbis_File vf;
	int eof=0;
	int current_section;
 
	int r = ov_open_callbacks(in_vfile, &vf, NULL, 0, vfs_callbacks);
	if(r < 0) 
	{
		llwarns << r << " Input to vorbis decode does not appear to be an Ogg bitstream: " << in_uuid << llendl;
		return(FALSE);
	}

	{
		char **ptr=ov_comment(&vf,-1)->user_comments;
//		vorbis_info *vi=ov_info(&vf,-1);
		while(*ptr){
			fprintf(stderr,"%s\n",*ptr);
			++ptr;
		}
//    fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate);
//    fprintf(stderr,"\nDecoded length: %ld samples\n", (long)ov_pcm_total(&vf,-1));
//    fprintf(stderr,"Encoded by: %s\n\n",ov_comment(&vf,-1)->vendor);
	}
  
	while(!eof){
		long ret=ov_read(&vf,pcmout,sizeof(pcmout),0,2,1,&current_section);
		if (ret == 0) {
			/* EOF */
			eof=1;
//			llinfos << "Vorbis EOF" << llendl;
		} else if (ret < 0) {
			/* error in the stream.  Not a problem, just reporting it in
			   case we (the app) cares.  In this case, we don't. */
			llwarning("Error in vorbis stream",0); 
			break;

		} else {
//			llinfos << "Vorbis read " << ret << "bytes" << llendl;
			/* we don't bother dealing with sample rate changes, etc, but.
			   you'll have to*/
			data_length += ll_apr_file_write(outfp, pcmout, ret);
		}
	}

	ov_clear(&vf);
  
	// write "data" chunk length
	ll_apr_file_seek(outfp,APR_SET,40);
	ll_apr_file_write(outfp,&data_length,4);
 
	// write overall "RIFF" length
	data_length += 36;
	ll_apr_file_seek(outfp,APR_SET,4);
	ll_apr_file_write(outfp,&data_length,1*4);

	// F**K!!! Vorbis encode/decode messes up loop point transitions (pop)
	// do a cheap-and-cheesy crossfade 
	

	S16 *samplep;
	S32 i;
	S32 fade_length;

	fade_length = llmin((S32)128,(S32)(data_length-36)/8);
	
	ll_apr_file_seek(outfp,APR_SET,44);
	ll_apr_file_read(outfp, pcmout,2*fade_length);  //read first 16 samples

	samplep = (S16 *)pcmout;

	for (i = 0 ;i < fade_length; i++)
	{
		*samplep++ = ((F32)*samplep * ((F32)i/(F32)fade_length));	   
	}
	
	ll_apr_file_seek(outfp,APR_SET,44);
	ll_apr_file_write(outfp,pcmout,2*fade_length);  //write back xfaded first 16 samples

	ll_apr_file_seek(outfp,APR_END,-fade_length*2); 
	ll_apr_file_read(outfp, pcmout,2*fade_length);  //read last 16 samples

	samplep = (S16 *)pcmout;

	for (i = fade_length-1 ; i >=  0; i--)
	{
		*samplep++ = ((F32)*samplep * ((F32)i/(F32)fade_length));	   
	}
	
	ll_apr_file_seek(outfp,SEEK_END,-fade_length*2); 
	ll_apr_file_write(outfp,pcmout,2*fade_length);  //write back xfaded last 16 samples

	apr_file_close(outfp);

	if ((36 == data_length) || (!(eof)))
	{
		llwarning("BAD Vorbis DECODE!, removing .wav!",0); 
		LLFile::remove(out_fname);
		return (FALSE);
	}
    
//	fprintf(stderr,"Done.\n");

	return(TRUE);
}
Example #6
0
void LLFlatListView::onItemMouseClick(item_pair_t* item_pair, MASK mask)
{
	if (!item_pair) return;

	if (!item_pair->first) 
	{
		llwarning("Attempt to selet an item pair containing null panel item", 0);
		return;
	}

	setFocus(TRUE);
	
	bool select_item = !isSelected(item_pair);

	//*TODO find a better place for that enforcing stuff
	if (mKeepOneItemSelected && numSelected() == 1 && !select_item) return;

	if ( (mask & MASK_SHIFT) && !(mask & MASK_CONTROL)
		 && mMultipleSelection && !mSelectedItemPairs.empty() )
	{
		item_pair_t* last_selected_pair = mSelectedItemPairs.back();

		// If item_pair is already selected - do nothing
		if (last_selected_pair == item_pair)
			return;

		bool grab_items = false;
		bool reverse = false;
		pairs_list_t pairs_to_select;

		// Pick out items from list between last selected and current clicked item_pair.
		for (pairs_iterator_t
				 iter = mItemPairs.begin(),
				 iter_end = mItemPairs.end();
			 iter != iter_end; ++iter)
		{
			item_pair_t* cur = *iter;
			if (cur == last_selected_pair || cur == item_pair)
			{
				// We've got reverse selection if last grabed item isn't a new selection.
				reverse = grab_items && (cur != item_pair);
				grab_items = !grab_items;
				// Skip last selected and current clicked item pairs.
				continue;
			}
			if (!cur->first->getVisible())
			{
				// Skip invisible item pairs.
				continue;
			}
			if (grab_items)
			{
				pairs_to_select.push_back(cur);
			}
		}

		if (reverse)
		{
			pairs_to_select.reverse();
		}

		pairs_to_select.push_back(item_pair);

		for (pairs_iterator_t
				 iter = pairs_to_select.begin(),
				 iter_end = pairs_to_select.end();
			 iter != iter_end; ++iter)
		{
			item_pair_t* pair_to_select = *iter;
			if (isSelected(pair_to_select))
			{
				// Item was already selected but there is a need to keep order from last selected pair to new selection.
				// Do it here to prevent extra mCommitOnSelectionChange in selectItemPair().
				mSelectedItemPairs.remove(pair_to_select);
				mSelectedItemPairs.push_back(pair_to_select);
			}
			else
			{
				selectItemPair(pair_to_select, true);
			}
		}

		if (!select_item)
		{
			// Update last selected item border.
			mSelectedItemsBorder->setRect(getLastSelectedItemRect().stretch(-1));
		}
		return;
	}

	//no need to do additional commit on selection reset
	if (!(mask & MASK_CONTROL) || !mMultipleSelection) resetSelection(true);

	//only CTRL usage allows to deselect an item, usual clicking on an item cannot deselect it
	if (mask & MASK_CONTROL)
	selectItemPair(item_pair, select_item);
	else
		selectItemPair(item_pair, true);
}