Changeset 4306d8b


Ignore:
Timestamp:
2007-12-02T16:43:57Z (17 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
911cc4f
Parents:
9ff5737
Message:

Removed retarded printf() (ARGH) and moved the event handling handling of
IQ packets to jabber_util so I can reuse it for certain presence packets.

Location:
protocols/jabber
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/iq.c

    r9ff5737 r4306d8b  
    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

    r9ff5737 r4306d8b  
    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
  • protocols/jabber/jabber.h

    r9ff5737 r4306d8b  
    185185void jabber_cache_entry_free( gpointer entry );
    186186void jabber_cache_clean( struct im_connection *ic );
     187xt_status jabber_cache_handle_packet( struct im_connection *ic, struct xt_node *node );
    187188const struct jabber_away_state *jabber_away_state_by_code( char *code );
    188189const struct jabber_away_state *jabber_away_state_by_name( char *name );
  • protocols/jabber/jabber_util.c

    r9ff5737 r4306d8b  
    179179                return FALSE;
    180180        }
     181}
     182
     183xt_status jabber_cache_handle_packet( struct im_connection *ic, struct xt_node *node )
     184{
     185        struct jabber_data *jd = ic->proto_data;
     186        struct jabber_cache_entry *entry;
     187        char *s;
     188       
     189        if( ( s = xt_find_attr( node, "id" ) ) == NULL ||
     190            strncmp( s, jd->cached_id_prefix, strlen( jd->cached_id_prefix ) ) != 0 )
     191        {
     192                /* Silently ignore it, without an ID (or a non-cache
     193                   ID) we don't know how to handle the packet and we
     194                   probably don't have to. */
     195                return XT_HANDLED;
     196        }
     197       
     198        entry = g_hash_table_lookup( jd->node_cache, s );
     199       
     200        if( entry == NULL )
     201        {
     202                imcb_log( ic, "WARNING: Received %s-%s packet with unknown/expired ID %s!",
     203                              node->name, xt_find_attr( node, "type" ) ? : "(no type)", s );
     204        }
     205        else if( entry->func )
     206        {
     207                return entry->func( ic, node, entry->node );
     208        }
     209       
     210        return XT_HANDLED;
    181211}
    182212
Note: See TracChangeset for help on using the changeset viewer.