summaryrefslogtreecommitdiff
path: root/src/plugins/irc/irc-buffer.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2013-03-17 22:18:11 +0100
committerSebastien Helleu <flashcode@flashtux.org>2013-03-17 22:18:11 +0100
commitbbd080e6802b8fd6f442e8d8bbf41f45d0e86971 (patch)
tree857bc7bdbe64df3a4080119645f0ed64a8da3604 /src/plugins/irc/irc-buffer.c
parent3e1d811761887ca6c234e7b369febdf3d1710ae5 (diff)
downloadweechat-bbd080e6802b8fd6f442e8d8bbf41f45d0e86971.zip
irc: add option irc.look.pv_buffer: automatically merge private buffers (optionally by server) (task #11924)
Diffstat (limited to 'src/plugins/irc/irc-buffer.c')
-rw-r--r--src/plugins/irc/irc-buffer.c47
1 files changed, 44 insertions, 3 deletions
diff --git a/src/plugins/irc/irc-buffer.c b/src/plugins/irc/irc-buffer.c
index c29a1f050..24789ecc2 100644
--- a/src/plugins/irc/irc-buffer.c
+++ b/src/plugins/irc/irc-buffer.c
@@ -184,14 +184,13 @@ irc_buffer_nickcmp_cb (void *data,
}
/*
- * Searches for first server buffer that will be used to merge all IRC server
- * buffers.
+ * Searches for the server buffer with the lowest number.
*
* Returns pointer to buffer found, NULL if not found.
*/
struct t_gui_buffer *
-irc_buffer_search_first_for_all_servers ()
+irc_buffer_search_server_lowest_number ()
{
struct t_gui_buffer *ptr_buffer;
struct t_irc_server *ptr_server;
@@ -215,3 +214,45 @@ irc_buffer_search_first_for_all_servers ()
}
return ptr_buffer;
}
+
+/*
+ * Searches for the private buffer with the lowest number.
+ * If server is not NULL, searches only for this server.
+ *
+ * Returns pointer to buffer found, NULL if not found.
+ */
+
+struct t_gui_buffer *
+irc_buffer_search_private_lowest_number (struct t_irc_server *server)
+{
+ struct t_gui_buffer *ptr_buffer;
+ struct t_irc_server *ptr_server;
+ struct t_irc_channel *ptr_channel;
+ int number, number_found;
+
+ ptr_buffer = NULL;
+ number_found = INT_MAX;
+
+ for (ptr_server = (server) ? server : irc_servers; ptr_server;
+ ptr_server = ptr_server->next_server)
+ {
+ for (ptr_channel = ptr_server->channels; ptr_channel;
+ ptr_channel = ptr_channel->next_channel)
+ {
+ if ((ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)
+ && ptr_channel->buffer)
+ {
+ number = weechat_buffer_get_integer (ptr_channel->buffer,
+ "number");
+ if (number < number_found)
+ {
+ number_found = number;
+ ptr_buffer = ptr_channel->buffer;
+ }
+ }
+ }
+ if (server)
+ break;
+ }
+ return ptr_buffer;
+}