Changeset 0da65d5 for protocols/jabber


Ignore:
Timestamp:
2007-03-31T05:40:45Z (17 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. ;-)

Location:
protocols/jabber
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/io.c

    rfa29d093 r0da65d5  
    2626
    2727static gboolean jabber_write_callback( gpointer data, gint fd, b_input_condition cond );
    28 static gboolean jabber_write_queue( struct gaim_connection *gc );
    29 
    30 int jabber_write_packet( struct gaim_connection *gc, struct xt_node *node )
     28static gboolean jabber_write_queue( struct im_connection *ic );
     29
     30int jabber_write_packet( struct im_connection *ic, struct xt_node *node )
    3131{
    3232        char *buf;
     
    3434       
    3535        buf = xt_to_string( node );
    36         st = jabber_write( gc, buf, strlen( buf ) );
     36        st = jabber_write( ic, buf, strlen( buf ) );
    3737        g_free( buf );
    3838       
     
    4040}
    4141
    42 int jabber_write( struct gaim_connection *gc, char *buf, int len )
    43 {
    44         struct jabber_data *jd = gc->proto_data;
     42int jabber_write( struct im_connection *ic, char *buf, int len )
     43{
     44        struct jabber_data *jd = ic->proto_data;
    4545        gboolean ret;
    4646       
     
    5454                   it via the event handler. If not, add the handler. (In
    5555                   most cases it probably won't be necessary.) */
    56                 if( ( ret = jabber_write_queue( gc ) ) && jd->tx_len > 0 )
    57                         jd->w_inpa = b_input_add( jd->fd, GAIM_INPUT_WRITE, jabber_write_callback, gc );
     56                if( ( ret = jabber_write_queue( ic ) ) && jd->tx_len > 0 )
     57                        jd->w_inpa = b_input_add( jd->fd, GAIM_INPUT_WRITE, jabber_write_callback, ic );
    5858        }
    5959        else
     
    8585static gboolean jabber_write_callback( gpointer data, gint fd, b_input_condition cond )
    8686{
    87         struct jabber_data *jd = ((struct gaim_connection *)data)->proto_data;
     87        struct jabber_data *jd = ((struct im_connection *)data)->proto_data;
    8888       
    8989        return jd->fd != -1 &&
     
    9292}
    9393
    94 static gboolean jabber_write_queue( struct gaim_connection *gc )
    95 {
    96         struct jabber_data *jd = gc->proto_data;
     94static gboolean jabber_write_queue( struct im_connection *ic )
     95{
     96        struct jabber_data *jd = ic->proto_data;
    9797        int st;
    9898       
     
    117117                jd->fd = -1;
    118118               
    119                 hide_login_progress_error( gc, "Short write() to server" );
    120                 signoff( gc );
     119                hide_login_progress_error( ic, "Short write() to server" );
     120                signoff( ic );
    121121                return FALSE;
    122122        }
     
    142142static gboolean jabber_read_callback( gpointer data, gint fd, b_input_condition cond )
    143143{
    144         struct gaim_connection *gc = data;
    145         struct jabber_data *jd = gc->proto_data;
     144        struct im_connection *ic = data;
     145        struct jabber_data *jd = ic->proto_data;
    146146        char buf[512];
    147147        int st;
     
    160160                if( xt_feed( jd->xt, buf, st ) < 0 )
    161161                {
    162                         hide_login_progress_error( gc, "XML stream error" );
    163                         signoff( gc );
     162                        hide_login_progress_error( ic, "XML stream error" );
     163                        signoff( ic );
    164164                        return FALSE;
    165165                }
     
    176176                {
    177177                        jd->flags &= ~JFLAG_STREAM_RESTART;
    178                         jabber_start_stream( gc );
     178                        jabber_start_stream( ic );
    179179                }
    180180               
     
    196196                                   this is an old server that can't do SASL
    197197                                   authentication. */
    198                                 if( !sasl_supported( gc ) )
     198                                if( !sasl_supported( ic ) )
    199199                                {
    200200                                        /* If there's no version= tag, we suppose
    201201                                           this server does NOT implement: XMPP 1.0,
    202202                                           SASL and TLS. */
    203                                         if( set_getbool( &gc->acc->set, "tls" ) )
     203                                        if( set_getbool( &ic->acc->set, "tls" ) )
    204204                                        {
    205                                                 hide_login_progress( gc, "TLS is turned on for this "
     205                                                hide_login_progress( ic, "TLS is turned on for this "
    206206                                                          "account, but is not supported by this server" );
    207                                                 signoff( gc );
     207                                                signoff( ic );
    208208                                                return FALSE;
    209209                                        }
    210210                                        else
    211211                                        {
    212                                                 return jabber_init_iq_auth( gc );
     212                                                return jabber_init_iq_auth( ic );
    213213                                        }
    214214                                }
     
    216216                        else
    217217                        {
    218                                 hide_login_progress( gc, "XML stream error" );
    219                                 signoff( gc );
     218                                hide_login_progress( ic, "XML stream error" );
     219                                signoff( ic );
    220220                                return FALSE;
    221221                        }
     
    227227                jd->fd = -1;
    228228               
    229                 hide_login_progress_error( gc, "Error while reading from server" );
    230                 signoff( gc );
     229                hide_login_progress_error( ic, "Error while reading from server" );
     230                signoff( ic );
    231231                return FALSE;
    232232        }
     
    238238gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition cond )
    239239{
    240         struct gaim_connection *gc = data;
     240        struct im_connection *ic = data;
    241241       
    242242        if( source == -1 )
    243243        {
    244                 hide_login_progress( gc, "Could not connect to server" );
    245                 signoff( gc );
     244                hide_login_progress( ic, "Could not connect to server" );
     245                signoff( ic );
    246246                return FALSE;
    247247        }
    248248       
    249         set_login_progress( gc, 1, "Connected to server, logging in" );
    250        
    251         return jabber_start_stream( gc );
     249        set_login_progress( ic, 1, "Connected to server, logging in" );
     250       
     251        return jabber_start_stream( ic );
    252252}
    253253
    254254gboolean jabber_connected_ssl( gpointer data, void *source, b_input_condition cond )
    255255{
    256         struct gaim_connection *gc = data;
    257         struct jabber_data *jd = gc->proto_data;
     256        struct im_connection *ic = data;
     257        struct jabber_data *jd = ic->proto_data;
    258258       
    259259        if( source == NULL )
     
    263263                jd->ssl = NULL;
    264264               
    265                 hide_login_progress( gc, "Could not connect to server" );
    266                 signoff( gc );
     265                hide_login_progress( ic, "Could not connect to server" );
     266                signoff( ic );
    267267                return FALSE;
    268268        }
    269269       
    270         set_login_progress( gc, 1, "Connected to server, logging in" );
    271        
    272         return jabber_start_stream( gc );
     270        set_login_progress( ic, 1, "Connected to server, logging in" );
     271       
     272        return jabber_start_stream( ic );
    273273}
    274274
     
    281281static xt_status jabber_pkt_features( struct xt_node *node, gpointer data )
    282282{
    283         struct gaim_connection *gc = data;
    284         struct jabber_data *jd = gc->proto_data;
     283        struct im_connection *ic = data;
     284        struct jabber_data *jd = ic->proto_data;
    285285        struct xt_node *c, *reply;
    286286        int trytls;
    287287       
    288         trytls = g_strcasecmp( set_getstr( &gc->acc->set, "tls" ), "try" ) == 0;
     288        trytls = g_strcasecmp( set_getstr( &ic->acc->set, "tls" ), "try" ) == 0;
    289289        c = xt_find_node( node->children, "starttls" );
    290290        if( c && !jd->ssl )
     
    295295                c = xt_find_node( c->children, "required" );
    296296               
    297                 if( c && ( !trytls && !set_getbool( &gc->acc->set, "tls" ) ) )
    298                 {
    299                         hide_login_progress( gc, "Server requires TLS connections, but TLS is turned off for this account" );
    300                         signoff( gc );
     297                if( c && ( !trytls && !set_getbool( &ic->acc->set, "tls" ) ) )
     298                {
     299                        hide_login_progress( ic, "Server requires TLS connections, but TLS is turned off for this account" );
     300                        signoff( ic );
    301301                       
    302302                        return XT_ABORT;
     
    304304               
    305305                /* Only run this if the tls setting is set to true or try: */
    306                 if( ( trytls || set_getbool( &gc->acc->set, "tls" ) ) )
     306                if( ( trytls || set_getbool( &ic->acc->set, "tls" ) ) )
    307307                {
    308308                        reply = xt_new_node( "starttls", NULL, NULL );
    309309                        xt_add_attr( reply, "xmlns", XMLNS_TLS );
    310                         if( !jabber_write_packet( gc, reply ) )
     310                        if( !jabber_write_packet( ic, reply ) )
    311311                        {
    312312                                xt_free_node( reply );
     
    325325                   using SSL/TLS. */
    326326               
    327                 if( !trytls && set_getbool( &gc->acc->set, "tls" ) )
    328                 {
    329                         hide_login_progress( gc, "TLS is turned on for this account, but is not supported by this server" );
    330                         signoff( gc );
     327                if( !trytls && set_getbool( &ic->acc->set, "tls" ) )
     328                {
     329                        hide_login_progress( ic, "TLS is turned on for this account, but is not supported by this server" );
     330                        signoff( ic );
    331331                       
    332332                        return XT_ABORT;
     
    346346           other way. jabber.com doesn't seem to do SASL while it pretends
    347347           to be XMPP 1.0 compliant! */
    348         else if( !( jd->flags & JFLAG_AUTHENTICATED ) && sasl_supported( gc ) )
    349         {
    350                 if( !jabber_init_iq_auth( gc ) )
     348        else if( !( jd->flags & JFLAG_AUTHENTICATED ) && sasl_supported( ic ) )
     349        {
     350                if( !jabber_init_iq_auth( ic ) )
    351351                        return XT_ABORT;
    352352        }
     
    354354        if( ( c = xt_find_node( node->children, "bind" ) ) )
    355355        {
    356                 reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &gc->acc->set, "resource" ), NULL ) );
     356                reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) );
    357357                xt_add_attr( reply, "xmlns", XMLNS_BIND );
    358358                reply = jabber_make_packet( "iq", "set", NULL, reply );
    359                 jabber_cache_add( gc, reply, jabber_pkt_bind_sess );
    360                
    361                 if( !jabber_write_packet( gc, reply ) )
     359                jabber_cache_add( ic, reply, jabber_pkt_bind_sess );
     360               
     361                if( !jabber_write_packet( ic, reply ) )
    362362                        return XT_ABORT;
    363363               
     
    370370                xt_add_attr( reply, "xmlns", XMLNS_SESSION );
    371371                reply = jabber_make_packet( "iq", "set", NULL, reply );
    372                 jabber_cache_add( gc, reply, jabber_pkt_bind_sess );
    373                
    374                 if( !jabber_write_packet( gc, reply ) )
     372                jabber_cache_add( ic, reply, jabber_pkt_bind_sess );
     373               
     374                if( !jabber_write_packet( ic, reply ) )
    375375                        return XT_ABORT;
    376376               
     
    383383        if( jd->flags & JFLAG_AUTHENTICATED && ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 )
    384384        {
    385                 if( !jabber_get_roster( gc ) )
     385                if( !jabber_get_roster( ic ) )
    386386                        return XT_ABORT;
    387387        }
     
    392392static xt_status jabber_pkt_proceed_tls( struct xt_node *node, gpointer data )
    393393{
    394         struct gaim_connection *gc = data;
    395         struct jabber_data *jd = gc->proto_data;
     394        struct im_connection *ic = data;
     395        struct jabber_data *jd = ic->proto_data;
    396396        char *xmlns;
    397397       
     
    417417        jd->w_inpa = jd->r_inpa = 0;
    418418       
    419         set_login_progress( gc, 1, "Converting stream to TLS" );
    420        
    421         jd->ssl = ssl_starttls( jd->fd, jabber_connected_ssl, gc );
     419        set_login_progress( ic, 1, "Converting stream to TLS" );
     420       
     421        jd->ssl = ssl_starttls( jd->fd, jabber_connected_ssl, ic );
    422422       
    423423        return XT_HANDLED;
     
    426426static xt_status jabber_pkt_stream_error( struct xt_node *node, gpointer data )
    427427{
    428         struct gaim_connection *gc = data;
     428        struct im_connection *ic = data;
    429429        struct xt_node *c;
    430430        char *s, *type = NULL, *text = NULL;
     
    452452        if( type == NULL )
    453453        {
    454                 hide_login_progress_error( gc, "Unknown stream error reported by server" );
    455                 signoff( gc );
     454                hide_login_progress_error( ic, "Unknown stream error reported by server" );
     455                signoff( ic );
    456456                return XT_ABORT;
    457457        }
     
    462462        if( strcmp( type, "conflict" ) == 0 )
    463463        {
    464                 hide_login_progress( gc, "Account and resource used from a different location" );
    465                 gc->wants_to_die = TRUE;
     464                hide_login_progress( ic, "Account and resource used from a different location" );
     465                ic->wants_to_die = TRUE;
    466466        }
    467467        else
    468468        {
    469469                s = g_strdup_printf( "Stream error: %s%s%s", type, text ? ": " : "", text ? text : "" );
    470                 hide_login_progress_error( gc, s );
     470                hide_login_progress_error( ic, s );
    471471                g_free( s );
    472472        }
    473473       
    474         signoff( gc );
     474        signoff( ic );
    475475       
    476476        return XT_ABORT;
     
    500500};
    501501
    502 gboolean jabber_start_stream( struct gaim_connection *gc )
    503 {
    504         struct jabber_data *jd = gc->proto_data;
     502gboolean jabber_start_stream( struct im_connection *ic )
     503{
     504        struct jabber_data *jd = ic->proto_data;
    505505        int st;
    506506        char *greet;
     
    509509           from the server too. */
    510510        xt_free( jd->xt );      /* In case we're RE-starting. */
    511         jd->xt = xt_new( gc );
     511        jd->xt = xt_new( ic );
    512512        jd->xt->handlers = (struct xt_handler_entry*) jabber_handlers;
    513513       
    514514        if( jd->r_inpa <= 0 )
    515                 jd->r_inpa = b_input_add( jd->fd, GAIM_INPUT_READ, jabber_read_callback, gc );
     515                jd->r_inpa = b_input_add( jd->fd, GAIM_INPUT_READ, jabber_read_callback, ic );
    516516       
    517517        greet = g_strdup_printf( "<?xml version='1.0' ?>"
     
    519519                                  "xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\">", jd->server );
    520520       
    521         st = jabber_write( gc, greet, strlen( greet ) );
     521        st = jabber_write( ic, greet, strlen( greet ) );
    522522       
    523523        g_free( greet );
     
    526526}
    527527
    528 void jabber_end_stream( struct gaim_connection *gc )
    529 {
    530         struct jabber_data *jd = gc->proto_data;
     528void jabber_end_stream( struct im_connection *ic )
     529{
     530        struct jabber_data *jd = ic->proto_data;
    531531       
    532532        /* Let's only do this if the queue is currently empty, otherwise it'd
     
    538538                int st = 1;
    539539               
    540                 if( gc->flags & OPT_LOGGED_IN )
     540                if( ic->flags & OPT_LOGGED_IN )
    541541                {
    542542                        node = jabber_make_packet( "presence", "unavailable", NULL, NULL );
    543                         st = jabber_write_packet( gc, node );
     543                        st = jabber_write_packet( ic, node );
    544544                        xt_free_node( node );
    545545                }
    546546               
    547547                if( st )
    548                         jabber_write( gc, eos, strlen( eos ) );
    549         }
    550 }
     548                        jabber_write( ic, eos, strlen( eos ) );
     549        }
     550}
  • 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 );
  • protocols/jabber/jabber.c

    rfa29d093 r0da65d5  
    3333#include "jabber.h"
    3434
    35 static void jabber_acc_init( account_t *acc )
     35static void jabber_init( account_t *acc )
    3636{
    3737        set_t *s;
     
    5959static void jabber_login( account_t *acc )
    6060{
    61         struct gaim_connection *gc = new_gaim_conn( acc );
     61        struct im_connection *ic = new_gaim_conn( acc );
    6262        struct jabber_data *jd = g_new0( struct jabber_data, 1 );
    6363        struct ns_srv_reply *srv = NULL;
    6464        char *connect_to, *s;
    6565       
    66         jd->gc = gc;
    67         gc->proto_data = jd;
     66        jd->ic = ic;
     67        ic->proto_data = jd;
    6868       
    6969        jd->username = g_strdup( acc->user );
     
    7272        if( jd->server == NULL )
    7373        {
    74                 hide_login_progress( gc, "Incomplete account name (format it like <username@jabberserver.name>)" );
    75                 signoff( gc );
     74                hide_login_progress( ic, "Incomplete account name (format it like <username@jabberserver.name>)" );
     75                signoff( ic );
    7676                return;
    7777        }
     
    159159                connect_to = jd->server;
    160160       
    161         set_login_progress( gc, 0, "Connecting" );
     161        set_login_progress( ic, 0, "Connecting" );
    162162       
    163163        if( set_getint( &acc->set, "port" ) < JABBER_PORT_MIN ||
    164164            set_getint( &acc->set, "port" ) > JABBER_PORT_MAX )
    165165        {
    166                 serv_got_crap( gc, "Incorrect port number, must be in the %d-%d range",
     166                serv_got_crap( ic, "Incorrect port number, must be in the %d-%d range",
    167167                               JABBER_PORT_MIN, JABBER_PORT_MAX );
    168                 signoff( gc );
     168                signoff( ic );
    169169                return;
    170170        }
     
    175175        if( set_getbool( &acc->set, "ssl" ) )
    176176        {
    177                 jd->ssl = ssl_connect( connect_to, set_getint( &acc->set, "port" ), jabber_connected_ssl, gc );
     177                jd->ssl = ssl_connect( connect_to, set_getint( &acc->set, "port" ), jabber_connected_ssl, ic );
    178178                jd->fd = jd->ssl ? ssl_getfd( jd->ssl ) : -1;
    179179        }
    180180        else
    181181        {
    182                 jd->fd = proxy_connect( connect_to, srv ? srv->port : set_getint( &acc->set, "port" ), jabber_connected_plain, gc );
     182                jd->fd = proxy_connect( connect_to, srv ? srv->port : set_getint( &acc->set, "port" ), jabber_connected_plain, ic );
    183183        }
    184184        g_free( srv );
     
    186186        if( jd->fd == -1 )
    187187        {
    188                 hide_login_progress( gc, "Could not connect to server" );
    189                 signoff( gc );
    190         }
    191 }
    192 
    193 static void jabber_close( struct gaim_connection *gc )
    194 {
    195         struct jabber_data *jd = gc->proto_data;
    196        
    197         jabber_end_stream( gc );
     188                hide_login_progress( ic, "Could not connect to server" );
     189                signoff( ic );
     190        }
     191}
     192
     193static void jabber_logout( struct im_connection *ic )
     194{
     195        struct jabber_data *jd = ic->proto_data;
     196       
     197        jabber_end_stream( ic );
    198198       
    199199        if( jd->r_inpa >= 0 )
     
    219219}
    220220
    221 static int jabber_send_im( struct gaim_connection *gc, char *who, char *message, int len, int away )
    222 {
    223         struct jabber_data *jd = gc->proto_data;
     221static int jabber_send_im( struct im_connection *ic, char *who, char *message, int flags )
     222{
     223        struct jabber_data *jd = ic->proto_data;
    224224        struct jabber_buddy *bud;
    225225        struct xt_node *node;
    226226        int st;
    227227       
    228         bud = jabber_buddy_by_jid( gc, who, 0 );
     228        bud = jabber_buddy_by_jid( ic, who, 0 );
    229229       
    230230        node = xt_new_node( "body", message, NULL );
     
    251251        }
    252252       
    253         st = jabber_write_packet( gc, node );
     253        st = jabber_write_packet( ic, node );
    254254        xt_free_node( node );
    255255       
     
    257257}
    258258
    259 static GList *jabber_away_states( struct gaim_connection *gc )
     259static GList *jabber_away_states( struct im_connection *ic )
    260260{
    261261        static GList *l = NULL;
     
    269269}
    270270
    271 static void jabber_get_info( struct gaim_connection *gc, char *who )
    272 {
    273         struct jabber_data *jd = gc->proto_data;
     271static void jabber_get_info( struct im_connection *ic, char *who )
     272{
     273        struct jabber_data *jd = ic->proto_data;
    274274        struct jabber_buddy *bud;
    275275       
    276276        if( strchr( who, '/' ) )
    277                 bud = jabber_buddy_by_jid( gc, who, 0 );
     277                bud = jabber_buddy_by_jid( ic, who, 0 );
    278278        else
    279279        {
     
    285285        while( bud )
    286286        {
    287                 serv_got_crap( gc, "Buddy %s (%d) information:\nAway state: %s\nAway message: %s",
     287                serv_got_crap( ic, "Buddy %s (%d) information:\nAway state: %s\nAway message: %s",
    288288                                   bud->full_jid, bud->priority,
    289289                                   bud->away_state ? bud->away_state->full_name : "(none)",
     
    292292        }
    293293       
    294         jabber_get_vcard( gc, bud ? bud->full_jid : who );
    295 }
    296 
    297 static void jabber_set_away( struct gaim_connection *gc, char *state_txt, char *message )
    298 {
    299         struct jabber_data *jd = gc->proto_data;
     294        jabber_get_vcard( ic, bud ? bud->full_jid : who );
     295}
     296
     297static void jabber_set_away( struct im_connection *ic, char *state_txt, char *message )
     298{
     299        struct jabber_data *jd = ic->proto_data;
    300300        struct jabber_away_state *state;
    301301       
     
    306306        jd->away_message = ( message && *message ) ? g_strdup( message ) : NULL;
    307307       
    308         presence_send_update( gc );
    309 }
    310 
    311 static void jabber_add_buddy( struct gaim_connection *gc, char *who )
    312 {
    313         if( jabber_add_to_roster( gc, who, NULL ) )
    314                 presence_send_request( gc, who, "subscribe" );
    315 }
    316 
    317 static void jabber_remove_buddy( struct gaim_connection *gc, char *who, char *group )
     308        presence_send_update( ic );
     309}
     310
     311static void jabber_add_buddy( struct im_connection *ic, char *who, char *group )
     312{
     313        if( jabber_add_to_roster( ic, who, NULL ) )
     314                presence_send_request( ic, who, "subscribe" );
     315}
     316
     317static void jabber_remove_buddy( struct im_connection *ic, char *who, char *group )
    318318{
    319319        /* We should always do this part. Clean up our administration a little bit. */
    320         jabber_buddy_remove_bare( gc, who );
    321        
    322         if( jabber_remove_from_roster( gc, who ) )
    323                 presence_send_request( gc, who, "unsubscribe" );
    324 }
    325 
    326 static void jabber_keepalive( struct gaim_connection *gc )
     320        jabber_buddy_remove_bare( ic, who );
     321       
     322        if( jabber_remove_from_roster( ic, who ) )
     323                presence_send_request( ic, who, "unsubscribe" );
     324}
     325
     326static void jabber_keepalive( struct im_connection *ic )
    327327{
    328328        /* Just any whitespace character is enough as a keepalive for XMPP sessions. */
    329         jabber_write( gc, "\n", 1 );
     329        jabber_write( ic, "\n", 1 );
    330330       
    331331        /* This runs the garbage collection every minute, which means every packet
    332332           is in the cache for about a minute (which should be enough AFAIK). */
    333         jabber_cache_clean( gc );
    334 }
    335 
    336 static int jabber_send_typing( struct gaim_connection *gc, char *who, int typing )
    337 {
    338         struct jabber_data *jd = gc->proto_data;
     333        jabber_cache_clean( ic );
     334}
     335
     336static int jabber_send_typing( struct im_connection *ic, char *who, int typing )
     337{
     338        struct jabber_data *jd = ic->proto_data;
    339339        struct jabber_buddy *bud;
    340340       
     
    342342        jd->flags |= JFLAG_WANT_TYPING;
    343343       
    344         if( ( bud = jabber_buddy_by_jid( gc, who, 0 ) ) == NULL )
     344        if( ( bud = jabber_buddy_by_jid( ic, who, 0 ) ) == NULL )
    345345        {
    346346                /* Sending typing notifications to unknown buddies is
     
    369369                node = jabber_make_packet( "message", "chat", bud->full_jid, node );
    370370               
    371                 st = jabber_write_packet( gc, node );
     371                st = jabber_write_packet( ic, node );
    372372                xt_free_node( node );
    373373               
     
    378378}
    379379
    380 void jabber_init()
     380void jabber_initmodule()
    381381{
    382382        struct prpl *ret = g_new0( struct prpl, 1 );
     
    384384        ret->name = "jabber";
    385385        ret->login = jabber_login;
    386         ret->acc_init = jabber_acc_init;
    387         ret->close = jabber_close;
     386        ret->init = jabber_init;
     387        ret->logout = jabber_logout;
    388388        ret->send_im = jabber_send_im;
    389389        ret->away_states = jabber_away_states;
  • protocols/jabber/jabber.h

    rfa29d093 r0da65d5  
    5858struct jabber_data
    5959{
    60         struct gaim_connection *gc;
     60        struct im_connection *ic;
    6161       
    6262        int fd;
     
    8787};
    8888
    89 typedef xt_status (*jabber_cache_event) ( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );
     89typedef xt_status (*jabber_cache_event) ( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );
    9090
    9191struct jabber_cache_entry
     
    137137/* iq.c */
    138138xt_status jabber_pkt_iq( struct xt_node *node, gpointer data );
    139 int jabber_init_iq_auth( struct gaim_connection *gc );
    140 xt_status jabber_pkt_bind_sess( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );
    141 int jabber_get_roster( struct gaim_connection *gc );
    142 int jabber_get_vcard( struct gaim_connection *gc, char *bare_jid );
    143 int jabber_add_to_roster( struct gaim_connection *gc, char *handle, char *name );
    144 int jabber_remove_from_roster( struct gaim_connection *gc, char *handle );
     139int jabber_init_iq_auth( struct im_connection *ic );
     140xt_status jabber_pkt_bind_sess( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );
     141int jabber_get_roster( struct im_connection *ic );
     142int jabber_get_vcard( struct im_connection *ic, char *bare_jid );
     143int jabber_add_to_roster( struct im_connection *ic, char *handle, char *name );
     144int jabber_remove_from_roster( struct im_connection *ic, char *handle );
    145145
    146146/* message.c */
     
    149149/* presence.c */
    150150xt_status jabber_pkt_presence( struct xt_node *node, gpointer data );
    151 int presence_send_update( struct gaim_connection *gc );
    152 int presence_send_request( struct gaim_connection *gc, char *handle, char *request );
     151int presence_send_update( struct im_connection *ic );
     152int presence_send_request( struct im_connection *ic, char *handle, char *request );
    153153
    154154/* jabber_util.c */
     
    157157struct xt_node *jabber_make_packet( char *name, char *type, char *to, struct xt_node *children );
    158158struct xt_node *jabber_make_error_packet( struct xt_node *orig, char *err_cond, char *err_type );
    159 void jabber_cache_add( struct gaim_connection *gc, struct xt_node *node, jabber_cache_event func );
    160 struct xt_node *jabber_cache_get( struct gaim_connection *gc, char *id );
     159void jabber_cache_add( struct im_connection *ic, struct xt_node *node, jabber_cache_event func );
     160struct xt_node *jabber_cache_get( struct im_connection *ic, char *id );
    161161void jabber_cache_entry_free( gpointer entry );
    162 void jabber_cache_clean( struct gaim_connection *gc );
     162void jabber_cache_clean( struct im_connection *ic );
    163163const struct jabber_away_state *jabber_away_state_by_code( char *code );
    164164const struct jabber_away_state *jabber_away_state_by_name( char *name );
    165 void jabber_buddy_ask( struct gaim_connection *gc, char *handle );
     165void jabber_buddy_ask( struct im_connection *ic, char *handle );
    166166char *jabber_normalize( char *orig );
    167167
     
    172172} get_buddy_flags_t;
    173173
    174 struct jabber_buddy *jabber_buddy_add( struct gaim_connection *gc, char *full_jid );
    175 struct jabber_buddy *jabber_buddy_by_jid( struct gaim_connection *gc, char *jid, get_buddy_flags_t flags );
    176 int jabber_buddy_remove( struct gaim_connection *gc, char *full_jid );
    177 int jabber_buddy_remove_bare( struct gaim_connection *gc, char *bare_jid );
     174struct jabber_buddy *jabber_buddy_add( struct im_connection *ic, char *full_jid );
     175struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid, get_buddy_flags_t flags );
     176int jabber_buddy_remove( struct im_connection *ic, char *full_jid );
     177int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid );
    178178
    179179extern const struct jabber_away_state jabber_away_state_list[];
    180180
    181181/* io.c */
    182 int jabber_write_packet( struct gaim_connection *gc, struct xt_node *node );
    183 int jabber_write( struct gaim_connection *gc, char *buf, int len );
     182int jabber_write_packet( struct im_connection *ic, struct xt_node *node );
     183int jabber_write( struct im_connection *ic, char *buf, int len );
    184184gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition cond );
    185185gboolean jabber_connected_ssl( gpointer data, void *source, b_input_condition cond );
    186 gboolean jabber_start_stream( struct gaim_connection *gc );
    187 void jabber_end_stream( struct gaim_connection *gc );
     186gboolean jabber_start_stream( struct im_connection *ic );
     187void jabber_end_stream( struct im_connection *ic );
    188188
    189189/* sasl.c */
     
    191191xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data );
    192192xt_status sasl_pkt_result( struct xt_node *node, gpointer data );
    193 gboolean sasl_supported( struct gaim_connection *gc );
     193gboolean sasl_supported( struct im_connection *ic );
    194194
    195195#endif
  • protocols/jabber/jabber_util.c

    rfa29d093 r0da65d5  
    4242        /* Only run this stuff if the account is online ATM,
    4343           and if the setting seems to be acceptable. */
    44         if( acc->gc )
     44        if( acc->ic )
    4545        {
    4646                /* Although set_eval functions usually are very nice and
     
    5858                /* (Yes, sorry, I prefer the hack. :-P) */
    5959               
    60                 presence_send_update( acc->gc );
     60                presence_send_update( acc->ic );
    6161        }
    6262       
     
    130130   them when you receive the response. Use this BEFORE sending the packet so
    131131   it'll get a new id= tag, and do NOT free() the packet after writing it! */
    132 void jabber_cache_add( struct gaim_connection *gc, struct xt_node *node, jabber_cache_event func )
    133 {
    134         struct jabber_data *jd = gc->proto_data;
     132void jabber_cache_add( struct im_connection *ic, struct xt_node *node, jabber_cache_event func )
     133{
     134        struct jabber_data *jd = ic->proto_data;
    135135        char *id = g_strdup_printf( "%s%05x", JABBER_CACHED_ID, ( next_id++ ) & 0xfffff );
    136136        struct jabber_cache_entry *entry = g_new0( struct jabber_cache_entry, 1 );
     
    159159   node should be available in the cache for at least a minute (assuming the
    160160   function is indeed called every minute). */
    161 void jabber_cache_clean( struct gaim_connection *gc )
    162 {
    163         struct jabber_data *jd = gc->proto_data;
     161void jabber_cache_clean( struct im_connection *ic )
     162{
     163        struct jabber_data *jd = ic->proto_data;
    164164       
    165165        g_hash_table_foreach_remove( jd->node_cache, jabber_cache_clean_entry, NULL );
     
    214214struct jabber_buddy_ask_data
    215215{
    216         struct gaim_connection *gc;
     216        struct im_connection *ic;
    217217        char *handle;
    218218        char *realname;
     
    221221static void jabber_buddy_ask_yes( gpointer w, struct jabber_buddy_ask_data *bla )
    222222{
    223         presence_send_request( bla->gc, bla->handle, "subscribed" );
    224        
    225         if( find_buddy( bla->gc, bla->handle ) == NULL )
    226                 show_got_added( bla->gc, bla->handle, NULL );
     223        presence_send_request( bla->ic, bla->handle, "subscribed" );
     224       
     225        if( find_buddy( bla->ic, bla->handle ) == NULL )
     226                show_got_added( bla->ic, bla->handle, NULL );
    227227       
    228228        g_free( bla->handle );
     
    232232static void jabber_buddy_ask_no( gpointer w, struct jabber_buddy_ask_data *bla )
    233233{
    234         presence_send_request( bla->gc, bla->handle, "subscribed" );
     234        presence_send_request( bla->ic, bla->handle, "subscribed" );
    235235       
    236236        g_free( bla->handle );
     
    238238}
    239239
    240 void jabber_buddy_ask( struct gaim_connection *gc, char *handle )
     240void jabber_buddy_ask( struct im_connection *ic, char *handle )
    241241{
    242242        struct jabber_buddy_ask_data *bla = g_new0( struct jabber_buddy_ask_data, 1 );
    243243        char *buf;
    244244       
    245         bla->gc = gc;
     245        bla->ic = ic;
    246246        bla->handle = g_strdup( handle );
    247247       
    248248        buf = g_strdup_printf( "The user %s wants to add you to his/her buddy list.", handle );
    249         do_ask_dialog( gc, buf, bla, jabber_buddy_ask_yes, jabber_buddy_ask_no );
     249        do_ask_dialog( ic, buf, bla, jabber_buddy_ask_yes, jabber_buddy_ask_no );
    250250        g_free( buf );
    251251}
     
    271271   to deal with that properly. Set their ->resource property to NULL. Do *NOT*
    272272   allow to mix this stuff, though... */
    273 struct jabber_buddy *jabber_buddy_add( struct gaim_connection *gc, char *full_jid_ )
    274 {
    275         struct jabber_data *jd = gc->proto_data;
     273struct jabber_buddy *jabber_buddy_add( struct im_connection *ic, char *full_jid_ )
     274{
     275        struct jabber_data *jd = ic->proto_data;
    276276        struct jabber_buddy *bud, *new, *bi;
    277277        char *s, *full_jid;
     
    343343   asked for a bare JID, it uses the "resource_select" setting to see which
    344344   resource to pick. */
    345 struct jabber_buddy *jabber_buddy_by_jid( struct gaim_connection *gc, char *jid_, get_buddy_flags_t flags )
    346 {
    347         struct jabber_data *jd = gc->proto_data;
     345struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_, get_buddy_flags_t flags )
     346{
     347        struct jabber_data *jd = ic->proto_data;
    348348        struct jabber_buddy *bud;
    349349        char *s, *jid;
     
    371371                }
    372372               
    373                 if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && find_buddy( gc, jid ) )
     373                if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && find_buddy( ic, jid ) )
    374374                {
    375375                        *s = '/';
    376                         bud = jabber_buddy_add( gc, jid );
     376                        bud = jabber_buddy_add( ic, jid );
    377377                }
    378378               
     
    391391                if( bud == NULL )
    392392                        /* No match. Create it now? */
    393                         return ( ( flags & GET_BUDDY_CREAT ) && find_buddy( gc, jid_ ) ) ?
    394                                    jabber_buddy_add( gc, jid_ ) : NULL;
     393                        return ( ( flags & GET_BUDDY_CREAT ) && find_buddy( ic, jid_ ) ) ?
     394                                   jabber_buddy_add( ic, jid_ ) : NULL;
    395395                else if( bud->resource && ( flags & GET_BUDDY_EXACT ) )
    396396                        /* We want an exact match, so in thise case there shouldn't be a /resource. */
     
    409409                }
    410410               
    411                 if( ( set = set_getstr( &gc->acc->set, "resource_select" ) ) == NULL )
     411                if( ( set = set_getstr( &ic->acc->set, "resource_select" ) ) == NULL )
    412412                        return NULL;
    413413                else if( strcmp( set, "activity" ) == 0 )
     
    421421   off-line (because (s)he can still be online from a different location.
    422422   XXX: See above, we should accept bare JIDs too... */
    423 int jabber_buddy_remove( struct gaim_connection *gc, char *full_jid_ )
    424 {
    425         struct jabber_data *jd = gc->proto_data;
     423int jabber_buddy_remove( struct im_connection *ic, char *full_jid_ )
     424{
     425        struct jabber_data *jd = ic->proto_data;
    426426        struct jabber_buddy *bud, *prev, *bi;
    427427        char *s, *full_jid;
     
    495495   specified bare JID. Use this when removing someone from the contact
    496496   list, for example. */
    497 int jabber_buddy_remove_bare( struct gaim_connection *gc, char *bare_jid_ )
    498 {
    499         struct jabber_data *jd = gc->proto_data;
     497int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid_ )
     498{
     499        struct jabber_data *jd = ic->proto_data;
    500500        struct jabber_buddy *bud, *next;
    501501        char *bare_jid;
  • protocols/jabber/message.c

    rfa29d093 r0da65d5  
    2626xt_status jabber_pkt_message( struct xt_node *node, gpointer data )
    2727{
    28         struct gaim_connection *gc = data;
     28        struct im_connection *ic = data;
    2929        char *from = xt_find_attr( node, "from" );
    3030        char *type = xt_find_attr( node, "type" );
     
    4747                if( ( s = strchr( from, '/' ) ) )
    4848                {
    49                         if( ( bud = jabber_buddy_by_jid( gc, from, GET_BUDDY_EXACT ) ) )
     49                        if( ( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT ) ) )
    5050                                bud->last_act = time( NULL );
    5151                        else
     
    7676               
    7777                if( fullmsg->len > 0 )
    78                         serv_got_im( gc, bud ? bud->bare_jid : from, fullmsg->str, 0, 0, fullmsg->len );
     78                        serv_got_im( ic, bud ? bud->bare_jid : from, fullmsg->str, 0, 0, fullmsg->len );
    7979               
    8080                g_string_free( fullmsg, TRUE );
     
    8484                {
    8585                        bud->flags |= JBFLAG_DOES_XEP85;
    86                         serv_got_typing( gc, bud ? bud->bare_jid : from, 0, 1 );
     86                        serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 1 );
    8787                }
    8888                /* No need to send a "stopped typing" signal when there's a message. */
     
    9090                {
    9191                        bud->flags |= JBFLAG_DOES_XEP85;
    92                         serv_got_typing( gc, bud ? bud->bare_jid : from, 0, 0 );
     92                        serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 0 );
    9393                }
    9494                else if( xt_find_node( node->children, "paused" ) )
    9595                {
    9696                        bud->flags |= JBFLAG_DOES_XEP85;
    97                         serv_got_typing( gc, bud ? bud->bare_jid : from, 0, 2 );
     97                        serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 2 );
    9898                }
    9999               
  • protocols/jabber/presence.c

    rfa29d093 r0da65d5  
    2626xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
    2727{
    28         struct gaim_connection *gc = data;
     28        struct im_connection *ic = data;
    2929        char *from = xt_find_attr( node, "from" );
    3030        char *type = xt_find_attr( node, "type" );      /* NULL should mean the person is online. */
     
    3838        if( type == NULL )
    3939        {
    40                 if( !( bud = jabber_buddy_by_jid( gc, from, GET_BUDDY_EXACT | GET_BUDDY_CREAT ) ) )
     40                if( !( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT | GET_BUDDY_CREAT ) ) )
    4141                {
    42                         if( set_getbool( &gc->irc->set, "debug" ) )
    43                                 serv_got_crap( gc, "WARNING: Could not handle presence information from JID: %s", from );
     42                        if( set_getbool( &ic->irc->set, "debug" ) )
     43                                serv_got_crap( ic, "WARNING: Could not handle presence information from JID: %s", from );
    4444                        return XT_HANDLED;
    4545                }
     
    6666                        bud->priority = 0;
    6767               
    68                 serv_got_update( gc, bud->bare_jid, 1, 0, 0, 0,
     68                serv_got_update( ic, bud->bare_jid, 1, 0, 0, 0,
    6969                                 bud->away_state ? UC_UNAVAILABLE : 0, 0 );
    7070        }
    7171        else if( strcmp( type, "unavailable" ) == 0 )
    7272        {
    73                 if( jabber_buddy_by_jid( gc, from, GET_BUDDY_EXACT ) == NULL )
     73                if( jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT ) == NULL )
    7474                {
    75                         if( set_getbool( &gc->irc->set, "debug" ) )
    76                                 serv_got_crap( gc, "WARNING: Received presence information from unknown JID: %s", from );
     75                        if( set_getbool( &ic->irc->set, "debug" ) )
     76                                serv_got_crap( ic, "WARNING: Received presence information from unknown JID: %s", from );
    7777                        return XT_HANDLED;
    7878                }
    7979               
    80                 jabber_buddy_remove( gc, from );
     80                jabber_buddy_remove( ic, from );
    8181               
    8282                if( ( s = strchr( from, '/' ) ) )
     
    8686                        /* Only count this as offline if there's no other resource
    8787                           available anymore. */
    88                         if( jabber_buddy_by_jid( gc, from, 0 ) == NULL )
    89                                 serv_got_update( gc, from, 0, 0, 0, 0, 0, 0 );
     88                        if( jabber_buddy_by_jid( ic, from, 0 ) == NULL )
     89                                serv_got_update( ic, from, 0, 0, 0, 0, 0, 0 );
    9090                       
    9191                        *s = '/';
     
    9393                else
    9494                {
    95                         serv_got_update( gc, from, 0, 0, 0, 0, 0, 0 );
     95                        serv_got_update( ic, from, 0, 0, 0, 0, 0, 0 );
    9696                }
    9797        }
    9898        else if( strcmp( type, "subscribe" ) == 0 )
    9999        {
    100                 jabber_buddy_ask( gc, from );
     100                jabber_buddy_ask( ic, from );
    101101        }
    102102        else if( strcmp( type, "subscribed" ) == 0 )
    103103        {
    104104                /* Not sure about this one, actually... */
    105                 serv_got_crap( gc, "%s just accepted your authorization request", from );
     105                serv_got_crap( ic, "%s just accepted your authorization request", from );
    106106        }
    107107        else if( strcmp( type, "unsubscribe" ) == 0 || strcmp( type, "unsubscribed" ) == 0 )
     
    131131/* Whenever presence information is updated, call this function to inform the
    132132   server. */
    133 int presence_send_update( struct gaim_connection *gc )
     133int presence_send_update( struct im_connection *ic )
    134134{
    135         struct jabber_data *jd = gc->proto_data;
     135        struct jabber_data *jd = ic->proto_data;
    136136        struct xt_node *node;
    137137        char *show = jd->away_state->code;
     
    140140       
    141141        node = jabber_make_packet( "presence", NULL, NULL, NULL );
    142         xt_add_child( node, xt_new_node( "priority", set_getstr( &gc->acc->set, "priority" ), NULL ) );
     142        xt_add_child( node, xt_new_node( "priority", set_getstr( &ic->acc->set, "priority" ), NULL ) );
    143143        if( show && *show )
    144144                xt_add_child( node, xt_new_node( "show", show, NULL ) );
     
    146146                xt_add_child( node, xt_new_node( "status", status, NULL ) );
    147147       
    148         st = jabber_write_packet( gc, node );
     148        st = jabber_write_packet( ic, node );
    149149       
    150150        xt_free_node( node );
     
    153153
    154154/* Send a subscribe/unsubscribe request to a buddy. */
    155 int presence_send_request( struct gaim_connection *gc, char *handle, char *request )
     155int presence_send_request( struct im_connection *ic, char *handle, char *request )
    156156{
    157157        struct xt_node *node;
     
    162162        xt_add_attr( node, "type", request );
    163163       
    164         st = jabber_write_packet( gc, node );
     164        st = jabber_write_packet( ic, node );
    165165       
    166166        xt_free_node( node );
  • protocols/jabber/sasl.c

    rfa29d093 r0da65d5  
    2727xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data )
    2828{
    29         struct gaim_connection *gc = data;
    30         struct jabber_data *jd = gc->proto_data;
     29        struct im_connection *ic = data;
     30        struct jabber_data *jd = ic->proto_data;
    3131        struct xt_node *c, *reply;
    3232        char *s;
    3333        int sup_plain = 0, sup_digest = 0;
    3434       
    35         if( !sasl_supported( gc ) )
     35        if( !sasl_supported( ic ) )
    3636        {
    3737                /* Should abort this now, since we should already be doing
    3838                   IQ authentication. Strange things happen when you try
    3939                   to do both... */
    40                 serv_got_crap( gc, "XMPP 1.0 non-compliant server seems to support SASL, please report this as a BitlBee bug!" );
     40                serv_got_crap( ic, "XMPP 1.0 non-compliant server seems to support SASL, please report this as a BitlBee bug!" );
    4141                return XT_HANDLED;
    4242        }
     
    4545        if( !s || strcmp( s, XMLNS_SASL ) != 0 )
    4646        {
    47                 signoff( gc );
     47                signoff( ic );
    4848                return XT_ABORT;
    4949        }
     
    6262        if( !sup_plain && !sup_digest )
    6363        {
    64                 hide_login_progress( gc, "No known SASL authentication schemes supported" );
    65                 signoff( gc );
     64                hide_login_progress( ic, "No known SASL authentication schemes supported" );
     65                signoff( ic );
    6666                return XT_ABORT;
    6767        }
     
    8383               
    8484                /* With SASL PLAIN in XMPP, the text should be b64(\0user\0pass) */
    85                 len = strlen( jd->username ) + strlen( gc->acc->pass ) + 2;
     85                len = strlen( jd->username ) + strlen( ic->acc->pass ) + 2;
    8686                s = g_malloc( len + 1 );
    8787                s[0] = 0;
    8888                strcpy( s + 1, jd->username );
    89                 strcpy( s + 2 + strlen( jd->username ), gc->acc->pass );
     89                strcpy( s + 2 + strlen( jd->username ), ic->acc->pass );
    9090                reply->text = base64_encode( s, len );
    9191                reply->text_len = strlen( reply->text );
     
    9393        }
    9494       
    95         if( !jabber_write_packet( gc, reply ) )
     95        if( !jabber_write_packet( ic, reply ) )
    9696        {
    9797                xt_free_node( reply );
     
    181181xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data )
    182182{
    183         struct gaim_connection *gc = data;
    184         struct jabber_data *jd = gc->proto_data;
     183        struct im_connection *ic = data;
     184        struct jabber_data *jd = ic->proto_data;
    185185        struct xt_node *reply = NULL;
    186186        char *nonce = NULL, *realm = NULL, *cnonce = NULL, cnonce_bin[30];
     
    222222                   I decided to call it H. */
    223223                md5_init( &H );
    224                 s = g_strdup_printf( "%s:%s:%s", jd->username, realm, gc->acc->pass );
     224                s = g_strdup_printf( "%s:%s:%s", jd->username, realm, ic->acc->pass );
    225225                md5_append( &H, (unsigned char *) s, strlen( s ) );
    226226                g_free( s );
     
    272272        xt_add_attr( reply, "xmlns", XMLNS_SASL );
    273273       
    274         if( !jabber_write_packet( gc, reply ) )
     274        if( !jabber_write_packet( ic, reply ) )
    275275                goto silent_error;
    276276       
     
    279279
    280280error:
    281         hide_login_progress( gc, "Incorrect SASL challenge received" );
    282         signoff( gc );
     281        hide_login_progress( ic, "Incorrect SASL challenge received" );
     282        signoff( ic );
    283283
    284284silent_error:
     
    296296xt_status sasl_pkt_result( struct xt_node *node, gpointer data )
    297297{
    298         struct gaim_connection *gc = data;
    299         struct jabber_data *jd = gc->proto_data;
     298        struct im_connection *ic = data;
     299        struct jabber_data *jd = ic->proto_data;
    300300        char *s;
    301301       
     
    303303        if( !s || strcmp( s, XMLNS_SASL ) != 0 )
    304304        {
    305                 signoff( gc );
     305                signoff( ic );
    306306                return XT_ABORT;
    307307        }
     
    309309        if( strcmp( node->name, "success" ) == 0 )
    310310        {
    311                 set_login_progress( gc, 1, "Authentication finished" );
     311                set_login_progress( ic, 1, "Authentication finished" );
    312312                jd->flags |= JFLAG_AUTHENTICATED | JFLAG_STREAM_RESTART;
    313313        }
    314314        else if( strcmp( node->name, "failure" ) == 0 )
    315315        {
    316                 hide_login_progress( gc, "Authentication failure" );
    317                 signoff( gc );
     316                hide_login_progress( ic, "Authentication failure" );
     317                signoff( ic );
    318318                return XT_ABORT;
    319319        }
     
    325325   It's done by checking if the <stream:stream> from the server has a
    326326   version attribute. I don't know if this is the right way though... */
    327 gboolean sasl_supported( struct gaim_connection *gc )
    328 {
    329         struct jabber_data *jd = gc->proto_data;
     327gboolean sasl_supported( struct im_connection *ic )
     328{
     329        struct jabber_data *jd = ic->proto_data;
    330330       
    331331        return ( (void*) ( jd->xt && jd->xt->root && xt_find_attr( jd->xt->root, "version" ) ) ) != NULL;
Note: See TracChangeset for help on using the changeset viewer.