Ignore:
Timestamp:
2012-02-11T17:26:41Z (12 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
7d4ffc2
Parents:
4f37a98
Message:

Drop dead support for MSN offline messages (that SOAP server isn't even in
DNS anymore). Bug #874 for adding support for the new (much simpler, for a
change) way.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/soap.c

    r4f37a98 rdcf155d  
    474474
    475475
    476 /* oim_send: Sending offline messages */
    477 
    478 struct msn_soap_oim_send_data
    479 {
    480         char *to;
    481         char *msg;
    482         int number;
    483         msn_soap_result_t need_retry;
    484 };
    485 
    486 static int msn_soap_oim_build_request( struct msn_soap_req_data *soap_req )
    487 {
    488         struct msn_soap_oim_send_data *oim = soap_req->data;
    489         struct im_connection *ic = soap_req->ic;
    490         struct msn_data *md = ic->proto_data;
    491         char *display_name_b64;
    492        
    493         display_name_b64 = tobase64( set_getstr( &ic->acc->set, "display_name" ) );
    494        
    495         soap_req->url = g_strdup( SOAP_OIM_SEND_URL );
    496         soap_req->action = g_strdup( SOAP_OIM_SEND_ACTION );
    497         soap_req->payload = g_markup_printf_escaped( SOAP_OIM_SEND_PAYLOAD,
    498                 ic->acc->user, display_name_b64, MSNP_VER, MSNP_BUILD,
    499                 oim->to, md->tokens[2],
    500                 MSNP11_PROD_ID, md->lock_key ? md->lock_key : "",
    501                 oim->number, oim->number, oim->msg );
    502        
    503         g_free( display_name_b64 );
    504         oim->need_retry = MSN_SOAP_OK;
    505        
    506         return MSN_SOAP_OK;
    507 }
    508 
    509 static xt_status msn_soap_oim_reauth( struct xt_node *node, gpointer data )
    510 {
    511         struct msn_soap_req_data *soap_req = data;
    512         struct msn_soap_oim_send_data *oim = soap_req->data;
    513         struct im_connection *ic = soap_req->ic;
    514         struct msn_data *md = ic->proto_data;
    515         struct xt_node *c;
    516        
    517         if( ( c = xt_find_node( node->children, "LockKeyChallenge" ) ) && c->text_len > 0 )
    518         {
    519                 g_free( md->lock_key );
    520                 md->lock_key = msn_p11_challenge( c->text );
    521                 oim->need_retry = MSN_SOAP_RETRY;
    522         }
    523         if( xt_find_node( node->children, "RequiredAuthPolicy" ) )
    524         {
    525                 oim->need_retry = MSN_SOAP_REAUTH;
    526         }
    527        
    528         return XT_HANDLED;
    529 }
    530 
    531 static const struct xt_handler_entry msn_soap_oim_send_parser[] = {
    532         { "detail", "soap:Fault", msn_soap_oim_reauth },
    533         { NULL,     NULL,         NULL                }
    534 };
    535 
    536 static int msn_soap_oim_handle_response( struct msn_soap_req_data *soap_req )
    537 {
    538         struct msn_soap_oim_send_data *oim = soap_req->data;
    539        
    540         if( soap_req->http_req->status_code == 500 && oim->need_retry && soap_req->ttl > 0 )
    541         {
    542                 return oim->need_retry;
    543         }
    544         else if( soap_req->http_req->status_code == 200 )
    545         {
    546                 /* Noise..
    547                 imcb_log( soap_req->ic, "Offline message successfully delivered to %s", oim->to );
    548                 */
    549                 return MSN_SOAP_OK;
    550         }
    551         else
    552         {
    553                 char *dec = frombase64( oim->msg );
    554                 imcb_log( soap_req->ic, "Failed to deliver offline message to %s:\n%s", oim->to, dec );
    555                 g_free( dec );
    556                 return MSN_SOAP_ABORT;
    557         }
    558 }
    559 
    560 static int msn_soap_oim_free_data( struct msn_soap_req_data *soap_req )
    561 {
    562         struct msn_soap_oim_send_data *oim = soap_req->data;
    563        
    564         g_free( oim->to );
    565         g_free( oim->msg );
    566         g_free( oim );
    567        
    568         return MSN_SOAP_OK;
    569 }
    570 
    571 int msn_soap_oim_send( struct im_connection *ic, const char *to, const char *msg )
    572 {
    573         struct msn_soap_oim_send_data *data;
    574        
    575         /* Don't send any of the special messages since they creep people out. :-) */
    576         if( strncmp( msg, "\r\r", 2 ) == 0 )
    577                 return 0;
    578        
    579         data = g_new0( struct msn_soap_oim_send_data, 1 );
    580         data->to = g_strdup( to );
    581         data->msg = tobase64( msg );
    582         data->number = 1;
    583        
    584         return msn_soap_start( ic, data, msn_soap_oim_build_request,
    585                                          msn_soap_oim_send_parser,
    586                                          msn_soap_oim_handle_response,
    587                                          msn_soap_oim_free_data );
    588 }
    589 
    590 int msn_soap_oim_send_queue( struct im_connection *ic, GSList **msgq )
    591 {
    592         GSList *l;
    593         char *n = NULL;
    594        
    595         for( l = *msgq; l; l = l->next )
    596         {
    597                 struct msn_message *m = l->data;
    598                
    599                 if( n == NULL )
    600                         n = m->who;
    601                 if( strcmp( n, m->who ) == 0 )
    602                         msn_soap_oim_send( ic, m->who, m->text );
    603         }
    604        
    605         while( *msgq != NULL )
    606         {
    607                 struct msn_message *m = (*msgq)->data;
    608                
    609                 g_free( m->who );
    610                 g_free( m->text );
    611                 g_free( m );
    612                
    613                 *msgq = g_slist_remove( *msgq, m );
    614         }
    615        
    616         return 1;
    617 }
    618 
    619 
    620476/* memlist: Fetching the membership list (NOT address book) */
    621477
Note: See TracChangeset for help on using the changeset viewer.