void LLWLParamManager::savePreset(const std::string & name)
{
	// bugfix for SL-46920: preventing filenames that break stuff.
	char * curl_str = curl_escape(name.c_str(), name.size());
	std::string escaped_filename(curl_str);
	curl_free(curl_str);
	curl_str = NULL;

	escaped_filename += ".xml";

	// make an empty llsd
	LLSD paramsData(LLSD::emptyMap());
	std::string pathName(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", escaped_filename));

	// fill it with LLSD windlight params
	paramsData = mParamList[name].getAll();

	// write to file
	llofstream presetsXML(pathName);
	LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
	formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);
	presetsXML.close();

	propagateParameters();
	notifyObservers();
}
void LLWLParamManager::savePresets(const std::string & fileName)
{
	//Nobody currently calls me, but if they did, then its reasonable to write the data out to the user's folder
	//and not over the RO system wide version.

	LLSD paramsData(LLSD::emptyMap());
	
	std::string pathName(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight", fileName));

	for(std::map<std::string, LLWLParamSet>::iterator mIt = mParamList.begin();
		mIt != mParamList.end();
		++mIt) 
	{
		paramsData[mIt->first] = mIt->second.getAll();
	}

	llofstream presetsXML(pathName);

	LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();

	formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);

	presetsXML.close();

	propagateParameters();
}
示例#3
0
void LLWLParamManager::loadPreset(const std::string & name,bool propagate)
{
	
	// bugfix for SL-46920: preventing filenames that break stuff.
	char * curl_str = curl_escape(name.c_str(), name.size());
	std::string escaped_filename(curl_str);
	curl_free(curl_str);
	curl_str = NULL;

	escaped_filename += ".xml";

	std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", escaped_filename));
	LL_DEBUGS2("AppInit", "Shaders") << "Loading WindLight sky setting from " << pathName << LL_ENDL; 

	llifstream presetsXML;
	presetsXML.open(pathName.c_str());

	// That failed, try loading from the users area instead.
	if(!presetsXML)
	{
		pathName=gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", escaped_filename);
		LL_DEBUGS2("AppInit", "Shaders")<< "Loading User WindLight sky setting from "  << LL_ENDL; 
		presetsXML.open(pathName.c_str());
	}

	if (presetsXML)
	{
		LLSD paramsData(LLSD::emptyMap());

		LLPointer<LLSDParser> parser = new LLSDXMLParser();

		parser->parse(presetsXML, paramsData, LLSDSerialize::SIZE_UNLIMITED);

		std::map<std::string, LLWLParamSet>::iterator mIt = mParamList.find(name);
		if(mIt == mParamList.end())
		{
			addParamSet(name, paramsData);
		}
		else 
		{
			setParamSet(name, paramsData);
		}
		presetsXML.close();
	} 
	else 
	{
		llwarns << "Can't find " << name << llendl;
		return;
	}

	
	if(propagate)
	{
		getParamSet(name, mCurParams);
		propagateParameters();
	}

	notifyObservers();
}	
bool LLWLParamManager::savePresetToNotecard(const std::string & name)
{
	// make an empty llsd
	LLSD paramsData(LLSD::emptyMap());

	LLWLParamKey key(name, LLEnvKey::SCOPE_LOCAL);
	if(!hasParamSet(key)) return false;

	// fill it with LLSD windlight params
	paramsData = mParamList[key].getAll();

	// get some XML
	std::ostringstream presetsXML;
	LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
	formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);

	// Write it to a notecard
	LLNotecard notecard;
	notecard.setText(presetsXML.str());
 
	LLInventoryItem *item = gInventory.getItem(mParamList[key].mInventoryID);
	if(!item)
	{
		mParamList[key].mInventoryID = LLUUID::null;
		return false;
	}
	std::string agent_url = gAgent.getRegion()->getCapability("UpdateNotecardAgentInventory");
	if(!agent_url.empty())
	{
		LLTransactionID tid;
		LLAssetID asset_id;
		tid.generate();
		asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
		
		LLVFile file(gVFS, asset_id, LLAssetType::AT_NOTECARD, LLVFile::APPEND);
		
		std::ostringstream stream;
		notecard.exportStream(stream);
		std::string buffer = stream.str();
		
		S32 size = buffer.length() + 1;
		file.setMaxSize(size);
		file.write((U8*)buffer.c_str(), size);
		LLSD body;
		body["item_id"] = item->getUUID();
		LLHTTPClient::post(agent_url, body, new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD));
	}
	else
	{
		LL_WARNS("WindLight") << "Failed to save notecard." << LL_ENDL;
		return false;
	}
	
	return true;
}
void LLWaterParamManager::loadPreset(const std::string & name,bool propagate)
{
	// bugfix for SL-46920: preventing filenames that break stuff.
	std::string escaped_filename = LLWeb::curlEscape(name);

	escaped_filename += ".xml";

	std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", escaped_filename));
	llinfos << "Loading water settings from " << pathName << llendl;
	
	std::ifstream presetsXML;
	presetsXML.open(pathName.c_str());
	
	// That failed, try loading from the users area instead.
	if(!presetsXML)
	{
		pathName=gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", escaped_filename);
		llinfos << "Loading User water setting from " << pathName << llendl;
		presetsXML.open(pathName.c_str());
	}

	if (presetsXML)
	{
		LLSD paramsData(LLSD::emptyMap());

		LLPointer<LLSDParser> parser = new LLSDXMLParser();

		parser->parse(presetsXML, paramsData, LLSDSerialize::SIZE_UNLIMITED);

		std::map<std::string, LLWaterParamSet>::iterator mIt = mParamList.find(name);
		if(mIt == mParamList.end())
		{
			addParamSet(name, paramsData);
		}
		else 
		{
			setParamSet(name, paramsData);
		}
		presetsXML.close();
	} 
	else 
	{
		llwarns << "Can't find " << name << llendl;
		return;
	}

	if(propagate)
	{
		getParamSet(name, mCurParams);
		propagateParameters();
	}
}	
void LLWLParamManager::savePreset(LLWLParamKey key)
{
	llassert(key.scope == LLEnvKey::SCOPE_LOCAL && !key.name.empty());

	// make an empty llsd
	LLSD paramsData(LLSD::emptyMap());
	std::string pathName(getUserDir() + LLWeb::curlEscape(key.name) + ".xml");

	// fill it with LLSD windlight params
	paramsData = mParamList[key].getAll();

	// write to file
	llofstream presetsXML(pathName);
	LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
	formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);
	presetsXML.close();

	propagateParameters();
}
示例#7
0
void LLWaterParamManager::savePreset(const std::string & name)
{
	llassert(!name.empty());

	// make an empty llsd
	LLSD paramsData(LLSD::emptyMap());
	std::string pathName(getUserDir() + LLURI::escape(name) + ".xml");

	// fill it with LLSD windlight params
	paramsData = mParamList[name].getAll();

	// write to file
	llofstream presetsXML(pathName.c_str());
	LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
	formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);
	presetsXML.close();

	propagateParameters();
}
void AscentDayCycleManager::savePreset(const std::string & name)
{
	// bugfix for SL-46920: preventing filenames that break stuff.
	std::string escaped_filename = LLWeb::curlEscape(name);

	escaped_filename += ".xml";

	// make an empty llsd
	LLSD paramsData(LLSD::emptyMap());
	std::string pathName(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/days", escaped_filename));

	// fill it with LLSD windlight params
	//paramsData = mParamList[name].getAll();

	// write to file
	llofstream presetsXML(pathName);
	LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
	formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);
	presetsXML.close();
}
void LLWaterParamManager::savePreset(const std::string & name)
{
	std::string escaped_filename = LLCurl::escapeSafe(name);
	escaped_filename += ".xml";

	// make an empty llsd
	LLSD paramsData(LLSD::emptyMap());
	std::string pathName(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", escaped_filename));

	// fill it with LLSD windlight params
	paramsData = mParamList[name].getAll();

	// write to file
	llofstream presetsXML(pathName);
	LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
	formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);
	presetsXML.close();

	propagateParameters();
}
示例#10
0
void LLWLParamManager::savePresets(const std::string & fileName)
{
	LLSD paramsData(LLSD::emptyMap());
	
	std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", fileName));

	for(std::map<std::string, LLWLParamSet>::iterator mIt = mParamList.begin();
		mIt != mParamList.end();
		++mIt) 
	{
		paramsData[mIt->first] = mIt->second.getAll();
	}

	llofstream presetsXML(pathName);

	LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();

	formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);

	presetsXML.close();
}
示例#11
0
sctpErrorCode sctpCommand::processCommand(QIODevice *inDevice, QIODevice *outDevice)
{
    quint8 cmdCode = SCTP_CMD_UNKNOWN;
    quint8 cmdFlags = 0;
    quint32 cmdId = 0;
    quint32 cmdParamSize = 0;

    // read command header
    if (!waitAvailableBytes(inDevice, cmdHeaderSize()))
        return SCTP_ERROR_CMD_HEADER_READ_TIMEOUT;

    inDevice->read((char*)&cmdCode, sizeof(cmdCode));
    inDevice->read((char*)&cmdFlags, sizeof(cmdFlags));
    inDevice->read((char*)&cmdId, sizeof(cmdId));
    inDevice->read((char*)&cmdParamSize, sizeof(cmdParamSize));

    qDebug() << "command code: " << cmdCode << "; params size: " << cmdParamSize << "\n";

    // read params data
    QByteArray paramsData(cmdParamSize, 0);
    if (!waitAvailableBytes(inDevice, cmdParamSize))
        return SCTP_ERROR_CMD_PARAM_READ_TIMEOUT;

    inDevice->read((char*)paramsData.data(), paramsData.size());
    QDataStream paramsStream(paramsData);


    switch (cmdCode)
    {
    case SCTP_CMD_CHECK_ELEMENT:
        return processCheckElement(cmdFlags, cmdId, &paramsStream, outDevice);

    case SCTP_CMD_GET_ELEMENT_TYPE:
        return processGetElementType(cmdFlags, cmdId, &paramsStream, outDevice);

    case SCTP_CMD_ERASE_ELEMENT:
        return processElementErase(cmdFlags, cmdId, &paramsStream, outDevice);

    case SCTP_CMD_CREATE_NODE:
        return processCreateNode(cmdFlags, cmdId, &paramsStream, outDevice);

    case SCTP_CMD_CREAET_LINK:
        return processCreateLink(cmdFlags, cmdId, &paramsStream, outDevice);

    case SCTP_CMD_CREATE_ARC:
        return processCreateArc(cmdFlags, cmdId, &paramsStream, outDevice);

    case SCTP_CMD_GET_LINK_CONTENT:
        return processGetLinkContent(cmdFlags, cmdId, &paramsStream, outDevice);

    case SCTP_CMD_FIND_LINKS:
        return processFindLinks(cmdFlags, cmdId, &paramsStream, outDevice);


    case SCTP_CMD_FIND_ELEMENT_BY_SYSITDF:
        return processFindElementBySysIdtf(cmdFlags, cmdId, &paramsStream, outDevice);

    case SCTP_CMD_SHUTDOWN:
        QCoreApplication::quit();
        break;

    default:
        return SCTP_ERROR_UNKNOWN_CMD;
    }

    return SCTP_ERROR;
}
bool LLWLParamManager::loadPresetXML(const std::string& name, std::istream& preset_stream, bool propagate /* = false */, bool check_if_real /* = false */)
{
	LLSD paramsData(LLSD::emptyMap());
	
	LLPointer<LLSDParser> parser = new LLSDXMLParser();
	
	if(parser->parse(preset_stream, paramsData, LLSDSerialize::SIZE_UNLIMITED) == LLSDParser::PARSE_FAILURE)
	{
		return false;
	}
	
	if(check_if_real)
	{
		static const char* expected_windlight_settings[] = {
			"ambient",
			"blue_density",
			"blue_horizon",
			"cloud_color",
			"cloud_pos_density1",
			"cloud_pos_density2",
			"cloud_scale",
			"cloud_scroll_rate",
			"cloud_shadow",
			"density_multiplier",
			"distance_multiplier",
			"east_angle",
			"enable_cloud_scroll",
			"gamma",
			"glow",
			"haze_density",
			"haze_horizon",
			"lightnorm",
			"max_y",
			"star_brightness",
			"sun_angle",
			"sunlight_color"
		};
		static S32 expected_count = LL_ARRAY_SIZE(expected_windlight_settings);
		for(S32 i = 0; i < expected_count; ++i)
		{
			if(!paramsData.has(expected_windlight_settings[i]))
			{
				LL_WARNS("WindLight") << "Attempted to load WindLight param set without " << expected_windlight_settings[i] << LL_ENDL;
				return false;
			}
		}
	}
	
	std::map<std::string, LLWLParamSet>::iterator mIt = mParamList.find(name);
	if(mIt == mParamList.end())
	{
		addParamSet(name, paramsData);
	}
	else 
	{
		setParamSet(name, paramsData);
	}

	if(propagate)
	{
		getParamSet(name, mCurParams);
		propagateParameters();
	}
	return true;
}
示例#13
0
void LLWLParamManager::loadPresets(const std::string& file_name)
{
	// if fileName exists, use legacy loading form the big file, otherwise, search the sky 
	// directory, and add the list
	if(file_name != "") 
	{
		std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", file_name));
		LL_INFOS2("AppInit", "Shaders") << "Loading WindLight settings from " << path_name << LL_ENDL;

		llifstream presetsXML(path_name);
	
		if (presetsXML)
		{
			LLSD paramsData(LLSD::emptyMap());

			LLPointer<LLSDParser> parser = new LLSDXMLParser();

			parser->parse(presetsXML, paramsData, LLSDSerialize::SIZE_UNLIMITED);

			LLSD::map_const_iterator endParams = paramsData.endMap();
			for(LLSD::map_const_iterator curParams = paramsData.beginMap();
				curParams != endParams;
				++curParams)
			{
				addParamSet(curParams->first, curParams->second);
			}
		}
	}
	
	// otherwise, search the sky directory and find things there
	else
	{
		std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", ""));
		LL_INFOS2("AppInit", "Shaders") << "Loading WindLight settings from " << path_name << LL_ENDL;
	
		//mParamList.clear();
		
		bool found = true;			
		while(found) 
		{
			std::string name;
			found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false);

			LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL;
			
			// if we have one
			if(found) 
			{
				// bugfix for SL-46920: preventing filenames that break stuff.
				char * curl_str = curl_unescape(name.c_str(), name.size());
				std::string unescaped_name(curl_str);
				curl_free(curl_str);
				curl_str = NULL;

				// not much error checking here since we're getting rid of this
				std::string sky_name = unescaped_name.substr(0, unescaped_name.size() - 4);
			
				std::string cur_path(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", name));
				LL_DEBUGS2("AppInit", "Shaders") << "Loading sky from " << cur_path << LL_ENDL;
				
				llifstream sky_xml(cur_path);
				if (sky_xml)
				{
					LLSD sky_data(LLSD::emptyMap());
					LLPointer<LLSDParser> parser = new LLSDXMLParser();
					parser->parse(sky_xml, sky_data, LLSDSerialize::SIZE_UNLIMITED);

					addParamSet(sky_name, sky_data);
					sky_xml.close();
				}
			}
		}
	}
}