diff options
| -rw-r--r-- | irc.c | 8 | ||||
| -rw-r--r-- | irc_commands.c | 10 | ||||
| -rw-r--r-- | motd.txt | 2 | ||||
| -rw-r--r-- | protocols/msn/msn.c | 27 | ||||
| -rw-r--r-- | protocols/msn/msn.h | 4 | ||||
| -rw-r--r-- | protocols/msn/sb.c | 20 | ||||
| -rw-r--r-- | protocols/nogaim.c | 48 | ||||
| -rw-r--r-- | protocols/nogaim.h | 48 | ||||
| -rw-r--r-- | protocols/oscar/oscar.c | 52 | ||||
| -rw-r--r-- | protocols/yahoo/yahoo.c | 38 | ||||
| -rw-r--r-- | root_commands.c | 48 | 
11 files changed, 158 insertions, 147 deletions
| @@ -658,7 +658,7 @@ void irc_names( irc_t *irc, char *channel )  			strcat( namelist, " " );  		}  	} -	else if( ( c = conv_findchannel( channel ) ) ) +	else if( ( c = chat_by_channel( channel ) ) )  	{  		GList *l; @@ -811,7 +811,7 @@ void irc_topic( irc_t *irc, char *channel )  	}  	else  	{ -		struct conversation *c = conv_findchannel( channel ); +		struct conversation *c = chat_by_channel( channel );  		if( c )  			irc_reply( irc, 332, "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", channel, c->title ); @@ -949,7 +949,7 @@ int irc_send( irc_t *irc, char *nick, char *s, int flags )  	if( *nick == '#' || *nick == '&' )  	{ -		if( !( c = conv_findchannel( nick ) ) ) +		if( !( c = chat_by_channel( nick ) ) )  		{  			irc_reply( irc, 403, "%s :Channel does not exist", nick );  			return( 0 ); @@ -1037,7 +1037,7 @@ int irc_send( irc_t *irc, char *nick, char *s, int flags )  	}  	else if( c && c->gc && c->gc->acc && c->gc->acc->prpl )  	{ -		return( bim_chat_msg( c->gc, c->id, s ) ); +		return( bim_chat_msg( c, s ) );  	}  	return( 0 ); diff --git a/irc_commands.c b/irc_commands.c index b1045c93..023bd0d4 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -143,7 +143,7 @@ static void irc_cmd_part( irc_t *irc, char **cmd )  		irc_part( irc, u, irc->channel );  		irc_join( irc, u, irc->channel );  	} -	else if( ( c = conv_findchannel( cmd[1] ) ) ) +	else if( ( c = chat_by_channel( cmd[1] ) ) )  	{  		user_t *u = user_find( irc, irc->nick ); @@ -152,7 +152,7 @@ static void irc_cmd_part( irc_t *irc, char **cmd )  		if( c->gc )  		{  			c->joined = 0; -			c->gc->acc->prpl->chat_leave( c->gc, c->id ); +			c->gc->acc->prpl->chat_leave( c );  		}  	}  	else @@ -200,13 +200,13 @@ static void irc_cmd_join( irc_t *irc, char **cmd )  static void irc_cmd_invite( irc_t *irc, char **cmd )  {  	char *nick = cmd[1], *channel = cmd[2]; -	struct conversation *c = conv_findchannel( channel ); +	struct conversation *c = chat_by_channel( channel );  	user_t *u = user_find( irc, nick );  	if( u && c && ( u->gc == c->gc ) )  		if( c->gc && c->gc->acc->prpl->chat_invite )  		{ -			c->gc->acc->prpl->chat_invite( c->gc, c->id, "", u->handle ); +			c->gc->acc->prpl->chat_invite( c, "", u->handle );  			irc_reply( irc, 341, "%s %s", nick, channel );  			return;  		} @@ -286,7 +286,7 @@ static void irc_cmd_who( irc_t *irc, char **cmd )  				irc_reply( irc, 352, "%s %s %s %s %s %c :0 %s", channel, u->user, u->host, irc->myhost, u->nick, u->away ? 'G' : 'H', u->realname );  			u = u->next;  		} -	else if( ( c = conv_findchannel( channel ) ) ) +	else if( ( c = chat_by_channel( channel ) ) )  		for( l = c->in_room; l; l = l->next )  		{  			if( ( u = user_findhandle( c->gc, l->data ) ) ) @@ -13,6 +13,6 @@ information.  The developers of the Bee hope you have a buzzing time. -* BitlBee development team: wilmer, ctrlsoft, Maurits +* BitlBee development team: wilmer, jelmer, Maurits  ... Buzzing, haha, get it? diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c index 663bff8c..a73d85d4 100644 --- a/protocols/msn/msn.c +++ b/protocols/msn/msn.c @@ -240,9 +240,9 @@ static void msn_remove_buddy( struct gaim_connection *gc, char *who, char *group  	msn_buddy_list_remove( gc, "FL", who );  } -static int msn_chat_send( struct gaim_connection *gc, int id, char *message ) +static int msn_chat_send( struct conversation *c, char *message )  { -	struct msn_switchboard *sb = msn_sb_by_id( gc, id ); +	struct msn_switchboard *sb = msn_sb_by_chat( c );  	if( sb )  		return( msn_sb_sendmessage( sb, message ) ); @@ -250,9 +250,9 @@ static int msn_chat_send( struct gaim_connection *gc, int id, char *message )  		return( 0 );  } -static void msn_chat_invite( struct gaim_connection *gc, int id, char *msg, char *who ) +static void msn_chat_invite( struct conversation *c, char *msg, char *who )  { -	struct msn_switchboard *sb = msn_sb_by_id( gc, id ); +	struct msn_switchboard *sb = msn_sb_by_chat( c );  	char buf[1024];  	if( sb ) @@ -262,15 +262,15 @@ static void msn_chat_invite( struct gaim_connection *gc, int id, char *msg, char  	}  } -static void msn_chat_leave( struct gaim_connection *gc, int id ) +static void msn_chat_leave( struct conversation *c )  { -	struct msn_switchboard *sb = msn_sb_by_id( gc, id ); +	struct msn_switchboard *sb = msn_sb_by_chat( c );  	if( sb )  		msn_sb_write( sb, "OUT\r\n", 5 );  } -static int msn_chat_open( struct gaim_connection *gc, char *who ) +static struct conversation *msn_chat_open( struct gaim_connection *gc, char *who )  {  	struct msn_switchboard *sb;  	struct msn_data *md = gc->proto_data; @@ -279,8 +279,7 @@ static int msn_chat_open( struct gaim_connection *gc, char *who )  	if( ( sb = msn_sb_by_handle( gc, who ) ) )  	{  		debug( "Converting existing switchboard to %s to a groupchat", who ); -		msn_sb_to_chat( sb ); -		return( 1 ); +		return msn_sb_to_chat( sb );  	}  	else  	{ @@ -291,10 +290,7 @@ static int msn_chat_open( struct gaim_connection *gc, char *who )  			debug( "Trying to reuse an existing switchboard as a groupchat with %s", who );  			g_snprintf( buf, sizeof( buf ), "CAL %d %s\r\n", ++sb->trId, who );  			if( msn_sb_write( sb, buf, strlen( buf ) ) ) -			{ -				msn_sb_to_chat( sb ); -				return( 1 ); -			} +				return msn_sb_to_chat( sb );  		}  		/* If the stuff above failed for some reason: */ @@ -313,10 +309,11 @@ static int msn_chat_open( struct gaim_connection *gc, char *who )  		/* Queue the magic message and cross your fingers. */  		md->msgq = g_slist_append( md->msgq, m ); -		return( 1 ); +		/* FIXME: Can I try to return something here already? */ +		return NULL;  	} -	return( 0 ); +	return NULL;  }  static void msn_keepalive( struct gaim_connection *gc ) diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h index b4777d41..78cc3caf 100644 --- a/protocols/msn/msn.h +++ b/protocols/msn/msn.h @@ -168,9 +168,9 @@ const struct msn_status_code *msn_status_by_number( int number );  int msn_sb_write( struct msn_switchboard *sb, char *s, int len );  struct msn_switchboard *msn_sb_create( struct gaim_connection *gc, char *host, int port, char *key, int session );  struct msn_switchboard *msn_sb_by_handle( struct gaim_connection *gc, char *handle ); -struct msn_switchboard *msn_sb_by_id( struct gaim_connection *gc, int id ); +struct msn_switchboard *msn_sb_by_chat( struct conversation *c );  struct msn_switchboard *msn_sb_spare( struct gaim_connection *gc );  int msn_sb_sendmessage( struct msn_switchboard *sb, char *text ); -void msn_sb_to_chat( struct msn_switchboard *sb ); +struct conversation *msn_sb_to_chat( struct msn_switchboard *sb );  void msn_sb_destroy( struct msn_switchboard *sb );  gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond ); diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c index 7ec340bd..8e912273 100644 --- a/protocols/msn/sb.c +++ b/protocols/msn/sb.c @@ -85,16 +85,16 @@ struct msn_switchboard *msn_sb_by_handle( struct gaim_connection *gc, char *hand  	return( NULL );  } -struct msn_switchboard *msn_sb_by_id( struct gaim_connection *gc, int id ) +struct msn_switchboard *msn_sb_by_chat( struct conversation *c )  { -	struct msn_data *md = gc->proto_data; +	struct msn_data *md = c->gc->proto_data;  	struct msn_switchboard *sb;  	GSList *l;  	for( l = md->switchboards; l; l = l->next )  	{  		sb = l->data; -		if( sb->chat && sb->chat->id == id ) +		if( sb->chat == c )  			return( sb );  	} @@ -176,14 +176,14 @@ int msn_sb_sendmessage( struct msn_switchboard *sb, char *text )  	}  } -void msn_sb_to_chat( struct msn_switchboard *sb ) +struct conversation *msn_sb_to_chat( struct msn_switchboard *sb )  {  	struct gaim_connection *gc = sb->gc;  	char buf[1024];  	/* Create the groupchat structure. */  	g_snprintf( buf, sizeof( buf ), "MSN groupchat session %d", sb->session ); -	sb->chat = serv_got_joined_chat( gc, ++msn_chat_id, buf ); +	sb->chat = serv_got_joined_chat( gc, buf );  	/* Populate the channel. */  	if( sb->who ) add_chat_buddy( sb->chat, sb->who ); @@ -195,6 +195,8 @@ void msn_sb_to_chat( struct msn_switchboard *sb )  		g_free( sb->who );  		sb->who = NULL;  	} +	 +	return sb->chat;  }  void msn_sb_destroy( struct msn_switchboard *sb ) @@ -229,7 +231,7 @@ void msn_sb_destroy( struct msn_switchboard *sb )  	if( sb->chat )  	{ -		serv_got_chat_left( gc, sb->chat->id ); +		serv_got_chat_left( sb->chat );  	}  	if( sb->handler ) @@ -371,7 +373,7 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts )  			if( num == 1 )  			{  				g_snprintf( buf, sizeof( buf ), "MSN groupchat session %d", sb->session ); -				sb->chat = serv_got_joined_chat( gc, ++msn_chat_id, buf ); +				sb->chat = serv_got_joined_chat( gc, buf );  				g_free( sb->who );  				sb->who = NULL; @@ -609,7 +611,7 @@ static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int  			}  			else if( sb->chat )  			{ -				serv_got_chat_in( gc, sb->chat->id, cmd[1], 0, body, 0 ); +				serv_got_chat_in( sb->chat, cmd[1], 0, body, 0 );  			}  			else  			{ @@ -668,7 +670,7 @@ static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int  			}  			else if( sb->chat )  			{ -				serv_got_chat_in( gc, sb->chat->id, cmd[1], 0, buf, 0 ); +				serv_got_chat_in( sb->chat, cmd[1], 0, buf, 0 );  			}  			else  			{ diff --git a/protocols/nogaim.c b/protocols/nogaim.c index b627a23a..e983352f 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -681,15 +681,14 @@ void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int  	}  } -void serv_got_chat_left( struct gaim_connection *gc, int id ) +void serv_got_chat_left( struct conversation *c )  { -	struct conversation *c, *l = NULL; +	struct gaim_connection *gc = c->gc; +	struct conversation *l = NULL;  	GList *ir;  	if( set_getbool( &gc->irc->set, "debug" ) ) -		serv_got_crap( gc, "You were removed from conversation %d", (int) id ); -	 -	for( c = gc->conversations; c && c->id != id; c = (l=c)->next ); +		serv_got_crap( gc, "You were removed from conversation 0x%x", (int) c );  	if( c )  	{ @@ -719,9 +718,9 @@ void serv_got_chat_left( struct gaim_connection *gc, int id )  	}  } -void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whisper, char *msg, time_t mtime ) +void serv_got_chat_in( struct conversation *c, char *who, int whisper, char *msg, time_t mtime )  { -	struct conversation *c; +	struct gaim_connection *gc = c->gc;  	user_t *u;  	/* Gaim sends own messages through this too. IRC doesn't want this, so kill them */ @@ -729,7 +728,6 @@ void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whispe  		return;  	u = user_findhandle( gc, who ); -	for( c = gc->conversations; c && c->id != id; c = c->next );  	if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||  	    ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) ) @@ -738,13 +736,12 @@ void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whispe  	if( c && u )  		irc_privmsg( gc->irc, u, "PRIVMSG", c->channel, "", msg );  	else -		serv_got_crap( gc, "Message from/to conversation %s@%d (unknown conv/user): %s", who, id, msg ); +		serv_got_crap( gc, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg );  } -struct conversation *serv_got_joined_chat( struct gaim_connection *gc, int id, char *handle ) +struct conversation *serv_got_joined_chat( struct gaim_connection *gc, char *handle )  {  	struct conversation *c; -	char *s;  	/* This one just creates the conversation structure, user won't see anything yet */ @@ -754,21 +751,16 @@ struct conversation *serv_got_joined_chat( struct gaim_connection *gc, int id, c  		c = c->next = g_new0( struct conversation, 1 );  	}  	else -		gc->conversations = c = g_new0( struct conversation, 1); +		gc->conversations = c = g_new0( struct conversation, 1 ); -	c->id = id;  	c->gc = gc;  	c->title = g_strdup( handle ); -	 -	s = g_new( char, 16 ); -	sprintf( s, "&chat_%03d", gc->irc->c_id++ ); -	c->channel = g_strdup( s ); -	g_free( s ); +	c->channel = g_strdup_printf( "&chat_%03d", gc->irc->c_id++ );  	if( set_getbool( &gc->irc->set, "debug" ) ) -		serv_got_crap( gc, "Creating new conversation: (id=%d,handle=%s)", id, handle ); +		serv_got_crap( gc, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle ); -	return( c ); +	return c;  } @@ -780,7 +772,7 @@ void add_chat_buddy( struct conversation *b, char *handle )  	int me = 0;  	if( set_getbool( &b->gc->irc->set, "debug" ) ) -		serv_got_crap( b->gc, "User %s added to conversation %d", handle, b->id ); +		serv_got_crap( b->gc, "User %s added to conversation 0x%x", handle, (int) b );  	/* It might be yourself! */  	if( b->gc->acc->prpl->handle_cmp( handle, b->gc->username ) == 0 ) @@ -814,7 +806,7 @@ void remove_chat_buddy( struct conversation *b, char *handle, char *reason )  	int me = 0;  	if( set_getbool( &b->gc->irc->set, "debug" ) ) -		serv_got_crap( b->gc, "User %s removed from conversation %d (%s)", handle, b->id, reason ? reason : "" ); +		serv_got_crap( b->gc, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" );  	/* It might be yourself! */  	if( g_strcasecmp( handle, b->gc->username ) == 0 ) @@ -857,7 +849,7 @@ static int remove_chat_buddy_silent( struct conversation *b, char *handle )  /* Misc. BitlBee stuff which shouldn't really be here */ -struct conversation *conv_findchannel( char *channel ) +struct conversation *chat_by_channel( char *channel )  {  	struct gaim_connection *gc;  	struct conversation *c; @@ -869,10 +861,10 @@ struct conversation *conv_findchannel( char *channel )  		gc = l->data;  		for( c = gc->conversations; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next );  		if( c ) -			return( c ); +			return c;  	} -	return( NULL ); +	return NULL;  }  char *set_eval_away_devoice( set_t *set, char *value ) @@ -957,18 +949,18 @@ int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flag  	return st;  } -int bim_chat_msg( struct gaim_connection *gc, int id, char *msg ) +int bim_chat_msg( struct conversation *c, char *msg )  {  	char *buf = NULL;  	int st; -	if( ( gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) ) +	if( ( c->gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )  	{  		buf = escape_html( msg );  		msg = buf;  	} -	st = gc->acc->prpl->chat_send( gc, id, msg ); +	st = c->gc->acc->prpl->chat_send( c, msg );  	g_free( buf );  	return st; diff --git a/protocols/nogaim.h b/protocols/nogaim.h index bae4489f..6afa1801 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -99,26 +99,25 @@ struct conversation {  	struct gaim_connection *gc;  	/* stuff used just for chat */ -        GList *in_room; -        GList *ignored; -        int id; -         -        /* BitlBee */ -        struct conversation *next; -        char *channel; -        char *title; -        char joined; -        void *data; +	GList *in_room; +	GList *ignored; +	 +	/* BitlBee */ +	struct conversation *next; +	char *channel; +	char *title; +	char joined; +	void *data;  };  struct buddy {  	char name[80];  	char show[BUDDY_ALIAS_MAXLEN]; -        int present; +	int present;  	int evil;  	time_t signon;  	time_t idle; -        int uc; +	int uc;  	guint caps; /* woohoo! */  	void *proto_data; /* what a hack */  	struct gaim_connection *gc; /* the connection it belongs to */ @@ -152,11 +151,13 @@ struct prpl {  	void (* alias_buddy)	(struct gaim_connection *, char *who);	/* save/store buddy's alias on server list/roster */  	/* Group chat stuff. */ -	void (* join_chat)	(struct gaim_connection *, GList *data); -	void (* chat_invite)	(struct gaim_connection *, int id, char *who, char *message); -	void (* chat_leave)	(struct gaim_connection *, int id); -	int  (* chat_send)	(struct gaim_connection *, int id, char *message); -	int  (* chat_open)	(struct gaim_connection *, char *who); +	void (* chat_invite)	(struct conversation *, char *who, char *message); +	void (* chat_leave)	(struct conversation *); +	int  (* chat_send)	(struct conversation *, char *message); +	struct conversation * +	     (* chat_open)	(struct gaim_connection *, char *who); +	struct conversation * +	     (* chat_join)	(struct gaim_connection *, char *chat, char *nick, char *password);  	/* DIE! */  	char *(* get_status_string) (struct gaim_connection *gc, int stat); @@ -182,7 +183,7 @@ G_MODULE_EXPORT void register_protocol(struct prpl *);  /* nogaim.c */  int bim_set_away( struct gaim_connection *gc, char *away );  int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags ); -int bim_chat_msg( struct gaim_connection *gc, int id, char *msg ); +int bim_chat_msg( struct conversation *c, char *msg );  void bim_add_allow( struct gaim_connection *gc, char *handle );  void bim_rem_allow( struct gaim_connection *gc, char *handle ); @@ -223,15 +224,16 @@ G_MODULE_EXPORT void remove_chat_buddy( struct conversation *b, char *handle, ch  /* prpl.c */  G_MODULE_EXPORT void show_got_added( struct gaim_connection *gc, char *handle, const char *realname ); -/* server.c */                     +/* server.c */  G_MODULE_EXPORT void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps );  G_MODULE_EXPORT void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 flags, time_t mtime, gint len );  G_MODULE_EXPORT void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int type );  G_MODULE_EXPORT void serv_got_chat_invite( struct gaim_connection *gc, char *handle, char *who, char *msg, GList *data ); -G_MODULE_EXPORT struct conversation *serv_got_joined_chat( struct gaim_connection *gc, int id, char *handle ); -G_MODULE_EXPORT void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whisper, char *msg, time_t mtime ); -G_MODULE_EXPORT void serv_got_chat_left( struct gaim_connection *gc, int id ); +G_MODULE_EXPORT struct conversation *serv_got_joined_chat( struct gaim_connection *gc, char *handle ); +G_MODULE_EXPORT void serv_got_chat_in( struct conversation *c, char *who, int whisper, char *msg, time_t mtime ); +G_MODULE_EXPORT void serv_got_chat_left( struct conversation *c ); -struct conversation *conv_findchannel( char *channel ); +struct conversation *chat_by_channel( char *channel ); +struct conversation *chat_by_id( int id );  #endif diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 72078b3c..05539442 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -157,22 +157,6 @@ static char *extract_name(const char *name) {  	return tmp;  } -static struct chat_connection *find_oscar_chat(struct gaim_connection *gc, int id) { -	GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; -	struct chat_connection *c = NULL; - -	while (g) { -		c = (struct chat_connection *)g->data; -		if (c->id == id) -			break; -		g = g->next; -		c = NULL; -	} - -	return c; -} - -  static struct chat_connection *find_oscar_chat_by_conn(struct gaim_connection *gc,  							aim_conn_t *conn) {  	GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; @@ -768,7 +752,8 @@ static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) {  	chatcon = find_oscar_chat_by_conn(gc, fr->conn);  	chatcon->id = id; -	chatcon->cnv = serv_got_joined_chat(gc, id++, chatcon->show); +	chatcon->cnv = serv_got_joined_chat(gc, chatcon->show); +	chatcon->cnv->data = chatcon;  	return 1;  } @@ -1579,7 +1564,7 @@ static int gaim_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) {  	tmp = g_malloc(BUF_LONG);  	g_snprintf(tmp, BUF_LONG, "%s", msg); -	serv_got_chat_in(gc, ccon->id, info->sn, 0, tmp, time((time_t)NULL)); +	serv_got_chat_in(ccon->cnv, info->sn, 0, tmp, time((time_t)NULL));  	g_free(tmp);  	return 1; @@ -2520,8 +2505,9 @@ int oscar_send_typing(struct gaim_connection *gc, char * who, int typing)  	return( aim_im_sendmtn(od->sess, 1, who, typing ? 0x0002 : 0x0000) );  } -int oscar_chat_send(struct gaim_connection * gc, int id, char *message) +int oscar_chat_send(struct conversation *c, char *message)  { +	struct gaim_connection *gc = c->gc;  	struct oscar_data * od = (struct oscar_data*)gc->proto_data;  	struct chat_connection * ccon;  	int ret; @@ -2529,8 +2515,7 @@ int oscar_chat_send(struct gaim_connection * gc, int id, char *message)  	guint16 flags;  	char *s; -	if(!(ccon = find_oscar_chat(gc, id))) -		return -1; +	ccon = c->data;  	for (s = message; *s; s++)  		if (*s & 128) @@ -2567,13 +2552,11 @@ int oscar_chat_send(struct gaim_connection * gc, int id, char *message)    return (ret >= 0);  } -void oscar_chat_invite(struct gaim_connection * gc, int id, char *message, char *who) +void oscar_chat_invite(struct conversation *c, char *message, char *who)  { +	struct gaim_connection *gc = c->gc;  	struct oscar_data * od = (struct oscar_data *)gc->proto_data; -	struct chat_connection *ccon = find_oscar_chat(gc, id); -	 -	if (ccon == NULL) -		return; +	struct chat_connection *ccon = c->data;  	aim_chat_invite(od->sess, od->conn, who, message ? message : "",  					ccon->exchange, ccon->name, 0x0); @@ -2584,7 +2567,7 @@ void oscar_chat_kill(struct gaim_connection *gc, struct chat_connection *cc)  	struct oscar_data *od = (struct oscar_data *)gc->proto_data;  	/* Notify the conversation window that we've left the chat */ -	serv_got_chat_left(gc, cc->id); +	serv_got_chat_left(cc->cnv);  	/* Destroy the chat_connection */  	od->oscar_chats = g_slist_remove(od->oscar_chats, cc); @@ -2596,19 +2579,14 @@ void oscar_chat_kill(struct gaim_connection *gc, struct chat_connection *cc)  	g_free(cc);  } -void oscar_chat_leave(struct gaim_connection * gc, int id) +void oscar_chat_leave(struct conversation *c)  { -	struct chat_connection * ccon = find_oscar_chat(gc, id); - -	if(ccon == NULL) -		return; - -	oscar_chat_kill(gc, ccon); +	oscar_chat_kill(c->gc, c->data);  }  int oscar_chat_join(struct gaim_connection * gc, char * name)  { -    struct oscar_data * od = (struct oscar_data *)gc->proto_data; +	struct oscar_data * od = (struct oscar_data *)gc->proto_data;  	aim_conn_t * cur; @@ -2626,7 +2604,7 @@ int oscar_chat_join(struct gaim_connection * gc, char * name)  	}  } -int oscar_chat_open(struct gaim_connection * gc, char *who) +struct conversation *oscar_chat_open(struct gaim_connection * gc, char *who)  {  	struct oscar_data * od = (struct oscar_data *)gc->proto_data;  	int ret; @@ -2641,7 +2619,7 @@ int oscar_chat_open(struct gaim_connection * gc, char *who)  	g_free(chatname); -	return ret; +	return NULL;  }  void oscar_accept_chat(gpointer w, struct aim_chat_invitation * inv) diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 6f286196..e0dcabff 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -139,7 +139,7 @@ static void byahoo_close( struct gaim_connection *gc )  	GSList *l;  	while( gc->conversations ) -		serv_got_chat_left( gc, gc->conversations->id ); +		serv_got_chat_left( gc->conversations );  	for( l = yd->buddygroups; l; l = l->next )  	{ @@ -331,40 +331,31 @@ static char *byahoo_get_status_string( struct gaim_connection *gc, int stat )  	}  } -static int byahoo_chat_send( struct gaim_connection *gc, int id, char *message ) +static int byahoo_chat_send( struct conversation *c, char *message )  { -	struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data; -	struct conversation *c; +	struct byahoo_data *yd = (struct byahoo_data *) c->gc->proto_data; -	for( c = gc->conversations; c && c->id != id; c = c->next ); -  	yahoo_conference_message( yd->y2_id, NULL, c->data, c->title, message, 1 );  	return( 0 );  } -static void byahoo_chat_invite( struct gaim_connection *gc, int id, char *msg, char *who ) +static void byahoo_chat_invite( struct conversation *c, char *msg, char *who )  { -	struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data; -	struct conversation *c; -	 -	for( c = gc->conversations; c && c->id != id; c = c->next ); +	struct byahoo_data *yd = (struct byahoo_data *) c->gc->proto_data;  	yahoo_conference_invite( yd->y2_id, NULL, c->data, c->title, msg );  } -static void byahoo_chat_leave( struct gaim_connection *gc, int id ) +static void byahoo_chat_leave( struct conversation *c )  { -	struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data; -	struct conversation *c; -	 -	for( c = gc->conversations; c && c->id != id; c = c->next ); +	struct byahoo_data *yd = (struct byahoo_data *) c->gc->proto_data;  	yahoo_conference_logoff( yd->y2_id, NULL, c->data, c->title ); -	serv_got_chat_left( gc, c->id ); +	serv_got_chat_left( c );  } -static int byahoo_chat_open( struct gaim_connection *gc, char *who ) +static struct conversation *byahoo_chat_open( struct gaim_connection *gc, char *who )  {  	struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;  	struct conversation *c; @@ -374,7 +365,7 @@ static int byahoo_chat_open( struct gaim_connection *gc, char *who )  	roomname = g_new0( char, strlen( gc->username ) + 16 );  	g_snprintf( roomname, strlen( gc->username ) + 16, "%s-Bee-%d", gc->username, byahoo_chat_id ); -	c = serv_got_joined_chat( gc, ++byahoo_chat_id, roomname ); +	c = serv_got_joined_chat( gc, roomname );  	add_chat_buddy( c, gc->username );  	/* FIXME: Free this thing when the chat's destroyed. We can't *always* @@ -386,7 +377,7 @@ static int byahoo_chat_open( struct gaim_connection *gc, char *who )  	g_free( roomname ); -	return( 1 ); +	return c;  }  void byahoo_init( ) @@ -804,7 +795,7 @@ static void byahoo_accept_conf( gpointer w, struct byahoo_conf_invitation *inv )  static void byahoo_reject_conf( gpointer w, struct byahoo_conf_invitation *inv )  {  	yahoo_conference_decline( inv->yid, NULL, inv->members, inv->name, "User rejected groupchat" ); -	serv_got_chat_left( inv->gc, inv->c->id ); +	serv_got_chat_left( inv->c );  	g_free( inv->name );  	g_free( inv );  } @@ -819,7 +810,7 @@ void ext_yahoo_got_conf_invite( int id, char *who, char *room, char *msg, YList  	inv = g_malloc( sizeof( struct byahoo_conf_invitation ) );  	memset( inv, 0, sizeof( struct byahoo_conf_invitation ) );  	inv->name = g_strdup( room ); -	inv->c = serv_got_joined_chat( gc, ++byahoo_chat_id, room ); +	inv->c = serv_got_joined_chat( gc, room );  	inv->c->data = members;  	inv->yid = id;  	inv->members = members; @@ -871,7 +862,8 @@ void ext_yahoo_conf_message( int id, char *who, char *room, char *msg, int utf8  	for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); -	serv_got_chat_in( gc, c ? c->id : 0, who, 0, m, 0 ); +	if( c ) +		serv_got_chat_in( c, who, 0, m, 0 );  	g_free( m );  } diff --git a/root_commands.c b/root_commands.c index 116f1d06..ff2d8b37 100644 --- a/root_commands.c +++ b/root_commands.c @@ -884,6 +884,53 @@ static void cmd_qlist( irc_t *irc, char **cmd )  			irc_usermsg( irc, "%d, BitlBee: %s", num, q->question );  } +static void cmd_join_chat( irc_t *irc, char **cmd ) +{ +	account_t *a; +	struct gaim_connection *gc; +	char *chat, *channel, *nick = NULL, *password = NULL; +	struct conversation *c; +	 +	if( !( a = account_get( irc, cmd[1] ) ) ) +	{ +		irc_usermsg( irc, "Invalid account" ); +		return; +	} +	else if( !( a->gc && ( a->gc->flags & OPT_LOGGED_IN ) ) ) +	{ +		irc_usermsg( irc, "That account is not on-line" ); +		return; +	} +	else if( a->prpl->chat_join == NULL ) +	{ +		irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); +		return; +	} +	gc = a->gc; +	 +	chat = cmd[2]; +	if( cmd[3] ) +	{ +		channel = g_strdup( cmd[3] ); +	} +	else +	{ +		char *s; +		 +		channel = g_strdup( chat ); +		if( ( s = strchr( channel, '@' ) ) ) +			*s = 0; +	} +	if( cmd[3] && cmd[4] ) +		nick = cmd[4]; +	if( cmd[3] && cmd[4] && cmd[5] ) +		password = cmd[5]; +	 +	c = a->prpl->chat_join( gc, chat, nick, password ); +	 +	g_free( channel ); +} +  const command_t commands[] = {  	{ "help",           0, cmd_help,           0 },   	{ "identify",       1, cmd_identify,       0 }, @@ -903,5 +950,6 @@ const command_t commands[] = {  	{ "blist",          0, cmd_blist,          0 },  	{ "nick",           1, cmd_nick,           0 },  	{ "qlist",          0, cmd_qlist,          0 }, +	{ "join_chat",      2, cmd_join_chat,      0 },  	{ NULL }  }; | 
