[f06894d] | 1 | /***************************************************************************\ |
---|
| 2 | * * |
---|
| 3 | * BitlBee - An IRC to IM gateway * |
---|
[21167d2] | 4 | * Jabber module - Handling of message(s) (tags), etc * |
---|
[f06894d] | 5 | * * |
---|
| 6 | * Copyright 2006 Wilmer van der Gaast <wilmer@gaast.net> * |
---|
| 7 | * * |
---|
| 8 | * This program is free software; you can redistribute it and/or modify * |
---|
| 9 | * it under the terms of the GNU General Public License as published by * |
---|
| 10 | * the Free Software Foundation; either version 2 of the License, or * |
---|
| 11 | * (at your option) any later version. * |
---|
| 12 | * * |
---|
| 13 | * This program is distributed in the hope that it will be useful, * |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
---|
| 16 | * GNU General Public License for more details. * |
---|
| 17 | * * |
---|
| 18 | * You should have received a copy of the GNU General Public License along * |
---|
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., * |
---|
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * |
---|
| 21 | * * |
---|
| 22 | \***************************************************************************/ |
---|
| 23 | |
---|
| 24 | #include "jabber.h" |
---|
| 25 | |
---|
| 26 | xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) |
---|
| 27 | { |
---|
[dd788bb] | 28 | struct gaim_connection *gc = data; |
---|
[f06894d] | 29 | char *from = xt_find_attr( node, "from" ); |
---|
[dd788bb] | 30 | char *type = xt_find_attr( node, "type" ); |
---|
[a21a8ac] | 31 | struct xt_node *body = xt_find_node( node->children, "body" ); |
---|
[f06894d] | 32 | |
---|
[a21a8ac] | 33 | if( !type ) |
---|
[dd788bb] | 34 | return XT_HANDLED; /* Grmbl... FIXME */ |
---|
| 35 | |
---|
| 36 | if( strcmp( type, "chat" ) == 0 ) |
---|
| 37 | { |
---|
[a21a8ac] | 38 | struct jabber_buddy *bud = NULL; |
---|
[dd788bb] | 39 | |
---|
[a21a8ac] | 40 | if( strchr( from, '/' ) == NULL ) |
---|
| 41 | { |
---|
| 42 | /* It just shouldn't happen. */ |
---|
| 43 | hide_login_progress( gc, "Received message packet from bare JID" ); |
---|
| 44 | signoff( gc ); |
---|
| 45 | return XT_ABORT; |
---|
| 46 | } |
---|
[dd788bb] | 47 | |
---|
[a21a8ac] | 48 | bud = jabber_buddy_by_jid( gc, from ); |
---|
| 49 | bud->last_act = time( NULL ); |
---|
[dd788bb] | 50 | |
---|
[a21a8ac] | 51 | if( body ) /* Could be just a typing notification. */ |
---|
| 52 | serv_got_im( gc, bud->handle, body->text, 0, 0, 0 ); |
---|
| 53 | |
---|
| 54 | if( xt_find_node( node->children, "composing" ) ) |
---|
| 55 | { |
---|
| 56 | bud->flags |= JBFLAG_DOES_JEP85; |
---|
| 57 | serv_got_typing( gc, bud->handle, 0, 1 ); |
---|
| 58 | } |
---|
| 59 | else if( xt_find_node( node->children, "active" ) ) |
---|
| 60 | { |
---|
| 61 | bud->flags |= JBFLAG_DOES_JEP85; |
---|
| 62 | } |
---|
[dd788bb] | 63 | } |
---|
| 64 | else |
---|
| 65 | { |
---|
[a21a8ac] | 66 | printf( "Received MSG from %s:\n", from ); |
---|
[dd788bb] | 67 | xt_print( node ); |
---|
| 68 | } |
---|
[f06894d] | 69 | |
---|
| 70 | return XT_HANDLED; |
---|
| 71 | } |
---|
| 72 | |
---|