From f06894d8f55b50b632c1d81ad878f8581273ba66 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 20 Sep 2006 12:18:56 +0200 Subject: Added some pretty empty files. --- protocols/jabber/message.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 protocols/jabber/message.c (limited to 'protocols/jabber/message.c') diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c new file mode 100644 index 00000000..d4326063 --- /dev/null +++ b/protocols/jabber/message.c @@ -0,0 +1,36 @@ +/***************************************************************************\ +* * +* BitlBee - An IRC to IM gateway * +* Jabber module - Main file * +* * +* Copyright 2006 Wilmer van der Gaast * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, write to the Free Software Foundation, Inc., * +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * +* * +\***************************************************************************/ + +#include "jabber.h" + +xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) +{ + char *from = xt_find_attr( node, "from" ); + struct xt_node *msg = xt_find_node( node->children, "body" ); + + printf( "Received MSG from %s: %s\n", from, msg ? msg->text : "" ); + xt_print( node ); + + return XT_HANDLED; +} + -- cgit v1.2.3 From 21167d2d14c333d67445546bb69dd52dd295287d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 20 Sep 2006 21:42:27 +0200 Subject: It can send a valid (pre-XMPP) login packet. Lots of work to do, still... --- protocols/jabber/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols/jabber/message.c') diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c index d4326063..e5f75464 100644 --- a/protocols/jabber/message.c +++ b/protocols/jabber/message.c @@ -1,7 +1,7 @@ /***************************************************************************\ * * * BitlBee - An IRC to IM gateway * -* Jabber module - Main file * +* Jabber module - Handling of message(s) (tags), etc * * * * Copyright 2006 Wilmer van der Gaast * * * -- cgit v1.2.3 From dd788bb0b18684be993cc7edf1f0da6f8e36449d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 21 Sep 2006 09:32:39 +0200 Subject: Added enough to not make it crash on login, and it can properly receive messages now. Just try to figure out why it doesn't get typing notifications... --- protocols/jabber/message.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'protocols/jabber/message.c') diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c index e5f75464..b41522fd 100644 --- a/protocols/jabber/message.c +++ b/protocols/jabber/message.c @@ -25,11 +25,32 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) { + struct gaim_connection *gc = data; char *from = xt_find_attr( node, "from" ); + char *type = xt_find_attr( node, "type" ); struct xt_node *msg = xt_find_node( node->children, "body" ); - printf( "Received MSG from %s: %s\n", from, msg ? msg->text : "" ); - xt_print( node ); + if( !type || !msg ) + return XT_HANDLED; /* Grmbl... FIXME */ + + if( strcmp( type, "chat" ) == 0 ) + { + char *s; + + s = strchr( from, '/' ); + if( s ) + *s = 0; + + serv_got_im( gc, from, msg->text, 0, 0, 0 ); + + if( s ) + *s = '/'; + } + else + { + printf( "Received MSG from %s: %s\n", from, msg ? msg->text : "" ); + xt_print( node ); + } return XT_HANDLED; } -- cgit v1.2.3 From a21a8ac4fbd5a234bc8d31d9d487c74a81383c8a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 10 Oct 2006 14:05:42 +0200 Subject: Added resource selection (based on priority or time of last message) to budd_by_jid(), added a full_jid property to easily address that resource without having to rebuild the full JID every time and implemented typing notification shite. --- protocols/jabber/message.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'protocols/jabber/message.c') diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c index b41522fd..fea728e3 100644 --- a/protocols/jabber/message.c +++ b/protocols/jabber/message.c @@ -28,27 +28,42 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) struct gaim_connection *gc = data; char *from = xt_find_attr( node, "from" ); char *type = xt_find_attr( node, "type" ); - struct xt_node *msg = xt_find_node( node->children, "body" ); + struct xt_node *body = xt_find_node( node->children, "body" ); - if( !type || !msg ) + if( !type ) return XT_HANDLED; /* Grmbl... FIXME */ if( strcmp( type, "chat" ) == 0 ) { - char *s; + struct jabber_buddy *bud = NULL; - s = strchr( from, '/' ); - if( s ) - *s = 0; + if( strchr( from, '/' ) == NULL ) + { + /* It just shouldn't happen. */ + hide_login_progress( gc, "Received message packet from bare JID" ); + signoff( gc ); + return XT_ABORT; + } - serv_got_im( gc, from, msg->text, 0, 0, 0 ); + bud = jabber_buddy_by_jid( gc, from ); + bud->last_act = time( NULL ); - if( s ) - *s = '/'; + if( body ) /* Could be just a typing notification. */ + serv_got_im( gc, bud->handle, body->text, 0, 0, 0 ); + + if( xt_find_node( node->children, "composing" ) ) + { + bud->flags |= JBFLAG_DOES_JEP85; + serv_got_typing( gc, bud->handle, 0, 1 ); + } + else if( xt_find_node( node->children, "active" ) ) + { + bud->flags |= JBFLAG_DOES_JEP85; + } } else { - printf( "Received MSG from %s: %s\n", from, msg ? msg->text : "" ); + printf( "Received MSG from %s:\n", from ); xt_print( node ); } -- cgit v1.2.3 From 788a1afa9628aeaf9d69fc53f49131a4330253cf Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Oct 2006 22:24:01 +0200 Subject: Proper cleanup of jabber buddy structures when removing a buddy from the list, proper checking (and handling) of events related to buddies that aren't "hashed" yet, limit checks on priorityto setting, renamed JEP85 to XEP85, support for more XEP85 states. --- protocols/jabber/message.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'protocols/jabber/message.c') 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; } - -- cgit v1.2.3 From f0071b791cc1be18a3236bdc6e363c837210e5cd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 23 Oct 2006 22:01:19 +0200 Subject: Better handling of packets. (Headlines, JIDs without /resource part, non-chat messages.) --- protocols/jabber/message.c | 62 ++++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 21 deletions(-) (limited to 'protocols/jabber/message.c') diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c index 3ff1da1c..81de177a 100644 --- a/protocols/jabber/message.c +++ b/protocols/jabber/message.c @@ -28,31 +28,56 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) struct gaim_connection *gc = 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" ); + struct xt_node *body = xt_find_node( node->children, "body" ), *c; char *s; - if( !type ) - return XT_HANDLED; /* Grmbl... FIXME */ - - if( strcmp( type, "chat" ) == 0 ) + if( type && strcmp( type, "error" ) == 0 ) + { + /* Handle type=error packet. */ + } + else if( type && strcmp( type, "groupchat" ) == 0 ) + { + /* TODO! */ + } + else /* "chat", "normal", "headline", no-type or whatever. Should all be pretty similar. */ { struct jabber_buddy *bud = NULL; + GString *fullmsg = g_string_new( "" ); - if( ( s = strchr( from, '/' ) ) == NULL ) + if( ( s = strchr( from, '/' ) ) ) { - /* It just shouldn't happen. */ - hide_login_progress( gc, "Received message packet from bare JID" ); - signoff( gc ); - return XT_ABORT; + 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( ( bud = jabber_buddy_by_jid( gc, from ) ) ) - bud->last_act = time( NULL ); - else - *s = 0; /* We need to generate a bare JID now. */ + if( strcmp( type, "headline" ) == 0 ) + { + c = xt_find_node( node->children, "subject" ); + g_string_append_printf( fullmsg, "Headline: %s\n", c && c->text_len > 0 ? c->text : "" ); + + /* http://.... can contain a URL, it seems. */ + for( c = node->children; c; c = c->next ) + { + struct xt_node *url; + + if( ( url = xt_find_node( c->children, "url" ) ) && url->text_len > 0 ) + g_string_append_printf( fullmsg, "URL: %s\n", url->text ); + } + } + else if( ( c = xt_find_node( node->children, "subject" ) ) && c->text_len > 0 ) + { + g_string_append_printf( fullmsg, "<< \002BitlBee\002 - Message with subject: %s >>\n", c->text ); + } + + if( body && body->text_len > 0 ) /* Could be just a typing notification. */ + fullmsg = g_string_append( fullmsg, body->text ); - if( body ) /* Could be just a typing notification. */ - serv_got_im( gc, bud ? bud->handle : from, body->text, 0, 0, 0 ); + if( fullmsg->len > 0 ) + serv_got_im( gc, bud ? bud->handle : from, fullmsg->str, 0, 0, fullmsg->len ); + + g_string_free( fullmsg, TRUE ); /* Handling of incoming typing notifications. */ if( xt_find_node( node->children, "composing" ) ) @@ -75,11 +100,6 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) if( s ) *s = '/'; /* And convert it back to a full JID. */ } - else - { - printf( "Received MSG from %s:\n", from ); - xt_print( node ); - } return XT_HANDLED; } -- cgit v1.2.3 From 62d0c141f1118d245fe192151e57b2beb739aa5c Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 24 Oct 2006 21:04:52 +0200 Subject: Forgot about one possible NULL pointer dereference in jabber_pkt_message(). --- protocols/jabber/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols/jabber/message.c') diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c index 81de177a..ad19a1dc 100644 --- a/protocols/jabber/message.c +++ b/protocols/jabber/message.c @@ -52,7 +52,7 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) *s = 0; /* We need to generate a bare JID now. */ } - if( strcmp( type, "headline" ) == 0 ) + if( type && strcmp( type, "headline" ) == 0 ) { c = xt_find_node( node->children, "subject" ); g_string_append_printf( fullmsg, "Headline: %s\n", c && c->text_len > 0 ? c->text : "" ); -- cgit v1.2.3 From 0d3f30f5449cf1730c006314f3dd60843e911ad1 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 13 Nov 2006 00:06:08 +0100 Subject: Improved handling of JIDs: Bare JIDs are allowed (*sigh*) and case insensitivity. Probably not complete yet... --- protocols/jabber/message.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'protocols/jabber/message.c') diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c index ad19a1dc..ac72f661 100644 --- a/protocols/jabber/message.c +++ b/protocols/jabber/message.c @@ -46,7 +46,7 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) if( ( s = strchr( from, '/' ) ) ) { - if( ( bud = jabber_buddy_by_jid( gc, from ) ) ) + if( ( bud = jabber_buddy_by_jid( gc, from, GET_BUDDY_EXACT ) ) ) bud->last_act = time( NULL ); else *s = 0; /* We need to generate a bare JID now. */ @@ -75,7 +75,7 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) fullmsg = g_string_append( fullmsg, body->text ); if( fullmsg->len > 0 ) - serv_got_im( gc, bud ? bud->handle : from, fullmsg->str, 0, 0, fullmsg->len ); + serv_got_im( gc, bud ? bud->bare_jid : from, fullmsg->str, 0, 0, fullmsg->len ); g_string_free( fullmsg, TRUE ); @@ -83,18 +83,18 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) if( xt_find_node( node->children, "composing" ) ) { bud->flags |= JBFLAG_DOES_XEP85; - serv_got_typing( gc, bud ? bud->handle : from, 0, 1 ); + serv_got_typing( gc, bud ? bud->bare_jid : from, 0, 1 ); } /* 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_XEP85; - serv_got_typing( gc, bud ? bud->handle : from, 0, 0 ); + serv_got_typing( gc, bud ? bud->bare_jid : 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 ); + serv_got_typing( gc, bud ? bud->bare_jid : from, 0, 2 ); } if( s ) -- cgit v1.2.3 From 0da65d5fb37691ed4d31f7ab4058732f1440db6b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 30 Mar 2007 22:40:45 -0700 Subject: s/gaim_connection/im_connection/ and some other minor API changes. The rest will come tomorrow. It compiles, I'll leave the real testing up to someone else. ;-) --- protocols/jabber/message.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'protocols/jabber/message.c') diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c index ac72f661..6c105d1d 100644 --- a/protocols/jabber/message.c +++ b/protocols/jabber/message.c @@ -25,7 +25,7 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) { - struct gaim_connection *gc = data; + struct im_connection *ic = 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" ), *c; @@ -46,7 +46,7 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) if( ( s = strchr( from, '/' ) ) ) { - if( ( bud = jabber_buddy_by_jid( gc, from, GET_BUDDY_EXACT ) ) ) + if( ( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT ) ) ) bud->last_act = time( NULL ); else *s = 0; /* We need to generate a bare JID now. */ @@ -75,7 +75,7 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) fullmsg = g_string_append( fullmsg, body->text ); if( fullmsg->len > 0 ) - serv_got_im( gc, bud ? bud->bare_jid : from, fullmsg->str, 0, 0, fullmsg->len ); + serv_got_im( ic, bud ? bud->bare_jid : from, fullmsg->str, 0, 0, fullmsg->len ); g_string_free( fullmsg, TRUE ); @@ -83,18 +83,18 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) if( xt_find_node( node->children, "composing" ) ) { bud->flags |= JBFLAG_DOES_XEP85; - serv_got_typing( gc, bud ? bud->bare_jid : from, 0, 1 ); + serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 1 ); } /* 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_XEP85; - serv_got_typing( gc, bud ? bud->bare_jid : from, 0, 0 ); + serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 0 ); } else if( xt_find_node( node->children, "paused" ) ) { bud->flags |= JBFLAG_DOES_XEP85; - serv_got_typing( gc, bud ? bud->bare_jid : from, 0, 2 ); + serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 2 ); } if( s ) -- cgit v1.2.3 From 9624fdf0d6f170d8caa7948fb1b3a138b05e1d8c Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 16 Apr 2007 21:49:17 -0700 Subject: API cleanup pretty much complete. Fixed pretty much everything except the buddy/groupchat related functions. --- protocols/jabber/message.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'protocols/jabber/message.c') diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c index 6c105d1d..19edbdfd 100644 --- a/protocols/jabber/message.c +++ b/protocols/jabber/message.c @@ -75,7 +75,7 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) fullmsg = g_string_append( fullmsg, body->text ); if( fullmsg->len > 0 ) - serv_got_im( ic, bud ? bud->bare_jid : from, fullmsg->str, 0, 0, fullmsg->len ); + imcb_buddy_msg( ic, bud ? bud->bare_jid : from, fullmsg->str, 0, 0 ); g_string_free( fullmsg, TRUE ); @@ -83,18 +83,18 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) if( xt_find_node( node->children, "composing" ) ) { bud->flags |= JBFLAG_DOES_XEP85; - serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 1 ); + imcb_buddy_typing( ic, bud ? bud->bare_jid : from, OPT_TYPING ); } /* 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_XEP85; - serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 0 ); + imcb_buddy_typing( ic, bud ? bud->bare_jid : from, 0 ); } else if( xt_find_node( node->children, "paused" ) ) { bud->flags |= JBFLAG_DOES_XEP85; - serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 2 ); + imcb_buddy_typing( ic, bud ? bud->bare_jid : from, OPT_THINKING ); } if( s ) -- cgit v1.2.3 From e35d1a121d5fb2da3698fbe4a365fe38d0097665 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 22 Apr 2007 13:44:27 -0700 Subject: Read-only support for Jabber conferences (non-anonymous rooms only). Just don't use this, you're really not going to like it. :-) --- protocols/jabber/message.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'protocols/jabber/message.c') diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c index 19edbdfd..8a4ecaf4 100644 --- a/protocols/jabber/message.c +++ b/protocols/jabber/message.c @@ -29,24 +29,29 @@ 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" ), *c; + struct jabber_buddy *bud = NULL; char *s; + if( !from ) + return XT_HANDLED; /* Consider this packet corrupted. */ + + bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT ); + if( type && strcmp( type, "error" ) == 0 ) { /* Handle type=error packet. */ } - else if( type && strcmp( type, "groupchat" ) == 0 ) + else if( type && from && strcmp( type, "groupchat" ) == 0 ) { - /* TODO! */ + jabber_chat_pkt_message( ic, bud, node ); } else /* "chat", "normal", "headline", no-type or whatever. Should all be pretty similar. */ { - struct jabber_buddy *bud = NULL; GString *fullmsg = g_string_new( "" ); if( ( s = strchr( from, '/' ) ) ) { - if( ( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT ) ) ) + if( bud ) bud->last_act = time( NULL ); else *s = 0; /* We need to generate a bare JID now. */ -- cgit v1.2.3 From 43671b964b636520a54e343542c5958b30e9f589 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 22 Apr 2007 16:39:37 -0700 Subject: You can send messages too now. But it's still very kludgy and doesn't work with anonymous rooms (ie about 95% of all available Jabber chatrooms?). --- protocols/jabber/message.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'protocols/jabber/message.c') diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c index 8a4ecaf4..198fc3b9 100644 --- a/protocols/jabber/message.c +++ b/protocols/jabber/message.c @@ -80,7 +80,8 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) fullmsg = g_string_append( fullmsg, body->text ); if( fullmsg->len > 0 ) - imcb_buddy_msg( ic, bud ? bud->bare_jid : from, fullmsg->str, 0, 0 ); + imcb_buddy_msg( ic, bud ? bud->bare_jid : from, fullmsg->str, + 0, jabber_get_timestamp( node ) ); g_string_free( fullmsg, TRUE ); -- cgit v1.2.3 From b9f8b870f7b884747b747be91ce0ac797a7c6e82 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 1 Jul 2007 17:29:21 +0100 Subject: Better handling of private messages via groupchats. --- protocols/jabber/message.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'protocols/jabber/message.c') diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c index 198fc3b9..52ee3a53 100644 --- a/protocols/jabber/message.c +++ b/protocols/jabber/message.c @@ -52,7 +52,10 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) if( ( s = strchr( from, '/' ) ) ) { if( bud ) + { bud->last_act = time( NULL ); + from = bud->ext_jid ? : bud->bare_jid; + } else *s = 0; /* We need to generate a bare JID now. */ } @@ -80,7 +83,7 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) fullmsg = g_string_append( fullmsg, body->text ); if( fullmsg->len > 0 ) - imcb_buddy_msg( ic, bud ? bud->bare_jid : from, fullmsg->str, + imcb_buddy_msg( ic, from, fullmsg->str, 0, jabber_get_timestamp( node ) ); g_string_free( fullmsg, TRUE ); @@ -89,18 +92,18 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) if( xt_find_node( node->children, "composing" ) ) { bud->flags |= JBFLAG_DOES_XEP85; - imcb_buddy_typing( ic, bud ? bud->bare_jid : from, OPT_TYPING ); + imcb_buddy_typing( ic, from, OPT_TYPING ); } /* 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_XEP85; - imcb_buddy_typing( ic, bud ? bud->bare_jid : from, 0 ); + imcb_buddy_typing( ic, from, 0 ); } else if( xt_find_node( node->children, "paused" ) ) { bud->flags |= JBFLAG_DOES_XEP85; - imcb_buddy_typing( ic, bud ? bud->bare_jid : from, OPT_THINKING ); + imcb_buddy_typing( ic, from, OPT_THINKING ); } if( s ) -- cgit v1.2.3 From 82135c7178b6379f35741991f6c06bb308143194 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 8 Aug 2007 10:20:57 +0100 Subject: Not trying to handle typing notifications from unknown buddies anymore (NULL pointer dereference). --- protocols/jabber/message.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'protocols/jabber/message.c') diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c index 52ee3a53..fab62a91 100644 --- a/protocols/jabber/message.c +++ b/protocols/jabber/message.c @@ -89,7 +89,11 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) g_string_free( fullmsg, TRUE ); /* Handling of incoming typing notifications. */ - if( xt_find_node( node->children, "composing" ) ) + if( bud == NULL ) + { + /* Can't handle these for unknown buddies. */ + } + else if( xt_find_node( node->children, "composing" ) ) { bud->flags |= JBFLAG_DOES_XEP85; imcb_buddy_typing( ic, from, OPT_TYPING ); -- cgit v1.2.3