mirror of
https://github.com/weechat/weechat.git
synced 2026-07-04 00:33:13 +02:00
Added hotlist in session file when using /upgrade command (task #5449)
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2006-08-20
|
||||
ChangeLog - 2006-08-21
|
||||
|
||||
|
||||
Version 0.2.1 (under dev!):
|
||||
* added hotlist in session file when using /upgrade command (task #5449)
|
||||
* fixed nick refresh problem with unrealircd specific modes: chan owner (~)
|
||||
and chan admin (&) (bug #17340)
|
||||
|
||||
|
||||
@@ -76,7 +76,8 @@ hotlist_find_pos (t_weechat_hotlist *new_hotlist)
|
||||
*/
|
||||
|
||||
void
|
||||
hotlist_add (int priority, t_irc_server *server, t_gui_buffer *buffer)
|
||||
hotlist_add (int priority, t_irc_server *server, t_gui_buffer *buffer,
|
||||
int allow_current_buffer)
|
||||
{
|
||||
t_weechat_hotlist *new_hotlist, *pos_hotlist;
|
||||
|
||||
@@ -84,7 +85,8 @@ hotlist_add (int priority, t_irc_server *server, t_gui_buffer *buffer)
|
||||
return;
|
||||
|
||||
/* do not highlight current buffer */
|
||||
if (buffer == gui_current_window->buffer)
|
||||
if ((buffer == gui_current_window->buffer)
|
||||
&& (!allow_current_buffer))
|
||||
return;
|
||||
|
||||
if ((pos_hotlist = hotlist_search (buffer)))
|
||||
|
||||
@@ -43,7 +43,7 @@ struct t_weechat_hotlist
|
||||
extern t_weechat_hotlist *hotlist;
|
||||
extern t_gui_buffer *hotlist_initial_buffer;
|
||||
|
||||
extern void hotlist_add (int, t_irc_server *, t_gui_buffer *);
|
||||
extern void hotlist_add (int, t_irc_server *, t_gui_buffer *, int);
|
||||
extern void hotlist_free (t_weechat_hotlist *);
|
||||
extern void hotlist_free_all ();
|
||||
extern void hotlist_remove_buffer (t_gui_buffer *);
|
||||
|
||||
+112
-9
@@ -36,6 +36,7 @@
|
||||
|
||||
#include "weechat.h"
|
||||
#include "session.h"
|
||||
#include "hotlist.h"
|
||||
#include "log.h"
|
||||
#include "../irc/irc.h"
|
||||
#include "../gui/gui.h"
|
||||
@@ -436,6 +437,33 @@ session_save_uptime (FILE *file)
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* session_save_hotlist: save hotlist into session file
|
||||
*/
|
||||
|
||||
int
|
||||
session_save_hotlist (FILE *file)
|
||||
{
|
||||
int rc;
|
||||
t_weechat_hotlist *ptr_hotlist;
|
||||
|
||||
rc = 1;
|
||||
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
rc = rc && (session_write_id (file, SESSION_OBJ_HOTLIST));
|
||||
rc = rc && (session_write_int (file, SESSION_HOTL_PRIORITY, ptr_hotlist->priority));
|
||||
rc = rc && (session_write_str (file, SESSION_HOTL_SERVER, (ptr_hotlist->server) ? ptr_hotlist->server->name : NULL));
|
||||
rc = rc && (session_write_int (file, SESSION_HOTL_BUFFER_NUMBER, ptr_hotlist->buffer->number));
|
||||
rc = rc && (session_write_id (file, SESSION_HOTL_END));
|
||||
|
||||
if (!rc)
|
||||
return 0;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* session_save: save current session
|
||||
*/
|
||||
@@ -456,6 +484,7 @@ session_save (char *filename)
|
||||
rc = rc && (session_save_history (file, history_global_last));
|
||||
rc = rc && (session_save_buffers (file));
|
||||
rc = rc && (session_save_uptime (file));
|
||||
rc = rc && (session_save_hotlist (file));
|
||||
|
||||
fclose (file);
|
||||
|
||||
@@ -976,7 +1005,8 @@ session_load_server (FILE *file)
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"server (object id: %d)\n"));
|
||||
"server (object id: %d)\n"),
|
||||
object_id);
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
}
|
||||
@@ -1078,7 +1108,8 @@ session_load_channel (FILE *file)
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"channel (object id: %d)\n"));
|
||||
"channel (object id: %d)\n"),
|
||||
object_id);
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
}
|
||||
@@ -1148,7 +1179,8 @@ session_load_nick (FILE *file)
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"nick (object id: %d)\n"));
|
||||
"nick (object id: %d)\n"),
|
||||
object_id);
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
}
|
||||
@@ -1311,7 +1343,8 @@ session_load_dcc (FILE *file)
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"DCC (object id: %d)\n"));
|
||||
"DCC (object id: %d)\n"),
|
||||
object_id);
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
}
|
||||
@@ -1361,7 +1394,8 @@ session_load_history (FILE *file)
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"history (object id: %d)\n"));
|
||||
"history (object id: %d)\n"),
|
||||
object_id);
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
}
|
||||
@@ -1463,7 +1497,8 @@ session_load_buffer (FILE *file)
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"buffer (object id: %d)\n"));
|
||||
"buffer (object id: %d)\n"),
|
||||
object_id);
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
}
|
||||
@@ -1540,7 +1575,8 @@ session_load_line (FILE *file)
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"line (object id: %d)\n"));
|
||||
"line (object id: %d)\n"),
|
||||
object_id);
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
}
|
||||
@@ -1577,7 +1613,67 @@ session_load_uptime (FILE *file)
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"uptime (object id: %d)\n"));
|
||||
"uptime (object id: %d)\n"),
|
||||
object_id);
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* session_load_hotlist: load hotlist from file
|
||||
*/
|
||||
|
||||
int
|
||||
session_load_hotlist (FILE *file)
|
||||
{
|
||||
int object_id, rc;
|
||||
int priority;
|
||||
char *server_name;
|
||||
t_irc_server *ptr_server;
|
||||
int buffer_number;
|
||||
t_gui_buffer *ptr_buffer;
|
||||
|
||||
priority = 0;
|
||||
ptr_server = NULL;
|
||||
ptr_buffer = NULL;
|
||||
|
||||
/* read hotlist values */
|
||||
rc = 1;
|
||||
while (rc)
|
||||
{
|
||||
if (feof (file))
|
||||
{
|
||||
session_crash (file, _("unexpected end of file (reading hotlist)"));
|
||||
return 0;
|
||||
}
|
||||
if (fread ((void *)(&object_id), sizeof (int), 1, file) == 0)
|
||||
return 0;
|
||||
switch (object_id)
|
||||
{
|
||||
case SESSION_HOTL_END:
|
||||
hotlist_add (priority, ptr_server, ptr_buffer, 1);
|
||||
return 1;
|
||||
case SESSION_HOTL_PRIORITY:
|
||||
rc = rc && (session_read_int (file, &priority));
|
||||
break;
|
||||
case SESSION_HOTL_SERVER:
|
||||
server_name = NULL;
|
||||
if (!session_read_str (file, &server_name))
|
||||
return 0;
|
||||
ptr_server = server_search (server_name);
|
||||
free (server_name);
|
||||
break;
|
||||
case SESSION_HOTL_BUFFER_NUMBER:
|
||||
rc = rc && (session_read_int (file, &buffer_number));
|
||||
ptr_buffer = gui_buffer_search_by_number (buffer_number);
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"history (object id: %d)\n"),
|
||||
object_id);
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
}
|
||||
@@ -1690,6 +1786,13 @@ session_load (char *filename)
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case SESSION_OBJ_HOTLIST:
|
||||
if (!session_load_hotlist (file))
|
||||
{
|
||||
session_crash (file, _("failed to load hotlist"));
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("ignoring object (id: %d)\n"),
|
||||
object_id);
|
||||
@@ -1720,7 +1823,7 @@ session_load (char *filename)
|
||||
irc_display_prefix (NULL, gui_current_window->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (gui_current_window->buffer,
|
||||
_("%s can't delete session file (%s)\n"),
|
||||
WEECHAT_ERROR);
|
||||
WEECHAT_ERROR, filename);
|
||||
}
|
||||
|
||||
irc_display_prefix (NULL, gui_current_window->buffer, PREFIX_INFO);
|
||||
|
||||
+10
-1
@@ -44,7 +44,8 @@ enum t_session_object
|
||||
SESSION_OBJ_HISTORY,
|
||||
SESSION_OBJ_BUFFER,
|
||||
SESSION_OBJ_LINE,
|
||||
SESSION_OBJ_UPTIME
|
||||
SESSION_OBJ_UPTIME,
|
||||
SESSION_OBJ_HOTLIST
|
||||
};
|
||||
|
||||
enum t_session_server
|
||||
@@ -187,6 +188,14 @@ enum t_session_uptime
|
||||
SESSION_UPT_START_TIME
|
||||
};
|
||||
|
||||
enum t_session_hotlist
|
||||
{
|
||||
SESSION_HOTL_END = 0,
|
||||
SESSION_HOTL_PRIORITY,
|
||||
SESSION_HOTL_SERVER,
|
||||
SESSION_HOTL_BUFFER_NUMBER
|
||||
};
|
||||
|
||||
int session_save (char *filename);
|
||||
int session_load (char *filename);
|
||||
|
||||
|
||||
@@ -289,6 +289,26 @@ gui_buffer_search (char *server, char *channel)
|
||||
gui_buffers : ptr_buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_search_by_number: search a buffer by number
|
||||
*/
|
||||
|
||||
t_gui_buffer *
|
||||
gui_buffer_search_by_number (int number)
|
||||
{
|
||||
t_gui_buffer *ptr_buffer;
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
if (ptr_buffer->number == number)
|
||||
return ptr_buffer;
|
||||
}
|
||||
|
||||
/* buffer not found */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_find_window: find a window displaying buffer
|
||||
*/
|
||||
|
||||
@@ -180,13 +180,13 @@ gui_add_to_line (t_gui_buffer *buffer, int type, char *nick, char *message)
|
||||
buffer->notify_level)
|
||||
{
|
||||
if (buffer->last_line->line_with_highlight)
|
||||
hotlist_add (HOTLIST_HIGHLIGHT, SERVER(buffer), buffer);
|
||||
hotlist_add (HOTLIST_HIGHLIGHT, SERVER(buffer), buffer, 0);
|
||||
else if (BUFFER_IS_PRIVATE(buffer) && (buffer->last_line->line_with_message))
|
||||
hotlist_add (HOTLIST_PRIVATE, SERVER(buffer), buffer);
|
||||
hotlist_add (HOTLIST_PRIVATE, SERVER(buffer), buffer, 0);
|
||||
else if (buffer->last_line->line_with_message)
|
||||
hotlist_add (HOTLIST_MSG, SERVER(buffer), buffer);
|
||||
hotlist_add (HOTLIST_MSG, SERVER(buffer), buffer, 0);
|
||||
else
|
||||
hotlist_add (HOTLIST_LOW, SERVER(buffer), buffer);
|
||||
hotlist_add (HOTLIST_LOW, SERVER(buffer), buffer, 0);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ extern void gui_window_print_log (t_gui_window *);
|
||||
extern t_gui_buffer *gui_buffer_servers_search ();
|
||||
extern t_gui_buffer *gui_buffer_new (t_gui_window *, void *, void *, int, int);
|
||||
extern t_gui_buffer *gui_buffer_search (char *, char *);
|
||||
extern t_gui_buffer *gui_buffer_search_by_number (int);
|
||||
extern t_gui_window *gui_buffer_find_window (t_gui_buffer *);
|
||||
extern t_gui_buffer *gui_buffer_get_dcc (t_gui_window *);
|
||||
extern void gui_buffer_clear (t_gui_buffer *);
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ dcc_redraw (int highlight)
|
||||
gui_window_redraw_buffer (gui_buffer_get_dcc (gui_current_window));
|
||||
if (highlight)
|
||||
{
|
||||
hotlist_add (highlight, NULL, gui_buffer_get_dcc (gui_current_window));
|
||||
hotlist_add (highlight, NULL, gui_buffer_get_dcc (gui_current_window), 0);
|
||||
gui_status_draw (gui_current_window->buffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -413,7 +413,7 @@ irc_cmd_recv_invite (t_irc_server *server, char *host, char *nick, char *argumen
|
||||
GUI_COLOR(COLOR_WIN_CHAT),
|
||||
GUI_COLOR(COLOR_WIN_CHAT_NICK),
|
||||
nick);
|
||||
hotlist_add (HOTLIST_HIGHLIGHT, server, server->buffer);
|
||||
hotlist_add (HOTLIST_HIGHLIGHT, server, server->buffer, 0);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
@@ -1023,7 +1023,7 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *nick, char *argumen
|
||||
(ascii_strcasecmp (nick, "chanserv") != 0) &&
|
||||
(ascii_strcasecmp (nick, "memoserv") != 0))
|
||||
{
|
||||
hotlist_add (HOTLIST_PRIVATE, server, server->buffer);
|
||||
hotlist_add (HOTLIST_PRIVATE, server, server->buffer, 0);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2006-08-20
|
||||
ChangeLog - 2006-08-21
|
||||
|
||||
|
||||
Version 0.2.1 (under dev!):
|
||||
* added hotlist in session file when using /upgrade command (task #5449)
|
||||
* fixed nick refresh problem with unrealircd specific modes: chan owner (~)
|
||||
and chan admin (&) (bug #17340)
|
||||
|
||||
|
||||
@@ -76,7 +76,8 @@ hotlist_find_pos (t_weechat_hotlist *new_hotlist)
|
||||
*/
|
||||
|
||||
void
|
||||
hotlist_add (int priority, t_irc_server *server, t_gui_buffer *buffer)
|
||||
hotlist_add (int priority, t_irc_server *server, t_gui_buffer *buffer,
|
||||
int allow_current_buffer)
|
||||
{
|
||||
t_weechat_hotlist *new_hotlist, *pos_hotlist;
|
||||
|
||||
@@ -84,7 +85,8 @@ hotlist_add (int priority, t_irc_server *server, t_gui_buffer *buffer)
|
||||
return;
|
||||
|
||||
/* do not highlight current buffer */
|
||||
if (buffer == gui_current_window->buffer)
|
||||
if ((buffer == gui_current_window->buffer)
|
||||
&& (!allow_current_buffer))
|
||||
return;
|
||||
|
||||
if ((pos_hotlist = hotlist_search (buffer)))
|
||||
|
||||
@@ -43,7 +43,7 @@ struct t_weechat_hotlist
|
||||
extern t_weechat_hotlist *hotlist;
|
||||
extern t_gui_buffer *hotlist_initial_buffer;
|
||||
|
||||
extern void hotlist_add (int, t_irc_server *, t_gui_buffer *);
|
||||
extern void hotlist_add (int, t_irc_server *, t_gui_buffer *, int);
|
||||
extern void hotlist_free (t_weechat_hotlist *);
|
||||
extern void hotlist_free_all ();
|
||||
extern void hotlist_remove_buffer (t_gui_buffer *);
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
#include "weechat.h"
|
||||
#include "session.h"
|
||||
#include "hotlist.h"
|
||||
#include "log.h"
|
||||
#include "../irc/irc.h"
|
||||
#include "../gui/gui.h"
|
||||
@@ -436,6 +437,33 @@ session_save_uptime (FILE *file)
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* session_save_hotlist: save hotlist into session file
|
||||
*/
|
||||
|
||||
int
|
||||
session_save_hotlist (FILE *file)
|
||||
{
|
||||
int rc;
|
||||
t_weechat_hotlist *ptr_hotlist;
|
||||
|
||||
rc = 1;
|
||||
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
rc = rc && (session_write_id (file, SESSION_OBJ_HOTLIST));
|
||||
rc = rc && (session_write_int (file, SESSION_HOTL_PRIORITY, ptr_hotlist->priority));
|
||||
rc = rc && (session_write_str (file, SESSION_HOTL_SERVER, (ptr_hotlist->server) ? ptr_hotlist->server->name : NULL));
|
||||
rc = rc && (session_write_int (file, SESSION_HOTL_BUFFER_NUMBER, ptr_hotlist->buffer->number));
|
||||
rc = rc && (session_write_id (file, SESSION_HOTL_END));
|
||||
|
||||
if (!rc)
|
||||
return 0;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* session_save: save current session
|
||||
*/
|
||||
@@ -456,6 +484,7 @@ session_save (char *filename)
|
||||
rc = rc && (session_save_history (file, history_global_last));
|
||||
rc = rc && (session_save_buffers (file));
|
||||
rc = rc && (session_save_uptime (file));
|
||||
rc = rc && (session_save_hotlist (file));
|
||||
|
||||
fclose (file);
|
||||
|
||||
@@ -976,7 +1005,8 @@ session_load_server (FILE *file)
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"server (object id: %d)\n"));
|
||||
"server (object id: %d)\n"),
|
||||
object_id);
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
}
|
||||
@@ -1078,7 +1108,8 @@ session_load_channel (FILE *file)
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"channel (object id: %d)\n"));
|
||||
"channel (object id: %d)\n"),
|
||||
object_id);
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
}
|
||||
@@ -1148,7 +1179,8 @@ session_load_nick (FILE *file)
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"nick (object id: %d)\n"));
|
||||
"nick (object id: %d)\n"),
|
||||
object_id);
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
}
|
||||
@@ -1311,7 +1343,8 @@ session_load_dcc (FILE *file)
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"DCC (object id: %d)\n"));
|
||||
"DCC (object id: %d)\n"),
|
||||
object_id);
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
}
|
||||
@@ -1361,7 +1394,8 @@ session_load_history (FILE *file)
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"history (object id: %d)\n"));
|
||||
"history (object id: %d)\n"),
|
||||
object_id);
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
}
|
||||
@@ -1463,7 +1497,8 @@ session_load_buffer (FILE *file)
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"buffer (object id: %d)\n"));
|
||||
"buffer (object id: %d)\n"),
|
||||
object_id);
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
}
|
||||
@@ -1540,7 +1575,8 @@ session_load_line (FILE *file)
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"line (object id: %d)\n"));
|
||||
"line (object id: %d)\n"),
|
||||
object_id);
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
}
|
||||
@@ -1577,7 +1613,67 @@ session_load_uptime (FILE *file)
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"uptime (object id: %d)\n"));
|
||||
"uptime (object id: %d)\n"),
|
||||
object_id);
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* session_load_hotlist: load hotlist from file
|
||||
*/
|
||||
|
||||
int
|
||||
session_load_hotlist (FILE *file)
|
||||
{
|
||||
int object_id, rc;
|
||||
int priority;
|
||||
char *server_name;
|
||||
t_irc_server *ptr_server;
|
||||
int buffer_number;
|
||||
t_gui_buffer *ptr_buffer;
|
||||
|
||||
priority = 0;
|
||||
ptr_server = NULL;
|
||||
ptr_buffer = NULL;
|
||||
|
||||
/* read hotlist values */
|
||||
rc = 1;
|
||||
while (rc)
|
||||
{
|
||||
if (feof (file))
|
||||
{
|
||||
session_crash (file, _("unexpected end of file (reading hotlist)"));
|
||||
return 0;
|
||||
}
|
||||
if (fread ((void *)(&object_id), sizeof (int), 1, file) == 0)
|
||||
return 0;
|
||||
switch (object_id)
|
||||
{
|
||||
case SESSION_HOTL_END:
|
||||
hotlist_add (priority, ptr_server, ptr_buffer, 1);
|
||||
return 1;
|
||||
case SESSION_HOTL_PRIORITY:
|
||||
rc = rc && (session_read_int (file, &priority));
|
||||
break;
|
||||
case SESSION_HOTL_SERVER:
|
||||
server_name = NULL;
|
||||
if (!session_read_str (file, &server_name))
|
||||
return 0;
|
||||
ptr_server = server_search (server_name);
|
||||
free (server_name);
|
||||
break;
|
||||
case SESSION_HOTL_BUFFER_NUMBER:
|
||||
rc = rc && (session_read_int (file, &buffer_number));
|
||||
ptr_buffer = gui_buffer_search_by_number (buffer_number);
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"history (object id: %d)\n"),
|
||||
object_id);
|
||||
rc = rc && (session_read_ignore_value (file));
|
||||
break;
|
||||
}
|
||||
@@ -1690,6 +1786,13 @@ session_load (char *filename)
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case SESSION_OBJ_HOTLIST:
|
||||
if (!session_load_hotlist (file))
|
||||
{
|
||||
session_crash (file, _("failed to load hotlist"));
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("ignoring object (id: %d)\n"),
|
||||
object_id);
|
||||
@@ -1720,7 +1823,7 @@ session_load (char *filename)
|
||||
irc_display_prefix (NULL, gui_current_window->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (gui_current_window->buffer,
|
||||
_("%s can't delete session file (%s)\n"),
|
||||
WEECHAT_ERROR);
|
||||
WEECHAT_ERROR, filename);
|
||||
}
|
||||
|
||||
irc_display_prefix (NULL, gui_current_window->buffer, PREFIX_INFO);
|
||||
|
||||
@@ -44,7 +44,8 @@ enum t_session_object
|
||||
SESSION_OBJ_HISTORY,
|
||||
SESSION_OBJ_BUFFER,
|
||||
SESSION_OBJ_LINE,
|
||||
SESSION_OBJ_UPTIME
|
||||
SESSION_OBJ_UPTIME,
|
||||
SESSION_OBJ_HOTLIST
|
||||
};
|
||||
|
||||
enum t_session_server
|
||||
@@ -187,6 +188,14 @@ enum t_session_uptime
|
||||
SESSION_UPT_START_TIME
|
||||
};
|
||||
|
||||
enum t_session_hotlist
|
||||
{
|
||||
SESSION_HOTL_END = 0,
|
||||
SESSION_HOTL_PRIORITY,
|
||||
SESSION_HOTL_SERVER,
|
||||
SESSION_HOTL_BUFFER_NUMBER
|
||||
};
|
||||
|
||||
int session_save (char *filename);
|
||||
int session_load (char *filename);
|
||||
|
||||
|
||||
@@ -289,6 +289,26 @@ gui_buffer_search (char *server, char *channel)
|
||||
gui_buffers : ptr_buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_search_by_number: search a buffer by number
|
||||
*/
|
||||
|
||||
t_gui_buffer *
|
||||
gui_buffer_search_by_number (int number)
|
||||
{
|
||||
t_gui_buffer *ptr_buffer;
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
if (ptr_buffer->number == number)
|
||||
return ptr_buffer;
|
||||
}
|
||||
|
||||
/* buffer not found */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_find_window: find a window displaying buffer
|
||||
*/
|
||||
|
||||
@@ -180,13 +180,13 @@ gui_add_to_line (t_gui_buffer *buffer, int type, char *nick, char *message)
|
||||
buffer->notify_level)
|
||||
{
|
||||
if (buffer->last_line->line_with_highlight)
|
||||
hotlist_add (HOTLIST_HIGHLIGHT, SERVER(buffer), buffer);
|
||||
hotlist_add (HOTLIST_HIGHLIGHT, SERVER(buffer), buffer, 0);
|
||||
else if (BUFFER_IS_PRIVATE(buffer) && (buffer->last_line->line_with_message))
|
||||
hotlist_add (HOTLIST_PRIVATE, SERVER(buffer), buffer);
|
||||
hotlist_add (HOTLIST_PRIVATE, SERVER(buffer), buffer, 0);
|
||||
else if (buffer->last_line->line_with_message)
|
||||
hotlist_add (HOTLIST_MSG, SERVER(buffer), buffer);
|
||||
hotlist_add (HOTLIST_MSG, SERVER(buffer), buffer, 0);
|
||||
else
|
||||
hotlist_add (HOTLIST_LOW, SERVER(buffer), buffer);
|
||||
hotlist_add (HOTLIST_LOW, SERVER(buffer), buffer, 0);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ extern void gui_window_print_log (t_gui_window *);
|
||||
extern t_gui_buffer *gui_buffer_servers_search ();
|
||||
extern t_gui_buffer *gui_buffer_new (t_gui_window *, void *, void *, int, int);
|
||||
extern t_gui_buffer *gui_buffer_search (char *, char *);
|
||||
extern t_gui_buffer *gui_buffer_search_by_number (int);
|
||||
extern t_gui_window *gui_buffer_find_window (t_gui_buffer *);
|
||||
extern t_gui_buffer *gui_buffer_get_dcc (t_gui_window *);
|
||||
extern void gui_buffer_clear (t_gui_buffer *);
|
||||
|
||||
@@ -66,7 +66,7 @@ dcc_redraw (int highlight)
|
||||
gui_window_redraw_buffer (gui_buffer_get_dcc (gui_current_window));
|
||||
if (highlight)
|
||||
{
|
||||
hotlist_add (highlight, NULL, gui_buffer_get_dcc (gui_current_window));
|
||||
hotlist_add (highlight, NULL, gui_buffer_get_dcc (gui_current_window), 0);
|
||||
gui_status_draw (gui_current_window->buffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ irc_cmd_recv_invite (t_irc_server *server, char *host, char *nick, char *argumen
|
||||
GUI_COLOR(COLOR_WIN_CHAT),
|
||||
GUI_COLOR(COLOR_WIN_CHAT_NICK),
|
||||
nick);
|
||||
hotlist_add (HOTLIST_HIGHLIGHT, server, server->buffer);
|
||||
hotlist_add (HOTLIST_HIGHLIGHT, server, server->buffer, 0);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
@@ -1023,7 +1023,7 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *nick, char *argumen
|
||||
(ascii_strcasecmp (nick, "chanserv") != 0) &&
|
||||
(ascii_strcasecmp (nick, "memoserv") != 0))
|
||||
{
|
||||
hotlist_add (HOTLIST_PRIVATE, server, server->buffer);
|
||||
hotlist_add (HOTLIST_PRIVATE, server, server->buffer, 0);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user