Ignore:
Timestamp:
2007-12-02T17:25:57Z (16 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
fc5d06d
Parents:
911cc4f
Message:

Handling of presence-error packets (only useful for groupchats now), moved
jabber_chat_by_jid() (with the right name) to conference.c, I don't know
what it was doing in jabber_util.c.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/conference.c

    r911cc4f r5bd21df  
    2424#include "jabber.h"
    2525
     26static xt_status jabber_chat_join_failed( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );
     27
    2628struct groupchat *jabber_chat_join( struct im_connection *ic, char *room, char *nick, char *password )
    2729{
     
    3537        xt_add_attr( node, "xmlns", XMLNS_MUC );
    3638        node = jabber_make_packet( "presence", NULL, roomjid, node );
     39        jabber_cache_add( ic, node, jabber_chat_join_failed );
    3740       
    3841        if( !jabber_write_packet( ic, node ) )
    3942        {
    4043                g_free( roomjid );
    41                 xt_free_node( node );
    4244                return NULL;
    4345        }
    44         xt_free_node( node );
    4546       
    4647        jc = g_new0( struct jabber_chat, 1 );
     
    6364       
    6465        return c;
     66}
     67
     68static xt_status jabber_chat_join_failed( struct im_connection *ic, struct xt_node *node, struct xt_node *orig )
     69{
     70        struct jabber_error *err;
     71        struct jabber_buddy *bud;
     72        char *room;
     73       
     74        room = xt_find_attr( orig, "to" );
     75        bud = jabber_buddy_by_jid( ic, room, 0 );
     76       
     77        err = jabber_error_parse( xt_find_node( node->children, "error" ), XMLNS_STANZA_ERROR );
     78        if( err )
     79        {
     80                imcb_error( ic, "Error joining groupchat %s: %s%s%s",
     81                            bud->bare_jid, err->code, err->text ? ": " : "",
     82                            err->text ? err->text : "" );
     83                jabber_error_free( err );
     84        }
     85       
     86        if( bud )
     87                jabber_chat_free( jabber_chat_by_jid( ic, bud->bare_jid ) );
     88}
     89
     90struct groupchat *jabber_chat_by_jid( struct im_connection *ic, const char *name )
     91{
     92        char *normalized = jabber_normalize( name );
     93        struct groupchat *ret;
     94        struct jabber_chat *jc;
     95       
     96        for( ret = ic->groupchats; ret; ret = ret->next )
     97        {
     98                jc = ret->data;
     99                if( strcmp( normalized, jc->name ) == 0 )
     100                        break;
     101        }
     102        g_free( normalized );
     103       
     104        return ret;
    65105}
    66106
     
    148188        char *s;
    149189       
    150         if( ( chat = jabber_chat_by_name( ic, bud->bare_jid ) ) == NULL )
     190        if( ( chat = jabber_chat_by_jid( ic, bud->bare_jid ) ) == NULL )
    151191        {
    152192                /* How could this happen?? We could do kill( self, 11 )
     
    250290                return;
    251291        }
    252         else if( ( chat = jabber_chat_by_name( ic, bud->bare_jid ) ) == NULL )
     292        else if( ( chat = jabber_chat_by_jid( ic, bud->bare_jid ) ) == NULL )
    253293        {
    254294                /* How could this happen?? We could do kill( self, 11 )
Note: See TracChangeset for help on using the changeset viewer.