summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2008-09-24 19:39:17 +0200
committerSebastien Helleu <flashcode@flashtux.org>2008-09-24 19:39:17 +0200
commitace2d20e33da6bd22d08f0cbcf53c85036bece43 (patch)
tree229c2d6e3930866fdffe1b9c430820d33f2b861e
parent0fd3f8b6eb4e0643f583be150c9c47c479f0ef64 (diff)
downloadweechat-ace2d20e33da6bd22d08f0cbcf53c85036bece43.zip
Fix /upgrade when there is one buffer for all IRC servers
-rw-r--r--src/core/wee-upgrade.c32
-rw-r--r--src/gui/gui-buffer.c32
-rw-r--r--src/gui/gui-buffer.h5
-rw-r--r--src/plugins/irc/irc-server.c11
-rw-r--r--src/plugins/irc/irc-upgrade.c24
5 files changed, 95 insertions, 9 deletions
diff --git a/src/core/wee-upgrade.c b/src/core/wee-upgrade.c
index c2c1f1617..3df61740d 100644
--- a/src/core/wee-upgrade.c
+++ b/src/core/wee-upgrade.c
@@ -23,6 +23,7 @@
#include "config.h"
#endif
+#include <stdlib.h>
#include <string.h>
#include "weechat.h"
@@ -278,12 +279,13 @@ int
upgrade_weechat_read_cb (int object_id,
struct t_infolist *infolist)
{
- char *type, *name, *prefix, *group_name;
+ char *type, *name, *prefix, *group_name, option_name[32], *key;
+ char *option_key;
struct t_gui_nick_group *ptr_group;
struct t_gui_buffer *ptr_buffer;
struct timeval creation_time;
void *buf;
- int size;
+ int size, key_index, length;
infolist_reset_item_cursor (infolist);
while (infolist_next (infolist))
@@ -321,6 +323,32 @@ upgrade_weechat_read_cb (int object_id,
infolist_integer (infolist, "nicklist_case_sensitive");
upgrade_current_buffer->nicklist_display_groups =
infolist_integer (infolist, "nicklist_display_groups");
+ gui_buffer_set_highlight_words (upgrade_current_buffer,
+ infolist_string (infolist, "highlight_words"));
+ gui_buffer_set_highlight_tags (upgrade_current_buffer,
+ infolist_string (infolist, "highlight_tags"));
+ key_index = 0;
+ while (1)
+ {
+ snprintf (option_name, sizeof (option_name),
+ "key_%05d", key_index);
+ key = infolist_string (infolist, option_name);
+ if (!key)
+ break;
+ length = 16 + strlen (key) + 1;
+ option_key = malloc (length);
+ if (option_key)
+ {
+ snprintf (option_key, length, "key_bind_%s", key);
+ snprintf (option_name, sizeof (option_name),
+ "key_command_%05d", key_index);
+ gui_buffer_set (upgrade_current_buffer,
+ option_key,
+ infolist_string (infolist, option_name));
+ free (option_key);
+ }
+ key_index++;
+ }
}
}
else
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index cd943b844..3fa7b2e99 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -171,6 +171,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
/* highlight */
new_buffer->highlight_words = NULL;
+ new_buffer->highlight_tags = NULL;
new_buffer->highlight_tags_count = 0;
new_buffer->highlight_tags_array = NULL;
@@ -481,17 +482,24 @@ void
gui_buffer_set_highlight_tags (struct t_gui_buffer *buffer,
const char *new_highlight_tags)
{
+ if (buffer->highlight_tags)
+ free (buffer->highlight_tags);
if (buffer->highlight_tags_array)
string_free_exploded (buffer->highlight_tags_array);
if (new_highlight_tags)
{
- buffer->highlight_tags_array = string_explode (new_highlight_tags,
- ",", 0, 0,
- &buffer->highlight_tags_count);
+ buffer->highlight_tags = strdup (new_highlight_tags);
+ if (buffer->highlight_tags)
+ {
+ buffer->highlight_tags_array = string_explode (new_highlight_tags,
+ ",", 0, 0,
+ &buffer->highlight_tags_count);
+ }
}
else
{
+ buffer->highlight_tags = NULL;
buffer->highlight_tags_count = 0;
buffer->highlight_tags_array = NULL;
}
@@ -1148,7 +1156,9 @@ gui_buffer_add_to_infolist (struct t_infolist *infolist,
struct t_gui_buffer *buffer)
{
struct t_infolist_item *ptr_item;
- char *pos_point;
+ struct t_gui_key *ptr_key;
+ char *pos_point, option_name[32];
+ int i;
if (!infolist || !buffer)
return 0;
@@ -1196,6 +1206,20 @@ gui_buffer_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!infolist_new_var_string (ptr_item, "input_string", buffer->input_buffer))
return 0;
+ if (!infolist_new_var_string (ptr_item, "highlight_words", buffer->highlight_words))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "highlight_tags", buffer->highlight_tags))
+ return 0;
+ i = 0;
+ for (ptr_key = buffer->keys; ptr_key; ptr_key = ptr_key->next_key)
+ {
+ snprintf (option_name, sizeof (option_name), "key_%05d", i);
+ if (!infolist_new_var_string (ptr_item, option_name, ptr_key->key))
+ return 0;
+ snprintf (option_name, sizeof (option_name), "key_command_%05d", i);
+ if (!infolist_new_var_string (ptr_item, option_name, ptr_key->command))
+ return 0;
+ }
return 1;
}
diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h
index dc8c6b887..9e1a245f8 100644
--- a/src/gui/gui-buffer.h
+++ b/src/gui/gui-buffer.h
@@ -146,6 +146,7 @@ struct t_gui_buffer
/* highlight settings for buffer */
char *highlight_words; /* list of words to highlight */
+ char *highlight_tags; /* tags to highlight */
int highlight_tags_count; /* number of tags to highlight */
/* (if 0, any tag is highlighted) */
char **highlight_tags_array; /* tags to highlight */
@@ -202,6 +203,10 @@ extern void gui_buffer_set_nicklist (struct t_gui_buffer *buffer,
extern void gui_buffer_set_nicklist_case_sensitive (struct t_gui_buffer * buffer,
int case_sensitive);
extern void gui_buffer_set_nick (struct t_gui_buffer *buffer, const char *new_nick);
+extern void gui_buffer_set_highlight_words (struct t_gui_buffer *buffer,
+ const char *new_highlight_words);
+extern void gui_buffer_set_highlight_tags (struct t_gui_buffer *buffer,
+ const char *new_highlight_tags);
extern void gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
void *value);
extern struct t_gui_buffer *gui_buffer_search_main ();
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 880363dab..c49721272 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -2840,6 +2840,17 @@ irc_server_add_to_infolist (struct t_infolist *infolist,
if (!weechat_infolist_new_var_string (ptr_item, "name", server->name))
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_integer (ptr_item, "selected",
+ (weechat_config_boolean (irc_config_look_one_server_buffer)
+ && (irc_current_server != server)) ?
+ 0 : 1))
+ return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "autoconnect", server->autoconnect))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "autoreconnect", server->autoreconnect))
diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c
index c342bf972..afe8c8f85 100644
--- a/src/plugins/irc/irc-upgrade.c
+++ b/src/plugins/irc/irc-upgrade.c
@@ -25,6 +25,7 @@
#include "irc.h"
#include "irc-upgrade.h"
#include "irc-buffer.h"
+#include "irc-config.h"
#include "irc-input.h"
#include "irc-server.h"
#include "irc-channel.h"
@@ -168,8 +169,9 @@ irc_upgrade_read_cb (int object_id,
struct t_infolist *infolist)
{
int flags, sock, size;
- char *str, *buf;
+ char *str, *buf, *buffer_name;
struct t_irc_nick *ptr_nick;
+ struct t_gui_buffer *ptr_buffer;
weechat_infolist_reset_item_cursor (infolist);
while (weechat_infolist_next (infolist))
@@ -180,8 +182,24 @@ irc_upgrade_read_cb (int object_id,
irc_upgrade_current_server = irc_server_search (weechat_infolist_string (infolist, "name"));
if (irc_upgrade_current_server)
{
- irc_upgrade_current_server->buffer = weechat_buffer_search (IRC_PLUGIN_NAME,
- irc_upgrade_current_server->name);
+ irc_upgrade_current_server->buffer = NULL;
+ buffer_name = weechat_infolist_string (infolist, "buffer_name");
+ if (buffer_name && buffer_name[0])
+ {
+ ptr_buffer = weechat_buffer_search (IRC_PLUGIN_NAME,
+ buffer_name);
+ if (ptr_buffer)
+ {
+ irc_upgrade_current_server->buffer = ptr_buffer;
+ if (weechat_config_boolean (irc_config_look_one_server_buffer)
+ && !irc_buffer_servers)
+ {
+ irc_buffer_servers = ptr_buffer;
+ }
+ if (weechat_infolist_integer (infolist, "selected"))
+ irc_current_server = irc_upgrade_current_server;
+ }
+ }
irc_upgrade_current_server->current_address = weechat_infolist_integer (infolist, "current_address");
sock = weechat_infolist_integer (infolist, "sock");