aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--protocols/msn/sb.c16
-rw-r--r--protocols/msn/soap.c54
-rw-r--r--protocols/msn/soap.h1
3 files changed, 51 insertions, 20 deletions
diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c
index 920e7f61..461bd483 100644
--- a/protocols/msn/sb.c
+++ b/protocols/msn/sb.c
@@ -606,18 +606,12 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts )
int num = atoi( cmd[0] );
const struct msn_status_code *err = msn_status_by_number( num );
+ /* If the person is offline, send an offline message instead,
+ and don't report an error. */
if( num == 217 )
- {
- GSList *l;
-
- for( l = sb->msgq; l; l = l->next )
- {
- struct msn_message *m = l->data;
- msn_soap_oim_send( ic, m->who, m->text );
- }
- }
-
- imcb_error( ic, "Error reported by switchboard server: %s", err->text );
+ msn_soap_oim_send_queue( ic, &sb->msgq );
+ else
+ imcb_error( ic, "Error reported by switchboard server: %s", err->text );
if( err->flags & STATUS_SB_FATAL )
{
diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c
index f329cea9..82ecfea2 100644
--- a/protocols/msn/soap.c
+++ b/protocols/msn/soap.c
@@ -56,14 +56,6 @@ struct msn_soap_req_data
msn_soap_func build_request, handle_response, free_data;
};
-struct msn_soap_oim_send_data
-{
- char *to;
- char *msg;
- int number;
- int need_retry;
-};
-
static int msn_soap_send_request( struct msn_soap_req_data *req );
static int msn_soap_start( struct im_connection *ic,
@@ -138,6 +130,17 @@ static void msn_soap_handle_response( struct http_request *http_req )
}
}
+
+/* oim_send: Sending offline messages */
+
+struct msn_soap_oim_send_data
+{
+ char *to;
+ char *msg;
+ int number;
+ int need_retry;
+};
+
static int msn_soap_oim_build_request( struct msn_soap_req_data *soap_req )
{
struct msn_soap_oim_send_data *oim = soap_req->data;
@@ -182,15 +185,21 @@ static int msn_soap_oim_handle_response( struct msn_soap_req_data *soap_req )
{
struct msn_soap_oim_send_data *oim = soap_req->data;
- if( soap_req->http_req->status_code == 500 && oim->need_retry )
+ if( soap_req->http_req->status_code == 500 && oim->need_retry && soap_req->ttl > 0 )
{
oim->need_retry = 0;
return MSN_SOAP_RETRY;
}
else if( soap_req->http_req->status_code == 200 )
+ {
+ imcb_log( soap_req->ic, "Offline message successfully delivered to %s", oim->to );
return MSN_SOAP_OK;
+ }
else
+ {
+ imcb_log( soap_req->ic, "Failed to deliver offline message to %s:\n%s", oim->to, oim->msg );
return MSN_SOAP_ABORT;
+ }
}
static int msn_soap_oim_free_data( struct msn_soap_req_data *soap_req )
@@ -218,3 +227,30 @@ int msn_soap_oim_send( struct im_connection *ic, const char *to, const char *msg
msn_soap_oim_handle_response,
msn_soap_oim_free_data );
}
+
+int msn_soap_oim_send_queue( struct im_connection *ic, GSList **msgq )
+{
+ GSList *l;
+ char *n = NULL;
+
+ for( l = *msgq; l; l = l->next )
+ {
+ struct msn_message *m = l->data;
+
+ if( n == NULL )
+ n = m->who;
+ if( strcmp( n, m->who ) == 0 )
+ msn_soap_oim_send( ic, m->who, m->text );
+ }
+
+ while( *msgq != NULL )
+ {
+ struct msn_message *m = (*msgq)->data;
+
+ g_free( m->who );
+ g_free( m->text );
+ g_free( m );
+
+ *msgq = g_slist_remove( *msgq, m );
+ }
+}
diff --git a/protocols/msn/soap.h b/protocols/msn/soap.h
index 687cc282..3db2d59d 100644
--- a/protocols/msn/soap.h
+++ b/protocols/msn/soap.h
@@ -82,5 +82,6 @@
"</soap:Envelope>"
int msn_soap_oim_send( struct im_connection *ic, const char *to, const char *msg );
+int msn_soap_oim_send_queue( struct im_connection *ic, GSList **msgq );
#endif /* __SOAP_H__ */