Index: account.c
===================================================================
--- account.c	(revision 34fbbf9c6a80ea7bf5e371c6d36c6ed596b15bd7)
+++ account.c	(revision 58adb7e800db87c1e38b810c288f1455654dab3d)
@@ -2,5 +2,5 @@
   * 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                *
   \********************************************************************/
 
@@ -69,5 +69,14 @@
 		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;
 }
 
@@ -121,4 +130,19 @@
 		
 		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;
 	}
@@ -267,5 +291,5 @@
 	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';
Index: irc.c
===================================================================
--- irc.c	(revision 34fbbf9c6a80ea7bf5e371c6d36c6ed596b15bd7)
+++ irc.c	(revision 58adb7e800db87c1e38b810c288f1455654dab3d)
@@ -78,4 +78,23 @@
 }
 
+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 )
 {
@@ -143,4 +162,6 @@
 	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 );
@@ -163,4 +184,6 @@
 	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 );
Index: irc_commands.c
===================================================================
--- irc_commands.c	(revision 34fbbf9c6a80ea7bf5e371c6d36c6ed596b15bd7)
+++ irc_commands.c	(revision 58adb7e800db87c1e38b810c288f1455654dab3d)
@@ -475,11 +475,5 @@
 	}
 	
-	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 );
 }
 
Index: protocols/nogaim.c
===================================================================
--- protocols/nogaim.c	(revision 34fbbf9c6a80ea7bf5e371c6d36c6ed596b15bd7)
+++ protocols/nogaim.c	(revision 58adb7e800db87c1e38b810c288f1455654dab3d)
@@ -2,5 +2,5 @@
   * 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                *
   \********************************************************************/
 
@@ -268,7 +268,6 @@
 	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
@@ -1072,18 +1071,24 @@
 static char *imc_away_state_find( GList *gcm, char *away, char **message );
 
-int imc_set_away( struct im_connection *ic, char *away )
-{
-	char *s = NULL, *msg = away;
-	
+int imc_away_send_update( struct im_connection *ic )
+{
+	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;
-	}
-	
-	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 );
+		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" );
+	}
+	
+	ic->acc->prpl->set_away( ic, away, msg );
 	
 	return 1;
Index: protocols/nogaim.h
===================================================================
--- protocols/nogaim.h	(revision 34fbbf9c6a80ea7bf5e371c6d36c6ed596b15bd7)
+++ protocols/nogaim.h	(revision 58adb7e800db87c1e38b810c288f1455654dab3d)
@@ -314,5 +314,5 @@
 
 /* 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 );
