aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/msn/ns.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2012-09-16 22:44:09 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2012-09-16 22:44:09 +0100
commita325ebd591a7c54d5fc34a2ac313d0a723f54e05 (patch)
tree9e60725c1828f1f9a10b8fce35f4c3c65bfae629 /protocols/msn/ns.c
parentfe79de663c230f7d4b525a5052da39b1d10c3b9d (diff)
Notification on incoming offline messages. Life is too short to implement
the SOAP code to actually fetch them but at least tell the user that s/he received something.
Diffstat (limited to 'protocols/msn/ns.c')
-rw-r--r--protocols/msn/ns.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c
index 4f80f490..a4785eb2 100644
--- a/protocols/msn/ns.c
+++ b/protocols/msn/ns.c
@@ -674,7 +674,57 @@ static int msn_ns_message( struct msn_handler_data *handler, char *msg, int msgl
}
else if( g_strncasecmp( ct, "text/x-msmsgsactivemailnotification", 35 ) == 0 )
{
- /* Sorry, but this one really is *USELESS* */
+ }
+ else if( g_strncasecmp( ct, "text/x-msmsgsinitialmdatanotification", 37 ) == 0 ||
+ g_strncasecmp( ct, "text/x-msmsgsoimnotification", 28 ) == 0 )
+ {
+ /* We received an offline message. Or at least notification
+ that there is one waiting for us. Fetching the message(s)
+ and purging them from the server is a lot of SOAPy work
+ not worth doing IMHO. Also I thought it was possible to
+ have the notification server send them directly, I was
+ pretty sure I saw Pidgin do it..
+
+ At least give a notification for now, seems like a
+ reasonable thing to do. Only problem is, they'll keep
+ coming back at login time until you read them using a
+ different client. :-( */
+
+ char *xml = get_rfc822_header( body, "Mail-Data:", blen );
+ struct xt_node *md, *m;
+
+ if( !xml )
+ return 1;
+ md = xt_from_string( xml );
+ if( !md )
+ return 1;
+
+ for( m = md->children; ( m = xt_find_node( m, "M" ) ); m = m->next )
+ {
+ struct xt_node *e = xt_find_node( m->children, "E" );
+ struct xt_node *rt = xt_find_node( m->children, "RT" );
+ struct tm tp;
+ time_t msgtime = 0;
+
+ if( !e || !e->text )
+ continue;
+
+ memset( &tp, 0, sizeof( tp ) );
+ if( rt && rt->text &&
+ sscanf( rt->text, "%4d-%2d-%2dT%2d:%2d:%2d.",
+ &tp.tm_year, &tp.tm_mon, &tp.tm_mday,
+ &tp.tm_hour, &tp.tm_min, &tp.tm_sec ) == 6 )
+ {
+ tp.tm_year -= 1900;
+ tp.tm_mon --;
+ msgtime = mktime_utc( &tp );
+
+ }
+ imcb_buddy_msg( ic, e->text, "<< \002BitlBee\002 - Received offline message. BitlBee can't show these. >>", 0, msgtime );
+ }
+
+ g_free( xml );
+ xt_free_node( md );
}
else
{