summaryrefslogtreecommitdiff
path: root/src/plugins/irc
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2011-08-14 16:04:12 +0200
committerSebastien Helleu <flashcode@flashtux.org>2011-08-14 16:04:12 +0200
commit5073cd34768a871a77f21064f4f57899ad20fcbd (patch)
tree85c860759a37d9f849ceaa702b89f2066c00ae3b /src/plugins/irc
parentdd4863d67cc3a1e5b9c1aea6e9ec5e1432100a75 (diff)
downloadweechat-5073cd34768a871a77f21064f4f57899ad20fcbd.zip
core: add buffer property "short_name_is_set", return name if short name is not set (in buffer infolist or property)
Diffstat (limited to 'src/plugins/irc')
-rw-r--r--src/plugins/irc/irc-channel.c29
-rw-r--r--src/plugins/irc/irc-raw.c2
-rw-r--r--src/plugins/irc/irc-server.c31
3 files changed, 20 insertions, 42 deletions
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index 433141cf1..17e9c18f9 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -209,7 +209,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
if (buffer_created)
{
- if (!weechat_buffer_get_string (new_buffer, "short_name"))
+ if (!weechat_buffer_get_integer (new_buffer, "short_name_is_set"))
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");
@@ -918,7 +918,6 @@ 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;
@@ -929,24 +928,14 @@ irc_channel_add_to_infolist (struct t_infolist *infolist,
if (!weechat_infolist_new_var_pointer (ptr_item, "buffer", channel->buffer))
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_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 (!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-raw.c b/src/plugins/irc/irc-raw.c
index 3074979d3..051c85667 100644
--- a/src/plugins/irc/irc-raw.c
+++ b/src/plugins/irc/irc-raw.c
@@ -85,7 +85,7 @@ irc_raw_open (int switch_to_buffer)
weechat_buffer_set (irc_raw_buffer,
"title", _("IRC raw messages"));
- if (!weechat_buffer_get_string (irc_raw_buffer, "short_name"))
+ if (!weechat_buffer_get_integer (irc_raw_buffer, "short_name_is_set"))
{
weechat_buffer_set (irc_raw_buffer, "short_name",
IRC_RAW_BUFFER_NAME);
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 5a2b26237..fe1b0617f 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -1299,7 +1299,7 @@ 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);
- if (!weechat_buffer_get_string (server->buffer, "short_name"))
+ if (!weechat_buffer_get_integer (server->buffer, "short_name_is_set"))
weechat_buffer_set (server->buffer, "short_name", server->name);
weechat_buffer_set (server->buffer, "localvar_set_server",
server->name);
@@ -2840,7 +2840,7 @@ irc_server_create_buffer (struct t_irc_server *server)
if (!server->buffer)
return NULL;
- if (!weechat_buffer_get_string (server->buffer, "short_name"))
+ if (!weechat_buffer_get_integer (server->buffer, "short_name_is_set"))
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);
@@ -4040,7 +4040,6 @@ 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;
@@ -4053,24 +4052,14 @@ 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 (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, "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 (!weechat_infolist_new_var_string (ptr_item, "addresses",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_ADDRESSES)))
return 0;