Ignore:
Timestamp:
2006-09-23T16:18:24Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
172a73f1
Parents:
d8e0484
Message:

Implemented a list of away states, using this for a better set_away(), and
got rid of the double <presence> tag sent because of presence_announce().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/jabber.c

    rd8e0484 r5e202b0  
    111111        xt_free( jd->xt );
    112112       
     113        g_free( jd->away_message );
    113114        g_free( jd->username );
    114115        g_free( jd );
     
    128129}
    129130
    130 /* TODO: For away state handling, implement some list like the one for MSN. */
    131131static GList *jabber_away_states( struct gaim_connection *gc )
    132132{
    133         GList *l = NULL;
     133        static GList *l = NULL;
     134        int i;
    134135       
    135         l = g_list_append( l, (void*) "Online" );
    136         l = g_list_append( l, (void*) "Away" );
    137         l = g_list_append( l, (void*) "Extended Away" );
    138         l = g_list_append( l, (void*) "Do Not Disturb" );
     136        if( l == NULL )
     137                for( i = 0; jabber_away_state_list[i].full_name; i ++ )
     138                        l = g_list_append( l, (void*) jabber_away_state_list[i].full_name );
    139139       
    140         return( l );
     140        return l;
    141141}
    142142
    143 static void jabber_set_away( struct gaim_connection *gc, char *state, char *message )
     143static void jabber_set_away( struct gaim_connection *gc, char *state_txt, char *message )
    144144{
    145         /* For now let's just always set state to "away" and send the message, if available. */
    146         presence_send( gc, NULL, g_strcasecmp( state, "Online" ) == 0 ? NULL : "away", message );
     145        struct jabber_data *jd = gc->proto_data;
     146        struct jabber_away_state *state;
     147       
     148        /* Save all this info. We need it, for example, when changing the priority setting. */
     149        state = (void *) jabber_away_state_by_name( state_txt );
     150        jd->away_state = state ? state : (void *) jabber_away_state_list; /* Fall back to "Away" if necessary. */
     151        g_free( jd->away_message );
     152        jd->away_message = ( message && *message ) ? g_strdup( message ) : NULL;
     153       
     154        presence_send( gc, NULL, jd->away_state->code, jd->away_message );
    147155}
    148156
Note: See TracChangeset for help on using the changeset viewer.