//free the storage for the droid templates bool droidTemplateShutDown() { for (int player = 0; player < MAX_PLAYERS; player++) { clearTemplates(player); } localTemplates.clear(); return true; }
bool LLNotificationTemplates::loadTemplates() { LL_INFOS() << "Reading notifications template" << LL_ENDL; // Passing findSkinnedFilenames(constraint=LLDir::ALL_SKINS) makes it // output all relevant pathnames instead of just the ones from the most // specific skin. std::vector<std::string> search_paths = gDirUtilp->findSkinnedFilenames(LLDir::XUI, "notifications.xml", LLDir::ALL_SKINS); std::string base_filename = search_paths.front(); LLXMLNodePtr root; BOOL success = LLXMLNode::getLayeredXMLNode(root, search_paths); if (!success || root.isNull() || !root->hasName( "notifications" )) { LL_ERRS() << "Problem reading XML from UI Notifications file: " << base_filename << LL_ENDL; return false; } clearTemplates(); for (LLXMLNodePtr item = root->getFirstChild(); item.notNull(); item = item->getNextSibling()) { if (item->hasName("global")) { std::string global_name; if (item->getAttributeString("name", global_name)) { mGlobalStrings[global_name] = item->getTextContents(); } continue; } if (item->hasName("template")) { // store an xml template; templates must have a single node (can contain // other nodes) std::string name; item->getAttributeString("name", name); LLXMLNodePtr ptr = item->getFirstChild(); mXmlTemplates[name] = ptr; continue; } if (!item->hasName("notification")) { LL_WARNS() << "Unexpected entity " << item->getName()->mString << " found in notifications.xml [language=]" << LLUI::getLanguage() << LL_ENDL; continue; } } return true; }
bool LLNotificationTemplates::loadTemplates() { const std::string xml_filename = "notifications.xml"; LLXMLNodePtr root; BOOL success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root); if (!success || root.isNull() || !root->hasName( "notifications" )) { llerrs << "Problem reading UI Notifications file: " << xml_filename << llendl; return false; } clearTemplates(); for (LLXMLNodePtr item = root->getFirstChild(); item.notNull(); item = item->getNextSibling()) { if (item->hasName("global")) { std::string global_name; if (item->getAttributeString("name", global_name)) { mGlobalStrings[global_name] = item->getTextContents(); } continue; } if (item->hasName("template")) { // store an xml template; templates must have a single node (can contain // other nodes) std::string name; item->getAttributeString("name", name); LLXMLNodePtr ptr = item->getFirstChild(); mXmlTemplates[name] = ptr; continue; } if (!item->hasName("notification")) { llwarns << "Unexpected entity " << item->getName()->mString << " found in " << xml_filename << llendl; continue; } } return true; }
bool LLNotifications::loadTemplates() { const std::string xml_filename = "notifications.xml"; LLXMLNodePtr root; BOOL success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root); if (!success || root.isNull() || !root->hasName( "notifications" )) { llerrs << "Problem reading UI Notifications file: " << xml_filename << llendl; return false; } clearTemplates(); for (LLXMLNodePtr item = root->getFirstChild(); item.notNull(); item = item->getNextSibling()) { // we do this FIRST so that item can be changed if we // encounter a usetemplate -- we just replace the // current xml node and keep processing item = checkForXMLTemplate(item); if (item->hasName("global")) { std::string global_name; if (item->getAttributeString("name", global_name)) { mGlobalStrings[global_name] = item->getTextContents(); } continue; } if (item->hasName("template")) { // store an xml template; templates must have a single node (can contain // other nodes) std::string name; item->getAttributeString("name", name); LLXMLNodePtr ptr = item->getFirstChild(); mXmlTemplates[name] = ptr; continue; } if (!item->hasName("notification")) { llwarns << "Unexpected entity " << item->getName()->mString << " found in " << xml_filename << llendl; continue; } // now we know we have a notification entry, so let's build it LLNotificationTemplatePtr pTemplate(new LLNotificationTemplate()); if (!item->getAttributeString("name", pTemplate->mName)) { llwarns << "Unable to parse notification with no name" << llendl; continue; } //llinfos << "Parsing " << pTemplate->mName << llendl; pTemplate->mMessage = item->getTextContents(); pTemplate->mDefaultFunctor = pTemplate->mName; item->getAttributeString("type", pTemplate->mType); item->getAttributeString("icon", pTemplate->mIcon); item->getAttributeString("label", pTemplate->mLabel); item->getAttributeU32("duration", pTemplate->mExpireSeconds); item->getAttributeU32("expireOption", pTemplate->mExpireOption); std::string priority; item->getAttributeString("priority", priority); pTemplate->mPriority = NOTIFICATION_PRIORITY_NORMAL; if (!priority.empty()) { if (priority == "low") pTemplate->mPriority = NOTIFICATION_PRIORITY_LOW; if (priority == "normal") pTemplate->mPriority = NOTIFICATION_PRIORITY_NORMAL; if (priority == "high") pTemplate->mPriority = NOTIFICATION_PRIORITY_HIGH; if (priority == "critical") pTemplate->mPriority = NOTIFICATION_PRIORITY_CRITICAL; } item->getAttributeString("functor", pTemplate->mDefaultFunctor); BOOL persist = false; item->getAttributeBOOL("persist", persist); pTemplate->mPersist = persist; std::string sound; item->getAttributeString("sound", sound); if (!sound.empty()) { // TODO: test for bad sound effect name / missing effect pTemplate->mSoundEffect = LLUUID(LLUI::sConfigGroup->getString(sound.c_str())); } for (LLXMLNodePtr child = item->getFirstChild(); !child.isNull(); child = child->getNextSibling()) { child = checkForXMLTemplate(child); // <url> if (child->hasName("url")) { pTemplate->mURL = child->getTextContents(); child->getAttributeU32("option", pTemplate->mURLOption); } if (child->hasName("unique")) { pTemplate->mUnique = true; for (LLXMLNodePtr formitem = child->getFirstChild(); !formitem.isNull(); formitem = formitem->getNextSibling()) { if (formitem->hasName("context")) { std::string key; formitem->getAttributeString("key", key); pTemplate->mUniqueContext.push_back(key); //llwarns << "adding " << key << " to unique context" << llendl; } else { llwarns << "'unique' has unrecognized subelement " << formitem->getName()->mString << llendl; } } } // <form> if (child->hasName("form")) { pTemplate->mForm = LLNotificationFormPtr(new LLNotificationForm(pTemplate->mName, child)); } } addTemplate(pTemplate->mName, pTemplate); } //std::ostringstream ostream; //root->writeToOstream(ostream, "\n "); //llwarns << ostream.str() << llendl; return true; }