Changeset bb2d198 for protocols


Ignore:
Timestamp:
2012-02-10T15:14:38Z (13 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
fc0640e
Parents:
e0a0a42
Message:

Probing for Google Talk servers, based on iq-discovery responses. I'll need
this for automatically generating a sane name for groupchats.

Location:
protocols/jabber
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/iq.c

    re0a0a42 rbb2d198  
    2727static xt_status jabber_parse_roster( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );
    2828static xt_status jabber_iq_display_vcard( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );
     29static int jabber_iq_disco_server( struct im_connection *ic );
    2930
    3031xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )
     
    330331                if( !jabber_get_roster( ic ) )
    331332                        return XT_ABORT;
     333                if( !jabber_iq_disco_server( ic ) )
     334                        return XT_ABORT;
    332335        }
    333336       
     
    390393        {
    391394                if( !jabber_get_roster( ic ) )
     395                        return XT_ABORT;
     396                if( !jabber_iq_disco_server( ic ) )
    392397                        return XT_ABORT;
    393398        }
     
    887892        return XT_HANDLED;
    888893}
     894
     895static xt_status jabber_iq_disco_server_response( struct im_connection *ic,
     896        struct xt_node *node, struct xt_node *orig );
     897
     898static int jabber_iq_disco_server( struct im_connection *ic )
     899{
     900        struct xt_node *node, *iq;
     901        struct jabber_data *jd = ic->proto_data;
     902       
     903        node = xt_new_node( "query", NULL, NULL );
     904        xt_add_attr( node, "xmlns", XMLNS_DISCO_INFO );
     905        iq = jabber_make_packet( "iq", "get", jd->server, node );
     906       
     907        jabber_cache_add( ic, iq, jabber_iq_disco_server_response );
     908        return jabber_write_packet( ic, iq );
     909}
     910
     911static xt_status jabber_iq_disco_server_response( struct im_connection *ic,
     912        struct xt_node *node, struct xt_node *orig )
     913{
     914        struct jabber_data *jd = ic->proto_data;
     915        struct xt_node *id;
     916       
     917        if( ( id = xt_find_path( node, "query/identity" ) ) )
     918        {
     919                char *cat, *type, *name;
     920               
     921                if( !( cat = xt_find_attr( id, "category" ) ) ||
     922                    !( type = xt_find_attr( id, "type" ) ) ||
     923                    !( name = xt_find_attr( id, "name" ) ) )
     924                        return XT_HANDLED;
     925               
     926                if( strcmp( cat, "server" ) == 0 && strcmp( type, "im" ) == 0 &&
     927                    strstr( name, "Google" ) != NULL )
     928                        jd->flags |= JFLAG_GTALK;
     929        }
     930       
     931        return XT_HANDLED;
     932}
  • protocols/jabber/jabber.h

    re0a0a42 rbb2d198  
    4747        JFLAG_XMLCONSOLE = 64,          /* If the user added an xmlconsole buddy. */
    4848        JFLAG_STARTTLS_DONE = 128,      /* If a plaintext session was converted to TLS. */
    49        
     49
     50        JFLAG_GTALK =  0x100000,        /* Is Google Talk, as confirmed by iq discovery */
     51
    5052        JFLAG_SASL_FB = 0x10000,        /* Trying Facebook authentication. */
    5153} jabber_flags_t;
Note: See TracChangeset for help on using the changeset viewer.