diff options
| -rw-r--r-- | irc_commands.c | 30 | ||||
| -rw-r--r-- | protocols/bee.c | 51 | 
2 files changed, 62 insertions, 19 deletions
| diff --git a/irc_commands.c b/irc_commands.c index 5387fb4d..54c0067c 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -351,7 +351,6 @@ static void irc_cmd_nickserv( irc_t *irc, char **cmd )  #if 0 -//#if 0  static void irc_cmd_oper( irc_t *irc, char **cmd )  {  	if( global.conf->oper_pass && @@ -523,40 +522,37 @@ static void irc_cmd_topic( irc_t *irc, char **cmd )  		irc_topic( irc, channel );  	}  } +#endif  static void irc_cmd_away( irc_t *irc, char **cmd )  { -	user_t *u = user_find( irc, irc->nick ); -	char *away = cmd[1]; -	 -	if( !u ) return; +	char *set; -	if( away && *away ) +	if( cmd[1] && *cmd[1] )  	{ +		char away[strlen(cmd[1])+1];  		int i, j;  		/* Copy away string, but skip control chars. Mainly because  		   Jabber really doesn't like them. */ -		u->away = g_malloc( strlen( away ) + 1 ); -		for( i = j = 0; away[i]; i ++ ) -			if( ( u->away[j] = away[i] ) >= ' ' ) +		for( i = j = 0; cmd[1][i]; i ++ ) +			if( ( away[j] = cmd[1][i] ) >= ' ' )  				j ++; -		u->away[j] = 0; +		away[j] = '\0'; -		irc_send_num( irc, 306, ":You're now away: %s", u->away ); -		/* irc_umode_set( irc, irc->myhost, "+a" ); */ +		irc_send_num( irc, 306, ":You're now away: %s", away ); +		set = away;  	}  	else  	{ -		if( u->away ) g_free( u->away ); -		u->away = NULL; -		/* irc_umode_set( irc, irc->myhost, "-a" ); */  		irc_send_num( irc, 305, ":Welcome back" ); +		set = NULL;  	} -	set_setstr( &irc->set, "away", u->away ); +	set_setstr( &irc->b->set, "away", set );  } +#if 0  static void irc_cmd_version( irc_t *irc, char **cmd )  {  	irc_send_num( irc, 351, "bitlbee-%s. %s :%s/%s ", BITLBEE_VERSION, irc->myhost, ARCH, CPU ); @@ -612,6 +608,7 @@ static const command_t irc_commands[] = {  	{ "privmsg",     1, irc_cmd_privmsg,     IRC_CMD_LOGGED_IN },  	{ "nickserv",    1, irc_cmd_nickserv,    IRC_CMD_LOGGED_IN },  	{ "ns",          1, irc_cmd_nickserv,    IRC_CMD_LOGGED_IN }, +	{ "away",        0, irc_cmd_away,        IRC_CMD_LOGGED_IN },  #if 0  	{ "oper",        2, irc_cmd_oper,        IRC_CMD_LOGGED_IN },  	{ "invite",      2, irc_cmd_invite,      IRC_CMD_LOGGED_IN }, @@ -620,7 +617,6 @@ static const command_t irc_commands[] = {  	{ "ison",        1, irc_cmd_ison,        IRC_CMD_LOGGED_IN },  	{ "watch",       1, irc_cmd_watch,       IRC_CMD_LOGGED_IN },  	{ "topic",       1, irc_cmd_topic,       IRC_CMD_LOGGED_IN }, -	{ "away",        0, irc_cmd_away,        IRC_CMD_LOGGED_IN },  	{ "version",     0, irc_cmd_version,     IRC_CMD_LOGGED_IN },  	{ "completions", 0, irc_cmd_completions, IRC_CMD_LOGGED_IN },  	{ "die",         0, NULL,                IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, diff --git a/protocols/bee.c b/protocols/bee.c index 3f576b0b..1aaa90f0 100644 --- a/protocols/bee.c +++ b/protocols/bee.c @@ -1,11 +1,39 @@ +  /********************************************************************\ +  * BitlBee -- An IRC to other IM-networks gateway                     * +  *                                                                    * +  * Copyright 2002-2010 Wilmer van der Gaast and others                * +  \********************************************************************/ + +/* Some IM-core stuff                                                   */ + +/* +  This program is free software; you can redistribute it and/or modify +  it under the terms of the GNU General Public License as published by +  the Free Software Foundation; either version 2 of the License, or +  (at your option) any later version. + +  This program is distributed in the hope that it will be useful, +  but WITHOUT ANY WARRANTY; without even the implied warranty of +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +  GNU General Public License for more details. + +  You should have received a copy of the GNU General Public License with +  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; +  if not, write to the Free Software Foundation, Inc., 59 Temple Place, +  Suite 330, Boston, MA  02111-1307  USA +*/ + +#define BITLBEE_CORE  #include "bitlbee.h" +static char *set_eval_away_status( set_t *set, char *value ); +  bee_t *bee_new()  {  	bee_t *b = g_new0( bee_t, 1 );  	set_t *s; -	s = set_add( &b->set, "away", NULL, NULL/*set_eval_away_status*/, b ); +	s = set_add( &b->set, "away", NULL, set_eval_away_status, b );  	s->flags |= SET_NULL_OK;  	s = set_add( &b->set, "auto_connect", "true", set_eval_bool, b );  	s = set_add( &b->set, "auto_reconnect", "true", set_eval_bool, b ); @@ -14,7 +42,7 @@ bee_t *bee_new()  	s = set_add( &b->set, "password", NULL, NULL/*set_eval_password*/, b );  	s->flags |= SET_NULL_OK;  	s = set_add( &b->set, "save_on_quit", "true", set_eval_bool, b ); -	s = set_add( &b->set, "status", NULL, NULL/*set_eval_away_status*/, b ); +	s = set_add( &b->set, "status", NULL, set_eval_away_status, b );  	s->flags |= SET_NULL_OK;  	s = set_add( &b->set, "strip_html", "true", NULL, b ); @@ -45,3 +73,22 @@ void bee_free( bee_t *b )  	g_free( b );  } + +static char *set_eval_away_status( set_t *set, char *value ) +{ +	bee_t *bee = set->data; +	account_t *a; +	 +	g_free( set->value ); +	set->value = g_strdup( value ); +	 +	for( a = bee->accounts; a; a = a->next ) +	{ +		struct im_connection *ic = a->ic; +		 +		if( ic && ic->flags & OPT_LOGGED_IN ) +			imc_away_send_update( ic ); +	} +	 +	return value; +} | 
