Changeset 6738a67 for protocols


Ignore:
Timestamp:
2008-07-16T23:22:52Z (17 years ago)
Author:
Sven Moritz Hallberg <pesco@…>
Branches:
master
Children:
9b55485
Parents:
9730d72 (diff), 6a78c0e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge in latest trunk

Location:
protocols
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/Makefile

    r9730d72 r6738a67  
    1010
    1111# [SH] Program variables
    12 objects = conference.o io.o iq.o jabber.o jabber_util.o message.o presence.o sasl.o xmltree.o
     12objects = conference.o io.o iq.o jabber.o jabber_util.o message.o presence.o sasl.o
    1313
    1414CFLAGS += -Wall
  • protocols/jabber/io.c

    r9730d72 r6738a67  
    241241        }
    242242       
    243         /* EAGAIN/etc or a successful read. */
    244         return TRUE;
     243        if( ssl_pending( jd->ssl ) )
     244                /* OpenSSL empties the TCP buffers completely but may keep some
     245                   data in its internap buffers. select() won't see that, but
     246                   ssl_pending() does. */
     247                return jabber_read_callback( data, fd, cond );
     248        else
     249                return TRUE;
    245250}
    246251
     
    521526           from the server too. */
    522527        xt_free( jd->xt );      /* In case we're RE-starting. */
    523         jd->xt = xt_new( ic );
    524         jd->xt->handlers = (struct xt_handler_entry*) jabber_handlers;
     528        jd->xt = xt_new( jabber_handlers, ic );
    525529       
    526530        if( jd->r_inpa <= 0 )
  • protocols/jabber/jabber.c

    r9730d72 r6738a67  
    3333#include "jabber.h"
    3434#include "md5.h"
    35 #include "base64.h"
    3635
    3736GSList *jabber_connections;
    3837
     38/* First enty is the default */
     39static const int jabber_port_list[] = {
     40        5222,
     41        5223,
     42        5220,
     43        5221,
     44        5224,
     45        5225,
     46        5226,
     47        5227,
     48        5228,
     49        5229,
     50        80,
     51        443,
     52        0
     53};
     54
    3955static void jabber_init( account_t *acc )
    4056{
    4157        set_t *s;
    42        
    43         s = set_add( &acc->set, "port", JABBER_PORT_DEFAULT, set_eval_int, acc );
     58        char str[16];
     59       
     60        g_snprintf( str, sizeof( str ), "%d", jabber_port_list[0] );
     61        s = set_add( &acc->set, "port", str, set_eval_int, acc );
    4462        s->flags |= ACC_SET_OFFLINE_ONLY;
    4563       
     
    7290        struct ns_srv_reply *srv = NULL;
    7391        char *connect_to, *s;
     92        int i;
    7493       
    7594        /* For now this is needed in the _connected() handlers if using
     
    177196        imcb_log( ic, "Connecting" );
    178197       
    179         if( set_getint( &acc->set, "port" ) < JABBER_PORT_MIN ||
    180             set_getint( &acc->set, "port" ) > JABBER_PORT_MAX )
    181         {
    182                 imcb_log( ic, "Incorrect port number, must be in the %d-%d range",
    183                                JABBER_PORT_MIN, JABBER_PORT_MAX );
     198        for( i = 0; jabber_port_list[i] > 0; i ++ )
     199                if( set_getint( &acc->set, "port" ) == jabber_port_list[i] )
     200                        break;
     201
     202        if( jabber_port_list[i] == 0 )
     203        {
     204                imcb_log( ic, "Illegal port number" );
    184205                imc_logout( ic, FALSE );
    185206                return;
     
    219240}
    220241
     242/* This generates an unfinished md5_state_t variable. Every time we generate
     243   an ID, we finish the state by adding a sequence number and take the hash. */
    221244static void jabber_generate_id_hash( struct jabber_data *jd )
    222245{
    223         md5_state_t id_hash;
    224         md5_byte_t binbuf[16];
     246        md5_byte_t binbuf[4];
    225247        char *s;
    226248       
    227         md5_init( &id_hash );
    228         md5_append( &id_hash, (unsigned char *) jd->username, strlen( jd->username ) );
    229         md5_append( &id_hash, (unsigned char *) jd->server, strlen( jd->server ) );
     249        md5_init( &jd->cached_id_prefix );
     250        md5_append( &jd->cached_id_prefix, (unsigned char *) jd->username, strlen( jd->username ) );
     251        md5_append( &jd->cached_id_prefix, (unsigned char *) jd->server, strlen( jd->server ) );
    230252        s = set_getstr( &jd->ic->acc->set, "resource" );
    231         md5_append( &id_hash, (unsigned char *) s, strlen( s ) );
    232         random_bytes( binbuf, 16 );
    233         md5_append( &id_hash, binbuf, 16 );
    234         md5_finish( &id_hash, binbuf );
    235        
    236         s = base64_encode( binbuf, 9 );
    237         jd->cached_id_prefix = g_strdup_printf( "%s%s", JABBER_CACHED_ID, s );
    238         g_free( s );
     253        md5_append( &jd->cached_id_prefix, (unsigned char *) s, strlen( s ) );
     254        random_bytes( binbuf, 4 );
     255        md5_append( &jd->cached_id_prefix, binbuf, 4 );
    239256}
    240257
  • protocols/jabber/jabber.h

    r9730d72 r6738a67  
    8686        char *away_message;
    8787       
    88         char *cached_id_prefix;
     88        md5_state_t cached_id_prefix;
    8989        GHashTable *node_cache;
    9090        GHashTable *buddies;
     
    134134
    135135#define JABBER_XMLCONSOLE_HANDLE "xmlconsole"
    136 
    137 #define JABBER_PORT_DEFAULT "5222"
    138 #define JABBER_PORT_MIN 5220
    139 #define JABBER_PORT_MAX 5229
    140136
    141137/* Prefixes to use for packet IDs (mainly for IQ packets ATM). Usually the
  • protocols/jabber/jabber_util.c

    r9730d72 r6738a67  
    2323
    2424#include "jabber.h"
     25#include "md5.h"
     26#include "base64.h"
    2527
    2628static unsigned int next_id = 1;
     
    134136        struct jabber_data *jd = ic->proto_data;
    135137        struct jabber_cache_entry *entry = g_new0( struct jabber_cache_entry, 1 );
    136         char *id;
    137        
    138         id = g_strdup_printf( "%s%05x", jd->cached_id_prefix, ( next_id++ ) & 0xfffff );
     138        md5_state_t id_hash;
     139        md5_byte_t id_sum[16];
     140        char *id, *asc_hash;
     141       
     142        next_id ++;
     143       
     144        id_hash = jd->cached_id_prefix;
     145        md5_append( &id_hash, (md5_byte_t*) &next_id, sizeof( next_id ) );
     146        md5_finish( &id_hash, id_sum );
     147        asc_hash = base64_encode( id_sum, 12 );
     148       
     149        id = g_strdup_printf( "%s%s", JABBER_CACHED_ID, asc_hash );
    139150        xt_add_attr( node, "id", id );
    140151        g_free( id );
     152        g_free( asc_hash );
    141153       
    142154        entry->node = node;
     
    184196       
    185197        if( ( s = xt_find_attr( node, "id" ) ) == NULL ||
    186             strncmp( s, jd->cached_id_prefix, strlen( jd->cached_id_prefix ) ) != 0 )
     198            strncmp( s, JABBER_CACHED_ID, strlen( JABBER_CACHED_ID ) ) != 0 )
    187199        {
    188200                /* Silently ignore it, without an ID (or a non-cache
     
    196208        if( entry == NULL )
    197209        {
     210                /*
     211                There's no longer an easy way to see if we generated this
     212                one or someone else, and there's a ten-minute timeout anyway,
     213                so meh.
     214               
    198215                imcb_log( ic, "Warning: Received %s-%s packet with unknown/expired ID %s!",
    199216                              node->name, xt_find_attr( node, "type" ) ? : "(no type)", s );
     217                */
    200218        }
    201219        else if( entry->func )
     
    246264};
    247265
    248 static void jabber_buddy_ask_yes( gpointer w, struct jabber_buddy_ask_data *bla )
    249 {
     266static void jabber_buddy_ask_yes( void *data )
     267{
     268        struct jabber_buddy_ask_data *bla = data;
     269       
    250270        presence_send_request( bla->ic, bla->handle, "subscribed" );
    251271       
     
    257277}
    258278
    259 static void jabber_buddy_ask_no( gpointer w, struct jabber_buddy_ask_data *bla )
    260 {
     279static void jabber_buddy_ask_no( void *data )
     280{
     281        struct jabber_buddy_ask_data *bla = data;
     282       
    261283        presence_send_request( bla->ic, bla->handle, "subscribed" );
    262284       
     
    286308        len = strlen( orig );
    287309        new = g_new( char, len + 1 );
    288         for( i = 0; i < len; i ++ )
     310       
     311        /* So it turns out the /resource part is case sensitive. Yeah, and
     312           it's Unicode but feck Unicode. :-P So stop once we see a slash. */
     313        for( i = 0; i < len && orig[i] != '/' ; i ++ )
    289314                new[i] = tolower( orig[i] );
     315        for( ; orig[i]; i ++ )
     316                new[i] = orig[i];
    290317       
    291318        new[i] = 0;
     
    330357                {
    331358                        /* Check for dupes. */
    332                         if( g_strcasecmp( bi->resource, s + 1 ) == 0 )
     359                        if( strcmp( bi->resource, s + 1 ) == 0 )
    333360                        {
    334361                                *s = '/';
     
    383410        if( ( s = strchr( jid, '/' ) ) )
    384411        {
    385                 int none_found = 0;
     412                int bare_exists = 0;
    386413               
    387414                *s = 0;
     
    406433                        /* See if there's an exact match. */
    407434                        for( ; bud; bud = bud->next )
    408                                 if( g_strcasecmp( bud->resource, s + 1 ) == 0 )
     435                                if( strcmp( bud->resource, s + 1 ) == 0 )
    409436                                        break;
    410437                }
    411438                else
    412439                {
    413                         /* This hack is there to make sure that O_CREAT will
    414                            work if there's already another resouce present
    415                            for this JID, even if it's an unknown buddy. This
    416                            is done to handle conferences properly. */
    417                         none_found = 1;
    418                         /* TODO(wilmer): Find out what I was thinking when I
    419                            wrote this??? And then fix it. This makes me sad... */
    420                 }
    421                
    422                 if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && ( imcb_find_buddy( ic, jid ) || !none_found ) )
     440                        /* This variable tells the if down here that the bare
     441                           JID already exists and we should feel free to add
     442                           more resources, if the caller asked for that. */
     443                        bare_exists = 1;
     444                }
     445               
     446                if( bud == NULL && ( flags & GET_BUDDY_CREAT ) &&
     447                    ( !bare_exists || imcb_find_buddy( ic, jid ) ) )
    423448                {
    424449                        *s = '/';
     
    445470                        /* We want an exact match, so in thise case there shouldn't be a /resource. */
    446471                        return NULL;
    447                 else if( ( bud->resource == NULL || bud->next == NULL ) )
     472                else if( bud->resource == NULL || bud->next == NULL )
    448473                        /* No need for selection if there's only one option. */
    449474                        return bud;
     
    521546                   matches), removing it is simple. (And the hash reference
    522547                   should be removed too!) */
    523                 if( bud->next == NULL && ( ( s == NULL || bud->resource == NULL ) || g_strcasecmp( bud->resource, s + 1 ) == 0 ) )
     548                if( bud->next == NULL &&
     549                    ( ( s == NULL && bud->resource == NULL ) ||
     550                      ( bud->resource && s && strcmp( bud->resource, s + 1 ) == 0 ) ) )
    524551                {
    525552                        g_hash_table_remove( jd->buddies, bud->bare_jid );
     
    544571                {
    545572                        for( bi = bud, prev = NULL; bi; bi = (prev=bi)->next )
    546                                 if( g_strcasecmp( bi->resource, s + 1 ) == 0 )
     573                                if( strcmp( bi->resource, s + 1 ) == 0 )
    547574                                        break;
    548575                       
  • protocols/jabber/message.c

    r9730d72 r6738a67  
    4949        {
    5050                GString *fullmsg = g_string_new( "" );
     51
     52                for( c = node->children; ( c = xt_find_node( c, "x" ) ); c = c->next )
     53                {
     54                        char *ns = xt_find_attr( c, "xmlns" ), *room;
     55                        struct xt_node *inv, *reason;
     56                       
     57                        if( strcmp( ns, XMLNS_MUC_USER ) == 0 &&
     58                            ( inv = xt_find_node( c->children, "invite" ) ) )
     59                        {
     60                                room = from;
     61                                from = xt_find_attr( inv, "from" ) ? : from;
     62
     63                                g_string_append_printf( fullmsg, "<< \002BitlBee\002 - Invitation to chatroom %s >>\n", room );
     64                                if( ( reason = xt_find_node( inv->children, "reason" ) ) && reason->text_len > 0 )
     65                                        g_string_append( fullmsg, reason->text );
     66                        }
     67                }
    5168               
    5269                if( ( s = strchr( from, '/' ) ) )
  • protocols/msn/msn.h

    r9730d72 r6738a67  
    2929#define GROUPCHAT_SWITCHBOARD_MESSAGE "\r\r\rME WANT TALK TO MANY PEOPLE\r\r\r"
    3030
    31 #ifdef DEBUG
     31#ifdef DEBUG_MSN
    3232#define debug( text... ) imcb_log( ic, text );
    3333#else
  • protocols/msn/msn_util.c

    r9730d72 r6738a67  
    9090};
    9191
    92 static void msn_buddy_ask_yes( gpointer w, struct msn_buddy_ask_data *bla )
    93 {
     92static void msn_buddy_ask_yes( void *data )
     93{
     94        struct msn_buddy_ask_data *bla = data;
     95       
    9496        msn_buddy_list_add( bla->ic, "AL", bla->handle, bla->realname );
    9597       
     
    102104}
    103105
    104 static void msn_buddy_ask_no( gpointer w, struct msn_buddy_ask_data *bla )
    105 {
     106static void msn_buddy_ask_no( void *data )
     107{
     108        struct msn_buddy_ask_data *bla = data;
     109       
    106110        msn_buddy_list_add( bla->ic, "BL", bla->handle, bla->realname );
    107111       
  • protocols/msn/ns.c

    r9730d72 r6738a67  
    3434static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int num_parts );
    3535
    36 static void msn_auth_got_passport_id( struct passport_reply *rep );
     36static void msn_auth_got_passport_token( struct msn_auth_data *mad );
    3737
    3838gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond )
     
    178178                       
    179179                        debug( "Connecting to a new switchboard with key %s", cmd[5] );
    180                         sb = msn_sb_create( ic, server, port, cmd[5], MSN_SB_NEW );
     180
     181                        if( ( sb = msn_sb_create( ic, server, port, cmd[5], MSN_SB_NEW ) ) == NULL )
     182                        {
     183                                /* Although this isn't strictly fatal for the NS connection, it's
     184                                   definitely something serious (we ran out of file descriptors?). */
     185                                imcb_error( ic, "Could not create new switchboard" );
     186                                imc_logout( ic, TRUE );
     187                                return( 0 );
     188                        }
    181189                       
    182190                        if( md->msgq )
     
    214222                {
    215223                        /* Time for some Passport black magic... */
    216                         if( !passport_get_id( msn_auth_got_passport_id, ic, ic->acc->user, ic->acc->pass, cmd[4] ) )
     224                        if( !passport_get_token( msn_auth_got_passport_token, ic, ic->acc->user, ic->acc->pass, cmd[4] ) )
    217225                        {
    218226                                imcb_error( ic, "Error while contacting Passport server" );
     
    270278                if( num_parts == 5 )
    271279                {
     280                        int i, groupcount;
     281                       
     282                        groupcount = atoi( cmd[4] );
     283                        if( groupcount > 0 )
     284                        {
     285                                /* valgrind says this is leaking memory, I'm guessing
     286                                   that this happens during server redirects. */
     287                                if( md->grouplist )
     288                                {
     289                                        for( i = 0; i < md->groupcount; i ++ )
     290                                                g_free( md->grouplist[i] );
     291                                        g_free( md->grouplist );
     292                                }
     293                               
     294                                md->groupcount = groupcount;
     295                                md->grouplist = g_new0( char *, md->groupcount );
     296                        }
     297                       
    272298                        md->buddycount = atoi( cmd[3] );
    273                         md->groupcount = atoi( cmd[4] );
    274                         if( md->groupcount > 0 )
    275                                 md->grouplist = g_new0( char *, md->groupcount );
    276                        
    277299                        if( !*cmd[3] || md->buddycount == 0 )
    278300                                msn_logged_in( ic );
     
    468490                debug( "Got a call from %s (session %d). Key = %s", cmd[5], session, cmd[4] );
    469491               
    470                 sb = msn_sb_create( ic, server, port, cmd[4], session );
    471                 sb->who = g_strdup( cmd[5] );
     492                if( ( sb = msn_sb_create( ic, server, port, cmd[4], session ) ) == NULL )
     493                {
     494                        /* Although this isn't strictly fatal for the NS connection, it's
     495                           definitely something serious (we ran out of file descriptors?). */
     496                        imcb_error( ic, "Could not create new switchboard" );
     497                        imc_logout( ic, TRUE );
     498                        return( 0 );
     499                }
     500                else
     501                {
     502                        sb->who = g_strdup( cmd[5] );
     503                }
    472504        }
    473505        else if( strcmp( cmd[0], "ADD" ) == 0 )
     
    647679                                        imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders );
    648680                                }
     681                               
     682                                g_free( inbox );
     683                                g_free( folders );
    649684                        }
    650685                        else if( g_strncasecmp( ct, "text/x-msmsgsemailnotification", 30 ) == 0 )
     
    674709}
    675710
    676 static void msn_auth_got_passport_id( struct passport_reply *rep )
     711static void msn_auth_got_passport_token( struct msn_auth_data *mad )
    677712{
    678         struct im_connection *ic = rep->data;
    679         struct msn_data *md = ic->proto_data;
    680         char *key = rep->result;
    681         char buf[1024];
    682        
    683         if( key == NULL )
    684         {
    685                 imcb_error( ic, "Error during Passport authentication (%s)",
    686                                rep->error_string ? rep->error_string : "Unknown error" );
     713        struct im_connection *ic = mad->data;
     714        struct msn_data *md;
     715       
     716        /* Dead connection? */
     717        if( g_slist_find( msn_connections, ic ) == NULL )
     718                return;
     719       
     720        md = ic->proto_data;
     721        if( mad->token )
     722        {
     723                char buf[1024];
     724               
     725                g_snprintf( buf, sizeof( buf ), "USR %d TWN S %s\r\n", ++md->trId, mad->token );
     726                msn_write( ic, buf, strlen( buf ) );
     727        }
     728        else
     729        {
     730                imcb_error( ic, "Error during Passport authentication: %s", mad->error );
    687731                imc_logout( ic, TRUE );
    688732        }
    689         else
    690         {
    691                 g_snprintf( buf, sizeof( buf ), "USR %d TWN S %s\r\n", ++md->trId, key );
    692                 msn_write( ic, buf, strlen( buf ) );
    693         }
    694733}
  • protocols/msn/passport.c

    r9730d72 r6738a67  
    1 /* passport.c
     1/** passport.c
    22 *
    3  * Functions to login to microsoft passport service for Messenger
    4  * Copyright (C) 2004 Wouter Paesen <wouter@blue-gate.be>
    5  * Copyright (C) 2004 Wilmer van der Gaast <wilmer@gaast.net>
     3 * Functions to login to Microsoft Passport service for Messenger
     4 * Copyright (C) 2004-2008 Wilmer van der Gaast <wilmer@gaast.net>
    65 *
    76 * This program is free software; you can redistribute it and/or modify             
     
    2423#include "msn.h"
    2524#include "bitlbee.h"
     25#include "url.h"
     26#include "misc.h"
     27#include "xmltree.h"
    2628#include <ctype.h>
    2729#include <errno.h>
    2830
    29 #define MSN_BUF_LEN 8192
     31static int passport_get_token_real( struct msn_auth_data *mad );
     32static void passport_get_token_ready( struct http_request *req );
    3033
    31 static char *prd_cached = NULL;
    32 
    33 static int passport_get_id_real( gpointer func, gpointer data, char *header );
    34 static void passport_get_id_ready( struct http_request *req );
    35 
    36 static int passport_retrieve_dalogin( gpointer data, gpointer func, char *header );
    37 static void passport_retrieve_dalogin_ready( struct http_request *req );
    38 
    39 static char *passport_create_header( char *cookie, char *email, char *pwd );
    40 static void destroy_reply( struct passport_reply *rep );
    41 
    42 int passport_get_id( gpointer func, gpointer data, char *username, char *password, char *cookie )
     34int passport_get_token( gpointer func, gpointer data, char *username, char *password, char *cookie )
    4335{
    44         char *header = passport_create_header( cookie, username, password );
     36        struct msn_auth_data *mad = g_new0( struct msn_auth_data, 1 );
     37        int i;
    4538       
    46         if( prd_cached == NULL )
    47                 return passport_retrieve_dalogin( func, data, header );
    48         else
    49                 return passport_get_id_real( func, data, header );
     39        mad->username = g_strdup( username );
     40        mad->password = g_strdup( password );
     41        mad->cookie = g_strdup( cookie );
     42       
     43        mad->callback = func;
     44        mad->data = data;
     45       
     46        mad->url = g_strdup( SOAP_AUTHENTICATION_URL );
     47        mad->ttl = 3; /* Max. # of redirects. */
     48       
     49        /* HTTP-escape stuff and s/,/&/ */
     50        http_decode( mad->cookie );
     51        for( i = 0; mad->cookie[i]; i ++ )
     52                if( mad->cookie[i] == ',' )
     53                        mad->cookie[i] = '&';
     54       
     55        /* Microsoft doesn't allow password longer than 16 chars and silently
     56           fails authentication if you give the "full version" of your passwd. */
     57        if( strlen( mad->password ) > MAX_PASSPORT_PWLEN )
     58                mad->password[MAX_PASSPORT_PWLEN] = 0;
     59       
     60        return passport_get_token_real( mad );
    5061}
    5162
    52 static int passport_get_id_real( gpointer func, gpointer data, char *header )
     63static int passport_get_token_real( struct msn_auth_data *mad )
    5364{
    54         struct passport_reply *rep;
    55         char *server, *dummy, *reqs;
     65        char *post_payload, *post_request;
    5666        struct http_request *req;
     67        url_t url;
    5768       
    58         rep = g_new0( struct passport_reply, 1 );
    59         rep->data = data;
    60         rep->func = func;
    61         rep->header = header;
     69        url_set( &url, mad->url );
    6270       
    63         server = g_strdup( prd_cached );
    64         dummy = strchr( server, '/' );
     71        post_payload = g_markup_printf_escaped( SOAP_AUTHENTICATION_PAYLOAD,
     72                                                mad->username,
     73                                                mad->password,
     74                                                mad->cookie );
    6575       
    66         if( dummy == NULL )
    67         {
    68                 destroy_reply( rep );
    69                 return( 0 );
    70         }
     76        post_request = g_strdup_printf( SOAP_AUTHENTICATION_REQUEST,
     77                                        url.file, url.host,
     78                                        (int) strlen( post_payload ),
     79                                        post_payload );
     80                                       
     81        req = http_dorequest( url.host, url.port, 1, post_request,
     82                              passport_get_token_ready, mad );
    7183       
    72         reqs = g_strdup_printf( "GET %s HTTP/1.0\r\n%s\r\n\r\n", dummy, header );
     84        g_free( post_request );
     85        g_free( post_payload );
    7386       
    74         *dummy = 0;
    75         req = http_dorequest( server, 443, 1, reqs, passport_get_id_ready, rep );
    76        
    77         g_free( server );
    78         g_free( reqs );
    79        
    80         if( req == NULL )
    81                 destroy_reply( rep );
    82        
    83         return( req != NULL );
     87        return req != NULL;
    8488}
    8589
    86 static void passport_get_id_ready( struct http_request *req )
     90static xt_status passport_xt_extract_token( struct xt_node *node, gpointer data );
     91static xt_status passport_xt_handle_fault( struct xt_node *node, gpointer data );
     92
     93static const struct xt_handler_entry passport_xt_handlers[] = {
     94        { "wsse:BinarySecurityToken", "wst:RequestedSecurityToken", passport_xt_extract_token },
     95        { "S:Fault",                  "S:Envelope",                 passport_xt_handle_fault  },
     96        { NULL,                       NULL,                         NULL                      }
     97};
     98
     99static void passport_get_token_ready( struct http_request *req )
    87100{
    88         struct passport_reply *rep = req->data;
     101        struct msn_auth_data *mad = req->data;
     102        struct xt_parser *parser;
    89103       
    90         if( !g_slist_find( msn_connections, rep->data ) )
     104        g_free( mad->url );
     105        g_free( mad->error );
     106        mad->url = mad->error = NULL;
     107       
     108        if( req->status_code == 200 )
    91109        {
    92                 destroy_reply( rep );
    93                 return;
    94         }
    95        
    96         if( req->finished && req->reply_headers && req->status_code == 200 )
    97         {
    98                 char *dummy;
    99                
    100                 if( ( dummy = strstr( req->reply_headers, "from-PP='" ) ) )
    101                 {
    102                         char *responseend;
    103                        
    104                         dummy += strlen( "from-PP='" );
    105                         responseend = strchr( dummy, '\'' );
    106                         if( responseend )
    107                                 *responseend = 0;
    108                        
    109                         rep->result = g_strdup( dummy );
    110                 }
    111                 else
    112                 {
    113                         rep->error_string = g_strdup( "Could not parse Passport server response" );
    114                 }
     110                parser = xt_new( passport_xt_handlers, mad );
     111                xt_feed( parser, req->reply_body, req->body_size );
     112                xt_handle( parser, NULL, -1 );
     113                xt_free( parser );
    115114        }
    116115        else
    117116        {
    118                 rep->error_string = g_strdup_printf( "HTTP error: %s",
    119                                       req->status_string ? req->status_string : "Unknown error" );
     117                mad->error = g_strdup_printf( "HTTP error %d (%s)", req->status_code,
     118                                              req->status_string ? req->status_string : "unknown" );
    120119        }
    121120       
    122         rep->func( rep );
    123         destroy_reply( rep );
     121        if( mad->error == NULL && mad->token == NULL )
     122                mad->error = g_strdup( "Could not parse Passport server response" );
     123       
     124        if( mad->url && mad->token == NULL )
     125        {
     126                passport_get_token_real( mad );
     127        }
     128        else
     129        {
     130                mad->callback( mad );
     131               
     132                g_free( mad->url );
     133                g_free( mad->username );
     134                g_free( mad->password );
     135                g_free( mad->cookie );
     136                g_free( mad->token );
     137                g_free( mad->error );
     138                g_free( mad );
     139        }
    124140}
    125141
    126 static char *passport_create_header( char *cookie, char *email, char *pwd )
     142static xt_status passport_xt_extract_token( struct xt_node *node, gpointer data )
    127143{
    128         char *buffer;
    129         char *currenttoken;
    130         char *email_enc, *pwd_enc;
     144        struct msn_auth_data *mad = data;
     145        char *s;
    131146       
    132         currenttoken = strstr( cookie, "lc=" );
    133         if( currenttoken == NULL )
    134                 return NULL;
     147        if( ( s = xt_find_attr( node, "Id" ) ) && strcmp( s, "PPToken1" ) == 0 )
     148                mad->token = g_memdup( node->text, node->text_len + 1 );
    135149       
    136         email_enc = g_new0( char, strlen( email ) * 3 + 1 );
    137         strcpy( email_enc, email );
    138         http_encode( email_enc );
    139        
    140         pwd_enc = g_new0( char, strlen( pwd ) * 3 + 1 );
    141         strcpy( pwd_enc, pwd );
    142         http_encode( pwd_enc );
    143        
    144         buffer = g_strdup_printf( "Authorization: Passport1.4 OrgVerb=GET,"
    145                                   "OrgURL=http%%3A%%2F%%2Fmessenger%%2Emsn%%2Ecom,"
    146                                   "sign-in=%s,pwd=%s,%s", email_enc, pwd_enc,
    147                                   currenttoken );
    148        
    149         g_free( email_enc );
    150         g_free( pwd_enc );
    151        
    152         return buffer;
     150        return XT_HANDLED;
    153151}
    154152
    155 static int passport_retrieve_dalogin( gpointer func, gpointer data, char *header )
     153static xt_status passport_xt_handle_fault( struct xt_node *node, gpointer data )
    156154{
    157         struct passport_reply *rep = g_new0( struct passport_reply, 1 );
    158         struct http_request *req;
     155        struct msn_auth_data *mad = data;
     156        struct xt_node *code = xt_find_node( node->children, "faultcode" );
     157        struct xt_node *string = xt_find_node( node->children, "faultstring" );
     158        struct xt_node *redirect = xt_find_node( node->children, "psf:redirectUrl" );
    159159       
    160         rep->data = data;
    161         rep->func = func;
    162         rep->header = header;
     160        if( redirect && redirect->text_len && mad->ttl-- > 0 )
     161                mad->url = g_memdup( redirect->text, redirect->text_len + 1 );
    163162       
    164         req = http_dorequest_url( "https://nexus.passport.com/rdr/pprdr.asp", passport_retrieve_dalogin_ready, rep );
     163        if( code == NULL || code->text_len == 0 )
     164                mad->error = g_strdup( "Unknown error" );
     165        else
     166                mad->error = g_strdup_printf( "%s (%s)", code->text, string && string->text_len ?
     167                                              string->text : "no description available" );
    165168       
    166         if( !req )
    167                 destroy_reply( rep );
    168        
    169         return( req != NULL );
     169        return XT_HANDLED;
    170170}
    171 
    172 static void passport_retrieve_dalogin_ready( struct http_request *req )
    173 {
    174         struct passport_reply *rep = req->data;
    175         char *dalogin;
    176         char *urlend;
    177        
    178         if( !g_slist_find( msn_connections, rep->data ) )
    179         {
    180                 destroy_reply( rep );
    181                 return;
    182         }
    183        
    184         if( !req->finished || !req->reply_headers || req->status_code != 200 )
    185         {
    186                 rep->error_string = g_strdup_printf( "HTTP error while fetching DALogin: %s",
    187                                         req->status_string ? req->status_string : "Unknown error" );
    188                 goto failure;
    189         }
    190        
    191         dalogin = strstr( req->reply_headers, "DALogin=" );     
    192        
    193         if( !dalogin )
    194         {
    195                 rep->error_string = g_strdup( "Parse error while fetching DALogin" );
    196                 goto failure;
    197         }
    198        
    199         dalogin += strlen( "DALogin=" );
    200         urlend = strchr( dalogin, ',' );
    201         if( urlend )
    202                 *urlend = 0;
    203        
    204         /* strip the http(s):// part from the url */
    205         urlend = strstr( urlend, "://" );
    206         if( urlend )
    207                 dalogin = urlend + strlen( "://" );
    208        
    209         if( prd_cached == NULL )
    210                 prd_cached = g_strdup( dalogin );
    211        
    212         if( passport_get_id_real( rep->func, rep->data, rep->header ) )
    213         {
    214                 rep->header = NULL;
    215                 destroy_reply( rep );
    216                 return;
    217         }
    218        
    219 failure:       
    220         rep->func( rep );
    221         destroy_reply( rep );
    222 }
    223 
    224 static void destroy_reply( struct passport_reply *rep )
    225 {
    226         g_free( rep->result );
    227         g_free( rep->header );
    228         g_free( rep->error_string );
    229         g_free( rep );
    230 }
  • protocols/msn/passport.h

    r9730d72 r6738a67  
    1 #ifndef __PASSPORT_H__
    2 #define __PASSPORT_H__
    31/* passport.h
    42 *
    5  * Functions to login to Microsoft Passport Service for Messenger
    6  * Copyright (C) 2004 Wouter Paesen <wouter@blue-gate.be>,
    7  *                    Wilmer van der Gaast <wilmer@gaast.net>
     3 * Functions to login to Microsoft Passport service for Messenger
     4 * Copyright (C) 2004-2008 Wilmer van der Gaast <wilmer@gaast.net>
    85 *
    96 * This program is free software; you can redistribute it and/or modify             
     
    1815 * You should have received a copy of the GNU General Public License               
    1916 * along with this program; if not, write to the Free Software                     
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA         
     17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA         
    2118 */
     19
     20/* Thanks to http://msnpiki.msnfanatic.com/index.php/MSNP13:SOAPTweener
     21   for the specs! */
     22
     23#ifndef __PASSPORT_H__
     24#define __PASSPORT_H__
    2225
    2326#include <stdio.h>
     
    3336#include "nogaim.h"
    3437
    35 struct passport_reply
     38#define MAX_PASSPORT_PWLEN 16
     39
     40struct msn_auth_data
    3641{
    37         void (*func)( struct passport_reply * );
    38         void *data;
    39         char *result;
    40         char *header;
    41         char *error_string;
     42        char *url;
     43        int ttl;
     44       
     45        char *username;
     46        char *password;
     47        char *cookie;
     48       
     49        /* The end result, the only thing we'll really be interested in
     50           once finished. */
     51        char *token;
     52        char *error; /* Yeah, or that... */
     53       
     54        void (*callback)( struct msn_auth_data *mad );
     55        gpointer data;
    4256};
    4357
    44 int passport_get_id( gpointer func, gpointer data, char *username, char *password, char *cookie );
     58#define SOAP_AUTHENTICATION_URL "https://loginnet.passport.com/RST.srf"
     59
     60#define SOAP_AUTHENTICATION_REQUEST \
     61"POST %s HTTP/1.0\r\n" \
     62"Accept: text/*\r\n" \
     63"User-Agent: BitlBee " BITLBEE_VERSION "\r\n" \
     64"Host: %s\r\n" \
     65"Content-Length: %d\r\n" \
     66"Cache-Control: no-cache\r\n" \
     67"\r\n" \
     68"%s"
     69
     70#define SOAP_AUTHENTICATION_PAYLOAD \
     71"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" \
     72"<Envelope xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2003/06/secext\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2002/12/policy\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\" xmlns:wssc=\"http://schemas.xmlsoap.org/ws/2004/04/sc\" xmlns:wst=\"http://schemas.xmlsoap.org/ws/2004/04/trust\">" \
     73  "<Header>" \
     74    "<ps:AuthInfo xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\" Id=\"PPAuthInfo\">" \
     75      "<ps:HostingApp>{7108E71A-9926-4FCB-BCC9-9A9D3F32E423}</ps:HostingApp>" \
     76      "<ps:BinaryVersion>4</ps:BinaryVersion>" \
     77      "<ps:UIVersion>1</ps:UIVersion>" \
     78      "<ps:Cookies></ps:Cookies>" \
     79      "<ps:RequestParams>AQAAAAIAAABsYwQAAAAzMDg0</ps:RequestParams>" \
     80    "</ps:AuthInfo>" \
     81    "<wsse:Security>" \
     82       "<wsse:UsernameToken Id=\"user\">" \
     83         "<wsse:Username>%s</wsse:Username>" \
     84         "<wsse:Password>%s</wsse:Password>" \
     85       "</wsse:UsernameToken>" \
     86    "</wsse:Security>" \
     87  "</Header>" \
     88  "<Body>" \
     89    "<ps:RequestMultipleSecurityTokens xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\" Id=\"RSTS\">" \
     90      "<wst:RequestSecurityToken Id=\"RST0\">" \
     91        "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>" \
     92        "<wsp:AppliesTo>" \
     93          "<wsa:EndpointReference>" \
     94            "<wsa:Address>http://Passport.NET/tb</wsa:Address>" \
     95          "</wsa:EndpointReference>" \
     96        "</wsp:AppliesTo>" \
     97      "</wst:RequestSecurityToken>" \
     98      "<wst:RequestSecurityToken Id=\"RST1\">" \
     99       "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>" \
     100        "<wsp:AppliesTo>" \
     101          "<wsa:EndpointReference>" \
     102            "<wsa:Address>messenger.msn.com</wsa:Address>" \
     103          "</wsa:EndpointReference>" \
     104        "</wsp:AppliesTo>" \
     105        "<wsse:PolicyReference URI=\"?%s\"></wsse:PolicyReference>" \
     106      "</wst:RequestSecurityToken>" \
     107    "</ps:RequestMultipleSecurityTokens>" \
     108  "</Body>" \
     109"</Envelope>"
     110
     111int passport_get_token( gpointer func, gpointer data, char *username, char *password, char *cookie );
    45112
    46113#endif /* __PASSPORT_H__ */
  • protocols/nogaim.c

    r9730d72 r6738a67  
    343343/* dialogs.c */
    344344
    345 void imcb_ask( struct im_connection *ic, char *msg, void *data, void *doit, void *dont )
     345void imcb_ask( struct im_connection *ic, char *msg, void *data,
     346               query_callback doit, query_callback dont )
    346347{
    347348        query_add( ic->irc, ic, msg, doit, dont, data );
     
    495496};
    496497
    497 void show_got_added_no( gpointer w, struct show_got_added_data *data )
    498 {
    499         g_free( data->handle );
     498void show_got_added_no( void *data )
     499{
     500        g_free( ((struct show_got_added_data*)data)->handle );
    500501        g_free( data );
    501502}
    502503
    503 void show_got_added_yes( gpointer w, struct show_got_added_data *data )
    504 {
    505         data->ic->acc->prpl->add_buddy( data->ic, data->handle, NULL );
    506         /* imcb_add_buddy( data->ic, NULL, data->handle, data->handle ); */
    507        
    508         return show_got_added_no( w, data );
     504void show_got_added_yes( void *data )
     505{
     506        struct show_got_added_data *sga = data;
     507       
     508        sga->ic->acc->prpl->add_buddy( sga->ic, sga->handle, NULL );
     509        /* imcb_add_buddy( sga->ic, NULL, sga->handle, sga->handle ); */
     510       
     511        return show_got_added_no( data );
    509512}
    510513
  • protocols/nogaim.h

    r9730d72 r6738a67  
    4242#include "account.h"
    4343#include "proxy.h"
     44#include "query.h"
    4445#include "md5.h"
    45 
    46 #define BUF_LEN MSG_LEN
    47 #define BUF_LONG ( BUF_LEN * 2 )
    48 #define MSG_LEN 2048
    49 #define BUF_LEN MSG_LEN
    5046
    5147#define BUDDY_ALIAS_MAXLEN 388   /* because MSN names can be 387 characters */
     
    265261 * - 'doit' or 'dont' will be called depending of the answer of the user.
    266262 */
    267 G_MODULE_EXPORT void imcb_ask( struct im_connection *ic, char *msg, void *data, void *doit, void *dont );
     263G_MODULE_EXPORT void imcb_ask( struct im_connection *ic, char *msg, void *data, query_callback doit, query_callback dont );
    268264G_MODULE_EXPORT void imcb_ask_add( struct im_connection *ic, char *handle, const char *realname );
    269265
  • protocols/oscar/oscar.c

    r9730d72 r6738a67  
    6060
    6161#define OSCAR_GROUP "Friends"
     62
     63#define BUF_LEN 2048
     64#define BUF_LONG ( BUF_LEN * 2 )
    6265
    6366/* Don't know if support for UTF8 is really working. For now it's UTF16 here.
     
    240243};
    241244static int msgerrreasonlen = 25;
     245
     246/* Hurray, this function is NOT thread-safe \o/ */
     247static char *normalize(const char *s)
     248{
     249        static char buf[BUF_LEN];
     250        char *t, *u;
     251        int x = 0;
     252
     253        g_return_val_if_fail((s != NULL), NULL);
     254
     255        u = t = g_strdup(s);
     256
     257        strcpy(t, s);
     258        g_strdown(t);
     259
     260        while (*t && (x < BUF_LEN - 1)) {
     261                if (*t != ' ' && *t != '!') {
     262                        buf[x] = *t;
     263                        x++;
     264                }
     265                t++;
     266        }
     267        buf[x] = '\0';
     268        g_free(u);
     269        return buf;
     270}
    242271
    243272static gboolean oscar_callback(gpointer data, gint source,
     
    10021031        }
    10031032
    1004         tmp = g_strdup(normalize(ic->acc->user));
    1005         if (!strcmp(tmp, normalize(info->sn)))
     1033        if (!aim_sncmp(ic->acc->user, info->sn))
    10061034                g_snprintf(ic->displayname, sizeof(ic->displayname), "%s", info->sn);
    1007         g_free(tmp);
    1008 
    1009         imcb_buddy_status(ic, info->sn, flags, state_string, NULL);
    1010         /* imcb_buddy_times(ic, info->sn, signon, time_idle); */
     1035
     1036        tmp = normalize(info->sn);
     1037        imcb_buddy_status(ic, tmp, flags, state_string, NULL);
     1038        /* imcb_buddy_times(ic, tmp, signon, time_idle); */
     1039
    10111040
    10121041        return 1;
     
    10221051        va_end(ap);
    10231052
    1024         imcb_buddy_status(ic, info->sn, 0, NULL, NULL );
     1053        imcb_buddy_status(ic, normalize(info->sn), 0, NULL, NULL );
    10251054
    10261055        return 1;
     
    10781107       
    10791108        strip_linefeed(tmp);
    1080         imcb_buddy_msg(ic, userinfo->sn, tmp, flags, 0);
     1109        imcb_buddy_msg(ic, normalize(userinfo->sn), tmp, flags, 0);
    10811110        g_free(tmp);
    10821111       
     
    10841113}
    10851114
    1086 void oscar_accept_chat(gpointer w, struct aim_chat_invitation * inv);
    1087 void oscar_reject_chat(gpointer w, struct aim_chat_invitation * inv);
     1115void oscar_accept_chat(void *data);
     1116void oscar_reject_chat(void *data);
    10881117       
    10891118static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) {
     
    11191148}
    11201149
    1121 static void gaim_icq_authgrant(gpointer w, struct icq_auth *data) {
     1150static void gaim_icq_authgrant(void *data_) {
     1151        struct icq_auth *data = data_;
    11221152        char *uin, message;
    11231153        struct oscar_data *od = (struct oscar_data *)data->ic->proto_data;
     
    11341164}
    11351165
    1136 static void gaim_icq_authdeny(gpointer w, struct icq_auth *data) {
     1166static void gaim_icq_authdeny(void *data_) {
     1167        struct icq_auth *data = data_;
    11371168        char *uin, *message;
    11381169        struct oscar_data *od = (struct oscar_data *)data->ic->proto_data;
     
    11751206                        message = g_strdup(args->msg);
    11761207                        strip_linefeed(message);
    1177                         imcb_buddy_msg(ic, uin, message, 0, 0);
     1208                        imcb_buddy_msg(ic, normalize(uin), message, 0, 0);
    11781209                        g_free(uin);
    11791210                        g_free(message);
     
    11941225
    11951226                        strip_linefeed(message);
    1196                         imcb_buddy_msg(ic, uin, message, 0, 0);
     1227                        imcb_buddy_msg(ic, normalize(uin), message, 0, 0);
    11971228                        g_free(uin);
    11981229                        g_free(m);
     
    14691500
    14701501        for (i = 0; i < count; i++)
    1471                 imcb_chat_add_buddy(c->cnv, info[i].sn);
     1502                imcb_chat_add_buddy(c->cnv, normalize(info[i].sn));
    14721503
    14731504        return 1;
     
    14921523
    14931524        for (i = 0; i < count; i++)
    1494                 imcb_chat_remove_buddy(c->cnv, info[i].sn, NULL);
     1525                imcb_chat_remove_buddy(c->cnv, normalize(info[i].sn), NULL);
    14951526
    14961527        return 1;
     
    15431574        tmp = g_malloc(BUF_LONG);
    15441575        g_snprintf(tmp, BUF_LONG, "%s", msg);
    1545         imcb_chat_msg(ccon->cnv, info->sn, tmp, 0, 0);
     1576        imcb_chat_msg(ccon->cnv, normalize(info->sn), tmp, 0, 0);
    15461577        g_free(tmp);
    15471578
     
    17561787                        g_snprintf(sender, sizeof(sender), "%u", msg->sender);
    17571788                        strip_linefeed(dialog_msg);
    1758                         imcb_buddy_msg(ic, sender, dialog_msg, 0, t);
     1789                        imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t);
    17591790                        g_free(dialog_msg);
    17601791                } break;
     
    17771808
    17781809                        strip_linefeed(dialog_msg);
    1779                         imcb_buddy_msg(ic, sender, dialog_msg, 0, t);
     1810                        imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t);
    17801811                        g_free(dialog_msg);
    17811812                        g_free(m);
     
    20152046        struct aim_ssi_item *curitem;
    20162047        int tmp;
     2048        char *nrm;
    20172049
    20182050        /* Add from server list to local list */
    20192051        tmp = 0;
    20202052        for (curitem=sess->ssi.items; curitem; curitem=curitem->next) {
     2053                nrm = curitem->name ? normalize(curitem->name) : NULL;
     2054               
    20212055                switch (curitem->type) {
    20222056                        case 0x0000: /* Buddy */
    2023                                 if ((curitem->name) && (!imcb_find_buddy(ic, curitem->name))) {
     2057                                if ((curitem->name) && (!imcb_find_buddy(ic, nrm))) {
    20242058                                        char *realname = NULL;
    20252059
     
    20272061                                                    realname = aim_gettlv_str(curitem->data, 0x0131, 1);
    20282062                                               
    2029                                         imcb_add_buddy(ic, curitem->name, NULL);
     2063                                        imcb_add_buddy(ic, nrm, NULL);
    20302064                                       
    20312065                                        if (realname) {
    2032                                                 imcb_buddy_nick_hint(ic, curitem->name, realname);
    2033                                                 imcb_rename_buddy(ic, curitem->name, realname);
     2066                                                imcb_buddy_nick_hint(ic, nrm, realname);
     2067                                                imcb_rename_buddy(ic, nrm, realname);
    20342068                                                g_free(realname);
    20352069                                        }
     
    20432077                                        if (!list) {
    20442078                                                char *name;
    2045                                                 name = g_strdup(normalize(curitem->name));
     2079                                                name = g_strdup(nrm);
    20462080                                                ic->permit = g_slist_append(ic->permit, name);
    20472081                                                tmp++;
     
    20562090                                        if (!list) {
    20572091                                                char *name;
    2058                                                 name = g_strdup(normalize(curitem->name));
     2092                                                name = g_strdup(nrm);
    20592093                                                ic->deny = g_slist_append(ic->deny, name);
    20602094                                                tmp++;
     
    21182152                        if( st == 0x00 )
    21192153                        {
    2120                                 imcb_add_buddy( sess->aux_data, list, NULL );
     2154                                imcb_add_buddy( sess->aux_data, normalize(list), NULL );
    21212155                        }
    21222156                        else if( st == 0x0E )
     
    24482482        if(type2 == 0x0002) {
    24492483                /* User is typing */
    2450                 imcb_buddy_typing(ic, sn, OPT_TYPING);
     2484                imcb_buddy_typing(ic, normalize(sn), OPT_TYPING);
    24512485        }
    24522486        else if (type2 == 0x0001) {
    24532487                /* User has typed something, but is not actively typing (stale) */
    2454                 imcb_buddy_typing(ic, sn, OPT_THINKING);
     2488                imcb_buddy_typing(ic, normalize(sn), OPT_THINKING);
    24552489        }
    24562490        else {
    24572491                /* User has stopped typing */
    2458                 imcb_buddy_typing(ic, sn, 0);
     2492                imcb_buddy_typing(ic, normalize(sn), 0);
    24592493        }
    24602494       
     
    25882622}
    25892623
    2590 void oscar_accept_chat(gpointer w, struct aim_chat_invitation * inv)
    2591 {
     2624void oscar_accept_chat(void *data)
     2625{
     2626        struct aim_chat_invitation * inv = data;
     2627       
    25922628        oscar_chat_join(inv->ic, inv->name, NULL, NULL);
    25932629        g_free(inv->name);
     
    25952631}
    25962632
    2597 void oscar_reject_chat(gpointer w, struct aim_chat_invitation * inv)
    2598 {
     2633void oscar_reject_chat(void *data)
     2634{
     2635        struct aim_chat_invitation * inv = data;
     2636       
    25992637        g_free(inv->name);
    26002638        g_free(inv);
  • protocols/yahoo/libyahoo2.c

    r9730d72 r6738a67  
    6969#ifdef __MINGW32__
    7070# include <winsock2.h>
    71 # define write(a,b,c) send(a,b,c,0)
    72 # define read(a,b,c)  recv(a,b,c,0)
    7371#endif
    7472
     
    381379
    382380/* call repeatedly to get the next one */
    383 /*
    384381static struct yahoo_input_data * find_input_by_id(int id)
    385382{
     
    392389        return NULL;
    393390}
    394 */
    395391
    396392static struct yahoo_input_data * find_input_by_id_and_webcam_user(int id, const char * who)
     
    737733
    738734        memcpy(data + pos, "YMSG", 4); pos += 4;
    739         pos += yahoo_put16(data + pos, 0x0a00);
     735        pos += yahoo_put16(data + pos, 0x000c);
    740736        pos += yahoo_put16(data + pos, 0x0000);
    741737        pos += yahoo_put16(data + pos, pktlen + extra_pad);
     
    797793{
    798794        struct yahoo_data *yd = find_conn_by_id(id);
     795       
    799796        if(!yd)
    800797                return;
     
    31663163
    31673164        LOG(("write callback: id=%d fd=%d data=%p", id, fd, data));
    3168         if(!yid || !yid->txqueues)
     3165        if(!yid || !yid->txqueues || !find_conn_by_id(id))
    31693166                return -2;
    31703167       
     
    33513348                                        break;
    33523349                                case 5:
    3353                                         if(cp != "\005")
     3350                                        if(strcmp(cp, "5") != 0)
    33543351                                                yct->location = cp;
    33553352                                        k = 0;
     
    38423839        }
    38433840
    3844        
    3845 /*      do {
     3841        do {
    38463842                yahoo_input_close(yid);
    3847         } while((yid = find_input_by_id(id)));*/
    3848        
     3843        } while((yid = find_input_by_id(id)));
    38493844}
    38503845
  • protocols/yahoo/yahoo.c

    r9730d72 r6738a67  
    163163        g_slist_free( yd->buddygroups );
    164164       
    165         if( yd->logged_in )
    166                 yahoo_logoff( yd->y2_id );
    167         else
    168                 yahoo_close( yd->y2_id );
     165        yahoo_logoff( yd->y2_id );
    169166       
    170167        g_free( yd );
     
    315312        struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data;
    316313       
    317         yahoo_conference_invite( yd->y2_id, NULL, c->data, c->title, msg );
     314        yahoo_conference_invite( yd->y2_id, NULL, c->data, c->title, msg ? msg : "" );
    318315}
    319316
     
    454451{
    455452        struct byahoo_write_ready_data *d = data;
    456        
    457         if( !byahoo_get_ic_by_id( d->id ) )
    458                 /* WTF doesn't libyahoo clean this up? */
    459                 return FALSE;
    460453       
    461454        yahoo_write_ready( d->id, d->fd, d->data );
     
    798791}
    799792
    800 static void byahoo_accept_conf( gpointer w, struct byahoo_conf_invitation *inv )
    801 {
     793static void byahoo_accept_conf( void *data )
     794{
     795        struct byahoo_conf_invitation *inv = data;
     796       
    802797        yahoo_conference_logon( inv->yid, NULL, inv->members, inv->name );
    803798        imcb_chat_add_buddy( inv->c, inv->ic->acc->user );
     
    806801}
    807802
    808 static void byahoo_reject_conf( gpointer w, struct byahoo_conf_invitation *inv )
    809 {
     803static void byahoo_reject_conf( void *data )
     804{
     805        struct byahoo_conf_invitation *inv = data;
     806       
    810807        yahoo_conference_decline( inv->yid, NULL, inv->members, inv->name, "User rejected groupchat" );
    811808        imcb_chat_free( inv->c );
  • protocols/yahoo/yahoo_httplib.c

    r9730d72 r6738a67  
    5151#ifdef __MINGW32__
    5252# include <winsock2.h>
    53 # define write(a,b,c) send(a,b,c,0)
    54 # define read(a,b,c)  recv(a,b,c,0)
    5553# define snprintf _snprintf
    5654#endif
Note: See TracChangeset for help on using the changeset viewer.