Ignore:
Timestamp:
2006-10-10T12:05:42Z (16 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
8eb10c9
Parents:
6a1128d
Message:

Added resource selection (based on priority or time of last message) to
budd_by_jid(), added a full_jid property to easily address that resource
without having to rebuild the full JID every time and implemented typing
notification shite.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/jabber.c

    r6a1128d ra21a8ac  
    4444        s = set_add( &acc->set, "resource", "BitlBee", NULL, acc );
    4545        s->flags |= ACC_SET_OFFLINE_ONLY;
     46       
     47        s = set_add( &acc->set, "resource_select", "priority", NULL, acc );
    4648       
    4749        s = set_add( &acc->set, "server", NULL, set_eval_account, acc );
     
    137139static int jabber_send_im( struct gaim_connection *gc, char *who, char *message, int len, int away )
    138140{
     141        struct jabber_data *jd = gc->proto_data;
     142        struct jabber_buddy *bud;
    139143        struct xt_node *node;
    140144        int st;
    141145       
    142         /*
    143         event = xt_new_node( "active", NULL, NULL );
    144         xt_add_attr( event, "xlmns", "http://jabber.org/protocol/chatstates" );
    145        
    146         event = xt_new_node( "x", NULL, xt_new_node( "composing", NULL, NULL ) );
    147         xt_add_attr( event, "xmlns", "jabber:x:event" );
    148         */
     146        bud = jabber_buddy_by_jid( gc, who );
    149147       
    150148        node = xt_new_node( "body", message, NULL );
    151         node = jabber_make_packet( "message", "chat", who, node );
     149        node = jabber_make_packet( "message", "chat", bud->full_jid, node );
     150       
     151        if( ( jd->flags & JFLAG_WANT_TYPING ) &&
     152            ( ( bud->flags & JBFLAG_DOES_JEP85 ) ||
     153             !( bud->flags & JBFLAG_PROBED_JEP85 ) ) )
     154        {
     155                struct xt_node *act;
     156               
     157                /* If the user likes typing notification and if we don't know
     158                   (and didn't probe before) if this resource supports JEP85,
     159                   include a probe in this packet now. */
     160                act = xt_new_node( "active", NULL, NULL );
     161                xt_add_attr( act, "xmlns", "http://jabber.org/protocol/chatstates" );
     162                xt_add_child( node, act );
     163               
     164                /* Just make sure we do this only once. */
     165                bud->flags |= JBFLAG_PROBED_JEP85;
     166        }
     167       
    152168        st = jabber_write_packet( gc, node );
    153169        xt_free_node( node );
     
    227243           is in the cache for about a minute (which should be enough AFAIK). */
    228244        jabber_cache_clean( gc );
     245}
     246
     247static int jabber_send_typing( struct gaim_connection *gc, char *who, int typing )
     248{
     249        struct jabber_data *jd = gc->proto_data;
     250        struct jabber_buddy *bud;
     251       
     252        /* Enable typing notification related code from now. */
     253        jd->flags |= JFLAG_WANT_TYPING;
     254       
     255        bud = jabber_buddy_by_jid( gc, who );
     256        if( bud->flags & JBFLAG_DOES_JEP85 )
     257        {
     258                /* We're only allowed to send this stuff if we know the other
     259                   side supports it. */
     260               
     261                struct xt_node *node;
     262                char *type;
     263                int st;
     264               
     265                if( typing == 0 )
     266                        type = "active";
     267                else if( typing == 2 )
     268                        type = "paused";
     269                else /* if( typing == 1 ) */
     270                        type = "composing";
     271               
     272                node = xt_new_node( type, NULL, NULL );
     273                xt_add_attr( node, "xmlns", "http://jabber.org/protocol/chatstates" );
     274                node = jabber_make_packet( "message", "chat", bud->full_jid, node );
     275               
     276                st = jabber_write_packet( gc, node );
     277                xt_free_node( node );
     278               
     279                return st;
     280        }
     281       
     282        return 1;
    229283}
    230284
     
    250304//      ret->chat_open = jabber_chat_open;
    251305        ret->keepalive = jabber_keepalive;
    252 //      ret->send_typing = jabber_send_typing;
     306        ret->send_typing = jabber_send_typing;
    253307        ret->handle_cmp = g_strcasecmp;
    254308
Note: See TracChangeset for help on using the changeset viewer.