Changeset 5bd21df for protocols


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.

Location:
protocols/jabber
Files:
5 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 )
  • protocols/jabber/jabber.c

    r911cc4f r5bd21df  
    270270                return jabber_write( ic, message, strlen( message ) );
    271271       
    272         if( ( s = strchr( who, '=' ) ) && jabber_chat_by_name( ic, s + 1 ) )
     272        if( ( s = strchr( who, '=' ) ) && jabber_chat_by_jid( ic, s + 1 ) )
    273273                bud = jabber_buddy_by_ext_jid( ic, who, 0 );
    274274        else
     
    397397        if( strchr( room, '@' ) == NULL )
    398398                imcb_error( ic, "Invalid room name: %s", room );
    399         else if( jabber_chat_by_name( ic, room ) )
     399        else if( jabber_chat_by_jid( ic, room ) )
    400400                imcb_error( ic, "Already present in chat `%s'", room );
    401401        else
  • protocols/jabber/jabber.h

    r911cc4f r5bd21df  
    208208int jabber_buddy_remove( struct im_connection *ic, char *full_jid );
    209209int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid );
    210 struct groupchat *jabber_chat_by_name( struct im_connection *ic, const char *name );
    211210time_t jabber_get_timestamp( struct xt_node *xt );
    212211struct jabber_error *jabber_error_parse( struct xt_node *node, char *xmlns );
     
    231230/* conference.c */
    232231struct groupchat *jabber_chat_join( struct im_connection *ic, char *room, char *nick, char *password );
     232struct groupchat *jabber_chat_by_jid( struct im_connection *ic, const char *name );
    233233void jabber_chat_free( struct groupchat *c );
    234234int jabber_chat_msg( struct groupchat *ic, char *message, int flags );
  • protocols/jabber/jabber_util.c

    r911cc4f r5bd21df  
    614614}
    615615
    616 struct groupchat *jabber_chat_by_name( struct im_connection *ic, const char *name )
    617 {
    618         char *normalized = jabber_normalize( name );
    619         struct groupchat *ret;
    620         struct jabber_chat *jc;
    621        
    622         for( ret = ic->groupchats; ret; ret = ret->next )
    623         {
    624                 jc = ret->data;
    625                 if( strcmp( normalized, jc->name ) == 0 )
    626                         break;
    627         }
    628         g_free( normalized );
    629        
    630         return ret;
    631 }
    632 
    633616time_t jabber_get_timestamp( struct xt_node *xt )
    634617{
     
    682665struct jabber_error *jabber_error_parse( struct xt_node *node, char *xmlns )
    683666{
    684         struct jabber_error *err = g_new0( struct jabber_error, 1 );
     667        struct jabber_error *err;
    685668        struct xt_node *c;
    686669        char *s;
    687670       
     671        if( node == NULL )
     672                return NULL;
     673       
     674        err = g_new0( struct jabber_error, 1 );
    688675        err->type = xt_find_attr( node, "type" );
    689676       
  • protocols/jabber/presence.c

    r911cc4f r5bd21df  
    4040        {
    4141                *s = 0;
    42                 if( jabber_chat_by_name( ic, from ) )
     42                if( jabber_chat_by_jid( ic, from ) )
    4343                        is_chat = 1;
    4444                *s = '/';
     
    164164        else if( strcmp( type, "error" ) == 0 )
    165165        {
     166                return jabber_cache_handle_packet( ic, node );
     167               
     168                /*
    166169                struct jabber_error *err;
    167                
    168170                if( ( c = xt_find_node( node->children, "error" ) ) )
    169171                {
     
    173175                                    err->text ? err->text : "" );
    174176                        jabber_error_free( err );
    175                 }
    176                 /* What else to do with it? */
     177                } */
    177178        }
    178179       
Note: See TracChangeset for help on using the changeset viewer.