diff options
-rw-r--r-- | src/core/channels.c | 20 | ||||
-rw-r--r-- | src/core/channels.h | 3 | ||||
-rw-r--r-- | src/core/expandos.c | 4 | ||||
-rw-r--r-- | src/core/settings.h | 1 | ||||
-rw-r--r-- | src/irc/core/channel-events.c | 10 | ||||
-rw-r--r-- | src/irc/core/irc-channels.c | 5 |
6 files changed, 38 insertions, 5 deletions
diff --git a/src/core/channels.c b/src/core/channels.c index 126c3b7e..5dd90c2e 100644 --- a/src/core/channels.c +++ b/src/core/channels.c @@ -129,6 +129,26 @@ CHANNEL_REC *channel_find(SERVER_REC *server, const char *name) (void *) name); } +void channel_change_name(CHANNEL_REC *channel, const char *name) +{ + g_return_if_fail(IS_CHANNEL(channel)); + + g_free(channel->name); + channel->name = g_strdup(name); + + signal_emit("channel name changed", 1, channel); +} + +void channel_change_visible_name(CHANNEL_REC *channel, const char *name) +{ + g_return_if_fail(IS_CHANNEL(channel)); + + g_free(channel->visible_name); + channel->visible_name = g_strdup(name); + + signal_emit("window item name changed", 1, channel); +} + static CHANNEL_REC *channel_find_servers(GSList *servers, const char *name) { return gslist_foreach_find(servers, diff --git a/src/core/channels.h b/src/core/channels.h index ff121a2c..0839d69b 100644 --- a/src/core/channels.h +++ b/src/core/channels.h @@ -26,6 +26,9 @@ void channel_destroy(CHANNEL_REC *channel); /* find channel by name, if `server' is NULL, search from all servers */ CHANNEL_REC *channel_find(SERVER_REC *server, const char *name); +void channel_change_name(CHANNEL_REC *channel, const char *name); +void channel_change_visible_name(CHANNEL_REC *channel, const char *name); + /* Send the auto send command to channel */ void channel_send_autocommands(CHANNEL_REC *channel); diff --git a/src/core/expandos.c b/src/core/expandos.c index 6f0f392d..67a9d269 100644 --- a/src/core/expandos.c +++ b/src/core/expandos.c @@ -643,7 +643,9 @@ void expandos_init(void) "window server changed", EXPANDO_ARG_WINDOW, NULL); expando_create("itemname", expando_itemname, "window changed", EXPANDO_ARG_NONE, - "window item changed", EXPANDO_ARG_WINDOW, NULL); + "window item changed", EXPANDO_ARG_WINDOW, + "window item name changed", EXPANDO_ARG_WINDOW_ITEM, + NULL); read_settings(); diff --git a/src/core/settings.h b/src/core/settings.h index e0df975a..fdff3801 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -19,7 +19,6 @@ typedef struct { #define iconfig_get_str(a, b, c) config_get_str(mainconfig, a, b, c) #define iconfig_get_int(a, b, c) config_get_int(mainconfig, a, b, c) #define iconfig_get_bool(a, b, c) config_get_bool(mainconfig, a, b, c) -#define iconfig_list_find(a, b, c, d) config_list_find(mainconfig, a, b, c, d) #define iconfig_set_str(a, b, c) config_set_str(mainconfig, a, b, c) #define iconfig_set_int(a, b, c) config_set_int(mainconfig, a, b, c) diff --git a/src/irc/core/channel-events.c b/src/irc/core/channel-events.c index 02fe0242..6b474097 100644 --- a/src/irc/core/channel-events.c +++ b/src/irc/core/channel-events.c @@ -236,8 +236,18 @@ static void event_join(IRC_SERVER_REC *server, const char *data, const char *nic shortchan = g_strdup_printf("!%s", channel+6); chanrec = channel_find_unjoined(server, shortchan); if (chanrec != NULL) { + channel_change_name(CHANNEL(chanrec), channel); g_free(chanrec->name); chanrec->name = g_strdup(channel); + } else { + /* well, did we join it with full name? if so, and if + this was the first short one, change it's name. */ + chanrec = channel_find_unjoined(server, channel); + if (chanrec != NULL && + irc_channel_find(server, shortchan) == NULL) { + channel_change_visible_name(CHANNEL(chanrec), + shortchan); + } } } diff --git a/src/irc/core/irc-channels.c b/src/irc/core/irc-channels.c index d6acf6ae..5adf5fb1 100644 --- a/src/irc/core/irc-channels.c +++ b/src/irc/core/irc-channels.c @@ -149,12 +149,11 @@ static CHANNEL_REC *irc_channel_find_server(SERVER_REC *server, if (rec->chat_type != server->chat_type) continue; + /* check both !ABCDEchannel and !channel */ if (g_strcasecmp(channel, rec->name) == 0) return rec; - /* check after removing ABCDE from !ABCDEchannel */ - if (*channel == '!' && *rec->name == '!' && - g_strcasecmp(channel+1, rec->name+6) == 0) + if (g_strcasecmp(channel, rec->visible_name) == 0) return rec; } |