CHANNEL_REC->get_join_data() - Returns the information needed to call

SERVER_REC->channels_join() for this channel. Usually just the channel name,
but may contain also the channel key.

If we receive PART-message to channel that hasn't received a JOIN yet,
don't destroy the channel. It's probably because we did quickly /PART +
/JOIN.

Moved /CYCLE to fe-common/core, it doesn't close the window for the cycled
channel anymore if you had autoclosing on.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1484 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-05-11 16:08:48 +00:00 committed by cras
commit 1f23c05ee7
7 changed files with 74 additions and 43 deletions

View file

@ -249,7 +249,7 @@ static void event_part(IRC_SERVER_REC *server, const char *data, const char *nic
params = event_get_params(data, 2, &channel, &reason);
chanrec = channel_find(SERVER(server), channel);
if (chanrec != NULL) {
if (chanrec != NULL && chanrec->joined) {
chanrec->left = TRUE;
channel_destroy(chanrec);
}

View file

@ -62,18 +62,6 @@ IRC_CHANNEL_REC *irc_channel_create(IRC_SERVER_REC *server,
return rec;
}
static void sig_channel_destroyed(IRC_CHANNEL_REC *channel)
{
if (!IS_IRC_CHANNEL(channel))
return;
if (channel->server != NULL && !channel->left && !channel->kicked) {
/* destroying channel record without actually
having left the channel yet */
signal_emit("command part", 3, "", channel->server, channel);
}
}
#define get_join_key(key) \
(((key) == NULL || *(key) == '\0') ? "x" : (key))
@ -185,9 +173,36 @@ static void sig_server_looking(SERVER_REC *server)
irc_channels_join;
}
static char *irc_get_join_data(CHANNEL_REC *channel)
{
IRC_CHANNEL_REC *irc_channel = (IRC_CHANNEL_REC *) channel;
return irc_channel->key == NULL ? g_strdup(irc_channel->name) :
g_strconcat(irc_channel->name, " ", irc_channel->key, NULL);
}
static void sig_channel_created(IRC_CHANNEL_REC *channel)
{
if (IS_IRC_CHANNEL(channel))
channel->get_join_data = irc_get_join_data;
}
static void sig_channel_destroyed(IRC_CHANNEL_REC *channel)
{
if (!IS_IRC_CHANNEL(channel))
return;
if (channel->server != NULL && !channel->left && !channel->kicked) {
/* destroying channel record without actually
having left the channel yet */
signal_emit("command part", 3, "", channel->server, channel);
}
}
void irc_channels_init(void)
{
signal_add("server looking", (SIGNAL_FUNC) sig_server_looking);
signal_add("channel created", (SIGNAL_FUNC) sig_channel_created);
signal_add("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
channel_events_init();
@ -205,6 +220,7 @@ void irc_channels_init(void)
void irc_channels_deinit(void)
{
signal_remove("server looking", (SIGNAL_FUNC) sig_server_looking);
signal_remove("channel created", (SIGNAL_FUNC) sig_channel_created);
signal_remove("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
channel_events_deinit();

View file

@ -664,32 +664,6 @@ static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item
cmd_params_free(free_arg);
}
/* SYNTAX: CYCLE [<channel>] [<message>] */
static void cmd_cycle(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
{
IRC_CHANNEL_REC *chanrec;
char *channame, *msg;
void *free_arg;
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN, item, &channame, &msg))
return;
if (*channame == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
chanrec = irc_channel_find(server, channame);
if (chanrec == NULL) cmd_param_error(CMDERR_CHAN_NOT_FOUND);
irc_send_cmdv(server, *msg == '\0' ? "PART %s" : "PART %s :%s",
channame, msg);
irc_send_cmdv(server, chanrec->key == NULL ? "JOIN %s" : "JOIN %s %s",
channame, chanrec->key);
cmd_params_free(free_arg);
}
/* SYNTAX: KICKBAN [<channel>] <nicks> <reason> */
static void cmd_kickban(const char *data, IRC_SERVER_REC *server,
WI_ITEM_REC *item)
@ -733,7 +707,7 @@ static void cmd_kickban(const char *data, IRC_SERVER_REC *server,
}
g_free(kickcmd);
g_free(bancmd);
cmd_params_free(free_arg);
}
@ -1074,7 +1048,6 @@ void irc_commands_init(void)
command_bind("wallops", NULL, (SIGNAL_FUNC) command_1self);
/* SYNTAX: WALLCHOPS <channel> <message> */
command_bind("wallchops", NULL, (SIGNAL_FUNC) command_2self);
command_bind("cycle", NULL, (SIGNAL_FUNC) cmd_cycle);
command_bind("kickban", NULL, (SIGNAL_FUNC) cmd_kickban);
command_bind("knockout", NULL, (SIGNAL_FUNC) cmd_knockout);
@ -1146,7 +1119,6 @@ void irc_commands_deinit(void)
command_unbind("wait", (SIGNAL_FUNC) cmd_wait);
command_unbind("wallops", (SIGNAL_FUNC) command_1self);
command_unbind("wallchops", (SIGNAL_FUNC) command_2self);
command_unbind("cycle", (SIGNAL_FUNC) cmd_cycle);
command_unbind("kickban", (SIGNAL_FUNC) cmd_kickban);
command_unbind("knockout", (SIGNAL_FUNC) cmd_knockout);
signal_remove("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);