summaryrefslogtreecommitdiff
path: root/src/fe-common
diff options
context:
space:
mode:
Diffstat (limited to 'src/fe-common')
-rw-r--r--src/fe-common/core/chat-completion.c6
-rw-r--r--src/fe-common/core/fe-channels.c47
-rw-r--r--src/fe-common/core/fe-exec.c8
-rw-r--r--src/fe-common/core/fe-log.c2
-rw-r--r--src/fe-common/core/fe-messages.c15
-rw-r--r--src/fe-common/core/fe-windows.c4
-rw-r--r--src/fe-common/core/fe-windows.h2
-rw-r--r--src/fe-common/core/window-commands.c5
-rw-r--r--src/fe-common/core/window-items.c18
-rw-r--r--src/fe-common/core/windows-layout.c2
-rw-r--r--src/fe-common/irc/Makefile.am2
-rw-r--r--src/fe-common/irc/fe-common-irc.c6
-rw-r--r--src/fe-common/irc/fe-events-numeric.c33
-rw-r--r--src/fe-common/irc/fe-events.c48
-rw-r--r--src/fe-common/irc/fe-irc-commands.c51
-rw-r--r--src/fe-common/irc/fe-irc-layout.c63
-rw-r--r--src/fe-common/irc/fe-irc-server.c15
-rw-r--r--src/fe-common/irc/fe-irc-server.h9
-rw-r--r--src/fe-common/irc/fe-modes.c6
19 files changed, 179 insertions, 163 deletions
diff --git a/src/fe-common/core/chat-completion.c b/src/fe-common/core/chat-completion.c
index df5525eb..2de58a5a 100644
--- a/src/fe-common/core/chat-completion.c
+++ b/src/fe-common/core/chat-completion.c
@@ -501,7 +501,9 @@ GList *completion_get_channels(SERVER_REC *server, const char *word)
for (; tmp != NULL; tmp = tmp->next) {
CHANNEL_REC *rec = tmp->data;
- if (g_strncasecmp(rec->name, word, len) == 0)
+ if (g_strncasecmp(rec->visible_name, word, len) == 0)
+ list = g_list_append(list, g_strdup(rec->visible_name));
+ else if (g_strncasecmp(rec->name, word, len) == 0)
list = g_list_append(list, g_strdup(rec->name));
}
@@ -861,7 +863,7 @@ static void event_text(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
str = g_strdup_printf(IS_CHANNEL(item) ? "-channel %s %s" :
IS_QUERY(item) ? "-nick %s %s" : "%s %s",
- item->name, line);
+ window_item_get_target(item), line);
signal_emit("command msg", 3, str, server, item);
diff --git a/src/fe-common/core/fe-channels.c b/src/fe-common/core/fe-channels.c
index 27ad4365..f80c4173 100644
--- a/src/fe-common/core/fe-channels.c
+++ b/src/fe-common/core/fe-channels.c
@@ -70,7 +70,7 @@ static void signal_channel_destroyed(CHANNEL_REC *channel)
!channel->server->disconnected) {
/* kicked out from channel */
window_bind_add(window, channel->server->tag,
- channel->name);
+ channel->visible_name);
} else if (!channel->joined || channel->left)
window_auto_destroy(window);
}
@@ -86,7 +86,7 @@ static void sig_disconnected(SERVER_REC *server)
CHANNEL_REC *channel = tmp->data;
window = window_item_window((WI_ITEM_REC *) channel);
- window_bind_add(window, server->tag, channel->name);
+ window_bind_add(window, server->tag, channel->visible_name);
}
}
@@ -96,8 +96,9 @@ static void signal_window_item_changed(WINDOW_REC *window, WI_ITEM_REC *item)
if (item == NULL) return;
if (g_slist_length(window->items) > 1 && IS_CHANNEL(item)) {
- printformat(item->server, item->name, MSGLEVEL_CLIENTNOTICE,
- TXT_TALKING_IN, item->name);
+ printformat(item->server, item->visible_name,
+ MSGLEVEL_CLIENTNOTICE,
+ TXT_TALKING_IN, item->visible_name);
signal_stop();
}
}
@@ -172,7 +173,8 @@ static void cmd_channel_list_joined(void)
/* print active channel */
channel = CHANNEL(active_win->active);
if (channel != NULL)
- printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_CURRENT_CHANNEL, channel->name);
+ printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
+ TXT_CURRENT_CHANNEL, channel->visible_name);
/* print list of all channels, their modes, server tags and nicks */
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_CHANLIST_HEADER);
@@ -189,7 +191,8 @@ static void cmd_channel_list_joined(void)
if (nicks->len > 1) g_string_truncate(nicks, nicks->len-1);
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_CHANLIST_LINE,
- channel->name, channel->mode, channel->server->tag, nicks->str);
+ channel->visible_name, channel->mode,
+ channel->server->tag, nicks->str);
g_slist_free(nicklist);
g_string_free(nicks, TRUE);
@@ -326,13 +329,13 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist)
int *columns, cols, rows, last_col_rows, col, row, max_width;
int item_extra, linebuf_size, formatnum;
- window = window_find_closest(channel->server, channel->name,
+ window = window_find_closest(channel->server, channel->visible_name,
MSGLEVEL_CLIENTCRAP);
max_width = window->width;
/* get the length of item extra stuff ("[ ] ") */
format = format_get_text(MODULE_NAME, NULL,
- channel->server, channel->name,
+ channel->server, channel->visible_name,
TXT_NAMES_NICK, " ", "");
stripped = strip_codes(format);
item_extra = strlen(stripped);
@@ -344,7 +347,7 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist)
max_width = settings_get_int("names_max_width");
/* remove width of the timestamp from max_width */
- format_create_dest(&dest, channel->server, channel->name,
+ format_create_dest(&dest, channel->server, channel->visible_name,
MSGLEVEL_CLIENTCRAP, NULL);
format = format_get_line_start(current_theme, &dest, time(NULL));
if (format != NULL) {
@@ -356,8 +359,9 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist)
/* remove width of the prefix from max_width */
prefix_format = format_get_text(MODULE_NAME, NULL,
- channel->server, channel->name,
- TXT_NAMES_PREFIX, channel->name);
+ channel->server, channel->visible_name,
+ TXT_NAMES_PREFIX,
+ channel->visible_name);
if (prefix_format != NULL) {
stripped = strip_codes(prefix_format);
max_width -= strlen(stripped);
@@ -410,13 +414,14 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist)
rec->voice ? TXT_NAMES_NICK_VOICE :
TXT_NAMES_NICK;
format = format_get_text(MODULE_NAME, NULL,
- channel->server, channel->name,
+ channel->server,
+ channel->visible_name,
formatnum, nickmode, linebuf);
g_string_append(str, format);
g_free(format);
if (++col == cols) {
- printtext(channel->server, channel->name,
+ printtext(channel->server, channel->visible_name,
MSGLEVEL_CLIENTCRAP, "%s", str->str);
g_string_truncate(str, 0);
if (prefix_format != NULL)
@@ -429,7 +434,7 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist)
}
if (str->len > strlen(prefix_format)) {
- printtext(channel->server, channel->name,
+ printtext(channel->server, channel->visible_name,
MSGLEVEL_CLIENTCRAP, "%s", str->str);
}
@@ -480,15 +485,17 @@ void fe_channels_nicklist(CHANNEL_REC *channel, int flags)
/* display the nicks */
if ((flags & CHANNEL_NICKLIST_FLAG_COUNT) == 0) {
- printformat(channel->server, channel->name,
- MSGLEVEL_CLIENTCRAP, TXT_NAMES, channel->name, nicks, ops, halfops, voices, normal);
+ printformat(channel->server, channel->visible_name,
+ MSGLEVEL_CLIENTCRAP, TXT_NAMES,
+ channel->visible_name,
+ nicks, ops, halfops, voices, normal);
display_sorted_nicks(channel, sorted);
}
g_slist_free(sorted);
- printformat(channel->server, channel->name,
+ printformat(channel->server, channel->visible_name,
MSGLEVEL_CLIENTNOTICE, TXT_ENDOFNAMES,
- channel->name, nicks, ops, halfops, voices, normal);
+ channel->visible_name, nicks, ops, halfops, voices, normal);
}
/* SYNTAX: NAMES [-count | -ops -halfops -voices -normal] [<channels> | **] */
@@ -513,7 +520,7 @@ static void cmd_names(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
if (!IS_CHANNEL(item))
cmd_param_error(CMDERR_NOT_JOINED);
- channel = item->name;
+ channel = CHANNEL(item)->name;
}
flags = 0;
@@ -575,7 +582,7 @@ static void cmd_cycle(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
joindata = chanrec->get_join_data(chanrec);
window_bind_add(window_item_window(chanrec),
- chanrec->server->tag, chanrec->name);
+ chanrec->server->tag, chanrec->visible_name);
/* FIXME: kludgy kludgy... */
signal_emit("command part", 3, data, server, item);
diff --git a/src/fe-common/core/fe-exec.c b/src/fe-common/core/fe-exec.c
index 88df56ae..8c23072c 100644
--- a/src/fe-common/core/fe-exec.c
+++ b/src/fe-common/core/fe-exec.c
@@ -54,7 +54,7 @@ static void exec_wi_destroy(EXEC_WI_REC *rec)
window_item_destroy((WI_ITEM_REC *) rec);
MODULE_DATA_DEINIT(rec);
- g_free(rec->name);
+ g_free(rec->visible_name);
g_free(rec);
}
@@ -68,7 +68,7 @@ static EXEC_WI_REC *exec_wi_create(WINDOW_REC *window, PROCESS_REC *rec)
item = g_new0(EXEC_WI_REC, 1);
item->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "EXEC");
item->destroy = (void (*) (WI_ITEM_REC *)) exec_wi_destroy;
- item->name = rec->name != NULL ? g_strdup(rec->name) :
+ item->visible_name = rec->name != NULL ? g_strdup(rec->name) :
g_strdup_printf("%%%d", rec->id);
item->createtime = time(NULL);
@@ -411,7 +411,7 @@ static void handle_exec(const char *args, GHashTable *optlist,
/* redirect output to active channel/query */
if (item == NULL)
cmd_return_error(CMDERR_NOT_JOINED);
- target = item->name;
+ target = (char *) window_item_get_target(item);
target_channel = IS_CHANNEL(item);
target_nick = IS_QUERY(item);
} else if (g_hash_table_lookup(optlist, "msg") != NULL) {
@@ -589,7 +589,7 @@ static void sig_exec_input(PROCESS_REC *rec, const char *text)
3, str, server, item);
g_free(str);
} else if (rec->target_item != NULL) {
- printtext(NULL, rec->target_item->name,
+ printtext(NULL, rec->target_item->visible_name,
rec->level, "%s", text);
} else {
printtext_window(rec->target_win, rec->level, "%s", text);
diff --git a/src/fe-common/core/fe-log.c b/src/fe-common/core/fe-log.c
index bebff7f5..9362f6da 100644
--- a/src/fe-common/core/fe-log.c
+++ b/src/fe-common/core/fe-log.c
@@ -595,7 +595,7 @@ static void sig_window_item_destroy(WINDOW_REC *window, WI_ITEM_REC *item)
{
LOG_REC *log;
- log = logs_find_item(LOG_ITEM_TARGET, item->name,
+ log = logs_find_item(LOG_ITEM_TARGET, item->visible_name,
item->server == NULL ? NULL :
item->server->tag, NULL);
if (log != NULL && log->temp)
diff --git a/src/fe-common/core/fe-messages.c b/src/fe-common/core/fe-messages.c
index 44c9fb35..311c2adf 100644
--- a/src/fe-common/core/fe-messages.c
+++ b/src/fe-common/core/fe-messages.c
@@ -347,7 +347,7 @@ static void sig_message_quit(SERVER_REC *server, const char *nick,
if (!nicklist_find(rec, nick))
continue;
- if (ignore_check(server, nick, address, rec->name,
+ if (ignore_check(server, nick, address, rec->visible_name,
reason, MSGLEVEL_QUITS)) {
count++;
continue;
@@ -355,17 +355,18 @@ static void sig_message_quit(SERVER_REC *server, const char *nick,
if (print_channel == NULL ||
active_win->active == (WI_ITEM_REC *) rec)
- print_channel = rec->name;
+ print_channel = rec->visible_name;
if (once)
- g_string_sprintfa(chans, "%s,", rec->name);
+ g_string_sprintfa(chans, "%s,", rec->visible_name);
else {
window = window_item_window((WI_ITEM_REC *) rec);
if (g_slist_find(windows, window) == NULL) {
windows = g_slist_append(windows, window);
- printformat(server, rec->name, MSGLEVEL_QUITS,
+ printformat(server, rec->visible_name,
+ MSGLEVEL_QUITS,
TXT_QUIT, nick, address, reason,
- rec->name);
+ rec->visible_name);
}
}
count++;
@@ -441,8 +442,8 @@ static void print_nick_change(SERVER_REC *server, const char *newnick,
continue;
windows = g_slist_append(windows, window);
- print_nick_change_channel(server, channel->name, newnick,
- oldnick, address, ownnick);
+ print_nick_change_channel(server, channel->visible_name,
+ newnick, oldnick, address, ownnick);
msgprint = TRUE;
}
diff --git a/src/fe-common/core/fe-windows.c b/src/fe-common/core/fe-windows.c
index af8e4297..4ac94c5f 100644
--- a/src/fe-common/core/fe-windows.c
+++ b/src/fe-common/core/fe-windows.c
@@ -232,12 +232,12 @@ void window_set_immortal(WINDOW_REC *window, int immortal)
}
/* return active item's name, or if none is active, window's name */
-char *window_get_active_name(WINDOW_REC *window)
+const char *window_get_active_name(WINDOW_REC *window)
{
g_return_val_if_fail(window != NULL, NULL);
if (window->active != NULL)
- return window->active->name;
+ return window->active->visible_name;
return window->name;
}
diff --git a/src/fe-common/core/fe-windows.h b/src/fe-common/core/fe-windows.h
index 9173459f..64aaddd4 100644
--- a/src/fe-common/core/fe-windows.h
+++ b/src/fe-common/core/fe-windows.h
@@ -69,7 +69,7 @@ void window_set_level(WINDOW_REC *window, int level);
void window_set_immortal(WINDOW_REC *window, int immortal);
/* return active item's name, or if none is active, window's name */
-char *window_get_active_name(WINDOW_REC *window);
+const char *window_get_active_name(WINDOW_REC *window);
WINDOW_REC *window_find_level(void *server, int level);
WINDOW_REC *window_find_closest(void *server, const char *name, int level);
diff --git a/src/fe-common/core/window-commands.c b/src/fe-common/core/window-commands.c
index bbe495aa..e877b906 100644
--- a/src/fe-common/core/window-commands.c
+++ b/src/fe-common/core/window-commands.c
@@ -64,7 +64,8 @@ static void window_print_items(WINDOW_REC *win)
type = module_find_id_str("WINDOW ITEM TYPE", item->type);
printformat_window(win, MSGLEVEL_CLIENTCRAP,
TXT_WINDOW_INFO_ITEM,
- type == NULL ? "??" : type, item->name,
+ type == NULL ? "??" : type,
+ item->visible_name,
item->server == NULL ? "" :
item->server->tag);
}
@@ -660,7 +661,7 @@ static void cmd_window_list(void)
levelstr = bits2level(rec->level);
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_WINDOWLIST_LINE,
rec->refnum, rec->name == NULL ? "" : rec->name,
- rec->active == NULL ? "" : rec->active->name,
+ rec->active == NULL ? "" : rec->active->visible_name,
rec->active_server == NULL ? "" : ((SERVER_REC *) rec->active_server)->tag,
levelstr);
g_free(levelstr);
diff --git a/src/fe-common/core/window-items.c b/src/fe-common/core/window-items.c
index e53e5a1d..ce4b57e0 100644
--- a/src/fe-common/core/window-items.c
+++ b/src/fe-common/core/window-items.c
@@ -23,6 +23,7 @@
#include "modules.h"
#include "signals.h"
#include "servers.h"
+#include "channels.h"
#include "settings.h"
#include "levels.h"
@@ -195,15 +196,23 @@ void window_item_next(WINDOW_REC *window)
WI_ITEM_REC *window_item_find_window(WINDOW_REC *window,
void *server, const char *name)
{
+ CHANNEL_REC *channel;
GSList *tmp;
for (tmp = window->items; tmp != NULL; tmp = tmp->next) {
WI_ITEM_REC *rec = tmp->data;
if ((server == NULL || rec->server == server) &&
- g_strcasecmp(name, rec->name) == 0) return rec;
+ g_strcasecmp(name, rec->visible_name) == 0)
+ return rec;
}
+ /* try with channel name too, it's not necessarily
+ same as visible_name (!channels) */
+ channel = channel_find(server, name);
+ if (channel != NULL && window_item_window(channel) == window)
+ return (WI_ITEM_REC *) channel;
+
return NULL;
}
@@ -259,7 +268,7 @@ void window_item_create(WI_ITEM_REC *item, int automatic)
/* is item bound to this window? */
if (item->server != NULL) {
bind = window_bind_find(rec, item->server->tag,
- item->name);
+ item->visible_name);
if (bind != NULL) {
if (!bind->sticky)
window_bind_destroy(rec, bind);
@@ -316,8 +325,9 @@ static void signal_window_item_changed(WINDOW_REC *window, WI_ITEM_REC *item)
if (g_slist_length(window->items) > 1) {
/* default to printing "talking with ...",
you can override it it you wish */
- printformat(item->server, item->name, MSGLEVEL_CLIENTNOTICE,
- TXT_TALKING_WITH, item->name);
+ printformat(item->server, item->visible_name,
+ MSGLEVEL_CLIENTNOTICE,
+ TXT_TALKING_WITH, item->visible_name);
}
}
diff --git a/src/fe-common/core/windows-layout.c b/src/fe-common/core/windows-layout.c
index a19b2942..4dd1ee32 100644
--- a/src/fe-common/core/windows-layout.c
+++ b/src/fe-common/core/windows-layout.c
@@ -147,7 +147,7 @@ static void sig_layout_save_item(WINDOW_REC *window, WI_ITEM_REC *item,
iconfig_node_set_str(subnode, "type", type);
type = chat_protocol_find_id(item->chat_type)->name;
iconfig_node_set_str(subnode, "chat_type", type);
- iconfig_node_set_str(subnode, "name", item->name);
+ iconfig_node_set_str(subnode, "name", item->visible_name);
if (item->server != NULL)
iconfig_node_set_str(subnode, "tag", item->server->tag);
diff --git a/src/fe-common/irc/Makefile.am b/src/fe-common/irc/Makefile.am
index 8e1b1501..d633d247 100644
--- a/src/fe-common/irc/Makefile.am
+++ b/src/fe-common/irc/Makefile.am
@@ -14,7 +14,6 @@ INCLUDES = \
real_sources = \
fe-irc-channels.c \
fe-irc-commands.c \
- fe-irc-layout.c \
fe-irc-messages.c \
fe-irc-queries.c \
fe-irc-server.c \
@@ -33,6 +32,7 @@ libfe_common_irc_a_SOURCES = \
irc-modules.c
noinst_HEADERS = \
+ fe-irc-server.h \
module.h \
module-formats.h
diff --git a/src/fe-common/irc/fe-common-irc.c b/src/fe-common/irc/fe-common-irc.c
index 583dbca9..9c0f6716 100644
--- a/src/fe-common/irc/fe-common-irc.c
+++ b/src/fe-common/irc/fe-common-irc.c
@@ -27,6 +27,7 @@
#include "settings.h"
#include "themes.h"
+#include "fe-irc-server.h"
void fe_irc_modules_init(void);
void fe_irc_modules_deinit(void);
@@ -49,9 +50,6 @@ void fe_irc_commands_deinit(void);
void fe_ircnet_init(void);
void fe_ircnet_deinit(void);
-void fe_irc_server_init(void);
-void fe_irc_server_deinit(void);
-
void fe_ctcp_init(void);
void fe_ctcp_deinit(void);
@@ -78,7 +76,6 @@ void fe_common_irc_init(void)
fe_irc_channels_init();
fe_irc_queries_init();
- fe_irc_layout_init();
fe_irc_messages_init();
fe_irc_commands_init();
fe_ircnet_init();
@@ -102,7 +99,6 @@ void fe_common_irc_deinit(void)
fe_irc_channels_deinit();
fe_irc_queries_deinit();
- fe_irc_layout_deinit();
fe_irc_messages_deinit();
fe_irc_commands_deinit();
fe_ircnet_deinit();
diff --git a/src/fe-common/irc/fe-events-numeric.c b/src/fe-common/irc/fe-events-numeric.c
index 1ea6bd2b..f5cf2208 100644
--- a/src/fe-common/irc/fe-events-numeric.c
+++ b/src/fe-common/irc/fe-events-numeric.c
@@ -32,6 +32,7 @@
#include "../core/module-formats.h"
#include "printtext.h"
#include "fe-channels.h"
+#include "fe-irc-server.h"
static void print_event_received(IRC_SERVER_REC *server, const char *data,
const char *nick, int target_param);
@@ -132,7 +133,8 @@ static void event_end_of_who(IRC_SERVER_REC *server, const char *data)
static void event_ban_list(IRC_SERVER_REC *server, const char *data)
{
- char *params, *channel, *ban, *setby, *tims;
+ const char *channel;
+ char *params, *ban, *setby, *tims;
long secs;
g_return_if_fail(data != NULL);
@@ -142,6 +144,7 @@ static void event_ban_list(IRC_SERVER_REC *server, const char *data)
secs = *tims == '\0' ? 0 :
(long) (time(NULL) - atol(tims));
+ channel = get_visible_target(server, channel);
printformat(server, channel, MSGLEVEL_CRAP,
*setby == '\0' ? IRCTXT_BANLIST : IRCTXT_BANLIST_LONG,
0, channel, ban, setby, secs);
@@ -151,7 +154,8 @@ static void event_ban_list(IRC_SERVER_REC *server, const char *data)
static void event_eban_list(IRC_SERVER_REC *server, const char *data)
{
- char *params, *channel, *ban, *setby, *tims;
+ const char *channel;
+ char *params, *ban, *setby, *tims;
long secs;
g_return_if_fail(data != NULL);
@@ -161,6 +165,7 @@ static void event_eban_list(IRC_SERVER_REC *server, const char *data)
secs = *tims == '\0' ? 0 :
(long) (time(NULL) - atol(tims));
+ channel = get_visible_target(server, channel);
printformat(server, channel, MSGLEVEL_CRAP,
*setby == '\0' ? IRCTXT_EBANLIST : IRCTXT_EBANLIST_LONG,
channel, ban, setby, secs);
@@ -183,11 +188,13 @@ static void event_silence_list(IRC_SERVER_REC *server, const char *data)
static void event_invite_list(IRC_SERVER_REC *server, const char *data)
{
- char *params, *channel, *invite;
+ const char *channel;
+ char *params, *invite;
g_return_if_fail(data != NULL);
params = event_get_params(data, 3, NULL, &channel, &invite);
+ channel = get_visible_target(server, channel);
printformat(server, channel, MSGLEVEL_CRAP,
IRCTXT_INVITELIST, channel, invite);
g_free(params);
@@ -210,11 +217,13 @@ static void event_nick_in_use(IRC_SERVER_REC *server, const char *data)
static void event_topic_get(IRC_SERVER_REC *server, const char *data)
{
- char *params, *channel, *topic;
+ const char *channel;
+ char *params, *topic;
g_return_if_fail(data != NULL);
params = event_get_params(data, 3, NULL, &channel, &topic);
+ channel = get_visible_target(server, channel);
printformat(server, channel, MSGLEVEL_CRAP,
IRCTXT_TOPIC, channel, topic);
g_free(params);
@@ -222,7 +231,8 @@ static void event_topic_get(IRC_SERVER_REC *server, const char *data)
static void event_topic_info(IRC_SERVER_REC *server, const char *data)
{
- char *params, *timestr, *channel, *bynick, *byhost, *topictime;
+ const char *channel;
+ char *params, *timestr, *bynick, *byhost, *topictime;
g_return_if_fail(data != NULL);
@@ -235,6 +245,7 @@ static void event_topic_info(IRC_SERVER_REC *server, const char *data)
if (byhost != NULL)
*byhost++ = '\0';
+ channel = get_visible_target(server, channel);
printformat(server, channel, MSGLEVEL_CRAP, IRCTXT_TOPIC_INFO,
bynick, timestr, byhost == NULL ? "" : byhost);
g_free(timestr);
@@ -243,12 +254,14 @@ static void event_topic_info(IRC_SERVER_REC *server, const char *data)
static void event_channel_mode(IRC_SERVER_REC *server, const char *data)
{
- char *params, *channel, *mode;
+ const char *channel;
+ char *params, *mode;
g_return_if_fail(data != NULL);
params = event_get_params(data, 3 | PARAM_FLAG_GETREST,
NULL, &channel, &mode);
+ channel = get_visible_target(server, channel);
printformat(server, channel, MSGLEVEL_CRAP,
IRCTXT_CHANNEL_MODE, channel, g_strchomp(mode));
g_free(params);
@@ -256,13 +269,15 @@ static void event_channel_mode(IRC_SERVER_REC *server, const char *data)
static void event_channel_created(IRC_SERVER_REC *server, const char *data)
{
- char *params, *channel, *createtime, *timestr;
+ const char *channel;
+ char *params, *createtime, *timestr;
g_return_if_fail(data != NULL);
params = event_get_params(data, 3, NULL, &channel, &createtime);
timestr = my_asctime((time_t) atol(createtime));
+ channel = get_visible_target(server, channel);
printformat(server, channel, MSGLEVEL_CRAP,
IRCTXT_CHANNEL_CREATED, channel, timestr);
g_free(timestr);
@@ -604,11 +619,13 @@ static void event_end_of_whois(IRC_SERVER_REC *server, const char *data)
static void event_chanserv_url(IRC_SERVER_REC *server, const char *data)
{
- char *params, *channel, *url;
+ const char *channel;
+ char *params, *url;
g_return_if_fail(data != NULL);
params = event_get_params(data, 3, NULL, &channel, &url);
+ channel = get_visible_target(server, channel);
printformat(server, channel, MSGLEVEL_CRAP,
IRCTXT_CHANNEL_URL, channel, url);
g_free(params);
diff --git a/src/fe-common/irc/fe-events.c b/src/fe-common/irc/fe-events.c
index 88839238..7bdf375a 100644
--- a/src/fe-common/irc/fe-events.c
+++ b/src/fe-common/irc/fe-events.c
@@ -39,8 +39,8 @@
#include "printtext.h"
#include "fe-queries.h"
#include "fe-windows.h"
-
-#include "completion.h"
+#include "fe-irc-server.h"
+//#include "completion.h"
static void event_privmsg(IRC_SERVER_REC *server, const char *data,
const char *nick, const char *addr)
@@ -56,11 +56,13 @@ static void event_privmsg(IRC_SERVER_REC *server, const char *data,
if (*target == '@' && ischannel(target[1])) {
/* Hybrid 6 feature, send msg to all ops in channel */
signal_emit("message irc op_public", 5,
- server, msg, nick, addr, target+1);
+ server, msg, nick, addr,
+ get_visible_target(server, target+1));
} else {
signal_emit(ischannel(*target) ?
"message public" : "message private", 5,
- server, msg, nick, addr, target);
+ server, msg, nick, addr,
+ get_visible_target(server, target));
}
g_free(params);
@@ -73,7 +75,8 @@ static void ctcp_action(IRC_SERVER_REC *server, const char *data,
g_return_if_fail(data != NULL);
signal_emit("message irc action", 5,
- server, data, nick, addr, target);
+ server, data, nick, addr,
+ get_visible_target(server, target));
}
static void event_notice(IRC_SERVER_REC *server, const char *data,
@@ -90,15 +93,16 @@ static void event_notice(IRC_SERVER_REC *server, const char *data,
server->real_address;
}
- signal_emit("message irc notice", 5,
- server, msg, nick, addr, target);
+ signal_emit("message irc notice", 5, server, msg, nick, addr,
+ get_visible_target(server, target));
g_free(params);
}
static void event_join(IRC_SERVER_REC *server, const char *data,
const char *nick, const char *addr)
{
- char *params, *channel, *tmp;
+ const char *channel;
+ char *params, *tmp;
g_return_if_fail(data != NULL);
@@ -106,6 +110,9 @@ static void event_join(IRC_SERVER_REC *server, const char *data,
tmp = strchr(channel, 7); /* ^G does something weird.. */
if (tmp != NULL) *tmp = '\0';
+ if (g_strcasecmp(server->nick, nick) != 0)
+ channel = get_visible_target(server, channel);
+
signal_emit("message join", 4, server, channel, nick, addr);
g_free(params);
}
@@ -119,7 +126,8 @@ static void event_part(IRC_SERVER_REC *server, const char *data,
params = event_get_params(data, 2 | PARAM_FLAG_GETREST,
&channel, &reason);
- signal_emit("message part", 5, server, channel, nick, addr, reason);
+ signal_emit("message part", 5, server,
+ get_visible_target(server, channel), nick, addr, reason);
g_free(params);
}
@@ -141,8 +149,9 @@ static void event_kick(IRC_SERVER_REC *server, const char *data,
params = event_get_params(data, 3 | PARAM_FLAG_GETREST,
&channel, &nick, &reason);
- signal_emit("message kick", 6, server, channel, nick,
- kicker, addr, reason);
+ signal_emit("message kick", 6,
+ server, get_visible_target(server, channel),
+ nick, kicker, addr, reason);
g_free(params);
}
@@ -205,8 +214,9 @@ static void event_mode(IRC_SERVER_REC *server, const char *data,
params = event_get_params(data, 2 | PARAM_FLAG_GETREST,
&channel, &mode);
- signal_emit("message irc mode", 5, server, channel, nick, addr,
- g_strchomp(mode));
+ signal_emit("message irc mode", 5,
+ server, get_visible_target(server, channel),
+ nick, addr, g_strchomp(mode));
g_free(params);
}
@@ -230,7 +240,8 @@ static void event_invite(IRC_SERVER_REC *server, const char *data,
g_return_if_fail(data != NULL);
params = event_get_params(data, 2, NULL, &channel);
- signal_emit("message invite", 4, server, channel, nick, addr);
+ signal_emit("message invite", 4,
+ server, get_visible_target(server, channel), nick, addr);
g_free(params);
}
@@ -243,7 +254,8 @@ static void event_topic(IRC_SERVER_REC *server, const char *data,
params = event_get_params(data, 2 | PARAM_FLAG_GETREST,
&channel, &topic);
- signal_emit("message topic", 5, server, channel, topic, nick, addr);
+ signal_emit("message topic", 5, server,
+ get_visible_target(server, channel), topic, nick, addr);
g_free(params);
}
@@ -291,8 +303,10 @@ static void channel_sync(CHANNEL_REC *channel)
{
g_return_if_fail(channel != NULL);
- printformat(channel->server, channel->name, MSGLEVEL_CLIENTNOTICE|MSGLEVEL_NO_ACT,
- IRCTXT_CHANNEL_SYNCED, channel->name, (long) (time(NULL)-channel->createtime));
+ printformat(channel->server, channel->visible_name,
+ MSGLEVEL_CLIENTNOTICE|MSGLEVEL_NO_ACT,
+ IRCTXT_CHANNEL_SYNCED, channel->visible_name,
+ (long) (time(NULL)-channel->createtime));
}
static void event_connected(IRC_SERVER_REC *server)
diff --git a/src/fe-common/irc/fe-irc-commands.c b/src/fe-common/irc/fe-irc-commands.c
index 4bbdb96a..e0377542 100644
--- a/src/fe-common/irc/fe-irc-commands.c
+++ b/src/fe-common/irc/fe-irc-commands.c
@@ -40,7 +40,7 @@
#include "printtext.h"
#include "keyboard.h"
-static char *skip_target(char *target)
+static const char *skip_target(const char *target)
{
if (*target == '@') {
/* @#channel, @+#channel - Hybrid6 / Bahamut features */
@@ -63,17 +63,18 @@ static void cmd_me(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
if (server == NULL || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
- signal_emit("message irc own_action", 3, server, data, item->name);
+ signal_emit("message irc own_action", 3, server, data,
+ item->visible_name);
irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001",
- item->name, data);
+ window_item_get_target(item), data);
}
/* SYNTAX: ACTION [-<server tag>] <target> <message> */
static void cmd_action(const char *data, IRC_SERVER_REC *server)
{
GHashTable *optlist;
- char *target, *text;
+ const char *target, *text;
void *free_arg;
CMD_IRC_SERVER(server);
@@ -99,7 +100,7 @@ static void cmd_action(const char *data, IRC_SERVER_REC *server)
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);
@@ -108,7 +109,7 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server,
&target, &msg))
return;
if (strcmp(target, "*") == 0)
- target = item == NULL ? "" : item->name;
+ target = item == NULL ? "" : window_item_get_target(item);
if (*target == '\0' || *msg == '\0')
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
@@ -121,7 +122,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);
@@ -130,7 +132,7 @@ static void cmd_ctcp(const char *data, IRC_SERVER_REC *server,
&target, &ctcpcmd, &ctcpdata))
return;
if (strcmp(target, "*") == 0)
- target = item == NULL ? "" : item->name;
+ target = item == NULL ? "" : window_item_get_target(item);
if (*target == '\0' || *ctcpcmd == '\0')
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
@@ -152,7 +154,7 @@ 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, *text;
+ const char *target, *text;
void *free_arg;
CMD_IRC_SERVER(server);
@@ -161,7 +163,7 @@ static void cmd_nctcp(const char *data, IRC_SERVER_REC *server,
&target, &text))
return;
if (strcmp(target, "*") == 0)
- target = item == NULL ? "" : item->name;
+ target = item == NULL ? "" : window_item_get_target(item);
if (*target == '\0' || *text == '\0')
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
@@ -174,7 +176,7 @@ static void cmd_wall(const char *data, IRC_SERVER_REC *server,
WI_ITEM_REC *item)
{
IRC_CHANNEL_REC *chanrec;
- char *channame, *msg;
+ const char *channame, *msg;
void *free_arg;
CMD_IRC_SERVER(server);
@@ -187,7 +189,8 @@ static void cmd_wall(const char *data, IRC_SERVER_REC *server,
chanrec = irc_channel_find(server, channame);
if (chanrec == NULL) cmd_param_error(CMDERR_CHAN_NOT_FOUND);
- signal_emit("message irc own_wall", 3, server, msg, chanrec->name);
+ signal_emit("message irc own_wall", 3, server, msg,
+ chanrec->visible_name);
cmd_params_free(free_arg);
}
@@ -234,8 +237,9 @@ static void bans_show_channel(IRC_CHANNEL_REC *channel, IRC_SERVER_REC *server)
cmd_return_error(CMDERR_CHAN_NOT_SYNCED);
if (channel->banlist == NULL) {
- printformat(server, channel->name, MSGLEVEL_CLIENTNOTICE,
- IRCTXT_NO_BANS, channel->name);
+ printformat(server, channel->visible_name,
+ MSGLEVEL_CLIENTNOTICE,
+ IRCTXT_NO_BANS, channel->visible_name);
return;
}
@@ -244,10 +248,11 @@ static void bans_show_channel(IRC_CHANNEL_REC *channel, IRC_SERVER_REC *server)
for (tmp = channel->banlist; tmp != NULL; tmp = tmp->next) {
BAN_REC *rec = tmp->data;
- printformat(server, channel->name, MSGLEVEL_CRAP,
+ printformat(server, channel->visible_name, MSGLEVEL_CRAP,
(rec->setby == NULL || *rec->setby == '\0') ?
IRCTXT_BANLIST : IRCTXT_BANLIST_LONG,
- counter, channel->name, rec->ban, rec->setby,
+ counter, channel->visible_name,
+ rec->ban, rec->setby,
(int) (time(NULL)-rec->time));
counter++;
}
@@ -306,7 +311,8 @@ static void cmd_ver(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
if (*data == '\0' && !IS_IRC_ITEM(item))
cmd_return_error(CMDERR_NOT_JOINED);
- str = g_strdup_printf("%s VERSION", *data == '\0' ? item->name : data);
+ str = g_strdup_printf("%s VERSION", *data == '\0' ?
+ window_item_get_target(item) : data);
signal_emit("command ctcp", 3, str, server, item);
g_free(str);
}
@@ -321,9 +327,9 @@ static void cmd_topic(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
channel = *data != '\0' ? channel_find(server, data) : CHANNEL(item);
if (channel == NULL) return;
- printformat(server, channel->name, MSGLEVEL_CRAP,
+ printformat(server, channel->visible_name, MSGLEVEL_CRAP,
channel->topic == NULL ? IRCTXT_NO_TOPIC : IRCTXT_TOPIC,
- channel->name, channel->topic);
+ channel->visible_name, channel->topic);
if (channel->topic_time > 0) {
byhost = strchr(channel->topic_by, '!');
@@ -337,7 +343,7 @@ static void cmd_topic(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
}
timestr = my_asctime(channel->topic_time);
- printformat(server, channel->name, MSGLEVEL_CRAP,
+ printformat(server, channel->visible_name, MSGLEVEL_CRAP,
IRCTXT_TOPIC_INFO, bynick, timestr, byhost);
g_free(timestr);
g_free(bynick);
@@ -356,7 +362,8 @@ static void cmd_ts(const char *data)
CHANNEL_REC *rec = tmp->data;
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_TOPIC,
- rec->name, rec->topic == NULL ? "" : rec->topic);
+ rec->visible_name,
+ rec->topic == NULL ? "" : rec->topic);
}
}
@@ -423,7 +430,7 @@ static void cmd_sethost(const char *data, IRC_SERVER_REC *server)
CHANNEL_REC *channel = tmp->data;
window_bind_add(window_item_window(channel),
- server->tag, channel->name);
+ server->tag, channel->visible_name);
}
irc_send_cmdv(server, "SETHOST %s", data);
diff --git a/src/fe-common/irc/fe-irc-layout.c b/src/fe-common/irc/fe-irc-layout.c
deleted file mode 100644
index 73e00555..00000000
--- a/src/fe-common/irc/fe-irc-layout.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- fe-irc-layout.c : irssi
-
- Copyright (C) 2000-2002 Timo Sirainen
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-#include "module.h"
-#include "signals.h"
-#include "settings.h"
-#include "lib-config/iconfig.h"
-
-#include "irc-servers.h"
-#include "irc-channels.h"
-
-#include "fe-windows.h"
-
-static void sig_layout_save_item(WINDOW_REC *window, WI_ITEM_REC *item,
- CONFIG_NODE *node)
-{
- CONFIG_NODE *subnode;
- IRC_CHANNEL_REC *channel;
- char *name;
-
- channel = IRC_CHANNEL(item);
- if (channel == NULL || *channel->name != '!')
- return;
-
- /* save !ABCDEchannels using just short name */
- subnode = config_node_section(node, NULL, NODE_TYPE_BLOCK);
-
- name = g_strconcat("!", channel->name+6, NULL);
- iconfig_node_set_str(subnode, "type", "CHANNEL");
- iconfig_node_set_str(subnode, "chat_type", "IRC");
- iconfig_node_set_str(subnode, "name", name);
- iconfig_node_set_str(subnode, "tag", channel->server->tag);
- g_free(name);
-
- signal_stop();
-}
-
-void fe_irc_layout_init(void)
-{
- signal_add("layout save item", (SIGNAL_FUNC) sig_layout_save_item);
-}
-
-void fe_irc_layout_deinit(void)
-{
- signal_remove("layout save item", (SIGNAL_FUNC) sig_layout_save_item);
-}
diff --git a/src/fe-common/irc/fe-irc-server.c b/src/fe-common/irc/fe-irc-server.c
index 1bbed153..8b01c3a4 100644
--- a/src/fe-common/irc/fe-irc-server.c
+++ b/src/fe-common/irc/fe-irc-server.c
@@ -29,12 +29,27 @@
#include "levels.h"
#include "irc-chatnets.h"
#include "irc-servers.h"
+#include "irc-channels.h"
#include "servers-reconnect.h"
#include "irc-servers-setup.h"
#include "fe-windows.h"
#include "printtext.h"
+const char *get_visible_target(IRC_SERVER_REC *server, const char *target)
+{
+ IRC_CHANNEL_REC *channel;
+
+ if (*target == '!') {
+ /* visible_name of !channels is different - don't bother
+ checking other types for now, they'll just slow up */
+ channel = irc_channel_find(server, target);
+ if (channel != NULL)
+ return channel->visible_name;
+ }
+
+ return target;
+}
/* SYNTAX: SERVER ADD [-4 | -6] [-auto | -noauto] [-ircnet <ircnet>]
[-host <hostname>] [-cmdspeed <ms>] [-cmdmax <count>]
[-port <port>] <address> [<port> [<password>]] */
diff --git a/src/fe-common/irc/fe-irc-server.h b/src/fe-common/irc/fe-irc-server.h
new file mode 100644
index 00000000..7d9425be
--- /dev/null
+++ b/src/fe-common/irc/fe-irc-server.h
@@ -0,0 +1,9 @@
+#ifndef __FE_IRC_SERVER_H
+#define __FE_IRC_SERVER_H
+
+const char *get_visible_target(IRC_SERVER_REC *server, const char *target);
+
+void fe_irc_server_init(void);
+void fe_irc_server_deinit(void);
+
+#endif
diff --git a/src/fe-common/irc/fe-modes.c b/src/fe-common/irc/fe-modes.c
index 44f8d89c..99b6b60d 100644
--- a/src/fe-common/irc/fe-modes.c
+++ b/src/fe-common/irc/fe-modes.c
@@ -84,9 +84,9 @@ static void print_mode(MODE_REC *rec)
tmp = modes; modes = NULL;
nicks = gslist_to_string(rec->nicks, ", ");
- printformat(rec->channel->server, rec->channel->name, MSGLEVEL_MODES,
- IRCTXT_CHANMODE_CHANGE,
- rec->channel->name, rec->mode, nicks, "");
+ printformat(rec->channel->server, rec->channel->visible_name,
+ MSGLEVEL_MODES, IRCTXT_CHANMODE_CHANGE,
+ rec->channel->visible_name, rec->mode, nicks, "");
g_free(nicks);
modes = tmp;