source: protocols/jabber/message.c @ 3b3cd693

Last change on this file since 3b3cd693 was 788a1af, checked in by Wilmer van der Gaast <wilmer@…>, at 2006-10-15T20:24:01Z

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.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/***************************************************************************\
2*                                                                           *
3*  BitlBee - An IRC to IM gateway                                           *
4*  Jabber module - Handling of message(s) (tags), etc                       *
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
26xt_status jabber_pkt_message( struct xt_node *node, gpointer data )
27{
28        struct gaim_connection *gc = data;
29        char *from = xt_find_attr( node, "from" );
30        char *type = xt_find_attr( node, "type" );
31        struct xt_node *body = xt_find_node( node->children, "body" );
32        char *s;
33       
34        if( !type )
35                return XT_HANDLED;      /* Grmbl... FIXME */
36       
37        if( strcmp( type, "chat" ) == 0 )
38        {
39                struct jabber_buddy *bud = NULL;
40               
41                if( ( s = strchr( from, '/' ) ) == NULL )
42                {
43                        /* It just shouldn't happen. */
44                        hide_login_progress( gc, "Received message packet from bare JID" );
45                        signoff( gc );
46                        return XT_ABORT;
47                }
48               
49                if( ( bud = jabber_buddy_by_jid( gc, from ) ) )
50                        bud->last_act = time( NULL );
51                else
52                        *s = 0; /* We need to generate a bare JID now. */
53               
54                if( body ) /* Could be just a typing notification. */
55                        serv_got_im( gc, bud ? bud->handle : from, body->text, 0, 0, 0 );
56               
57                /* Handling of incoming typing notifications. */
58                if( xt_find_node( node->children, "composing" ) )
59                {
60                        bud->flags |= JBFLAG_DOES_XEP85;
61                        serv_got_typing( gc, bud ? bud->handle : from, 0, 1 );
62                }
63                /* No need to send a "stopped typing" signal when there's a message. */
64                else if( xt_find_node( node->children, "active" ) && ( body == NULL ) )
65                {
66                        bud->flags |= JBFLAG_DOES_XEP85;
67                        serv_got_typing( gc, bud ? bud->handle : from, 0, 0 );
68                }
69                else if( xt_find_node( node->children, "paused" ) )
70                {
71                        bud->flags |= JBFLAG_DOES_XEP85;
72                        serv_got_typing( gc, bud ? bud->handle : from, 0, 2 );
73                }
74               
75                if( s )
76                        *s = '/'; /* And convert it back to a full JID. */
77        }
78        else
79        {
80                printf( "Received MSG from %s:\n", from );
81                xt_print( node );
82        }
83       
84        return XT_HANDLED;
85}
Note: See TracBrowser for help on using the repository browser.