Dump "login_refresh" SLURL app command and implement missing "location_login" command instead

Tue, 22 Mar 2016 09:53:54 +0100

author
Ansariel
date
Tue, 22 Mar 2016 09:53:54 +0100
changeset 48931
37021f68c712
parent 48930
dc9d26d27a3e
child 48932
680ad57c187a

Dump "login_refresh" SLURL app command and implement missing "location_login" command instead

indra/newview/fspanellogin.cpp file | annotate | diff | revisions
indra/newview/fspanellogin.h file | annotate | diff | revisions
     1.1 --- a/indra/newview/fspanellogin.cpp	Sun Mar 20 19:20:52 2016 +0100
     1.2 +++ b/indra/newview/fspanellogin.cpp	Tue Mar 22 09:53:54 2016 +0100
     1.3 @@ -91,20 +91,86 @@
     1.4  // For new accounts without a last name "Resident" is added as a last name.
     1.5  static std::string canonicalize_username(const std::string& name);
     1.6  
     1.7 -class LLLoginRefreshHandler : public LLCommandHandler
     1.8 +class LLLoginLocationAutoHandler : public LLCommandHandler
     1.9  {
    1.10  public:
    1.11  	// don't allow from external browsers
    1.12 -	LLLoginRefreshHandler() : LLCommandHandler("login_refresh", UNTRUSTED_BLOCK) { }
    1.13 +	LLLoginLocationAutoHandler() : LLCommandHandler("location_login", UNTRUSTED_BLOCK) { }
    1.14  	bool handle(const LLSD& tokens, const LLSD& query_map, LLMediaCtrl* web)
    1.15  	{	
    1.16  		if (LLStartUp::getStartupState() < STATE_LOGIN_CLEANUP)
    1.17  		{
    1.18 -			FSPanelLogin::loadLoginPage();
    1.19 +			if ( tokens.size() == 0 || tokens.size() > 4 ) 
    1.20 +				return false;
    1.21 +
    1.22 +			// unescape is important - uris with spaces are escaped in this code path
    1.23 +			// (e.g. space -> %20) and the code to log into a region doesn't support that.
    1.24 +			const std::string region = LLURI::unescape( tokens[0].asString() );
    1.25 +
    1.26 +			// just region name as payload 
    1.27 +			if ( tokens.size() == 1 )
    1.28 +			{
    1.29 +				// region name only - slurl will end up as center of region
    1.30 +				LLSLURL slurl(region);
    1.31 +				FSPanelLogin::autologinToLocation(slurl);
    1.32 +			}
    1.33 +			else
    1.34 +			// region name and x coord as payload 
    1.35 +			if ( tokens.size() == 2 )
    1.36 +			{
    1.37 +				// invalid to only specify region and x coordinate
    1.38 +				// slurl code will revert to same as region only, so do this anyway
    1.39 +				LLSLURL slurl(region);
    1.40 +				FSPanelLogin::autologinToLocation(slurl);
    1.41 +			}
    1.42 +			else
    1.43 +			// region name and x/y coord as payload 
    1.44 +			if ( tokens.size() == 3 )
    1.45 +			{
    1.46 +				// region and x/y specified - default z to 0
    1.47 +				F32 xpos;
    1.48 +				std::istringstream codec(tokens[1].asString());
    1.49 +				codec >> xpos;
    1.50 +
    1.51 +				F32 ypos;
    1.52 +				codec.clear();
    1.53 +				codec.str(tokens[2].asString());
    1.54 +				codec >> ypos;
    1.55 +
    1.56 +				const LLVector3 location(xpos, ypos, 0.0f);
    1.57 +				LLSLURL slurl(region, location);
    1.58 +
    1.59 +				FSPanelLogin::autologinToLocation(slurl);
    1.60 +			}
    1.61 +			else
    1.62 +			// region name and x/y/z coord as payload 
    1.63 +			if ( tokens.size() == 4 )
    1.64 +			{
    1.65 +				// region and x/y/z specified - ok
    1.66 +				F32 xpos;
    1.67 +				std::istringstream codec(tokens[1].asString());
    1.68 +				codec >> xpos;
    1.69 +
    1.70 +				F32 ypos;
    1.71 +				codec.clear();
    1.72 +				codec.str(tokens[2].asString());
    1.73 +				codec >> ypos;
    1.74 +
    1.75 +				F32 zpos;
    1.76 +				codec.clear();
    1.77 +				codec.str(tokens[3].asString());
    1.78 +				codec >> zpos;
    1.79 +
    1.80 +				const LLVector3 location(xpos, ypos, zpos);
    1.81 +				LLSLURL slurl(region, location);
    1.82 +
    1.83 +				FSPanelLogin::autologinToLocation(slurl);
    1.84 +			};
    1.85  		}	
    1.86  		return true;
    1.87  	}
    1.88  };
    1.89 +LLLoginLocationAutoHandler gLoginLocationAutoHandler;
    1.90  
    1.91  //---------------------------------------------------------------------------
    1.92  // Public methods
    1.93 @@ -752,6 +818,18 @@
    1.94  	LLStartUp::setStartSLURL(slurl); // calls onUpdateStartSLURL, above
    1.95  }
    1.96  
    1.97 +void FSPanelLogin::autologinToLocation(const LLSLURL& slurl)
    1.98 +{
    1.99 +	LL_DEBUGS("AppInit")<<"automatically logging into Location "<<slurl.asString()<<LL_ENDL;
   1.100 +	LLStartUp::setStartSLURL(slurl); // calls onUpdateStartSLURL, above
   1.101 +
   1.102 +	if ( FSPanelLogin::sInstance != NULL )
   1.103 +	{
   1.104 +		void* unused_parameter = 0;
   1.105 +		FSPanelLogin::sInstance->onClickConnect(unused_parameter);
   1.106 +	}
   1.107 +}
   1.108 +
   1.109  // static
   1.110  void FSPanelLogin::closePanel()
   1.111  {
     2.1 --- a/indra/newview/fspanellogin.h	Sun Mar 20 19:20:52 2016 +0100
     2.2 +++ b/indra/newview/fspanellogin.h	Tue Mar 22 09:53:54 2016 +0100
     2.3 @@ -69,6 +69,7 @@
     2.4  
     2.5  	static BOOL areCredentialFieldsDirty();
     2.6  	static void setLocation(const LLSLURL& slurl);
     2.7 +	static void autologinToLocation(const LLSLURL& slurl);
     2.8  	
     2.9  	/// Call when preferences that control visibility may have changed
    2.10  	static void updateLocationSelectorsVisibility();

mercurial