aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--account.c30
-rw-r--r--irc.c23
-rw-r--r--irc_commands.c8
-rw-r--r--protocols/nogaim.c27
-rw-r--r--protocols/nogaim.h2
5 files changed, 68 insertions, 22 deletions
diff --git a/account.c b/account.c
index 912cba6a..99c3ff53 100644
--- a/account.c
+++ b/account.c
@@ -1,7 +1,7 @@
/********************************************************************\
* BitlBee -- An IRC to other IM-networks gateway *
* *
- * Copyright 2002-2004 Wilmer van der Gaast and others *
+ * Copyright 2002-2010 Wilmer van der Gaast and others *
\********************************************************************/
/* Account management functions */
@@ -68,7 +68,16 @@ account_t *account_add( irc_t *irc, struct prpl *prpl, char *user, char *pass )
if( prpl->init )
prpl->init( a );
- return( a );
+ s = set_add( &a->set, "away", NULL, set_eval_account, a );
+ s->flags |= SET_NULL_OK;
+
+ if( a->flags & ACC_FLAG_STATUS_MESSAGE )
+ {
+ s = set_add( &a->set, "status", NULL, set_eval_account, a );
+ s->flags |= SET_NULL_OK;
+ }
+
+ return a;
}
char *set_eval_account( set_t *set, char *value )
@@ -122,6 +131,21 @@ char *set_eval_account( set_t *set, char *value )
acc->auto_connect = bool2int( value );
return value;
}
+ else if( strcmp( set->key, "away" ) == 0 ||
+ strcmp( set->key, "status" ) == 0 )
+ {
+ if( acc->ic && acc->ic->flags & OPT_LOGGED_IN )
+ {
+ /* If we're currently on-line, set the var now already
+ (bit of a hack) and send an update. */
+ g_free( set->value );
+ set->value = g_strdup( value );
+
+ imc_away_send_update( acc->ic );
+ }
+
+ return value;
+ }
return SET_INVALID;
}
@@ -266,7 +290,7 @@ int account_reconnect_delay_parse( char *value, struct account_reconnect_delay *
/* A whole day seems like a sane "maximum maximum". */
p->max = 86400;
- /* Format: /[0-9]+([*+][0-9]+(<[0-9+]))/ */
+ /* Format: /[0-9]+([*+][0-9]+(<[0-9+])?)?/ */
while( *value && isdigit( *value ) )
p->start = p->start * 10 + *value++ - '0';
diff --git a/irc.c b/irc.c
index 2dcc625d..8d503e02 100644
--- a/irc.c
+++ b/irc.c
@@ -77,6 +77,25 @@ static char *set_eval_charset( set_t *set, char *value )
return value;
}
+static char *set_eval_away_status( set_t *set, char *value )
+{
+ irc_t *irc = set->data;
+ account_t *a;
+
+ g_free( set->value );
+ set->value = g_strdup( value );
+
+ for( a = irc->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;
+}
+
irc_t *irc_new( int fd )
{
irc_t *irc;
@@ -142,6 +161,8 @@ irc_t *irc_new( int fd )
irc_connection_list = g_slist_append( irc_connection_list, irc );
+ s = set_add( &irc->set, "away", NULL, set_eval_away_status, irc );
+ s->flags |= SET_NULL_OK;
s = set_add( &irc->set, "away_devoice", "true", set_eval_away_devoice, irc );
s = set_add( &irc->set, "auto_connect", "true", set_eval_bool, irc );
s = set_add( &irc->set, "auto_reconnect", "false", set_eval_bool, irc );
@@ -162,6 +183,8 @@ irc_t *irc_new( int fd )
s = set_add( &irc->set, "root_nick", irc->mynick, set_eval_root_nick, irc );
s = set_add( &irc->set, "save_on_quit", "true", set_eval_bool, irc );
s = set_add( &irc->set, "simulate_netsplit", "true", set_eval_bool, irc );
+ s = set_add( &irc->set, "status", NULL, set_eval_away_status, irc );
+ s->flags |= SET_NULL_OK;
s = set_add( &irc->set, "strip_html", "true", NULL, irc );
s = set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc );
s = set_add( &irc->set, "typing_notice", "false", set_eval_bool, irc );
diff --git a/irc_commands.c b/irc_commands.c
index 74334ee9..0fbaacd1 100644
--- a/irc_commands.c
+++ b/irc_commands.c
@@ -474,13 +474,7 @@ static void irc_cmd_away( irc_t *irc, char **cmd )
irc_reply( irc, 305, ":Welcome back" );
}
- for( a = irc->accounts; a; a = a->next )
- {
- struct im_connection *ic = a->ic;
-
- if( ic && ic->flags & OPT_LOGGED_IN )
- imc_set_away( ic, u->away );
- }
+ set_setstr( &irc->set, "away", u->away );
}
static void irc_cmd_whois( irc_t *irc, char **cmd )
diff --git a/protocols/nogaim.c b/protocols/nogaim.c
index f7a62f54..3d2cff5c 100644
--- a/protocols/nogaim.c
+++ b/protocols/nogaim.c
@@ -1,7 +1,7 @@
/********************************************************************\
* BitlBee -- An IRC to other IM-networks gateway *
* *
- * Copyright 2002-2006 Wilmer van der Gaast and others *
+ * Copyright 2002-2010 Wilmer van der Gaast and others *
\********************************************************************/
/*
@@ -267,9 +267,8 @@ void imcb_connected( struct im_connection *ic )
ic->keepalive = b_timeout_add( 60000, send_keepalive, ic );
ic->flags |= OPT_LOGGED_IN;
- /* Also necessary when we're not away, at least for some of the
- protocols. */
- imc_set_away( ic, u->away );
+ /* Necessary to send initial presence status, even if we're not away. */
+ imc_away_send_update( ic );
/* Apparently we're connected successfully, so reset the
exponential backoff timer. */
@@ -1071,20 +1070,26 @@ int imc_chat_msg( struct groupchat *c, char *msg, int flags )
static char *imc_away_state_find( GList *gcm, char *away, char **message );
-int imc_set_away( struct im_connection *ic, char *away )
+int imc_away_send_update( struct im_connection *ic )
{
- char *s = NULL, *msg = away;
+ char *away, *msg;
+ away = set_getstr( &ic->acc->set, "away" ) ?
+ : set_getstr( &ic->irc->set, "away" );
if( away && *away )
{
GList *m = ic->acc->prpl->away_states( ic );
- s = imc_away_state_find( m, away, &msg ) ? : m->data;
+ msg = ic->acc->flags & ACC_FLAG_AWAY_MESSAGE ? away : NULL;
+ away = imc_away_state_find( m, away, &msg ) ? : m->data;
+ }
+ else if( ic->acc->flags & ACC_FLAG_STATUS_MESSAGE )
+ {
+ away = NULL;
+ msg = set_getstr( &ic->acc->set, "status" ) ?
+ : set_getstr( &ic->irc->set, "status" );
}
- if( set_getbool( &ic->irc->set, "debug" ) )
- imcb_log( ic, "Setting away state to %s", s );
-
- ic->acc->prpl->set_away( ic, s, ic->acc->flags & ACC_FLAG_AWAY_MESSAGE ? msg : NULL );
+ ic->acc->prpl->set_away( ic, away, msg );
return 1;
}
diff --git a/protocols/nogaim.h b/protocols/nogaim.h
index 80f8ed40..4fc32281 100644
--- a/protocols/nogaim.h
+++ b/protocols/nogaim.h
@@ -313,7 +313,7 @@ G_MODULE_EXPORT void imcb_chat_topic( struct groupchat *c, char *who, char *topi
G_MODULE_EXPORT void imcb_chat_free( struct groupchat *c );
/* Actions, or whatever. */
-int imc_set_away( struct im_connection *ic, char *away );
+int imc_away_send_update( struct im_connection *ic );
int imc_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags );
int imc_chat_msg( struct groupchat *c, char *msg, int flags );