Compare commits
6 Commits
build/mult
...
fbe73a07f3
| Author | SHA1 | Date | |
|---|---|---|---|
| fbe73a07f3 | |||
| efad679e59 | |||
| a2fc1032a9 | |||
| 4bb4a43487 | |||
|
3738be4af1
|
|||
|
ad95edb2b9
|
@@ -1902,9 +1902,9 @@ static const struct cmd_t command_defs[] = {
|
||||
CMD_ARGS(
|
||||
{ "where", "Show the current log file location." },
|
||||
{ "rotate on|off", "Rotate log, default on. Does not take effect if you specified a filename yourself when starting Profanity." },
|
||||
{ "maxsize <bytes>", "With rotate enabled, specifies the max log size, defaults to 10485760 (10MB)." },
|
||||
{ "maxsize <bytes>", "With rotate enabled, specifies the max log size, defaults to 10485760 (10MiB)." },
|
||||
{ "shared on|off", "Share logs between all instances, default: on. When off, the process id will be included in the log filename. Does not take effect if you specified a filename yourself when starting Profanity." },
|
||||
{"level INFO|DEBUG|WARN|ERROR", "Set the log level. Default is INFO. Only works with default log file, not with user provided log file during startup via -f." })
|
||||
{ "level INFO|DEBUG|WARN|ERROR", "Set the log level. Default is INFO." })
|
||||
},
|
||||
|
||||
{ CMD_PREAMBLE("/carbons",
|
||||
|
||||
@@ -6271,10 +6271,11 @@ cmd_log(ProfWin* window, const char* const command, gchar** args)
|
||||
if (strcmp(subcmd, "level") == 0) {
|
||||
log_level_t prof_log_level;
|
||||
if (log_level_from_string(value, &prof_log_level) == 0) {
|
||||
auto_char char* log_file = strdup(get_log_file_location());
|
||||
log_close();
|
||||
log_init(prof_log_level, NULL);
|
||||
log_init(prof_log_level, log_file);
|
||||
|
||||
cons_show("Log level changed to: %s.", value);
|
||||
cons_show("Log level changed to: %s (log file: %s).", value, log_file ? log_file : "[default]");
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ log_error(const char* const msg, ...)
|
||||
}
|
||||
|
||||
void
|
||||
log_init(log_level_t filter, char* log_file)
|
||||
log_init(log_level_t filter, const char* const log_file)
|
||||
{
|
||||
level_filter = filter;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ typedef enum {
|
||||
PROF_LEVEL_ERROR
|
||||
} log_level_t;
|
||||
|
||||
void log_init(log_level_t filter, char* log_file);
|
||||
void log_init(log_level_t filter, const char* const log_file);
|
||||
log_level_t log_get_filter(void);
|
||||
void log_close(void);
|
||||
const gchar* get_log_file_location(void);
|
||||
|
||||
@@ -99,6 +99,7 @@ _buffer_add(ProfBuff buffer, const char* show_char, int pad_indent, GDateTime* t
|
||||
|
||||
// With 10% margin to ensure overflow prevention
|
||||
while (buffer->lines >= PAD_SIZE - (PAD_SIZE / 10) && g_slist_length(buffer->entries) > 1) {
|
||||
log_debug("DELETING");
|
||||
// Delete message from the opposite size to free buffer
|
||||
GSList* buffer_entry_to_delete = append ? buffer->entries : g_slist_last(buffer->entries);
|
||||
ProfBuffEntry* entry_to_delete = (ProfBuffEntry*)buffer_entry_to_delete->data;
|
||||
|
||||
@@ -268,7 +268,11 @@ _show_scrolled(ProfWin* current)
|
||||
wattroff(win, bracket_attrs);
|
||||
|
||||
wattron(win, scrolled_attrs);
|
||||
wprintw(win, "SCROLLED");
|
||||
if (current->layout->unread_msg == 0) {
|
||||
wprintw(win, "SCROLLED");
|
||||
} else {
|
||||
wprintw(win, "SCROLLED, NEW MESSAGES");
|
||||
}
|
||||
wattroff(win, scrolled_attrs);
|
||||
|
||||
wattron(win, bracket_attrs);
|
||||
|
||||
@@ -120,6 +120,7 @@ typedef struct prof_layout_t
|
||||
ProfBuff buffer;
|
||||
int y_pos;
|
||||
int paged;
|
||||
int unread_msg;
|
||||
} ProfLayout;
|
||||
|
||||
typedef struct prof_layout_simple_t
|
||||
|
||||
@@ -103,6 +103,7 @@ _win_create_simple_layout(void)
|
||||
layout->base.buffer = buffer_create();
|
||||
layout->base.y_pos = 0;
|
||||
layout->base.paged = 0;
|
||||
layout->base.unread_msg = 0;
|
||||
scrollok(layout->base.win, TRUE);
|
||||
|
||||
return &layout->base;
|
||||
@@ -120,6 +121,7 @@ _win_create_split_layout(void)
|
||||
layout->base.buffer = buffer_create();
|
||||
layout->base.y_pos = 0;
|
||||
layout->base.paged = 0;
|
||||
layout->base.unread_msg = 0;
|
||||
scrollok(layout->base.win, TRUE);
|
||||
layout->subwin = NULL;
|
||||
layout->sub_y_pos = 0;
|
||||
@@ -197,6 +199,7 @@ win_create_muc(const char* const roomjid)
|
||||
layout->base.buffer = buffer_create();
|
||||
layout->base.y_pos = 0;
|
||||
layout->base.paged = 0;
|
||||
layout->base.unread_msg = 0;
|
||||
scrollok(layout->base.win, TRUE);
|
||||
new_win->window.layout = (ProfLayout*)layout;
|
||||
|
||||
@@ -709,7 +712,7 @@ win_page_down(ProfWin* window, int scroll_size)
|
||||
*page_start += scroll_size;
|
||||
|
||||
// Scrolled down after reaching the bottom of the page
|
||||
if ((*page_start > total_rows - page_space || (*page_start == page_space && *page_start >= total_rows)) && window->type == WIN_CHAT) {
|
||||
if (((*page_start > total_rows + window->layout->unread_msg - page_space) || ((*page_start == page_space + window->layout->unread_msg) && *page_start >= (total_rows + window->layout->unread_msg))) && window->type == WIN_CHAT) {
|
||||
int bf_size = buffer_size(window->layout->buffer);
|
||||
if (bf_size > 0 && *scroll_state != WIN_SCROLL_REACHED_BOTTOM) {
|
||||
// How many lines are left until end of the screen
|
||||
@@ -743,13 +746,15 @@ win_page_down(ProfWin* window, int scroll_size)
|
||||
window->layout->paged = 1;
|
||||
|
||||
// update only if position has changed
|
||||
if (page_start_initial != *page_start) {
|
||||
if ((page_start_initial != *page_start) || (window->layout->unread_msg)) {
|
||||
win_update_virtual(window);
|
||||
}
|
||||
|
||||
// switch off page if last line and space line visible
|
||||
if (total_rows - *page_start == page_space) {
|
||||
/*switch off page if no messages left to read
|
||||
TODO: update buffer end handling to check meassages just after last entry*/
|
||||
if (*scroll_state == WIN_SCROLL_REACHED_BOTTOM) {
|
||||
window->layout->paged = 0;
|
||||
window->layout->unread_msg = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -810,6 +815,7 @@ win_clear(ProfWin* window)
|
||||
int* page_start = &(window->layout->y_pos);
|
||||
*page_start = y;
|
||||
window->layout->paged = 1;
|
||||
window->layout->unread_msg = 0;
|
||||
win_update_virtual(window);
|
||||
}
|
||||
|
||||
@@ -914,6 +920,7 @@ void
|
||||
win_move_to_end(ProfWin* window)
|
||||
{
|
||||
window->layout->paged = 0;
|
||||
window->layout->unread_msg = 0;
|
||||
|
||||
int rows = getmaxy(stdscr);
|
||||
int y = getcury(window->layout->win);
|
||||
@@ -1696,6 +1703,13 @@ win_newline(ProfWin* window)
|
||||
static void
|
||||
_win_printf(ProfWin* window, const char* show_char, int pad_indent, GDateTime* timestamp, int flags, theme_item_t theme_item, const char* const display_from, const char* const from_jid, const char* const message_id, const char* const message, ...)
|
||||
{
|
||||
|
||||
/* Prevent printing and buffer update when user is viewing message history [SCROLLING]*/
|
||||
if ((window->layout->paged) && wins_is_current(window)) {
|
||||
window->layout->unread_msg++;
|
||||
return;
|
||||
}
|
||||
|
||||
if (timestamp == NULL) {
|
||||
timestamp = g_date_time_new_now_local();
|
||||
} else {
|
||||
|
||||
@@ -979,6 +979,7 @@ _connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status
|
||||
|
||||
connection_get_jid();
|
||||
conn.domain = strdup(conn.jid->domainpart);
|
||||
log_debug("conn.domain=%s", conn.jid->domainpart);
|
||||
|
||||
connection_clear_data();
|
||||
conn.features_by_jid = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)g_hash_table_destroy);
|
||||
@@ -1163,3 +1164,32 @@ connection_get_profanity_identifier(void)
|
||||
{
|
||||
return prof_identifier;
|
||||
}
|
||||
|
||||
void
|
||||
connection_debug_print_features()
|
||||
{
|
||||
log_debug("=== Connection Features ===");
|
||||
|
||||
GHashTableIter iter;
|
||||
gpointer jid_ptr, features_ptr;
|
||||
|
||||
g_hash_table_iter_init(&iter, conn.features_by_jid);
|
||||
while (g_hash_table_iter_next(&iter, &jid_ptr, &features_ptr)) {
|
||||
const char* jid = (const char*)jid_ptr;
|
||||
GHashTable* features = (GHashTable*)features_ptr;
|
||||
|
||||
if (!features || g_hash_table_size(features) == 0) {
|
||||
log_debug("%s:\t(no features)", jid);
|
||||
continue;
|
||||
}
|
||||
|
||||
GList* feature_keys = g_hash_table_get_keys(features);
|
||||
for (GList* l = feature_keys; l != NULL; l = l->next) {
|
||||
const char* feature = (const char*)l->data;
|
||||
log_debug("%s:\t%s", jid, feature);
|
||||
}
|
||||
g_list_free(feature_keys);
|
||||
}
|
||||
|
||||
log_debug("=== End of Features ===");
|
||||
}
|
||||
|
||||
@@ -1417,6 +1417,8 @@ _manual_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static gboolean autoping_error_shown = false;
|
||||
|
||||
static int
|
||||
_autoping_timed_send(xmpp_conn_t* const conn, void* const userdata)
|
||||
{
|
||||
@@ -1425,10 +1427,13 @@ _autoping_timed_send(xmpp_conn_t* const conn, void* const userdata)
|
||||
}
|
||||
|
||||
if (connection_supports(XMPP_FEATURE_PING) == FALSE) {
|
||||
log_warning("Server doesn't advertise %s feature, disabling autoping.", XMPP_FEATURE_PING);
|
||||
prefs_set_autoping(0);
|
||||
cons_show_error("Server ping not supported (%s), autoping disabled.", XMPP_FEATURE_PING);
|
||||
return 0;
|
||||
// TODO: do we need to check it on each autoping call?
|
||||
log_warning("Server doesn't advertise %s feature.", XMPP_FEATURE_PING);
|
||||
if (!autoping_error_shown) {
|
||||
connection_debug_print_features();
|
||||
cons_show_error("Server ping not supported (%s). Check log for details.", XMPP_FEATURE_PING);
|
||||
}
|
||||
autoping_error_shown = 1;
|
||||
}
|
||||
|
||||
if (autoping_wait) {
|
||||
@@ -1499,7 +1504,7 @@ _auto_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
if (g_strcmp0(errtype, STANZA_TYPE_CANCEL) == 0) {
|
||||
log_warning("Server ping (id=%s) error type 'cancel', disabling autoping.", id);
|
||||
prefs_set_autoping(0);
|
||||
cons_show_error("Server ping not supported, autoping disabled.");
|
||||
cons_show_error("Autoping is not supported by the server (stanza cancelled). The feature has been disabled automatically.");
|
||||
xmpp_timed_handler_delete(connection_get_conn(), _autoping_timed_send);
|
||||
}
|
||||
|
||||
@@ -2515,6 +2520,7 @@ _disco_items_result_handler(xmpp_stanza_t* const stanza)
|
||||
GSList* items = NULL;
|
||||
|
||||
if ((g_strcmp0(id, "discoitemsreq") != 0) && (g_strcmp0(id, "discoitemsreq_onconnect") != 0)) {
|
||||
log_warning("_disco_items_result_handler: Received unexpected disco id: %s", id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -208,6 +208,8 @@ const char* connection_jid_for_feature(const char* const feature);
|
||||
|
||||
const char* connection_get_profanity_identifier(void);
|
||||
|
||||
void connection_debug_print_features();
|
||||
|
||||
char* message_send_chat(const char* const barejid, const char* const msg, const char* const oob_url, gboolean request_receipt, const char* const replace_id);
|
||||
char* message_send_chat_otr(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id);
|
||||
char* message_send_chat_pgp(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "log.h"
|
||||
|
||||
void
|
||||
log_init(log_level_t filter, char* log_file)
|
||||
log_init(log_level_t filter, const char* const log_file)
|
||||
{
|
||||
}
|
||||
log_level_t
|
||||
|
||||
@@ -156,6 +156,11 @@ connection_get_profanity_identifier(void)
|
||||
return "profident";
|
||||
}
|
||||
|
||||
void
|
||||
connection_debug_print_features()
|
||||
{
|
||||
}
|
||||
|
||||
jabber_conn_status_t
|
||||
connection_register(const char* const altdomain, int port, const char* const tls_policy,
|
||||
const char* const username, const char* const password)
|
||||
|
||||
Reference in New Issue
Block a user