Ignore:
Timestamp:
2012-02-10T18:00:00Z (12 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
b5fe39b
Parents:
bb2d198
Message:

Support for "nameless" chatrooms on Jabber.

Just join #somechannel and start inviting people. It should Just Work,
like on other IM networks. Works at least with GTalk and with other
servers that have conference stuff installed on conference.$servername.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/conference.c

    rbb2d198 rfc0640e  
    2323
    2424#include "jabber.h"
     25#include "sha1.h"
    2526
    2627static xt_status jabber_chat_join_failed( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );
     
    6869}
    6970
     71struct groupchat *jabber_chat_with( struct im_connection *ic, char *who )
     72{
     73        struct jabber_data *jd = ic->proto_data;
     74        struct jabber_chat *jc;
     75        struct groupchat *c;
     76        sha1_state_t sum;
     77        double now = gettime();
     78        char *uuid, *rjid, *cserv;
     79       
     80        sha1_init( &sum );
     81        sha1_append( &sum, (uint8_t*) ic->acc->user, strlen( ic->acc->user ) );
     82        sha1_append( &sum, (uint8_t*) &now, sizeof( now ) );
     83        sha1_append( &sum, (uint8_t*) who, strlen( who ) );
     84        uuid = sha1_random_uuid( &sum );
     85       
     86        if( jd->flags & JFLAG_GTALK )
     87                cserv = g_strdup( "groupchat.google.com" );
     88        else
     89                /* Guess... */
     90                cserv = g_strdup_printf( "conference.%s", jd->server );
     91       
     92        rjid = g_strdup_printf( "private-chat-%s@%s", uuid, cserv );
     93        g_free( uuid );
     94        g_free( cserv );
     95       
     96        c = jabber_chat_join( ic, rjid, jd->username, NULL );
     97        g_free( rjid );
     98        if( c == NULL )
     99                return NULL;
     100       
     101        jc = c->data;
     102        jc->invite = g_strdup( who );
     103       
     104        return c;
     105}
     106
    70107static xt_status jabber_chat_join_failed( struct im_connection *ic, struct xt_node *node, struct xt_node *orig )
    71108{
     
    116153        g_free( jc->my_full_jid );
    117154        g_free( jc->name );
     155        g_free( jc->invite );
    118156        g_free( jc );
    119157       
     
    283321                }
    284322               
     323                if( bud == jc->me && jc->invite != NULL )
     324                {
     325                        char *msg = g_strdup_printf( "Please join me in room %s", jc->name );
     326                        jabber_chat_invite( chat, jc->invite, msg );
     327                        g_free( jc->invite );
     328                        g_free( msg );
     329                        jc->invite = NULL;
     330                }
     331               
    285332                s = strchr( bud->ext_jid, '/' );
    286333                if( s ) *s = 0; /* Should NEVER be NULL, but who knows... */
Note: See TracChangeset for help on using the changeset viewer.