diff options
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/core/channel-events.c | 2 | ||||
-rw-r--r-- | src/irc/core/irc-channels.c | 30 | ||||
-rw-r--r-- | src/irc/core/irc-channels.h | 4 | ||||
-rw-r--r-- | src/irc/core/irc-commands.c | 22 | ||||
-rw-r--r-- | src/irc/core/irc-core.c | 3 | ||||
-rw-r--r-- | src/irc/core/modes.c | 7 | ||||
-rw-r--r-- | src/irc/core/netsplit.c | 2 |
7 files changed, 47 insertions, 23 deletions
diff --git a/src/irc/core/channel-events.c b/src/irc/core/channel-events.c index aa80a0f5..a296938d 100644 --- a/src/irc/core/channel-events.c +++ b/src/irc/core/channel-events.c @@ -254,7 +254,7 @@ static void event_join(IRC_SERVER_REC *server, const char *data, const char *nic chanrec = channel_find_unjoined(server, channel); if (chanrec == NULL) { /* didn't get here with /join command.. */ - chanrec = irc_channel_create(server, channel, TRUE); + chanrec = irc_channel_create(server, channel, NULL, TRUE); } chanrec->joined = TRUE; if (strcmp(chanrec->name, channel) != 0) { diff --git a/src/irc/core/irc-channels.c b/src/irc/core/irc-channels.c index 59726d22..3e6b2378 100644 --- a/src/irc/core/irc-channels.c +++ b/src/irc/core/irc-channels.c @@ -44,21 +44,37 @@ void irc_channels_setup_deinit(void); void massjoin_init(void); void massjoin_deinit(void); -IRC_CHANNEL_REC *irc_channel_create(IRC_SERVER_REC *server, - const char *name, int automatic) +IRC_CHANNEL_REC *irc_channel_create(IRC_SERVER_REC *server, const char *name, + const char *visible_name, int automatic) { IRC_CHANNEL_REC *rec; + char *new_name; g_return_val_if_fail(server == NULL || IS_IRC_SERVER(server), NULL); g_return_val_if_fail(name != NULL, NULL); rec = g_new0(IRC_CHANNEL_REC, 1); - rec->chat_type = IRC_PROTOCOL; - rec->name = g_strdup(name); - rec->server = server; if (*name == '+') rec->no_modes = TRUE; - channel_init((CHANNEL_REC *) rec, automatic); + new_name = NULL; + if (visible_name == NULL) { + /* !?????channel -> !channel */ + new_name = *name == '!' && strlen(name) >= 1+5 ? + g_strconcat("!", name+1+5, NULL) : + g_strdup(name); + + if (irc_channel_find(server, new_name) != NULL) { + /* this was second !channel with same name, + show the channel id after all */ + g_free_and_null(new_name); + } + + visible_name = new_name; + } + + channel_init((CHANNEL_REC *) rec, (SERVER_REC *) server, + name, visible_name, automatic); + g_free(new_name); return rec; } @@ -112,7 +128,7 @@ static void irc_channels_join(IRC_SERVER_REC *server, const char *data, g_string_sprintfa(outkeys, "%s,", get_join_key(key)); channame = channel + (channel[0] == '!' && channel[1] == '!'); - chanrec = irc_channel_create(server, channame, + chanrec = irc_channel_create(server, channame, NULL, automatic); if (key != NULL) chanrec->key = g_strdup(key); } diff --git a/src/irc/core/irc-channels.h b/src/irc/core/irc-channels.h index 13a61908..8cfc4992 100644 --- a/src/irc/core/irc-channels.h +++ b/src/irc/core/irc-channels.h @@ -26,8 +26,8 @@ void irc_channels_init(void); void irc_channels_deinit(void); /* Create new IRC channel record */ -IRC_CHANNEL_REC *irc_channel_create(IRC_SERVER_REC *server, - const char *name, int automatic); +IRC_CHANNEL_REC *irc_channel_create(IRC_SERVER_REC *server, const char *name, + const char *visible_name, int automatic); #define irc_channel_find(server, name) \ IRC_CHANNEL(channel_find(SERVER(server), name)) diff --git a/src/irc/core/irc-commands.c b/src/irc/core/irc-commands.c index 64b31509..d7512de2 100644 --- a/src/irc/core/irc-commands.c +++ b/src/irc/core/irc-commands.c @@ -62,7 +62,7 @@ static int knockout_tag; static void cmd_notice(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item) { - char *target, *msg; + const char *target, *msg; void *free_arg; CMD_IRC_SERVER(server); @@ -71,7 +71,7 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server, &target, &msg)) return; if (strcmp(target, "*") == 0) - target = item == NULL ? NULL : item->name; + target = item == NULL ? NULL : window_item_get_target(item); if (*target == '\0' || *msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); @@ -85,7 +85,8 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server, static void cmd_ctcp(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item) { - char *target, *ctcpcmd, *ctcpdata; + const char *target; + char *ctcpcmd, *ctcpdata; void *free_arg; CMD_IRC_SERVER(server); @@ -94,7 +95,7 @@ static void cmd_ctcp(const char *data, IRC_SERVER_REC *server, &target, &ctcpcmd, &ctcpdata)) return; if (strcmp(target, "*") == 0) - target = item == NULL ? NULL : item->name; + target = item == NULL ? NULL : window_item_get_target(item); if (*target == '\0' || *ctcpcmd == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); @@ -112,7 +113,8 @@ static void cmd_ctcp(const char *data, IRC_SERVER_REC *server, static void cmd_nctcp(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item) { - char *target, *ctcpcmd, *ctcpdata; + const char *target; + char *ctcpcmd, *ctcpdata; void *free_arg; CMD_IRC_SERVER(server); @@ -121,7 +123,7 @@ static void cmd_nctcp(const char *data, IRC_SERVER_REC *server, &target, &ctcpcmd, &ctcpdata)) return; if (strcmp(target, "*") == 0) - target = item == NULL ? NULL : item->name; + target = item == NULL ? NULL : window_item_get_target(item); if (*target == '\0' || *ctcpcmd == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); @@ -216,7 +218,7 @@ static void cmd_invite(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *it if (!IS_IRC_CHANNEL(item)) cmd_param_error(CMDERR_NOT_JOINED); - channame = item->name; + channame = IRC_CHANNEL(item)->name; } irc_send_cmdv(server, "INVITE %s %s", nick, channame); @@ -262,7 +264,7 @@ static void cmd_who(const char *data, IRC_SERVER_REC *server, if (!IS_IRC_CHANNEL(item)) cmd_param_error(CMDERR_NOT_JOINED); - channel = item->name; + channel = IRC_CHANNEL(item)->name; } if (strcmp(channel, "**") == 0) { /* ** displays all nicks.. */ @@ -291,7 +293,7 @@ static void cmd_names(const char *data, IRC_SERVER_REC *server, if (!IS_IRC_CHANNEL(item)) cmd_param_error(CMDERR_NOT_JOINED); - channel = item->name; + channel = IRC_CHANNEL(item)->name; } if (strcmp(channel, "**") == 0) { @@ -480,7 +482,7 @@ static void cmd_ping(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item if (!IS_IRC_ITEM(item)) cmd_return_error(CMDERR_NOT_JOINED); - data = item->name; + data = window_item_get_target(item); } g_get_current_time(&tv); diff --git a/src/irc/core/irc-core.c b/src/irc/core/irc-core.c index efede641..9d441f09 100644 --- a/src/irc/core/irc-core.c +++ b/src/irc/core/irc-core.c @@ -94,7 +94,8 @@ void irc_core_init(void) rec->server_connect = (SERVER_REC *(*) (SERVER_CONNECT_REC *)) irc_server_connect; rec->channel_create = - (CHANNEL_REC *(*) (SERVER_REC *, const char *, int)) + (CHANNEL_REC *(*) (SERVER_REC *, const char *, + const char *, int)) irc_channel_create; rec->query_create = (QUERY_REC *(*) (const char *, const char *, int)) diff --git a/src/irc/core/modes.c b/src/irc/core/modes.c index 08ac6f8d..5f16d5ba 100644 --- a/src/irc/core/modes.c +++ b/src/irc/core/modes.c @@ -490,8 +490,9 @@ void channel_set_singlemode(IRC_CHANNEL_REC *channel, const char *nicks, void channel_set_mode(IRC_SERVER_REC *server, const char *channel, const char *mode) { - char *modestr, *curmode, *orig, type, prevtype; + IRC_CHANNEL_REC *chanrec; GString *tmode, *targs; + char *modestr, *curmode, *orig, type, prevtype; int count; g_return_if_fail(IS_IRC_SERVER(server)); @@ -501,6 +502,10 @@ void channel_set_mode(IRC_SERVER_REC *server, const char *channel, targs = g_string_new(NULL); count = 0; + chanrec = irc_channel_find(server, channel); + if (chanrec != NULL) + channel = chanrec->name; + orig = modestr = g_strdup(mode); type = '+'; prevtype = '\0'; diff --git a/src/irc/core/netsplit.c b/src/irc/core/netsplit.c index c7018ec1..15bfab28 100644 --- a/src/irc/core/netsplit.c +++ b/src/irc/core/netsplit.c @@ -131,7 +131,7 @@ static NETSPLIT_REC *netsplit_add(IRC_SERVER_REC *server, const char *nick, continue; splitchan = g_new0(NETSPLIT_CHAN_REC, 1); - splitchan->name = g_strdup(channel->name); + splitchan->name = g_strdup(channel->visible_name); splitchan->op = nickrec->op; splitchan->halfop = nickrec->halfop; splitchan->voice = nickrec->voice; |