Ticket #458: google-talk-invis.patch

File google-talk-invis.patch, 3.8 KB (added by anonymous, at 2008-11-14T15:58:26Z)
  • protocols/jabber/iq.c

    diff -Naur bitlbee-1.2.3-orig/protocols/jabber/iq.c bitlbee-1.2.3/protocols/jabber/iq.c
    old new  
    153153                                reply = jabber_make_error_packet( node, "not-allowed", "cancel" );
    154154                                pack = 0;
    155155                        }
    156                 }
     156                }
     157                else if( strcmp( s, "google:shared-status" ) == 0 )
     158                {
     159                        xt_free_node( reply );
     160                        reply = NULL;
     161                        pack = 0;
     162                }
    157163                else
    158164                {
    159165                        xt_free_node( reply );
     
    267273{
    268274        struct jabber_data *jd = ic->proto_data;
    269275        char *type;
    270        
     276               
    271277        if( !( type = xt_find_attr( node, "type" ) ) )
    272278        {
    273279                imcb_log( ic, "Warning: Received incomplete IQ packet while authenticating" );
     
    289295                if( !jabber_get_roster( ic ) )
    290296                        return XT_ABORT;
    291297        }
    292        
     298
     299        /* Register to google shared status settings */
    293300        return XT_HANDLED;
    294301}
    295302
     
    324331
    325332int jabber_get_roster( struct im_connection *ic )
    326333{
    327         struct xt_node *node;
     334        struct xt_node *node, *n;
    328335        int st;
     336
     337
     338        n = xt_new_node( "query", NULL, NULL );
     339        xt_add_attr( n, "xmlns", "google:shared-status" );
     340        xt_add_attr( n, "version", "2" );
     341        n = jabber_make_packet( "iq", "get", NULL, n);
     342       
     343        jabber_write_packet( ic, n );
    329344       
     345        xt_free_node( n );
     346
    330347        imcb_log( ic, "Authenticated, requesting buddy list" );
    331348       
    332349        node = xt_new_node( "query", NULL, NULL );
  • protocols/jabber/jabber.c

    diff -Naur bitlbee-1.2.3-orig/protocols/jabber/jabber.c bitlbee-1.2.3/protocols/jabber/jabber.c
    old new  
    380380       
    381381        /* Save all this info. We need it, for example, when changing the priority setting. */
    382382        state = (void *) jabber_away_state_by_name( state_txt );
    383         jd->away_state = state ? state : (void *) jabber_away_state_list; /* Fall back to "Away" if necessary. */
     383        jd->away_state = state ? state : (void *) (jabber_away_state_list+4); /* Fall back to "Away" if necessary. */
    384384        g_free( jd->away_message );
    385385        jd->away_message = ( message && *message ) ? g_strdup( message ) : NULL;
    386386       
  • protocols/jabber/presence.c

    diff -Naur bitlbee-1.2.3-orig/protocols/jabber/presence.c bitlbee-1.2.3/protocols/jabber/presence.c
    old new  
    205205int presence_send_update( struct im_connection *ic )
    206206{
    207207        struct jabber_data *jd = ic->proto_data;
    208         struct xt_node *node, *cap;
     208        struct xt_node *node, *cap, *n;
    209209        char *show = jd->away_state->code;
    210210        char *status = jd->away_message;
    211211        struct groupchat *c;
    212212        int st;
     213        int invisible=0;
     214        static char fid[1024];
     215
     216        if(show && *show=='x')
     217                invisible = 1;
     218
     219        n = xt_new_node( "query", NULL, NULL );
     220        xt_add_attr( n, "xmlns", "google:shared-status" );
     221        xt_add_attr( n, "version", "2" );
     222       
     223        cap = xt_new_node("status",status,NULL);
     224        xt_add_child(n,cap);
     225       
     226        if(*show == 'd')
     227                cap = xt_new_node("show","dnd",NULL);
     228        else
     229                cap = xt_new_node("show","default",NULL);
     230        xt_add_child(n,cap);
     231       
     232        cap = xt_new_node("status-list",NULL,NULL);
     233        xt_add_attr(cap,"show","default");
     234        xt_add_child(n,cap);
     235
     236        cap = xt_new_node("status-list",NULL,NULL);
     237        xt_add_attr(cap,"show","dnd");
     238        xt_add_child(n,cap);
     239
     240        cap = xt_new_node("invisible",NULL,NULL);
     241        if(invisible)
     242                xt_add_attr(cap,"value","true");
     243        else
     244                xt_add_attr(cap,"value","false");
     245        xt_add_child(n,cap);
     246
     247        sprintf(fid,"%s@%s",jd->username,jd->server);
     248        n = jabber_make_packet( "iq", "set", fid, n);
     249        st = jabber_write_packet( ic, n );
     250        xt_free_node( n );
     251
     252        if(invisible)
     253                return st;
    213254       
    214255        node = jabber_make_packet( "presence", NULL, NULL, NULL );
    215256        xt_add_child( node, xt_new_node( "priority", set_getstr( &ic->acc->set, "priority" ), NULL ) );