Ignore:
Timestamp:
2007-03-31T05:40:45Z (13 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
aef4828
Parents:
fa29d093
Message:

s/gaim_connection/im_connection/ and some other minor API changes. The rest
will come tomorrow. It compiles, I'll leave the real testing up to someone
else. ;-)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/iq.c

    rfa29d093 r0da65d5  
    2424#include "jabber.h"
    2525
    26 static xt_status jabber_parse_roster( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );
    27 static xt_status jabber_iq_display_vcard( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );
     26static xt_status jabber_parse_roster( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );
     27static xt_status jabber_iq_display_vcard( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );
    2828
    2929xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )
    3030{
    31         struct gaim_connection *gc = data;
    32         struct jabber_data *jd = gc->proto_data;
     31        struct im_connection *ic = data;
     32        struct jabber_data *jd = ic->proto_data;
    3333        struct xt_node *c, *reply = NULL;
    3434        char *type, *s;
     
    3939        if( !type )
    4040        {
    41                 hide_login_progress_error( gc, "Received IQ packet without type." );
    42                 signoff( gc );
     41                hide_login_progress_error( ic, "Received IQ packet without type." );
     42                signoff( ic );
    4343                return XT_ABORT;
    4444        }
     
    6060               
    6161                if( entry == NULL )
    62                         serv_got_crap( gc, "WARNING: Received IQ-%s packet with unknown/expired ID %s!", type, s );
     62                        serv_got_crap( ic, "WARNING: Received IQ-%s packet with unknown/expired ID %s!", type, s );
    6363                else if( entry->func )
    64                         return entry->func( gc, node, entry->node );
     64                        return entry->func( ic, node, entry->node );
    6565        }
    6666        else if( strcmp( type, "get" ) == 0 )
     
    6969                    !( s = xt_find_attr( c, "xmlns" ) ) )
    7070                {
    71                         serv_got_crap( gc, "WARNING: Received incomplete IQ-%s packet", type );
     71                        serv_got_crap( ic, "WARNING: Received incomplete IQ-%s packet", type );
    7272                        return XT_HANDLED;
    7373                }
     
    132132                    !( s = xt_find_attr( c, "xmlns" ) ) )
    133133                {
    134                         serv_got_crap( gc, "WARNING: Received incomplete IQ-%s packet", type );
     134                        serv_got_crap( ic, "WARNING: Received incomplete IQ-%s packet", type );
    135135                        return XT_HANDLED;
    136136                }
     
    141141                if( strcmp( s, XMLNS_ROSTER ) == 0 )
    142142                {
    143                         int bare_len = strlen( gc->acc->user );
     143                        int bare_len = strlen( ic->acc->user );
    144144                       
    145145                        if( ( s = xt_find_attr( node, "from" ) ) == NULL ||
    146                             ( strncmp( s, gc->acc->user, bare_len ) == 0 &&
     146                            ( strncmp( s, ic->acc->user, bare_len ) == 0 &&
    147147                              ( s[bare_len] == 0 || s[bare_len] == '/' ) ) )
    148148                        {
    149                                 jabber_parse_roster( gc, node, NULL );
     149                                jabber_parse_roster( ic, node, NULL );
    150150                               
    151151                                /* Should we generate a reply here? Don't think it's
     
    154154                        else
    155155                        {
    156                                 serv_got_crap( gc, "WARNING: %s tried to fake a roster push!", s ? s : "(unknown)" );
     156                                serv_got_crap( ic, "WARNING: %s tried to fake a roster push!", s ? s : "(unknown)" );
    157157                               
    158158                                xt_free_node( reply );
     
    182182                }
    183183               
    184                 st = jabber_write_packet( gc, reply );
     184                st = jabber_write_packet( ic, reply );
    185185                xt_free_node( reply );
    186186                if( !st )
     
    191191}
    192192
    193 static xt_status jabber_do_iq_auth( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );
    194 static xt_status jabber_finish_iq_auth( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );
    195 
    196 int jabber_init_iq_auth( struct gaim_connection *gc )
    197 {
    198         struct jabber_data *jd = gc->proto_data;
     193static xt_status jabber_do_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );
     194static xt_status jabber_finish_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );
     195
     196int jabber_init_iq_auth( struct im_connection *ic )
     197{
     198        struct jabber_data *jd = ic->proto_data;
    199199        struct xt_node *node;
    200200        int st;
     
    204204        node = jabber_make_packet( "iq", "get", NULL, node );
    205205       
    206         jabber_cache_add( gc, node, jabber_do_iq_auth );
    207         st = jabber_write_packet( gc, node );
     206        jabber_cache_add( ic, node, jabber_do_iq_auth );
     207        st = jabber_write_packet( ic, node );
    208208       
    209209        return st;
    210210}
    211211
    212 static xt_status jabber_do_iq_auth( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )
    213 {
    214         struct jabber_data *jd = gc->proto_data;
     212static xt_status jabber_do_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig )
     213{
     214        struct jabber_data *jd = ic->proto_data;
    215215        struct xt_node *reply, *query;
    216216        xt_status st;
     
    219219        if( !( query = xt_find_node( node->children, "query" ) ) )
    220220        {
    221                 serv_got_crap( gc, "WARNING: Received incomplete IQ packet while authenticating" );
    222                 signoff( gc );
     221                serv_got_crap( ic, "WARNING: Received incomplete IQ packet while authenticating" );
     222                signoff( ic );
    223223                return XT_HANDLED;
    224224        }
     
    228228        xt_add_attr( reply, "xmlns", XMLNS_AUTH );
    229229        xt_add_child( reply, xt_new_node( "username", jd->username, NULL ) );
    230         xt_add_child( reply, xt_new_node( "resource", set_getstr( &gc->acc->set, "resource" ), NULL ) );
     230        xt_add_child( reply, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) );
    231231       
    232232        if( xt_find_node( query->children, "digest" ) && ( s = xt_find_attr( jd->xt->root, "id" ) ) )
     
    241241                shaInit( &sha );
    242242                shaUpdate( &sha, (unsigned char*) s, strlen( s ) );
    243                 shaUpdate( &sha, (unsigned char*) gc->acc->pass, strlen( gc->acc->pass ) );
     243                shaUpdate( &sha, (unsigned char*) ic->acc->pass, strlen( ic->acc->pass ) );
    244244                shaFinal( &sha, hash );
    245245               
     
    252252        {
    253253                /* We'll have to stick with plaintext. Let's hope we're using SSL/TLS... */
    254                 xt_add_child( reply, xt_new_node( "password", gc->acc->pass, NULL ) );
     254                xt_add_child( reply, xt_new_node( "password", ic->acc->pass, NULL ) );
    255255        }
    256256        else
     
    258258                xt_free_node( reply );
    259259               
    260                 hide_login_progress( gc, "Can't find suitable authentication method" );
    261                 signoff( gc );
     260                hide_login_progress( ic, "Can't find suitable authentication method" );
     261                signoff( ic );
    262262                return XT_ABORT;
    263263        }
    264264       
    265265        reply = jabber_make_packet( "iq", "set", NULL, reply );
    266         jabber_cache_add( gc, reply, jabber_finish_iq_auth );
    267         st = jabber_write_packet( gc, reply );
     266        jabber_cache_add( ic, reply, jabber_finish_iq_auth );
     267        st = jabber_write_packet( ic, reply );
    268268       
    269269        return st ? XT_HANDLED : XT_ABORT;
    270270}
    271271
    272 static xt_status jabber_finish_iq_auth( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )
    273 {
    274         struct jabber_data *jd = gc->proto_data;
     272static xt_status jabber_finish_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig )
     273{
     274        struct jabber_data *jd = ic->proto_data;
    275275        char *type;
    276276       
    277277        if( !( type = xt_find_attr( node, "type" ) ) )
    278278        {
    279                 serv_got_crap( gc, "WARNING: Received incomplete IQ packet while authenticating" );
    280                 signoff( gc );
     279                serv_got_crap( ic, "WARNING: Received incomplete IQ packet while authenticating" );
     280                signoff( ic );
    281281                return XT_HANDLED;
    282282        }
     
    284284        if( strcmp( type, "error" ) == 0 )
    285285        {
    286                 hide_login_progress( gc, "Authentication failure" );
    287                 signoff( gc );
     286                hide_login_progress( ic, "Authentication failure" );
     287                signoff( ic );
    288288                return XT_ABORT;
    289289        }
     
    293293                   old (non-SASL) way. */
    294294                jd->flags |= JFLAG_AUTHENTICATED;
    295                 if( !jabber_get_roster( gc ) )
     295                if( !jabber_get_roster( ic ) )
    296296                        return XT_ABORT;
    297297        }
     
    300300}
    301301
    302 xt_status jabber_pkt_bind_sess( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )
    303 {
    304         struct jabber_data *jd = gc->proto_data;
     302xt_status jabber_pkt_bind_sess( struct im_connection *ic, struct xt_node *node, struct xt_node *orig )
     303{
     304        struct jabber_data *jd = ic->proto_data;
    305305        struct xt_node *c;
    306306        char *s;
     
    310310                c = xt_find_node( c->children, "jid" );
    311311                if( c && c->text_len && ( s = strchr( c->text, '/' ) ) &&
    312                     strcmp( s + 1, set_getstr( &gc->acc->set, "resource" ) ) != 0 )
    313                         serv_got_crap( gc, "Server changed session resource string to `%s'", s + 1 );
     312                    strcmp( s + 1, set_getstr( &ic->acc->set, "resource" ) ) != 0 )
     313                        serv_got_crap( ic, "Server changed session resource string to `%s'", s + 1 );
    314314               
    315315                jd->flags &= ~JFLAG_WAIT_BIND;
     
    322322        if( ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 )
    323323        {
    324                 if( !jabber_get_roster( gc ) )
     324                if( !jabber_get_roster( ic ) )
    325325                        return XT_ABORT;
    326326        }
     
    329329}
    330330
    331 int jabber_get_roster( struct gaim_connection *gc )
     331int jabber_get_roster( struct im_connection *ic )
    332332{
    333333        struct xt_node *node;
    334334        int st;
    335335       
    336         set_login_progress( gc, 1, "Authenticated, requesting buddy list" );
     336        set_login_progress( ic, 1, "Authenticated, requesting buddy list" );
    337337       
    338338        node = xt_new_node( "query", NULL, NULL );
     
    340340        node = jabber_make_packet( "iq", "get", NULL, node );
    341341       
    342         jabber_cache_add( gc, node, jabber_parse_roster );
    343         st = jabber_write_packet( gc, node );
     342        jabber_cache_add( ic, node, jabber_parse_roster );
     343        st = jabber_write_packet( ic, node );
    344344       
    345345        return st;
    346346}
    347347
    348 static xt_status jabber_parse_roster( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )
     348static xt_status jabber_parse_roster( struct im_connection *ic, struct xt_node *node, struct xt_node *orig )
    349349{
    350350        struct xt_node *query, *c;
     
    353353        if( !( query = xt_find_node( node->children, "query" ) ) )
    354354        {
    355                 serv_got_crap( gc, "WARNING: Received NULL roster packet" );
     355                serv_got_crap( ic, "WARNING: Received NULL roster packet" );
    356356                return XT_HANDLED;
    357357        }
     
    371371                {
    372372                        if( ( strcmp( sub, "both" ) == 0 || strcmp( sub, "to" ) == 0 ) )
    373                                 add_buddy( gc, NULL, jid, name );
     373                                add_buddy( ic, NULL, jid, name );
    374374                }
    375375                else
     
    378378                        if( ( strcmp( sub, "both" ) == 0 || strcmp( sub, "to" ) == 0 ) )
    379379                        {
    380                                 if( find_buddy( gc, jid ) == NULL )
    381                                         add_buddy( gc, NULL, jid, name );
     380                                if( find_buddy( ic, jid ) == NULL )
     381                                        add_buddy( ic, NULL, jid, name );
    382382                                else if( name )
    383                                         serv_buddy_rename( gc, jid, name );
     383                                        serv_buddy_rename( ic, jid, name );
    384384                        }
    385385                        else if( strcmp( sub, "remove" ) == 0 )
     
    387387                                /* Don't have any API call for this yet! So let's
    388388                                   just try to handle this as well as we can. */
    389                                 jabber_buddy_remove_bare( gc, jid );
    390                                 serv_got_update( gc, jid, 0, 0, 0, 0, 0, 0 );
     389                                jabber_buddy_remove_bare( ic, jid );
     390                                serv_got_update( ic, jid, 0, 0, 0, 0, 0, 0 );
    391391                                /* FIXME! */
    392392                        }
     
    397397       
    398398        if( initial )
    399                 account_online( gc );
     399                account_online( ic );
    400400       
    401401        return XT_HANDLED;
    402402}
    403403
    404 int jabber_get_vcard( struct gaim_connection *gc, char *bare_jid )
     404int jabber_get_vcard( struct im_connection *ic, char *bare_jid )
    405405{
    406406        struct xt_node *node;
     
    413413        node = jabber_make_packet( "iq", "get", bare_jid, node );
    414414       
    415         jabber_cache_add( gc, node, jabber_iq_display_vcard );
    416         return jabber_write_packet( gc, node );
    417 }
    418 
    419 static xt_status jabber_iq_display_vcard( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )
    420 {
    421         struct xt_node *vc, *c, *sc; /* subchild, gc is already in use ;-) */
     415        jabber_cache_add( ic, node, jabber_iq_display_vcard );
     416        return jabber_write_packet( ic, node );
     417}
     418
     419static xt_status jabber_iq_display_vcard( struct im_connection *ic, struct xt_node *node, struct xt_node *orig )
     420{
     421        struct xt_node *vc, *c, *sc; /* subchild, ic is already in use ;-) */
    422422        GString *reply;
    423423        char *s;
     
    428428        {
    429429                s = xt_find_attr( orig, "to" ); /* If this returns NULL something's wrong.. */
    430                 serv_got_crap( gc, "Could not retrieve vCard of %s", s ? s : "(NULL)" );
     430                serv_got_crap( ic, "Could not retrieve vCard of %s", s ? s : "(NULL)" );
    431431                return XT_HANDLED;
    432432        }
     
    536536        /* *sigh* */
    537537       
    538         serv_got_crap( gc, reply->str );
     538        serv_got_crap( ic, reply->str );
    539539        g_string_free( reply, TRUE );
    540540       
     
    542542}
    543543
    544 int jabber_add_to_roster( struct gaim_connection *gc, char *handle, char *name )
     544int jabber_add_to_roster( struct im_connection *ic, char *handle, char *name )
    545545{
    546546        struct xt_node *node;
     
    558558        node = jabber_make_packet( "iq", "set", NULL, node );
    559559       
    560         st = jabber_write_packet( gc, node );
     560        st = jabber_write_packet( ic, node );
    561561       
    562562        xt_free_node( node );
     
    564564}
    565565
    566 int jabber_remove_from_roster( struct gaim_connection *gc, char *handle )
     566int jabber_remove_from_roster( struct im_connection *ic, char *handle )
    567567{
    568568        struct xt_node *node;
     
    579579        node = jabber_make_packet( "iq", "set", NULL, node );
    580580       
    581         st = jabber_write_packet( gc, node );
     581        st = jabber_write_packet( ic, node );
    582582       
    583583        xt_free_node( node );
Note: See TracChangeset for help on using the changeset viewer.