diff options
Diffstat (limited to 'protocols')
| -rw-r--r-- | protocols/Makefile | 2 | ||||
| -rw-r--r-- | protocols/bee.c | 3 | ||||
| -rw-r--r-- | protocols/bee.h | 26 | ||||
| -rw-r--r-- | protocols/jabber/conference.c | 4 | ||||
| -rw-r--r-- | protocols/jabber/jabber.c | 2 | ||||
| -rw-r--r-- | protocols/jabber/presence.c | 4 | ||||
| -rw-r--r-- | protocols/nogaim.c | 270 | ||||
| -rw-r--r-- | protocols/nogaim.h | 8 | 
8 files changed, 41 insertions, 278 deletions
| diff --git a/protocols/Makefile b/protocols/Makefile index 46c73559..bf2533cb 100644 --- a/protocols/Makefile +++ b/protocols/Makefile @@ -9,7 +9,7 @@  -include ../Makefile.settings  # [SH] Program variables -objects = account.o bee.o bee_ft.o bee_user.o nogaim.o +objects = account.o bee.o bee_chat.o bee_ft.o bee_user.o nogaim.o  # [SH] The next two lines should contain the directory name (in $(subdirs)) diff --git a/protocols/bee.c b/protocols/bee.c index de9550c2..8c38d550 100644 --- a/protocols/bee.c +++ b/protocols/bee.c @@ -46,6 +46,8 @@ bee_t *bee_new()  	s->flags |= SET_NULL_OK;  	s = set_add( &b->set, "strip_html", "true", NULL, b ); +	b->user = g_malloc( 1 ); +	  	return b;  } @@ -69,6 +71,7 @@ void bee_free( bee_t *b )  	while( b->set )  		set_del( &b->set, b->set->key ); +	g_free( b->user );  	g_free( b );  } diff --git a/protocols/bee.h b/protocols/bee.h index 62f60477..f69d29d4 100644 --- a/protocols/bee.h +++ b/protocols/bee.h @@ -27,6 +27,7 @@  #define __BEE_H__  struct bee_ui_funcs; +struct groupchat;  typedef struct bee  { @@ -35,6 +36,11 @@ typedef struct bee  	GSList *users;  	struct account *accounts; /* TODO(wilmer): Use GSList here too? */ +	/* Symbolic, to refer to the local user (who has no real bee_user +	   object). Not to be used by anything except so far imcb_chat_add/ +	   remove_buddy(). This seems slightly cleaner than abusing NULL. */ +	struct bee_user *user; +	  	const struct bee_ui_funcs *ui;  	void *ui_data;  } bee_t; @@ -72,6 +78,13 @@ typedef struct bee_ui_funcs  	gboolean (*user_msg)( bee_t *bee, bee_user_t *bu, const char *msg, time_t sent_at );  	gboolean (*user_typing)( bee_t *bee, bee_user_t *bu, guint32 flags ); +	gboolean (*chat_new)( bee_t *bee, struct groupchat *c ); +	gboolean (*chat_free)( bee_t *bee, struct groupchat *c ); +	gboolean (*chat_log)( bee_t *bee, struct groupchat *c, const char *format, ... ); +	gboolean (*chat_msg)( bee_t *bee, struct groupchat *c, const char *who, const char *msg, time_t sent_at ); +	gboolean (*chat_add_user)( bee_t *bee, struct groupchat *c, bee_user_t *bu ); +	gboolean (*chat_remove_user)( bee_t *bee, struct groupchat *c, bee_user_t *bu ); +	  	struct file_transfer* (*ft_in_start)( bee_t *bee, bee_user_t *bu, const char *file_name, size_t file_size );  	gboolean (*ft_out_start)( struct im_connection *ic, struct file_transfer *ft );  	void (*ft_close)( struct im_connection *ic, struct file_transfer *ft ); @@ -100,4 +113,17 @@ G_MODULE_EXPORT void imcb_buddy_status( struct im_connection *ic, const char *ha  /* Call when a handle says something. 'flags' and 'sent_at may be just 0. */  G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, guint32 flags, time_t sent_at ); +/* bee_chat.c */ +#if 0 +struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle ); +void imcb_chat_name_hint( struct groupchat *c, const char *name ); +void imcb_chat_free( struct groupchat *c ); +void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t flags, time_t sent_at ); +void imcb_chat_log( struct groupchat *c, char *format, ... ); +void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at ); +void imcb_chat_add_buddy( struct groupchat *b, const char *handle ); +void imcb_chat_remove_buddy( struct groupchat *b, const char *handle, const char *reason ); +static int remove_chat_buddy_silent( struct groupchat *b, const char *handle ); +#endif +  #endif /* __BEE_H__ */ diff --git a/protocols/jabber/conference.c b/protocols/jabber/conference.c index f434c58a..17108428 100644 --- a/protocols/jabber/conference.c +++ b/protocols/jabber/conference.c @@ -91,11 +91,13 @@ static xt_status jabber_chat_join_failed( struct im_connection *ic, struct xt_no  struct groupchat *jabber_chat_by_jid( struct im_connection *ic, const char *name )  {  	char *normalized = jabber_normalize( name ); +	GSList *l;  	struct groupchat *ret;  	struct jabber_chat *jc; -	for( ret = ic->groupchats; ret; ret = ret->next ) +	for( l = ic->groupchats; l; l = l->next )  	{ +		ret = l->data;  		jc = ret->data;  		if( strcmp( normalized, jc->name ) == 0 )  			break; diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index acad525e..75bc44d3 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -281,7 +281,7 @@ static void jabber_logout( struct im_connection *ic )  		jabber_end_stream( ic );  	while( ic->groupchats ) -		jabber_chat_free( ic->groupchats ); +		jabber_chat_free( ic->groupchats->data );  	if( jd->r_inpa >= 0 )  		b_event_remove( jd->r_inpa ); diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c index 006eeead..dadccfb9 100644 --- a/protocols/jabber/presence.c +++ b/protocols/jabber/presence.c @@ -205,6 +205,7 @@ int presence_send_update( struct im_connection *ic )  	struct jabber_data *jd = ic->proto_data;  	struct xt_node *node, *cap;  	struct groupchat *c; +	GSList *l;  	int st;  	node = jabber_make_packet( "presence", NULL, NULL, NULL ); @@ -228,8 +229,9 @@ int presence_send_update( struct im_connection *ic )  	/* Have to send this update to all groupchats too, the server won't  	   do this automatically. */ -	for( c = ic->groupchats; c && st; c = c->next ) +	for( l = ic->groupchats; l && st; l = l->next )  	{ +		struct groupchat *c = l->data;  		struct jabber_chat *jc = c->data;  		xt_add_attr( node, "to", jc->my_full_jid ); diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 74ec0642..149e64f1 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -536,276 +536,6 @@ struct bee_user *imcb_buddy_by_handle( struct im_connection *ic, const char *han  	return bee_user_by_handle( ic->bee, ic, handle );  } -struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle ) -{ -#if 0 -	struct groupchat *c; -	 -	/* This one just creates the conversation structure, user won't see anything yet */ -	 -	if( ic->groupchats ) -	{ -		for( c = ic->groupchats; c->next; c = c->next ); -		c = c->next = g_new0( struct groupchat, 1 ); -	} -	else -		ic->groupchats = c = g_new0( struct groupchat, 1 ); -	 -	c->ic = ic; -	c->title = g_strdup( handle ); -	c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ ); -	c->topic = g_strdup_printf( "BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->title ); -	 -	if( set_getbool( &ic->bee->set, "debug" ) ) -		imcb_log( ic, "Creating new conversation: (id=%p,handle=%s)", c, handle ); -	 -	return c; -#endif -	return NULL; -} - -void imcb_chat_name_hint( struct groupchat *c, const char *name ) -{ -#if 0 -	if( !c->joined ) -	{ -		struct im_connection *ic = c->ic; -		char stripped[MAX_NICK_LENGTH+1], *full_name; -		 -		strncpy( stripped, name, MAX_NICK_LENGTH ); -		stripped[MAX_NICK_LENGTH] = '\0'; -		nick_strip( stripped ); -		if( set_getbool( &ic->irc->set, "lcnicks" ) ) -			nick_lc( stripped ); -		 -		full_name = g_strdup_printf( "&%s", stripped ); -		 -		if( stripped[0] && -		    nick_cmp( stripped, ic->irc->channel + 1 ) != 0 && -		    irc_chat_by_channel( ic->irc, full_name ) == NULL ) -		{ -			g_free( c->channel ); -			c->channel = full_name; -		} -		else -		{ -			g_free( full_name ); -		} -	} -#endif -} - -void imcb_chat_free( struct groupchat *c ) -{ -#if 0 -	struct im_connection *ic = c->ic; -	struct groupchat *l; -	GList *ir; -	 -	if( set_getbool( &ic->bee->set, "debug" ) ) -		imcb_log( ic, "You were removed from conversation %p", c ); -	 -	if( c ) -	{ -		if( c->joined ) -		{ -			user_t *u, *r; -			 -			r = user_find( ic->irc, ic->irc->mynick ); -			irc_privmsg( ic->irc, r, "PRIVMSG", c->channel, "", "Cleaning up channel, bye!" ); -			 -			u = user_find( ic->irc, ic->irc->nick ); -			irc_kick( ic->irc, u, c->channel, r ); -			/* irc_part( ic->irc, u, c->channel ); */ -		} -		 -		/* Find the previous chat in the linked list. */ -		for( l = ic->groupchats; l && l->next != c; l = l->next ); -		 -		if( l ) -			l->next = c->next; -		else -			ic->groupchats = c->next; -		 -		for( ir = c->in_room; ir; ir = ir->next ) -			g_free( ir->data ); -		g_list_free( c->in_room ); -		g_free( c->channel ); -		g_free( c->title ); -		g_free( c->topic ); -		g_free( c ); -	} -#endif -} - -void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t flags, time_t sent_at ) -{ -#if 0 -	struct im_connection *ic = c->ic; -	char *wrapped; -	user_t *u; -	 -	/* Gaim sends own messages through this too. IRC doesn't want this, so kill them */ -	if( g_strcasecmp( who, ic->acc->user ) == 0 ) -		return; -	 -	u = user_findhandle( ic, who ); -	 -	if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) || -	    ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) ) -		strip_html( msg ); -	 -	wrapped = word_wrap( msg, 425 ); -	if( c && u ) -	{ -		char *ts = NULL; -		if( set_getbool( &ic->irc->set, "display_timestamps" ) ) -			ts = format_timestamp( ic->irc, sent_at ); -		irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, ts ? : "", wrapped ); -		g_free( ts ); -	} -	else -	{ -		imcb_log( ic, "Message from/to conversation %s@%p (unknown conv/user): %s", who, c, wrapped ); -	} -	g_free( wrapped ); -#endif -} - -void imcb_chat_log( struct groupchat *c, char *format, ... ) -{ -#if 0 -	irc_t *irc = c->ic->irc; -	va_list params; -	char *text; -	user_t *u; -	 -	va_start( params, format ); -	text = g_strdup_vprintf( format, params ); -	va_end( params ); -	 -	u = user_find( irc, irc->mynick ); -	 -	irc_privmsg( irc, u, "PRIVMSG", c->channel, "System message: ", text ); -	 -	g_free( text ); -#endif -} - -void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at ) -{ -#if 0 -	struct im_connection *ic = c->ic; -	user_t *u = NULL; -	 -	if( who == NULL) -		u = user_find( ic->irc, ic->irc->mynick ); -	else if( g_strcasecmp( who, ic->acc->user ) == 0 ) -		u = user_find( ic->irc, ic->irc->nick ); -	else -		u = user_findhandle( ic, who ); -	 -	if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) || -	    ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) ) -		strip_html( topic ); -	 -	g_free( c->topic ); -	c->topic = g_strdup( topic ); -	 -	if( c->joined && u ) -		irc_write( ic->irc, ":%s!%s@%s TOPIC %s :%s", u->nick, u->user, u->host, c->channel, topic ); -#endif -} - -void imcb_chat_add_buddy( struct groupchat *b, const char *handle ) -{ -#if 0 -	user_t *u = user_findhandle( b->ic, handle ); -	int me = 0; -	 -	if( set_getbool( &b->ic->bee->set, "debug" ) ) -		imcb_log( b->ic, "User %s added to conversation %p", handle, b ); -	 -	/* It might be yourself! */ -	if( b->ic->acc->prpl->handle_cmp( handle, b->ic->acc->user ) == 0 ) -	{ -		u = user_find( b->ic->irc, b->ic->irc->nick ); -		if( !b->joined ) -			irc_join( b->ic->irc, u, b->channel ); -		b->joined = me = 1; -	} -	 -	/* Most protocols allow people to join, even when they're not in -	   your contact list. Try to handle that here */ -	if( !u ) -	{ -		imcb_add_buddy( b->ic, handle, NULL ); -		u = user_findhandle( b->ic, handle ); -	} -	 -	/* Add the handle to the room userlist, if it's not 'me' */ -	if( !me ) -	{ -		if( b->joined ) -			irc_join( b->ic->irc, u, b->channel ); -		b->in_room = g_list_append( b->in_room, g_strdup( handle ) ); -	} -#endif -} - -/* This function is one BIG hack... :-( EREWRITE */ -void imcb_chat_remove_buddy( struct groupchat *b, const char *handle, const char *reason ) -{ -#if 0 -	user_t *u; -	int me = 0; -	 -	if( set_getbool( &b->ic->bee->set, "debug" ) ) -		imcb_log( b->ic, "User %s removed from conversation %p (%s)", handle, b, reason ? reason : "" ); -	 -	/* It might be yourself! */ -	if( g_strcasecmp( handle, b->ic->acc->user ) == 0 ) -	{ -		if( b->joined == 0 ) -			return; -		 -		u = user_find( b->ic->irc, b->ic->irc->nick ); -		b->joined = 0; -		me = 1; -	} -	else -	{ -		u = user_findhandle( b->ic, handle ); -	} -	 -	if( me || ( remove_chat_buddy_silent( b, handle ) && b->joined && u ) ) -		irc_part( b->ic->irc, u, b->channel ); -#endif -} - -#if 0 -static int remove_chat_buddy_silent( struct groupchat *b, const char *handle ) -{ -	GList *i; -	 -	/* Find the handle in the room userlist and shoot it */ -	i = b->in_room; -	while( i ) -	{ -		if( g_strcasecmp( handle, i->data ) == 0 ) -		{ -			g_free( i->data ); -			b->in_room = g_list_remove( b->in_room, i->data ); -			return( 1 ); -		} -		 -		i = i->next; -	} -	 -	return 0; -} -#endif -  /* Misc. BitlBee stuff which shouldn't really be here */  #if 0 diff --git a/protocols/nogaim.h b/protocols/nogaim.h index 6632827c..580b4001 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -88,7 +88,7 @@ struct im_connection  	/* BitlBee */  	bee_t *bee; -	struct groupchat *groupchats; +	GSList *groupchats;  };  struct groupchat { @@ -99,10 +99,9 @@ struct groupchat {  	 * "nick list". This is how you can check who is in the group chat  	 * already, for example to avoid adding somebody two times. */  	GList *in_room; -	GList *ignored; +	//GList *ignored; -	struct groupchat *next; -	char *channel; +	//struct groupchat *next;  	/* The title variable contains the ID you gave when you created the  	 * chat using imcb_chat_new(). */  	char *title; @@ -113,6 +112,7 @@ struct groupchat {  	/* This is for you, you can add your own structure here to extend this  	 * structure for your protocol's needs. */  	void *data; +	void *ui_data;  };  struct buddy { | 
