summaryrefslogtreecommitdiff
path: root/src/plugins/irc
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/irc')
-rw-r--r--src/plugins/irc/irc-bar-item.c109
-rw-r--r--src/plugins/irc/irc-nick.c4
-rw-r--r--src/plugins/irc/irc-server.c7
3 files changed, 120 insertions, 0 deletions
diff --git a/src/plugins/irc/irc-bar-item.c b/src/plugins/irc/irc-bar-item.c
index bfc8379de..2afb1027f 100644
--- a/src/plugins/irc/irc-bar-item.c
+++ b/src/plugins/irc/irc-bar-item.c
@@ -380,6 +380,106 @@ irc_bar_item_channel (const void *pointer, void *data,
}
/*
+ * Returns content of bar item "irc_nick": bar item with nick name
+ * (without modes).
+ */
+
+char *
+irc_bar_item_nick (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window, struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
+{
+ char buf[512];
+ struct t_irc_server *server;
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) item;
+ (void) window;
+ (void) extra_info;
+
+ if (!buffer)
+ return NULL;
+
+ irc_buffer_get_server_and_channel (buffer, &server, NULL);
+ if (!server || !server->nick)
+ return NULL;
+
+ snprintf (buf, sizeof (buf), "%s%s",
+ IRC_COLOR_INPUT_NICK,
+ server->nick);
+
+ return strdup (buf);
+}
+
+/*
+ * Returns content of bar item "irc_host": bar item with self host.
+ */
+
+char *
+irc_bar_item_host (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window, struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
+{
+ struct t_irc_server *server;
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) item;
+ (void) window;
+ (void) extra_info;
+
+ if (!buffer)
+ return NULL;
+
+ irc_buffer_get_server_and_channel (buffer, &server, NULL);
+ if (!server || !server->nick_host)
+ return NULL;
+
+ return strdup (server->nick_host);
+}
+
+/*
+ * Returns content of bar item "irc_nick_host": bar item with nick and host.
+ */
+
+char *
+irc_bar_item_nick_host (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
+{
+ char buf[512];
+ struct t_irc_server *server;
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) item;
+ (void) window;
+ (void) extra_info;
+
+ if (!buffer)
+ return NULL;
+
+ irc_buffer_get_server_and_channel (buffer, &server, NULL);
+ if (!server || !server->nick)
+ return NULL;
+
+ snprintf (buf, sizeof (buf), "%s%s%s",
+ server->nick,
+ (server->nick_host) ? "@" : "",
+ (server->nick_host) ? server->nick_host : "");
+
+ return strdup (buf);
+}
+
+/*
* Returns content of bar item "lag": bar item with lag value.
*/
@@ -615,6 +715,9 @@ irc_bar_item_buffer_switch (const void *pointer, void *data,
weechat_bar_item_update ("lag");
weechat_bar_item_update ("input_prompt");
weechat_bar_item_update ("irc_nick_modes");
+ weechat_bar_item_update ("irc_nick");
+ weechat_bar_item_update ("irc_host");
+ weechat_bar_item_update ("irc_nick_host");
return WEECHAT_RC_OK;
}
@@ -648,6 +751,12 @@ irc_bar_item_init ()
&irc_bar_item_buffer_modes, NULL, NULL);
weechat_bar_item_new ("irc_channel",
&irc_bar_item_channel, NULL, NULL);
+ weechat_bar_item_new ("irc_nick",
+ &irc_bar_item_nick, NULL, NULL);
+ weechat_bar_item_new ("irc_host",
+ &irc_bar_item_host, NULL, NULL);
+ weechat_bar_item_new ("irc_nick_host",
+ &irc_bar_item_nick_host, NULL, NULL);
weechat_bar_item_new ("lag",
&irc_bar_item_lag, NULL, NULL);
weechat_bar_item_new ("input_prompt",
diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c
index 3e8b55c25..5295016b5 100644
--- a/src/plugins/irc/irc-nick.c
+++ b/src/plugins/irc/irc-nick.c
@@ -624,7 +624,11 @@ irc_nick_set_mode (struct t_irc_server *server, struct t_irc_channel *channel,
irc_nick_nicklist_add (server, channel, nick);
if (irc_server_strcasecmp (server, nick->name, server->nick) == 0)
+ {
weechat_bar_item_update ("input_prompt");
+ weechat_bar_item_update ("irc_nick");
+ weechat_bar_item_update ("irc_nick_host");
+ }
}
/*
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index aa23ed56e..28d0136af 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -756,6 +756,8 @@ irc_server_set_nick (struct t_irc_server *server, const char *nick)
}
weechat_bar_item_update ("input_prompt");
+ weechat_bar_item_update ("irc_nick");
+ weechat_bar_item_update ("irc_nick_host");
}
/*
@@ -787,6 +789,9 @@ irc_server_set_nick_host (struct t_irc_server *server, const char *host)
weechat_buffer_set (ptr_channel->buffer,
"localvar_set_nick_host", host);
}
+
+ weechat_bar_item_update ("irc_host");
+ weechat_bar_item_update ("irc_nick_host");
}
/*
@@ -5115,6 +5120,8 @@ irc_server_disconnect (struct t_irc_server *server, int switch_address,
{
free (server->nick_host);
server->nick_host = NULL;
+ weechat_bar_item_update ("irc_host");
+ weechat_bar_item_update ("irc_nick_host");
}
server->checking_cap_ls = 0;
weechat_hashtable_remove_all (server->cap_ls);