summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/channel-rec.h1
-rw-r--r--src/core/channels.c31
-rw-r--r--src/core/channels.h3
-rw-r--r--src/core/chat-commands.c5
-rw-r--r--src/core/chat-protocols.h3
-rw-r--r--src/core/commands.c13
-rw-r--r--src/core/expandos.c12
-rw-r--r--src/core/queries.c12
-rw-r--r--src/core/query-rec.h1
-rw-r--r--src/core/session.c6
-rw-r--r--src/core/window-item-rec.h6
-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
-rw-r--r--src/irc/core/channel-events.c2
-rw-r--r--src/irc/core/irc-channels.c30
-rw-r--r--src/irc/core/irc-channels.h4
-rw-r--r--src/irc/core/irc-commands.c22
-rw-r--r--src/irc/core/irc-core.c3
-rw-r--r--src/irc/core/modes.c7
-rw-r--r--src/irc/core/netsplit.c2
-rw-r--r--src/perl/common/Channel.xs8
-rw-r--r--src/perl/irc/Channel.xs8
-rw-r--r--src/perl/perl-common.c4
-rw-r--r--src/perl/ui/Themes.xs2
-rw-r--r--src/perl/ui/Window.xs6
42 files changed, 304 insertions, 229 deletions
diff --git a/src/core/channel-rec.h b/src/core/channel-rec.h
index f3ec5f8d..7b806ca4 100644
--- a/src/core/channel-rec.h
+++ b/src/core/channel-rec.h
@@ -2,6 +2,7 @@
#include "window-item-rec.h"
+char *name;
char *topic;
char *topic_by;
time_t topic_time;
diff --git a/src/core/channels.c b/src/core/channels.c
index 1884c402..126c3b7e 100644
--- a/src/core/channels.c
+++ b/src/core/channels.c
@@ -35,24 +35,37 @@ static char *get_join_data(CHANNEL_REC *channel)
return g_strdup(channel->name);
}
-void channel_init(CHANNEL_REC *channel, int automatic)
+static const char *channel_get_target(WI_ITEM_REC *item)
+{
+ return ((CHANNEL_REC *) item)->name;
+}
+
+void channel_init(CHANNEL_REC *channel, SERVER_REC *server, const char *name,
+ const char *visible_name, int automatic)
{
g_return_if_fail(channel != NULL);
- g_return_if_fail(channel->name != NULL);
+ g_return_if_fail(name != NULL);
+ g_return_if_fail(server != NULL);
- channels = g_slist_append(channels, channel);
- if (channel->server != NULL) {
- channel->server->channels =
- g_slist_append(channel->server->channels, channel);
- }
+ if (visible_name == NULL)
+ visible_name = name;
MODULE_DATA_INIT(channel);
channel->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "CHANNEL");
channel->destroy = (void (*) (WI_ITEM_REC *)) channel_destroy;
- channel->mode = g_strdup("");
- channel->createtime = time(NULL);
+ channel->get_target = channel_get_target;
channel->get_join_data = get_join_data;
+ channel->chat_type = server->chat_type;
+ channel->server = server;
+ channel->name = g_strdup(name);
+ channel->visible_name = g_strdup(visible_name);
+ channel->mode = g_strdup("");
+ channel->createtime = time(NULL);
+
+ channels = g_slist_append(channels, channel);
+ server->channels = g_slist_append(server->channels, channel);
+
signal_emit("channel created", 2, channel, GINT_TO_POINTER(automatic));
}
diff --git a/src/core/channels.h b/src/core/channels.h
index 98b75ee0..ff121a2c 100644
--- a/src/core/channels.h
+++ b/src/core/channels.h
@@ -19,7 +19,8 @@ struct _CHANNEL_REC {
extern GSList *channels;
/* Create new channel record */
-void channel_init(CHANNEL_REC *channel, int automatic);
+void channel_init(CHANNEL_REC *channel, SERVER_REC *server, const char *name,
+ const char *visible_name, int automatic);
void channel_destroy(CHANNEL_REC *channel);
/* find channel by name, if `server' is NULL, search from all servers */
diff --git a/src/core/chat-commands.c b/src/core/chat-commands.c
index 933cc3f5..838db914 100644
--- a/src/core/chat-commands.c
+++ b/src/core/chat-commands.c
@@ -344,9 +344,8 @@ static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
target_type = IS_CHANNEL(item) ?
SEND_TARGET_CHANNEL : SEND_TARGET_NICK;
- target = item->name;
- }
- else if (g_hash_table_lookup(optlist, "channel") != NULL)
+ target = (char *) window_item_get_target(item);
+ } else if (g_hash_table_lookup(optlist, "channel") != NULL)
target_type = SEND_TARGET_CHANNEL;
else if (g_hash_table_lookup(optlist, "nick") != NULL)
target_type = SEND_TARGET_NICK;
diff --git a/src/core/chat-protocols.h b/src/core/chat-protocols.h
index ad8c64ba..95ab0937 100644
--- a/src/core/chat-protocols.h
+++ b/src/core/chat-protocols.h
@@ -18,7 +18,8 @@ struct _CHAT_PROTOCOL_REC {
void (*destroy_server_connect) (SERVER_CONNECT_REC *);
SERVER_REC *(*server_connect) (SERVER_CONNECT_REC *);
- CHANNEL_REC *(*channel_create) (SERVER_REC *, const char *, int);
+ CHANNEL_REC *(*channel_create) (SERVER_REC *, const char *,
+ const char *, int);
QUERY_REC *(*query_create) (const char *, const char *, int);
};
diff --git a/src/core/commands.c b/src/core/commands.c
index 96a74008..91e4a170 100644
--- a/src/core/commands.c
+++ b/src/core/commands.c
@@ -653,11 +653,12 @@ typedef struct {
GHashTable *options;
} CMD_TEMP_REC;
-static char *get_optional_channel(WI_ITEM_REC *active_item, char **data,
- int require_name)
+static const char *
+get_optional_channel(WI_ITEM_REC *active_item, char **data, int require_name)
{
CHANNEL_REC *chanrec;
- char *tmp, *origtmp, *channel, *ret;
+ const char *ret;
+ char *tmp, *origtmp, *channel;
if (active_item == NULL) {
/* no active channel in window, channel required */
@@ -670,10 +671,10 @@ static char *get_optional_channel(WI_ITEM_REC *active_item, char **data,
if (strcmp(channel, "*") == 0 && !require_name) {
/* "*" means active channel */
cmd_get_param(data);
- ret = active_item->name;
+ ret = window_item_get_target(active_item);
} else if (!server_ischannel(active_item->server, channel)) {
/* we don't have channel parameter - use active channel */
- ret = active_item->name;
+ ret = window_item_get_target(active_item);
} else {
/* Find the channel first and use it's name if found.
This allows automatic !channel -> !XXXXXchannel replaces. */
@@ -730,7 +731,7 @@ int cmd_get_params(const char *data, gpointer *free_me, int count, ...)
/* optional channel as first parameter */
require_name = (count & PARAM_FLAG_OPTCHAN_NAME) ==
PARAM_FLAG_OPTCHAN_NAME;
- arg = get_optional_channel(item, &datad, require_name);
+ arg = (char *) get_optional_channel(item, &datad, require_name);
str = (char **) va_arg(args, char **);
if (str != NULL) *str = arg;
diff --git a/src/core/expandos.c b/src/core/expandos.c
index 2830d677..6f0f392d 100644
--- a/src/core/expandos.c
+++ b/src/core/expandos.c
@@ -358,7 +358,8 @@ static char *expando_serverversion(SERVER_REC *server, void *item, int *free_ret
/* target of current input (channel or QUERY nickname) */
static char *expando_target(SERVER_REC *server, void *item, int *free_ret)
{
- return item == NULL ? "" : ((WI_ITEM_REC *) item)->name;
+ return item == NULL ? "" :
+ (char *) window_item_get_target((WI_ITEM_REC *) item);
}
/* client release date (in YYYYMMDD format) */
@@ -461,6 +462,12 @@ static char *expando_chatnet(SERVER_REC *server, void *item, int *free_ret)
return server == NULL ? "" : server->connrec->chatnet;
}
+/* visible_name of current window item */
+static char *expando_itemname(SERVER_REC *server, void *item, int *free_ret)
+{
+ return item == NULL ? "" : ((WI_ITEM_REC *) item)->visible_name;
+}
+
static void sig_message_public(SERVER_REC *server, const char *msg,
const char *nick, const char *address,
const char *target)
@@ -634,6 +641,9 @@ void expandos_init(void)
expando_create("chatnet", expando_chatnet,
"window changed", EXPANDO_ARG_NONE,
"window server changed", EXPANDO_ARG_WINDOW, NULL);
+ expando_create("itemname", expando_itemname,
+ "window changed", EXPANDO_ARG_NONE,
+ "window item changed", EXPANDO_ARG_WINDOW, NULL);
read_settings();
diff --git a/src/core/queries.c b/src/core/queries.c
index 8ae994a2..799a6320 100644
--- a/src/core/queries.c
+++ b/src/core/queries.c
@@ -27,6 +27,11 @@
GSList *queries;
+static const char *query_get_target(WI_ITEM_REC *item)
+{
+ return ((QUERY_REC *) item)->name;
+}
+
void query_init(QUERY_REC *query, int automatic)
{
g_return_if_fail(query != NULL);
@@ -37,8 +42,10 @@ void query_init(QUERY_REC *query, int automatic)
MODULE_DATA_INIT(query);
query->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "QUERY");
query->destroy = (void (*) (WI_ITEM_REC *)) query_destroy;
+ query->get_target = query_get_target;
query->createtime = time(NULL);
query->last_unread_msg = time(NULL);
+ query->visible_name = g_strdup(query->name);
if (query->server_tag != NULL) {
query->server = server_find_tag(query->server_tag);
@@ -69,6 +76,7 @@ void query_destroy(QUERY_REC *query)
g_free_not_null(query->hilight_color);
g_free_not_null(query->server_tag);
g_free_not_null(query->address);
+ g_free(query->visible_name);
g_free(query->name);
query->type = 0;
@@ -124,6 +132,10 @@ void query_change_nick(QUERY_REC *query, const char *nick)
oldnick = query->name;
query->name = g_strdup(nick);
+
+ g_free(query->visible_name);
+ query->visible_name = g_strdup(nick);
+
signal_emit("query nick changed", 2, query, oldnick);
signal_emit("window item name changed", 1, query);
g_free(oldnick);
diff --git a/src/core/query-rec.h b/src/core/query-rec.h
index fc08d2ef..ddb85ba4 100644
--- a/src/core/query-rec.h
+++ b/src/core/query-rec.h
@@ -2,6 +2,7 @@
#include "window-item-rec.h"
+char *name;
char *address;
char *server_tag;
time_t last_unread_msg;
diff --git a/src/core/session.c b/src/core/session.c
index b5419134..4e7a832c 100644
--- a/src/core/session.c
+++ b/src/core/session.c
@@ -146,6 +146,7 @@ static void session_save_channel(CHANNEL_REC *channel, CONFIG_REC *config,
node = config_node_section(node, NULL, NODE_TYPE_BLOCK);
config_node_set_str(config, node, "name", channel->name);
+ config_node_set_str(config, node, "visible_name", channel->visible_name);
config_node_set_str(config, node, "topic", channel->topic);
config_node_set_str(config, node, "topic_by", channel->topic_by);
config_node_set_int(config, node, "topic_time", channel->topic_time);
@@ -215,13 +216,14 @@ static void session_restore_channel_nicks(CHANNEL_REC *channel,
static void session_restore_channel(SERVER_REC *server, CONFIG_NODE *node)
{
CHANNEL_REC *channel;
- const char *name;
+ const char *name, *visible_name;
name = config_node_get_str(node, "name", NULL);
if (name == NULL)
return;
- channel = CHAT_PROTOCOL(server)->channel_create(server, name, TRUE);
+ visible_name = config_node_get_str(node, "visible_name", NULL);
+ channel = CHAT_PROTOCOL(server)->channel_create(server, name, visible_name, TRUE);
channel->topic = g_strdup(config_node_get_str(node, "topic", NULL));
channel->topic_by = g_strdup(config_node_get_str(node, "topic_by", NULL));
channel->topic_time = config_node_get_int(node, "topic_time", 0);
diff --git a/src/core/window-item-rec.h b/src/core/window-item-rec.h
index eeb465f4..d7b6f7db 100644
--- a/src/core/window-item-rec.h
+++ b/src/core/window-item-rec.h
@@ -6,7 +6,7 @@ GHashTable *module_data;
void *window;
STRUCT_SERVER_REC *server;
-char *name;
+char *visible_name;
time_t createtime;
int data_level;
@@ -14,4 +14,8 @@ char *hilight_color;
void (*destroy)(WI_ITEM_REC *item);
+const char *(*get_target)(WI_ITEM_REC *item);
+#define window_item_get_target(item) \
+ ((item)->get_target(item))
+
#undef STRUCT_SERVER_REC
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;
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;
diff --git a/src/perl/common/Channel.xs b/src/perl/common/Channel.xs
index f425dc2b..0692a7cc 100644
--- a/src/perl/common/Channel.xs
+++ b/src/perl/common/Channel.xs
@@ -43,14 +43,6 @@ CODE:
server->channels_join(server, channels, automatic);
Irssi::Channel
-channel_create(server, name, automatic)
- Irssi::Server server
- char *name
- int automatic
-CODE:
- CHAT_PROTOCOL(server)->channel_create(server, name, automatic);
-
-Irssi::Channel
channel_find(server, name)
Irssi::Server server
char *name
diff --git a/src/perl/irc/Channel.xs b/src/perl/irc/Channel.xs
index 0bf94753..472bb56d 100644
--- a/src/perl/irc/Channel.xs
+++ b/src/perl/irc/Channel.xs
@@ -61,11 +61,3 @@ CODE:
RETVAL = irc_nicklist_insert(channel, nick, op, halfop, voice, send_massjoin);
OUTPUT:
RETVAL
-
-MODULE = Irssi::Irc::Channel PACKAGE = Irssi::Irc::Server PREFIX = irc_
-
-Irssi::Irc::Channel
-irc_channel_create(server, name, automatic)
- Irssi::Irc::Server server
- char *name
- int automatic
diff --git a/src/perl/perl-common.c b/src/perl/perl-common.c
index 72fc557c..be73bd30 100644
--- a/src/perl/perl-common.c
+++ b/src/perl/perl-common.c
@@ -326,7 +326,7 @@ void perl_window_item_fill_hash(HV *hv, WI_ITEM_REC *item)
if (item->server != NULL) {
hv_store(hv, "server", 6, iobject_bless(item->server), 0);
}
- hv_store(hv, "name", 4, new_pv(item->name), 0);
+ hv_store(hv, "visible_name", 12, new_pv(item->visible_name), 0);
hv_store(hv, "createtime", 10, newSViv(item->createtime), 0);
hv_store(hv, "data_level", 10, newSViv(item->data_level), 0);
@@ -343,6 +343,7 @@ void perl_channel_fill_hash(HV *hv, CHANNEL_REC *channel)
if (channel->ownnick != NULL)
hv_store(hv, "ownnick", 7, iobject_bless(channel->ownnick), 0);
+ hv_store(hv, "name", 4, new_pv(channel->name), 0);
hv_store(hv, "topic", 5, new_pv(channel->topic), 0);
hv_store(hv, "topic_by", 8, new_pv(channel->topic_by), 0);
hv_store(hv, "topic_time", 10, newSViv(channel->topic_time), 0);
@@ -369,6 +370,7 @@ void perl_query_fill_hash(HV *hv, QUERY_REC *query)
perl_window_item_fill_hash(hv, (WI_ITEM_REC *) query);
+ hv_store(hv, "name", 4, new_pv(query->name), 0);
hv_store(hv, "last_unread_msg", 15, newSViv(query->last_unread_msg), 0);
hv_store(hv, "address", 7, new_pv(query->address), 0);
hv_store(hv, "server_tag", 10, new_pv(query->server_tag), 0);
diff --git a/src/perl/ui/Themes.xs b/src/perl/ui/Themes.xs
index 64a05676..7f1c5277 100644
--- a/src/perl/ui/Themes.xs
+++ b/src/perl/ui/Themes.xs
@@ -195,7 +195,7 @@ PREINIT:
char *arglist[MAX_FORMAT_PARAMS+1];
int n;
CODE:
- format_create_dest(&dest, item->server, item->name, level, NULL);
+ format_create_dest(&dest, item->server, item->visible_name, level, NULL);
memset(arglist, 0, sizeof(arglist));
for (n = 3; n < items && n < MAX_FORMAT_PARAMS+3; n++) {
arglist[n-3] = SvPV(ST(n), PL_na);
diff --git a/src/perl/ui/Window.xs b/src/perl/ui/Window.xs
index cadff1ab..89d874ee 100644
--- a/src/perl/ui/Window.xs
+++ b/src/perl/ui/Window.xs
@@ -225,6 +225,10 @@ window_activity(window, data_level, hilight_color=NULL)
char *
window_get_active_name(window)
Irssi::UI::Window window
+CODE:
+ RETVAL = (char *) window_get_active_name(window);
+OUTPUT:
+ RETVAL
Irssi::Windowitem
window_item_find(window, server, name)
@@ -246,7 +250,7 @@ print(item, str, level=MSGLEVEL_CLIENTNOTICE)
int level
char *str
CODE:
- printtext_string(item->server, item->name, level, str);
+ printtext_string(item->server, item->visible_name, level, str);
Irssi::UI::Window
window_create(item, automatic)