Changeset bc090f0


Ignore:
Timestamp:
2010-03-20T22:42:59Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
ee6cc94
Parents:
ffb6dea
Message:

Error reporting and added a msgq_send function. Need to put some more
intelligence into it later.

Location:
protocols/msn
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/sb.c

    rffb6dea rbc090f0  
    607607                const struct msn_status_code *err = msn_status_by_number( num );
    608608               
     609                /* If the person is offline, send an offline message instead,
     610                   and don't report an error. */
    609611                if( num == 217 )
    610                 {
    611                         GSList *l;
    612                        
    613                         for( l = sb->msgq; l; l = l->next )
    614                         {
    615                                 struct msn_message *m = l->data;
    616                                 msn_soap_oim_send( ic, m->who, m->text );
    617                         }
    618                 }
    619                
    620                 imcb_error( ic, "Error reported by switchboard server: %s", err->text );
     612                        msn_soap_oim_send_queue( ic, &sb->msgq );
     613                else
     614                        imcb_error( ic, "Error reported by switchboard server: %s", err->text );
    621615               
    622616                if( err->flags & STATUS_SB_FATAL )
  • protocols/msn/soap.c

    rffb6dea rbc090f0  
    5757};
    5858
    59 struct msn_soap_oim_send_data
    60 {
    61         char *to;
    62         char *msg;
    63         int number;
    64         int need_retry;
    65 };
    66 
    6759static int msn_soap_send_request( struct msn_soap_req_data *req );
    6860
     
    139131}
    140132
     133
     134/* oim_send: Sending offline messages */
     135
     136struct msn_soap_oim_send_data
     137{
     138        char *to;
     139        char *msg;
     140        int number;
     141        int need_retry;
     142};
     143
    141144static int msn_soap_oim_build_request( struct msn_soap_req_data *soap_req )
    142145{
     
    183186        struct msn_soap_oim_send_data *oim = soap_req->data;
    184187       
    185         if( soap_req->http_req->status_code == 500 && oim->need_retry )
     188        if( soap_req->http_req->status_code == 500 && oim->need_retry && soap_req->ttl > 0 )
    186189        {
    187190                oim->need_retry = 0;
     
    189192        }
    190193        else if( soap_req->http_req->status_code == 200 )
     194        {
     195                imcb_log( soap_req->ic, "Offline message successfully delivered to %s", oim->to );
    191196                return MSN_SOAP_OK;
     197        }
    192198        else
     199        {
     200                imcb_log( soap_req->ic, "Failed to deliver offline message to %s:\n%s", oim->to, oim->msg );
    193201                return MSN_SOAP_ABORT;
     202        }
    194203}
    195204
     
    219228                                         msn_soap_oim_free_data );
    220229}
     230
     231int msn_soap_oim_send_queue( struct im_connection *ic, GSList **msgq )
     232{
     233        GSList *l;
     234        char *n = NULL;
     235       
     236        for( l = *msgq; l; l = l->next )
     237        {
     238                struct msn_message *m = l->data;
     239               
     240                if( n == NULL )
     241                        n = m->who;
     242                if( strcmp( n, m->who ) == 0 )
     243                        msn_soap_oim_send( ic, m->who, m->text );
     244        }
     245       
     246        while( *msgq != NULL )
     247        {
     248                struct msn_message *m = (*msgq)->data;
     249               
     250                g_free( m->who );
     251                g_free( m->text );
     252                g_free( m );
     253               
     254                *msgq = g_slist_remove( *msgq, m );
     255        }
     256}
  • protocols/msn/soap.h

    rffb6dea rbc090f0  
    8383
    8484int msn_soap_oim_send( struct im_connection *ic, const char *to, const char *msg );
     85int msn_soap_oim_send_queue( struct im_connection *ic, GSList **msgq );
    8586
    8687#endif /* __SOAP_H__ */
Note: See TracChangeset for help on using the changeset viewer.