bool LLFlatListView::updateValue(const LLSD& old_value, const LLSD& new_value)
{
	if (old_value.isUndefined() || new_value.isUndefined()) return false;
	if (llsds_are_equal(old_value, new_value)) return false;

	item_pair_t* item_pair = getItemPair(old_value);
	if (!item_pair) return false;

	item_pair->second = new_value;
	return true;
}
void LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, const LLPathfindingObjectListPtr &pLinksetListPtr, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, object_request_callback_t pLinksetsCallback) const
{
	LLPathfindingObjectListPtr emptyLinksetListPtr;

	std::string objectLinksetsURL = getObjectLinksetsURLForCurrentRegion();
	std::string terrainLinksetsURL = getTerrainLinksetsURLForCurrentRegion();
	if (objectLinksetsURL.empty() || terrainLinksetsURL.empty())
	{
		pLinksetsCallback(pRequestId, kRequestNotEnabled, emptyLinksetListPtr);
	}
	else if ((pLinksetListPtr == NULL) || pLinksetListPtr->isEmpty())
	{
		pLinksetsCallback(pRequestId, kRequestCompleted, emptyLinksetListPtr);
	}
	else 
	{
		const LLPathfindingLinksetList *linksetList = dynamic_cast<const LLPathfindingLinksetList *>(pLinksetListPtr.get());

		LLSD objectPostData = linksetList->encodeObjectFields(pLinksetUse, pA, pB, pC, pD);
		LLSD terrainPostData;
		if (isAllowViewTerrainProperties())
		{
			terrainPostData = linksetList->encodeTerrainFields(pLinksetUse, pA, pB, pC, pD);
		}

		if (objectPostData.isUndefined() && terrainPostData.isUndefined())
		{
			pLinksetsCallback(pRequestId, kRequestCompleted, emptyLinksetListPtr);
		}
		else
		{
			pLinksetsCallback(pRequestId, kRequestStarted, emptyLinksetListPtr);

			LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pRequestId, pLinksetsCallback, !objectPostData.isUndefined(), !terrainPostData.isUndefined()));

			if (!objectPostData.isUndefined())
			{
				LLHTTPClient::ResponderPtr objectLinksetsResponder = new ObjectLinksetsResponder(objectLinksetsURL, linksetsResponderPtr);
				LLHTTPClient::put(objectLinksetsURL, objectPostData, objectLinksetsResponder);
			}

			if (!terrainPostData.isUndefined())
			{
				LLHTTPClient::ResponderPtr terrainLinksetsResponder = new TerrainLinksetsResponder(terrainLinksetsURL, linksetsResponderPtr);
				LLHTTPClient::put(terrainLinksetsURL, terrainPostData, terrainLinksetsResponder);
			}
		}
	}
}
// virtual
bool LLMessageConfigFile::loadFile()
{
	LLSD data;
    {
        llifstream file(filename());
        
        if (file.is_open())
        {
			LL_DEBUGS("AppInit") << "Loading message.xml file at " << filename() << LL_ENDL;
            LLSDSerialize::fromXML(data, file);
        }

        if (data.isUndefined())
        {
            LL_INFOS("AppInit") << "LLMessageConfigFile::loadFile: file missing,"
				" ill-formed, or simply undefined; not changing the"
				" file" << LL_ENDL;
            return false;
        }
    }
	loadServerDefaults(data);
	loadMaxQueuedEvents(data);
	loadMessages(data);
	loadCapBans(data);
	loadMessageBans(data);
	return true;
}
Exemple #4
0
void LLFloaterIMPanel::onFlyoutCommit(LLComboBox* flyout, const LLSD& value)
{
	if (value.isUndefined() || value.asInteger() == 0)
	{
		LLAvatarActions::showProfile(mOtherParticipantUUID);
		return;
	}

	int option = value.asInteger();
	if (option == 1) onClickHistory();
	else if (option == 2) LLAvatarActions::offerTeleport(mOtherParticipantUUID);
	else if (option == 3) LLAvatarActions::teleportRequest(mOtherParticipantUUID);
	else if (option == 4) LLAvatarActions::pay(mOtherParticipantUUID);
	else if (option == 5) LLAvatarActions::inviteToGroup(mOtherParticipantUUID);
	else if (option == -1) copy_profile_uri(mOtherParticipantUUID);
	else if (option >= 6) // Options that use dynamic items
	{
		// First remove them all
		removeDynamics(flyout);

		// Toggle as requested, adjust the strings
		if (option == 6) mDing = !mDing;
		else if (option == 7) mRPMode = !mRPMode;
		else if (option == 8) LLAvatarActions::isFriend(mOtherParticipantUUID) ? LLAvatarActions::removeFriendDialog(mOtherParticipantUUID) : LLAvatarActions::requestFriendshipDialog(mOtherParticipantUUID);
		//else if (option == 9) LLAvatarActions::toggleBlock(mOtherParticipantUUID);

		// Last add them back
		addDynamics(flyout);
	}
}
void LLPanelClassifiedEdit::onOpen(const LLSD& key)
{
	mIsNew = key.isUndefined();
	
	scrollToTop();

	// classified is not created yet
	bool is_new = isNew() || isNewWithErrors();

	if(is_new)
	{
		resetData();
		resetControls();

		fillIn(key);

		if(isNew())
		{
			LLAvatarPropertiesProcessor::getInstance()->addObserver(getAvatarId(), this);
		}
	}
	else
	{
		LLPanelClassifiedInfo::onOpen(key);
	}

	std::string save_btn_label = is_new ? getString("publish_label") : getString("save_label");
	getChild<LLUICtrl>("save_changes_btn")->setLabelArg("[LABEL]", save_btn_label);

	enableVerbs(is_new);
	enableEditing(is_new);
	showEditing(!is_new);
	resetDirty();
	setInfoLoaded(false);
}
LLSD getLLSD(const LLSD& input, const char* block, const char* var, S32 blocknum)
{
	// babbage: log error to llerrs if variable not found to mimic
	// LLTemplateMessageReader::getData behaviour
	if(NULL == block)
	{
		llerrs << "NULL block name" << llendl;
		return LLSD();
	}
	if(NULL == var)
	{
		llerrs << "NULL var name" << llendl;
		return LLSD();
	}
	if(! input[block].isArray())
	{
		// NOTE: babbage: need to return default for missing blocks to allow
		// backwards/forwards compatibility - handlers must cope with default
		// values.
		llwarns << "block " << block << " not found" << llendl;
		return LLSD();
	}

	LLSD result = input[block][blocknum][var]; 
	if(result.isUndefined())
	{
		// NOTE: babbage: need to return default for missing vars to allow
		// backwards/forwards compatibility - handlers must cope with default
		// values.
		llwarns << "var " << var << " not found" << llendl;
	}
	return result;
}
// virtual
LLIOPipe::EStatus LLContextURLExtractor::process_impl(
	const LLChannelDescriptors& channels,
	buffer_ptr_t& buffer,
	bool& eos,
	LLSD& context,
	LLPumpIO* pump)
{
	PUMP_DEBUG;
	LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
	// The destination host is in the context.
	if(context.isUndefined() || !mRequest)
	{
		return STATUS_PRECONDITION_NOT_MET;
	}

	// copy in to out, since this just extract the URL and does not
	// actually change the data.
	LLChangeChannel change(channels.in(), channels.out());
	std::for_each(buffer->beginSegment(), buffer->endSegment(), change);

	// find the context url
	if(context.has(CONTEXT_DEST_URI_SD_LABEL))
	{
		mRequest->setURL(context[CONTEXT_DEST_URI_SD_LABEL].asString());
		return STATUS_DONE;
	}
	return STATUS_ERROR;
}
		/*virtual*/ void httpFailure()
		{
 			LL_WARNS("ExperienceCache") << "Request failed "<<getStatus()<<" "<<getReason()<< LL_ENDL;
 			// We're going to construct a dummy record and cache it for a while,
 			// either briefly for a 503 Service Unavailable, or longer for other
 			// errors.
 			F64 retry_timestamp = errorRetryTimestamp(getStatus());
 
 
 			// Add dummy records for all agent IDs in this request
 			ask_queue_t::const_iterator it = mKeys.begin();
 			for ( ; it != mKeys.end(); ++it)
			{

				LLSD exp = get(it->first);
                //leave the properties alone if we already have a cache entry for this xp
                if(exp.isUndefined())
                {
                    exp[PROPERTIES]=PROPERTY_INVALID;
                }
				exp[EXPIRES]=retry_timestamp;
				exp[EXPERIENCE_ID] = it->first;
				exp["key_type"] = it->second;
				exp["uuid"] = it->first;
				exp["error"] = (LLSD::Integer)getStatus();
                exp[QUOTA] = DEFAULT_QUOTA;

 				LLExperienceCache::processExperience(it->first, exp);
 			}

		}
