1 #ifndef __MCABBER_HBUF_H__
2 #define __MCABBER_HBUF_H__ 1
3 
4 #include <time.h>
5 #include <glib.h>
6 
7 // With current implementation a message must fit in a hbuf block,
8 // so we shouldn't choose a too small size.
9 #define HBB_BLOCKSIZE   8192    // > 20 please
10 
11 // Flags:
12 // - ALLOC: the ptr data has been allocated, it can be freed
13 // - PERSISTENT: this is a new history line
14 #define HBB_FLAG_ALLOC      1
15 #define HBB_FLAG_PERSISTENT 2
16 
17 #define HBB_PREFIX_IN         (1U<<0)
18 #define HBB_PREFIX_OUT        (1U<<1)
19 #define HBB_PREFIX_STATUS     (1U<<2)
20 #define HBB_PREFIX_AUTH       (1U<<3)
21 #define HBB_PREFIX_INFO       (1U<<4)
22 #define HBB_PREFIX_ERR        (1U<<5)
23 #define HBB_PREFIX_NOFLAG     (1U<<6)
24 #define HBB_PREFIX_HLIGHT_OUT (1U<<7)
25 #define HBB_PREFIX_HLIGHT     (1U<<8)
26 #define HBB_PREFIX_NONE       (1U<<9)
27 #define HBB_PREFIX_SPECIAL    (1U<<10)
28 #define HBB_PREFIX_PGPCRYPT   (1U<<11)
29 #define HBB_PREFIX_OTRCRYPT   (1U<<12)
30 #define HBB_PREFIX_CONT       (1U<<13)
31 #define HBB_PREFIX_RECEIPT    (1U<<14)
32 #define HBB_PREFIX_READMARK   (1U<<15)
33 #define HBB_PREFIX_DELAYED    (1U<<16)
34 #define HBB_PREFIX_CARBON     (1U<<17)
35 
36 typedef struct {
37   time_t timestamp;
38   guint flags;
39   unsigned mucnicklen;
40   char *text;
41 } hbb_line;
42 
43 void hbuf_add_line(GList **p_hbuf, const char *text, time_t timestamp,
44         guint prefix_flags, guint width, guint maxhbufblocks,
45         unsigned mucnicklen, gpointer xep184);
46 void hbuf_free(GList **p_hbuf);
47 void hbuf_rebuild(GList **p_hbuf, unsigned int width);
48 GList *hbuf_previous_persistent(GList *l_line);
49 
50 hbb_line **hbuf_get_lines(GList *hbuf, unsigned int n);
51 GList *hbuf_search(GList *hbuf, int direction, const char *string);
52 GList *hbuf_jump_date(GList *hbuf, time_t t);
53 GList *hbuf_jump_percent(GList *hbuf, int pc);
54 GList *hbuf_jump_readmark(GList *hbuf);
55 gboolean hbuf_remove_receipt(GList *hbuf, gconstpointer xep184);
56 void hbuf_set_readmark(GList *hbuf, gboolean action);
57 void hbuf_remove_trailing_readmark(GList *hbuf);
58 
59 void hbuf_dump_to_file(GList *hbuf, const char *filename);
60 
61 guint hbuf_get_blocks_number(GList *p_hbuf);
62 
63 #endif /* __MCABBER_HBUF_H__ */
64 
65 /* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2:  For Vim users... */
66