Changeset 68286eb for protocols


Ignore:
Timestamp:
2011-12-20T16:45:53Z (12 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
e14b47b8
Parents:
f9789d4
Message:

Detect JID changes at login time and warn the user about them.

Location:
protocols/jabber
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/conference.c

    rf9789d4 r68286eb  
    211211        struct xt_node *c;
    212212        char *type = xt_find_attr( node, "type" );
     213        struct jabber_data *jd = ic->proto_data;
    213214        struct jabber_chat *jc;
    214215        char *s;
     
    252253                        if( bud == jc->me )
    253254                        {
    254                                 bud->ext_jid = jabber_normalize( ic->acc->user );
     255                                bud->ext_jid = g_strdup( jd->me );
    255256                        }
    256257                        else
  • protocols/jabber/iq.c

    rf9789d4 r68286eb  
    3131{
    3232        struct im_connection *ic = data;
     33        struct jabber_data *jd = ic->proto_data;
    3334        struct xt_node *c, *reply = NULL;
    3435        char *type, *s;
     
    170171                   was added to (or removed from) the buddy list. AFAIK they're
    171172                   sent even if we added this buddy in our own session. */
    172                         int bare_len = strlen( ic->acc->user );
     173                        int bare_len = strlen( jd->me );
    173174                       
    174175                        if( ( s = xt_find_attr( node, "from" ) ) == NULL ||
    175                             ( strncmp( s, ic->acc->user, bare_len ) == 0 &&
     176                            ( strncmp( s, jd->me, bare_len ) == 0 &&
    176177                              ( s[bare_len] == 0 || s[bare_len] == '/' ) ) )
    177178                        {
     
    343344        {
    344345                c = xt_find_node( c->children, "jid" );
    345                 if( c && c->text_len && ( s = strchr( c->text, '/' ) ) &&
    346                     strcmp( s + 1, set_getstr( &ic->acc->set, "resource" ) ) != 0 )
     346                if( !c || !c->text )
     347                {
     348                        /* Server is crap, but this is no disaster. */
     349                }
     350                else if( strncmp( jd->me, c->text, strlen( jd->me ) ) != 0 )
     351                {
     352                        s = strchr( c->text, '/' );
     353                        if( s )
     354                                *s = '\0';
     355                        jabber_set_me( ic, c->text );
     356                        imcb_log( ic, "Server claims your JID is `%s' instead of `%s'. "
     357                                  "This mismatch may cause problems with groupchats "
     358                                  "and possibly other things.",
     359                                  c->text, ic->acc->user );
     360                        if( s )
     361                                *s = '/';
     362                }
     363                else if( c && c->text_len && ( s = strchr( c->text, '/' ) ) &&
     364                         strcmp( s + 1, set_getstr( &ic->acc->set, "resource" ) ) != 0 )
    347365                        imcb_log( ic, "Server changed session resource string to `%s'", s + 1 );
    348366        }
  • protocols/jabber/jabber.c

    rf9789d4 r68286eb  
    111111        ic->proto_data = jd;
    112112       
    113         jd->username = g_strdup( acc->user );
    114         jd->server = strchr( jd->username, '@' );
     113        jabber_set_me( ic, acc->user );
    115114       
    116115        jd->fd = jd->r_inpa = jd->w_inpa = -1;
     
    122121                return;
    123122        }
    124        
    125         /* So don't think of free()ing jd->server.. :-) */
    126         *jd->server = 0;
    127         jd->server ++;
    128123       
    129124        if( ( s = strchr( jd->server, '/' ) ) )
     
    314309        g_free( jd->away_message );
    315310        g_free( jd->username );
     311        g_free( jd->me );
    316312        g_free( jd );
    317313       
     
    495491static void jabber_chat_invite_( struct groupchat *c, char *who, char *msg )
    496492{
     493        struct jabber_data *jd = c->ic->proto_data;
    497494        struct jabber_chat *jc = c->data;
    498495        gchar *msg_alt = NULL;
    499496
    500497        if( msg == NULL )
    501                 msg_alt = g_strdup_printf( "%s invited you to %s", c->ic->acc->user, jc->name );
     498                msg_alt = g_strdup_printf( "%s invited you to %s", jd->me, jc->name );
    502499       
    503500        if( c && who )
  • protocols/jabber/jabber.h

    rf9789d4 r68286eb  
    9494        char *username;         /* USERNAME@server */
    9595        char *server;           /* username@SERVER -=> server/domain, not hostname */
     96        char *me;               /* bare jid */
    9697       
    9798        const struct oauth2_service *oauth2_service;
     
    308309struct jabber_error *jabber_error_parse( struct xt_node *node, char *xmlns );
    309310void jabber_error_free( struct jabber_error *err );
     311gboolean jabber_set_me( struct im_connection *ic, const char *me );
    310312
    311313extern const struct jabber_away_state jabber_away_state_list[];
  • protocols/jabber/jabber_util.c

    rf9789d4 r68286eb  
    761761        g_free( err );
    762762}
     763
     764gboolean jabber_set_me( struct im_connection *ic, const char *me )
     765{
     766        struct jabber_data *jd = ic->proto_data;
     767       
     768        if( strchr( me, '@' ) == NULL )
     769                return FALSE;
     770       
     771        g_free( jd->username );
     772        g_free( jd->me );
     773       
     774        jd->me = jabber_normalize( me );
     775        jd->server = strchr( jd->me, '@' );
     776        jd->username = g_strndup( jd->me, jd->server - jd->me );
     777        jd->server ++;
     778       
     779        return TRUE;
     780}
Note: See TracChangeset for help on using the changeset viewer.