Changeset 08135df for protocols


Ignore:
Timestamp:
2007-12-04T01:08:43Z (17 years ago)
Author:
ulim <a.sporto+bee@…>
Branches:
master
Children:
793cc25
Parents:
fa30fa5 (diff), aaf92a9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merged in current devel

Wilmer van der Gaast 2007-12-02 Imported setuid() patch from Simo Leone <simo@archlinux...> with some

Wilmer van der Gaast 2007-12-02 Forgot to return something in jabber_chat_join_failed().
Wilmer van der Gaast 2007-12-02 Merging a change I should've pulled before committing three other changes.
Wilmer van der Gaast 2007-12-02 Added charset checks on incoming msgs (from the IRC side) to prevent possible
Wilmer van der Gaast 2007-12-02 Handling of presence-error packets (only useful for groupchats now), moved
Wilmer van der Gaast 2007-12-02 Defining DEBUG via CFLAGS so that it'll always be there, even when a file
Wilmer van der Gaast 2007-12-02 Removed retarded printf() (ARGH) and moved the event handling handling of
Wilmer van der Gaast 2007-11-29 printf() in daemons considered harmful.
Wilmer van der Gaast 2007-11-28 Fixed the epoll+ForkDaemon combination. The libevent event handling

Location:
protocols
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/conference.c

    rfa30fa5 r08135df  
    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        if( ( bud = jabber_buddy_by_jid( ic, room, 0 ) ) )
     76                jabber_chat_free( jabber_chat_by_jid( ic, bud->bare_jid ) );
     77       
     78        err = jabber_error_parse( xt_find_node( node->children, "error" ), XMLNS_STANZA_ERROR );
     79        if( err )
     80        {
     81                imcb_error( ic, "Error joining groupchat %s: %s%s%s",
     82                            bud->bare_jid, err->code, err->text ? ": " : "",
     83                            err->text ? err->text : "" );
     84                jabber_error_free( err );
     85        }
     86       
     87        return XT_HANDLED;
     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/iq.c

    rfa30fa5 r08135df  
    3131{
    3232        struct im_connection *ic = data;
    33         struct jabber_data *jd = ic->proto_data;
    3433        struct xt_node *c, *reply = NULL;
    3534        char *type, *s;
     
    4746        if( strcmp( type, "result" ) == 0 || strcmp( type, "error" ) == 0 )
    4847        {
    49                 struct jabber_cache_entry *entry;
    50                
    51                 if( ( s = xt_find_attr( node, "id" ) ) == NULL ||
    52                     strncmp( s, jd->cached_id_prefix, strlen( jd->cached_id_prefix ) ) != 0 )
    53                 {
    54                         /* Silently ignore it, without an ID (or a non-cache
    55                            ID) we don't know how to handle the packet and we
    56                            probably don't have to. */
    57                         return XT_HANDLED;
    58                 }
    59                
    60                 entry = g_hash_table_lookup( jd->node_cache, s );
    61                
    62                 if( entry == NULL )
    63                         imcb_log( ic, "WARNING: Received IQ-%s packet with unknown/expired ID %s!", type, s );
    64                 else if( entry->func )
    65                         return entry->func( ic, node, entry->node );
     48                return jabber_cache_handle_packet( ic, node );
    6649        }
    6750        else if( strcmp( type, "get" ) == 0 )
  • protocols/jabber/jabber.c

    rfa30fa5 r08135df  
    226226        jd->cached_id_prefix = g_strdup_printf( "%s%s", JABBER_CACHED_ID, s );
    227227        g_free( s );
    228        
    229         printf( "%s\n", jd->cached_id_prefix );
    230228}
    231229
     
    272270                return jabber_write( ic, message, strlen( message ) );
    273271       
    274         if( ( s = strchr( who, '=' ) ) && jabber_chat_by_name( ic, s + 1 ) )
     272        if( ( s = strchr( who, '=' ) ) && jabber_chat_by_jid( ic, s + 1 ) )
    275273                bud = jabber_buddy_by_ext_jid( ic, who, 0 );
    276274        else
     
    399397        if( strchr( room, '@' ) == NULL )
    400398                imcb_error( ic, "Invalid room name: %s", room );
    401         else if( jabber_chat_by_name( ic, room ) )
     399        else if( jabber_chat_by_jid( ic, room ) )
    402400                imcb_error( ic, "Already present in chat `%s'", room );
    403401        else
  • protocols/jabber/jabber.h

    rfa30fa5 r08135df  
    227227void jabber_cache_entry_free( gpointer entry );
    228228void jabber_cache_clean( struct im_connection *ic );
     229xt_status jabber_cache_handle_packet( struct im_connection *ic, struct xt_node *node );
    229230const struct jabber_away_state *jabber_away_state_by_code( char *code );
    230231const struct jabber_away_state *jabber_away_state_by_name( char *name );
     
    249250int jabber_buddy_remove( struct im_connection *ic, char *full_jid );
    250251int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid );
    251 struct groupchat *jabber_chat_by_name( struct im_connection *ic, const char *name );
    252252time_t jabber_get_timestamp( struct xt_node *xt );
    253253struct jabber_error *jabber_error_parse( struct xt_node *node, char *xmlns );
     
    272272/* conference.c */
    273273struct groupchat *jabber_chat_join( struct im_connection *ic, char *room, char *nick, char *password );
     274struct groupchat *jabber_chat_by_jid( struct im_connection *ic, const char *name );
    274275void jabber_chat_free( struct groupchat *c );
    275276int jabber_chat_msg( struct groupchat *ic, char *message, int flags );
  • protocols/jabber/jabber_util.c

    rfa30fa5 r08135df  
    183183                return FALSE;
    184184        }
     185}
     186
     187xt_status jabber_cache_handle_packet( struct im_connection *ic, struct xt_node *node )
     188{
     189        struct jabber_data *jd = ic->proto_data;
     190        struct jabber_cache_entry *entry;
     191        char *s;
     192       
     193        if( ( s = xt_find_attr( node, "id" ) ) == NULL ||
     194            strncmp( s, jd->cached_id_prefix, strlen( jd->cached_id_prefix ) ) != 0 )
     195        {
     196                /* Silently ignore it, without an ID (or a non-cache
     197                   ID) we don't know how to handle the packet and we
     198                   probably don't have to. */
     199                return XT_HANDLED;
     200        }
     201       
     202        entry = g_hash_table_lookup( jd->node_cache, s );
     203       
     204        if( entry == NULL )
     205        {
     206                imcb_log( ic, "WARNING: Received %s-%s packet with unknown/expired ID %s!",
     207                              node->name, xt_find_attr( node, "type" ) ? : "(no type)", s );
     208        }
     209        else if( entry->func )
     210        {
     211                return entry->func( ic, node, entry->node );
     212        }
     213       
     214        return XT_HANDLED;
    185215}
    186216
     
    595625}
    596626
    597 struct groupchat *jabber_chat_by_name( struct im_connection *ic, const char *name )
    598 {
    599         char *normalized = jabber_normalize( name );
    600         struct groupchat *ret;
    601         struct jabber_chat *jc;
    602        
    603         for( ret = ic->groupchats; ret; ret = ret->next )
    604         {
    605                 jc = ret->data;
    606                 if( strcmp( normalized, jc->name ) == 0 )
    607                         break;
    608         }
    609         g_free( normalized );
    610        
    611         return ret;
    612 }
    613 
    614627time_t jabber_get_timestamp( struct xt_node *xt )
    615628{
     
    663676struct jabber_error *jabber_error_parse( struct xt_node *node, char *xmlns )
    664677{
    665         struct jabber_error *err = g_new0( struct jabber_error, 1 );
     678        struct jabber_error *err;
    666679        struct xt_node *c;
    667680        char *s;
    668681       
     682        if( node == NULL )
     683                return NULL;
     684       
     685        err = g_new0( struct jabber_error, 1 );
    669686        err->type = xt_find_attr( node, "type" );
    670687       
  • protocols/jabber/presence.c

    rfa30fa5 r08135df  
    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       
  • protocols/oscar/msgcookie.c

    rfa30fa5 r08135df  
    131131}
    132132
    133 #if 0 /* debugging feature */
    134 int aim_dumpcookie(aim_msgcookie_t *cookie)
    135 {
    136 
    137         if (!cookie)
    138                 return -EINVAL;
    139 
    140         printf("\tCookie at %p: %d/%s with %p, next %p\n",
    141                         cookie, cookie->type, cookie->cookie,
    142                         cookie->data, cookie->next);
    143 
    144         return 0;
    145 }
    146 #endif
    147 
    148133/**
    149134 * aim_cookie_free - free an aim_msgcookie_t struct
Note: See TracChangeset for help on using the changeset viewer.