diff options
Diffstat (limited to 'protocols/jabber/message.c')
| -rw-r--r-- | protocols/jabber/message.c | 31 | 
1 files changed, 22 insertions, 9 deletions
| diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c index fea728e3..3ff1da1c 100644 --- a/protocols/jabber/message.c +++ b/protocols/jabber/message.c @@ -29,6 +29,7 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data )  	char *from = xt_find_attr( node, "from" );  	char *type = xt_find_attr( node, "type" );  	struct xt_node *body = xt_find_node( node->children, "body" ); +	char *s;  	if( !type )  		return XT_HANDLED;	/* Grmbl... FIXME */ @@ -37,7 +38,7 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data )  	{  		struct jabber_buddy *bud = NULL; -		if( strchr( from, '/' ) == NULL ) +		if( ( s = strchr( from, '/' ) ) == NULL )  		{  			/* It just shouldn't happen. */  			hide_login_progress( gc, "Received message packet from bare JID" ); @@ -45,21 +46,34 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data )  			return XT_ABORT;  		} -		bud = jabber_buddy_by_jid( gc, from ); -		bud->last_act = time( NULL ); +		if( ( bud = jabber_buddy_by_jid( gc, from ) ) ) +			bud->last_act = time( NULL ); +		else +			*s = 0; /* We need to generate a bare JID now. */  		if( body ) /* Could be just a typing notification. */ -			serv_got_im( gc, bud->handle, body->text, 0, 0, 0 ); +			serv_got_im( gc, bud ? bud->handle : from, body->text, 0, 0, 0 ); +		/* Handling of incoming typing notifications. */  		if( xt_find_node( node->children, "composing" ) )  		{ -			bud->flags |= JBFLAG_DOES_JEP85; -			serv_got_typing( gc, bud->handle, 0, 1 ); +			bud->flags |= JBFLAG_DOES_XEP85; +			serv_got_typing( gc, bud ? bud->handle : from, 0, 1 );  		} -		else if( xt_find_node( node->children, "active" ) ) +		/* No need to send a "stopped typing" signal when there's a message. */ +		else if( xt_find_node( node->children, "active" ) && ( body == NULL ) )  		{ -			bud->flags |= JBFLAG_DOES_JEP85; +			bud->flags |= JBFLAG_DOES_XEP85; +			serv_got_typing( gc, bud ? bud->handle : from, 0, 0 );  		} +		else if( xt_find_node( node->children, "paused" ) ) +		{ +			bud->flags |= JBFLAG_DOES_XEP85; +			serv_got_typing( gc, bud ? bud->handle : from, 0, 2 ); +		} +		 +		if( s ) +			*s = '/'; /* And convert it back to a full JID. */  	}  	else  	{ @@ -69,4 +83,3 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data )  	return XT_HANDLED;  } - | 
