Ejemplo n.º 1
0
//compares two LLSD's
bool llsds_are_equal(const LLSD& llsd_1, const LLSD& llsd_2)
{
	llassert(llsd_1.isDefined());
	llassert(llsd_2.isDefined());
	
	if (llsd_1.type() != llsd_2.type()) return false;

	if (!llsd_1.isMap())
	{
		if (llsd_1.isUUID()) return llsd_1.asUUID() == llsd_2.asUUID();

		//assumptions that string representaion is enough for other types
		return llsd_1.asString() == llsd_2.asString();
	}

	if (llsd_1.size() != llsd_2.size()) return false;

	LLSD::map_const_iterator llsd_1_it = llsd_1.beginMap();
	LLSD::map_const_iterator llsd_2_it = llsd_2.beginMap();
	for (S32 i = 0; i < llsd_1.size(); ++i)
	{
		if ((*llsd_1_it).first != (*llsd_2_it).first) return false;
		if (!llsds_are_equal((*llsd_1_it).second, (*llsd_2_it).second)) return false;
		++llsd_1_it;
		++llsd_2_it;
	}
	return true;
}
Ejemplo n.º 2
0
// static
void LLClassifiedInfo::loadCategories(const LLSD& options)
{
	for(LLSD::array_const_iterator resp_it = options.beginArray(),
		end = options.endArray(); resp_it != end; ++resp_it)
	{
		LLSD name = (*resp_it)["category_name"];
		if(name.isDefined())
		{
			LLSD id = (*resp_it)["category_id"];
			if(id.isDefined())
			{
				LLClassifiedInfo::sCategories[id.asInteger()] = name.asString();
			}
		}
	}
}
	void sd_object::test<9>()
	{
		std::ostringstream resp;
		resp << "{'label':'short binary test', 'singlebinary':b(1)\"A\", 'singlerawstring':s(1)\"A\", 'endoftest':'end' }";
		std::string str = resp.str();
		LLSD sd;
		LLMemoryStream mstr((U8*)str.c_str(), str.size());
		S32 count = LLSDSerialize::fromNotation(sd, mstr, str.size());
		ensure_equals("parse count", count, 5);
		ensure("sd created", sd.isDefined());
		ensure_equals("sd type", sd.type(), LLSD::TypeMap);
		ensure_equals("map element count", sd.size(), 4);
		ensure_equals(
			"label",
			sd["label"].asString(),
			"short binary test");
		std::vector<U8> bin =  sd["singlebinary"].asBinary();
		std::vector<U8> expected;
		expected.resize(1);
		expected[0] = 'A';
		ensure("single binary", (0 == memcmp(&bin[0], &expected[0], 1)));
		ensure_equals(
			"single string",
			sd["singlerawstring"].asString(),
			std::string("A"));
		ensure_equals("end", sd["endoftest"].asString(), "end");
	}
Ejemplo n.º 4
0
	virtual bool validate(const std::string& name, LLSD& context) const
	{
		llinfos << "LLHTTPLiveConfigSingleService::validate(" << name
			<< ")" << llendl;
		LLSD option = LLApp::instance()->getOption(name);
		if(option.isDefined()) return true;
		else return false;
	}
