Example #1
0
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");
}
	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;
	}
Example #3
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;
}
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();
		}*/
	}
}
Example #5
0
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);
}
Example #6
0
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);
}
	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;
	}
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;
}
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);
}