Changeset fc0640e


Ignore:
Timestamp:
2012-02-10T18:00:00Z (9 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.

Location:
protocols/jabber
Files:
3 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... */
  • protocols/jabber/jabber.c

    rbb2d198 rfc0640e  
    483483}
    484484
     485static struct groupchat *jabber_chat_with_( struct im_connection *ic, char *who )
     486{
     487        return jabber_chat_with( ic, who );
     488}
     489
    485490static void jabber_chat_msg_( struct groupchat *c, char *message, int flags )
    486491{
     
    635640        ret->chat_leave = jabber_chat_leave_;
    636641        ret->chat_join = jabber_chat_join_;
     642        ret->chat_with = jabber_chat_with_;
    637643        ret->chat_add_settings = jabber_chat_add_settings;
    638644        ret->chat_free_settings = jabber_chat_free_settings;
  • protocols/jabber/jabber.h

    rbb2d198 rfc0640e  
    163163        char *my_full_jid; /* Separate copy because of case sensitivity. */
    164164        struct jabber_buddy *me;
     165        char *invite;
    165166};
    166167
     
    339340/* conference.c */
    340341struct groupchat *jabber_chat_join( struct im_connection *ic, const char *room, const char *nick, const char *password );
     342struct groupchat *jabber_chat_with( struct im_connection *ic, char *who );
    341343struct groupchat *jabber_chat_by_jid( struct im_connection *ic, const char *name );
    342344void jabber_chat_free( struct groupchat *c );
Note: See TracChangeset for help on using the changeset viewer.