Ticket #554: jabber-password-change.diff

File jabber-password-change.diff, 4.4 KB (added by g@…, at 2014-04-24T05:55:08Z)

submitted patch

  • protocols/account.c

    === modified file 'protocols/account.c'
     
    168168               
    169169                g_free( acc->pass );
    170170                acc->pass = g_strdup( value );
     171
     172                /* Callback protocol's set password function only if account
     173                   is online. */
     174                if( acc->ic && acc->prpl->set_password )
     175                        acc->prpl->set_password( acc->ic, value );
     176
    171177                return NULL;    /* password shouldn't be visible in plaintext! */
    172178        }
    173179        else if( strcmp( set->key, "tag" ) == 0 )
  • protocols/jabber/iq.c

    === modified file 'protocols/jabber/iq.c'
     
    931931       
    932932        return XT_HANDLED;
    933933}
     934
     935int jabber_iq_register_password( struct im_connection *ic, const char *password )
     936{
     937        struct jabber_data *jd = ic->proto_data;
     938        struct xt_node *node;
     939        int st;
     940
     941        node = xt_new_node( "query", NULL, NULL );
     942        xt_add_attr( node, "xmlns", XMLNS_REGISTER );
     943        xt_add_child( node, xt_new_node( "username", jd->username, NULL ) );
     944        xt_add_child( node, xt_new_node( "password", password, NULL ) );
     945        node = jabber_make_packet( "iq", "set", NULL, node );
     946        st = jabber_write_packet( ic, node );
     947       
     948        return st;
     949}
  • protocols/jabber/jabber.c

    === modified file 'protocols/jabber/jabber.c'
     
    5353        0
    5454};
    5555
     56static char * jabber_password_blacklist[] = {
     57        "chat.facebook.com",
     58        "talk.google.com",
     59        0
     60};
     61
    5662static void jabber_init( account_t *acc )
    5763{
    5864        set_t *s;
     
    579585        return 1;
    580586}
    581587
     588static void jabber_set_password_( void *data )
     589{
     590        struct im_connection *ic = (struct im_connection *)data;
     591        jabber_iq_register_password( ic, ic->acc->pass );
     592}
     593
     594static void jabber_ask_set_password_( struct im_connection *ic, char *pass )
     595{
     596        struct jabber_data *jd = ic->proto_data;
     597        char *buf;
     598        int i;
     599
     600        g_assert( jd->server == NULL );
     601
     602        for( i = 0; jabber_password_blacklist[i] > 0; i ++ )
     603                if( g_strcasecmp( jd->server, jabber_password_blacklist[i] ) == 0 )
     604                        return;
     605
     606        buf = g_strdup_printf( "Notify the server of the password change?" );
     607        query_add( (irc_t *) ic->bee->ui_data, ic, buf,
     608            jabber_set_password_, NULL, NULL, // callbacks
     609            ic ); // data
     610        g_free( buf );
     611}
     612
    582613void jabber_chat_add_settings( account_t *acc, set_t **head )
    583614{
    584615        /* Meh. Stupid room passwords. Not trying to obfuscate/hide
     
    652683        ret->transfer_request = jabber_si_transfer_request;
    653684        ret->buddy_action_list = jabber_buddy_action_list;
    654685        ret->buddy_action = jabber_buddy_action;
     686        ret->set_password = jabber_ask_set_password_;
    655687
    656688        register_protocol( ret );
    657689}
  • protocols/jabber/jabber.h

    === modified file 'protocols/jabber/jabber.h'
     
    221221#define XMLNS_ROSTER       "jabber:iq:roster"
    222222
    223223/* Some supported extensions/legacy stuff */
     224#define XMLNS_REGISTER     "jabber:iq:register"                                  /* XEP-0077 */
    224225#define XMLNS_AUTH         "jabber:iq:auth"                                      /* XEP-0078 */
    225226#define XMLNS_VERSION      "jabber:iq:version"                                   /* XEP-0092 */
    226227#define XMLNS_TIME_OLD     "jabber:iq:time"                                      /* XEP-0090 */
     
    256257xt_status jabber_iq_query_features( struct im_connection *ic, char *bare_jid );
    257258xt_status jabber_iq_query_server( struct im_connection *ic, char *jid, char *xmlns );
    258259void jabber_iq_version_send( struct im_connection *ic, struct jabber_buddy *bud, void *data );
     260int jabber_iq_register_password( struct im_connection *ic, const char *password );
    259261
    260262/* si.c */
    261263int jabber_si_handle_request( struct im_connection *ic, struct xt_node *node, struct xt_node *sinode );
  • protocols/nogaim.h

    === modified file 'protocols/nogaim.h'
     
    261261       
    262262        GList *(* buddy_action_list) (struct bee_user *bu);
    263263        void *(* buddy_action) (struct bee_user *bu, const char *action, char * const args[], void *data);
    264        
     264
     265        /* Implement callback if you want to perform some action when account
     266           password is changed. */
     267        void (* set_password) (struct im_connection *, char *pass);
     268
    265269        /* Some placeholders so eventually older plugins may cooperate with newer BitlBees. */
    266270        void *resv1;
    267271        void *resv2;
    268272        void *resv3;
    269273        void *resv4;
    270         void *resv5;
    271274};
    272275
    273276/* im_api core stuff. */