Ejemplo n.º 5
0
// virtual
LLIOPipe::EStatus LLHTTPResponseHeader::process_impl(
	const LLChannelDescriptors& channels,
	buffer_ptr_t& buffer,
	bool& eos,
	LLSD& context,
	LLPumpIO* pump)
{
	PUMP_DEBUG;
	LLMemType m1(LLMemType::MTYPE_IO_HTTP_SERVER);
	if(eos)
	{
		PUMP_DEBUG;
		//mGotEOS = true;
		std::ostringstream ostr;
		std::string message = context[CONTEXT_RESPONSE]["statusMessage"];
		
		int code = context[CONTEXT_RESPONSE]["statusCode"];
		if (code < 200)
		{
			code = 200;
			message = "OK";
		}
		
		ostr << HTTP_VERSION_STR << " " << code << " " << message << "\r\n";
		S32 content_length = buffer->countAfter(channels.in(), NULL);
		if(0 < content_length)
		{
			ostr << "Content-Length: " << content_length << "\r\n";
		}
		// *NOTE: This guard can go away once the LLSD static map
		// iterator is available. Phoenix. 2008-05-09
		LLSD headers = context[CONTEXT_RESPONSE][CONTEXT_HEADERS];
		if(headers.isDefined())
		{
			LLSD::map_iterator iter = headers.beginMap();
			LLSD::map_iterator end = headers.endMap();
			for(; iter != end; ++iter)
			{
				ostr << (*iter).first << ": " << (*iter).second.asString()
					<< "\r\n";
			}
		}
		ostr << "\r\n";

		LLChangeChannel change(channels.in(), channels.out());
		std::for_each(buffer->beginSegment(), buffer->endSegment(), change);
		std::string header = ostr.str();
		buffer->prepend(channels.out(), (U8*)header.c_str(), header.size());
		PUMP_DEBUG;
		return STATUS_DONE;
	}
	PUMP_DEBUG;
	return STATUS_OK;
}
Ejemplo n.º 6
0
//static
void LLPanelPicks::onClickDelete()
{
	LLSD value = mPicksList->getSelectedValue();
	if (value.isDefined())
	{
		LLSD args; 
		args["PICK"] = value[PICK_NAME]; 
		LLNotificationsUtil::add("DeleteAvatarPick", args, LLSD(), boost::bind(&LLPanelPicks::callbackDeletePick, this, _1, _2)); 
		return;
	}

	value = mClassifiedsList->getSelectedValue();
	if(value.isDefined())
	{
		LLSD args; 
		args["NAME"] = value[CLASSIFIED_NAME]; 
		LLNotificationsUtil::add("DeleteClassified", args, LLSD(), boost::bind(&LLPanelPicks::callbackDeleteClassified, this, _1, _2)); 
		return;
	}
}
// called when the Delete Entry button is pressed
void LLFloaterAutoReplaceSettings::onDeleteEntry()
{
	LLSD selectedRow = mReplacementsList->getSelectedValue();
	if (selectedRow.isDefined())
	{	
		std::string keyword = selectedRow.asString();
		mReplacementsList->deleteSelectedItems(); // delete from the control
		mSettings.removeEntryFromList(keyword, mSelectedListName); // delete from the local settings copy
		disableReplacementEntry(); // no selection active, so turn off the buttons
	}
}
Ejemplo n.º 8
0
bool LLCrashLogger::init()
{
	// We assume that all the logs we're looking for reside on the current drive
	gDirUtilp->initAppDirs("SecondLife");

	// Default to the product name "Second Life" (this is overridden by the -name argument)
	mProductName = "Second Life";
	
	mCrashSettings.declareS32(CRASH_BEHAVIOR_SETTING, CRASH_BEHAVIOR_ASK, "Controls behavior when viewer crashes "
		"(0 = ask before sending crash report, 1 = always send crash report, 2 = never send crash report)");

	llinfos << "Loading crash behavior setting" << llendl;
	mCrashBehavior = loadCrashBehaviorSetting();

	//Run through command line options
	if(getOption("previous").isDefined())
	{
		llinfos << "Previous execution did not remove SecondLife.exec_marker" << llendl;
		mCrashInPreviousExec = TRUE;
	}

	if(getOption("dialog").isDefined())
	{
		llinfos << "Show the user dialog" << llendl;
		mCrashBehavior = CRASH_BEHAVIOR_ASK;
	}
	
	LLSD name = getOption("name");
	if(name.isDefined())
	{	
		mProductName = name.asString();
	}

	// If user doesn't want to send, bail out
	if (mCrashBehavior == CRASH_BEHAVIOR_NEVER_SEND)
	{
		llinfos << "Crash behavior is never_send, quitting" << llendl;
		return false;
	}

	gServicePump = new LLPumpIO(gAPRPoolp);
	gServicePump->prime(gAPRPoolp);
	LLHTTPClient::setPump(*gServicePump);

	//If we've opened the crash logger, assume we can delete the marker file if it exists	
	if( gDirUtilp )
	{
		std::string marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"SecondLife.exec_marker");
		ll_apr_file_remove( marker_file );
	}
	
	return true;
}
Ejemplo n.º 9
0
LLSD LLApp::getOption(const std::string& name) const
{
	LLSD rv;
	LLSD::array_const_iterator iter = mOptions.beginArray();
	LLSD::array_const_iterator end = mOptions.endArray();
	for(; iter != end; ++iter)
	{
		rv = (*iter)[name];
		if(rv.isDefined()) break;
	}
	return rv;
}
Ejemplo n.º 10
0
bool LLProgressView::handleUpdate(const LLSD& event_data)
{
	LLSD message = event_data.get("message");
	LLSD desc = event_data.get("desc");
	LLSD percent = event_data.get("percent");

	if(message.isDefined())
	{
		setMessage(message.asString());
	}

	if(desc.isDefined())
	{
		setText(desc.asString());
	}
	
	if(percent.isDefined())
	{
		setPercent(percent.asReal());
	}
	return false;
}
void LLFloaterChatterBox::onOpen(const LLSD& key)
{
	//*TODO:Skinning show the session id associated with key
	if (key.asString() == "local")
	{
	}
	else if (key.isDefined())
	{
		/*LLFloaterIMPanel* impanel = gIMMgr->findFloaterBySession(key.asUUID());
		if (impanel)
		{
			impanel->openFloater();
		}*/
	}
}
void LLLoginInstance::handleIndeterminate(const LLSD& event)
{
	// The indeterminate response means that the server
	// gave the viewer a new url and params to try.
	// The login module handles the retry, but it gives us the
	// server response so that we may show
	// the user some status.
	LLSD message = event.get("data").get("message");
	if(message.isDefined())
	{
		LLSD progress_update;
		progress_update["desc"] = message;
		LLEventPumps::getInstance()->obtain("LLProgressView").post(progress_update);
	}
}
	void sd_object::test<1>()
	{
		std::ostringstream resp;
		resp << "{'connect':true,  'position':[r128,r128,r128], 'look_at':[r0,r1,r0], 'agent_access':'M', 'region_x':i8192, 'region_y':i8192}";
		std::string str = resp.str();
		LLMemoryStream mstr((U8*)str.c_str(), str.size());
		LLSD response;
		S32 count = LLSDSerialize::fromNotation(response, mstr, str.size());
		ensure("stream parsed", response.isDefined());
		ensure_equals("stream parse count", count, 13);
		ensure_equals("sd type", response.type(), LLSD::TypeMap);
		ensure_equals("map element count", response.size(), 6);
		ensure_equals("value connect", response["connect"].asBoolean(), true);
		ensure_equals("value region_x", response["region_x"].asInteger(),8192);
		ensure_equals("value region_y", response["region_y"].asInteger(),8192);
	}
