mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Refactored show history, free'd memory
This commit is contained in:
parent
6ef7b30cd7
commit
c0cc829519
@ -83,6 +83,8 @@ static void _win_handle_switch(const int * const ch);
|
|||||||
static void _win_handle_page(const int * const ch);
|
static void _win_handle_page(const int * const ch);
|
||||||
static void _win_resize_all(void);
|
static void _win_resize_all(void);
|
||||||
static gint _win_get_unread(void);
|
static gint _win_get_unread(void);
|
||||||
|
static void _win_show_history(WINDOW *win, int win_index,
|
||||||
|
const char * const contact);
|
||||||
|
|
||||||
#ifdef HAVE_LIBNOTIFY
|
#ifdef HAVE_LIBNOTIFY
|
||||||
static void _win_notify(const char * const message, int timeout,
|
static void _win_notify(const char * const message, int timeout,
|
||||||
@ -284,15 +286,7 @@ win_show_incomming_msg(const char * const from, const char * const message)
|
|||||||
|
|
||||||
_wins[win_index].unread++;
|
_wins[win_index].unread++;
|
||||||
if (prefs_get_chlog() && prefs_get_history()) {
|
if (prefs_get_chlog() && prefs_get_history()) {
|
||||||
if (!_wins[win_index].history_shown) {
|
_win_show_history(win, win_index, short_from);
|
||||||
GSList *history = NULL;
|
|
||||||
history = chat_log_get_previous(jabber_get_jid(), short_from, history);
|
|
||||||
while (history != NULL) {
|
|
||||||
wprintw(win, "%s\n", history->data);
|
|
||||||
history = g_slist_next(history);
|
|
||||||
}
|
|
||||||
_wins[win_index].history_shown = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_win_show_time(win);
|
_win_show_time(win);
|
||||||
@ -390,15 +384,7 @@ win_show_outgoing_msg(const char * const from, const char * const to,
|
|||||||
win = _wins[win_index].win;
|
win = _wins[win_index].win;
|
||||||
|
|
||||||
if (prefs_get_chlog() && prefs_get_history()) {
|
if (prefs_get_chlog() && prefs_get_history()) {
|
||||||
if (!_wins[win_index].history_shown) {
|
_win_show_history(win, win_index, to);
|
||||||
GSList *history = NULL;
|
|
||||||
history = chat_log_get_previous(jabber_get_jid(), to, history);
|
|
||||||
while (history != NULL) {
|
|
||||||
wprintw(win, "%s\n", history->data);
|
|
||||||
history = g_slist_next(history);
|
|
||||||
}
|
|
||||||
_wins[win_index].history_shown = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(p_contact_show(contact), "offline") == 0) {
|
if (strcmp(p_contact_show(contact), "offline") == 0) {
|
||||||
@ -1097,3 +1083,19 @@ _win_get_unread(void)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_win_show_history(WINDOW *win, int win_index, const char * const contact)
|
||||||
|
{
|
||||||
|
if (!_wins[win_index].history_shown) {
|
||||||
|
GSList *history = NULL;
|
||||||
|
history = chat_log_get_previous(jabber_get_jid(), contact, history);
|
||||||
|
while (history != NULL) {
|
||||||
|
wprintw(win, "%s\n", history->data);
|
||||||
|
history = g_slist_next(history);
|
||||||
|
}
|
||||||
|
_wins[win_index].history_shown = 1;
|
||||||
|
|
||||||
|
g_slist_free_full(history, free);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user