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. ;-)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.