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/msn/msn.c

    rfa29d093 r0da65d5  
    2929static char *msn_set_display_name( set_t *set, char *value );
    3030
    31 static void msn_acc_init( account_t *acc )
     31static void msn_init( account_t *acc )
    3232{
    3333        set_t *s;
     
    3939static void msn_login( account_t *acc )
    4040{
    41         struct gaim_connection *gc = new_gaim_conn( acc );
     41        struct im_connection *ic = new_gaim_conn( acc );
    4242        struct msn_data *md = g_new0( struct msn_data, 1 );
    4343       
    44         gc->proto_data = md;
     44        ic->proto_data = md;
    4545        md->fd = -1;
    4646       
    4747        if( strchr( acc->user, '@' ) == NULL )
    4848        {
    49                 hide_login_progress( gc, "Invalid account name" );
    50                 signoff( gc );
     49                hide_login_progress( ic, "Invalid account name" );
     50                signoff( ic );
    5151                return;
    5252        }
    5353       
    54         set_login_progress( gc, 1, "Connecting" );
    55        
    56         md->fd = proxy_connect( "messenger.hotmail.com", 1863, msn_ns_connected, gc );
     54        set_login_progress( ic, 1, "Connecting" );
     55       
     56        md->fd = proxy_connect( "messenger.hotmail.com", 1863, msn_ns_connected, ic );
    5757        if( md->fd < 0 )
    5858        {
    59                 hide_login_progress( gc, "Could not connect to server" );
    60                 signoff( gc );
     59                hide_login_progress( ic, "Could not connect to server" );
     60                signoff( ic );
    6161                return;
    6262        }
    6363       
    64         md->gc = gc;
     64        md->ic = ic;
    6565        md->away_state = msn_away_state_list;
    6666       
    67         msn_connections = g_slist_append( msn_connections, gc );
    68 }
    69 
    70 static void msn_close( struct gaim_connection *gc )
    71 {
    72         struct msn_data *md = gc->proto_data;
     67        msn_connections = g_slist_append( msn_connections, ic );
     68}
     69
     70static void msn_logout( struct im_connection *ic )
     71{
     72        struct msn_data *md = ic->proto_data;
    7373        GSList *l;
    7474       
     
    9696                                m = l->data;
    9797                       
    98                                 serv_got_crap( gc, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who );
     98                                serv_got_crap( ic, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who );
    9999                                g_free( m->who );
    100100                                g_free( m->text );
     
    111111        }
    112112       
    113         for( l = gc->permit; l; l = l->next )
     113        for( l = ic->permit; l; l = l->next )
    114114                g_free( l->data );
    115         g_slist_free( gc->permit );
    116        
    117         for( l = gc->deny; l; l = l->next )
     115        g_slist_free( ic->permit );
     116       
     117        for( l = ic->deny; l; l = l->next )
    118118                g_free( l->data );
    119         g_slist_free( gc->deny );
    120        
    121         msn_connections = g_slist_remove( msn_connections, gc );
    122 }
    123 
    124 static int msn_send_im( struct gaim_connection *gc, char *who, char *message, int len, int away )
     119        g_slist_free( ic->deny );
     120       
     121        msn_connections = g_slist_remove( msn_connections, ic );
     122}
     123
     124static int msn_send_im( struct im_connection *ic, char *who, char *message, int away )
    125125{
    126126        struct msn_switchboard *sb;
    127         struct msn_data *md = gc->proto_data;
    128        
    129         if( ( sb = msn_sb_by_handle( gc, who ) ) )
     127        struct msn_data *md = ic->proto_data;
     128       
     129        if( ( sb = msn_sb_by_handle( ic, who ) ) )
    130130        {
    131131                return( msn_sb_sendmessage( sb, message ) );
     
    142142               
    143143                /* FIXME: *CHECK* the reliability of using spare sb's! */
    144                 if( ( sb = msn_sb_spare( gc ) ) )
     144                if( ( sb = msn_sb_spare( ic ) ) )
    145145                {
    146146                        debug( "Trying to use a spare switchboard to message %s", who );
     
    160160                /* If we reach this line, there was no spare switchboard, so let's make one. */
    161161                g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId );
    162                 if( !msn_write( gc, buf, strlen( buf ) ) )
     162                if( !msn_write( ic, buf, strlen( buf ) ) )
    163163                {
    164164                        g_free( m->who );
     
    180180}
    181181
    182 static GList *msn_away_states( struct gaim_connection *gc )
     182static GList *msn_away_states( struct im_connection *ic )
    183183{
    184184        static GList *l = NULL;
     
    192192}
    193193
    194 static char *msn_get_status_string( struct gaim_connection *gc, int number )
     194static char *msn_get_status_string( struct im_connection *ic, int number )
    195195{
    196196        const struct msn_away_state *st = msn_away_state_by_number( number );
     
    202202}
    203203
    204 static void msn_set_away( struct gaim_connection *gc, char *state, char *message )
     204static void msn_set_away( struct im_connection *ic, char *state, char *message )
    205205{
    206206        char buf[1024];
    207         struct msn_data *md = gc->proto_data;
     207        struct msn_data *md = ic->proto_data;
    208208        const struct msn_away_state *st;
    209209       
     
    217217       
    218218        g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, st->code );
    219         msn_write( gc, buf, strlen( buf ) );
    220 }
    221 
    222 static void msn_set_info( struct gaim_connection *gc, char *info )
    223 {
    224         msn_set_display_name( set_find( &gc->acc->set, "display_name" ), info );
    225 }
    226 
    227 static void msn_get_info(struct gaim_connection *gc, char *who)
     219        msn_write( ic, buf, strlen( buf ) );
     220}
     221
     222static void msn_set_my_name( struct im_connection *ic, char *info )
     223{
     224        msn_set_display_name( set_find( &ic->acc->set, "display_name" ), info );
     225}
     226
     227static void msn_get_info(struct im_connection *ic, char *who)
    228228{
    229229        /* Just make an URL and let the user fetch the info */
    230         serv_got_crap( gc, "%s\n%s: %s%s", _("User Info"), _("For now, fetch yourself"), PROFILE_URL, who );
    231 }
    232 
    233 static void msn_add_buddy( struct gaim_connection *gc, char *who )
    234 {
    235         msn_buddy_list_add( gc, "FL", who, who );
    236 }
    237 
    238 static void msn_remove_buddy( struct gaim_connection *gc, char *who, char *group )
    239 {
    240         msn_buddy_list_remove( gc, "FL", who );
    241 }
    242 
    243 static int msn_chat_send( struct conversation *c, char *message )
     230        serv_got_crap( ic, "%s\n%s: %s%s", _("User Info"), _("For now, fetch yourself"), PROFILE_URL, who );
     231}
     232
     233static void msn_add_buddy( struct im_connection *ic, char *who, char *group )
     234{
     235        msn_buddy_list_add( ic, "FL", who, who );
     236}
     237
     238static void msn_remove_buddy( struct im_connection *ic, char *who, char *group )
     239{
     240        msn_buddy_list_remove( ic, "FL", who );
     241}
     242
     243static void msn_chat_send( struct groupchat *c, char *message, int flags )
    244244{
    245245        struct msn_switchboard *sb = msn_sb_by_chat( c );
    246246       
    247247        if( sb )
    248                 return( msn_sb_sendmessage( sb, message ) );
    249         else
    250                 return( 0 );
    251 }
    252 
    253 static void msn_chat_invite( struct conversation *c, char *msg, char *who )
     248                msn_sb_sendmessage( sb, message );
     249        /* FIXME: Error handling (although this can't happen unless something's
     250           already severely broken) disappeared here! */
     251}
     252
     253static void msn_chat_invite( struct groupchat *c, char *msg, char *who )
    254254{
    255255        struct msn_switchboard *sb = msn_sb_by_chat( c );
     
    263263}
    264264
    265 static void msn_chat_leave( struct conversation *c )
     265static void msn_chat_leave( struct groupchat *c )
    266266{
    267267        struct msn_switchboard *sb = msn_sb_by_chat( c );
     
    271271}
    272272
    273 static struct conversation *msn_chat_open( struct gaim_connection *gc, char *who )
     273static struct groupchat *msn_chat_with( struct im_connection *ic, char *who )
    274274{
    275275        struct msn_switchboard *sb;
    276         struct msn_data *md = gc->proto_data;
     276        struct msn_data *md = ic->proto_data;
    277277        char buf[1024];
    278278       
    279         if( ( sb = msn_sb_by_handle( gc, who ) ) )
     279        if( ( sb = msn_sb_by_handle( ic, who ) ) )
    280280        {
    281281                debug( "Converting existing switchboard to %s to a groupchat", who );
     
    286286                struct msn_message *m;
    287287               
    288                 if( ( sb = msn_sb_spare( gc ) ) )
     288                if( ( sb = msn_sb_spare( ic ) ) )
    289289                {
    290290                        debug( "Trying to reuse an existing switchboard as a groupchat with %s", who );
     
    299299                /* Request a new switchboard. */
    300300                g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId );
    301                 if( !msn_write( gc, buf, strlen( buf ) ) )
     301                if( !msn_write( ic, buf, strlen( buf ) ) )
    302302                        return( 0 );
    303303               
     
    317317}
    318318
    319 static void msn_keepalive( struct gaim_connection *gc )
    320 {
    321         msn_write( gc, "PNG\r\n", strlen( "PNG\r\n" ) );
    322 }
    323 
    324 static void msn_add_permit( struct gaim_connection *gc, char *who )
    325 {
    326         msn_buddy_list_add( gc, "AL", who, who );
    327 }
    328 
    329 static void msn_rem_permit( struct gaim_connection *gc, char *who )
    330 {
    331         msn_buddy_list_remove( gc, "AL", who );
    332 }
    333 
    334 static void msn_add_deny( struct gaim_connection *gc, char *who )
     319static void msn_keepalive( struct im_connection *ic )
     320{
     321        msn_write( ic, "PNG\r\n", strlen( "PNG\r\n" ) );
     322}
     323
     324static void msn_add_permit( struct im_connection *ic, char *who )
     325{
     326        msn_buddy_list_add( ic, "AL", who, who );
     327}
     328
     329static void msn_rem_permit( struct im_connection *ic, char *who )
     330{
     331        msn_buddy_list_remove( ic, "AL", who );
     332}
     333
     334static void msn_add_deny( struct im_connection *ic, char *who )
    335335{
    336336        struct msn_switchboard *sb;
    337337       
    338         msn_buddy_list_add( gc, "BL", who, who );
     338        msn_buddy_list_add( ic, "BL", who, who );
    339339       
    340340        /* If there's still a conversation with this person, close it. */
    341         if( ( sb = msn_sb_by_handle( gc, who ) ) )
     341        if( ( sb = msn_sb_by_handle( ic, who ) ) )
    342342        {
    343343                msn_sb_destroy( sb );
     
    345345}
    346346
    347 static void msn_rem_deny( struct gaim_connection *gc, char *who )
    348 {
    349         msn_buddy_list_remove( gc, "BL", who );
    350 }
    351 
    352 static int msn_send_typing( struct gaim_connection *gc, char *who, int typing )
     347static void msn_rem_deny( struct im_connection *ic, char *who )
     348{
     349        msn_buddy_list_remove( ic, "BL", who );
     350}
     351
     352static int msn_send_typing( struct im_connection *ic, char *who, int typing )
    353353{
    354354        if( typing )
    355                 return( msn_send_im( gc, who, TYPING_NOTIFICATION_MESSAGE, strlen( TYPING_NOTIFICATION_MESSAGE ), 0 ) );
     355                return( msn_send_im( ic, who, TYPING_NOTIFICATION_MESSAGE, 0 ) );
    356356        else
    357357                return( 1 );
     
    361361{
    362362        account_t *acc = set->data;
    363         struct gaim_connection *gc = acc->gc;
     363        struct im_connection *ic = acc->ic;
    364364        struct msn_data *md;
    365365        char buf[1024], *fn;
    366366       
    367367        /* Double-check. */
    368         if( gc == NULL )
     368        if( ic == NULL )
    369369                return NULL;
    370370       
    371         md = gc->proto_data;
     371        md = ic->proto_data;
    372372       
    373373        if( strlen( value ) > 129 )
    374374        {
    375                 serv_got_crap( gc, "Maximum name length exceeded" );
     375                serv_got_crap( ic, "Maximum name length exceeded" );
    376376                return NULL;
    377377        }
     
    379379        fn = msn_http_encode( value );
    380380       
    381         g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, gc->username, fn );
    382         msn_write( gc, buf, strlen( buf ) );
     381        g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->username, fn );
     382        msn_write( ic, buf, strlen( buf ) );
    383383        g_free( fn );
    384384       
     
    389389}
    390390
    391 void msn_init()
     391void msn_initmodule()
    392392{
    393393        struct prpl *ret = g_new0(struct prpl, 1);
     
    395395        ret->name = "msn";
    396396        ret->login = msn_login;
    397         ret->acc_init = msn_acc_init;
    398         ret->close = msn_close;
     397        ret->init = msn_init;
     398        ret->logout = msn_logout;
    399399        ret->send_im = msn_send_im;
    400400        ret->away_states = msn_away_states;
    401401        ret->get_status_string = msn_get_status_string;
    402402        ret->set_away = msn_set_away;
    403         ret->set_info = msn_set_info;
    404403        ret->get_info = msn_get_info;
     404        ret->set_my_name = msn_set_my_name;
    405405        ret->add_buddy = msn_add_buddy;
    406406        ret->remove_buddy = msn_remove_buddy;
     
    408408        ret->chat_invite = msn_chat_invite;
    409409        ret->chat_leave = msn_chat_leave;
    410         ret->chat_open = msn_chat_open;
     410        ret->chat_with = msn_chat_with;
    411411        ret->keepalive = msn_keepalive;
    412412        ret->add_permit = msn_add_permit;
Note: See TracChangeset for help on using the changeset viewer.