History logfile: Use a special code (MI) for local MUC info messages
(Suggested by bb)
--- a/mcabber/src/histolog.c Sat Nov 03 15:57:39 2007 +0100
+++ b/mcabber/src/histolog.c Sat Nov 03 16:52:25 2007 +0100
@@ -122,14 +122,15 @@
for (p=data ; *p ; p++)
if (*p == '\n') len++;
- /* Line format: "TI yyyymmddThh:mm:ssZ [data]"
- * (Old format: "TI DDDDDDDDDD LLL [data])"
+ /* Line format: "TI yyyymmddThh:mm:ssZ LLL [data]"
* T=Type, I=Info, yyyymmddThh:mm:ssZ=date, LLL=0-padded-len
*
* Types:
- * - M message Info: S (send) R (receive)
+ * - M message Info: S (send) R (receive) I (info)
* - S status Info: [_ofdnai]
- * We don't check them, we'll trust the caller.
+ * We don't check them, we trust the caller.
+ * (Info messages are not sent nor received, they're generated
+ * locally by mcabber.)
*/
fp = fopen(filename, "a");
@@ -241,8 +242,8 @@
len = (guint) atoi(&data[22]);
// Some checks
- if (((type == 'M') && (info != 'S' && info != 'R')) ||
- ((type == 'I') && (!strchr("OAIFDN", info)))) {
+ if (((type == 'M') && (info != 'S' && info != 'R' && info != 'I')) ||
+ ((type == 'S') && (!strchr("_OFDNAI", info)))) {
if (!err) {
scr_LogPrint(LPRINT_LOGNORM, "Error in history file format (%s), l.%u",
bjid, ln);
@@ -280,10 +281,13 @@
if (type == 'M') {
char *converted;
- if (info == 'S')
+ if (info == 'S') {
prefix_flags = HBB_PREFIX_OUT | HBB_PREFIX_HLIGHT_OUT;
- else
+ } else {
prefix_flags = HBB_PREFIX_IN;
+ if (info == 'I')
+ prefix_flags = HBB_PREFIX_INFO;
+ }
converted = from_utf8(&data[dataoffset+1]);
if (converted) {
xtext = ut_expand_tabs(converted); // Expand tabs
@@ -348,7 +352,18 @@
inline void hlog_write_message(const char *bjid, time_t timestamp, int sent,
const char *msg)
{
- write_histo_line(bjid, timestamp, 'M', ((sent) ? 'S' : 'R'), msg);
+ guchar info;
+ /* sent=1 message sent by mcabber
+ * sent=0 message received by mcabber
+ * sent=-1 local info message
+ */
+ if (sent == 1)
+ info = 'S';
+ else if (sent == 0)
+ info = 'R';
+ else
+ info = 'I';
+ write_histo_line(bjid, timestamp, 'M', info, msg);
}
inline void hlog_write_status(const char *bjid, time_t timestamp,
--- a/mcabber/src/hooks.c Sat Nov 03 15:57:39 2007 +0100
+++ b/mcabber/src/hooks.c Sat Nov 03 16:52:25 2007 +0100
@@ -171,7 +171,7 @@
// option is off (and it is not a history line)
if (!(message_flags & HBB_PREFIX_ERR) &&
(!is_room || (is_groupchat && log_muc_conf && !timestamp)))
- hlog_write_message(bjid, timestamp, FALSE, wmsg);
+ hlog_write_message(bjid, timestamp, 0, wmsg);
if (settings_opt_get_int("events_ignore_active_window") &&
current_buddy && scr_get_chatmode()) {
@@ -253,7 +253,7 @@
// We don't log private messages
if (!nick)
- hlog_write_message(bjid, timestamp, TRUE, msg);
+ hlog_write_message(bjid, timestamp, 1, msg);
// External command
hk_ext_cmd(bjid, 'M', 'S', NULL);
--- a/mcabber/src/jabglue.c Sat Nov 03 15:57:39 2007 +0100
+++ b/mcabber/src/jabglue.c Sat Nov 03 16:52:25 2007 +0100
@@ -2052,7 +2052,7 @@
scr_WriteIncomingMessage(roomjid, mbuf, usttime,
HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0);
if (log_muc_conf)
- hlog_write_message(roomjid, 0, FALSE, mbuf);
+ hlog_write_message(roomjid, 0, -1, mbuf);
g_free(mbuf);
buddy_resource_setname(room_elt->data, rname, mbnick);
// Maybe it's _our_ nickname...
@@ -2138,7 +2138,7 @@
scr_WriteIncomingMessage(roomjid, mbuf, usttime, msgflags, 0);
if (log_muc_conf)
- hlog_write_message(roomjid, 0, FALSE, mbuf);
+ hlog_write_message(roomjid, 0, -1, mbuf);
if (we_left) {
scr_LogPrint(LPRINT_LOGNORM, "%s", mbuf);
@@ -2170,7 +2170,7 @@
scr_WriteIncomingMessage(roomjid, mbuf, 0,
HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0);
if (log_muc_conf)
- hlog_write_message(roomjid, 0, FALSE, mbuf);
+ hlog_write_message(roomjid, 0, -1, mbuf);
g_free(mbuf);
mbuf = g_strdup_printf("%s has joined", rname);
new_member = TRUE;
@@ -2189,7 +2189,7 @@
msgflags |= HBB_PREFIX_NOFLAG;
scr_WriteIncomingMessage(roomjid, mbuf, usttime, msgflags, 0);
if (log_muc_conf)
- hlog_write_message(roomjid, 0, FALSE, mbuf);
+ hlog_write_message(roomjid, 0, -1, mbuf);
g_free(mbuf);
}
}
@@ -2413,7 +2413,7 @@
scr_WriteIncomingMessage(s, mbuf, 0,
HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0);
if (settings_opt_get_int("log_muc_conf"))
- hlog_write_message(s, 0, FALSE, mbuf);
+ hlog_write_message(s, 0, -1, mbuf);
g_free(s);
g_free(mbuf);
// The topic is displayed in the chat status line, so refresh now.