diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-06-07 00:47:46 +0100 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-06-07 00:47:46 +0100 | 
| commit | 92cb8c4c251fb04a483b29e7108e7a52388f14dd (patch) | |
| tree | 227b80ca36f96b0ec2189eb6ac62ca583a4b67f2 /root_commands.c | |
| parent | 16834a53f85be092acc16dee70cb72451b2230f9 (diff) | |
Complete (hopefully) fix for nickname changes: Add flags to the identify
command to allow identifying without loading any new settings. With some
documentation hints.
Diffstat (limited to 'root_commands.c')
| -rw-r--r-- | root_commands.c | 42 | 
1 files changed, 37 insertions, 5 deletions
| diff --git a/root_commands.c b/root_commands.c index cdc1ccdb..bb9b26cd 100644 --- a/root_commands.c +++ b/root_commands.c @@ -104,15 +104,46 @@ static void cmd_account( irc_t *irc, char **cmd );  static void cmd_identify( irc_t *irc, char **cmd )  { -	storage_status_t status = storage_load( irc, cmd[1] ); +	storage_status_t status;  	char *account_on[] = { "account", "on", NULL }; +	gboolean load = TRUE; +	char *password = cmd[1]; -	if( strchr( irc->umode, 'R' ) != NULL ) +	if( irc->status & USTATUS_IDENTIFIED )  	{  		irc_usermsg( irc, "You're already logged in." );  		return;  	} +	if( strncmp( cmd[1], "-no", 3 ) == 0 ) +	{ +		load = FALSE; +		password = cmd[2]; +	} +	else if( strncmp( cmd[1], "-force", 6 ) == 0 ) +	{ +		password = cmd[2]; +	} +	else if( irc->b->accounts != NULL ) +	{ +		irc_usermsg( irc, +		             "You're trying to identify yourself, but already have " +		             "at least one IM account set up. " +		             "Use \x02identify -noload\x02 or \x02identify -force\x02 " +		             "instead (see \x02help identify\x02)." ); +		return; +	} +	 +	if( password == NULL ) +	{ +		MIN_ARGS( 2 ); +	} +	 +	if( load ) +		status = storage_load( irc, password ); +	else +		status = storage_check_pass( irc->user->nick, password ); +	  	switch (status) {  	case STORAGE_INVALID_PASSWORD:  		irc_usermsg( irc, "Incorrect password" ); @@ -121,11 +152,12 @@ static void cmd_identify( irc_t *irc, char **cmd )  		irc_usermsg( irc, "The nick is (probably) not registered" );  		break;  	case STORAGE_OK: -		irc_usermsg( irc, "Password accepted, settings and accounts loaded" ); -		irc_setpass( irc, cmd[1] ); +		irc_usermsg( irc, "Password accepted%s", +		             load ? ", settings and accounts loaded" : "" ); +		irc_setpass( irc, password );  		irc->status |= USTATUS_IDENTIFIED;  		irc_umode_set( irc, "+R", 1 ); -		if( set_getbool( &irc->b->set, "auto_connect" ) ) +		if( load && set_getbool( &irc->b->set, "auto_connect" ) )  			cmd_account( irc, account_on );  		break;  	case STORAGE_OTHER_ERROR: | 
