Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/xmpp.c @ 2105:1cc84780eb5f
Very basic carbons support is hacked into mcabber.
Messages are now intercepted and parsed. It probably makes more sense to
implement XEP-0297: Stanza Forwarding in a more general way.
A better way to display the carbons (so the user actually knows it is a carbon
message) is in the pipeline.
author | Roeland Jago Douma <roeland@famdouma.nl> |
---|---|
date | Sun, 03 Mar 2013 14:32:16 +0100 |
parents | 1210a22726d3 |
children | 0c2276f60f78 |
comparison
equal
deleted
inserted
replaced
2104:c7e9950fa741 | 2105:1cc84780eb5f |
---|---|
1271 #endif | 1271 #endif |
1272 } else { | 1272 } else { |
1273 handle_state_events(from, m->node); | 1273 handle_state_events(from, m->node); |
1274 } | 1274 } |
1275 | 1275 |
1276 if (from && (body || subject)) | 1276 // Check for carbons! |
1277 x = lm_message_node_find_xmlns(m->node, NS_CARBONS_2); | |
1278 char carbons = 0; | |
1279 if (x) { | |
1280 carbons = 1; | |
1281 // Parse a message that is send to one of our other resources | |
1282 if (!g_strcmp0(x->name, "received")) { | |
1283 // Go 1 level deeper to the forwarded message | |
1284 x = lm_message_node_find_xmlns(x, "urn:xmpp:forward:0"); | |
1285 x = lm_message_node_get_child(x, "message"); | |
1286 | |
1287 from = lm_message_node_get_attribute(x, "from"); | |
1288 g_free(bjid); | |
1289 bjid = g_strdup(from); | |
1290 res = strchr(bjid, JID_RESOURCE_SEPARATOR); | |
1291 if (res) *res++ = 0; | |
1292 scr_WriteIncomingMessage(bjid, body, timestamp, HBB_PREFIX_IN, 0); | |
1293 | |
1294 scr_LogPrint(LPRINT_NORMAL|LPRINT_DEBUG, "carbon from:%s", lm_message_node_get_attribute(x, "from")); | |
1295 | |
1296 } else if (!g_strcmp0(x->name, "sent")) { | |
1297 x = lm_message_node_find_xmlns(x, "urn:xmpp:forward:0"); | |
1298 x = lm_message_node_get_child(x, "message"); | |
1299 | |
1300 const char *to= lm_message_node_get_attribute(x, "to"); | |
1301 g_free(bjid); | |
1302 bjid = g_strdup(to); | |
1303 res = strchr(bjid, JID_RESOURCE_SEPARATOR); | |
1304 if (res) *res++ = 0; | |
1305 | |
1306 scr_write_outgoing_message(bjid, body, 0, NULL); | |
1307 } | |
1308 } | |
1309 | |
1310 | |
1311 if (from && (body || subject) && !carbons) | |
1277 gotmessage(mstype, from, body, enc, subject, timestamp, | 1312 gotmessage(mstype, from, body, enc, subject, timestamp, |
1278 lm_message_node_find_xmlns(m->node, NS_SIGNED)); | 1313 lm_message_node_find_xmlns(m->node, NS_SIGNED)); |
1279 | 1314 |
1280 // Report received message if message delivery receipt was requested | 1315 // Report received message if message delivery receipt was requested |
1281 if (lm_message_node_get_child(m->node, "request") && | 1316 if (lm_message_node_get_child(m->node, "request") && |