New option: 'clear_unread_on_carbon'
If the new 'clear_unread_on_carbon' option is set to 1, clear the unread
message flag for a contact whenever an outgoing carbon copy of a message
sent to that contact is received from another client.
---
mcabber/mcabber/commands.c | 2 +-
mcabber/mcabber/hbuf.h | 1 +
mcabber/mcabber/hooks.c | 17 ++++++++++++-----
mcabber/mcabber/hooks.h | 2 +-
mcabber/mcabber/screen.c | 18 ++++++++++++++----
mcabber/mcabber/xmpp.c | 2 +-
mcabber/mcabberrc.example | 5 +++++
7 files changed, 35 insertions(+), 12 deletions(-)
--- a/mcabber/mcabber/api.h Sun Oct 04 19:07:17 2015 +0200
+++ b/mcabber/mcabber/api.h Thu Jul 23 23:44:45 2015 +0200
@@ -4,8 +4,8 @@
#include <glib.h>
#include <mcabber/config.h> // For MCABBER_BRANCH
-#define MCABBER_API_VERSION 37
-#define MCABBER_API_MIN 36
+#define MCABBER_API_VERSION 38
+#define MCABBER_API_MIN 38
#define MCABBER_BRANCH_DEV 1
--- a/mcabber/mcabber/commands.c Sun Oct 04 19:07:17 2015 +0200
+++ b/mcabber/mcabber/commands.c Thu Jul 23 23:44:45 2015 +0200
@@ -1333,7 +1333,7 @@
// Hook
if (!isroom)
- hk_message_out(bare_jid, rp, 0, hmsg, crypted, xep184);
+ hk_message_out(bare_jid, rp, 0, hmsg, crypted, FALSE, xep184);
send_message_to_return:
if (hmsg != msg) g_free(hmsg);
--- a/mcabber/mcabber/hbuf.h Sun Oct 04 19:07:17 2015 +0200
+++ b/mcabber/mcabber/hbuf.h Thu Jul 23 23:44:45 2015 +0200
@@ -31,6 +31,7 @@
#define HBB_PREFIX_RECEIPT (1U<<14)
#define HBB_PREFIX_READMARK (1U<<15)
#define HBB_PREFIX_DELAYED (1U<<16)
+#define HBB_PREFIX_CARBON (1U<<17)
typedef struct {
time_t timestamp;
--- a/mcabber/mcabber/hooks.c Sun Oct 04 19:07:17 2015 +0200
+++ b/mcabber/mcabber/hooks.c Thu Jul 23 23:44:45 2015 +0200
@@ -212,6 +212,9 @@
else if (encrypted == ENCRYPTED_OTR)
message_flags |= HBB_PREFIX_OTRCRYPT;
+ if (carbon)
+ message_flags |= HBB_PREFIX_CARBON;
+
if (type == LM_MESSAGE_SUB_TYPE_GROUPCHAT) {
rtype = ROSTER_TYPE_ROOM;
is_groupchat = TRUE;
@@ -447,10 +450,10 @@
// normal messages.
void hk_message_out(const char *bjid, const char *nick,
time_t timestamp, const char *msg,
- guint encrypted, gpointer xep184)
+ guint encrypted, gboolean carbon, gpointer xep184)
{
char *wmsg = NULL, *bmsg = NULL, *mmsg = NULL;
- guint cryptflag = 0;
+ guint message_flags = 0;
if (nick) {
wmsg = bmsg = g_strdup_printf("PRIV#<%s> %s", nick, msg);
@@ -474,10 +477,14 @@
// cases scr_write_outgoing_message() will load the history and we'd
// have the message twice...
if (encrypted == ENCRYPTED_PGP)
- cryptflag = HBB_PREFIX_PGPCRYPT;
+ message_flags |= HBB_PREFIX_PGPCRYPT;
else if (encrypted == ENCRYPTED_OTR)
- cryptflag = HBB_PREFIX_OTRCRYPT;
- scr_write_outgoing_message(bjid, wmsg, cryptflag, xep184);
+ message_flags |= HBB_PREFIX_OTRCRYPT;
+
+ if (carbon)
+ message_flags |= HBB_PREFIX_CARBON;
+
+ scr_write_outgoing_message(bjid, wmsg, message_flags, xep184);
// We don't log private messages
if (!nick)
--- a/mcabber/mcabber/hooks.h Sun Oct 04 19:07:17 2015 +0200
+++ b/mcabber/mcabber/hooks.h Thu Jul 23 23:44:45 2015 +0200
@@ -50,7 +50,7 @@
guint encrypted, gboolean carbon);
void hk_message_out(const char *bjid, const char *nickname,
time_t timestamp, const char *msg,
- guint encrypted, gpointer xep184);
+ guint encrypted, gboolean carbon, gpointer xep184);
void hk_statuschange(const char *bjid, const char *resname, gchar prio,
time_t timestamp, enum imstatus status,
char const *status_msg);
--- a/mcabber/mcabber/screen.c Sun Oct 04 19:07:17 2015 +0200
+++ b/mcabber/mcabber/screen.c Thu Jul 23 23:44:45 2015 +0200
@@ -1468,6 +1468,7 @@
int special;
guint num_history_blocks;
bool setmsgflg = FALSE;
+ bool clearmsgflg = FALSE;
char *nicktmp, *nicklocaltmp;
// Look for the window entry.
@@ -1539,12 +1540,21 @@
scr_update_window(win_entry);
top_panel(inputPanel);
update_panels();
+ } else if (settings_opt_get_int("clear_unread_on_carbon") &&
+ prefix_flags & HBB_PREFIX_OUT &&
+ prefix_flags & HBB_PREFIX_CARBON) {
+ clearmsgflg = TRUE;
} else if (!(prefix_flags & HBB_PREFIX_NOFLAG)) {
setmsgflg = TRUE;
}
- if (setmsgflg && !special) {
- roster_msg_setflag(winId, FALSE, TRUE);
- update_roster = TRUE;
+ if (!special) {
+ if (clearmsgflg) {
+ roster_msg_setflag(winId, FALSE, FALSE);
+ update_roster = TRUE;
+ } else if (setmsgflg) {
+ roster_msg_setflag(winId, FALSE, TRUE);
+ update_roster = TRUE;
+ }
}
}
@@ -2317,7 +2327,7 @@
{
if (!(prefix &
~HBB_PREFIX_NOFLAG & ~HBB_PREFIX_HLIGHT & ~HBB_PREFIX_HLIGHT_OUT &
- ~HBB_PREFIX_PGPCRYPT & ~HBB_PREFIX_OTRCRYPT))
+ ~HBB_PREFIX_PGPCRYPT & ~HBB_PREFIX_OTRCRYPT & ~HBB_PREFIX_CARBON))
prefix |= HBB_PREFIX_IN;
scr_write_message(jidfrom, text, timestamp, prefix, mucnicklen, NULL);
--- a/mcabber/mcabber/xmpp.c Sun Oct 04 19:07:17 2015 +0200
+++ b/mcabber/mcabber/xmpp.c Thu Jul 23 23:44:45 2015 +0200
@@ -1169,7 +1169,7 @@
#endif
if (body && *body)
- hk_message_out(bjid, NULL, timestamp, body, encrypted, NULL);
+ hk_message_out(bjid, NULL, timestamp, body, encrypted, TRUE, NULL);
scr_LogPrint(LPRINT_DEBUG, "Received outgoing carbon for <%s>", to);
g_free(decrypted_pgp);
--- a/mcabber/mcabberrc.example Sun Oct 04 19:07:17 2015 +0200
+++ b/mcabber/mcabberrc.example Thu Jul 23 23:44:45 2015 +0200
@@ -147,6 +147,11 @@
# supports them), set the 'carbons' option to 1. Default is 0.
#set carbons = 1
+# Set the 'clear_unread_on_carbon' option to 1 if the unread messages flag
+# should be cleared when an outgoing copy of a message sent to that contact
+# is received from another client.
+#set clear_unread_on_carbon = 1
+
# Typing notifications, Chat States, Events (XEP-22/85)
# Set disable_chatstates to 1 if you don't want to use typing notifications.
# Note: changing this option once mcabber is running has no effect.