Changeset dcf155d


Ignore:
Timestamp:
2012-02-11T17:26:41Z (9 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.

Location:
protocols/msn
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/sb.c

    r4f37a98 rdcf155d  
    629629                /* If the person is offline, send an offline message instead,
    630630                   and don't report an error. */
     631                /* TODO: Support for OIMs that works. (#874) */
     632                /*
    631633                if( num == 217 )
    632634                        msn_soap_oim_send_queue( ic, &sb->msgq );
    633635                else
     636                */
    634637                        imcb_error( ic, "Error reported by switchboard server: %s", err->text );
    635638               
  • 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
  • protocols/msn/soap.h

    r4f37a98 rdcf155d  
    144144
    145145int msn_soap_passport_sso_request( struct im_connection *ic, const char *nonce );
    146 
    147 
    148 #define SOAP_OIM_SEND_URL "https://ows.messenger.msn.com/OimWS/oim.asmx"
    149 #define SOAP_OIM_SEND_ACTION "http://messenger.live.com/ws/2006/09/oim/Store2"
    150 
    151 #define SOAP_OIM_SEND_PAYLOAD \
    152 "<?xml version=\"1.0\" encoding=\"utf-8\"?>" \
    153 "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
    154 "<soap:Header>" \
    155   "<From memberName=\"%s\" friendlyName=\"=?utf-8?B?%s?=\" xml:lang=\"nl-nl\" proxy=\"MSNMSGR\" xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\" msnpVer=\"%s\" buildVer=\"%s\"/>" \
    156   "<To memberName=\"%s\" xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\"/>" \
    157   "<Ticket passport=\"%s\" appid=\"%s\" lockkey=\"%s\" xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\"/>" \
    158   "<Sequence xmlns=\"http://schemas.xmlsoap.org/ws/2003/03/rm\">" \
    159     "<Identifier xmlns=\"http://schemas.xmlsoap.org/ws/2002/07/utility\">http://messenger.msn.com</Identifier>" \
    160     "<MessageNumber>%d</MessageNumber>" \
    161   "</Sequence>" \
    162 "</soap:Header>" \
    163 "<soap:Body>" \
    164   "<MessageType xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\">text</MessageType>" \
    165   "<Content xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\">" \
    166     "MIME-Version: 1.0\r\n" \
    167     "Content-Type: text/plain; charset=UTF-8\r\n" \
    168     "Content-Transfer-Encoding: base64\r\n" \
    169     "X-OIM-Message-Type: OfflineMessage\r\n" \
    170     "X-OIM-Run-Id: {F9A6C9DD-0D94-4E85-9CC6-F9D118CC1CAF}\r\n" \
    171     "X-OIM-Sequence-Num: %d\r\n" \
    172     "\r\n" \
    173     "%s" \
    174   "</Content>" \
    175 "</soap:Body>" \
    176 "</soap:Envelope>"
    177 
    178 int msn_soap_oim_send( struct im_connection *ic, const char *to, const char *msg );
    179 int msn_soap_oim_send_queue( struct im_connection *ic, GSList **msgq );
    180146
    181147
Note: See TracChangeset for help on using the changeset viewer.