LLSD LLUserAuth::parseValues(UserAuthcode &auth_code, const std::string& key_pfx, XMLRPC_VALUE param) { auth_code = E_OK; LLSD responses; for(XMLRPC_VALUE current = XMLRPC_VectorRewind(param); current; current = XMLRPC_VectorNext(param)) { std::string key(XMLRPC_GetValueID(current)); lldebugs << "key: " << key_pfx << key << llendl; XMLRPC_VALUE_TYPE_EASY type = XMLRPC_GetValueTypeEasy(current); if(xmlrpc_type_string == type) { LLSD::String val(XMLRPC_GetValueString(current)); lldebugs << "val: " << val << llendl; responses.insert(key,val); } else if(xmlrpc_type_int == type) { LLSD::Integer val(XMLRPC_GetValueInt(current)); lldebugs << "val: " << val << llendl; responses.insert(key,val); } else if (xmlrpc_type_double == type) { LLSD::Real val(XMLRPC_GetValueDouble(current)); lldebugs << "val: " << val << llendl; responses.insert(key,val); } else if(xmlrpc_type_array == type) { // We expect this to be an array of submaps. Walk the array, // recursively parsing each submap and collecting them. LLSD array; int i = 0; // for descriptive purposes for (XMLRPC_VALUE row = XMLRPC_VectorRewind(current); row; row = XMLRPC_VectorNext(current), ++i) { // Recursive call. For the lower-level key_pfx, if 'key' // is "foo", pass "foo[0]:", then "foo[1]:", etc. In the // nested call, a subkey "bar" will then be logged as // "foo[0]:bar", and so forth. // Parse the scalar subkey/value pairs from this array // entry into a temp submap. Collect such submaps in 'array'. std::string key_prefix = key_pfx; array.append(parseValues(auth_code, STRINGIZE(key_pfx << key << '[' << i << "]:"), row)); } // Having collected an 'array' of 'submap's, insert that whole // 'array' as the value of this 'key'. responses.insert(key, array); } else if (xmlrpc_type_struct == type) { LLSD submap = parseValues(auth_code, STRINGIZE(key_pfx << key << ':'), current); responses.insert(key, submap); } else { // whoops - unrecognized type llwarns << "Unhandled xmlrpc type " << type << " for key " << key_pfx << key << LL_ENDL; responses.insert(key, STRINGIZE("<bad XMLRPC type " << type << '>')); auth_code = E_UNHANDLED_ERROR; } } return responses; }
void LLControlGroupCLP::configure(const std::string& config_filename, LLControlGroup* controlGroup) { // This method reads the llsd based config file, and uses it to set // members of a control group. LLSD clpConfigLLSD; llifstream input_stream; input_stream.open(config_filename, std::ios::in | std::ios::binary); if(input_stream.is_open()) { LLSDSerialize::fromXML(clpConfigLLSD, input_stream); for(LLSD::map_iterator option_itr = clpConfigLLSD.beginMap(); option_itr != clpConfigLLSD.endMap(); ++option_itr) { LLSD::String long_name = option_itr->first; LLSD option_params = option_itr->second; std::string desc("n/a"); if(option_params.has("desc")) { desc = option_params["desc"].asString(); } std::string short_name = LLStringUtil::null; if(option_params.has("short")) { short_name = option_params["short"].asString(); } unsigned int token_count = 0; if(option_params.has("count")) { token_count = option_params["count"].asInteger(); } bool composing = false; if(option_params.has("compose")) { composing = option_params["compose"].asBoolean(); } bool positional = false; if(option_params.has("positional")) { positional = option_params["positional"].asBoolean(); } bool last_option = false; if(option_params.has("last_option")) { last_option = option_params["last_option"].asBoolean(); } boost::function1<void, const token_vector_t&> callback; if(option_params.has("map-to") && (NULL != controlGroup)) { std::string controlName = option_params["map-to"].asString(); callback = boost::bind(setControlValueCB, _1, controlName, controlGroup); } this->addOptionDesc( long_name, callback, token_count, desc, short_name, composing, positional, last_option); } } }
void LLFloaterSettingsDebug::onUpdateFilter(const LLSD& value) { updateFilter(value.asString()); }
static bool handleDebugViewsChanged(const LLSD& newvalue) { LLView::sDebugRects = newvalue.asBoolean(); return true; }
static bool handleRenderAvatarMouselookChanged(const LLSD& newvalue) { LLVOAvatar::sVisibleInFirstPerson = newvalue.asBoolean(); return true; }
static bool handleRenderUseImpostorsChanged(const LLSD& newvalue) { LLVOAvatar::sUseImpostors = newvalue.asBoolean(); return true; }
static bool handleRenderDebugGLChanged(const LLSD& newvalue) { gDebugGL = newvalue.asBoolean(); gGL.clearErrors(); return true; }
static bool handleAvatarLODChanged(const LLSD& newvalue) { LLVOAvatar::sLODFactor = (F32) newvalue.asReal(); return true; }
static bool handleAvatarMaxVisibleChanged(const LLSD& newvalue) { LLVOAvatar::sMaxVisible = (U32) newvalue.asInteger(); return true; }
static bool handleSetSelfInvisible( const LLSD& newvalue) { LLVOAvatar::onChangeSelfInvisible( newvalue.asBoolean() ); return true; }
static bool handleVolumeLODChanged(const LLSD& newvalue) { LLVOVolume::sLODFactor = (F32) newvalue.asReal(); LLVOVolume::sDistanceFactor = 1.f-LLVOVolume::sLODFactor * 0.1f; return true; }
static bool handleTerrainDetailChanged(const LLSD& newvalue) { LLDrawPoolTerrain::sDetailMode = newvalue.asInteger(); return true; }
void LLInspectAvatar::onVolumeChange(const LLSD& data) { F32 volume = (F32)data.asReal(); LLVoiceClient::getInstance()->setUserVolume(mAvatarID, volume); }
void LLAvatarTracker::processNotify(LLMessageSystem* msg, bool online) { S32 count = msg->getNumberOfBlocksFast(_PREHASH_AgentBlock); BOOL chat_notify = gSavedSettings.getBOOL("ChatOnlineNotification"); lldebugs << "Received " << count << " online notifications **** " << llendl; if(count > 0) { LLUUID agent_id; const LLRelationship* info = NULL; LLUUID tracking_id; if(mTrackingData) { tracking_id = mTrackingData->mAvatarID; } BOOL notify = FALSE; LLSD args; LLSD payload; for(S32 i = 0; i < count; ++i) { msg->getUUIDFast(_PREHASH_AgentBlock, _PREHASH_AgentID, agent_id, i); payload["FROM_ID"] = agent_id; info = getBuddyInfo(agent_id); if(info) { setBuddyOnline(agent_id,online); if(chat_notify) { std::string first, last; if(gCacheName->getName(agent_id, first, last)) { notify = TRUE; args["FIRST"] = first; args["LAST"] = last; } } } else { llwarns << "Received online notification for unknown buddy: " << agent_id << " is " << (online ? "ONLINE" : "OFFLINE") << llendl; } if(tracking_id == agent_id) { // we were tracking someone who went offline deleteTrackingData(); } // *TODO: get actual inventory id gInventory.addChangedMask(LLInventoryObserver::CALLING_CARD, LLUUID::null); } if(notify) { // Popup a notify box with online status of this agent LLNotificationPtr notification; if (online) { notification = LLNotificationsUtil::add("FriendOnline", args, payload.with("respond_on_mousedown", TRUE), boost::bind(&LLAvatarActions::startIM, agent_id)); } else { notification = LLNotificationsUtil::add("FriendOffline", args, payload); } // If there's an open IM session with this agent, send a notification there too. LLUUID session_id = LLIMMgr::computeSessionID(IM_NOTHING_SPECIAL, agent_id); std::string notify_msg = notification->getMessage(); LLIMModel::instance().proccessOnlineOfflineNotification(session_id, notify_msg); } mModifyMask |= LLFriendObserver::ONLINE; instance().notifyObservers(); gInventory.notifyObservers(); } }
static bool handleUploadBakedTexOldChanged(const LLSD& newvalue) { LLPipeline::sForceOldBakedUpload = newvalue.asBoolean(); return true; }
static bool handleTreeLODChanged(const LLSD& newvalue) { LLVOTree::sTreeFactor = (F32) newvalue.asReal(); return true; }
static bool handleRenderDynamicLODChanged(const LLSD& newvalue) { LLPipeline::sDynamicLOD = newvalue.asBoolean(); return true; }
static bool handleFlexLODChanged(const LLSD& newvalue) { LLVolumeImplFlexible::sUpdateFactor = (F32) newvalue.asReal(); return true; }
static bool handleAuditTextureChanged(const LLSD& newvalue) { gAuditTexture = newvalue.asBoolean(); return true; }
static bool handleFogRatioChanged(const LLSD& newvalue) { F32 fog_ratio = llmax(MIN_USER_FOG_RATIO, llmin((F32) newvalue.asReal(), MAX_USER_FOG_RATIO)); gSky.setFogRatio(fog_ratio); return true; }
static bool handleRenderDebugPipelineChanged(const LLSD& newvalue) { gDebugPipeline = newvalue.asBoolean(); return true; }
static bool handleMaxPartCountChanged(const LLSD& newvalue) { LLViewerPartSim::setMaxPartCount(newvalue.asInteger()); return true; }
bool handleRenderSculptSAMaxChanged(const LLSD& newvalue) { LLVOVolume::sSculptSAMax = newvalue.asReal(); return true; }
static bool handleVideoMemoryChanged(const LLSD& newvalue) { gImageList.updateMaxResidentTexMem(newvalue.asInteger()); return true; }
//---------------------------------------------------------------------------- // LLControlGroupCLP defintions //---------------------------------------------------------------------------- void setControlValueCB(const LLCommandLineParser::token_vector_t& value, const std::string& opt_name, LLControlGroup* ctrlGroup) { // *FIX: Do sematic conversion here. // LLSD (ImplString) Is no good for doing string to type conversion for... // booleans // compound types // ?... LLControlVariable* ctrl = ctrlGroup->getControl(opt_name); if(NULL != ctrl) { switch(ctrl->type()) { case TYPE_BOOLEAN: if(value.size() > 1) { LL_WARNS() << "Ignoring extra tokens." << LL_ENDL; } if(value.size() > 0) { // There's a token. check the string for true/false/1/0 etc. BOOL result = false; BOOL gotSet = LLStringUtil::convertToBOOL(value[0], result); if(gotSet) { ctrl->setValue(LLSD(result), false); } } else { ctrl->setValue(LLSD(true), false); } break; default: { // For the default types, let llsd do the conversion. if(value.size() > 1 && ctrl->isType(TYPE_LLSD)) { // Assume its an array... LLSD llsdArray; for(unsigned int i = 0; i < value.size(); ++i) { LLSD llsdValue; llsdValue.assign(LLSD::String(value[i])); llsdArray.set(i, llsdValue); } ctrl->setValue(llsdArray, false); } else if(value.size() > 0) { if(value.size() > 1) { LL_WARNS() << "Ignoring extra tokens mapped to the setting: " << opt_name << "." << LL_ENDL; } LLSD llsdValue; llsdValue.assign(LLSD::String(value[0])); ctrl->setValue(llsdValue, false); } } break; } } else { LL_WARNS() << "Command Line option mapping '" << opt_name << "' not found! Ignoring." << LL_ENDL; } }
static bool handleBandwidthChanged(const LLSD& newvalue) { gViewerThrottle.setMaxBandwidth((F32) newvalue.asReal()); return true; }
// we've switched controls, so update spinners, etc. void LLFloaterSettingsDebug::updateControl() { LLSpinCtrl* spinner1 = getChild<LLSpinCtrl>("val_spinner_1"); LLSpinCtrl* spinner2 = getChild<LLSpinCtrl>("val_spinner_2"); LLSpinCtrl* spinner3 = getChild<LLSpinCtrl>("val_spinner_3"); LLSpinCtrl* spinner4 = getChild<LLSpinCtrl>("val_spinner_4"); LLColorSwatchCtrl* color_swatch = getChild<LLColorSwatchCtrl>("val_color_swatch"); LLUICtrl* bool_ctrl = getChild<LLUICtrl>("boolean_combo"); if (!spinner1 || !spinner2 || !spinner3 || !spinner4 || !color_swatch) { llwarns << "Could not find all desired controls by name" << llendl; return; } spinner1->setVisible(FALSE); spinner2->setVisible(FALSE); spinner3->setVisible(FALSE); spinner4->setVisible(FALSE); color_swatch->setVisible(FALSE); getChildView("val_text")->setVisible( FALSE); mComment->setText(LLStringUtil::null); childSetEnabled("copy_btn", false); childSetEnabled("default_btn", false); bool_ctrl->setVisible(false); if (mCurrentControlVariable) { // [RLVa:KB] - Checked: 2011-05-28 (RLVa-1.4.0a) | Modified: RLVa-1.4.0a // If "HideFromEditor" was toggled while the floater is open then we need to manually disable access to the control mOldVisibility = mCurrentControlVariable->isHiddenFromSettingsEditor(); spinner1->setEnabled(!mOldVisibility); spinner2->setEnabled(!mOldVisibility); spinner3->setEnabled(!mOldVisibility); spinner4->setEnabled(!mOldVisibility); color_swatch->setEnabled(!mOldVisibility); childSetEnabled("val_text", !mOldVisibility); bool_ctrl->setEnabled(!mOldVisibility); childSetEnabled("default_btn", !mOldVisibility); // [/RLVa:KB] childSetEnabled("copy_btn", true); eControlType type = mCurrentControlVariable->type(); mComment->setText(mCurrentControlVariable->getName() + std::string(": ") + mCurrentControlVariable->getComment()); spinner1->setMaxValue(F32_MAX); spinner2->setMaxValue(F32_MAX); spinner3->setMaxValue(F32_MAX); spinner4->setMaxValue(F32_MAX); spinner1->setMinValue(-F32_MAX); spinner2->setMinValue(-F32_MAX); spinner3->setMinValue(-F32_MAX); spinner4->setMinValue(-F32_MAX); if (!spinner1->hasFocus()) { spinner1->setIncrement(0.1f); } if (!spinner2->hasFocus()) { spinner2->setIncrement(0.1f); } if (!spinner3->hasFocus()) { spinner3->setIncrement(0.1f); } if (!spinner4->hasFocus()) { spinner4->setIncrement(0.1f); } LLSD sd = mCurrentControlVariable->get(); switch(type) { case TYPE_U32: spinner1->setVisible(TRUE); spinner1->setLabel(std::string("value")); // Debug, don't translate if (!spinner1->hasFocus()) { spinner1->setValue(sd); spinner1->setMinValue((F32)U32_MIN); spinner1->setMaxValue((F32)U32_MAX); spinner1->setIncrement(1.f); spinner1->setPrecision(0); } break; case TYPE_S32: spinner1->setVisible(TRUE); spinner1->setLabel(std::string("value")); // Debug, don't translate if (!spinner1->hasFocus()) { spinner1->setValue(sd); spinner1->setMinValue((F32)S32_MIN); spinner1->setMaxValue((F32)S32_MAX); spinner1->setIncrement(1.f); spinner1->setPrecision(0); } break; case TYPE_F32: spinner1->setVisible(TRUE); spinner1->setLabel(std::string("value")); // Debug, don't translate if (!spinner1->hasFocus()) { spinner1->setPrecision(3); spinner1->setValue(sd); } break; case TYPE_BOOLEAN: bool_ctrl->setVisible(true); if (!bool_ctrl->hasFocus()) { if (sd.asBoolean()) { bool_ctrl->setValue(LLSD("TRUE")); } else { bool_ctrl->setValue(LLSD("FALSE")); } } break; case TYPE_STRING: getChildView("val_text")->setVisible( TRUE); if (!getChild<LLUICtrl>("val_text")->hasFocus()) { getChild<LLUICtrl>("val_text")->setValue(sd); } break; case TYPE_VEC3: { LLVector3 v; v.setValue(sd); spinner1->setVisible(TRUE); spinner1->setLabel(std::string("X")); spinner2->setVisible(TRUE); spinner2->setLabel(std::string("Y")); spinner3->setVisible(TRUE); spinner3->setLabel(std::string("Z")); if (!spinner1->hasFocus()) { spinner1->setPrecision(3); spinner1->setValue(v[VX]); } if (!spinner2->hasFocus()) { spinner2->setPrecision(3); spinner2->setValue(v[VY]); } if (!spinner3->hasFocus()) { spinner3->setPrecision(3); spinner3->setValue(v[VZ]); } break; } case TYPE_VEC3D: { LLVector3d v; v.setValue(sd); spinner1->setVisible(TRUE); spinner1->setLabel(std::string("X")); spinner2->setVisible(TRUE); spinner2->setLabel(std::string("Y")); spinner3->setVisible(TRUE); spinner3->setLabel(std::string("Z")); if (!spinner1->hasFocus()) { spinner1->setPrecision(3); spinner1->setValue(v[VX]); } if (!spinner2->hasFocus()) { spinner2->setPrecision(3); spinner2->setValue(v[VY]); } if (!spinner3->hasFocus()) { spinner3->setPrecision(3); spinner3->setValue(v[VZ]); } break; } case TYPE_RECT: { LLRect r; r.setValue(sd); spinner1->setVisible(TRUE); spinner1->setLabel(std::string("Left")); spinner2->setVisible(TRUE); spinner2->setLabel(std::string("Right")); spinner3->setVisible(TRUE); spinner3->setLabel(std::string("Bottom")); spinner4->setVisible(TRUE); spinner4->setLabel(std::string("Top")); if (!spinner1->hasFocus()) { spinner1->setPrecision(0); spinner1->setValue(r.mLeft); } if (!spinner2->hasFocus()) { spinner2->setPrecision(0); spinner2->setValue(r.mRight); } if (!spinner3->hasFocus()) { spinner3->setPrecision(0); spinner3->setValue(r.mBottom); } if (!spinner4->hasFocus()) { spinner4->setPrecision(0); spinner4->setValue(r.mTop); } spinner1->setMinValue((F32)S32_MIN); spinner1->setMaxValue((F32)S32_MAX); spinner1->setIncrement(1.f); spinner2->setMinValue((F32)S32_MIN); spinner2->setMaxValue((F32)S32_MAX); spinner2->setIncrement(1.f); spinner3->setMinValue((F32)S32_MIN); spinner3->setMaxValue((F32)S32_MAX); spinner3->setIncrement(1.f); spinner4->setMinValue((F32)S32_MIN); spinner4->setMaxValue((F32)S32_MAX); spinner4->setIncrement(1.f); break; } case TYPE_COL4: { LLColor4 clr; clr.setValue(sd); color_swatch->setVisible(TRUE); // only set if changed so color picker doesn't update if(clr != LLColor4(color_swatch->getValue())) { color_swatch->set(LLColor4(sd), TRUE, FALSE); } spinner4->setVisible(TRUE); spinner4->setLabel(std::string("Alpha")); if (!spinner4->hasFocus()) { spinner4->setPrecision(3); spinner4->setMinValue(0.0); spinner4->setMaxValue(1.f); spinner4->setValue(clr.mV[VALPHA]); } break; } case TYPE_COL3: { LLColor3 clr; clr.setValue(sd); color_swatch->setVisible(TRUE); color_swatch->setValue(sd); break; } case TYPE_COL4U: { LLColor4U clr; clr.setValue(sd); color_swatch->setVisible(TRUE); if(LLColor4(clr) != LLColor4(color_swatch->getValue())) { color_swatch->set(LLColor4(clr), TRUE, FALSE); } spinner4->setVisible(TRUE); spinner4->setLabel(std::string("Alpha")); if(!spinner4->hasFocus()) { spinner4->setPrecision(0); spinner4->setValue(clr.mV[VALPHA]); } spinner4->setMinValue(0); spinner4->setMaxValue(255); spinner4->setIncrement(1.f); break; } default: mComment->setText(std::string("unknown")); break; } } }
static bool handleUseOcclusionChanged(const LLSD& newvalue) { LLPipeline::sUseOcclusion = (newvalue.asBoolean() && gGLManager.mHasOcclusionQuery && LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion") && !gUseWireframe) ? 2 : 0; return true; }
U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_values, bool save_values) { LLSD settings; llifstream infile; infile.open(filename); if(!infile.is_open()) { llwarns << "Cannot find file " << filename << " to load." << llendl; return 0; } S32 ret = LLSDSerialize::fromXML(settings, infile); if (ret <= 0) { infile.close(); llwarns << "Unable to open LLSD control file " << filename << ". Trying Legacy Method." << llendl; return loadFromFileLegacy(filename, TRUE, TYPE_STRING); } U32 validitems = 0; bool hidefromsettingseditor = false; for(LLSD::map_const_iterator itr = settings.beginMap(); itr != settings.endMap(); ++itr) { bool persist = true; std::string const & name = itr->first; LLSD const & control_map = itr->second; if(control_map.has("Persist")) { persist = control_map["Persist"].asInteger(); } // Sometimes we want to use the settings system to provide cheap persistence, but we // don't want the settings themselves to be easily manipulated in the UI because // doing so can cause support problems. So we have this option: if(control_map.has("HideFromEditor")) { hidefromsettingseditor = control_map["HideFromEditor"].asInteger(); } else { hidefromsettingseditor = false; } // If the control exists just set the value from the input file. LLControlVariable* existing_control = getControl(name); if(existing_control) { if(set_default_values) { // Override all previously set properties of this control. // ... except for type. The types must match. eControlType new_type = typeStringToEnum(control_map["Type"].asString()); if(existing_control->isType(new_type)) { existing_control->setDefaultValue(control_map["Value"]); existing_control->setPersist(persist); existing_control->setHiddenFromSettingsEditor(hidefromsettingseditor); existing_control->setComment(control_map["Comment"].asString()); } else { llerrs << "Mismatched type of control variable '" << name << "' found while loading '" << filename << "'." << llendl; } } else if(existing_control->isPersisted()) { existing_control->setValue(control_map["Value"], save_values); } // *NOTE: If not persisted and not setting defaults, // the value should not get loaded. } else { declareControl(name, typeStringToEnum(control_map["Type"].asString()), control_map["Value"], control_map["Comment"].asString(), persist, hidefromsettingseditor ); } ++validitems; } return validitems; }
static bool handleAllowLargeSounds(const LLSD& newvalue) { if(gAudiop) gAudiop->setAllowLargeSounds(newvalue.asBoolean()); return true; }