Example #1
0
std::string LLURI::mapToQueryString(const LLSD& queryMap)
{
	std::string query_string;
	if (queryMap.isMap())
	{
		bool first_element = true;
		LLSD::map_const_iterator iter = queryMap.beginMap();
		LLSD::map_const_iterator end = queryMap.endMap();
		std::ostringstream ostr;
		for (; iter != end; ++iter)
		{
			if(first_element)
			{
				ostr << "?";
				first_element = false;
			}
			else
			{
				ostr << "&";
			}
			ostr << escapeQueryVariable(iter->first);
			if(iter->second.isDefined())
			{
				ostr << "=" <<  escapeQueryValue(iter->second.asString());
			}
		}
		query_string = ostr.str();
	}
	return query_string;
}
void LLIMFloater::processAgentListUpdates(const LLSD& body)
{
	if ( !body.isMap() ) return;

	if ( body.has("agent_updates") && body["agent_updates"].isMap() )
	{
		LLSD agent_data = body["agent_updates"].get(gAgentID.asString());
		if (agent_data.isMap() && agent_data.has("info"))
		{
			LLSD agent_info = agent_data["info"];

			if (agent_info.has("mutes"))
			{
				BOOL moderator_muted_text = agent_info["mutes"]["text"].asBoolean(); 
				mInputEditor->setEnabled(!moderator_muted_text);
				std::string label;
				if (moderator_muted_text)
					label = LLTrans::getString("IM_muted_text_label");
				else
					label = LLTrans::getString("IM_to_label") + " " + LLIMModel::instance().getName(mSessionID);
				mInputEditor->setLabel(label);

				if (moderator_muted_text)
					LLNotificationsUtil::add("TextChatIsMutedByModerator");
			}
		}
	}
}
    void deserializeKeyboardData( LLSD native_key_data, uint32_t& native_scan_code, uint32_t& native_virtual_key, uint32_t& native_modifiers )
    {
        native_scan_code = 0;
        native_virtual_key = 0;
        native_modifiers = 0;

        if( native_key_data.isMap() )
        {
#if LL_DARWIN
            native_scan_code = (uint32_t)(native_key_data["char_code"].asInteger());
            native_virtual_key = (uint32_t)(native_key_data["key_code"].asInteger());
            native_modifiers = (uint32_t)(native_key_data["modifiers"].asInteger());
#elif LL_WINDOWS
            native_scan_code = (uint32_t)(native_key_data["scan_code"].asInteger());
            native_virtual_key = (uint32_t)(native_key_data["virtual_key"].asInteger());
            // TODO: I don't think we need to do anything with native modifiers here -- please verify
#elif LL_LINUX
            native_scan_code = (uint32_t)(native_key_data["scan_code"].asInteger());
            native_virtual_key = (uint32_t)(native_key_data["virtual_key"].asInteger());
            native_modifiers = (uint32_t)(native_key_data["modifiers"].asInteger());
#else
            // Add other platforms here as needed
#endif
        };
    };
