Changeset 840bba8 for protocols/jabber


Ignore:
Timestamp:
2010-03-06T14:50:52Z (15 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
2bc8ac0
Parents:
d1ad6f0
Message:

The Jabber part of the change. Also made representation of not-away a bit
more consistent. Except for free-for-chat, which is nuts anyway.

Location:
protocols/jabber
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/jabber.c

    rd1ad6f0 r840bba8  
    8080        s = set_add( &acc->set, "xmlconsole", "false", set_eval_bool, acc );
    8181        s->flags |= ACC_SET_OFFLINE_ONLY;
     82       
     83        acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE;
    8284}
    8385
     
    377379{
    378380        struct jabber_data *jd = ic->proto_data;
    379         struct jabber_away_state *state;
    380        
    381         /* Save all this info. We need it, for example, when changing the priority setting. */
    382         state = (void *) jabber_away_state_by_name( state_txt );
    383         jd->away_state = state ? state : (void *) jabber_away_state_list; /* Fall back to "Away" if necessary. */
     381       
     382        /* state_txt == NULL -> Not away.
     383           Unknown state -> fall back to the first defined away state. */
     384        jd->away_state = state_txt ? jabber_away_state_by_name( state_txt )
     385                         ? : jabber_away_state_list : NULL;
     386       
    384387        g_free( jd->away_message );
    385388        jd->away_message = ( message && *message ) ? g_strdup( message ) : NULL;
  • protocols/jabber/jabber.h

    rd1ad6f0 r840bba8  
    8484        /* After changing one of these two (or the priority setting), call
    8585           presence_send_update() to inform the server about the changes. */
    86         struct jabber_away_state *away_state;
     86        const struct jabber_away_state *away_state;
    8787        char *away_message;
    8888       
  • protocols/jabber/jabber_util.c

    rd1ad6f0 r840bba8  
    228228{
    229229        { "away",  "Away" },
    230         { "chat",  "Free for Chat" },
     230        { "chat",  "Free for Chat" },   /* WTF actually uses this? */
    231231        { "dnd",   "Do not Disturb" },
    232232        { "xa",    "Extended Away" },
    233         { "",      "Online" },
    234233        { "",      NULL }
    235234};
     
    238237{
    239238        int i;
     239       
     240        if( code == NULL )
     241                return NULL;
    240242       
    241243        for( i = 0; jabber_away_state_list[i].full_name; i ++ )
     
    249251{
    250252        int i;
     253       
     254        if( name == NULL )
     255                return NULL;
    251256       
    252257        for( i = 0; jabber_away_state_list[i].full_name; i ++ )
  • protocols/jabber/presence.c

    rd1ad6f0 r840bba8  
    190190                int is_away = 0;
    191191
    192                 if( send_presence->away_state && !( *send_presence->away_state->code == 0 ||
    193                     strcmp( send_presence->away_state->code, "chat" ) == 0 ) )
     192                if( send_presence->away_state &&
     193                    strcmp( send_presence->away_state->code, "chat" ) != 0 )
    194194                        is_away = OPT_AWAY;
    195195
    196196                imcb_buddy_status( ic, send_presence->bare_jid, OPT_LOGGED_IN | is_away,
    197                                    ( is_away && send_presence->away_state ) ?
    198                                    send_presence->away_state->full_name : NULL,
     197                                   is_away ? send_presence->away_state->full_name : NULL,
    199198                                   send_presence->away_message );
    200199        }
     
    209208        struct jabber_data *jd = ic->proto_data;
    210209        struct xt_node *node, *cap;
    211         char *show = jd->away_state->code;
    212         char *status = jd->away_message;
    213210        struct groupchat *c;
    214211        int st;
     
    216213        node = jabber_make_packet( "presence", NULL, NULL, NULL );
    217214        xt_add_child( node, xt_new_node( "priority", set_getstr( &ic->acc->set, "priority" ), NULL ) );
    218         if( show && *show )
    219                 xt_add_child( node, xt_new_node( "show", show, NULL ) );
    220         if( status )
    221                 xt_add_child( node, xt_new_node( "status", status, NULL ) );
     215        if( jd->away_state )
     216                xt_add_child( node, xt_new_node( "show", jd->away_state->code, NULL ) );
     217        if( jd->away_message )
     218                xt_add_child( node, xt_new_node( "status", jd->away_message, NULL ) );
    222219       
    223220        /* This makes the packet slightly bigger, but clients interested in
Note: See TracChangeset for help on using the changeset viewer.