diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2007-04-25 21:41:34 -0700 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2007-04-25 21:41:34 -0700 | 
| commit | 6286f80d6dc1dc4cb8106b4e209a8578d7cebe56 (patch) | |
| tree | 0db5a8b93910ffdf18d4d3588a3022ad727f7e40 /protocols/jabber | |
| parent | 2d317bbe8def887fb796b2daaa958c59d8f4c070 (diff) | |
Prepared the Jabber module for anonymous rooms, but the BitlBee core
doesn't deal with it very well, and I don't really know yet how I'll
solve this... :-(
Diffstat (limited to 'protocols/jabber')
| -rw-r--r-- | protocols/jabber/conference.c | 31 | ||||
| -rw-r--r-- | protocols/jabber/jabber.h | 6 | ||||
| -rw-r--r-- | protocols/jabber/jabber_util.c | 3 | 
3 files changed, 24 insertions, 16 deletions
| diff --git a/protocols/jabber/conference.c b/protocols/jabber/conference.c index f0d8f050..dde2b8b5 100644 --- a/protocols/jabber/conference.c +++ b/protocols/jabber/conference.c @@ -136,28 +136,31 @@ void jabber_chat_pkt_presence( struct im_connection *ic, struct jabber_buddy *bu  				if( ( s = xt_find_attr( c, "jid" ) ) )  				{  					/* Yay, found what we need. :-) */ -					bud->orig_jid = g_strdup( s ); +					bud->ext_jid = g_strdup( s );  					break;  				}  			} -		/* Won't handle this for now. */ -		if( bud->orig_jid == NULL ) -			return; +		/* Make up some other handle, if necessary. */ +		if( bud->ext_jid == NULL ) +		{ +			/* Don't want the nick to be at the end, so let's +			   think of some slightly different notation to use +			   for anonymous groupchat participants in BitlBee. */ +			bud->ext_jid = g_strdup_printf( "%s=%s", bud->resource, bud->bare_jid ); +			bud->flags |= JBFLAG_IS_ANONYMOUS; +		} -		s = strchr( bud->orig_jid, '/' ); +		s = strchr( bud->ext_jid, '/' );  		if( s ) *s = 0; /* Should NEVER be NULL, but who knows... */ -		imcb_chat_add_buddy( chat, bud->orig_jid ); +		imcb_chat_add_buddy( chat, bud->ext_jid );  		if( s ) *s = '/';  	}  	else if( type ) /* This only gets called if type is NULL or "unavailable" */  	{ -		/* Won't handle this for now. */ -		if( bud->orig_jid == NULL ) -			return; -		s = strchr( bud->orig_jid, '/' ); -		if( s ) *s = 0; /* Should NEVER be NULL, but who knows... */ -		imcb_chat_remove_buddy( chat, bud->orig_jid, NULL ); +		s = strchr( bud->ext_jid, '/' ); +		if( s ) *s = 0; +		imcb_chat_remove_buddy( chat, bud->ext_jid, NULL );  		if( s ) *s = '/';  		if( bud == jc->me ) @@ -198,9 +201,9 @@ void jabber_chat_pkt_message( struct im_connection *ic, struct jabber_buddy *bud  	if( body && body->text_len > 0 )  	{ -		s = strchr( bud->orig_jid, '/' ); +		s = strchr( bud->ext_jid, '/' );  		if( s ) *s = 0; -		imcb_chat_msg( chat, bud->orig_jid, body->text, 0, jabber_get_timestamp( node ) ); +		imcb_chat_msg( chat, bud->ext_jid, body->text, 0, jabber_get_timestamp( node ) );  		if( s ) *s = '/';  	}  } diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 57e24b5f..ba61920c 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -51,6 +51,8 @@ typedef enum  	                                   XEP85 (typing notification shite). */  	JBFLAG_IS_CHATROOM = 4,		/* It's convenient to use this JID thingy for  	                                   groupchat state info too. */ +	JBFLAG_IS_ANONYMOUS = 8,	/* For anonymous chatrooms, when we don't have +	                                   have a real JID. */  } jabber_buddy_flags_t;  #define JABBER_PORT_DEFAULT "5222" @@ -102,8 +104,8 @@ struct jabber_buddy  	char *full_jid;  	char *resource; -	/* Groupchat-only */ -	char *orig_jid; +	char *ext_jid; /* The JID to use in BitlBee. The real JID if possible, */ +	               /* otherwise something similar to the conference JID. */  	int priority;  	struct jabber_away_state *away_state; diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c index 091e6c7d..4dae3287 100644 --- a/protocols/jabber/jabber_util.c +++ b/protocols/jabber/jabber_util.c @@ -450,6 +450,7 @@ int jabber_buddy_remove( struct im_connection *ic, char *full_jid_ )  		{  			g_hash_table_remove( jd->buddies, bud->bare_jid );  			g_free( bud->bare_jid ); +			g_free( bud->ext_jid );  			g_free( bud->full_jid );  			g_free( bud->away_message );  			g_free( bud ); @@ -482,6 +483,7 @@ int jabber_buddy_remove( struct im_connection *ic, char *full_jid_ )  					   item, because we're removing the first. */  					g_hash_table_replace( jd->buddies, bi->bare_jid, bi->next ); +				g_free( bi->ext_jid );  				g_free( bi->full_jid );  				g_free( bi->away_message );  				g_free( bi ); @@ -525,6 +527,7 @@ int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid_ )  		while( bud )  		{  			next = bud->next; +			g_free( bud->ext_jid );  			g_free( bud->full_jid );  			g_free( bud->away_message );  			g_free( bud ); | 
