aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2006-09-24 12:25:41 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2006-09-24 12:25:41 +0200
commit172a73f1a4b37fa20d1d50496a3faccb8fe6c769 (patch)
treedaffad6b274d33928faa471303477761f13c6b4c
parent5e202b09f2cd9faff5f316ae6804facb5342eace (diff)
Updated <presence> stuff to handle changing the priority setting.
-rw-r--r--protocols/jabber/jabber.c2
-rw-r--r--protocols/jabber/jabber.h5
-rw-r--r--protocols/jabber/jabber_util.c39
-rw-r--r--protocols/jabber/presence.c12
4 files changed, 47 insertions, 11 deletions
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c
index b3199cde..ee26a007 100644
--- a/protocols/jabber/jabber.c
+++ b/protocols/jabber/jabber.c
@@ -151,7 +151,7 @@ static void jabber_set_away( struct gaim_connection *gc, char *state_txt, char *
g_free( jd->away_message );
jd->away_message = ( message && *message ) ? g_strdup( message ) : NULL;
- presence_send( gc, NULL, jd->away_state->code, jd->away_message );
+ presence_send_update( gc );
}
static void jabber_keepalive( struct gaim_connection *gc )
diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h
index 29cf6a84..4a8292ea 100644
--- a/protocols/jabber/jabber.h
+++ b/protocols/jabber/jabber.h
@@ -53,6 +53,9 @@ struct jabber_data
char *username; /* USERNAME@server */
char *server; /* username@SERVER -=> server/domain, not hostname */
+
+ /* After changing one of these two (or the priority setting), call
+ presence_send_update() to inform the server about the changes. */
struct jabber_away_state *away_state;
char *away_message;
@@ -74,7 +77,7 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data );
/* presence.c */
xt_status jabber_pkt_presence( struct xt_node *node, gpointer data );
-int presence_send( struct gaim_connection *gc, char *to, char *show, char *status );
+int presence_send_update( struct gaim_connection *gc );
/* jabber_util.c */
char *set_eval_resprio( set_t *set, char *value );
diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c
index 21df5126..e7a161cc 100644
--- a/protocols/jabber/jabber_util.c
+++ b/protocols/jabber/jabber_util.c
@@ -28,17 +28,42 @@ static int next_id = 1;
char *set_eval_resprio( set_t *set, char *value )
{
account_t *acc = set->data;
+ char *ret;
- /* Only run this stuff if the account is online ATM. */
- if( acc->gc )
+ if( strcmp( set->key, "priority" ) == 0 )
+ ret = set_eval_int( set, value );
+ else
+ ret = value;
+
+ /* Only run this stuff if the account is online ATM,
+ and if the setting seems to be acceptable. */
+ if( acc->gc && ret )
{
- /* ... */
+ if( strcmp( set->key, "priority" ) == 0 )
+ {
+ /* Although set_eval functions usually are very nice
+ and convenient, they have one disadvantage: If I
+ would just call p_s_u() now to send the new prio
+ setting, it would send the old setting because the
+ set->value gets changed when the eval returns a
+ non-NULL value.
+
+ So now I can choose between implementing post-set
+ functions next to evals, or just do this little
+ hack: */
+ g_free( set->value );
+ set->value = g_strdup( ret );
+
+ /* (Yes, sorry, I prefer the hack. :-P) */
+
+ presence_send_update( acc->gc );
+ }
+ else
+ {
+ }
}
- if( g_strcasecmp( set->key, "priority" ) == 0 )
- return set_eval_int( set, value );
- else
- return value;
+ return ret;
}
char *set_eval_tls( set_t *set, char *value )
diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c
index 18ce969b..d9053c5f 100644
--- a/protocols/jabber/presence.c
+++ b/protocols/jabber/presence.c
@@ -53,16 +53,24 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
return XT_HANDLED;
}
-int presence_send( struct gaim_connection *gc, char *to, char *show, char *status )
+/* Whenever presence information is updated, call this function to inform the
+ server. */
+int presence_send_update( struct gaim_connection *gc )
{
+ struct jabber_data *jd = gc->proto_data;
struct xt_node *node;
+ char *show = jd->away_state->code;
+ char *status = jd->away_message;
int st;
- node = jabber_make_packet( "presence", NULL, to, NULL );
+ node = jabber_make_packet( "presence", NULL, NULL, NULL );
if( show && *show )
xt_add_child( node, xt_new_node( "show", show, NULL ) );
if( status )
xt_add_child( node, xt_new_node( "status", status, NULL ) );
+ /* if( set_getint( &gc->acc->set, "priority" ) != 0 ) */
+ /* Let's just send this every time... */
+ xt_add_child( node, xt_new_node( "priority", set_getstr( &gc->acc->set, "priority" ), NULL ) );
st = jabber_write_packet( gc, node );