Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.c

    rdaae10f r4452e69  
    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
     
    6874        md->ic = ic;
    6975        md->away_state = msn_away_state_list;
     76        md->domaintree = g_tree_new( msn_domaintree_cmp );
    7077       
    7178        msn_connections = g_slist_append( msn_connections, ic );
     
    103110                        g_free( md->grouplist[--md->groupcount] );
    104111                g_free( md->grouplist );
     112                g_free( md->tokens[0] );
     113                g_free( md->tokens[1] );
     114                g_free( md->tokens[2] );
     115                g_free( md->lock_key );
     116               
     117                g_tree_destroy( md->domaintree );
     118                md->domaintree = NULL;
    105119               
    106120                while( md->grpq )
     
    174188{
    175189        char buf[1024];
     190        char *uux;
    176191        struct msn_data *md = ic->proto_data;
    177192       
     
    182197       
    183198        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 );
     199        if( !msn_write( ic, buf, strlen( buf ) ) )
     200                return;
     201       
     202        uux = g_markup_printf_escaped( "<Data><PSM>%s</PSM><CurrentMedia></CurrentMedia>"
     203                                       "</Data>", message ? message : "" );
     204        g_snprintf( buf, sizeof( buf ), "UUX %d %zd\r\n%s", ++md->trId, strlen( uux ), uux );
     205        if( !msn_write( ic, buf, strlen( buf ) ) )
     206                return;
    190207}
    191208
     
    314331        account_t *acc = set->data;
    315332        struct im_connection *ic = acc->ic;
    316        
    317         /* Allow any name if we're offline. */
    318         if( ic == NULL )
    319                 return value;
     333        struct msn_data *md = ic->proto_data;
     334        char buf[512];
     335        char *fn;
    320336       
    321337        if( strlen( value ) > 129 )
     
    325341        }
    326342       
    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;
     343        msn_soap_addressbook_set_display_name( ic, value );
     344
     345        fn = g_malloc( strlen( value ) * 3 + 1 );
     346        strcpy( fn, value );
     347        http_encode( fn );
     348        g_snprintf( buf, sizeof( buf ), "PRP %d MFN %s\r\n",
     349                    ++md->trId, fn );
     350        g_free( fn );
     351       
     352        /* Note: We don't actually know if the server accepted the new name,
     353           and won't give proper feedback yet if it doesn't. */
     354        return msn_write( ic, buf, strlen( buf ) ) ? value : NULL;
     355}
     356
     357static void msn_buddy_data_add( bee_user_t *bu )
     358{
     359        struct msn_data *md = bu->ic->proto_data;
     360        bu->data = g_new0( struct msn_buddy_data, 1 );
     361        g_tree_insert( md->domaintree, bu->handle, bu );
     362}
     363
     364static void msn_buddy_data_free( bee_user_t *bu )
     365{
     366        struct msn_data *md = bu->ic->proto_data;
     367        g_tree_remove( md->domaintree, bu->handle );
     368        g_free( bu->data );
    331369}
    332370
     
    343381        ret->set_away = msn_set_away;
    344382        ret->get_info = msn_get_info;
    345         ret->set_my_name = msn_set_my_name;
    346383        ret->add_buddy = msn_add_buddy;
    347384        ret->remove_buddy = msn_remove_buddy;
     
    357394        ret->send_typing = msn_send_typing;
    358395        ret->handle_cmp = g_strcasecmp;
     396        ret->buddy_data_add = msn_buddy_data_add;
     397        ret->buddy_data_free = msn_buddy_data_free;
     398       
    359399        //ret->transfer_request = msn_ftp_transfer_request;
    360400
Note: See TracChangeset for help on using the changeset viewer.