Exemple #9
0
LLSavedLogins LLSavedLogins::loadFile(const std::string& filepath)
{
	LLSavedLogins hist;
	LLSD data;

	llifstream file(filepath);

	if (file.is_open())
	{
		llinfos << "Loading login history file at " << filepath << llendl;
		LLSDSerialize::fromXML(data, file);
	}

	if (data.isUndefined())
	{
		llinfos << "Login History File \"" << filepath << "\" is missing, "
		    "ill-formed, or simply undefined; not loading the file." << llendl;
	}
	else
	{
		try
		{
			hist = LLSavedLogins(data);
		}
		catch(std::invalid_argument& error)
		{
			llwarns << "Login History File \"" << filepath << "\" is ill-formed (" <<
			        error.what() << "); not loading the file." << llendl;
		}
	}

	return hist;
}
// static
bool LLURLHistory::loadFile(const std::string& filename)
{
	LLSD data;
	{
		std::string temp_str = gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter();

		llifstream file((temp_str + filename));

		if (file.is_open())
		{
			llinfos << "Loading history.xml file at " << temp_str + filename << llendl;
			LLSDSerialize::fromXML(data, file);
		}

		if (data.isUndefined())
		{
			llinfos << "file missing, ill-formed, "
				"or simply undefined; not changing the"
				" file" << llendl;
			sHistorySD = LLSD();
			return false;
		}
	}
	sHistorySD = data;
	return true;
}
bool LLNotificationsListener::Forwarder::matchType(const LLSD& filter, const std::string& type) const
{
    // Decide whether this notification matches filter:
    // undefined: forward all notifications
    if (filter.isUndefined())
    {
        return true;
    }
    // array of string: forward any notification matching any named type
    if (filter.isArray())
    {
        for (LLSD::array_const_iterator ti(filter.beginArray()), tend(filter.endArray());
             ti != tend; ++ti)
        {
            if (ti->asString() == type)
            {
                return true;
            }
        }
        // Didn't match any entry in the array
        return false;
    }
    // string: forward only the specific named type
    return (filter.asString() == type);
}
	void SDTestObject::test<1>()
		// construction and test of undefined
	{
		SDCleanupCheck check;
		
		LLSD u;
		ensure("is undefined", u.isUndefined());
	}
