pidgin/pidgin

e32ab786a04f
Parents 5933c91abf0c
Children d7e28f8a0994
Finally add XMPP Message Carbons XEP-0280

Initial XMPP message carbons support. Most of the credit goes to Koosha Khajehmoogahi as I pulled most of this from their GSOC 2015 branch.

Testing Done:
Ran side by side with pidgin2 and messaged a separate XMPP account from pidgin2, pidgin3, and conversations on my phone.

Reviewed at https://reviews.imfreedom.org/r/204/
--- a/libpurple/protocols/jabber/disco.c Tue Nov 10 03:00:37 2020 -0600
+++ b/libpurple/protocols/jabber/disco.c Tue Nov 10 03:01:09 2020 -0600
@@ -379,6 +379,16 @@
jabber_request_block_list(js);
}
+ /* If the server supports carbons, enable them! */
+ if(js->server_caps & JABBER_CAP_MESSAGE_CARBONS) {
+ JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET);
+ PurpleXmlNode *enable = purple_xmlnode_new_child(iq->node, "enable");
+
+ purple_xmlnode_set_namespace(enable, NS_MESSAGE_CARBONS);
+
+ jabber_iq_send(iq);
+ }
+
/* If there are manually specified bytestream proxies, query them */
ft_proxies = purple_account_get_string(purple_connection_get_account(js->gc), "ft_proxies", NULL);
if (ft_proxies) {
@@ -538,6 +548,8 @@
js->server_caps |= JABBER_CAP_ADHOC;
} else if (purple_strequal(NS_SIMPLE_BLOCKING, var)) {
js->server_caps |= JABBER_CAP_BLOCKING;
+ } else if (purple_strequal(NS_MESSAGE_CARBONS, var)) {
+ js->server_caps |= JABBER_CAP_MESSAGE_CARBONS;
}
}
--- a/libpurple/protocols/jabber/jabber.h Tue Nov 10 03:00:37 2020 -0600
+++ b/libpurple/protocols/jabber/jabber.h Tue Nov 10 03:01:09 2020 -0600
@@ -50,6 +50,8 @@
JABBER_CAP_ITEMS = 1 << 14,
JABBER_CAP_ROSTER_VERSIONING = 1 << 15,
+ JABBER_CAP_MESSAGE_CARBONS = 1 << 19,
+
JABBER_CAP_RETRIEVED = 1 << 31
} JabberCapabilities;
--- a/libpurple/protocols/jabber/message.c Tue Nov 10 03:00:37 2020 -0600
+++ b/libpurple/protocols/jabber/message.c Tue Nov 10 03:01:09 2020 -0600
@@ -581,12 +581,36 @@
{
JabberMessage *jm;
const char *id, *from, *to, *type;
- PurpleXmlNode *child;
+ PurpleXmlNode *child = NULL, *received = NULL;
gboolean signal_return;
+ /* Check if we have a carbons received element. */
+ received = purple_xmlnode_get_child_with_namespace(packet, "received",
+ NS_MESSAGE_CARBONS);
+ if(received != NULL) {
+ PurpleXmlNode *forwarded = NULL;
+
+ forwarded = purple_xmlnode_get_child_with_namespace(received,
+ "forwarded",
+ NS_FORWARD);
+ if(forwarded != NULL) {
+ PurpleXmlNode *fwd_msg = NULL;
+
+ fwd_msg = purple_xmlnode_get_child_with_namespace(forwarded,
+ "message",
+ NS_XMPP_CLIENT);
+ if(fwd_msg != NULL) {
+ packet = fwd_msg;
+ }
+ }
+ }
+
+ /* If the message was forward, packet is now pointing to the forwarded
+ * message.
+ */
from = purple_xmlnode_get_attrib(packet, "from");
- id = purple_xmlnode_get_attrib(packet, "id");
- to = purple_xmlnode_get_attrib(packet, "to");
+ id = purple_xmlnode_get_attrib(packet, "id");
+ to = purple_xmlnode_get_attrib(packet, "to");
type = purple_xmlnode_get_attrib(packet, "type");
signal_return = GPOINTER_TO_INT(purple_signal_emit_return_1(purple_connection_get_protocol(js->gc),
--- a/libpurple/protocols/jabber/namespaces.h Tue Nov 10 03:00:37 2020 -0600
+++ b/libpurple/protocols/jabber/namespaces.h Tue Nov 10 03:01:09 2020 -0600
@@ -98,6 +98,12 @@
/* XEP-0264 File Transfer Thumbnails (Thumbs) */
#define NS_THUMBS "urn:xmpp:thumbs:0"
+/* XEP-0280 Message Carbons */
+#define NS_MESSAGE_CARBONS "urn:xmpp:carbons:2"
+
+/* XEP-0297 Stanza Forwarding */
+#define NS_FORWARD "urn:xmpp:forward:0"
+
/* Google extensions */
#define NS_GOOGLE_CAMERA "http://www.google.com/xmpp/protocol/camera/v1"
#define NS_GOOGLE_VIDEO "http://www.google.com/xmpp/protocol/video/v1"