diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-05-14 00:34:38 +0100 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-05-14 00:34:38 +0100 | 
| commit | 7b71feb6f88b7e14199b8f7e9930f76d5324e356 (patch) | |
| tree | 2aadf040f7c2b29d6457fbf2ca265a804c75a193 | |
| parent | ad404ab26aa3cfdfc3c76f6926e556e333d02753 (diff) | |
Just enough code to join named chatrooms again. This UI is *not* final, the "chat"
command will probably mostly stick around for bw compatibility. Still thinking
about how this should work eventually.
| -rw-r--r-- | irc.h | 6 | ||||
| -rw-r--r-- | irc_channel.c | 20 | ||||
| -rw-r--r-- | irc_commands.c | 8 | ||||
| -rw-r--r-- | root_commands.c | 64 | 
4 files changed, 43 insertions, 55 deletions
| @@ -194,6 +194,12 @@ struct irc_control_channel  	struct account *account;  }; +struct irc_groupchat_stub +{ +	struct account *acc; +	char *room; +}; +  extern const struct bee_ui_funcs irc_ui_funcs;  /* irc.c */ diff --git a/irc_channel.c b/irc_channel.c index 28cd7d43..a3a7e1ee 100644 --- a/irc_channel.c +++ b/irc_channel.c @@ -312,9 +312,27 @@ static gboolean groupchat_stub_invite( irc_channel_t *ic, irc_user_t *iu )  	}  } +static gboolean groupchat_stub_join( irc_channel_t *ic ) +{ +	struct irc_groupchat_stub *igs = ic->data; +	 +	if( igs && igs->acc->ic && igs->acc->prpl->chat_join ) +	{ +		ic->flags |= IRC_CHANNEL_CHAT_PICKME; +		igs->acc->prpl->chat_join( igs->acc->ic, igs->room, ic->irc->user->nick, NULL ); +		ic->flags &= ~IRC_CHANNEL_CHAT_PICKME; +		return FALSE; +	} +	else +	{ +		irc_send_num( ic->irc, 403, "%s :Can't join channel, account offline?", ic->name ); +		return FALSE; +	} +} +  static const struct irc_channel_funcs groupchat_stub_funcs = {  	NULL, -	NULL, +	groupchat_stub_join,  	NULL,  	NULL,  	groupchat_stub_invite, diff --git a/irc_commands.c b/irc_commands.c index e6954071..530e849b 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -139,6 +139,14 @@ static void irc_cmd_join( irc_t *irc, char **cmd )  		return; /* Dude, you're already there...  		           RFC doesn't have any reply for that though? */ +	if( ic->f->join && !ic->f->join( ic ) ) +		/* The story is: FALSE either means the handler showed an error +		   message, or is doing some work before the join should be +		   confirmed. (In the latter case, the caller should take care +		   of that confirmation.) +		   TRUE means all's good, let the user join the channel right away. */ +		return; +	  	irc_channel_add_user( ic, irc->user );  } diff --git a/root_commands.c b/root_commands.c index aeb4f62a..65f3de9a 100644 --- a/root_commands.c +++ b/root_commands.c @@ -939,17 +939,6 @@ static void cmd_qlist( irc_t *irc, char **cmd )  			irc_usermsg( irc, "%d, BitlBee: %s", num, q->question );  } -#if 0 -static set_t **cmd_chat_set_findhead( irc_t *irc, char *id ) -{ -	struct chat *c; -	 -	if( ( c = chat_get( irc, id ) ) ) -		return &c->set; -	else -		return NULL; -} -  static void cmd_chat( irc_t *irc, char **cmd )  {  	account_t *acc; @@ -958,10 +947,11 @@ static void cmd_chat( irc_t *irc, char **cmd )  	if( g_strcasecmp( cmd[1], "add" ) == 0 )  	{  		char *channel, *s; +		struct irc_channel *ic;  		MIN_ARGS( 3 ); -		if( !( acc = account_get( irc, cmd[2] ) ) ) +		if( !( acc = account_get( irc->b, cmd[2] ) ) )  		{  			irc_usermsg( irc, "Invalid account" );  			return; @@ -980,53 +970,21 @@ static void cmd_chat( irc_t *irc, char **cmd )  		if( strchr( CTYPES, channel[0] ) == NULL )  		{ -			s = g_strdup_printf( "%c%s", CTYPES[0], channel ); +			s = g_strdup_printf( "#%s", channel );  			g_free( channel );  			channel = s;  		} -		if( ( c = chat_add( irc, acc, cmd[3], channel ) ) ) -			irc_usermsg( irc, "Chatroom added successfully." ); -		else -			irc_usermsg( irc, "Could not add chatroom." ); -		 -		g_free( channel ); -	} -	else if( g_strcasecmp( cmd[1], "list" ) == 0 ) -	{ -		int i = 0; -		 -		if( strchr( irc->umode, 'b' ) ) -			irc_usermsg( irc, "Chatroom list:" ); -		 -		for( c = irc->chatrooms; c; c = c->next ) +		if( ( ic = irc_channel_new( irc, channel ) ) )  		{ -			irc_usermsg( irc, "%2d. %s(%s) %s, %s", i, c->acc->prpl->name, -			                  c->acc->user, c->handle, c->channel ); +			struct irc_groupchat_stub *igs; -			i ++; -		} -		irc_usermsg( irc, "End of chatroom list" ); -	} -	else if( g_strcasecmp( cmd[1], "set" ) == 0 ) -	{ -		MIN_ARGS( 2 ); -		 -		cmd_set_real( irc, cmd + 1, cmd_chat_set_findhead, NULL ); -	} -	else if( g_strcasecmp( cmd[1], "del" ) == 0 ) -	{ -		MIN_ARGS( 2 ); -		 -		if( ( c = chat_get( irc, cmd[2] ) ) ) -		{ -			chat_del( irc, c ); -		} -		else -		{ -			irc_usermsg( irc, "Could not remove chat." ); +			ic->data = igs = g_new0( struct irc_groupchat_stub, 1 ); +			igs->acc = acc; +			igs->room = g_strdup( cmd[3] );  		}  	} +	/*  	else if( g_strcasecmp( cmd[1], "with" ) == 0 )  	{  		user_t *u; @@ -1046,12 +1004,12 @@ static void cmd_chat( irc_t *irc, char **cmd )  			irc_usermsg( irc, "Can't open a groupchat with %s.", cmd[2] );  		}  	} +	*/  	else  	{  		irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "chat", cmd[1] );  	}  } -#endif  static void cmd_transfer( irc_t *irc, char **cmd )  { @@ -1136,8 +1094,6 @@ const command_t commands[] = {  	{ "set",            0, cmd_set,            0 },  	{ "transfer",       0, cmd_transfer,       0 },  	{ "yes",            0, cmd_yesno,          0 }, -#if 0  	{ "chat",           1, cmd_chat,           0 }, -#endif  	{ NULL }  }; | 
