Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/message.c

    r9624fdf r82135c7  
    3030        char *type = xt_find_attr( node, "type" );
    3131        struct xt_node *body = xt_find_node( node->children, "body" ), *c;
     32        struct jabber_buddy *bud = NULL;
    3233        char *s;
     34       
     35        if( !from )
     36                return XT_HANDLED; /* Consider this packet corrupted. */
     37       
     38        bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT );
    3339       
    3440        if( type && strcmp( type, "error" ) == 0 )
     
    3642                /* Handle type=error packet. */
    3743        }
    38         else if( type && strcmp( type, "groupchat" ) == 0 )
     44        else if( type && from && strcmp( type, "groupchat" ) == 0 )
    3945        {
    40                 /* TODO! */
     46                jabber_chat_pkt_message( ic, bud, node );
    4147        }
    4248        else /* "chat", "normal", "headline", no-type or whatever. Should all be pretty similar. */
    4349        {
    44                 struct jabber_buddy *bud = NULL;
    4550                GString *fullmsg = g_string_new( "" );
    4651               
    4752                if( ( s = strchr( from, '/' ) ) )
    4853                {
    49                         if( ( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT ) ) )
     54                        if( bud )
     55                        {
    5056                                bud->last_act = time( NULL );
     57                                from = bud->ext_jid ? : bud->bare_jid;
     58                        }
    5159                        else
    5260                                *s = 0; /* We need to generate a bare JID now. */
     
    7684               
    7785                if( fullmsg->len > 0 )
    78                         imcb_buddy_msg( ic, bud ? bud->bare_jid : from, fullmsg->str, 0, 0 );
     86                        imcb_buddy_msg( ic, from, fullmsg->str,
     87                                        0, jabber_get_timestamp( node ) );
    7988               
    8089                g_string_free( fullmsg, TRUE );
    8190               
    8291                /* Handling of incoming typing notifications. */
    83                 if( xt_find_node( node->children, "composing" ) )
     92                if( bud == NULL )
     93                {
     94                        /* Can't handle these for unknown buddies. */
     95                }
     96                else if( xt_find_node( node->children, "composing" ) )
    8497                {
    8598                        bud->flags |= JBFLAG_DOES_XEP85;
    86                         imcb_buddy_typing( ic, bud ? bud->bare_jid : from, OPT_TYPING );
     99                        imcb_buddy_typing( ic, from, OPT_TYPING );
    87100                }
    88101                /* No need to send a "stopped typing" signal when there's a message. */
     
    90103                {
    91104                        bud->flags |= JBFLAG_DOES_XEP85;
    92                         imcb_buddy_typing( ic, bud ? bud->bare_jid : from, 0 );
     105                        imcb_buddy_typing( ic, from, 0 );
    93106                }
    94107                else if( xt_find_node( node->children, "paused" ) )
    95108                {
    96109                        bud->flags |= JBFLAG_DOES_XEP85;
    97                         imcb_buddy_typing( ic, bud ? bud->bare_jid : from, OPT_THINKING );
     110                        imcb_buddy_typing( ic, from, OPT_THINKING );
    98111                }
    99112               
Note: See TracChangeset for help on using the changeset viewer.