Ejemplo n.º 14
0
void LLSpellChecker::setSecondaryDictionaries(dict_list_t dict_list)
{
	if (!getUseSpellCheck())
	{
		return;
	}

	// Check if we're only adding secondary dictionaries, or removing them
	dict_list_t dict_add(llmax(dict_list.size(), mDictSecondary.size())), dict_rem(llmax(dict_list.size(), mDictSecondary.size()));
	dict_list.sort();
	mDictSecondary.sort();
	dict_list_t::iterator end_added = std::set_difference(dict_list.begin(), dict_list.end(), mDictSecondary.begin(), mDictSecondary.end(), dict_add.begin());
	dict_list_t::iterator end_removed = std::set_difference(mDictSecondary.begin(), mDictSecondary.end(), dict_list.begin(), dict_list.end(), dict_rem.begin());

	if (end_removed != dict_rem.begin())		// We can't remove secondary dictionaries so we need to recreate the Hunspell instance
	{
		mDictSecondary = dict_list;

		std::string dict_language = mDictLanguage;
		initHunspell(dict_language);
	}
	else if (end_added != dict_add.begin())		// Add the new secondary dictionaries one by one
	{
		const std::string app_path = getDictionaryAppPath();
		const std::string user_path = getDictionaryUserPath();
		for (dict_list_t::const_iterator it_added = dict_add.begin(); it_added != end_added; ++it_added)
		{
			const LLSD dict_entry = getDictionaryData(*it_added);
			if ( (!dict_entry.isDefined()) || (!dict_entry["installed"].asBoolean()) )
			{
				continue;
			}

			const std::string strFileDic = dict_entry["name"].asString() + ".dic";
			if (gDirUtilp->fileExists(user_path + strFileDic))
			{
				mHunspell->add_dic((user_path + strFileDic).c_str());
			}
			else if (gDirUtilp->fileExists(app_path + strFileDic))
			{
				mHunspell->add_dic((app_path + strFileDic).c_str());
			}
		}
		mDictSecondary = dict_list;
		sSettingsChangeSignal();
	}
}
	void sd_object::test<10>()
	{

		std::string message("parcel '' is naughty.");
		std::stringstream str;
		str << "{'message':'" << LLSDNotationFormatter::escapeString(message)
			<< "'}";
		std::string expected_str("{'message':'parcel \\'\\' is naughty.'}");
		std::string actual_str = str.str();
		ensure_equals("stream contents", actual_str, expected_str);
		LLSD sd;
		S32 count = LLSDSerialize::fromNotation(sd, str, actual_str.size());
		ensure_equals("parse count", count, 2);
		ensure("valid parse", sd.isDefined());
		std::string actual = sd["message"].asString();
		ensure_equals("message contents", actual, message);
	}
Ejemplo n.º 16
0
	LLSD getProgressEventLLSD(const std::string& state, const std::string& change,
						   const LLSD& data = LLSD())
	{
		LLSD status_data;
		status_data["state"] = state;
		status_data["change"] = change;
		status_data["progress"] = 0.0f;

		if(mAuthResponse.has("transfer_rate"))
		{
			status_data["transfer_rate"] = mAuthResponse["transfer_rate"];
		}

		if(data.isDefined())
		{
			status_data["data"] = data;
		}
		return status_data;
	}
void LLFloaterAutoReplaceSettings::onSelectEntry()
{
    LLSD selectedRow = mReplacementsList->getSelectedValue();
	if (selectedRow.isDefined())
	{
		mPreviousKeyword = selectedRow.asString();
		LL_DEBUGS("AutoReplace")<<"selected entry '"<<mPreviousKeyword<<"'"<<LL_ENDL;	
		mKeyword->setValue(selectedRow);
		std::string replacement = mSettings.replacementFor(mPreviousKeyword, mSelectedListName );
		mReplacement->setValue(replacement);
		enableReplacementEntry();		
		mReplacement->setFocus(true);
	}
	else
	{
		// no entry selection, so the entry panel should be off
		disableReplacementEntry();		
		LL_DEBUGS("AutoReplace")<<"no row selected"<<LL_ENDL;
	}
}
void LLFloaterAutoReplaceSettings::onSelectList()
{
	std::string previousSelectedListName = mSelectedListName;
	// only one selection allowed
	LLSD selected = mListNames->getSelectedValue();
	if (selected.isDefined())
	{
		mSelectedListName = selected.asString();
		LL_DEBUGS("AutoReplace")<<"selected list '"<<mSelectedListName<<"'"<<LL_ENDL;
	}
	else
	{
		mSelectedListName.clear();
		LL_DEBUGS("AutoReplace")<<"unselected"<<LL_ENDL;
	}

	updateListNamesControls();

	if ( previousSelectedListName != mSelectedListName )
	{
		updateReplacementsList();
	}
}
Ejemplo n.º 19
0
	LLSD getConfig(const std::string& name, const LLSD& defaultVal) const
	{ 
		LLSD r = mProcessorInfo["config"].get(name);
		return r.isDefined() ? r : defaultVal;
	}
