Changeset b9f8b87 for protocols


Ignore:
Timestamp:
2007-07-01T16:29:21Z (17 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
9c9b37c
Parents:
2758cfe
Message:

Better handling of private messages via groupchats.

Location:
protocols/jabber
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/conference.c

    r2758cfe rb9f8b87  
    128128                   Slightly hackish way of finding out eh? ;-) */
    129129               
    130                 /* This is pretty messy... */
     130                /* This is pretty messy... Here it sets ext_jid to the real
     131                   JID of the participant. Works for non-anonymized channels.
     132                   Might break if someone joins a chat twice, though. */
    131133                for( c = node->children; ( c = xt_find_node( c, "x" ) ); c = c->next )
    132134                        if( ( s = xt_find_attr( c, "xmlns" ) ) &&
     
    137139                                {
    138140                                        /* Yay, found what we need. :-) */
    139                                         bud->ext_jid = g_strdup( s );
     141                                        bud->ext_jid = jabber_normalize( s );
    140142                                        break;
    141143                                }
     
    146148                {
    147149                        if( bud == jc->me )
    148                                 bud->ext_jid = g_strdup( ic->acc->user );
     150                                bud->ext_jid = jabber_normalize( ic->acc->user );
    149151                        else
    150152                                /* Don't want the nick to be at the end, so let's
  • protocols/jabber/jabber.c

    r2758cfe rb9f8b87  
    224224        struct jabber_buddy *bud;
    225225        struct xt_node *node;
     226        char *s;
    226227        int st;
    227228       
     
    229230                return jabber_write( ic, message, strlen( message ) );
    230231       
    231         bud = jabber_buddy_by_jid( ic, who, 0 );
     232        if( ( s = strchr( who, '=' ) ) && jabber_chat_by_name( ic, s + 1 ) )
     233                bud = jabber_buddy_by_ext_jid( ic, who, 0 );
     234        else
     235                bud = jabber_buddy_by_jid( ic, who, 0 );
    232236       
    233237        node = xt_new_node( "body", message, NULL );
  • protocols/jabber/jabber.h

    r2758cfe rb9f8b87  
    195195struct jabber_buddy *jabber_buddy_add( struct im_connection *ic, char *full_jid );
    196196struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid, get_buddy_flags_t flags );
     197struct jabber_buddy *jabber_buddy_by_ext_jid( struct im_connection *ic, char *jid, get_buddy_flags_t flags );
    197198int jabber_buddy_remove( struct im_connection *ic, char *full_jid );
    198199int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid );
  • protocols/jabber/jabber_util.c

    r2758cfe rb9f8b87  
    320320        else
    321321        {
     322                /* Keep in mind that full_jid currently isn't really
     323                   a full JID... */
    322324                new->bare_jid = g_strdup( full_jid );
    323325                g_hash_table_insert( jd->buddies, new->bare_jid, new );
     
    333335        {
    334336                /* Let's waste some more bytes of RAM instead of to make
    335                    memory management a total disaster here.. */
     337                   memory management a total disaster here. And it saves
     338                   me one g_free() call in this function. :-P */
    336339                new->full_jid = full_jid;
    337340        }
     
    426429                        return best_prio;
    427430        }
     431}
     432
     433/* I'm keeping a separate ext_jid attribute to save a JID that makes sense
     434   to export to BitlBee. This is mainly for groupchats right now. It's
     435   a bit of a hack, but I just think having the user nickname in the hostname
     436   part of the hostmask doesn't look nice on IRC. Normally you can convert
     437   a normal JID to ext_jid by swapping the part before and after the / and
     438   replacing the / with a =. But there should be some stripping (@s are
     439   allowed in Jabber nicks...). */
     440struct jabber_buddy *jabber_buddy_by_ext_jid( struct im_connection *ic, char *jid_, get_buddy_flags_t flags )
     441{
     442        struct jabber_buddy *bud;
     443        char *s, *jid;
     444       
     445        jid = jabber_normalize( jid_ );
     446       
     447        if( ( s = strchr( jid, '=' ) ) == NULL )
     448                return NULL;
     449       
     450        for( bud = jabber_buddy_by_jid( ic, s + 1, GET_BUDDY_FIRST ); bud; bud = bud->next )
     451        {
     452                /* Hmmm, could happen if not all people in the chat are anonymized? */
     453                if( bud->ext_jid == NULL )
     454                        continue;
     455               
     456                if( strcmp( bud->ext_jid, jid ) == 0 )
     457                        break;
     458        }
     459       
     460        g_free( jid );
     461       
     462        return bud;
    428463}
    429464
  • protocols/jabber/message.c

    r2758cfe rb9f8b87  
    5353                {
    5454                        if( bud )
     55                        {
    5556                                bud->last_act = time( NULL );
     57                                from = bud->ext_jid ? : bud->bare_jid;
     58                        }
    5659                        else
    5760                                *s = 0; /* We need to generate a bare JID now. */
     
    8184               
    8285                if( fullmsg->len > 0 )
    83                         imcb_buddy_msg( ic, bud ? bud->bare_jid : from, fullmsg->str,
     86                        imcb_buddy_msg( ic, from, fullmsg->str,
    8487                                        0, jabber_get_timestamp( node ) );
    8588               
     
    9093                {
    9194                        bud->flags |= JBFLAG_DOES_XEP85;
    92                         imcb_buddy_typing( ic, bud ? bud->bare_jid : from, OPT_TYPING );
     95                        imcb_buddy_typing( ic, from, OPT_TYPING );
    9396                }
    9497                /* No need to send a "stopped typing" signal when there's a message. */
     
    9699                {
    97100                        bud->flags |= JBFLAG_DOES_XEP85;
    98                         imcb_buddy_typing( ic, bud ? bud->bare_jid : from, 0 );
     101                        imcb_buddy_typing( ic, from, 0 );
    99102                }
    100103                else if( xt_find_node( node->children, "paused" ) )
    101104                {
    102105                        bud->flags |= JBFLAG_DOES_XEP85;
    103                         imcb_buddy_typing( ic, bud ? bud->bare_jid : from, OPT_THINKING );
     106                        imcb_buddy_typing( ic, from, OPT_THINKING );
    104107                }
    105108               
Note: See TracChangeset for help on using the changeset viewer.