Esempio n. 1
0
void URITestObject::test<4>()
{
    // scheme w/o paths
    checkParts(LLURI("mailto:[email protected]"),
               "mailto", "*****@*****.**", "", "");
    checkParts(LLURI("silly://abc/def?foo"),
               "silly", "//abc/def?foo", "", "");
}
Esempio n. 2
0
void URITestObject::test<6>()
{
    // path section
    checkParts(LLURI("http://host/a/b/"),
               "http", "//host/a/b/", "host", "/a/b/");

    checkParts(LLURI("http://host/a%3Fb/"),
               "http", "//host/a?b/", "host", "/a?b/");

    checkParts(LLURI("http://host/a:b/"),
               "http", "//host/a:b/", "host", "/a:b/");
}
Esempio n. 3
0
void URITestObject::test<7>()
{
    // query string
    checkParts(LLURI("http://host/?"),
               "http", "//host/?", "host", "/", "");

    checkParts(LLURI("http://host/?x"),
               "http", "//host/?x", "host", "/", "x");

    checkParts(LLURI("http://host/??"),
               "http", "//host/??", "host", "/", "?");

    checkParts(LLURI("http://host/?%3F"),
               "http", "//host/??", "host", "/", "?");
}
Esempio n. 4
0
void URITestObject::test<5>()
{
    // authority section
    checkParts(LLURI("http:///"),
               "http", "///", "", "/");

    checkParts(LLURI("http://abc"),
               "http", "//abc", "abc", "");

    checkParts(LLURI("http://a%2Fb/cd"),
               "http", "//a/b/cd", "a/b", "/cd");

    checkParts(LLURI("http://host?"),
               "http", "//host?", "host", "");
}
void LLUpdateDownloader::Implementation::resume(void)
{
	mCancelled = false;

	if(isDownloading()) {
		mClient.downloadError("download in progress");
	}

	mDownloadRecordPath = downloadMarkerPath();
	llifstream dataStream(mDownloadRecordPath);
	if(!dataStream) {
		mClient.downloadError("no download marker");
		return;
	}
	
	LLSDSerialize::fromXMLDocument(mDownloadData, dataStream);
	
	if(!mDownloadData.asBoolean()) {
		mClient.downloadError("no download information in marker");
		return;
	}
	
	std::string filePath = mDownloadData["path"].asString();
	try {
		if(LLFile::isfile(filePath)) {		
			llstat fileStatus;
			LLFile::stat(filePath, &fileStatus);
			if(fileStatus.st_size != mDownloadData["size"].asInteger()) {
				resumeDownloading(fileStatus.st_size);
			} else if(!validateDownload()) {
				LLFile::remove(filePath);
				download(LLURI(mDownloadData["url"].asString()), 
						 mDownloadData["hash"].asString(),
						 mDownloadData["update_version"].asString(),
						 mDownloadData["required"].asBoolean());
			} else {
				mClient.downloadComplete(mDownloadData);
			}
		} else {
			download(LLURI(mDownloadData["url"].asString()), 
					 mDownloadData["hash"].asString(),
					 mDownloadData["update_version"].asString(),
					 mDownloadData["required"].asBoolean());
		}
	} catch(DownloadError & e) {
		mClient.downloadError(e.what());
	}
}
Esempio n. 6
0
// virtual
void LLAudioEngine::startInternetStream(const std::string& url)
{
	llinfos << "entered startInternetStream()" << llendl;

	if (!mInternetStreamMedia)
	{
		LLMediaManager* mgr = LLMediaManager::getInstance();
		if (mgr)
		{
			mInternetStreamMedia = mgr->createSourceFromMimeType(LLURI(url).scheme(), "audio/mpeg"); // assumes that whatever media implementation supports mp3 also supports vorbis.
			llinfos << "mInternetStreamMedia is now " << mInternetStreamMedia << llendl;
		}
	}

	if(!mInternetStreamMedia)
		return;
	
	if (!url.empty()) {
		llinfos << "Starting internet stream: " << url << llendl;
		mInternetStreamURL = url;
#if LL_QUICKTIME_ENABLED
		mInternetStreamMedia->navigateTo ( createListenPls(url) );
#else
		mInternetStreamMedia->navigateTo ( url );
#endif
		llinfos << "Playing....." << llendl;		
		mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_START);
		mInternetStreamMedia->updateMedia();
	} else {
		llinfos << "setting stream to NULL"<< llendl;
		mInternetStreamURL.clear();
		mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP);
		mInternetStreamMedia->updateMedia();
	}
}
std::string LLUrlEntryRegion::getLocation(const std::string &url) const
{
	LLSD path_array = LLURI(url).pathArray();
	std::string region_name = unescapeUrl(path_array[2]);
	LL_DEBUGS("UrlEntry") << "location " << region_name << LL_ENDL;
	return region_name;
}
Esempio n. 8
0
// virtual
LLSD LLAssetStorage::getPendingDetailsImpl(const LLAssetStorage::request_list_t* requests,
										LLAssetType::EType asset_type,
										const std::string& detail_prefix) const
{
	LLSD details;
	if (requests)
	{
		request_list_t::const_iterator it = requests->begin();
		request_list_t::const_iterator end = requests->end();
		for ( ; it != end; ++it)
		{
			LLAssetRequest* req = *it;
			if (   (LLAssetType::AT_NONE == asset_type)
				|| (req->getType() == asset_type) )
			{
				LLSD row = req->getTerseDetails();

				std::ostringstream detail;
				detail	<< detail_prefix << "/" << LLAssetType::lookup(req->getType())
						<< "/" << req->getUUID();
				row["detail"] = LLURI(detail.str());

				details.append(row);
			}
		}
	}
	return details;
}
Esempio n. 9
0
void LLAres::rewriteURI(const std::string &uri, UriRewriteResponder *resp)
{
	llinfos << "Rewriting " << uri << llendl;

	resp->mUri = LLURI(uri);
	search("_" + resp->mUri.scheme() + "._tcp." + resp->mUri.hostName(),
		   RES_SRV, resp);
}
Esempio n. 10
0
void HippoGridInfo::setLoginUri(const std::string& loginUri)
{
	std::string uri = loginUri;
	mLoginUri = sanitizeUri(uri);
	if (utf8str_tolower(LLURI(uri).hostName()) == "login.agni.lindenlab.com")
	{
		mIsInProductionGrid = true;
	}
}
Esempio n. 11
0
void HippoGridInfo::setLoginUri(const std::string& loginUri)
{
	mLoginUri = sanitizeUri(loginUri);
	if (utf8str_tolower(LLURI(mLoginUri).hostName()) == "login.agni.lindenlab.com")
	{
		mIsInProductionGrid = true;
		useHttps();
		setPlatform(PLATFORM_SECONDLIFE);
	}
	else if (utf8str_tolower(LLURI(mLoginUri).hostName()) == "login.aditi.lindenlab.com")
	{
		useHttps();
		setPlatform(PLATFORM_SECONDLIFE);
	}
	else if (utf8str_tolower(LLURI(mLoginUri).hostName()) == "login.avination.com" ||
		utf8str_tolower(LLURI(mLoginUri).hostName()) == "login.avination.net")
	{
		mIsInAvination = true;
		useHttps();
	}
}
Esempio n. 12
0
// virtual
void LLAudioEngine::startInternetStream(const std::string& url)
{
	llinfos << "entered startInternetStream()" << llendl;

	if (!mInternetStreamMedia)
	{
		LLMediaManager* mgr = LLMediaManager::getInstance();
		if (mgr)
		{
			mInternetStreamMedia = mgr->createSourceFromMimeType(LLURI(url).scheme(), "audio/mpeg"); // assumes that whatever media implementation supports mp3 also supports vorbis.
			llinfos << "mInternetStreamMedia is now " << mInternetStreamMedia << llendl;
		}
	}

	if(!mInternetStreamMedia)
	{
		return;
	}
	// Check for a dead stream from gstreamer, just in case
	else if(getStatus() == LLMediaBase::STATUS_DEAD)
	{
		llinfos << "don't play dead stream urls"<< llendl;
		mInternetStreamURL.clear();
		mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP);
		mInternetStreamMedia->updateMedia();
		stopInternetStream();
	}
	else if (url.empty())
	{
		llinfos << "url is emptly. Setting stream to NULL"<< llendl;
		mInternetStreamURL.clear();
		mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP);
		mInternetStreamMedia->updateMedia();
	}
	// Stream appears to be good, attempting to play
	else
	{
		// stop any other stream first
		stopInternetStream();

		llinfos << "Starting internet stream: " << url << llendl;
		mInternetStreamURL = url;
		mInternetStreamMedia->navigateTo(url);
		//llinfos << "Playing....." << llendl;		
		mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_START);
		mInternetStreamMedia->updateMedia();
		mStatus = LLMediaBase::STATUS_STARTED;
	}
}
Esempio n. 13
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;
}
void FSPanelLogin::loadLoginPage()
{
	if (!sInstance) return;

	LLURI login_page = LLURI(LLGridManager::getInstance()->getLoginPage());
	LLSD params(login_page.queryMap());

	LL_DEBUGS("AppInit") << "login_page: " << login_page << LL_ENDL;

	// Language
	params["lang"] = LLUI::getLanguage();

	// First Login?
	if (gSavedSettings.getBOOL("FirstLoginThisInstall"))
	{
		params["firstlogin"] = "******"; // not bool: server expects string TRUE
	}

	// Channel and Version
	params["version"] = llformat("%s (%d)",
								 LLVersionInfo::getShortVersion().c_str(),
								 LLVersionInfo::getBuild());
	params["channel"] = LLVersionInfo::getChannel();

	// Grid
	params["grid"] = LLGridManager::getInstance()->getGridId();

	// add OS info
	params["os"] = LLAppViewer::instance()->getOSInfo().getOSStringSimple();

	// sourceid
	params["sourceid"] = gSavedSettings.getString("sourceid");

	// Make an LLURI with this augmented info
	LLURI login_uri(LLURI::buildHTTP(login_page.authority(),
									 login_page.path(),
									 params));

	LLMediaCtrl* web_browser = sInstance->getChild<LLMediaCtrl>("login_html");
	if (web_browser->getCurrentNavUrl() != login_uri.asString())
	{
		LL_DEBUGS("AppInit") << "loading:    " << login_uri << LL_ENDL;
		web_browser->navigateTo( login_uri.asString(), HTTP_CONTENT_TEXT_HTML );
	}
}
std::string LLUrlEntryRegion::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
{
	//
	// we handle SLURLs in the following formats:
	//   - secondlife:///app/region/Place/X/Y/Z
	//   - secondlife:///app/region/Place/X/Y
	//   - secondlife:///app/region/Place/X
	//   - secondlife:///app/region/Place
	//

	LLSD path_array = LLURI(url).pathArray();
	S32 path_parts = path_array.size();

	if (path_parts < 3) // no region name
	{
		llwarns << "Failed to parse url [" << url << "]" << llendl;
		return url;
	}

	std::string label = unescapeUrl(path_array[2]); // region name

	if (path_parts > 3) // secondlife:///app/region/Place/X
	{
		std::string x = path_array[3];
		label += " (" + x;

		if (path_parts > 4) // secondlife:///app/region/Place/X/Y
		{
			std::string y = path_array[4];
			label += "," + y;

			if (path_parts > 5) // secondlife:///app/region/Place/X/Y/Z
			{
				std::string z = path_array[5];
				label = label + "," + z;
			}
		}

		label += ")";
	}

	return label;
}
Esempio n. 16
0
void URITestObject::test<18>()
{
    LLURI u("GIS:///app/login?first_name=Testert4&last_name=Tester&web_login_key=test");
    // if GIS is the scheme, LLURI should parse /app/login as path, with no authority
    ensure_equals("scheme",		u.scheme(),		"GIS");
    ensure_equals("authority",	u.authority(),	"");
    ensure_equals("path",		u.path(),		"/app/login");
    ensure_equals("pathmap",	u.pathArray()[0].asString(),	"app");
    ensure_equals("pathmap",	u.pathArray()[1].asString(),	"login");
    ensure_equals("query",		u.query(),		"first_name=Testert4&last_name=Tester&web_login_key=test");
    ensure_equals("query map element", u.queryMap()["last_name"].asString(), "Tester");

    u = LLURI("GIS://Da Boom/128/128/128");
    // if GIS is the scheme, LLURI should parse /128/128/128 as path, with Da Boom as authority
    ensure_equals("scheme",		u.scheme(),		"GIS");
    ensure_equals("authority",	u.authority(),	"Da Boom");
    ensure_equals("path",		u.path(),		"/128/128/128");
    ensure_equals("pathmap",	u.pathArray()[0].asString(),	"128");
    ensure_equals("pathmap",	u.pathArray()[1].asString(),	"128");
    ensure_equals("pathmap",	u.pathArray()[2].asString(),	"128");
    ensure_equals("query",		u.query(),		"");
}
std::string LLUrlEntryParcel::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
{
	LLSD path_array = LLURI(url).pathArray();
	S32 path_parts = path_array.size();

	if (path_parts < 3) // no parcel id
	{
		llwarns << "Failed to parse url [" << url << "]" << llendl;
		return url;
	}

	std::string parcel_id_string = unescapeUrl(path_array[2]); // parcel id

	// Add an observer to call LLUrlLabelCallback when we have parcel name.
	addObserver(parcel_id_string, url, cb);

	LLUUID parcel_id(parcel_id_string);

	sendParcelInfoRequest(parcel_id);

	return unescapeUrl(url);
}
Esempio n. 18
0
// static
bool LLMediaEntry::checkUrlAgainstWhitelist(const std::string& url, 
                                            const std::vector<std::string> &whitelist)
{
    bool passes = true;
    // *NOTE: no entries?  Don't check
    if (whitelist.size() > 0) 
    {
        passes = false;
            
        // Case insensitive: the reason why we toUpper both this and the
        // filter
        std::string candidate_url = url;
        // Use lluri to see if there is a path part in the candidate URL.  No path?  Assume "/"
        LLURI candidate_uri(candidate_url);
        std::vector<std::string>::const_iterator iter = whitelist.begin();
        std::vector<std::string>::const_iterator end = whitelist.end();
        for ( ; iter < end; ++iter )
        {
            std::string filter = *iter;
                
            LLURI filter_uri(filter);
            bool scheme_passes = pattern_match( candidate_uri.scheme(), filter_uri.scheme() );
            if (filter_uri.scheme().empty()) 
            {
                filter_uri = LLURI(DEFAULT_URL_PREFIX + filter);
            }
            bool authority_passes = pattern_match( candidate_uri.authority(), filter_uri.authority() );
            bool path_passes = pattern_match( candidate_uri.escapedPath(), filter_uri.escapedPath() );

            if (scheme_passes && authority_passes && path_passes)
            {
                passes = true;
                break;
            }
        }
    }
    return passes;
}
Esempio n. 19
0
void LLPanelLogin::loadLoginPage()
{
	if (!sInstance) return;
	

	std::string login_page = gHippoGridManager->getCurrentGrid()->getLoginPage();
	if (login_page.empty()) 
	{
		sInstance->setSiteIsAlive(false);
		return;
	}

	std::ostringstream oStr;
	oStr << login_page;
	
	// Use the right delimeter depending on how LLURI parses the URL
	LLURI login_page_uri = LLURI(login_page);
	std::string first_query_delimiter = "&";
	if (login_page_uri.queryMap().size() == 0)
	{
		first_query_delimiter = "?";
	}

	// Language
	std::string language = LLUI::getLanguage();
	oStr << first_query_delimiter<<"lang=" << language;
	
	// First Login?
	if (gSavedSettings.getBOOL("FirstLoginThisInstall"))
	{
		oStr << "&firstlogin=TRUE";
	}

	// Channel and Version
	std::string version = llformat("%d.%d.%d %s",
		ViewerVersion::getImpMajorVersion(), ViewerVersion::getImpMinorVersion(),
		ViewerVersion::getImpPatchVersion(), ViewerVersion::getImpTestVersion().c_str() );

	char* curl_channel = curl_escape(gSavedSettings.getString("VersionChannelName").c_str(), 0);
	char* curl_version = curl_escape(version.c_str(), 0);

	oStr << "&channel=" << curl_channel;
	oStr << "&version=" << curl_version;

	curl_free(curl_channel);
	curl_free(curl_version);

	// Grid
	char* curl_grid = curl_escape(LLViewerLogin::getInstance()->getGridLabel().c_str(), 0);
	oStr << "&grid=" << curl_grid;
	curl_free(curl_grid);

	gViewerWindow->setMenuBackgroundColor(false, !LLViewerLogin::getInstance()->isInProductionGrid());
	//LLViewerLogin::getInstance()->setMenuColor();
	gLoginMenuBarView->setBackgroundColor(gMenuBarView->getBackgroundColor());


#if USE_VIEWER_AUTH
	LLURLSimString::sInstance.parse();

	std::string location;
	std::string region;
	std::string password;
	
	if (LLURLSimString::parse())
	{
		std::ostringstream oRegionStr;
		location = "specify";
		oRegionStr << LLURLSimString::sInstance.mSimName << "/" << LLURLSimString::sInstance.mX << "/"
			 << LLURLSimString::sInstance.mY << "/"
			 << LLURLSimString::sInstance.mZ;
		region = oRegionStr.str();
	}
	else
	{
		if (gSavedSettings.getBOOL("LoginLastLocation"))
		{
			location = "last";
		}
		else
		{
			location = "home";
		}
	}

	std::string firstname, lastname;

	if(gSavedSettings.getLLSD("UserLoginInfo").size() == 3)
	{
		LLSD cmd_line_login = gSavedSettings.getLLSD("UserLoginInfo");
		firstname = cmd_line_login[0].asString();
		lastname = cmd_line_login[1].asString();
		password = cmd_line_login[2].asString();
	}

	if (firstname.empty())
	{
		firstname = gSavedSettings.getString("FirstName");
	}
	
	if (lastname.empty())
	{
		lastname = gSavedSettings.getString("LastName");
	}
	
	char* curl_region = curl_escape(region.c_str(), 0);

	oStr <<"firstname=" << firstname <<
		"&lastname=" << lastname << "&location=" << location <<	"&region=" << curl_region;
	
	curl_free(curl_region);

	if (!password.empty())
	{
		oStr << "&password="******"&password=$1$" << password;
	}
	if (gAutoLogin)
	{
		oStr << "&auto_login=TRUE";
	}
	if (gSavedSettings.getBOOL("ShowStartLocation"))
	{
		oStr << "&show_start_location=TRUE";
	}	
	if (gSavedSettings.getBOOL("RememberPassword"))
	{
		oStr << "&remember_password=TRUE";
	}	
#ifndef	LL_RELEASE_FOR_DOWNLOAD
	oStr << "&show_grid=TRUE";
#else
	if (gSavedSettings.getBOOL("ForceShowGrid"))
		oStr << "&show_grid=TRUE";
#endif
#endif
	
	LLWebBrowserCtrl* web_browser = sInstance->getChild<LLWebBrowserCtrl>("login_html");
	
	// navigate to the "real" page 
	web_browser->navigateTo( oStr.str() );
}
Esempio n. 20
0
void LLPanelLogin::loadLoginPage()
{
	if (!sInstance) return;

	sInstance->updateGridCombo();
	std::ostringstream oStr;

	std::string login_page = gHippoGridManager->getConnectedGrid()->getLoginPage();
	if (login_page.empty())
	{
		sInstance->setSiteIsAlive(false);
		return;
	}

	oStr << login_page;

	// Use the right delimeter depending on how LLURI parses the URL
	LLURI login_page_uri = LLURI(login_page);
	std::string first_query_delimiter = "&";
	if (login_page_uri.queryMap().size() == 0)
	{
		first_query_delimiter = "?";
	}

	// Language
	std::string language = LLUI::getLanguage();
	oStr << first_query_delimiter<<"lang=" << language;

	// First Login?
	if (gSavedSettings.getBOOL("FirstLoginThisInstall"))
	{
		oStr << "&firstlogin=TRUE";
	}

	std::string version = llformat("%d.%d.%d (%d)",
						LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH, LL_VERSION_BUILD);

	if(login_page.find("secondlife.com") == -1) {
		oStr << "&channel=" << LLWeb::curlEscape(LL_CHANNEL);
		oStr << "&version=" << LLWeb::curlEscape(version);
	}

	// Grid
	oStr << "&grid=" << LLWeb::curlEscape(LLViewerLogin::getInstance()->getGridLabel());

	if (gHippoGridManager->getConnectedGrid()->isSecondLife()) {
		// find second life grid from login URI
		// yes, this is heuristic, but hey, it is just to get the right login page...
		std::string tmp = gHippoGridManager->getConnectedGrid()->getLoginUri();
		int i = tmp.find(".lindenlab.com");
		if (i != std::string::npos) {
			tmp = tmp.substr(0, i);
			i = tmp.rfind('.');
			if (i == std::string::npos)
				i = tmp.rfind('/');
			if (i != std::string::npos) {
				tmp = tmp.substr(i+1);
				oStr << "&grid=" << LLWeb::curlEscape(tmp);
			}
		}
	}
	
	gViewerWindow->setMenuBackgroundColor(false, !LLViewerLogin::getInstance()->isInProductionGrid());
	gLoginMenuBarView->setBackgroundColor(gMenuBarView->getBackgroundColor());


#if USE_VIEWER_AUTH
	LLURLSimString::sInstance.parse();

	std::string location;
	std::string region;
	std::string password;
	
	if (LLURLSimString::parse())
	{
		std::ostringstream oRegionStr;
		location = "specify";
		oRegionStr << LLURLSimString::sInstance.mSimName << "/" << LLURLSimString::sInstance.mX << "/"
			 << LLURLSimString::sInstance.mY << "/"
			 << LLURLSimString::sInstance.mZ;
		region = oRegionStr.str();
	}
	else
	{
		if (gSavedSettings.getBOOL("LoginLastLocation"))
		{
			location = "last";
		}
		else
		{
			location = "home";
		}
	}
	
	std::string firstname, lastname;

    if(gSavedSettings.getLLSD("UserLoginInfo").size() == 3)
    {
        LLSD cmd_line_login = gSavedSettings.getLLSD("UserLoginInfo");
		firstname = cmd_line_login[0].asString();
		lastname = cmd_line_login[1].asString();
        password = cmd_line_login[2].asString();
    }
    	
	if (firstname.empty())
	{
		firstname = gSavedSettings.getString("FirstName");
	}
	
	if (lastname.empty())
	{
		lastname = gSavedSettings.getString("LastName");
	}
	
	std::string curl_region = LLWeb::curlEscape(region);

	oStr <<"firstname=" << firstname <<
		"&lastname=" << lastname << "&location=" << location <<	"&region=" << curl_region;
	
	if (!password.empty())
	{
		oStr << "&password="******"&password=$1$" << password;
	}
	if (gAutoLogin)
	{
		oStr << "&auto_login=TRUE";
	}
	if (gSavedSettings.getBOOL("ShowStartLocation"))
	{
		oStr << "&show_start_location=TRUE";
	}	
	if (gSavedSettings.getBOOL("RememberPassword"))
	{
		oStr << "&remember_password=TRUE";
	}	
	BOOL show_server = sInstance ? sInstance->mShowServerCombo : FALSE;
	if (show_server || gSavedSettings.getBOOL("ForceShowGrid"))
	{
		oStr << "&show_grid=TRUE";
	}
#endif
	
	LLMediaCtrl* web_browser = sInstance->getChild<LLMediaCtrl>("login_html");
	
	// navigate to the "real" page 
	web_browser->navigateTo( oStr.str(), "text/html" );
}
Esempio n. 21
0
void LLPanelLogin::loadLoginPage()
{
	if (!sInstance) return;
	
	std::ostringstream oStr;

	LLViewerLogin* vl = LLViewerLogin::getInstance();
	std::string login_page = vl->getLoginPageURI();
	if (login_page.empty())
	{
		login_page = sInstance->getString( "real_url" );
		vl->setLoginPageURI(login_page);
	}
	oStr << login_page;
	
	// Use the right delimeter depending on how LLURI parses the URL
	LLURI login_page_uri = LLURI(login_page);
	std::string first_query_delimiter = "&";
	if (login_page_uri.queryMap().size() == 0)
	{
		first_query_delimiter = "?";
	}

	// Language
	std::string language = LLUI::getLanguage();
	oStr << first_query_delimiter<<"lang=" << language;
	
	// First Login?
	if (gSavedSettings.getBOOL("FirstLoginThisInstall"))
	{
		oStr << "&firstlogin=TRUE";
	}

	// Channel and Version
	std::string version = llformat("%d.%d.%d (%d)",
						LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH, LL_VIEWER_BUILD);

	char* curl_channel = curl_escape(LL_CHANNEL, 0);
	char* curl_version = curl_escape(version.c_str(), 0);
	char* curl_t = curl_escape(LLAppViewer::instance()->getWindowTitle().c_str(), 0);

	oStr << "&channel=" << curl_channel;
	oStr << "&version=" << curl_version;
	oStr << "&t=" << curl_t;
	if(LL_CHANNEL != EMERALD_RELEASE_CHANNEL)
		oStr << "&unsupported=1";

	curl_free(curl_channel);
	curl_free(curl_version);
	curl_free(curl_t);

	// grid=blah code was here. Due to the implementation of the Emerald login manager, sending
	// this information is a very bad idea. Don't do it.

	gViewerWindow->setMenuBackgroundColor(false, !LLViewerLogin::getInstance()->isInProductionGrid());
	gLoginMenuBarView->setBackgroundColor(gMenuBarView->getBackgroundColor());


#if USE_VIEWER_AUTH
	LLURLSimString::sInstance.parse();

	std::string location;
	std::string region;
	std::string password;
	
	if (LLURLSimString::parse())
	{
		std::ostringstream oRegionStr;
		location = "specify";
		oRegionStr << LLURLSimString::sInstance.mSimName << "/" << LLURLSimString::sInstance.mX << "/"
			 << LLURLSimString::sInstance.mY << "/"
			 << LLURLSimString::sInstance.mZ;
		region = oRegionStr.str();
	}
	else
	{
		if (gSavedSettings.getBOOL("LoginLastLocation"))
		{
			location = "last";
		}
		else
		{
			location = "home";
		}
	}
	
	std::string firstname, lastname;

    if(gSavedSettings.getLLSD("UserLoginInfo").size() == 3)
    {
        LLSD cmd_line_login = gSavedSettings.getLLSD("UserLoginInfo");
		firstname = cmd_line_login[0].asString();
		lastname = cmd_line_login[1].asString();
        password = cmd_line_login[2].asString();
    }
    	
	if (firstname.empty())
	{
		firstname = gSavedSettings.getString("FirstName");
	}
	
	if (lastname.empty())
	{
		lastname = gSavedSettings.getString("LastName");
	}
	
	char* curl_region = curl_escape(region.c_str(), 0);

	oStr <<"firstname=" << firstname <<
		"&lastname=" << lastname << "&location=" << location <<	"&region=" << curl_region;
	
	curl_free(curl_region);

	if (!password.empty())
	{
		oStr << "&password="******"&password=$1$" << password;
	}
	if (gAutoLogin)
	{
		oStr << "&auto_login=TRUE";
	}
	if (gSavedSettings.getBOOL("ShowStartLocation"))
	{
		oStr << "&show_start_location=TRUE";
	}	
	if (gSavedSettings.getBOOL("RememberPassword"))
	{
		oStr << "&remember_password=TRUE";
	}	
	BOOL show_server = sInstance ? sInstance->mShowServerCombo : FALSE;
	if (show_server || gSavedSettings.getBOOL("ForceShowGrid"))
	{
		oStr << "&show_grid=TRUE";
	}
#endif
	
	LLMediaCtrl* web_browser = sInstance->getChild<LLMediaCtrl>("login_html");
	
	// navigate to the "real" page 
	web_browser->navigateTo( oStr.str(), "text/html" );
}
Esempio n. 22
0
// resolve a simstring from a slurl
LLSLURL::LLSLURL(const std::string& slurl)
{
    // by default we go to agni.
    mType = INVALID;
    LL_INFOS("AppInit") << "SLURL: " << slurl << LL_ENDL;
    if(slurl == SIM_LOCATION_HOME)
    {
        mType = HOME_LOCATION;
    }
    else if(slurl.empty() || (slurl == SIM_LOCATION_LAST))
    {

        mType = LAST_LOCATION;
    }
    else
    {
        LLURI slurl_uri;
        // parse the slurl as a uri
        if(slurl.find(':') == std::string::npos)
        {
            // There may be no scheme ('secondlife:' etc.) passed in.  In that case
            // we want to normalize the slurl by putting the appropriate scheme
            // in front of the slurl.  So, we grab the appropriate slurl base
            // from the grid manager which may be http://slurl.com/secondlife/ for maingrid, or
            // https://<hostname>/region/ for Standalone grid (the word region, not the region name)
            // these slurls are typically passed in from the 'starting location' box on the login panel,
            // where the user can type in <regionname>/<x>/<y>/<z>
            std::string fixed_slurl = LLGridManager::getInstance()->getSLURLBase();
            // the slurl that was passed in might have a prepended /, or not.  So,
            // we strip off the prepended '/' so we don't end up with http://slurl.com/secondlife/<region>/<x>/<y>/<z>
            // or some such.

            if(slurl[0] == '/')
            {
                fixed_slurl += slurl.substr(1);
            }
            else
            {
                fixed_slurl += slurl;
            }
            // We then load the slurl into a LLURI form
            slurl_uri = LLURI(fixed_slurl);
        }
        else
        {
            // as we did have a scheme, implying a URI style slurl, we
            // simply parse it as a URI
            slurl_uri = LLURI(slurl);
        }

        LLSD path_array = slurl_uri.pathArray();

        // determine whether it's a maingrid URI or an Standalone/open style URI
        // by looking at the scheme.  If it's a 'secondlife:' slurl scheme or
        // 'sl:' scheme, we know it's maingrid

        // At the end of this if/else block, we'll have determined the grid,
        // and the slurl type (APP or LOCATION)
        if(slurl_uri.scheme() == LLSLURL::SLURL_SECONDLIFE_SCHEME)
        {
            // parse a maingrid style slurl.  We know the grid is maingrid
            // so grab it.
            // A location slurl for maingrid (with the special schemes) can be in the form
            // secondlife://<regionname>/<x>/<y>/<z>
            // or
            // secondlife://<Grid>/secondlife/<region>/<x>/<y>/<z>
            // where if grid is empty, it specifies Agni

            // An app style slurl for maingrid can be
            // secondlife://<Grid>/app/<app parameters>
            // where an empty grid implies Agni

            // we'll start by checking the top of the 'path' which will be
            // either 'app', 'secondlife', or <x>.

            // default to maingrid

            mGrid = MAINGRID;

            if ((path_array[0].asString() == LLSLURL::SLURL_SECONDLIFE_PATH) ||
                    (path_array[0].asString() == LLSLURL::SLURL_APP_PATH))
            {
                // it's in the form secondlife://<grid>/(app|secondlife)
                // so parse the grid name to derive the grid ID
                if (!slurl_uri.hostName().empty())
                {
                    mGrid = LLGridManager::getInstance()->getGridByLabel(slurl_uri.hostName());
                }
                else if(path_array[0].asString() == LLSLURL::SLURL_SECONDLIFE_PATH)
                {
                    // If the slurl is in the form secondlife:///secondlife/<region> form,
                    // then we are in fact on maingrid.
                    mGrid = MAINGRID;
                }
                else if(path_array[0].asString() == LLSLURL::SLURL_APP_PATH)
                {
                    // for app style slurls, where no grid name is specified, assume the currently
                    // selected or logged in grid.
                    mGrid =  LLGridManager::getInstance()->getGrid();
                }

                if(mGrid.empty())
                {
                    // we couldn't find the grid in the grid manager, so bail
                    return;
                }
                // set the type as appropriate.
                if(path_array[0].asString() == LLSLURL::SLURL_SECONDLIFE_PATH)
                {
                    mType = LOCATION;
                }
                else
                {
                    mType = APP;
                }
                path_array.erase(0);
            }
            else
            {
                // it wasn't a /secondlife/<region> or /app/<params>, so it must be secondlife://<region>
                // therefore the hostname will be the region name, and it's a location type
                mType = LOCATION;
                // 'normalize' it so the region name is in fact the head of the path_array
                path_array.insert(0, slurl_uri.hostName());
            }
        }
        else if((slurl_uri.scheme() == LLSLURL::SLURL_HTTP_SCHEME) ||
                (slurl_uri.scheme() == LLSLURL::SLURL_HTTPS_SCHEME) ||
                (slurl_uri.scheme() == LLSLURL::SLURL_X_GRID_LOCATION_INFO_SCHEME))
        {
            // *HACK: ignore http://secondlife.com/ URLs so that we can use
            // http://secondlife.com/app/ redirect URLs
            // This is only necessary while the server returns Release Note
            // urls using this format rather that pointing to the wiki
            if ((slurl_uri.scheme() == LLSLURL::SLURL_HTTP_SCHEME ||
                    slurl_uri.scheme() == LLSLURL::SLURL_HTTPS_SCHEME) &&
                    slurl_uri.hostName() == LLSLURL::SECONDLIFE_COM)
                return;

            // We're dealing with either a Standalone style slurl or slurl.com slurl
            if ((slurl_uri.hostName() == LLSLURL::SLURL_COM) ||
                    (slurl_uri.hostName() == LLSLURL::WWW_SLURL_COM) ||
                    (slurl_uri.hostName() == LLSLURL::MAPS_SECONDLIFE_COM))
            {
                // slurl.com implies maingrid
                mGrid = MAINGRID;
            }
            else
            {
                // As it's a Standalone grid/open, we will always have a hostname, as Standalone/open  style
                // urls are properly formed, unlike the stinky maingrid style
                mGrid = slurl_uri.hostName();
            }
            if (path_array.size() == 0)
            {
                // um, we need a path...
                return;
            }

            // we need to normalize the urls so
            // the path portion starts with the 'command' that we want to do
            // it can either be region or app.
            if ((path_array[0].asString() == LLSLURL::SLURL_REGION_PATH) ||
                    (path_array[0].asString() == LLSLURL::SLURL_SECONDLIFE_PATH))
            {
                // strip off 'region' or 'secondlife'
                path_array.erase(0);
                // it's a location
                mType = LOCATION;
            }
            else if (path_array[0].asString() == LLSLURL::SLURL_APP_PATH)
            {
                mType = APP;
                path_array.erase(0);
                // leave app appended.
            }
            else
            {
                // not a valid https/http/x-grid-location-info slurl, so it'll likely just be a URL
                return;
            }
        }
        else
        {
            // invalid scheme, so bail
            return;
        }


        if(path_array.size() == 0)
        {
            // we gotta have some stuff after the specifier as to whether it's a region or command
            return;
        }

        // now that we know whether it's an app slurl or a location slurl,
        // parse the slurl into the proper data structures.
        if(mType == APP)
        {
            // grab the app command type and strip it (could be a command to jump somewhere,
            // or whatever )
            mAppCmd = path_array[0].asString();
            path_array.erase(0);

            // Grab the parameters
            mAppPath = path_array;
            // and the query
            mAppQuery = slurl_uri.query();
            mAppQueryMap = slurl_uri.queryMap();
            return;
        }
        else if(mType == LOCATION)
        {
            // at this point, head of the path array should be [ <region>, <x>, <y>, <z> ] where x, y and z
            // are collectively optional
            // are optional
            mRegion = LLURI::unescape(path_array[0].asString());
            path_array.erase(0);

            // parse the x, y, z
            if(path_array.size() >= 3)
            {

                mPosition = LLVector3(path_array);
                if((F32(mPosition[VX]) < 0.f) ||
                        (mPosition[VX] > REGION_WIDTH_METERS) ||
                        (F32(mPosition[VY]) < 0.f) ||
                        (mPosition[VY] > REGION_WIDTH_METERS) ||
                        (F32(mPosition[VZ]) < 0.f) ||
                        (mPosition[VZ] > REGION_HEIGHT_METERS))
                {
                    mType = INVALID;
                    return;
                }

            }
            else
            {
                // if x, y and z were not fully passed in, go to the middle of the region.
                // teleport will adjust the actual location to make sure you're on the ground
                // and such
                mPosition = LLVector3(REGION_WIDTH_METERS/2, REGION_WIDTH_METERS/2, 0);
            }
        }
    }
}
Esempio n. 23
0
// virtual
S32 LLSDBinaryParser::doParse(std::istream& istr, LLSD& data) const
{
/**
 * Undefined: '!'<br>
 * Boolean: 't' for true 'f' for false<br>
 * Integer: 'i' + 4 bytes network byte order<br>
 * Real: 'r' + 8 bytes IEEE double<br>
 * UUID: 'u' + 16 byte unsigned integer<br>
 * String: 's' + 4 byte integer size + string<br>
 *  strings also secretly support the notation format
 * Date: 'd' + 8 byte IEEE double for seconds since epoch<br>
 * URI: 'l' + 4 byte integer size + string uri<br>
 * Binary: 'b' + 4 byte integer size + binary data<br>
 * Array: '[' + 4 byte integer size  + all values + ']'<br>
 * Map: '{' + 4 byte integer size  every(key + value) + '}'<br>
 *  map keys are serialized as s + 4 byte integer size + string or in the
 *  notation format.
 */
	char c;
	c = get(istr);
	if(!istr.good())
	{
		return 0;
	}
	S32 parse_count = 1;
	switch(c)
	{
	case '{':
	{
		S32 child_count = parseMap(istr, data);
		if((child_count == PARSE_FAILURE) || data.isUndefined())
		{
			parse_count = PARSE_FAILURE;
		}
		else
		{
			parse_count += child_count;
		}
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading binary map." << llendl;
			parse_count = PARSE_FAILURE;
		}
		break;
	}

	case '[':
	{
		S32 child_count = parseArray(istr, data);
		if((child_count == PARSE_FAILURE) || data.isUndefined())
		{
			parse_count = PARSE_FAILURE;
		}
		else
		{
			parse_count += child_count;
		}
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading binary array." << llendl;
			parse_count = PARSE_FAILURE;
		}
		break;
	}

	case '!':
		data.clear();
		break;

	case '0':
		data = false;
		break;

	case '1':
		data = true;
		break;

	case 'i':
	{
		U32 value_nbo = 0;
		read(istr, (char*)&value_nbo, sizeof(U32));	 /*Flawfinder: ignore*/
		data = (S32)ntohl(value_nbo);
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading binary integer." << llendl;
		}
		break;
	}

	case 'r':
	{
		F64 real_nbo = 0.0;
		read(istr, (char*)&real_nbo, sizeof(F64));	 /*Flawfinder: ignore*/
		data = ll_ntohd(real_nbo);
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading binary real." << llendl;
		}
		break;
	}

	case 'u':
	{
		LLUUID id;
		read(istr, (char*)(&id.mData), UUID_BYTES);	 /*Flawfinder: ignore*/
		data = id;
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading binary uuid." << llendl;
		}
		break;
	}

	case '\'':
	case '"':
	{
		std::string value;
		int cnt = deserialize_string_delim(istr, value, c);
		if(PARSE_FAILURE == cnt)
		{
			parse_count = PARSE_FAILURE;
		}
		else
		{
			data = value;
			account(cnt);
		}
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading binary (notation-style) string."
				<< llendl;
			parse_count = PARSE_FAILURE;
		}
		break;
	}

	case 's':
	{
		std::string value;
		if(parseString(istr, value))
		{
			data = value;
		}
		else
		{
			parse_count = PARSE_FAILURE;
		}
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading binary string." << llendl;
			parse_count = PARSE_FAILURE;
		}
		break;
	}

	case 'l':
	{
		std::string value;
		if(parseString(istr, value))
		{
			data = LLURI(value);
		}
		else
		{
			parse_count = PARSE_FAILURE;
		}
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading binary link." << llendl;
			parse_count = PARSE_FAILURE;
		}
		break;
	}

	case 'd':
	{
		F64 real = 0.0;
		read(istr, (char*)&real, sizeof(F64));	 /*Flawfinder: ignore*/
		data = LLDate(real);
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading binary date." << llendl;
			parse_count = PARSE_FAILURE;
		}
		break;
	}

	case 'b':
	{
		// We probably have a valid raw binary stream. determine
		// the size, and read it.
		U32 size_nbo = 0;
		read(istr, (char*)&size_nbo, sizeof(U32));	/*Flawfinder: ignore*/
		S32 size = (S32)ntohl(size_nbo);
		if(mCheckLimits && (size > mMaxBytesLeft))
		{
			parse_count = PARSE_FAILURE;
		}
		else
		{
			std::vector<U8> value;
			if(size > 0)
			{
				value.resize(size);
				account(fullread(istr, (char*)&value[0], size));
			}
			data = value;
		}
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading binary." << llendl;
			parse_count = PARSE_FAILURE;
		}
		break;
	}

	default:
		parse_count = PARSE_FAILURE;
		llinfos << "Unrecognized character while parsing: int(" << (int)c
			<< ")" << llendl;
		break;
	}
	if(PARSE_FAILURE == parse_count)
	{
		data.clear();
	}
	return parse_count;
}
Esempio n. 24
0
// virtual
S32 LLSDNotationParser::doParse(std::istream& istr, LLSD& data) const
{
	// map: { string:object, string:object }
	// array: [ object, object, object ]
	// undef: !
	// boolean: true | false | 1 | 0 | T | F | t | f | TRUE | FALSE
	// integer: i####
	// real: r####
	// uuid: u####
	// string: "g'day" | 'have a "nice" day' | s(size)"raw data"
	// uri: l"escaped"
	// date: d"YYYY-MM-DDTHH:MM:SS.FFZ"
	// binary: b##"ff3120ab1" | b(size)"raw data"
	char c;
	c = istr.peek();
	while(isspace(c))
	{
		// pop the whitespace.
		c = get(istr);
		c = istr.peek();
		continue;
	}
	if(!istr.good())
	{
		return 0;
	}
	S32 parse_count = 1;
	switch(c)
	{
	case '{':
	{
		S32 child_count = parseMap(istr, data);
		if((child_count == PARSE_FAILURE) || data.isUndefined())
		{
			parse_count = PARSE_FAILURE;
		}
		else
		{
			parse_count += child_count;
		}
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading map." << llendl;
			parse_count = PARSE_FAILURE;
		}
		break;
	}

	case '[':
	{
		S32 child_count = parseArray(istr, data);
		if((child_count == PARSE_FAILURE) || data.isUndefined())
		{
			parse_count = PARSE_FAILURE;
		}
		else
		{
			parse_count += child_count;
		}
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading array." << llendl;
			parse_count = PARSE_FAILURE;
		}
		break;
	}

	case '!':
		c = get(istr);
		data.clear();
		break;

	case '0':
		c = get(istr);
		data = false;
		break;

	case 'F':
	case 'f':
		ignore(istr);
		c = istr.peek();
		if(isalpha(c))
		{
			int cnt = deserialize_boolean(
				istr,
				data,
				NOTATION_FALSE_SERIAL,
				false);
			if(PARSE_FAILURE == cnt) parse_count = cnt;
			else account(cnt);
		}
		else
		{
			data = false;
		}
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading boolean." << llendl;
			parse_count = PARSE_FAILURE;
		}
		break;

	case '1':
		c = get(istr);
		data = true;
		break;

	case 'T':
	case 't':
		ignore(istr);
		c = istr.peek();
		if(isalpha(c))
		{
			int cnt = deserialize_boolean(istr,data,NOTATION_TRUE_SERIAL,true);
			if(PARSE_FAILURE == cnt) parse_count = cnt;
			else account(cnt);
		}
		else
		{
			data = true;
		}
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading boolean." << llendl;
			parse_count = PARSE_FAILURE;
		}
		break;

	case 'i':
	{
		c = get(istr);
		S32 integer = 0;
		istr >> integer;
		data = integer;
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading integer." << llendl;
			parse_count = PARSE_FAILURE;
		}
		break;
	}

	case 'r':
	{
		c = get(istr);
		F64 real = 0.0;
		istr >> real;
		data = real;
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading real." << llendl;
			parse_count = PARSE_FAILURE;
		}
		break;
	}

	case 'u':
	{
		c = get(istr);
		LLUUID id;
		istr >> id;
		data = id;
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading uuid." << llendl;
			parse_count = PARSE_FAILURE;
		}
		break;
	}

	case '\"':
	case '\'':
	case 's':
		if(!parseString(istr, data))
		{
			parse_count = PARSE_FAILURE;
		}
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading string." << llendl;
			parse_count = PARSE_FAILURE;
		}
		break;

	case 'l':
	{
		c = get(istr); // pop the 'l'
		c = get(istr); // pop the delimiter
		std::string str;
		int cnt = deserialize_string_delim(istr, str, c);
		if(PARSE_FAILURE == cnt)
		{
			parse_count = PARSE_FAILURE;
		}
		else
		{
			data = LLURI(str);
			account(cnt);
		}
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading link." << llendl;
			parse_count = PARSE_FAILURE;
		}
		break;
	}

	case 'd':
	{
		c = get(istr); // pop the 'd'
		c = get(istr); // pop the delimiter
		std::string str;
		int cnt = deserialize_string_delim(istr, str, c);
		if(PARSE_FAILURE == cnt)
		{
			parse_count = PARSE_FAILURE;
		}
		else
		{
			data = LLDate(str);
			account(cnt);
		}
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading date." << llendl;
			parse_count = PARSE_FAILURE;
		}
		break;
	}

	case 'b':
		if(!parseBinary(istr, data))
		{
			parse_count = PARSE_FAILURE;
		}
		if(istr.fail())
		{
			llinfos << "STREAM FAILURE reading data." << llendl;
			parse_count = PARSE_FAILURE;
		}
		break;

	default:
		parse_count = PARSE_FAILURE;
		llinfos << "Unrecognized character while parsing: int(" << (int)c
			<< ")" << llendl;
		break;
	}
	if(PARSE_FAILURE == parse_count)
	{
		data.clear();
	}
	return parse_count;
}
Esempio n. 25
0
std::string LLUrlEntryRegion::getLocation(const std::string &url) const
{
	LLSD path_array = LLURI(url).pathArray();
	std::string region_name = unescapeUrl(path_array[2]);
	return region_name;
}
Esempio n. 26
0
void LLPanelLogin::loadLoginPage()
{
	if (!sInstance) return;
	
	std::ostringstream oStr;

	std::string login_page = LLGridManager::getInstance()->getLoginPage();

	oStr << login_page;
	
	// Use the right delimeter depending on how LLURI parses the URL
	LLURI login_page_uri = LLURI(login_page);
	
	std::string first_query_delimiter = "&";
	if (login_page_uri.queryMap().size() == 0)
	{
		first_query_delimiter = "?";
	}

	// Language
	std::string language = LLUI::getLanguage();
	oStr << first_query_delimiter<<"lang=" << language;
	
	// First Login?
	if (gSavedSettings.getBOOL("FirstLoginThisInstall"))
	{
		oStr << "&firstlogin=TRUE";
	}

	// Channel and Version
	std::string version = llformat("%s (%d)",
								   LLVersionInfo::getShortVersion().c_str(),
								   LLVersionInfo::getBuild());

	char* curl_channel ;
	char* curl_version = curl_escape(version.c_str(), 0);

	if(strcmp(LLVersionInfo::getChannel().c_str(), LL_CHANNEL))
	{
		curl_channel = curl_escape(LLVersionInfo::getChannel().c_str(), 0);
	}
	else //if LL_CHANNEL, direct it to "Second Life Beta Viewer".
	{
		curl_channel = curl_escape("Second Life Beta Viewer", 0);		
	}
	oStr << "&channel=" << curl_channel;
	oStr << "&version=" << curl_version;
	
	curl_free(curl_channel);
	curl_free(curl_version);

	// Grid
	char* curl_grid = curl_escape(LLGridManager::getInstance()->getGridLabel().c_str(), 0);
	oStr << "&grid=" << curl_grid;
	curl_free(curl_grid);
	
	// add OS info
	char * os_info = curl_escape(LLAppViewer::instance()->getOSInfo().getOSStringSimple().c_str(), 0);
	oStr << "&os=" << os_info;
	curl_free(os_info);
	
	gViewerWindow->setMenuBackgroundColor(false, !LLGridManager::getInstance()->isInProductionGrid());
	
	LLMediaCtrl* web_browser = sInstance->getChild<LLMediaCtrl>("login_html");
	if (web_browser->getCurrentNavUrl() != oStr.str())
	{
		web_browser->navigateTo( oStr.str(), "text/html" );
	}
}
Esempio n. 27
0
void URITestObject::test<2>()
{
    // empty string
    checkParts(LLURI(""), "", "", "", "");
}
Esempio n. 28
0
void LLPanelLogin::loadLoginPage()
{
	if (!sInstance) return;

 	sInstance->updateGridCombo();

	std::string login_page_str = gHippoGridManager->getCurrentGrid()->getLoginPage();
	if (login_page_str.empty())
	{
		sInstance->setSiteIsAlive(false);
		return;
	}
  
	// Use the right delimeter depending on how LLURI parses the URL
	LLURI login_page = LLURI(login_page_str);
	LLSD params(login_page.queryMap());
 
	LL_DEBUGS("AppInit") << "login_page: " << login_page << LL_ENDL;

 	// Language
	params["lang"] = LLUI::getLanguage();
 
 	// First Login?
 	if (gSavedSettings.getBOOL("FirstLoginThisInstall"))
	{
		params["firstlogin"] = "******"; // not bool: server expects string TRUE
 	}
 
	params["version"]= llformat("%d.%d.%d (%d)",
				gVersionMajor, gVersionMinor, gVersionPatch, gVersionBuild);
	params["channel"] = gVersionChannel;

	// Grid

	if (gHippoGridManager->getCurrentGrid()->isSecondLife()) {
		// find second life grid from login URI
		// yes, this is heuristic, but hey, it is just to get the right login page...
		std::string tmp = gHippoGridManager->getCurrentGrid()->getLoginUri();
		int i = tmp.find(".lindenlab.com");
		if (i != std::string::npos) {
			tmp = tmp.substr(0, i);
			i = tmp.rfind('.');
			if (i == std::string::npos)
				i = tmp.rfind('/');
			if (i != std::string::npos) {
				tmp = tmp.substr(i+1);
				params["grid"] = tmp;
			}
		}
	}
	else if (gHippoGridManager->getCurrentGrid()->isOpenSimulator())
	{
		params["grid"] = gHippoGridManager->getCurrentGrid()->getGridNick();
	}
	else if (gHippoGridManager->getCurrentGrid()->getPlatform() == HippoGridInfo::PLATFORM_AURORA)
	{
		params["grid"] = LLViewerLogin::getInstance()->getGridLabel();
	}
	
	// add OS info
	params["os"] = LLAppViewer::instance()->getOSInfo().getOSStringSimple();
		
	// Make an LLURI with this augmented info
	LLURI login_uri(LLURI::buildHTTP(login_page.authority(),
									 login_page.path(),
									 params));
	
	gViewerWindow->setMenuBackgroundColor(false, !LLViewerLogin::getInstance()->isInProductionGrid());
	gLoginMenuBarView->setBackgroundColor(gMenuBarView->getBackgroundColor());

	std::string singularity_splash_uri = gSavedSettings.getString("SingularitySplashPagePrefix");
	if (!singularity_splash_uri.empty())
	{
		params["original_page"] = login_uri.asString();
		login_uri = LLURI::buildHTTP(singularity_splash_uri, gSavedSettings.getString("SingularitySplashPagePath"), params);
	}

	LLMediaCtrl* web_browser = sInstance->getChild<LLMediaCtrl>("login_html");
	if (web_browser->getCurrentNavUrl() != login_uri.asString())
	{
		LL_DEBUGS("AppInit") << "loading:    " << login_uri << LL_ENDL;
		web_browser->navigateTo( login_uri.asString(), "text/html" );
	}
}
Esempio n. 29
0
// resolve a simstring from a slurl
LLSLURL::LLSLURL(const std::string& slurl)
: mHypergrid(false)
{
	// by default we go to agni.
	mType = INVALID;
	LL_INFOS("AppInit") << "SLURL: " << slurl << LL_ENDL;
	LL_DEBUGS("SLURL") << "SLURL: " << slurl << LL_ENDL;
	if(slurl == SIM_LOCATION_HOME)
	{
		mType = HOME_LOCATION;
	}
	else if(slurl.empty() || (slurl == SIM_LOCATION_LAST) )
	{
		mType = LAST_LOCATION;
	}
	else
	{
		LLURI slurl_uri;
		// parse the slurl as a uri
		if(slurl.find("://") == std::string::npos)
		{
			// There may be no scheme ('secondlife:' etc.) passed in.  In that case
			// we want to normalize the slurl by putting the appropriate scheme
			// in front of the slurl.  So, we grab the appropriate slurl base
			// from the grid manager which may be http://slurl.com/secondlife/ for maingrid, or
			// https://<hostname>/region/ for Standalone grid (the word region, not the region name)
			// these slurls are typically passed in from the 'starting location' box on the login panel,
			// where the user can type in <regionname>/<x>/<y>/<z>
			std::string fixed_slurl = LLGridManager::getInstance()->getSLURLBase();
			// the slurl that was passed in might have a prepended /, or not.  So,
			// we strip off the prepended '/' so we don't end up with http://slurl.com/secondlife/<region>/<x>/<y>/<z>
			// or some such.

			if(slurl[0] == '/')
			{
				fixed_slurl += slurl.substr(1);
			}
			// <FS:LO> FIRE-6898 - Explicitly ignore data URI's
			else if(slurl.substr(0,4) == "data")
			{
				fixed_slurl = slurl;
			}
			// </FS:LO>
			else
			{
				fixed_slurl += slurl;
			}
			// We then load the slurl into a LLURI form
			slurl_uri = LLURI(fixed_slurl);
		}
		else if (slurl.find("|!!") == std::string::npos && slurl.find("hop://") == std::string::npos)
		{
			// as we did have a scheme, implying a URI style slurl, we
			// simply parse it as a URI
			slurl_uri = LLURI(slurl);
			LL_DEBUGS("SLURL") << "standard slurl " << slurl<< LL_ENDL;
		}
		else
		{
			mHypergrid = true;

			std::string hop = slurl;
			std::string match = "|!!";
			size_t pos = hop.find(match);
			if (pos != std::string::npos)
				hop.erase( 0,pos+match.length());

			boost::replace_all(hop, "|", ":");
			boost::replace_all(hop, "!", "/");
			boost::replace_first(hop, "+", "/");
			boost::replace_all(hop, "+", " ");

			if (hop.find("hop://") == std::string::npos)
				hop = "hop://" + hop;
			slurl_uri = LLURI(hop);

			LL_DEBUGS("SLURL") << "hypergrid slurl " << hop <<LL_ENDL;
		}

		LLSD path_array = slurl_uri.pathArray();

		// determine whether it's a maingrid URI or an Standalone/open style URI
		// by looking at the scheme.  If it's a 'secondlife:' slurl scheme or
		// 'sl:' scheme, we know it's maingrid

		// At the end of this if/else block, we'll have determined the grid,
		// and the slurl type (APP or LOCATION)

		// default to current
		std::string default_grid = LLGridManager::getInstance()->getGrid();
		mGrid = default_grid;

		if(slurl_uri.scheme() == LLSLURL::SLURL_SECONDLIFE_SCHEME)
		{
			LL_DEBUGS("SLURL") << "secondlife scheme" << LL_ENDL;
			// parse a maingrid style slurl.  We know the grid is maingrid
			// so grab it.
			// A location slurl for maingrid (with the special schemes) can be in the form
			// secondlife://<regionname>/<x>/<y>/<z>
			// or
			// secondlife://<Grid>/secondlife/<region>/<x>/<y>/<z>
			// where if grid is empty, it specifies Agni

			// An app style slurl for maingrid can be
			// secondlife://<Grid>/app/<app parameters>
			// where an empty grid implies Agni

			// we'll start by checking the top of the 'path' which will be
			// either 'app', 'secondlife', or <x>.

			LL_DEBUGS("SLURL") << "slurl_uri.hostNameAndPort(): " << slurl_uri.hostNameAndPort() << LL_ENDL;
			LL_DEBUGS("SLURL") << "path_array[0]: " << path_array[0].asString() << LL_ENDL;

			if ((path_array[0].asString() == LLSLURL::SLURL_SECONDLIFE_PATH) ||
			        (path_array[0].asString() == LLSLURL::SLURL_APP_PATH))
			{
				// it's in the form secondlife://<grid>/(app|secondlife)
				// so parse the grid name to derive the grid ID
				if (!slurl_uri.hostNameAndPort().empty())
				{
					LL_DEBUGS("SLURL") << "secondlife://<grid>/(app|secondlife)" << LL_ENDL;

					mGrid = LLGridManager::getInstance()->getGridByProbing(slurl_uri.hostNameAndPort());
					if (mGrid.empty())
						mGrid = LLGridManager::getInstance()->getGridByProbing(slurl_uri.hostName());
					if (mGrid.empty())
						mGrid = default_grid;
				}
				else if(path_array[0].asString() == LLSLURL::SLURL_SECONDLIFE_PATH)
				{
					LL_DEBUGS("SLURL") << "secondlife:///secondlife/<region>" << LL_ENDL;
					// If the slurl is in the form secondlife:///secondlife/<region> form,
					// then we are in fact on maingrid.
					mGrid = default_grid;
				}
				else if(path_array[0].asString() == LLSLURL::SLURL_APP_PATH)
				{
					LL_DEBUGS("SLURL") << "app style slurls, no grid name specified" << LL_ENDL;
					// for app style slurls, where no grid name is specified, assume the currently
					// selected or logged in grid.
					mGrid = default_grid;
				}

				// Ansariel: We get here at an early stage during startup when
				//           checking if we are launched with an SLURL cmdline
				//           option and need to hand over to a running instance.
				//           In that case simply ignore the fact we don't have a
				//           gridname yet. We are only interested in validating it.
				if(mGrid.empty() && LLStartUp::getStartupState() == STATE_STARTED)
				{
					LL_DEBUGS("SLURL") << "couldn't find the grid so bail" << LL_ENDL;
					// we couldn't find the grid in the grid manager, so bail
					return;
				}
				// set the type as appropriate.
				if(path_array[0].asString() == LLSLURL::SLURL_SECONDLIFE_PATH)
				{
					mType = LOCATION;
				}
				else
				{
					mType = APP;
				}
				path_array.erase(0);
			}
			else
			{
				LL_DEBUGS("SLURL") << "secondlife://<region>" << LL_ENDL;
				// it wasn't a /secondlife/<region> or /app/<params>, so it must be secondlife://<region>
				// therefore the hostname will be the region name, and it's a location type
				mType = LOCATION;

				//AW: use current grid for compatibility
				//with viewer 1 slurls.
				mGrid = LLGridManager::getInstance()->getGrid();

				// 'normalize' it so the region name is in fact the head of the path_array
				path_array.insert(0, slurl_uri.hostNameAndPort());
			}
		}
		else if((slurl_uri.scheme() == LLSLURL::SLURL_HTTP_SCHEME)
		        || (slurl_uri.scheme() == LLSLURL::SLURL_HTTPS_SCHEME)
		        || (slurl_uri.scheme() == LLSLURL::SLURL_X_GRID_LOCATION_INFO_SCHEME)
		        || (slurl_uri.scheme() == LLSLURL::HOP_SCHEME))
		{
			// We're dealing with either a Standalone style slurl or slurl.com slurl
			if ((slurl_uri.hostName() == LLSLURL::SLURL_COM) ||
			        (slurl_uri.hostName() == LLSLURL::WWW_SLURL_COM) ||
			        (slurl_uri.hostName() == LLSLURL::MAPS_SECONDLIFE_COM))
			{
				LL_DEBUGS("SLURL") << "slurl style slurl.com"  << LL_ENDL;
				if (slurl_uri.hostName() == LLSLURL::MAPS_SECONDLIFE_COM)
					mGrid = MAINGRID;
				else
					mGrid = default_grid;
			}
			else
			{
				LL_DEBUGS("SLURL") << "slurl style Standalone"  << LL_ENDL;
				// Don't try to match any old http://<host>/ URL as a SLurl.
				// SLE SLurls will have the grid hostname in the URL, so only
				// match http URLs if the hostname matches the grid hostname
				// (or its a slurl.com or maps.secondlife.com URL).
				std::string probe_grid;

				std::string hyper = slurl_uri.hostNameAndPort();
				std::string hyper_trimmed = LLGridManager::getInstance()->trimHypergrid(hyper);
				if (hyper != hyper_trimmed)
				{
					mHypergrid = true;
					path_array.insert(0,hyper);
				}

				probe_grid = LLGridManager::getInstance()->getGridByProbing(hyper);
				if (probe_grid.empty())
				{
					probe_grid = LLGridManager::getInstance()->getGridByProbing(slurl_uri.hostName());
				}

				LL_DEBUGS("SLURL") << "Probing result: " << probe_grid << LL_ENDL;
				LL_DEBUGS("SLURL") << "slurl_uri.hostNameAndPort(): "  << slurl_uri.hostNameAndPort() << LL_ENDL;

				if ((slurl_uri.scheme() == LLSLURL::SLURL_HTTP_SCHEME || slurl_uri.scheme() == LLSLURL::SLURL_HTTPS_SCHEME) && slurl_uri.hostNameAndPort() != probe_grid)
				{
					LL_DEBUGS("SLURL") << "Don't try to match any old http://<host>/ URL as a SLurl"  << LL_ENDL;

					return;
				}
				// As it's a Standalone grid/open, we will always have a hostname,
				// as Standalone/open style urls are properly formed,
				// unlike the stinky maingrid style
				if (probe_grid.empty())
				{
					mGrid = slurl_uri.hostNameAndPort();
				}
				else
				{
					mGrid = probe_grid;
					mHypergrid = LLGridManager::getInstance()->isHyperGrid(probe_grid);
				}
			}

			if (path_array.size() == 0)
			{
				LL_DEBUGS("SLURL") << "It's a broken slurl" << LL_ENDL;
				// um, we need a path...
				return;
			}

			// we need to normalize the urls so
			// the path portion starts with the 'command' that we want to do
			// it can either be region or app.
			if ((path_array[0].asString() == LLSLURL::SLURL_REGION_PATH) || (path_array[0].asString() == LLSLURL::SLURL_SECONDLIFE_PATH))
			{
				LL_DEBUGS("SLURL") << "It's a location slurl"  << LL_ENDL;
				// strip off 'region' or 'secondlife'
				path_array.erase(0);
				// it's a location
				mType = LOCATION;
			}
			else if (path_array[0].asString() == LLSLURL::SLURL_APP_PATH)
			{
				LL_DEBUGS("SLURL") << "It's an app slurl"  << LL_ENDL;
				mType = APP;
				if (mGrid.empty())
					mGrid = default_grid;
				path_array.erase(0);
				// leave app appended.
			}
// <AW: hop:// protocol>
			else if ( slurl_uri.scheme() == LLSLURL::HOP_SCHEME)
			{
				LL_DEBUGS("SLURL") << "It's a location hop"  << LL_ENDL;
				mType = LOCATION;
			}
// </AW: hop:// protocol>
			else
			{
				LL_DEBUGS("SLURL") << "Not a valid https/http/x-grid-location-info slurl " <<  slurl << LL_ENDL;
				// not a valid https/http/x-grid-location-info slurl, so it'll likely just be a URL
				return;
			}
		}
		else
		{
			// invalid scheme, so bail
			LL_DEBUGS("SLURL")<< "Invalid scheme" << LL_ENDL;
			return;
		}


		if(path_array.size() == 0)
		{
			LL_DEBUGS("SLURL") << "path_array.size() == 0"  << LL_ENDL;
			// we gotta have some stuff after the specifier as to whether it's a region or command
			return;
		}

		// now that we know whether it's an app slurl or a location slurl,
		// parse the slurl into the proper data structures.
		if(mType == APP)
		{
			// grab the app command type and strip it (could be a command to jump somewhere,
			// or whatever )
			mAppCmd = path_array[0].asString();
			path_array.erase(0);

			// Grab the parameters
			mAppPath = path_array;

			// and the query
			mAppQuery = slurl_uri.query();
			mAppQueryMap = slurl_uri.queryMap();
			return;
		}
		else if(mType == LOCATION)
		{
			// at this point, head of the path array should be [ <region>, <x>, <y>, <z> ] where x, y and z
			// are collectively optional
			// are optional
			mRegion = LLURI::unescape(path_array[0].asString());
			path_array.erase(0);

			LL_DEBUGS("SLURL") << "mRegion: "  << mRegion << LL_ENDL;

			// parse the x, y, z
			if(path_array.size() >= 3)
			{
				mPosition = LLVector3(path_array);
// AW: the simulator should care of this
// 				if((F32(mPosition[VX]) < 0.f) ||
// 				(mPosition[VX] > REGION_WIDTH_METERS) ||
// 				(F32(mPosition[VY]) < 0.f) ||
// 				(mPosition[VY] > REGION_WIDTH_METERS) ||
// 				(F32(mPosition[VZ]) < 0.f) ||
// 				(mPosition[VZ] > LLWorld::getInstance()->getRegionMaxHeight()))
// 				{
// 					mType = INVALID;
// 					return;
// 				}

			}
			else
			{
				// if x, y and z were not fully passed in, go to the middle of the region.
				// teleport will adjust the actual location to make sure you're on the ground
				// and such
				mPosition = LLVector3(REGION_WIDTH_METERS/2, REGION_WIDTH_METERS/2, 0);
			}
		}
	}
}
Esempio n. 30
0
void URITestObject::test<3>()
{
    // no scheme
    checkParts(LLURI("foo"), "", "foo", "", "");
    checkParts(LLURI("foo%3A"), "", "foo:", "", "");
}