void LLFloaterJoystick::onClickDefault(const LLSD& val)
{
	S32 type(val.asInteger());
	if (val.isUndefined()) // If button portion, set to default for device.
		if ((type = get_joystick_type()) == -1) // Invalid/No device
			return;
	LLViewerJoystick::getInstance()->setSNDefaults(type);
}
void LLFloaterWorldMap::updateSims(bool found_null_sim)
{
	if (mCompletingRegionName == "")
	{
		return;
	}

	LLScrollListCtrl *list = getChild<LLScrollListCtrl>("search_results");
	list->operateOnAll(LLCtrlListInterface::OP_DELETE);

	S32 name_length = mCompletingRegionName.length();

	LLSD match;
	
	S32 num_results = 0;
	std::map<U64, LLSimInfo*>::const_iterator it;
	for (it = LLWorldMap::getInstance()->getRegionMap().begin(); it != LLWorldMap::getInstance()->getRegionMap().end(); ++it)
	{
		LLSimInfo* info = it->second;
		std::string sim_name_lower = info->getName();
		LLStringUtil::toLower(sim_name_lower);

		if (sim_name_lower.substr(0, name_length) == mCompletingRegionName)
		{
			if (sim_name_lower == mCompletingRegionName)
			{
				match = info->getName();
			}
			
			LLSD value;
			value["id"] = info->getName();
			value["columns"][0]["column"] = "sim_name";
			value["columns"][0]["value"] = info->getName();
			list->addElement(value);
			num_results++;
		}
	}

	if (found_null_sim)
	{
		mCompletingRegionName = "";
	}

	// if match found, highlight it and go
	if (!match.isUndefined())
	{
		list->selectByValue(match);
		childSetFocus("search_results");
		onCommitSearchResult();
	}

	// if we found nothing, say "none"
	if (num_results == 0)
	{
		list->setCommentText(LLTrans::getString("worldmap_results_none_found"));
		list->operateOnAll(LLCtrlListInterface::OP_DESELECT);
	}
}
Exemple #15
0
void LLPanelPicks::onDoubleClickClassifiedItem(LLUICtrl* item)
{
	LLSD value = mClassifiedsList->getSelectedValue();
	if (value.isUndefined()) return;

	LLSD args; 
	args["CLASSIFIED"] = value[CLASSIFIED_NAME]; 
	LLNotificationsUtil::add("TeleportToClassified", args, LLSD(), boost::bind(&LLPanelPicks::callbackTeleport, this, _1, _2)); 
}
bool LLFlatListView::selectItemByValue(const LLSD& value, bool select /*= true*/)
{
	if (value.isUndefined()) return false;

	item_pair_t* item_pair = getItemPair(value);
	if (!item_pair) return false;

	return selectItemPair(item_pair, select);
}
bool LLFlatListView::removeItemByValue(const LLSD& value)
{
	if (value.isUndefined()) return false;
	
	item_pair_t* item_pair = getItemPair(value);
	if (!item_pair) return false;

	return removeItemPair(item_pair);
}
// static
void LLToolBar::onClickCommunicate(const LLSD& selected_option)
{
	if (selected_option.asString() == "contacts")
	{
		LLFloaterMyFriends::showInstance();
	}
	else if (selected_option.asString() == "local chat")
	{
		LLFloaterChat::showInstance();
	}
	else if (selected_option.asString() == "redock")
	{
		LLFloaterChatterBox::getInstance()->addFloater(LLFloaterMyFriends::getInstance(), FALSE);
		LLFloaterChatterBox::getInstance()->addFloater(LLFloaterChat::getInstance(), FALSE);
		LLUUID session_to_show;
		
		std::set<LLHandle<LLFloater> >::const_iterator floater_handle_it;
		for(floater_handle_it = gIMMgr->getIMFloaterHandles().begin(); floater_handle_it != gIMMgr->getIMFloaterHandles().end(); ++floater_handle_it)
		{
			LLFloater* im_floaterp = floater_handle_it->get();
			if (im_floaterp)
			{
				if (im_floaterp->isFrontmost())
				{
					session_to_show = ((LLFloaterIMPanel*)im_floaterp)->getSessionID();
				}
				LLFloaterChatterBox::getInstance()->addFloater(im_floaterp, FALSE);
			}
		}

		LLFloaterChatterBox::showInstance(session_to_show);
	}
	else if (selected_option.asString() == "mute list")
	{
		LLFloaterMute::showInstance();
	}
	else if (selected_option.isUndefined()) // user just clicked the communicate button, treat as toggle
	{
		if (LLFloaterChatterBox::getInstance()->getFloaterCount() == 0)
		{
			LLFloaterMyFriends::toggleInstance();
		}
		else
		{
			LLFloaterChatterBox::toggleInstance();
		}
	}
	else // otherwise selection_option is a specific IM session id
	{
		LLFloaterChatterBox::showInstance(selected_option);
	}
}
Exemple #19
0
void LLEventDetail::storeToLLSDPath(LLSD& dest, const LLSD& rawPath, const LLSD& value)
{
    if (rawPath.isUndefined())
    {
        // no-op case
        return;
    }

    // Arrange to treat rawPath uniformly as an array. If it's not already an
    // array, store it as the only entry in one.
    LLSD path;
    if (rawPath.isArray())
    {
        path = rawPath;
    }
    else
    {
        path.append(rawPath);
    }

    // Need to indicate a current destination -- but that current destination
    // needs to change as we step through the path array. Where normally we'd
    // use an LLSD& to capture a subscripted LLSD lvalue, this time we must
    // instead use a pointer -- since it must be reassigned.
    LLSD* pdest = &dest;

    // Now loop through that array
    for (LLSD::Integer i = 0; i < path.size(); ++i)
    {
        if (path[i].isString())
        {
            // *pdest is an LLSD map
            pdest = &((*pdest)[path[i].asString()]);
        }
        else if (path[i].isInteger())
        {
            // *pdest is an LLSD array
            pdest = &((*pdest)[path[i].asInteger()]);
        }
        else
        {
            // What do we do with Real or Array or Map or ...?
            // As it's a coder error -- not a user error -- rub the coder's
            // face in it so it gets fixed.
            LL_ERRS("lleventcoro") << "storeToLLSDPath(" << dest << ", " << rawPath << ", " << value
                                   << "): path[" << i << "] bad type " << path[i].type() << LL_ENDL;
        }
    }

    // Here *pdest is where we should store value.
    *pdest = value;
}
void LLToolBar::updateCommunicateList()
{
	if (!mCommunicateBtn->getVisible()) return;

	LLSD selected = mCommunicateBtn->getValue();

	mCommunicateBtn->removeall();

	const LLFloater* frontmost_floater = LLFloaterChatterBox::getInstance()->getActiveFloater();
	bold_if_equal(LLFloaterMyFriends::getInstance(), frontmost_floater, mCommunicateBtn->add(LLFloaterMyFriends::getInstance()->getShortTitle(), LLSD("contacts"), ADD_TOP));
	bold_if_equal(LLFloaterChat::getInstance(), frontmost_floater, mCommunicateBtn->add(LLFloaterChat::getInstance()->getShortTitle(), LLSD("local chat"), ADD_TOP));
	mCommunicateBtn->addSeparator(ADD_TOP);
	mCommunicateBtn->add(getString("Redock Windows"), LLSD("redock"), ADD_TOP);
	mCommunicateBtn->addSeparator(ADD_TOP);
	bold_if_equal(LLFloaterMute::getInstance(), frontmost_floater, mCommunicateBtn->add(LLFloaterMute::getInstance()->getShortTitle(), LLSD("mute list"), ADD_TOP));

	if (gIMMgr->getIMFloaterHandles().size() > 0) mCommunicateBtn->addSeparator(ADD_TOP);
	for(std::set<LLHandle<LLFloater> >::const_iterator floater_handle_it = gIMMgr->getIMFloaterHandles().begin(); floater_handle_it != gIMMgr->getIMFloaterHandles().end(); ++floater_handle_it)
	{
		if (LLFloaterIMPanel* im_floaterp = (LLFloaterIMPanel*)floater_handle_it->get())
		{
			const S32 count = im_floaterp->getNumUnreadMessages();
			std::string floater_title;
			if (count > 0) floater_title = "*";
			floater_title.append(im_floaterp->getShortTitle());
			static const LLCachedControl<bool> show_counts("ShowUnreadIMsCounts", true);
			if (show_counts && count > 0)
			{
				floater_title += " - ";
				if (count > 1)
				{
					LLStringUtil::format_map_t args;
					args["COUNT"] = llformat("%d", count);
					floater_title += getString("IMs", args);
				}
				else
				{
					floater_title += getString("IM");
				}
			}
			bold_if_equal(im_floaterp, frontmost_floater, mCommunicateBtn->add(floater_title, im_floaterp->getSessionID(), ADD_TOP));
		}
	}

	static const LLCachedControl<bool> show_comm("ShowCommunicate", true);
	mCommunicateBtn->setToggleState(show_comm);
	if (!selected.isUndefined()) mCommunicateBtn->setValue(selected);
}
	void sd_object::test<15>()
	{
		std::string val = "[{'failures':!,'successfuls':[u3c115e51-04f4-523c-9fa6-98aff1034730]}]";
		std::istringstream istr;
		istr.str(val);
		LLSD sd;
		LLSDSerialize::fromNotation(sd, istr, val.size());
		ensure_equals("parsed type", sd.type(), LLSD::TypeArray);
		ensure_equals("parsed size", sd.size(), 1);
		LLSD failures = sd[0]["failures"];
		ensure("no failures.", failures.isUndefined());
		LLSD success = sd[0]["successfuls"];
		ensure_equals("success type", success.type(), LLSD::TypeArray);
		ensure_equals("success size", success.size(), 1);
		ensure_equals("success instance type", success[0].type(), LLSD::TypeUUID);
	}