BOOL LLEventNotification::load(const LLSD& response)
{
	BOOL event_ok = TRUE;
	LLSD option = response.get("event_id");
	if (option.isDefined())
	{
		mEventID = option.asInteger();
	}
	else
	{
		event_ok = FALSE;
	}

	option = response.get("event_name");
	if (option.isDefined())
	{
		llinfos << "Event: " << option.asString() << llendl;
		mEventName = option.asString();
	}
	else
	{
		event_ok = FALSE;
	}

	option = response.get("event_date");
	if (option.isDefined())
	{
		llinfos << "EventDate: " << option.asString() << llendl;
		mEventDateStr = option.asString();
	}
	else
	{
		event_ok = FALSE;
	}

	option = response.get("event_date_ut");
	if (option.isDefined())
	{
		llinfos << "EventDate: " << option.asString() << llendl;
		mEventDate = strtoul(option.asString().c_str(), NULL, 10);
	}
	else
	{
		event_ok = FALSE;
	}

	S32 grid_x = 0;
	S32 grid_y = 0;
	S32 x_region = 0;
	S32 y_region = 0;

	option = response.get("grid_x");
	if (option.isDefined())
	{
		llinfos << "GridX: " << option.asInteger() << llendl;
		grid_x= option.asInteger();
	}
	else
	{
		event_ok = FALSE;
	}

	option = response.get("grid_y");
	if (option.isDefined())
	{
		llinfos << "GridY: " << option.asInteger() << llendl;
		grid_y = option.asInteger();
	}
	else
	{
		event_ok = FALSE;
	}

	option = response.get("x_region");
	if (option.isDefined())
	{
		llinfos << "RegionX: " << option.asInteger() << llendl;
		x_region = option.asInteger();
	}
	else
	{
		event_ok = FALSE;
	}

	option = response.get("y_region");
	if (option.isDefined())
	{
		llinfos << "RegionY: " << option.asInteger() << llendl;
		y_region = option.asInteger();
	}
	else
	{
		event_ok = FALSE;
	}

	mEventPosGlobal.mdV[VX] = grid_x * 256 + x_region;
	mEventPosGlobal.mdV[VY] = grid_y * 256 + y_region;
	mEventPosGlobal.mdV[VZ] = 0.f;

	return event_ok;
}
//compares the structure of an LLSD to a template LLSD and stores the
//"valid" values in a 3rd LLSD.  Default values pulled from the template
//if the tested LLSD does not contain the key/value pair.
//Excess values in the test LLSD are ignored in the resultant_llsd.
//If the llsd to test has a specific key to a map and the values
//are not of the same type, false is returned or if the LLSDs are not
//of the same value.  Ordering of arrays matters
//Otherwise, returns true
BOOL compare_llsd_with_template(
	const LLSD& llsd_to_test,
	const LLSD& template_llsd,
	LLSD& resultant_llsd)
{
	if (
		llsd_to_test.isUndefined() &&
		template_llsd.isDefined() )
	{
		resultant_llsd = template_llsd;
		return TRUE;
	}
	else if ( llsd_to_test.type() != template_llsd.type() )
	{
		resultant_llsd = LLSD();
		return FALSE;
	}

	if ( llsd_to_test.isArray() )
	{
		//they are both arrays
		//we loop over all the items in the template
		//verifying that the to_test has a subset (in the same order)
		//any shortcoming in the testing_llsd are just taken
		//to be the rest of the template
		LLSD data;
		LLSD::array_const_iterator test_iter;
		LLSD::array_const_iterator template_iter;

		resultant_llsd = LLSD::emptyArray();
		test_iter = llsd_to_test.beginArray();

		for (
			template_iter = template_llsd.beginArray();
			(template_iter != template_llsd.endArray() &&
			 test_iter != llsd_to_test.endArray());
			++template_iter)
		{
			if ( !compare_llsd_with_template(
					 *test_iter,
					 *template_iter,
					 data) )
			{
				resultant_llsd = LLSD();
				return FALSE;
			}
			else
			{
				resultant_llsd.append(data);
			}

			++test_iter;
		}

		//so either the test or the template ended
		//we do another loop now to the end of the template
		//grabbing the default values
		for (;
			 template_iter != template_llsd.endArray();
			 ++template_iter)
		{
			resultant_llsd.append(*template_iter);
		}
	}
	else if ( llsd_to_test.isMap() )
	{
		//now we loop over the keys of the two maps
		//any excess is taken from the template
		//excess is ignored in the test
		LLSD value;
		LLSD::map_const_iterator template_iter;

		resultant_llsd = LLSD::emptyMap();
		for (
			template_iter = template_llsd.beginMap();
			template_iter != template_llsd.endMap();
			++template_iter)
		{
			if ( llsd_to_test.has(template_iter->first) )
			{
				//the test LLSD has the same key
				if ( !compare_llsd_with_template(
						 llsd_to_test[template_iter->first],
						 template_iter->second,
						 value) )
				{
					resultant_llsd = LLSD();
					return FALSE;
				}
				else
				{
					resultant_llsd[template_iter->first] = value;
				}
			}
			else
			{
				//test llsd doesn't have it...take the
				//template as default value
				resultant_llsd[template_iter->first] =
					template_iter->second;
			}
		}
	}
	else
	{
		//of same type...take the test llsd's value
		resultant_llsd = llsd_to_test;
	}


	return TRUE;
}
void LLMediaRemoteCtrl::enableMediaButtons()
{
	// Media
	bool play_media_enabled = false;
	bool stop_media_enabled = false;
	bool play_music_enabled = false;
	bool stop_music_enabled = false;
	bool music_show_pause = false;
	bool media_show_pause = false;
	LLColor4 music_icon_color = LLUI::sColorsGroup->getColor( "IconDisabledColor" );
	LLColor4 media_icon_color = LLUI::sColorsGroup->getColor( "IconDisabledColor" );
	std::string media_type = "none/none";

	// Put this in xui file
	std::string media_url = mControls->getString("default_tooltip_label");
	LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();

	if (gSavedSettings.getBOOL("AudioStreamingMedia"))
	{
		if ( parcel && !parcel->getMediaURL().empty())
		{
			// Set the tooltip
			// Put this text into xui file
			media_url = parcel->getMediaURL();
			media_type = parcel->getMediaType();

			play_media_enabled = true;
			media_icon_color = LLUI::sColorsGroup->getColor( "IconEnabledColor" );

			LLViewerMediaImpl::EMediaStatus status = LLViewerParcelMedia::getStatus();
			switch(status)
			{
			case LLViewerMediaImpl::MEDIA_NONE:
				media_show_pause = false;
				stop_media_enabled = false;
				break;
			case LLViewerMediaImpl::MEDIA_LOADING:
			case LLViewerMediaImpl::MEDIA_LOADED:
			case LLViewerMediaImpl::MEDIA_PLAYING:
				// HACK: only show the pause button for movie types
				media_show_pause = LLMIMETypes::widgetType(parcel->getMediaType()) == "movie" ? true : false;
				stop_media_enabled = true;
				play_media_enabled = false;
				break;
			case LLViewerMediaImpl::MEDIA_PAUSED:
				media_show_pause = false;
				stop_media_enabled = true;
				break;
			default:
				// inherit defaults above
				break;
			}
		}
	}
	
	if (gSavedSettings.getBOOL("AudioStreamingMusic") && gAudiop)
	{
		if ( parcel && !parcel->getMusicURL().empty())
		{
			play_music_enabled = true;
			music_icon_color = LLUI::sColorsGroup->getColor( "IconEnabledColor" );

			if (gOverlayBar->musicPlaying())
			{
				music_show_pause = true;
				stop_music_enabled = true;
			}
			else
			{
				music_show_pause = false;
				stop_music_enabled = false;
			}
		}
		// Don't test the mime-type: this is not updated in a consistent basis. The existence of a valid gAudiop is enough guarantee.
	}
	const std::string media_icon_name = LLMIMETypes::findIcon(media_type);
	LLButton* music_play_btn = mMusicPlayBtn;
	LLButton* music_stop_btn = mMusicStopBtn;
	LLButton* music_pause_btn = mMusicPauseBtn;
	LLButton* media_play_btn = mMediaPlayBtn;
	LLButton* media_stop_btn = mMediaStopBtn;
	LLButton* media_pause_btn = mMediaPauseBtn;
	LLIconCtrl* media_icon = mMediaIcon;

	music_play_btn->setEnabled(play_music_enabled);
	music_stop_btn->setEnabled(stop_music_enabled);
	music_pause_btn->setEnabled(music_show_pause);
	music_pause_btn->setVisible(music_show_pause);
	music_play_btn->setVisible(! music_show_pause);

	if(music_show_pause)
	{
		LLStreamingAudioInterface *stream = gAudiop ? gAudiop->getStreamingAudioImpl() : NULL;
		if(stream && stream->getMetaData())
		{
			std::string info_text = "Loading...";
			const LLSD& metadata = *(stream->getMetaData());
			LLSD artist = metadata.get("ARTIST");
			LLSD title = metadata.get("TITLE");
			if(artist.isDefined() && title.isDefined())
				info_text = artist.asString() + " -- " + title.asString();
			else if(title.isDefined())
				info_text = getString("Title") + ": " + title.asString();
			else if(artist.isDefined())
				info_text = getString("Artist") + ": " + artist.asString();
			if(music_pause_btn->getToolTip() != info_text) //Has info_text changed since last call?
			{
				music_pause_btn->setToolTip(info_text);
				static LLCachedControl<bool> announce_stream_metadata("AnnounceStreamMetadata");
				if(announce_stream_metadata && info_text != sLastTooltip && info_text != "Loading...") //Are we announcing?  Don't annoounce what we've last announced.  Don't announce Loading.
				{
					sLastTooltip = info_text;
					LLChat chat;
					chat.mText = getString("Now_playing") + " " + info_text;
					chat.mSourceType = CHAT_SOURCE_SYSTEM;
					LLFloaterChat::addChat(chat);
				}
			}
		}
		else
			music_pause_btn->setToolTip(mCachedPauseTip);
	}

	mMusicIcon->setColor(music_icon_color);
	if(!media_icon_name.empty())
	{
		media_icon->setImage(media_icon_name);
	}

	media_play_btn->setEnabled(play_media_enabled);
	media_stop_btn->setEnabled(stop_media_enabled);
	media_pause_btn->setEnabled(media_show_pause);
	media_pause_btn->setVisible(media_show_pause);
	media_play_btn->setVisible(! media_show_pause);
	mMediaIcon->setColor(media_icon_color);

	setToolTip(media_url);
}
void LLMediaRemoteCtrl::enableMediaButtons()
{
	// Media
	bool play_media_enabled = false;
	bool stop_media_enabled = false;
	bool play_music_enabled = false;
	bool stop_music_enabled = false;
	bool music_show_pause = false;
	bool media_show_pause = false;
	LLColor4 music_icon_color = LLUI::sColorsGroup->getColor( "IconDisabledColor" );
	LLColor4 media_icon_color = LLUI::sColorsGroup->getColor( "IconDisabledColor" );
	std::string media_type = "none/none";

	// Put this in xui file
	std::string media_url = mControls->getString("default_tooltip_label");
	LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();

	if (gSavedSettings.getBOOL("AudioStreamingVideo"))
	{
		if ( parcel && !parcel->getMediaURL().empty())
		{
			// Set the tooltip
			// Put this text into xui file
			media_url = parcel->getMediaURL();
			media_type = parcel->getMediaType();

			play_media_enabled = true;
			media_icon_color = LLUI::sColorsGroup->getColor( "IconEnabledColor" );

			LLViewerMediaImpl::EMediaStatus status = LLViewerParcelMedia::getStatus();
			switch(status)
			{
			case LLViewerMediaImpl::MEDIA_NONE:
				media_show_pause = false;
				stop_media_enabled = false;
				break;
			case LLViewerMediaImpl::MEDIA_LOADING:
			case LLViewerMediaImpl::MEDIA_LOADED:
			case LLViewerMediaImpl::MEDIA_PLAYING:
				// HACK: only show the pause button for movie types
				media_show_pause = LLMIMETypes::widgetType(parcel->getMediaType()) == "movie" ? true : false;
				stop_media_enabled = true;
				play_media_enabled = false;
				break;
			case LLViewerMediaImpl::MEDIA_PAUSED:
				media_show_pause = false;
				stop_media_enabled = true;
				break;
			default:
				// inherit defaults above
				break;
			}
		}
	}
	
	if (gSavedSettings.getBOOL("AudioStreamingMusic") && gAudiop)
	{
		if ( parcel && !parcel->getMusicURL().empty())
		{
			play_music_enabled = true;
			music_icon_color = LLUI::sColorsGroup->getColor( "IconEnabledColor" );

			if (gOverlayBar->musicPlaying())
			{
				music_show_pause = true;
				stop_music_enabled = true;
			}
			else
			{
				music_show_pause = false;
				stop_music_enabled = false;
			}
		}
		// Don't test the mime-type: this is not updated in a consistent basis. The existence of a valid gAudiop is enough guarantee.
	}
	const std::string media_icon_name = LLMIMETypes::findIcon(media_type);
	LLButton* music_play_btn = getChild<LLButton>("music_play");
	LLButton* music_stop_btn = getChild<LLButton>("music_stop");
	LLButton* music_pause_btn = getChild<LLButton>("music_pause");
	LLButton* media_play_btn = getChild<LLButton>("media_play");
	LLButton* media_stop_btn = getChild<LLButton>("media_stop");
	LLButton* media_pause_btn = getChild<LLButton>("media_pause");
	LLIconCtrl* media_icon = getChild<LLIconCtrl>("media_icon");

	music_play_btn->setEnabled(play_music_enabled);
	music_stop_btn->setEnabled(stop_music_enabled);
	music_pause_btn->setEnabled(music_show_pause);
	music_pause_btn->setVisible(music_show_pause);
	music_play_btn->setVisible(! music_show_pause);

	if(music_show_pause)
	{
		LLStreamingAudioInterface *stream = gAudiop ? gAudiop->getStreamingAudioImpl() : NULL;
		if(stream && stream->getMetaData())
		{
			std::string info_text = "Loading...";
			const LLSD& metadata = *(stream->getMetaData());
			LLSD artist = metadata.get("ARTIST");
			LLSD title = metadata.get("TITLE");
			if(artist.isDefined() && title.isDefined())
				info_text = artist.asString() + " -- " + title.asString();
			else if(title.isDefined())
				info_text = std::string("Title: ") + title.asString();
			else if(artist.isDefined())
				info_text = std::string("Artist: ") + artist.asString();
			music_pause_btn->setToolTip(info_text);
		}
		else
			music_pause_btn->setToolTip(mCachedPauseTip);
	}

	childSetColor("music_icon", music_icon_color);
	if(!media_icon_name.empty())
	{
		media_icon->setImage(media_icon_name);
	}

	media_play_btn->setEnabled(play_media_enabled);
	media_stop_btn->setEnabled(stop_media_enabled);
	media_pause_btn->setEnabled(media_show_pause);
	media_pause_btn->setVisible(media_show_pause);
	media_play_btn->setVisible(! media_show_pause);
	childSetColor("media_icon", media_icon_color);

	setToolTip(media_url);
}
Ejemplo n.º 24
0
void PhoenixViewerLink::msdata(U32 status, std::string body)
{
	PhoenixViewerLink* self = getInstance();
	//cmdline_printchat("msdata downloaded");

	LLSD data;
	std::istringstream istr(body);
	LLSDSerialize::fromXML(data, istr);
	if(data.isDefined())
	{
		LLSD& support_agents = data["agents"];

		self->personnel.clear();
		for(LLSD::map_iterator itr = support_agents.beginMap(); itr != support_agents.endMap(); ++itr)
		{
			std::string key = (*itr).first;
			LLSD& content = (*itr).second;
			U8 val = 0;
			if(content.has("support"))val = val | EM_SUPPORT;
			if(content.has("developer"))val = val | EM_DEVELOPER;
			self->personnel[LLUUID(key)] = val;
		}

		LLSD& versions = data["versions"];

		self->versions2.clear();
		for(LLSD::map_iterator itr = versions.beginMap(); itr != versions.endMap(); ++itr)
		{
			std::string key = (*itr).first;
			key += "\n";
			LLSD& content = (*itr).second;
			U8 val = 0;
			if(content.has("beta"))val = val | PH_BETA;
			if(content.has("release"))val = val | PH_RELEASE;
			self->versions2[key] = val;
		}

		LLSD& blocked = data["blocked"];

		self->blocked_versions.clear();
		for (LLSD::array_iterator itr = blocked.beginArray(); itr != blocked.endArray(); ++itr)
		{
			std::string vers = (*itr).asString();
			self->blocked_versions.insert(vers);
		}

		if(data.has("MOTD"))
		{
			self->ms_motd = data["MOTD"].asString();
			gAgent.mMOTD = self->ms_motd;
		}else
		{
			self->ms_motd = "";
		}
		if(data.has("BlockedReason"))
		{
			blocked_login_info = data["BlockedReason"]; 
		}
		msDataDone=true;
	}

	//LLSD& dev_agents = data["dev_agents"];
	//LLSD& client_ids = data["client_ids"];
}
Ejemplo n.º 25
0
void LLSpellChecker::initHunspell(const std::string& dict_name)
{
	if (mHunspell)
	{
		delete mHunspell;
		mHunspell = NULL;
		mDictName.clear();
		mDictFile.clear();
		mIgnoreList.clear();
	}

	const LLSD dict_entry = (!dict_name.empty()) ? getDictionaryData(dict_name) : LLSD();
	if ( (!dict_entry.isDefined()) || (!dict_entry["installed"].asBoolean()) || (!dict_entry["is_primary"].asBoolean()))
	{
		sSettingsChangeSignal();
		return;
	}

	const std::string app_path = getDictionaryAppPath();
	const std::string user_path = getDictionaryUserPath();
	if (dict_entry.has("name"))
	{
		const std::string filename_aff = dict_entry["name"].asString() + ".aff";
		const std::string filename_dic = dict_entry["name"].asString() + ".dic";
		if ( (gDirUtilp->fileExists(user_path + filename_aff)) && (gDirUtilp->fileExists(user_path + filename_dic)) )
			mHunspell = new Hunspell((user_path + filename_aff).c_str(), (user_path + filename_dic).c_str());
		else if ( (gDirUtilp->fileExists(app_path + filename_aff)) && (gDirUtilp->fileExists(app_path + filename_dic)) )
			mHunspell = new Hunspell((app_path + filename_aff).c_str(), (app_path + filename_dic).c_str());
		if (!mHunspell)
			return;

		mDictName = dict_name;
		mDictFile = dict_entry["name"].asString();

		if (dict_entry["has_custom"].asBoolean())
		{
			const std::string filename_dic = user_path + mDictFile + DICT_CUSTOM_SUFFIX + ".dic";
			mHunspell->add_dic(filename_dic.c_str());
		}

		if (dict_entry["has_ignore"].asBoolean())
		{
			llifstream file_in(user_path + mDictFile + DICT_IGNORE_SUFFIX + ".dic", std::ios::in);
			if (file_in.is_open())
			{
				std::string word; int idxLine = 0;
				while (getline(file_in, word))
				{
					// Skip over the first line since that's just a line count
					if (0 != idxLine)
					{
						LLStringUtil::toLower(word);
						mIgnoreList.push_back(word);
					}
					idxLine++;
				}
			}
		}

		for (dict_list_t::const_iterator it = mDictSecondary.begin(); it != mDictSecondary.end(); ++it)
		{
			const LLSD dict_entry = getDictionaryData(*it);
			if ( (!dict_entry.isDefined()) || (!dict_entry["installed"].asBoolean()) )
				continue;

			const std::string filename_dic = dict_entry["name"].asString() + ".dic";
			if (gDirUtilp->fileExists(user_path + filename_dic))
				mHunspell->add_dic((user_path + filename_dic).c_str());
			else if (gDirUtilp->fileExists(app_path + filename_dic))
				mHunspell->add_dic((app_path + filename_dic).c_str());
		}
	}

	sSettingsChangeSignal();
}
std::string russ_format(const std::string& format_str, const LLSD& context)
{
	std::string service_url(format_str);
	if(!service_url.empty() && context.isMap())
	{
		// throw in a ridiculously large limiter to make sure we don't
		// loop forever with bad input.
		int iterations = 100;
		bool keep_looping = true;
		while(keep_looping)
		{
			if(0 == --iterations)
			{
				keep_looping = false;
			}

			int depth = 0;
			int deepest = 0;
			bool find_match = false;
			std::string::iterator iter(service_url.begin());
			std::string::iterator end(service_url.end());
			std::string::iterator deepest_node(service_url.end());
			std::string::iterator deepest_node_end(service_url.end());
			// parse out the variables to replace by going through {}s
			// one at a time, starting with the "deepest" in series
			// {{}}, and otherwise replacing right-to-left
			for(; iter != end; ++iter)
			{
				switch(*iter)
				{
				case '{':
					++depth;
					if(depth > deepest)
					{
						deepest = depth;
						deepest_node = iter;
						find_match = true;
					}
					break;
				case '}':
					--depth;
					if(find_match)
					{
						deepest_node_end = iter;
						find_match = false;
					}
					break;
				default:
					break;
				}
			}
			if((deepest_node == end) || (deepest_node_end == end))
			{
				break;
			}
			//replace the variable we found in the {} above.
			// *NOTE: since the c++ implementation only understands
			// params and straight string substitution, so it's a
			// known distance of 2 to skip the directive.
			std::string key(deepest_node + 2, deepest_node_end);
			LLSD value = context[key];
			switch(*(deepest_node + 1))
			{
			case '$':
				if(value.isDefined())
				{
					service_url.replace(
						deepest_node,
						deepest_node_end + 1,
						value.asString());
				}
				else
				{
					llwarns << "Unknown key: " << key << " in option map: "
						<< LLSDOStreamer<LLSDNotationFormatter>(context)
						<< llendl;
					keep_looping = false;
				}
				break;
			case '%':
				{
					std::string query_str = LLURI::mapToQueryString(value);
					service_url.replace(
						deepest_node,
						deepest_node_end + 1,
						query_str);
				}
				break;
			default:
				llinfos << "Unknown directive: " << *(deepest_node + 1)
					<< llendl;
				keep_looping = false;
				break;
			}
		}
	}
	if (service_url.find('{') != std::string::npos)
	{
		llwarns << "Constructed a likely bogus service URL: " << service_url
			<< llendl;
	}
	return service_url;
}
Ejemplo n.º 27
0
bool LLUpdaterServiceImpl::checkForInstall(bool launchInstaller)
{
	bool foundInstall = false; // return true if install is found.

	llifstream update_marker(update_marker_path(), 
							 std::ios::in | std::ios::binary);

	if(update_marker.is_open())
	{
		// Found an update info - now lets see if its valid.
		LLSD update_info;
		LLSDSerialize::fromXMLDocument(update_info, update_marker);
		update_marker.close();

		// Get the path to the installer file.
		LLSD path = update_info.get("path");
		if(update_info["current_version"].asString() != ll_get_version())
		{
			// This viewer is not the same version as the one that downloaded
			// the update.  Do not install this update.
			if(!path.asString().empty())
			{
				llinfos << "ignoring update dowloaded by different client version" << llendl;
				LLFile::remove(path.asString());
				LLFile::remove(update_marker_path());
			}
			else
			{
				; // Nothing to clean up.
			}
			
			foundInstall = false;
		} 
		else if(path.isDefined() && !path.asString().empty())
		{
			if(launchInstaller)
			{
				setState(LLUpdaterService::INSTALLING);
				
				LLFile::remove(update_marker_path());

				int result = ll_install_update(install_script_path(),
											   update_info["path"].asString(),
											   update_info["required"].asBoolean(),
											   install_script_mode());	
				
				if((result == 0) && mAppExitCallback)
				{
					mAppExitCallback();
				} else if(result != 0) {
					llwarns << "failed to run update install script" << LL_ENDL;
				} else {
					; // No op.
				}
			}
			
			foundInstall = true;
		}
	}
	return foundInstall;
}