Changeset fa8f57b for protocols/jabber/message.c
- Timestamp:
- 2015-11-21T03:01:05Z (8 years ago)
- Branches:
- master
- Children:
- 2f8e3ca
- Parents:
- 8fdeaa5
- git-author:
- dequis <dx@…> (21-11-15 02:04:06)
- git-committer:
- dequis <dx@…> (21-11-15 03:01:05)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/message.c
r8fdeaa5 rfa8f57b 24 24 #include "jabber.h" 25 25 26 xt_status jabber_pkt_message(struct xt_node *node, gpointer data)26 static xt_status jabber_pkt_message_normal(struct xt_node *node, gpointer data, gboolean carbons_sent) 27 27 { 28 28 struct im_connection *ic = data; 29 char *from = xt_find_attr(node, "from");29 char *from = xt_find_attr(node, carbons_sent ? "to" : "from"); 30 30 char *type = xt_find_attr(node, "type"); 31 31 char *id = xt_find_attr(node, "id"); … … 39 39 } 40 40 41 if (request && id && g_strcmp0(type, "groupchat") != 0 ) {41 if (request && id && g_strcmp0(type, "groupchat") != 0 && !carbons_sent) { 42 42 /* Send a message receipt (XEP-0184), looking like this: 43 43 * <message from='...' id='...' to='...'> … … 128 128 if (fullmsg->len > 0) { 129 129 imcb_buddy_msg(ic, from, fullmsg->str, 130 0, jabber_get_timestamp(node));130 carbons_sent ? OPT_SELFMESSAGE : 0, jabber_get_timestamp(node)); 131 131 } 132 132 if (room) { … … 137 137 138 138 /* Handling of incoming typing notifications. */ 139 if (bud == NULL) { 140 /* Can't handle these for unknown buddies. */ 139 if (bud == NULL || carbons_sent) { 140 /* Can't handle these for unknown buddies. 141 And ignore them if it's just carbons */ 141 142 } else if (xt_find_node(node->children, "composing")) { 142 143 bud->flags |= JBFLAG_DOES_XEP85; … … 162 163 return XT_HANDLED; 163 164 } 165 166 static xt_status jabber_carbons_message(struct xt_node *node, gpointer data) 167 { 168 struct im_connection *ic = data; 169 struct xt_node *wrap, *fwd, *msg; 170 gboolean carbons_sent; 171 172 if ((wrap = xt_find_node(node->children, "received"))) { 173 carbons_sent = FALSE; 174 } else if ((wrap = xt_find_node(node->children, "sent"))) { 175 carbons_sent = TRUE; 176 } 177 178 if (wrap == NULL || g_strcmp0(xt_find_attr(wrap, "xmlns"), XMLNS_CARBONS) != 0) { 179 return XT_NEXT; 180 } 181 182 if (!(fwd = xt_find_node(wrap->children, "forwarded")) || 183 (g_strcmp0(xt_find_attr(fwd, "xmlns"), XMLNS_FORWARDING) != 0) || 184 !(msg = xt_find_node(fwd->children, "message"))) { 185 imcb_log(ic, "Error: Invalid carbons message received"); 186 return XT_ABORT; 187 } 188 189 return jabber_pkt_message_normal(msg, data, carbons_sent); 190 } 191 192 xt_status jabber_pkt_message(struct xt_node *node, gpointer data) 193 { 194 struct im_connection *ic = data; 195 struct jabber_data *jd = ic->proto_data; 196 char *from = xt_find_attr(node, "from"); 197 198 if (jabber_compare_jid(jd->me, from)) { /* Probably a Carbons message */ 199 xt_status st = jabber_carbons_message(node, data); 200 if (st == XT_HANDLED || st == XT_ABORT) { 201 return st; 202 } 203 } 204 return jabber_pkt_message_normal(node, data, FALSE); 205 }
Note: See TracChangeset
for help on using the changeset viewer.