Exemple #22
0
// static
LLURI LLURI::buildHTTP(const std::string& prefix,
					   const LLSD& path)
{
	LLURI result;
	
	// TODO: deal with '/' '?' '#' in host_port
	if (prefix.find("://") != prefix.npos)
	{
		// it is a prefix
		result = LLURI(prefix);
	}
	else
	{
		// it is just a host and optional port
		result.mScheme = "http";
		result.mEscapedAuthority = escapeHostAndPort(prefix);
	}

	if (path.isArray())
	{
		// break out and escape each path component
		for (LLSD::array_const_iterator it = path.beginArray();
			 it != path.endArray();
			 ++it)
		{
			lldebugs << "PATH: inserting " << it->asString() << llendl;
			result.mEscapedPath += "/" + escapePathComponent(it->asString());
		}
	}
	else if(path.isString())
	{
		result.mEscapedPath += "/" + escapePathComponent(path.asString());
	} 
	else if(path.isUndefined())
	{
	  // do nothing
	}
    else
	{
	  llwarns << "Valid path arguments to buildHTTP are array, string, or undef, you passed type" 
			  << path.type() << llendl;
	}
	result.mEscapedOpaque = "//" + result.mEscapedAuthority +
		result.mEscapedPath;
	return result;
}
U32 LLMediaEntry::setWhiteList( const LLSD &whitelist )
{
    // If whitelist is undef, the whitelist is cleared
    if (whitelist.isUndefined()) 
	{
		mWhiteList.clear();
		return LSL_STATUS_OK;
	}

    // However, if the whitelist is an empty array, erase it.
    if (whitelist.isArray()) 
    {
        // *NOTE: This code is VERY similar to the setWhitelist above.
        // IF YOU CHANGE THIS IMPLEMENTATION, BE SURE TO CHANGE THE OTHER!
        U32 size = 0;
        U32 count = 0;
        // First check to make sure the size and count constraints are not violated
        LLSD::array_const_iterator iter = whitelist.beginArray();
        LLSD::array_const_iterator end = whitelist.endArray();
        for ( ; iter < end; ++iter) 
        {
            const std::string &entry = (*iter).asString();
            size += entry.length() + 1; // Include one for \0
            count ++;
            if (size > MAX_WHITELIST_SIZE || count > MAX_WHITELIST_COUNT) 
			{
                return LSL_STATUS_BOUNDS_ERROR;
            }
        }
        // Next clear the vector
        mWhiteList.clear();
        // Then re-iterate and copy entries
        iter = whitelist.beginArray();
        for ( ; iter < end; ++iter)
        {
            const std::string &entry = (*iter).asString();
            mWhiteList.push_back(entry);
        }
        return LSL_STATUS_OK;
    }
    else 
	{
        return LSL_STATUS_MALFORMED_PARAMS;
    }
}
void LLPanelClassifiedEdit::fillIn(const LLSD& key)
{
	setAvatarId(gAgent.getID());

	if(key.isUndefined())
	{
		setPosGlobal(gAgent.getPositionGlobal());

		LLUUID snapshot_id = LLUUID::null;
		std::string desc;
		LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();

		if(parcel)
		{
			desc = parcel->getDesc();
			snapshot_id = parcel->getSnapshotID();
		}

		std::string region_name = LLTrans::getString("ClassifiedUpdateAfterPublish");
		LLViewerRegion* region = gAgent.getRegion();
		if (region)
		{
			region_name = region->getName();
		}

		getChild<LLUICtrl>("classified_name")->setValue(makeClassifiedName());
		getChild<LLUICtrl>("classified_desc")->setValue(desc);
		setSnapshotId(snapshot_id);
		setClassifiedLocation(createLocationText(getLocationNotice(), region_name, getPosGlobal()));
		// server will set valid parcel id
		setParcelId(LLUUID::null);
	}
	else
	{
		setClassifiedId(key["classified_id"]);
		setClassifiedName(key["name"]);
		setDescription(key["desc"]);
		setSnapshotId(key["snapshot_id"]);
		setCategory((U32)key["category"].asInteger());
		setContentType((U32)key["content_type"].asInteger());
		setClassifiedLocation(key["location_text"]);
		getChild<LLUICtrl>("auto_renew")->setValue(key["auto_renew"]);
		getChild<LLUICtrl>("price_for_listing")->setValue(key["price_for_listing"].asInteger());
	}
}
bool LLFlatListView::insertItemAfter(LLPanel* after_item, LLPanel* item_to_add, const LLSD& value /*= LLUUID::null*/)
{
	if (!after_item) return false;
	if (!item_to_add) return false;
	if (value.isUndefined()) return false;

	if (mItemPairs.empty()) return false;

	//force uniqueness of items, easiest check but unreliable
	if (item_to_add->getParent() == mItemsPanel) return false;

	item_pair_t* after_pair = getItemPair(after_item);
	if (!after_pair) return false;

	item_pair_t* new_pair = new item_pair_t(item_to_add, value);
	if (after_pair == mItemPairs.back())
	{
		mItemPairs.push_back(new_pair);
		mItemsPanel->addChild(item_to_add);
	}
	else
	{
		pairs_iterator_t it = mItemPairs.begin();
		for (; it != mItemPairs.end(); ++it)
		{
			if (*it == after_pair)
			{
				// insert new elements before the element at position of passed iterator.
				mItemPairs.insert(++it, new_pair);
				mItemsPanel->addChild(item_to_add);
				break;
			}
		}
	}

	//_4 is for MASK
	item_to_add->setMouseDownCallback(boost::bind(&LLFlatListView::onItemMouseClick, this, new_pair, _4));
	item_to_add->setRightMouseDownCallback(boost::bind(&LLFlatListView::onItemRightMouseClick, this, new_pair, _4));

	rearrangeItems();
	notifyParentItemsRectChanged();
	return true;
}
bool LLTextureEntry::updateMediaData(const LLSD& media_data)
{
	if (media_data.isUndefined())
	{
		// clear the media data
        clearMediaData();
		return false;
	}
	else {
		mMediaFlags |= MF_HAS_MEDIA;
		if (mMediaEntry == NULL)
		{
			mMediaEntry = new LLMediaEntry;
		}
        // *NOTE: this will *clobber* all of the fields in mMediaEntry 
        // with whatever fields are present (or not present) in media_data!
 		mMediaEntry->fromLLSD(media_data);
		return true;
	}
}
//static
void LLFloaterTeleportHistory::loadFile(const std::string &file_name)
{
    LLFloaterTeleportHistory *pFloaterHistory = LLFloaterTeleportHistory::findInstance();
    if(!pFloaterHistory)
        return;

    LLScrollListCtrl* pScrollList = pFloaterHistory->mPlacesList;
    if(!pScrollList)
        return;

    std::string temp_str(gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter() + file_name);

    llifstream file(temp_str);

    if (file.is_open())
    {
        LL_INFOS() << "Loading "<< file_name << " file at " << temp_str << LL_ENDL;
        LLSD data;
        LLSDSerialize::fromXML(data, file);
        if (data.isUndefined())
        {
            LL_INFOS() << "file missing, ill-formed, "
                       "or simply undefined; not reading the"
                       " file" << LL_ENDL;
        }
        else
        {
            const S32 max_entries = gSavedSettings.getS32("TeleportHistoryMaxEntries");
            const S32 num_entries = llmin(max_entries,(const S32)data.size());
            pScrollList->clear();
            for(S32 i = 0; i < num_entries; i++) //Lower entry = newer
            {
                pScrollList->addElement(data[i], ADD_BOTTOM);
            }
            pScrollList->deselectAllItems(TRUE);
            pFloaterHistory->mID = pScrollList->getItemCount();
            pFloaterHistory->setButtonsEnabled(FALSE);
        }
    }
}
Exemple #28
0
LLSavedLoginEntry::LLSavedLoginEntry(const LLSD& entry_data)
{
	if (entry_data.isUndefined() || !entry_data.isMap())
	{
		throw std::invalid_argument("Cannot create a null login entry.");
	}
	if (!entry_data.has("firstname"))
	{
		throw std::invalid_argument("Missing firstname key.");
	}
	if (!entry_data.has("lastname"))
	{
		throw std::invalid_argument("Missing lastname key.");
	}
	if (!entry_data.has("grid"))
	{
		throw std::invalid_argument("Missing grid key.");
	}
	if (!entry_data.has("password"))
	{
		throw std::invalid_argument("Missing password key.");
	}
	if (!entry_data.get("grid").isInteger())
	{
		throw std::invalid_argument("grid key is not integer.");
	}
	if (!entry_data.get("firstname").isString())
	{
		throw std::invalid_argument("firstname key is not string.");
	}
	if (!entry_data.get("lastname").isString())
	{
		throw std::invalid_argument("lastname key is not string.");
	}
	if (!(entry_data.get("password").isUndefined() || entry_data.get("password").isBinary()))
	{
		throw std::invalid_argument("password key is neither blank nor binary.");
	}
	mEntry = entry_data;
}
void LLReqID::stamp(LLSD& response) const
{
    if (! (response.isUndefined() || response.isMap()))
    {
        // If 'response' was previously completely empty, it's okay to
        // turn it into a map. If it was already a map, then it should be
        // okay to add a key. But if it was anything else (e.g. a scalar),
        // assigning a ["reqid"] key will DISCARD the previous value,
        // replacing it with a map. That would be Bad.
        LL_INFOS("LLReqID") << "stamp(" << mReqid << ") leaving non-map response unmodified: "
                            << response << LL_ENDL;
        return;
    }
    LLSD oldReqid(response["reqid"]);
    if (! (oldReqid.isUndefined() || llsd_equals(oldReqid, mReqid)))
    {
        LL_INFOS("LLReqID") << "stamp(" << mReqid << ") preserving existing [\"reqid\"] value "
                            << oldReqid << " in response: " << response << LL_ENDL;
        return;
    }
    response["reqid"] = mReqid;
}
//static
void LLParamSDParserUtilities::readSDValues(read_sd_cb_t cb, const LLSD& sd, LLInitParam::Parser::name_stack_t& stack)
{
	if (sd.isMap())
	{
		for (LLSD::map_const_iterator it = sd.beginMap();
			it != sd.endMap();
			++it)
		{
			stack.push_back(make_pair(it->first, true));
			readSDValues(cb, it->second, stack);
			stack.pop_back();
		}
	}
	else if (sd.isArray())
	{
		for (LLSD::array_const_iterator it = sd.beginArray();
			it != sd.endArray();
			++it)
		{
			stack.push_back(make_pair(std::string(), true));
			readSDValues(cb, *it, stack);
			stack.pop_back();
		}
	}
	else if (sd.isUndefined())
	{
		if (!cb.empty())
		{
			cb(NO_VALUE_MARKER, stack);
		}
	}
	else
	{
		if (!cb.empty())
		{
			cb(sd, stack);
		}
	}
}