1 # HG changeset patch |
|
2 # Parent 99db5d4ed047b3dbe54727c1df311531f611f31f |
|
3 Fix receipts handling according to recent XEP updates |
|
4 |
|
5 * add lm_get_uid() @xmpp_helper.h |
|
6 * identify receipts by id attribute of 'received' subelement |
|
7 instead of stanza id |
|
8 |
|
9 diff -r 99db5d4ed047 mcabber/mcabber/hbuf.c |
|
10 --- a/mcabber/mcabber/hbuf.c Thu Mar 01 20:18:00 2012 +0100 |
|
11 +++ b/mcabber/mcabber/hbuf.c Mon Apr 30 23:10:28 2012 +0300 |
|
12 @@ -525,7 +525,7 @@ |
|
13 // hbuf_remove_receipt(hbuf, xep184) |
|
14 // Remove the Receipt Flag for the message with the given xep184 id |
|
15 // Returns TRUE if it was found and removed, otherwise FALSE |
|
16 -gboolean hbuf_remove_receipt(GList *hbuf, gpointer xep184) |
|
17 +gboolean hbuf_remove_receipt(GList *hbuf, gconstpointer xep184) |
|
18 { |
|
19 hbuf_block *blk; |
|
20 |
|
21 @@ -533,7 +533,8 @@ |
|
22 |
|
23 for ( ; hbuf; hbuf = g_list_previous(hbuf)) { |
|
24 blk = (hbuf_block*)(hbuf->data); |
|
25 - if (blk->prefix.xep184 == xep184) { |
|
26 + if (!g_strcmp0 (blk->prefix.xep184, xep184)) { |
|
27 + g_free (blk->prefix.xep184); |
|
28 blk->prefix.xep184 = NULL; |
|
29 blk->prefix.flags ^= HBB_PREFIX_RECEIPT; |
|
30 return TRUE; |
|
31 diff -r 99db5d4ed047 mcabber/mcabber/hbuf.h |
|
32 --- a/mcabber/mcabber/hbuf.h Thu Mar 01 20:18:00 2012 +0100 |
|
33 +++ b/mcabber/mcabber/hbuf.h Mon Apr 30 23:10:28 2012 +0300 |
|
34 @@ -50,7 +50,7 @@ |
|
35 GList *hbuf_jump_date(GList *hbuf, time_t t); |
|
36 GList *hbuf_jump_percent(GList *hbuf, int pc); |
|
37 GList *hbuf_jump_readmark(GList *hbuf); |
|
38 -gboolean hbuf_remove_receipt(GList *hbuf, gpointer xep184); |
|
39 +gboolean hbuf_remove_receipt(GList *hbuf, gconstpointer xep184); |
|
40 void hbuf_set_readmark(GList *hbuf, gboolean action); |
|
41 void hbuf_remove_trailing_readmark(GList *hbuf); |
|
42 |
|
43 diff -r 99db5d4ed047 mcabber/mcabber/screen.c |
|
44 --- a/mcabber/mcabber/screen.c Thu Mar 01 20:18:00 2012 +0100 |
|
45 +++ b/mcabber/mcabber/screen.c Mon Apr 30 23:10:28 2012 +0300 |
|
46 @@ -2239,7 +2239,7 @@ |
|
47 scr_show_window(jidto, FALSE); |
|
48 } |
|
49 |
|
50 -void scr_remove_receipt_flag(const char *bjid, gpointer xep184) |
|
51 +void scr_remove_receipt_flag(const char *bjid, gconstpointer xep184) |
|
52 { |
|
53 winbuf *win_entry = scr_search_window(bjid, FALSE); |
|
54 if (win_entry) { |
|
55 diff -r 99db5d4ed047 mcabber/mcabber/screen.h |
|
56 --- a/mcabber/mcabber/screen.h Thu Mar 01 20:18:00 2012 +0100 |
|
57 +++ b/mcabber/mcabber/screen.h Mon Apr 30 23:10:28 2012 +0300 |
|
58 @@ -108,7 +108,7 @@ |
|
59 void scr_update_main_status(int forceupdate); |
|
60 void scr_update_chat_status(int forceupdate); |
|
61 void scr_roster_visibility(int status); |
|
62 -void scr_remove_receipt_flag(const char *jidto, gpointer xep184); |
|
63 +void scr_remove_receipt_flag(const char *jidto, gconstpointer xep184); |
|
64 void scr_show_buddy_window(void); |
|
65 int scr_buddy_buffer_exists(const char *jid); |
|
66 void scr_update_buddy_window(void); |
|
67 diff -r 99db5d4ed047 mcabber/mcabber/xmpp.c |
|
68 --- a/mcabber/mcabber/xmpp.c Thu Mar 01 20:18:00 2012 +0100 |
|
69 +++ b/mcabber/mcabber/xmpp.c Mon Apr 30 23:10:28 2012 +0300 |
|
70 @@ -295,15 +295,6 @@ |
|
71 g_slist_free(resources); |
|
72 } |
|
73 |
|
74 -static LmHandlerResult cb_xep184(LmMessageHandler *h, LmConnection *c, |
|
75 - LmMessage *m, gpointer user_data) |
|
76 -{ |
|
77 - char *from = jidtodisp(lm_message_get_from(m)); |
|
78 - scr_remove_receipt_flag(from, h); |
|
79 - g_free(from); |
|
80 - return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
|
81 -} |
|
82 - |
|
83 // xmpp_send_msg(jid, text, type, subject, |
|
84 // otrinject, *encrypted, type_overwrite) |
|
85 // When encrypted is not NULL, the function set *encrypted to 1 if the |
|
86 @@ -432,7 +423,8 @@ |
|
87 lm_message_node_set_attribute |
|
88 (lm_message_node_add_child(x->node, "request", NULL), |
|
89 "xmlns", NS_RECEIPTS); |
|
90 - *xep184 = lm_message_handler_new(cb_xep184, NULL, NULL); |
|
91 + *xep184 = lm_get_uid (); |
|
92 + lm_message_node_set_attribute (x->node, "id", (const gchar *)*xep184); |
|
93 } |
|
94 g_free(barejid); |
|
95 |
|
96 @@ -499,11 +491,7 @@ |
|
97 if (mystatus != invisible) |
|
98 #endif |
|
99 update_last_use(); |
|
100 - if (xep184 && *xep184) { |
|
101 - lm_connection_send_with_reply(lconnection, x, *xep184, NULL); |
|
102 - lm_message_handler_unref(*xep184); |
|
103 - } else |
|
104 - lm_connection_send(lconnection, x, NULL); |
|
105 + lm_connection_send(lconnection, x, NULL); |
|
106 lm_message_unref(x); |
|
107 } |
|
108 |
|
109 @@ -1305,6 +1293,16 @@ |
|
110 lm_message_unref(rcvd); |
|
111 } |
|
112 |
|
113 + { // xep184 receipt confirmation |
|
114 + LmMessageNode *received = lm_message_node_get_child (m->node, "received"); |
|
115 + if (received && !g_strcmp0 (lm_message_node_get_attribute (received, "xmlns"), NS_RECEIPTS)) { |
|
116 + char *jid = jidtodisp(from); |
|
117 + const char *id = lm_message_node_get_attribute (received, "id"); |
|
118 + scr_remove_receipt_flag(jid, id); |
|
119 + g_free(jid); |
|
120 + } |
|
121 + } |
|
122 + |
|
123 if (from) { |
|
124 x = lm_message_node_find_xmlns(m->node, NS_MUC_USER); |
|
125 if (x && !strcmp(x->name, "x")) |
|
126 diff -r 99db5d4ed047 mcabber/mcabber/xmpp_helper.c |
|
127 --- a/mcabber/mcabber/xmpp_helper.c Thu Mar 01 20:18:00 2012 +0100 |
|
128 +++ b/mcabber/mcabber/xmpp_helper.c Mon Apr 30 23:10:28 2012 +0300 |
|
129 @@ -72,7 +72,6 @@ |
|
130 {0, NULL, NULL, NULL, NULL} |
|
131 }; |
|
132 |
|
133 - |
|
134 #ifdef MODULES_ENABLE |
|
135 static GSList *xmpp_additional_features = NULL; |
|
136 static char *ver, *ver_notavail; |
|
137 @@ -104,6 +103,13 @@ |
|
138 } |
|
139 #endif |
|
140 |
|
141 +// The caller must g_free this after use |
|
142 +gchar *lm_get_uid () |
|
143 +{ |
|
144 + static guint xmpp_uid = 0; |
|
145 + return g_strdup_printf ("mc%u", ++xmpp_uid); |
|
146 +} |
|
147 + |
|
148 const gchar* lm_message_node_get_child_value(LmMessageNode *node, |
|
149 const gchar *child) |
|
150 { |
|
151 diff -r 99db5d4ed047 mcabber/mcabber/xmpp_helper.h |
|
152 --- a/mcabber/mcabber/xmpp_helper.h Thu Mar 01 20:18:00 2012 +0100 |
|
153 +++ b/mcabber/mcabber/xmpp_helper.h Mon Apr 30 23:10:28 2012 +0300 |
|
154 @@ -29,6 +29,8 @@ |
|
155 void xmpp_del_feature (const char *xmlns); |
|
156 #endif |
|
157 |
|
158 +gchar *lm_get_uid (void); |
|
159 + |
|
160 LmMessageNode *lm_message_node_new(const gchar *name, const gchar *xmlns); |
|
161 LmMessageNode *lm_message_node_find_xmlns(LmMessageNode *node, |
|
162 const char *xmlns); |
|