Example #4
0
//static
std::string LLNotification::format(const std::string& s, const LLSD& substitutions)
{
	if (!substitutions.isMap()) 
	{
		return s;
	}

	std::ostringstream output;
	// match strings like [NAME]
	const boost::regex key("\\[([0-9_A-Z]+)]");
	
	std::string::const_iterator start = s.begin();
	std::string::const_iterator end = s.end();
	boost::smatch match;
	
	while (boost::regex_search(start, end, match, key, boost::match_default))
	{
		bool found_replacement = false;
		std::string replacement;
		
		// see if we have a replacement for the bracketed string (without the brackets)
		// test first using has() because if we just look up with operator[] we get back an
		// empty string even if the value is missing. We want to distinguish between 
		// missing replacements and deliberately empty replacement strings.
		if (substitutions.has(std::string(match[1].first, match[1].second)))
		{
			replacement = substitutions[std::string(match[1].first, match[1].second)].asString();
			found_replacement = true;
		}
		// if not, see if there's one WITH brackets
		else if (substitutions.has(std::string(match[0].first, match[0].second)))
		{
			replacement = substitutions[std::string(match[0].first, match[0].second)].asString();
			found_replacement = true;
		}
		
		if (found_replacement)
		{
			// found a replacement
			// "hello world" is output
			output << std::string(start, match[0].first) << replacement;
		}
		else
		{
			// we had no replacement, so leave the string we searched for so that it gets noticed by QA
			// "hello [NAME_NOT_FOUND]" is output
			output << std::string(start, match[0].second);
		}
		
		// update search position 
		start = match[0].second; 
	}
	// send the remainder of the string (with no further matches for bracketed names)
	output << std::string(start, end);
	return output.str();
}
bool LLWaterParamManager::setParamSet(const std::string& name, const LLSD & param)
{
	// quick, non robust (we won't be working with files, but assets) check
	if(!param.isMap()) 
	{
		return false;
	}
	
	mParamList[name].setAll(param);

	return true;
}
Example #6
0
void LLMultiSlider::setValue(const LLSD& value)
{
    // only do if it's a map
    if(value.isMap()) {

        // add each value... the first in the map becomes the current
        LLSD::map_const_iterator mIt = value.beginMap();
        mCurSlider = mIt->first;

        for(; mIt != value.endMap(); mIt++) {
            setSliderValue(mIt->first, (F32)mIt->second.asReal(), TRUE);
        }
    }
}
void LLPanelLogin::setLoginHistory(LLSavedLogins const& login_history)
{
	sInstance->mLoginHistoryData = login_history;

	LLComboBox* login_combo = sInstance->getChild<LLComboBox>("name_combo");
	llassert(login_combo);
	login_combo->clear();

	LLSavedLoginsList const& saved_login_entries(login_history.getEntries());
	for (LLSavedLoginsList::const_reverse_iterator i = saved_login_entries.rbegin();
	     i != saved_login_entries.rend(); ++i)
	{
		LLSD e = i->asLLSD();
		if (e.isMap() && gHippoGridManager->getGrid(i->getGrid()))
			login_combo->add(getDisplayString(*i), e);
	}
}
Example #8
0
void LLIMSpeakerMgr::setSpeakers(const LLSD& speakers)
{
	if ( !speakers.isMap() ) return;

	if ( speakers.has("agent_info") && speakers["agent_info"].isMap() )
	{
		LLSD::map_const_iterator speaker_it;
		for(speaker_it = speakers["agent_info"].beginMap();
			speaker_it != speakers["agent_info"].endMap();
			++speaker_it)
		{
			LLUUID agent_id(speaker_it->first);

			LLPointer<LLSpeaker> speakerp = setSpeaker(
				agent_id,
				"",
				LLSpeaker::STATUS_TEXT_ONLY);

			if ( speaker_it->second.isMap() )
			{
				speakerp->mIsModerator = speaker_it->second["is_moderator"];
				speakerp->mModeratorMutedText =
					speaker_it->second["mutes"]["text"];
			}
		}
	}
	else if ( speakers.has("agents" ) && speakers["agents"].isArray() )
	{
		//older, more decprecated way.  Need here for
		//using older version of servers
		LLSD::array_const_iterator speaker_it;
		for(speaker_it = speakers["agents"].beginArray();
			speaker_it != speakers["agents"].endArray();
			++speaker_it)
		{
			const LLUUID agent_id = (*speaker_it).asUUID();

			LLPointer<LLSpeaker> speakerp = setSpeaker(
				agent_id,
				"",
				LLSpeaker::STATUS_TEXT_ONLY);
		}
	}
}
void LLServiceBuilder::createServiceDefinition(
	const std::string& service_name,
	LLSD& service_llsd)
{
	if(service_llsd.isString())
	{
		mServiceMap[ service_name ] = service_llsd.asString();
	}			
	else if(service_llsd.isMap())
	{
		for(LLSD::map_iterator map_itr = service_llsd.beginMap();
			map_itr != service_llsd.endMap();
			++map_itr)
		{
			std::string compound_builder_name = service_name;
			compound_builder_name.append("-");
			compound_builder_name.append((*map_itr).first);
			mServiceMap[ compound_builder_name ] = (*map_itr).second.asString();
		}
	}
}
Example #10
0
	/*virtual*/ void post(
		LLHTTPNode::ResponsePtr response,
		const LLSD& context,
		const LLSD& input) const
	{
		if (!input || !context || !input.isMap() || !input.has("body")) {
			LL_INFOS() << "malformed WindLightRefresh!" << LL_ENDL;	 
			return;
		}

		//std::string dump = input["body"].asString();
		//LL_WARNS() << dump << LL_ENDL;

		LLSD body = input["body"];
		LLEnvManagerNew *env = &LLEnvManagerNew::instance();

		LLViewerRegion* regionp = gAgent.getRegion();
		LLUUID region_uuid = regionp ? regionp->getRegionID() : LLUUID::null;

		env->mNewRegionPrefs.clear();
		env->mCurRegionUUID = region_uuid;

		if(body.has("Interpolate")) {
			if(body["Interpolate"].asInteger() == 1) {
				env->mInterpNextChangeMessage = true;
			}
			else {
				env->mInterpNextChangeMessage = false;
			}
		}
		else {
			env->mInterpNextChangeMessage = true;
		}
		LL_INFOS() << "Windlight Refresh , interpolate:" << env->mInterpNextChangeMessage << LL_ENDL;
		env->requestRegionSettings();

		// Ansa: This cause the windlight editor and others to update since the windlight has changed!
		gAgent.changeRegion();
	}
