Mercurial > ~mikael > mcabber > hg
diff mcabber/src/hbuf.c @ 1602:f4a2c6f767d1
Message Receipts support (XEP-0184)
author | franky |
---|---|
date | Wed, 24 Sep 2008 11:41:29 +0200 |
parents | dcd5d4c75199 |
children |
line wrap: on
line diff
--- a/mcabber/src/hbuf.c Sun Oct 11 15:59:20 2009 +0200 +++ b/mcabber/src/hbuf.c Wed Sep 24 11:41:29 2008 +0200 @@ -44,6 +44,7 @@ time_t timestamp; unsigned mucnicklen; guint flags; + gpointer xep184; } prefix; } hbuf_block; @@ -123,7 +124,7 @@ // Note 2: width does not include the ending \0. void hbuf_add_line(GList **p_hbuf, const char *text, time_t timestamp, guint prefix_flags, guint width, guint maxhbufblocks, - unsigned mucnicklen) + unsigned mucnicklen, gpointer xep184) { GList *curr_elt; char *line; @@ -132,6 +133,8 @@ if (!text) return; + prefix_flags |= (xep184 ? HBB_PREFIX_RECEIPT : 0); + textlen = strlen(text); hbb_blocksize = MAX(textlen+1, HBB_BLOCKSIZE); @@ -139,6 +142,7 @@ hbuf_block_elt->prefix.timestamp = timestamp; hbuf_block_elt->prefix.flags = prefix_flags; hbuf_block_elt->prefix.mucnicklen = mucnicklen; + hbuf_block_elt->prefix.xep184 = xep184; if (!*p_hbuf) { hbuf_block_elt->ptr = g_new(char, hbb_blocksize); if (!hbuf_block_elt->ptr) { @@ -474,6 +478,26 @@ return; } +// hbuf_remove_receipt(hbuf, xep184) +// Remove the Receipt Flag for the message with the given xep184 id +// Returns TRUE if it was found and removed, otherwise FALSE +gboolean hbuf_remove_receipt(GList *hbuf, gpointer xep184) +{ + hbuf_block *blk; + + hbuf = g_list_first(hbuf); + + for ( ; hbuf; hbuf = g_list_next(hbuf)) { + blk = (hbuf_block*)(hbuf->data); + if (blk->prefix.xep184 == xep184) { + blk->prefix.xep184 = NULL; + blk->prefix.flags ^= HBB_PREFIX_RECEIPT; + return TRUE; + } + } + return FALSE; +} + // hbuf_get_blocks_number() // Returns the number of allocated hbuf_block's. guint hbuf_get_blocks_number(GList *hbuf)