예제 #1
0
파일: llinventory.cpp 프로젝트: Kiera/Crow
LLXMLNode *LLInventoryItem::exportFileXML(BOOL include_asset_key) const
{
	LLMemType m1(LLMemType::MTYPE_INVENTORY);
	LLXMLNode *ret = new LLXMLNode("item", FALSE);

	ret->createChild("uuid", TRUE)->setUUIDValue(1, &mUUID);
	ret->createChild("parent_uuid", TRUE)->setUUIDValue(1, &mParentUUID);

	mPermissions.exportFileXML()->setParent(ret);

	// Check for permissions to see the asset id, and if so write it
	// out as an asset id. Otherwise, apply our cheesy encryption.
	if(include_asset_key)
	{
		U32 mask = mPermissions.getMaskBase();
		if(((mask & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED)
		   || (mAssetUUID.isNull()))
		{
			ret->createChild("asset_id", FALSE)->setUUIDValue(1, &mAssetUUID);
		}
		else
		{
			LLUUID shadow_id(mAssetUUID);
			LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES);
			cipher.encrypt(shadow_id.mData, UUID_BYTES);

			ret->createChild("shadow_id", FALSE)->setUUIDValue(1, &shadow_id);
		}
	}

	std::string type_str = LLAssetType::lookup(mType);
	std::string inv_type_str = LLInventoryType::lookup(mInventoryType);

	ret->createChild("asset_type", FALSE)->setStringValue(type_str);
	ret->createChild("inventory_type", FALSE)->setStringValue(inv_type_str);
	S32 tmp_flags = (S32) mFlags;
	ret->createChild("flags", FALSE)->setByteValue(4, (U8*)(&tmp_flags), LLXMLNode::ENCODING_HEX);

	mSaleInfo.exportFileXML()->setParent(ret);

	std::string temp;
	temp.assign(mName);
	ret->createChild("name", FALSE)->setStringValue(temp);
	temp.assign(mDescription);
	ret->createChild("description", FALSE)->setStringValue(temp);
	S32 date = mCreationDate;
	ret->createChild("creation_date", FALSE)->setIntValue(1, &date);

	return ret;
}
예제 #2
0
// Checked: 2010-03-09 (RLVa-1.2.0a) | Added: RLVa-1.1.0h
void RlvStrings::initClass()
{
	static bool fInitialized = false;
	if (!fInitialized)
	{
		LLXMLNodePtr xmlRoot;
		if ( (!LLUICtrlFactory::getLayeredXMLNode("rlva_strings.xml", xmlRoot)) || (xmlRoot.isNull()) || (!xmlRoot->hasName("rlva_strings")) )
		{
			RLV_ERRS << "Problem reading RLVa string XML file" << RLV_ENDL;
			return;
		}

		for (LLXMLNode* pNode = xmlRoot->getFirstChild(); pNode != NULL; pNode = pNode->getNextSibling())
		{
			if (pNode->hasName("strings"))
			{
				std::string strName;
				for (LLXMLNode* pStringNode = pNode->getFirstChild(); pStringNode != NULL; pStringNode = pStringNode->getNextSibling())
				{
					if ( (!pStringNode->hasName("string")) || (!pStringNode->getAttributeString("name", strName)) )
						continue;
					m_StringMap[strName] = pStringNode->getTextContents();
				}
			}
			else if (pNode->hasName("anonyms"))
			{
				for (LLXMLNode* pAnonymNode = pNode->getFirstChild(); pAnonymNode != NULL; pAnonymNode = pAnonymNode->getNextSibling())
				{
					if (!pAnonymNode->hasName("anonym"))
						continue;
					m_Anonyms.push_back(pAnonymNode->getTextContents());
				}
			}
			#ifdef RLV_EXTENSION_NOTIFY_BEHAVIOUR
			else if (pNode->hasName("behaviour-notifications"))
			{
				std::string strBhvr, strType; ERlvBehaviour eBhvr;
				for (LLXMLNode* pNotifyNode = pNode->getFirstChild(); pNotifyNode != NULL; pNotifyNode = pNotifyNode->getNextSibling())
				{
					if ( (!pNotifyNode->hasName("notification")) || (!pNotifyNode->getAttributeString("type", strType)) ||
						 (!pNotifyNode->getAttributeString("behaviour", strBhvr)) || 
						 ((eBhvr = RlvCommand::getBehaviourFromString(strBhvr)) == RLV_BHVR_UNKNOWN) )
					{
						continue;
					}
					if ("add" == strType)
						m_BhvrAddMap.insert(std::pair<ERlvBehaviour, std::string>(eBhvr, pNotifyNode->getTextContents()));
					else if ("rem" == strType)
						m_BhvrRemMap.insert(std::pair<ERlvBehaviour, std::string>(eBhvr, pNotifyNode->getTextContents()));
				}
			}
			#endif // RLV_EXTENSION_NOTIFY_BEHAVIOUR
		}

		if ( (m_StringMap.empty()) || (m_Anonyms.empty()) )
		{
			RLV_ERRS << "Problem parsing RLVa string XML file" << RLV_ENDL;
			return;
		}

		fInitialized = true;
	}
}
예제 #3
0
//static
bool LLAlertDialog::parseAlerts(const LLString& xml_filename, LLControlGroup* settings, BOOL settings_only)
{
	LLXMLNodePtr root;
	BOOL success  = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root);

	if (!success || root.isNull() || !root->hasName( "alerts" ))
	{
		llerrs << "Problem reading UI Alerts file: " << xml_filename << llendl;
		return false;
	}

	BOOL add_settings = FALSE;
	if (settings)
	{
		sSettings = settings;
		add_settings = TRUE;
	}
	llassert(sSettings);
	
	for (LLXMLNode* alert = root->getFirstChild();
		 alert != NULL; alert = alert->getNextSibling())
	{
		if (alert->hasName("global"))
		{
			LLString global_name;
			if (alert->getAttributeString("name", global_name))
			{
				if (global_name == "skipnexttime")
				{
					sStringSkipNextTime = alert->getTextContents();
				}
				else if (global_name == "alwayschoose")
				{
					sStringAlwaysChoose = alert->getTextContents();
				}
			}
			continue;
		}

		if (!alert->hasName("alert"))
		{
			continue;
		}
		
		LLAlertDialogTemplate* xml_template = settings_only ? NULL : new LLAlertDialogTemplate;

		// name=
		LLString alert_name;
		if (alert->getAttributeString("name", alert_name))
		{
			if (xml_template)
			{
				xml_template->mLabel = alert_name;
			}
		}
		else
		{
			llwarns << "Unable to parse alert with no name" << llendl;
			delete xml_template;
			continue;
		}
		// title=
		LLString title;
		if (alert->getAttributeString("title", title))
		{
			if (xml_template)
			{
				xml_template->mTitle = title;
			}
		}
		// modal=
		BOOL modal;
		if (alert->getAttributeBOOL("modal", modal))
		{
			if (xml_template)
			{
				xml_template->mModal = modal;
			}
		}
		// caution=
		BOOL caution;
		if (alert->getAttributeBOOL("caution", caution))
		{
			if (xml_template)
			{
				xml_template->mCaution = caution;
			}
		}
		// unique=
		BOOL unique;
		if (alert->getAttributeBOOL("unique", unique))
		{
			if (xml_template)
			{
				xml_template->mUnique = unique;
			}
		}
				
		S32 default_option = 0;
		BOOL nodefault;
		if (alert->getAttributeBOOL("nodefault", nodefault))
		{
			if (nodefault)
			{
				if (xml_template)
				{
					xml_template->mDefaultOption = -1;
				}
				default_option = -1;
			}
		}

		S32 btn_idx = 0;
		for (LLXMLNode* child = alert->getFirstChild();
			 child != NULL; child = child->getNextSibling())
		{
			// <message>
			if (child->hasName("message"))
			{
				if (xml_template)
				{
					xml_template->mMessage = child->getTextContents();
				}
			}

			// <option>
			if (child->hasName("option"))
			{
				LLString label = child->getTextContents();
				BOOL is_default = FALSE;
				child->getAttributeBOOL("default", is_default);
				LLString ignore_text;
				if (!child->getAttributeString("ignore", ignore_text))
				{
					ignore_text = label;
				}
				if (xml_template)
				{
					xml_template->addOption(label, ignore_text, is_default);
				}
				if (is_default)
				{
					default_option = btn_idx;
				}
				btn_idx++;
			}
		
			// <editline>
			if (child->hasName("editline"))
			{
				if (xml_template)
				{
					xml_template->mEditLineText = child->getTextContents();
					if (xml_template->mEditLineText.empty())
					{
						xml_template->mEditLineText = " ";
					}
				}
			}
			
			// <ignore>
			if (child->hasName("ignore"))
			{
				LLString ignore_text = child->getTextContents();
				// label=
				LLString name;
				child->getAttributeString("name", name);
				
				//always set to alert_name for the sake of i18n
				//if (name.empty())
				name = alert_name;
				
				if (xml_template)
				{
					xml_template->mIgnorable = LLAlertDialog::IGNORE_USE_DEFAULT;
					xml_template->mIgnoreListText = ignore_text;
					xml_template->mIgnoreLabel = name;
				}
				if (!ignore_text.empty())
				{
					if (add_settings)
					{
						settings->addWarning(name);
					}
					if (xml_template)
					{
						sIgnorableTemplates[name] = xml_template; // will override any previous entry
					}
				}
				// save_option=
				BOOL save_option = FALSE;
				child->getAttributeBOOL("save_option", save_option);
				if (save_option)
				{
					if (xml_template)
					{
						xml_template->mIgnorable = LLAlertDialog::IGNORE_USE_SAVED;
					}
					if (add_settings)
					{
						settings->declareS32("Default" + name, default_option, "Default option number for this alert dialog");
					}
				}
			}

			// <url>
			if (child->hasName("url"))
			{
				S32 url_option = 0;
				child->getAttributeS32("option", url_option);
				if (xml_template)
				{
					xml_template->mURL = child->getTextContents();
					xml_template->mURLOption = url_option;
				}
			}
			
		}
		if (xml_template)
		{
			xml_template->mDefaultOption = default_option;
			sAlertTemplates[xml_template->mLabel] = xml_template;
		}
	}
	return true;
}
예제 #4
0
파일: llnotify.cpp 프로젝트: Boy/rainbow
//static
bool LLNotifyBox::parseNotify(const std::string& xml_filename)
{
	LLXMLNodePtr root;

	BOOL success  = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root);

	if (!success || root.isNull() || !root->hasName( "notifications" ))
	{
		llerrs << "Problem reading UI Notify file: " << xml_filename << llendl;
		return false;
	}

	for (LLXMLNode* notify = root->getFirstChild();
		 notify != NULL; notify = notify->getNextSibling())
	{
		if (!notify->hasName("notify"))
		{
			continue;
		}

		BOOL unique = FALSE;
		notify->getAttributeBOOL("unique", unique);

		F32 duration = gSavedSettings.getF32("NotifyTipDuration");
		notify->getAttributeF32("duration", duration);
		
		LLPointer<LLNotifyBoxTemplate> xml_template = new LLNotifyBoxTemplate(unique, duration);

		// label=
		std::string notify_name;
		if (notify->getAttributeString("name", notify_name))
		{
			xml_template->mLabel = notify_name;
		}
		else
		{
			llwarns << "Unable to parse notify with no name" << llendl;
			continue;
		}
		// modal=
		BOOL tip;
		if (notify->getAttributeBOOL("tip", tip))
		{
			xml_template->mIsTip = tip;
		}

		// parse a bool attribute named "caution" to determine
		// whether this notification gets cautionary special handling
		BOOL caution = FALSE;
		if (notify->getAttributeBOOL("caution", caution))
		{
			if (xml_template)
			{
				xml_template->mIsCaution = caution;
			}
		}
		
				
		S32 btn_idx = 0;
		for (LLXMLNode* child = notify->getFirstChild();
			 child != NULL; child = child->getNextSibling())
		{
			// <message>
			if (child->hasName("message"))
			{
				xml_template->mMessage = child->getTextContents();
			}

			// <option>
			if (child->hasName("option"))
			{
				std::string label = child->getValue();
				BOOL is_default = FALSE;
				child->getAttributeBOOL("default", is_default);
				std::string ignore_text;
				if (!child->getAttributeString("ignore", ignore_text))
				{
					ignore_text = label;
				}
				xml_template->addOption(label, is_default);
				btn_idx++;
			}
		}

		//*TODO:translate
		if (xml_template->mOptions.empty())
		{
			xml_template->addOption("OK", FALSE);
		}
		sNotifyTemplates[xml_template->mLabel] = xml_template;
	}
	return true;
}
예제 #5
0
// <AW opensim>
void LLGridManager::gridInfoResponderCB(GridEntry* grid_entry)
{
	for (LLXMLNode* node = grid_entry->info_root->getFirstChild(); node != NULL; node = node->getNextSibling())
	{
		std::string check;
		check = "login";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_LOGIN_URI_VALUE] = LLSD::emptyArray();
			grid_entry->grid[GRID_LOGIN_URI_VALUE].append(node->getTextContents());
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_LOGIN_URI_VALUE] << LL_ENDL;
			continue;
		}
		check = "gridname";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_LABEL_VALUE] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_LABEL_VALUE] << LL_ENDL;
			continue;
		}
		check = "gridnick";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_NICK_VALUE] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_NICK_VALUE] << LL_ENDL;
			continue;
		}
		check = "welcome";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_LOGIN_PAGE_VALUE] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_LOGIN_PAGE_VALUE] << LL_ENDL;
			continue;
		}
		check = GRID_REGISTER_NEW_ACCOUNT;
		if (node->hasName(check))
		{
			grid_entry->grid[check] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[check] << LL_ENDL;
			continue;
		}
		check = GRID_FORGOT_PASSWORD;
		if (node->hasName(check))
		{
			grid_entry->grid[check] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[check] << LL_ENDL;
			continue;
		}
		check = "help";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_HELP] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_HELP] << LL_ENDL;
			continue;
		}
		check = "about";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_ABOUT] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_ABOUT] << LL_ENDL;
			continue;
		}
		check = "search";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_SEARCH] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_SEARCH] << LL_ENDL;
			continue;
		}
		check = "SendGridInfoToViewerOnLogin";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_SENDGRIDINFO] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_SENDGRIDINFO] << LL_ENDL;
			continue;
		}
		check = "DirectoryFee";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_DIRECTORY_FEE] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_DIRECTORY_FEE] << LL_ENDL;
			continue;
		}
		check = "CurrencySymbol";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_CURRENCY_SYMBOL] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_CURRENCY_SYMBOL] << LL_ENDL;
			continue;
		}
		check = "RealCurrencySymbol";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_REAL_CURRENCY_SYMBOL] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_REAL_CURRENCY_SYMBOL] << LL_ENDL;
			continue;
		}
		check = "MaxGroups";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_MAXGROUPS] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_MAXGROUPS] << LL_ENDL;
			continue;
		}
		check = "platform";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_PLATFORM] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_PLATFORM] << LL_ENDL;
			continue;
		}
		check = "message";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_MESSAGE] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_MESSAGE] << LL_ENDL;
			continue;
		}
		check = "helperuri";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_HELPER_URI_VALUE] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_HELPER_URI_VALUE] << LL_ENDL;
			//don't continue, also check the next
		}
		check = "economy";
		if (node->hasName(check))
		{	//sic! economy and helperuri is 2 names for the same
			grid_entry->grid[GRID_HELPER_URI_VALUE] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_HELPER_URI_VALUE] << LL_ENDL;
		}
	}


	std::string grid = grid_entry->grid[GRID_VALUE].asString();
	std::string slurl_base(llformat(DEFAULT_HOP_BASE, grid.c_str())); // <AW: hop:// protocol>
	grid_entry->grid[GRID_SLURL_BASE]= slurl_base;

	LLDate now = LLDate::now();
	grid_entry->grid["LastModified"] = now;

	addGrid(grid_entry, FINISH);
}