Example #11
0
void LLAvatarListItem::setValue( const LLSD& value )
{
    if (!value.isMap()) return;;
    if (!value.has("selected")) return;
    getChildView("selected_icon")->setVisible( value["selected"]);
}
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;
}
Example #13
0
static void request(
	const std::string& url,
	LLURLRequest::ERequestAction method,
	Injector* body_injector,
	LLCurl::ResponderPtr responder,
	const F32 timeout = HTTP_REQUEST_EXPIRY_SECS,
	const LLSD& headers = LLSD())
{
	if (!LLHTTPClient::hasPump())
	{
		responder->completed(U32_MAX, "No pump", LLSD());
		return;
	}
	LLPumpIO::chain_t chain;

	LLURLRequest* req = new LLURLRequest(method, url);
	req->checkRootCertificate(true);

    // Insert custom headers is the caller sent any
    if (headers.isMap())
    {
        LLSD::map_const_iterator iter = headers.beginMap();
        LLSD::map_const_iterator end  = headers.endMap();

        for (; iter != end; ++iter)
        {
            std::ostringstream header;
            //if the header is "Pragma" with no value
            //the caller intends to force libcurl to drop
            //the Pragma header it so gratuitously inserts
            //Before inserting the header, force libcurl
            //to not use the proxy (read: llurlrequest.cpp)
			static const std::string PRAGMA("Pragma");
			if ((iter->first == PRAGMA) && (iter->second.asString().empty()))
            {
                req->useProxy(false);
            }
            header << iter->first << ": " << iter->second.asString() ;
            lldebugs << "header = " << header.str() << llendl;
            req->addHeader(header.str().c_str());
        }
    }

	// Check to see if we have already set Accept or not. If no one
	// set it, set it to application/llsd+xml since that's what we
	// almost always want.
	if( method != LLURLRequest::HTTP_PUT && method != LLURLRequest::HTTP_POST )
	{
		static const std::string ACCEPT("Accept");
		if(!headers.has(ACCEPT))
		{
			req->addHeader("Accept: application/llsd+xml");
		}
	}

	req->setCallback(new LLHTTPClientURLAdaptor(responder));

	if (method == LLURLRequest::HTTP_POST  &&  gMessageSystem)
	{
		req->addHeader(llformat("X-SecondLife-UDP-Listen-Port: %d",
								gMessageSystem->mPort).c_str());
   	}

	if (method == LLURLRequest::HTTP_PUT || method == LLURLRequest::HTTP_POST)
	{
		static const std::string CONTENT_TYPE("Content-Type");
		if(!headers.has(CONTENT_TYPE))
		{
			// If the Content-Type header was passed in, it has
			// already been added as a header through req->addHeader
			// in the loop above. We defer to the caller's wisdom, but
			// if they did not specify a Content-Type, then ask the
			// injector.
			req->addHeader(
				llformat(
					"Content-Type: %s",
					body_injector->contentType()).c_str());
		}
   		chain.push_back(LLIOPipe::ptr_t(body_injector));
	}

	chain.push_back(LLIOPipe::ptr_t(req));

	theClientPump->addChain(chain, timeout);
}
Example #14
0
void LLIMSpeakerMgr::updateSpeakers(const LLSD& update)
{
	if ( !update.isMap() ) return;

	if ( update.has("agent_updates") && update["agent_updates"].isMap() )
	{
		LLSD::map_const_iterator update_it;
		for(
			update_it = update["agent_updates"].beginMap();
			update_it != update["agent_updates"].endMap();
			++update_it)
		{
			LLUUID agent_id(update_it->first);
			LLPointer<LLSpeaker> speakerp = findSpeaker(agent_id);

			LLSD agent_data = update_it->second;

			if (agent_data.isMap() && agent_data.has("transition"))
			{
				if (agent_data["transition"].asString() == "LEAVE" && speakerp.notNull())
				{
					speakerp->mStatus = LLSpeaker::STATUS_NOT_IN_CHANNEL;
					speakerp->mDotColor = INACTIVE_COLOR;
					speakerp->mActivityTimer.resetWithExpiry(SPEAKER_TIMEOUT);
				}
				else if (agent_data["transition"].asString() == "ENTER")
				{
					// add or update speaker
					speakerp = setSpeaker(agent_id);
				}
				else
				{
					llwarns << "bad membership list update " << ll_print_sd(agent_data["transition"]) << llendl;
				}
			}

			if (speakerp.isNull()) continue;

			// should have a valid speaker from this point on
			if (agent_data.isMap() && agent_data.has("info"))
			{
				LLSD agent_info = agent_data["info"];

				if (agent_info.has("is_moderator"))
				{
					speakerp->mIsModerator = agent_info["is_moderator"];
				}

				if (agent_info.has("mutes"))
				{
					speakerp->mModeratorMutedText = agent_info["mutes"]["text"];
				}
			}
		}
	}
	else if ( update.has("updates") && update["updates"].isMap() )
	{
		LLSD::map_const_iterator update_it;
		for (
			update_it = update["updates"].beginMap();
			update_it != update["updates"].endMap();
			++update_it)
		{
			LLUUID agent_id(update_it->first);
			LLPointer<LLSpeaker> speakerp = findSpeaker(agent_id);

			std::string agent_transition = update_it->second.asString();
			if (agent_transition == "LEAVE" && speakerp.notNull())
			{
				speakerp->mStatus = LLSpeaker::STATUS_NOT_IN_CHANNEL;
				speakerp->mDotColor = INACTIVE_COLOR;
				speakerp->mActivityTimer.resetWithExpiry(SPEAKER_TIMEOUT);
			}
			else if ( agent_transition == "ENTER")
			{
				// add or update speaker
				speakerp = setSpeaker(agent_id);
			}
			else
			{
				llwarns << "bad membership list update "
						<< agent_transition << llendl;
			}
		}
	}
}