diff options
author | dequis <dx@dxzone.com.ar> | 2015-11-23 19:09:39 -0300 |
---|---|---|
committer | dequis <dx@dxzone.com.ar> | 2015-12-16 12:35:04 -0300 |
commit | d11ccbf6ea94264bde8b0f525c4bbedf50de0174 (patch) | |
tree | 117472f5c00f83d1075bdab41fb1ef2c753544a1 | |
parent | 3a620ff93afb90f1b9114bab0faad65cad5dd80e (diff) |
hipchat: Implement their own variant of self-messages (not working yet)
Reuses part of the carbons code, but it's not like it at all.
To be able to receive these messages at all, a different cap node
whitelisted by them is required. I could have used one of the official
clients, but let's try to get things done the right way.
This will start working once they make that change in their servers,
right now this is still in their ticket backlog. I'm merging this now
because it's harmless and nice to have as part of the upcoming release.
-rw-r--r-- | protocols/jabber/message.c | 12 | ||||
-rw-r--r-- | protocols/jabber/presence.c | 8 |
2 files changed, 19 insertions, 1 deletions
diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c index c57e6337..5a271fa8 100644 --- a/protocols/jabber/message.c +++ b/protocols/jabber/message.c @@ -26,6 +26,7 @@ static xt_status jabber_pkt_message_normal(struct xt_node *node, gpointer data, gboolean carbons_sent) { struct im_connection *ic = data; + struct jabber_data *jd = ic->proto_data; char *from = xt_find_attr(node, carbons_sent ? "to" : "from"); char *type = xt_find_attr(node, "type"); char *id = xt_find_attr(node, "id"); @@ -38,6 +39,17 @@ static xt_status jabber_pkt_message_normal(struct xt_node *node, gpointer data, return XT_HANDLED; /* Consider this packet corrupted. */ } + /* try to detect hipchat's own version of self-messages */ + if (jd->flags & JFLAG_HIPCHAT) { + struct xt_node *c; + + if ((c = xt_find_node_by_attr(node->children, "delay", "xmlns", XMLNS_DELAY)) && + (s = xt_find_attr(c, "from_jid")) && + jabber_compare_jid(s, jd->me)) { + carbons_sent = TRUE; + } + } + if (request && id && g_strcmp0(type, "groupchat") != 0 && !carbons_sent) { /* Send a message receipt (XEP-0184), looking like this: * <message from='...' id='...' to='...'> diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c index 14060148..6ee9ff0a 100644 --- a/protocols/jabber/presence.c +++ b/protocols/jabber/presence.c @@ -221,7 +221,13 @@ int presence_send_update(struct im_connection *ic) Trillian seem to do this right. */ cap = xt_new_node("c", NULL, NULL); xt_add_attr(cap, "xmlns", XMLNS_CAPS); - xt_add_attr(cap, "node", "http://bitlbee.org/xmpp/caps"); + + if (jd->flags & JFLAG_HIPCHAT) { + /* hipchat specific node, whitelisted by request to receive self-messages */ + xt_add_attr(cap, "node", "http://bitlbee.org/xmpp/caps/hipchat"); + } else { + xt_add_attr(cap, "node", "http://bitlbee.org/xmpp/caps"); + } xt_add_attr(cap, "ver", BITLBEE_VERSION); /* The XEP wants this hashed, but nobody's doing that. */ xt_add_child(node, cap); |