summaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-08-08 21:17:32 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-08-08 21:19:25 +0200
commite188de55017dc3965f23db0802bcc0d03c0dc8f5 (patch)
treeaabf7f14a2ced8a6c0daf5184659be0d45f65d31 /degesch.c
parentcdf6544c943e95bc63b4cdbaa4e8bb8231c3d099 (diff)
downloadxK-e188de55017dc3965f23db0802bcc0d03c0dc8f5.tar.gz
xK-e188de55017dc3965f23db0802bcc0d03c0dc8f5.tar.xz
xK-e188de55017dc3965f23db0802bcc0d03c0dc8f5.zip
degesch: don't show joins etc. as new activity
It's mostly just spam that shouldn't get your attention.
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/degesch.c b/degesch.c
index 83bafae..c548669 100644
--- a/degesch.c
+++ b/degesch.c
@@ -968,7 +968,8 @@ enum buffer_line_flags
BUFFER_LINE_ERROR = 1 << 1, ///< Error message
BUFFER_LINE_HIGHLIGHT = 1 << 2, ///< The user was highlighted by this
BUFFER_LINE_SKIP_FILE = 1 << 3, ///< Don't log this to file
- BUFFER_LINE_INDENT = 1 << 4 ///< Just indent the line
+ BUFFER_LINE_INDENT = 1 << 4, ///< Just indent the line
+ BUFFER_LINE_UNIMPORTANT = 1 << 5 ///< Joins, parts, similar spam
};
struct buffer_line
@@ -1022,6 +1023,7 @@ struct buffer
unsigned lines_count; ///< How many lines we have
unsigned unseen_messages_count; ///< # messages since last visited
+ unsigned unseen_unimportant_count; ///< How much of that is unimportant
bool highlighted; ///< We've been highlighted
FILE *log_file; ///< Log file
@@ -2898,6 +2900,8 @@ log_formatter (struct app_context *ctx,
if (!displayed)
{
buffer->unseen_messages_count++;
+ if (flags & BUFFER_LINE_UNIMPORTANT)
+ buffer->unseen_unimportant_count++;
if (flags & BUFFER_LINE_HIGHLIGHT)
buffer->highlighted = true;
@@ -2954,9 +2958,11 @@ log_full (struct app_context *ctx, struct server *s, struct buffer *buffer,
// Lines that are used in more than one place
#define log_nick_self(s, buffer, new_) \
- log_server_status ((s), (buffer), "You are now known as #n", (new_))
+ log_server ((s), (buffer), BUFFER_LINE_STATUS | BUFFER_LINE_UNIMPORTANT, \
+ "You are now known as #n", (new_))
#define log_nick(s, buffer, old, new_) \
- log_server_status ((s), (buffer), "#n is now known as #n", (old), (new_))
+ log_server ((s), (buffer), BUFFER_LINE_STATUS | BUFFER_LINE_UNIMPORTANT, \
+ "#n is now known as #n", (old), (new_))
#define log_outcoming_notice(s, buffer, who, text) \
log_server_status ((s), (buffer), "#s(#n): #m", "Notice", (who), (text))
@@ -3125,6 +3131,7 @@ buffer_print_backlog (struct app_context *ctx, struct buffer *buffer)
}
buffer->unseen_messages_count = 0;
+ buffer->unseen_unimportant_count = 0;
buffer->highlighted = false;
// So that it is obvious if the last line in the buffer is not from today
@@ -3830,7 +3837,8 @@ irc_disconnect (struct server *s)
str_map_iter_init (&iter, &s->irc_buffer_map);
struct buffer *buffer;
while ((buffer = str_map_iter_next (&iter)))
- log_server_status (s, buffer, "Disconnected from server");
+ log_server (s, buffer, BUFFER_LINE_STATUS | BUFFER_LINE_UNIMPORTANT,
+ "Disconnected from server");
irc_cancel_timers (s);
irc_destroy_transport (s);
@@ -4670,18 +4678,18 @@ irc_initiate_connect (struct server *s)
static void
make_unseen_prefix (struct app_context *ctx, struct str *active_buffers)
{
- size_t i = 0;
+ size_t buffer_no = 0;
LIST_FOR_EACH (struct buffer, iter, ctx->buffers)
{
- i++;
- if (!iter->unseen_messages_count)
+ buffer_no++;
+ if (!(iter->unseen_messages_count - iter->unseen_unimportant_count))
continue;
if (active_buffers->len)
str_append_c (active_buffers, ',');
if (iter->highlighted)
str_append_c (active_buffers, '!');
- str_append_printf (active_buffers, "%zu", i);
+ str_append_printf (active_buffers, "%zu", buffer_no);
}
}
@@ -5185,7 +5193,7 @@ irc_handle_join (struct server *s, const struct irc_message *msg)
// Finally log the message
if (buffer)
{
- log_server (s, buffer, 0, "#a-->#r #N #a#s#r #S",
+ log_server (s, buffer, BUFFER_LINE_UNIMPORTANT, "#a-->#r #N #a#s#r #S",
ATTR_JOIN, msg->prefix, ATTR_JOIN, "has joined", channel_name);
}
}
@@ -5487,7 +5495,7 @@ irc_handle_part (struct server *s, const struct irc_message *msg)
ATTR_PART, msg->prefix, ATTR_PART, "has left", channel_name);
if (message)
formatter_add (&f, " (#m)", message);
- log_formatter (s->ctx, buffer, 0, &f);
+ log_formatter (s->ctx, buffer, BUFFER_LINE_UNIMPORTANT, &f);
}
}
@@ -5644,7 +5652,7 @@ log_quit (struct server *s,
ATTR_PART, prefix, ATTR_PART, "has quit");
if (reason)
formatter_add (&f, " (#m)", reason);
- log_formatter (s->ctx, buffer, 0, &f);
+ log_formatter (s->ctx, buffer, BUFFER_LINE_UNIMPORTANT, &f);
}
static void