Ignore:
Timestamp:
2010-10-03T02:45:26Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
04f0c10
Parents:
88de0c9 (diff), 2af3e23 (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:

Merging mainline, which includes a huge msnp13 merge.

Not 100% sure about the OpenSSL merge, should double check that but I'm
currently offline.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.c

    r88de0c9 r8e9e2b7  
    22  * BitlBee -- An IRC to other IM-networks gateway                     *
    33  *                                                                    *
    4   * Copyright 2002-2004 Wilmer van der Gaast and others                *
     4  * Copyright 2002-2010 Wilmer van der Gaast and others                *
    55  \********************************************************************/
    66
     
    2525
    2626#include "nogaim.h"
     27#include "soap.h"
    2728#include "msn.h"
    2829
     
    3536static void msn_init( account_t *acc )
    3637{
    37         set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc );
    38         set_add( &acc->set, "local_display_name", "false", set_eval_bool, acc );
     38        set_t *s;
     39       
     40        s = set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc );
     41        s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY;
     42       
    3943        set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc );
    4044        set_add( &acc->set, "switchboard_keepalives", "false", set_eval_bool, acc );
     45       
     46        acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE;
    4147}
    4248
     
    4753       
    4854        ic->proto_data = md;
    49         md->fd = -1;
    5055       
    5156        if( strchr( acc->user, '@' ) == NULL )
     
    5661        }
    5762       
    58         imcb_log( ic, "Connecting" );
    59        
    60         md->fd = proxy_connect( "messenger.hotmail.com", 1863, msn_ns_connected, ic );
    61         if( md->fd < 0 )
    62         {
    63                 imcb_error( ic, "Could not connect to server" );
    64                 imc_logout( ic, TRUE );
    65                 return;
    66         }
    67        
    6863        md->ic = ic;
    6964        md->away_state = msn_away_state_list;
    70        
    71         msn_connections = g_slist_append( msn_connections, ic );
     65        md->domaintree = g_tree_new( msn_domaintree_cmp );
     66        md->ns->fd = -1;
     67       
     68        msn_connections = g_slist_prepend( msn_connections, ic );
     69       
     70        imcb_log( ic, "Connecting" );
     71        msn_ns_connect( ic, md->ns, MSN_NS_HOST, MSN_NS_PORT );
    7272}
    7373
     
    7676        struct msn_data *md = ic->proto_data;
    7777        GSList *l;
     78        int i;
    7879       
    7980        if( md )
     
    8586                */
    8687               
    87                 if( md->fd >= 0 )
    88                         closesocket( md->fd );
    89                
    90                 if( md->handler )
    91                 {
    92                         if( md->handler->rxq ) g_free( md->handler->rxq );
    93                         if( md->handler->cmd_text ) g_free( md->handler->cmd_text );
    94                         g_free( md->handler );
    95                 }
     88                msn_ns_close( md->ns );
    9689               
    9790                while( md->switchboards )
     
    9992               
    10093                msn_msgq_purge( ic, &md->msgq );
    101                
    102                 while( md->groupcount > 0 )
    103                         g_free( md->grouplist[--md->groupcount] );
    104                 g_free( md->grouplist );
     94                msn_soapq_flush( ic, FALSE );
     95               
     96                for( i = 0; i < sizeof( md->tokens ) / sizeof( md->tokens[0] ); i ++ )
     97                        g_free( md->tokens[i] );
     98                g_free( md->lock_key );
     99                g_free( md->pp_policy );
     100               
     101                while( md->groups )
     102                {
     103                        struct msn_group *mg = md->groups->data;
     104                        g_free( mg->id );
     105                        g_free( mg->name );
     106                        g_free( mg );
     107                        md->groups = g_slist_remove( md->groups, mg );
     108                }
     109               
     110                g_tree_destroy( md->domaintree );
     111                md->domaintree = NULL;
    105112               
    106113                while( md->grpq )
     
    134141        if( strcmp( who, "raw" ) == 0 )
    135142        {
    136                 msn_write( ic, message, strlen( message ) );
    137                 msn_write( ic, "\r\n", 2 );
     143                msn_ns_write( ic, -1, "%s\r\n", message );
    138144        }
    139145        else
     
    173179static void msn_set_away( struct im_connection *ic, char *state, char *message )
    174180{
    175         char buf[1024];
     181        char *uux;
    176182        struct msn_data *md = ic->proto_data;
    177183       
     
    181187                md->away_state = msn_away_state_list + 1;
    182188       
    183         g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, md->away_state->code );
    184         msn_write( ic, buf, strlen( buf ) );
    185 }
    186 
    187 static void msn_set_my_name( struct im_connection *ic, char *info )
    188 {
    189         msn_set_display_name( ic, info );
     189        if( !msn_ns_write( ic, -1, "CHG %d %s\r\n", ++md->trId, md->away_state->code ) )
     190                return;
     191       
     192        uux = g_markup_printf_escaped( "<Data><PSM>%s</PSM><CurrentMedia></CurrentMedia>"
     193                                       "</Data>", message ? message : "" );
     194        msn_ns_write( ic, -1, "UUX %d %zd\r\n%s", ++md->trId, strlen( uux ), uux );
     195        g_free( uux );
    190196}
    191197
     
    200206        struct bee_user *bu = bee_user_by_handle( ic->bee, ic, who );
    201207       
    202         msn_buddy_list_add( ic, "FL", who, who, group );
     208        msn_buddy_list_add( ic, MSN_BUDDY_FL, who, who, group );
    203209        if( bu && bu->group )
    204                 msn_buddy_list_remove( ic, "FL", who, bu->group->name );
     210                msn_buddy_list_remove( ic, MSN_BUDDY_FL, who, bu->group->name );
    205211}
    206212
    207213static void msn_remove_buddy( struct im_connection *ic, char *who, char *group )
    208214{
    209         msn_buddy_list_remove( ic, "FL", who, NULL );
     215        msn_buddy_list_remove( ic, MSN_BUDDY_FL, who, NULL );
    210216}
    211217
     
    267273static void msn_keepalive( struct im_connection *ic )
    268274{
    269         msn_write( ic, "PNG\r\n", strlen( "PNG\r\n" ) );
     275        msn_ns_write( ic, -1, "PNG\r\n" );
    270276}
    271277
    272278static void msn_add_permit( struct im_connection *ic, char *who )
    273279{
    274         msn_buddy_list_add( ic, "AL", who, who, NULL );
     280        msn_buddy_list_add( ic, MSN_BUDDY_AL, who, who, NULL );
    275281}
    276282
    277283static void msn_rem_permit( struct im_connection *ic, char *who )
    278284{
    279         msn_buddy_list_remove( ic, "AL", who, NULL );
     285        msn_buddy_list_remove( ic, MSN_BUDDY_AL, who, NULL );
    280286}
    281287
     
    284290        struct msn_switchboard *sb;
    285291       
    286         msn_buddy_list_add( ic, "BL", who, who, NULL );
     292        msn_buddy_list_add( ic, MSN_BUDDY_BL, who, who, NULL );
    287293       
    288294        /* If there's still a conversation with this person, close it. */
     
    295301static void msn_rem_deny( struct im_connection *ic, char *who )
    296302{
    297         msn_buddy_list_remove( ic, "BL", who, NULL );
     303        msn_buddy_list_remove( ic, MSN_BUDDY_BL, who, NULL );
    298304}
    299305
     
    314320        account_t *acc = set->data;
    315321        struct im_connection *ic = acc->ic;
    316        
    317         /* Allow any name if we're offline. */
    318         if( ic == NULL )
    319                 return value;
     322        struct msn_data *md = ic->proto_data;
    320323       
    321324        if( strlen( value ) > 129 )
     
    325328        }
    326329       
    327         /* Returning NULL would be better, because the server still has to
    328            confirm the name change. However, it looks a bit confusing to the
    329            user. */
    330         return msn_set_display_name( ic, value ) ? value : NULL;
     330        if( md->flags & MSN_GOT_PROFILE_DN )
     331                imcb_log( ic, "Warning: Persistent name changes for this account have to be done "
     332                              "in the profile. BitlBee doesn't currently support this." );
     333       
     334        msn_soap_addressbook_set_display_name( ic, value );
     335        return msn_ns_set_display_name( ic, value ) ? value : NULL;
     336}
     337
     338static void msn_buddy_data_add( bee_user_t *bu )
     339{
     340        struct msn_data *md = bu->ic->proto_data;
     341        bu->data = g_new0( struct msn_buddy_data, 1 );
     342        g_tree_insert( md->domaintree, bu->handle, bu );
     343}
     344
     345static void msn_buddy_data_free( bee_user_t *bu )
     346{
     347        struct msn_data *md = bu->ic->proto_data;
     348        g_tree_remove( md->domaintree, bu->handle );
     349        g_free( bu->data );
    331350}
    332351
     
    344363        ret->set_away = msn_set_away;
    345364        ret->get_info = msn_get_info;
    346         ret->set_my_name = msn_set_my_name;
    347365        ret->add_buddy = msn_add_buddy;
    348366        ret->remove_buddy = msn_remove_buddy;
     
    358376        ret->send_typing = msn_send_typing;
    359377        ret->handle_cmp = g_strcasecmp;
     378        ret->buddy_data_add = msn_buddy_data_add;
     379        ret->buddy_data_free = msn_buddy_data_free;
     380       
    360381        //ret->transfer_request = msn_ftp_transfer_request;
    361382
Note: See TracChangeset for help on using the changeset viewer.