Changeset be1efa3


Ignore:
Timestamp:
2015-01-26T02:43:34Z (10 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
fcb2c2e
Parents:
8519f45
git-author:
dequis <dx@…> (20-07-14 06:28:49)
git-committer:
dequis <dx@…> (26-01-15 02:43:34)
Message:

Add handle_is_self() prpl function to fix JID mismatch confusion bugs

When bee_chat needs to check for self messages, it can call this
function to let the protocol implementation do the comparison.

In the case of jabber, sometimes the server reports a different username
after login, this one is stored in jd->internal_jid, and the one that is
used for login isn't changed

Location:
protocols
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • protocols/bee_chat.c

    r8519f45 rbe1efa3  
    8080}
    8181
     82static gboolean handle_is_self( struct im_connection *ic, const char *handle )
     83{
     84        return ( ic->acc->prpl->handle_is_self ) ?
     85                 ic->acc->prpl->handle_is_self( ic, handle ) :
     86                 ( ic->acc->prpl->handle_cmp( ic->acc->user, handle ) == 0 );
     87}
     88
    8289void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t flags, time_t sent_at )
    8390{
     
    8996       
    9097        /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */
    91         if( g_strcasecmp( who, ic->acc->user ) == 0 )
     98        if( handle_is_self( ic, who ) )
    9299                return;
    93100       
     
    139146        if( who == NULL)
    140147                bu = NULL;
    141         else if( g_strcasecmp( who, ic->acc->user ) == 0 )
     148        else if( handle_is_self( ic, who ) )
    142149                bu = bee->user;
    143150        else
     
    161168                imcb_log( c->ic, "User %s added to conversation %p", handle, c );
    162169       
    163         me = ic->acc->prpl->handle_cmp( handle, ic->acc->user ) == 0;
     170        me = handle_is_self( ic, handle );
    164171       
    165172        /* Most protocols allow people to join, even when they're not in
     
    189196       
    190197        /* It might be yourself! */
    191         if( g_strcasecmp( handle, ic->acc->user ) == 0 )
     198        if( handle_is_self( ic, handle ) )
    192199        {
    193200                if( c->joined == 0 )
  • protocols/jabber/iq.c

    r8519f45 rbe1efa3  
    358358                                *s = '\0';
    359359                        jabber_set_me( ic, c->text );
    360                         imcb_log( ic, "Server claims your JID is `%s' instead of `%s'. "
    361                                   "This mismatch may cause problems with groupchats "
    362                                   "and possibly other things.",
    363                                   c->text, ic->acc->user );
    364360                        if( s )
    365361                                *s = '/';
  • protocols/jabber/jabber.c

    r8519f45 rbe1efa3  
    318318        g_free( jd->oauth2_access_token );
    319319        g_free( jd->away_message );
     320        g_free( jd->internal_jid );
    320321        g_free( jd->username );
    321322        g_free( jd->me );
     
    619620       
    620621        return NULL;
     622}
     623
     624gboolean jabber_handle_is_self( struct im_connection *ic, const char *who ) {
     625        struct jabber_data *jd = ic->proto_data;
     626        return ( ( g_strcasecmp( who, ic->acc->user ) == 0 ) ||
     627                 ( jd->internal_jid &&
     628                   g_strcasecmp( who, jd->internal_jid ) == 0 ) );
    621629}
    622630
     
    648656        ret->send_typing = jabber_send_typing;
    649657        ret->handle_cmp = g_strcasecmp;
     658        ret->handle_is_self = jabber_handle_is_self;
    650659        ret->transfer_request = jabber_si_transfer_request;
    651660        ret->buddy_action_list = jabber_buddy_action_list;
  • protocols/jabber/jabber.h

    r8519f45 rbe1efa3  
    9797        char *server;           /* username@SERVER -=> server/domain, not hostname */
    9898        char *me;               /* bare jid */
     99        char *internal_jid;
    99100       
    100101        const struct oauth2_service *oauth2_service;
  • protocols/jabber/jabber_util.c

    r8519f45 rbe1efa3  
    824824        jd->username = g_strndup( jd->me, jd->server - jd->me );
    825825        jd->server ++;
     826
     827        /* Set the "internal" account username, for groupchats */
     828        g_free( jd->internal_jid );
     829        jd->internal_jid = g_strdup( jd->me );
    826830       
    827831        return TRUE;
  • protocols/nogaim.h

    r8519f45 rbe1efa3  
    263263        void *(* buddy_action) (struct bee_user *bu, const char *action, char * const args[], void *data);
    264264       
     265        /* If null, equivalent to handle_cmp( ic->acc->user, who ) */
     266        gboolean (* handle_is_self) (struct im_connection *, const char *who);
     267
    265268        /* Some placeholders so eventually older plugins may cooperate with newer BitlBees. */
    266269        void *resv1;
Note: See TracChangeset for help on using the changeset viewer.