diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2011-08-14 13:20:47 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2011-08-14 13:20:47 +0200 |
commit | 2c204265771c1bb9e012c283dc05f89c96d785a8 (patch) | |
tree | 5d82f941cda3e9813e2563ef2ca22370ca07ef6f /src | |
parent | cc3a4834d02feef08cb413d8fb37f18369bb432b (diff) | |
download | weechat-2c204265771c1bb9e012c283dc05f89c96d785a8.zip |
irc: set short name on buffers only if it was not set by another plugin/script
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/irc/irc-channel.c | 30 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 7 | ||||
-rw-r--r-- | src/plugins/irc/irc-raw.c | 6 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.c | 35 |
4 files changed, 56 insertions, 22 deletions
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c index 5e1ba5d99..433141cf1 100644 --- a/src/plugins/irc/irc-channel.c +++ b/src/plugins/irc/irc-channel.c @@ -209,7 +209,8 @@ irc_channel_new (struct t_irc_server *server, int channel_type, if (buffer_created) { - weechat_buffer_set (new_buffer, "short_name", channel_name); + if (!weechat_buffer_get_string (new_buffer, "short_name")) + weechat_buffer_set (new_buffer, "short_name", channel_name); weechat_buffer_set (new_buffer, "localvar_set_type", (channel_type == IRC_CHANNEL_TYPE_CHANNEL) ? "channel" : "private"); weechat_buffer_set (new_buffer, "localvar_set_nick", server->nick); @@ -917,6 +918,7 @@ irc_channel_add_to_infolist (struct t_infolist *infolist, struct t_irc_channel_speaking *ptr_nick; char option_name[64]; int i, index; + const char *name, *short_name; if (!infolist || !channel) return 0; @@ -927,14 +929,24 @@ irc_channel_add_to_infolist (struct t_infolist *infolist, if (!weechat_infolist_new_var_pointer (ptr_item, "buffer", channel->buffer)) return 0; - if (!weechat_infolist_new_var_string (ptr_item, "buffer_name", - (channel->buffer) ? - weechat_buffer_get_string (channel->buffer, "name") : "")) - return 0; - if (!weechat_infolist_new_var_string (ptr_item, "buffer_short_name", - (channel->buffer) ? - weechat_buffer_get_string (channel->buffer, "short_name") : "")) - return 0; + if (channel->buffer) + { + name = weechat_buffer_get_string (channel->buffer, "name"); + short_name = weechat_buffer_get_string (channel->buffer, "short_name"); + if (!short_name) + short_name = name; + if (!weechat_infolist_new_var_string (ptr_item, "buffer_name", name)) + return 0; + if (!weechat_infolist_new_var_string (ptr_item, "buffer_short_name", short_name)) + return 0; + } + else + { + if (!weechat_infolist_new_var_string (ptr_item, "buffer_name", "")) + return 0; + if (!weechat_infolist_new_var_string (ptr_item, "buffer_short_name", "")) + return 0; + } if (!weechat_infolist_new_var_integer (ptr_item, "type", channel->type)) return 0; if (!weechat_infolist_new_var_string (ptr_item, "name", channel->name)) diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 766692799..d62d718c3 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -851,7 +851,12 @@ IRC_PROTOCOL_CALLBACK(nick) } buffer_name = irc_buffer_build_name (server->name, ptr_channel->name); weechat_buffer_set (ptr_channel->buffer, "name", buffer_name); - weechat_buffer_set (ptr_channel->buffer, "short_name", ptr_channel->name); + if (!weechat_buffer_get_string (ptr_channel->buffer, + "short_name")) + { + weechat_buffer_set (ptr_channel->buffer, "short_name", + ptr_channel->name); + } weechat_buffer_set (ptr_channel->buffer, "localvar_set_channel", ptr_channel->name); } diff --git a/src/plugins/irc/irc-raw.c b/src/plugins/irc/irc-raw.c index 01cb97d93..3074979d3 100644 --- a/src/plugins/irc/irc-raw.c +++ b/src/plugins/irc/irc-raw.c @@ -85,7 +85,11 @@ irc_raw_open (int switch_to_buffer) weechat_buffer_set (irc_raw_buffer, "title", _("IRC raw messages")); - weechat_buffer_set (irc_raw_buffer, "short_name", IRC_RAW_BUFFER_NAME); + if (!weechat_buffer_get_string (irc_raw_buffer, "short_name")) + { + weechat_buffer_set (irc_raw_buffer, "short_name", + IRC_RAW_BUFFER_NAME); + } weechat_buffer_set (irc_raw_buffer, "localvar_set_type", "debug"); weechat_buffer_set (irc_raw_buffer, "localvar_set_server", IRC_RAW_BUFFER_NAME); weechat_buffer_set (irc_raw_buffer, "localvar_set_channel", IRC_RAW_BUFFER_NAME); diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index cf8aff758..5a2b26237 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -1299,7 +1299,8 @@ irc_server_rename (struct t_irc_server *server, const char *new_server_name) { buffer_name = irc_buffer_build_name (server->name, NULL); weechat_buffer_set (server->buffer, "name", buffer_name); - weechat_buffer_set (server->buffer, "short_name", server->name); + if (!weechat_buffer_get_string (server->buffer, "short_name")) + weechat_buffer_set (server->buffer, "short_name", server->name); weechat_buffer_set (server->buffer, "localvar_set_server", server->name); weechat_buffer_set (server->buffer, "localvar_set_channel", @@ -2838,8 +2839,9 @@ irc_server_create_buffer (struct t_irc_server *server) &irc_buffer_close_cb, NULL); if (!server->buffer) return NULL; - - weechat_buffer_set (server->buffer, "short_name", server->name); + + if (!weechat_buffer_get_string (server->buffer, "short_name")) + weechat_buffer_set (server->buffer, "short_name", server->name); weechat_buffer_set (server->buffer, "localvar_set_type", "server"); weechat_buffer_set (server->buffer, "localvar_set_server", server->name); weechat_buffer_set (server->buffer, "localvar_set_channel", server->name); @@ -4038,6 +4040,7 @@ irc_server_add_to_infolist (struct t_infolist *infolist, struct t_irc_server *server) { struct t_infolist_item *ptr_item; + const char *name, *short_name; if (!infolist || !server) return 0; @@ -4050,14 +4053,24 @@ irc_server_add_to_infolist (struct t_infolist *infolist, return 0; if (!weechat_infolist_new_var_pointer (ptr_item, "buffer", server->buffer)) return 0; - if (!weechat_infolist_new_var_string (ptr_item, "buffer_name", - (server->buffer) ? - weechat_buffer_get_string (server->buffer, "name") : "")) - return 0; - if (!weechat_infolist_new_var_string (ptr_item, "buffer_short_name", - (server->buffer) ? - weechat_buffer_get_string (server->buffer, "short_name") : "")) - return 0; + if (server->buffer) + { + name = weechat_buffer_get_string (server->buffer, "name"); + short_name = weechat_buffer_get_string (server->buffer, "short_name"); + if (!short_name) + short_name = name; + if (!weechat_infolist_new_var_string (ptr_item, "buffer_name", name)) + return 0; + if (!weechat_infolist_new_var_string (ptr_item, "buffer_short_name", short_name)) + return 0; + } + else + { + if (!weechat_infolist_new_var_string (ptr_item, "buffer_name", "")) + return 0; + if (!weechat_infolist_new_var_string (ptr_item, "buffer_short_name", "")) + return 0; + } if (!weechat_infolist_new_var_string (ptr_item, "addresses", IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_ADDRESSES))) return 0; |